Файл: modules/wysibb/jquery.wysibb.min.js
Строк: 2788
<?php
/*! WysiBB - WYSIWYG BBCode editor - v1.4.2 - 2013-04-06
* http://www.wysibb.com
* Copyright (c) 2013 Vadim Dobroskok; Licensed MIT, GPL */
typeof WBBLANG=="undefined"&&(WBBLANG={}),WBBLANG.ru=CURLANG={bold:"Полужирный",italic:"Курсив",underline:"Подчеркнутый",strike:"Зачеркнутый",link:"Ссылка",img:"Изображение",sup:"Надстрочный текст",sub:"Подстрочный текст",justifyleft:"Текст по левому краю",justifycenter:"Текст по центру",justifyright:"Текст по правому краю",table:"Вставить таблицу",bullist:"Обычный список",numlist:"Нумерованный список",quote:"Цитата",offtop:"Оффтоп",code:"Код",spoiler:"Сворачиваемый текст",fontcolor:"Цвет текста",fontsize:"Размер текста",fontfamily:"Шрифт текста",fs_verysmall:"Очень маленький",fs_small:"Маленький",fs_normal:"Нормальный",fs_big:"Большой",fs_verybig:"Очень большой",smilebox:"Вставить смайл",video:"Вставить видео",removeFormat:"Удалить форматирование",modal_link_title:"Вставить ссылку",modal_link_text:"Отображаемый текст",modal_link_url:"URL ссылки",modal_email_text:"Отображаемый эл.адрес",modal_email_url:"Email",modal_link_tab1:"Вставить URL",modal_img_title:"Вставить изображение",modal_img_tab1:"Ввести URL",modal_img_tab2:"Загрузить файл",modal_imgsrc_text:"Введите адрес изображения",modal_img_btn:"Выберите файл для загрузки",add_attach:"Добавить вложение",modal_video_text:"Введите URL видео",close:"Закрыть",save:"Сохранить",cancel:"Отмена",remove:"Удалить",validation_err:"Введенные данные некорректны",error_onupload:"Ошибка во время загрузки файла или такое расширение файла не поддерживается",fileupload_text1:"Перетащите файл сюда",fileupload_text2:"или",loading:"Загрузка",auto:"Авто",views:"Просмотров",downloads:"Скачиваний",sm1:"Улыбка",sm2:"Смех",sm3:"Подмигивание",sm4:"Спасибо, класс",sm5:"Ругаю",sm6:"Шок",sm7:"Злой",sm8:"Огорчение",sm9:"Тошнит"},wbbdebug=!0,function(e){"use strict";e.wysibb=function(t,n){e(t).data("wbb",this),n&&n.deflang&&typeof WBBLANG[n.deflang]!="undefined"&&(CURLANG=WBBLANG[n.deflang]),n&&n.lang&&typeof WBBLANG[n.lang]!="undefined"&&(CURLANG=WBBLANG[n.lang]),this.txtArea=t,this.$txtArea=e(t);var r=this.$txtArea.attr("id")||this.setUID(this.txtArea);this.options={bbmode:!1,onlyBBmode:!1,themeName:"default",bodyClass:"",lang:"ru",tabInsert:!0,imgupload:!0,img_uploadurl:"/iupload.php",img_maxwidth:800,img_maxheight:800,hotkeys:!0,showHotkeys:!0,autoresize:!0,resize_maxheight:800,loadPageStyles:!0,traceTextarea:!0,smileConversion:!0,buttons:"bold,italic,underline,strike,sup,sub,|,img,video,link,|,bullist,numlist,smilebox,|,fontcolor,fontsize,fontfamily,|,justifyleft,justifycenter,justifyright,|,quote,code,offtop,table,removeFormat",allButtons:{bold:{title:CURLANG.bold,buttonHTML:'<span class="fonticon ve-tlb-bold1"></span>',excmd:"bold",hotkey:"ctrl+b",transform:{"<b>{SELTEXT}</b>":"[b]{SELTEXT}[/b]","<strong>{SELTEXT}</strong>":"[b]{SELTEXT}[/b]"}},italic:{title:CURLANG.italic,buttonHTML:'<span class="fonticon ve-tlb-italic1"></span>',excmd:"italic",hotkey:"ctrl+i",transform:{"<i>{SELTEXT}</i>":"[i]{SELTEXT}[/i]","<em>{SELTEXT}</em>":"[i]{SELTEXT}[/i]"}},underline:{title:CURLANG.underline,buttonHTML:'<span class="fonticon ve-tlb-underline1"></span>',excmd:"underline",hotkey:"ctrl+u",transform:{"<u>{SELTEXT}</u>":"[u]{SELTEXT}[/u]"}},strike:{title:CURLANG.strike,buttonHTML:'<span class="fonticon fi-stroke1 ve-tlb-strike1"></span>',excmd:"strikeThrough",transform:{"<strike>{SELTEXT}</strike>":"[s]{SELTEXT}[/s]","<s>{SELTEXT}</s>":"[s]{SELTEXT}[/s]"}},sup:{title:CURLANG.sup,buttonHTML:'<span class="fonticon ve-tlb-sup1"></span>',excmd:"superscript",transform:{"<sup>{SELTEXT}</sup>":"[sup]{SELTEXT}[/sup]"}},sub:{title:CURLANG.sub,buttonHTML:'<span class="fonticon ve-tlb-sub1"></span>',excmd:"subscript",transform:{"<sub>{SELTEXT}</sub>":"[sub]{SELTEXT}[/sub]"}},link:{title:CURLANG.link,buttonHTML:'<span class="fonticon ve-tlb-link1"></span>',hotkey:"ctrl+shift+2",modal:{title:CURLANG.modal_link_title,width:"500px",tabs:[{input:[{param:"SELTEXT",title:CURLANG.modal_link_text,type:"div"},{param:"URL",title:CURLANG.modal_link_url,validation:"^http(s)?://"}]}]},transform:{'<a href="{URL}">{SELTEXT}</a>':"[url={URL}]{SELTEXT}[/url]",'<a href="{URL}">{URL}</a>':"[url]{URL}[/url]"}},img:{title:CURLANG.img,buttonHTML:'<span class="fonticon ve-tlb-img1"></span>',hotkey:"ctrl+shift+1",modal:{title:CURLANG.modal_img_title,width:"600px",tabs:[{title:CURLANG.modal_img_tab1,input:[{param:"SRC",title:CURLANG.modal_imgsrc_text,validation:"^http(s)?://.*?.(jpg|png|gif|jpeg)$"}]},{title:CURLANG.modal_img_tab2,html:'<div id="imguploader"> <form id="fupform" class="upload" action="{img_uploadurl}" method="post" enctype="multipart/form-data" target="fupload"><input type="hidden" name="iframe" value="1"/><input type="hidden" name="idarea" value="'+r+'" /><div class="fileupload"><input id="fileupl" class="file" type="file" name="img" /><button id="nicebtn" class="wbb-button">'+CURLANG.modal_img_btn+'</button> </div> </form> </div><iframe id="fupload" name="fupload" src="about:blank" frameborder="0" style="width:0px;height:0px;display:none"></iframe></div>'}],onLoad:this.imgLoadModal},transform:{'<img src="{SRC}" />':"[img]{SRC}[/img]",'<img src="{SRC}" width="{WIDTH}" height="{HEIGHT}"/>':"[img width={WIDTH},height={HEIGHT}]{SRC}[/img]"}},bullist:{title:CURLANG.bullist,buttonHTML:'<span class="fonticon ve-tlb-list1"></span>',excmd:"insertUnorderedList",transform:{"<ul>{SELTEXT}</ul>":"[list]{SELTEXT}[/list]","<li>{SELTEXT}</li>":"[*]{SELTEXT}[/*]"}},numlist:{title:CURLANG.numlist,buttonHTML:'<span class="fonticon ve-tlb-numlist1"></span>',excmd:"insertOrderedList",transform:{"<ol>{SELTEXT}</ol>":"[list=1]{SELTEXT}[/list]","<li>{SELTEXT}</li>":"[*]{SELTEXT}[/*]"}},quote:{title:CURLANG.quote,buttonHTML:'<span class="fonticon ve-tlb-quote1"></span>',hotkey:"ctrl+shift+3",transform:{'<div class="quote">{SELTEXT}</div>':"[quote]{SELTEXT}[/quote]"}},code:{title:CURLANG.code,buttonText:"[code]",hotkey:"ctrl+shift+4",onlyClearText:!0,transform:{'<div class="codewrap"><div class="codetop" contenteditable="false">Код:</div><div class="codemain">{SELTEXT}</div></div>':"[code]{SELTEXT}[/code]"}},offtop:{title:CURLANG.offtop,buttonText:"offtop",transform:{'<span style="font-size:10px;color:#ccc">{SELTEXT}</span>':"[offtop]{SELTEXT}[/offtop]"}},fontcolor:{type:"colorpicker",title:CURLANG.fontcolor,excmd:"foreColor",valueBBname:"color",subInsert:!0,colors:"#000000,#444444,#666666,#999999,#b6b6b6,#cccccc,#d8d8d8,#efefef,#f4f4f4,#ffffff,-, #ff0000,#980000,#ff7700,#ffff00,#00ff00,#00ffff,#1e84cc,#0000ff,#9900ff,#ff00ff,-, #f4cccc,#dbb0a7,#fce5cd,#fff2cc,#d9ead3,#d0e0e3,#c9daf8,#cfe2f3,#d9d2e9,#ead1dc, #ea9999,#dd7e6b,#f9cb9c,#ffe599,#b6d7a8,#a2c4c9,#a4c2f4,#9fc5e8,#b4a7d6,#d5a6bd, #e06666,#cc4125,#f6b26b,#ffd966,#93c47d,#76a5af,#6d9eeb,#6fa8dc,#8e7cc3,#c27ba0, #cc0000,#a61c00,#e69138,#f1c232,#6aa84f,#45818e,#3c78d8,#3d85c6,#674ea7,#a64d79, #900000,#85200C,#B45F06,#BF9000,#38761D,#134F5C,#1155Cc,#0B5394,#351C75,#741B47, #660000,#5B0F00,#783F04,#7F6000,#274E13,#0C343D,#1C4587,#073763,#20124D,#4C1130",transform:{'<font color="{COLOR}">{SELTEXT}</font>':"[color={COLOR}]{SELTEXT}[/color]"}},table:{type:"table",title:CURLANG.table,cols:10,rows:10,cellwidth:15,transform:{"<td>{SELTEXT}</td>":"[td]{SELTEXT}[/td]","<tr>{SELTEXT}</tr>":"[tr]{SELTEXT}[/tr]",'<table class="wbb-table">{SELTEXT}</table>':"[table]{SELTEXT}[/table]"},skipRules:!0},fontsize:{type:"select",title:CURLANG.fontsize,options:"fs_verysmall,fs_small,fs_normal,fs_big,fs_verybig"},fontfamily:{type:"select",title:CURLANG.fontfamily,excmd:"fontName",valueBBname:"font",options:[{title:"Arial",exvalue:"Arial"},{title:"Comic Sans MS",exvalue:"Comic Sans MS"},{title:"Courier New",exvalue:"Courier New"},{title:"Georgia",exvalue:"Georgia"},{title:"Lucida Sans Unicode",exvalue:"Lucida Sans Unicode"},{title:"Tahoma",exvalue:"Tahoma"},{title:"Times New Roman",exvalue:"Times New Roman"},{title:"Trebuchet MS",exvalue:"Trebuchet MS"},{title:"Verdana",exvalue:"Verdana"}],transform:{'<font face="{FONT}">{SELTEXT}</font>':"[font={FONT}]{SELTEXT}[/font]"}},smilebox:{type:"smilebox",title:CURLANG.smilebox,buttonHTML:'<span class="fonticon ve-tlb-smilebox1"></span>'},justifyleft:{title:CURLANG.justifyleft,buttonHTML:'<span class="fonticon ve-tlb-textleft1"></span>',groupkey:"align",transform:{'<p style="text-align:left">{SELTEXT}</p>':"[left]{SELTEXT}[/left]"}},justifyright:{title:CURLANG.justifyright,buttonHTML:'<span class="fonticon ve-tlb-textright1"></span>',groupkey:"align",transform:{'<p style="text-align:right">{SELTEXT}</p>':"[right]{SELTEXT}[/right]"}},justifycenter:{title:CURLANG.justifycenter,buttonHTML:'<span class="fonticon ve-tlb-textcenter1"></span>',groupkey:"align",transform:{'<p style="text-align:center">{SELTEXT}</p>':"[center]{SELTEXT}[/center]"}},video:{title:CURLANG.video,buttonHTML:'<span class="fonticon ve-tlb-video1"></span>',modal:{title:CURLANG.video,width:"600px",tabs:[{title:CURLANG.video,input:[{param:"SRC",title:CURLANG.modal_video_text}]}],onSubmit:function(e,t,n){var r=this.$modal.find('input[name="SRC"]').val();r&&(r=r.replace(/^s+/,"").replace(/s+$/,""));var i;r.indexOf("youtu.be")!=-1?i=r.match(/^http://youtu.be/([a-z0-9_-]+)/i):i=r.match(/^http://www.youtube.com/watch?.*?v=([a-z0-9_-]+)/i);if(i&&i.length==2){var s=i[1];this.insertAtCursor(this.getCodeByCommand(e,{src:s}))}return this.closeModal(),this.updateUI(),!1}},transform:{'<iframe src="http://www.youtube.com/embed/{SRC}" width="640" height="480" frameborder="0"></iframe>':"[video]{SRC}[/video]"}},fs_verysmall:{title:CURLANG.fs_verysmall,buttonText:"fs1",excmd:"fontSize",exvalue:"1",transform:{'<font size="1">{SELTEXT}</font>':"[size=50]{SELTEXT}[/size]"}},fs_small:{title:CURLANG.fs_small,buttonText:"fs2",excmd:"fontSize",exvalue:"2",transform:{'<font size="2">{SELTEXT}</font>':"[size=85]{SELTEXT}[/size]"}},fs_normal:{title:CURLANG.fs_normal,buttonText:"fs3",excmd:"fontSize",exvalue:"3",transform:{'<font size="3">{SELTEXT}</font>':"[size=100]{SELTEXT}[/size]"}},fs_big:{title:CURLANG.fs_big,buttonText:"fs4",excmd:"fontSize",exvalue:"4",transform:{'<font size="4">{SELTEXT}</font>':"[size=150]{SELTEXT}[/size]"}},fs_verybig:{title:CURLANG.fs_verybig,buttonText:"fs5",excmd:"fontSize",exvalue:"6",transform:{'<font size="6">{SELTEXT}</font>':"[size=200]{SELTEXT}[/size]"}},removeformat:{title:CURLANG.removeFormat,buttonHTML:'<span class="fonticon ve-tlb-removeformat1"></span>',excmd:"removeFormat"}},systr:{"<br/>":"n",'<span class="wbbtab">{SELTEXT}</span>':" {SELTEXT}"},customRules:{td:[["[td]{SELTEXT}[/td]",{seltext:{rgx:!1,attr:!1,sel:!1}}]],tr:[["[tr]{SELTEXT}[/tr]",{seltext:{rgx:!1,attr:!1,sel:!1}}]],table:[["[table]{SELTEXT}[/table]",{seltext:{rgx:!1,attr:!1,sel:!1}}]]},smileList:[{title:CURLANG.sm1,img:'<img src="{themePrefix}{themeName}/img/smiles/sm1.png" class="sm">',bbcode:":)"},{title:CURLANG.sm8,img:'<img src="{themePrefix}{themeName}/img/smiles/sm8.png" class="sm">',bbcode:":("},{title:CURLANG.sm1,img:'<img src="{themePrefix}{themeName}/img/smiles/sm2.png" class="sm">',bbcode:":D"},{title:CURLANG.sm3,img:'<img src="{themePrefix}{themeName}/img/smiles/sm3.png" class="sm">',bbcode:";)"},{title:CURLANG.sm4,img:'<img src="{themePrefix}{themeName}/img/smiles/sm4.png" class="sm">',bbcode:":up:"},{title:CURLANG.sm5,img:'<img src="{themePrefix}{themeName}/img/smiles/sm5.png" class="sm">',bbcode:":down:"},{title:CURLANG.sm6,img:'<img src="{themePrefix}{themeName}/img/smiles/sm6.png" class="sm">',bbcode:":shock:"},{title:CURLANG.sm7,img:'<img src="{themePrefix}{themeName}/img/smiles/sm7.png" class="sm">',bbcode:":angry:"},{title:CURLANG.sm9,img:'<img src="{themePrefix}{themeName}/img/smiles/sm9.png" class="sm">',bbcode:":sick:"}],attrWrap:["src","color","href"]},this.inited=this.options.onlyBBmode,this.options.themePrefix||e("link").each(e.proxy(function(t,n){var r=e(n).get(0).href.match(/(.*/)(.*)/wbbtheme.css.*$/);r!==null&&(this.options.themeName=r[2],this.options.themePrefix=r[1])},this)),typeof WBBPRESET!="undefined"&&(WBBPRESET.allButtons&&e.each(WBBPRESET.allButtons,e.proxy(function(e,t){t.transform&&this.options.allButtons[e]&&delete this.options.allButtons[e].transform},this)),e.extend(!0,this.options,WBBPRESET)),n&&n.allButtons&&e.each(n.allButtons,e.proxy(function(e,t){t.transform&&this.options.allButtons[e]&&delete this.options.allButtons[e].transform},this)),e.extend(!0,this.options,n),this.init()},e.wysibb.prototype={lastid:1,init:function(){e.log("Init",this),this.isMobile=function(e){/android|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|meego.+mobile|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(e)}(navigator.userAgent||navigator.vendor||window.opera),this.isMobile&&(this.options.onlyBBmode=this.options.bbmode=!0),this.options.onlyBBmode===!0&&(this.options.bbmode=!0),this.controllers=[],this.options.buttons=this.options.buttons.toLowerCase(),this.options.buttons=this.options.buttons.split(","),this.options.allButtons._systr={},this.options.allButtons._systr.transform=this.options.systr,this.smileFind(),this.initTransforms(),this.build(),this.initModal(),this.options.hotkeys===!0&&!this.isMobile&&this.initHotkeys(),this.options.smileList&&this.options.smileList.length>0&&this.options.smileList.sort(function(e,t){return t.bbcode.length-e.bbcode.length}),this.$txtArea.parents("form").bind("submit",e.proxy(function(){return this.sync(),!0},this)),this.$txtArea.parents("form").find("input[id*='preview'],input[id*='submit'],input[class*='preview'],input[class*='submit'],input[name*='preview'],input[name*='submit']").bind("mousedown",e.proxy(function(){this.sync(),setTimeout(e.proxy(function(){this.options.bbmode===!1&&this.$txtArea.removeAttr("wbbsync").val("")},this),1e3)},this)),this.options.initCallback&&this.options.initCallback.call(this),e.log(this)},initTransforms:function(){e.log("Create rules for transform HTML=>BB");var t=this.options;t.rules||(t.rules={}),t.groups||(t.groups={});var n=t.buttons.slice();n.push("_systr");for(var r=0;r<n.length;r++){var i=t.allButtons[n[r]];if(!i)continue;i.en=!0,i.simplebbcode&&e.isArray(i.simplebbcode)&&i.simplebbcode.length==2&&(i.bbcode=i.html=i.simplebbcode[0]+"{SELTEXT}"+i.simplebbcode[1],i.transform&&delete i.transform,i.modal&&delete i.modal);if(i.type=="select"&&typeof i.options=="string"){var s=i.options.split(",");e.each(s,function(t,r){e.inArray(r,n)==-1&&n.push(r)})}if(i.transform&&i.skipRules!==!0){var o=e.extend({},i.transform);for(var u in o){var a=u,f=i.transform[u];i.bbSelector||(i.bbSelector=[]),e.inArray(f,i.bbSelector)==-1&&i.bbSelector.push(f);if(this.options.onlyBBmode===!1){u=this.wrapAttrs(u);var l=e(document.createElement("DIV")).append(e(this.elFromString(u,document))),c=this.filterByNode(l.children());if(c=="div"||typeof t.rules[c]!="undefined"){e.log("create unique selector: "+c),this.setUID(l.children()),c=this.filterByNode(l.children());var h=l.html();h=this.unwrapAttrs(h);var p=this.unwrapAttrs(u);i.transform[h]=f,delete i.transform[p],u=h,a=h}i.excmd||(i.rootSelector||(i.rootSelector=[]),i.rootSelector.push(c)),typeof t.rules[c]=="undefined"&&(t.rules[c]=[]);var d={};if(u.match(/{S+?}/)){l.find("*").each(e.proxy(function(t,n){var r=this.getAttributeList(n);e.each(r,e.proxy(function(t,r){var i=e(n).attr(r);r.substr(0,1)=="_"&&(r=r.substr(1));var s=i.match(/{S+?}/g);if(s)for(var o=0;o<s.length;o++){var u=s[o].substr(1,s[o].length-2);u=u.replace(this.getValidationRGX(u),"");var a=this.relFilterByNode(n,c),f=i!=s[o]?this.getRegexpReplace(i,s[o]):!1;d[u.toLowerCase()]={sel:a?e.trim(a):!1,attr:r,rgx:f}}},this));var i=[];e(n).is("iframe")||e(n).contents().filter(function(){return this.nodeType===3}).each(e.proxy(function(t,r){var s=r.textContent||r.data;if(typeof s=="undefined")return!0;var o=s.match(/{S+?}/g);if(o)for(var u=0;u<o.length;u++){var a=o[u].substr(1,o[u].length-2);a=a.replace(this.getValidationRGX(a),"");var f=this.relFilterByNode(n,c),l=s!=o[u]?this.getRegexpReplace(s,o[u]):!1,h=f?e.trim(f):!1;if(e.inArray(h,i)>-1||e(r).parent().contents().size()>1){var p=e("<span>").html("{"+a+"}");this.setUID(p,"wbb");var v=s.indexOf(a)+a.length+1,m=s.substr(v,s.length-v);r.data=s.substr(0,s.indexOf(a)-1),e(r).after(this.elFromString(m,document)).after(p),h=(h?h+" ":"")+this.filterByNode(p),l=!1}d[a.toLowerCase()]={sel:h,attr:!1,rgx:l},i[i.length]=h}},this)),i=null},this));var v=l.html();v=this.unwrapAttrs(v),a!=v&&(delete i.transform[a],i.transform[v]=f,u=v)}t.rules[c].push([f,d]),i.onlyClearText===!0&&(this.cleartext||(this.cleartext={}),this.cleartext[c]=n[r]),i.groupkey&&(t.groups[i.groupkey]||(t.groups[i.groupkey]=[]),t.groups[i.groupkey].push(c))}}i.rootSelector&&this.sortArray(i.rootSelector,-1);var m=e.map(i.transform,function(e,t){return t}).sort(function(e,t){return(t[0]||"").length-(e[0]||"").length});i.bbcode=i.transform[m[0]],i.html=m[0]}}this.options.btnlist=n,e.extend(t.rules,this.options.customRules),t.srules={},this.options.smileList&&e.each(t.smileList,e.proxy(function(n,r){var i=e(this.strf(r.img,t)),s=this.filterByNode(i);t.srules[s]=[r.bbcode,r.img]},this));for(var g in t.rules)this.options.rules[g].sort(function(e,t){return t[0].length-e[0].length});this.rsellist=[];for(var g in this.options.rules)this.rsellist.push(g);this.sortArray(this.rsellist,-1)},build:function(){e.log("Build editor"),this.$editor=e("<div>").addClass("wysibb"),this.options.direction&&this.$editor.css("direction",this.options.direction),this.$editor.insertAfter(this.txtArea).append(this.txtArea),this.startHeight=this.$txtArea.outerHeight(),this.$txtArea.addClass("wysibb-texarea"),this.buildToolbar(),this.$txtArea.wrap('<div class="wysibb-text">');if(this.options.onlyBBmode===!1){var t=this.options.minheight||this.$txtArea.outerHeight(),n=this.options.resize_maxheight,r=this.options.autoresize===!0?this.options.resize_maxheight:t;this.$body=e(this.strf('<div class="wysibb-text-editor" style="max-height:{maxheight}px;min-height:{height}px"></iframe>',{maxheight:r,height:t})).insertAfter(this.$txtArea),this.body=this.$body[0],this.$txtArea.hide(),e.log("WysiBB loaded"),this.$body.addClass("wysibb-body").addClass(this.options.bodyClass),this.options.direction&&this.$body.css("direction",this.options.direction);if("contentEditable"in this.body){this.body.contentEditable=!0;try{document.execCommand("StyleWithCSS",!1,!1),this.$body.append("<span></span>")}catch(i){}}else this.options.onlyBBmode=this.options.bbmode=!0;this.txtArea.value.length>0&&this.txtAreaInitContent(),this.$body.bind("keydown",e.proxy(function(t){if(t.which==86&&(t.ctrlKey==1||t.metaKey==1)||t.which==45&&(t.shiftKey==1||t.metaKey==1))return this.$pasteBlock||(this.saveRange(),this.$pasteBlock=e(this.elFromString('<div style="opacity:0;" contenteditable="true"></div>')),this.$pasteBlock.appendTo(this.body),e.support.htmlSerialize||this.$pasteBlock.focus(),setTimeout(e.proxy(function(){this.clearPaste(this.$pasteBlock);var e="<span>"+this.$pasteBlock.html()+"</span>";this.$body.attr("contentEditable","true"),this.$pasteBlock.blur().remove(),this.body.focus(),this.cleartext&&this.isInClearTextBlock()&&(e=this.toBB(e).replace(/n/g,"<br/>").replace(/s{3}/g,'<span class="wbbtab"></span>')),e=e.replace(/t/g,'<span class="wbbtab"></span>'),this.selectRange(this.lastRange),this.insertAtCursor(e,!1),this.lastRange=!1,this.$pasteBlock=!1},this),1),this.selectNode(this.$pasteBlock[0])),!0},this)),this.$body.bind("keydown",e.proxy(function(e){if(e.which==13){var t=this.isContain(this.getSelectNode(),"li");t||(e.preventDefault&&e.preventDefault(),this.checkForLastBR(this.getSelectNode()),this.insertAtCursor("<br/>",!1))}},this)),this.options.tabInsert===!0&&this.$body.bind("keydown",e.proxy(this.pressTab,this)),this.$body.bind("mouseup keyup",e.proxy(this.updateUI,this)),this.$body.bind("mousedown",e.proxy(function(e){this.clearLastRange(),this.checkForLastBR(e.target)},this)),this.options.traceTextarea===!0&&(e(document).bind("mousedown",e.proxy(this.traceTextareaEvent,this)),this.$txtArea.val("")),this.options.hotkeys===!0&&this.$body.bind("keydown",e.proxy(this.presskey,this)),this.options.smileConversion===!0&&this.$body.bind("keyup",e.proxy(this.smileConversion,this)),this.inited=!0,this.options.autoresize===!0&&(this.$bresize=e(this.elFromString('<div class="bottom-resize-line"></div>')).appendTo(this.$editor).wdrag({scope:this,axisY:!0,height:t}))}this.$editor.append('<span class="powered" style="display: none;">Powered by <a href="http://www.wysibb.com" target="_blank">WysiBB<a/></span>'),this.$txtArea.bind("mouseup keyup",e.proxy(function(){clearTimeout(this.uitimer),this.uitimer=setTimeout(e.proxy(this.updateUI,this),100)},this)),this.options.hotkeys===!0&&e(document).bind("keydown",e.proxy(this.presskey,this))},buildToolbar:function(){if(this.options.toolbar===!1)return!1;this.$toolbar=e("<div>").addClass("wysibb-toolbar").prependTo(this.$editor);var t;e.each(this.options.buttons,e.proxy(function(n,r){var i=this.options.allButtons[r];if(n==0||r=="|"||r=="-")r=="-"&&this.$toolbar.append("<div>"),t=e('<div class="wysibb-toolbar-container">').appendTo(this.$toolbar);i&&(i.type=="colorpicker"?this.buildColorpicker(t,r,i):i.type=="table"?this.buildTablepicker(t,r,i):i.type=="select"?this.buildSelect(t,r,i):i.type=="smilebox"?this.buildSmilebox(t,r,i):this.buildButton(t,r,i))},this)),this.$toolbar.find(".btn-tooltip").hover(function(){e(this).parent().css("overflow","hidden")},function(){e(this).parent().css("overflow","visible")});var n=e(document.createElement("div")).addClass("wysibb-toolbar-container modeSwitch").html('<div class="wysibb-toolbar-btn mswitch" unselectable="on"><span class="btn-inner modesw" unselectable="on">[BBcode]</span></div>').appendTo(this.$toolbar);this.options.bbmode==1&&n.children(".wysibb-toolbar-btn").addClass("on"),this.options.onlyBBmode===!1&&n.children(".wysibb-toolbar-btn").click(e.proxy(function(t){e(t.currentTarget).toggleClass("on"),this.modeSwitch()},this)),e.support.htmlSerialize&&this.$toolbar.find("*").attr("unselectable","on")},buildButton:function(t,n,r){typeof t!="object"&&(t=this.$toolbar);var i=r.buttonHTML?e(this.strf(r.buttonHTML,this.options)).addClass("btn-inner"):this.strf('<span class="btn-inner btn-text">{text}</span>',{text:r.buttonText.replace(/</g,"<")}),s=this.options.hotkeys===!0&&this.options.showHotkeys===!0&&r.hotkey?' <span class="tthotkey">['+r.hotkey+"]</span>":"",o=e('<div class="wysibb-toolbar-btn wbb-'+n+'">').appendTo(t).append(i).append(this.strf('<span class="btn-tooltip">{title}<ins/>{hotkey}</span>',{title:r.title,hotkey:s}));this.controllers.push(o),o.bind("queryState",e.proxy(function(t){this.queryState(n)?e(t.currentTarget).addClass("on"):e(t.currentTarget).removeClass("on")},this)),o.mousedown(e.proxy(function(t){t.preventDefault(),this.execCommand(n,r.exvalue||!1),e(t.currentTarget).trigger("queryState")},this))},buildColorpicker:function(t,n,r){var i=e('<div class="wysibb-toolbar-btn wbb-dropdown wbb-cp">').appendTo(t).append('<div class="ve-tlb-colorpick"><span class="fonticon"></span><span class="cp-line"></span></div><ins class="fonticon ar"></ins>').append(this.strf('<span class="btn-tooltip">{title}<ins/></span>',{title:r.title})),s=i.find(".cp-line"),o=e('<div class="wbb-list">').appendTo(i);o.append('<div class="nc">'+CURLANG.auto+"</div>");var u=r.colors?r.colors.split(","):[];for(var a=0;a<u.length;a++)u[a]=e.trim(u[a]),u[a]=="-"?o.append('<span class="pl"></span>'):o.append(this.strf('<div class="sc" style="background:{color}" title="{color}"></div>',{color:u[a]}));var f=e(document.body).css("color");this.controllers.push(i),i.bind("queryState",e.proxy(function(e){s.css("background-color",f);var t=this.queryState("fontcolor",!0);t&&(s.css("background-color",this.options.bbmode?t.color:t),i.find(".ve-tlb-colorpick span.fonticon").css("color",this.options.bbmode?t.color:t))},this)),i.mousedown(e.proxy(function(e){e.preventDefault(),this.dropdownclick(".wbb-cp",".wbb-list",e)},this)),i.find(".sc").mousedown(e.proxy(function(t){t.preventDefault(),this.selectLastRange();var n=e(t.currentTarget).attr("title");this.execCommand("fontcolor",n),i.trigger("queryState")},this)),i.find(".nc").mousedown(e.proxy(function(e){e.preventDefault(),this.selectLastRange(),this.execCommand("fontcolor",f),i.trigger("queryState")},this)),i.mousedown(function(e){e.preventDefault&&e.preventDefault()})},buildTablepicker:function(t,n,r){var i=e('<div class="wysibb-toolbar-btn wbb-dropdown wbb-tbl">').appendTo(t).append('<span class="btn-inner fonticon ve-tlb-table1"></span><ins class="fonticon ar"></ins>').append(this.strf('<span class="btn-tooltip">{title}<ins/></span>',{title:r.title})),s=e('<div class="wbb-list">').appendTo(i),o=r.rows||10,u=r.cols||10,a=o*u;s.css("width",u*r.cellwidth+2+"px").css("height",o*r.cellwidth+2+"px");for(var f=1;f<=u;f++)for(var l=1;l<=o;l++){var c='<div class="tbl-sel" style="width:'+f*r.cellwidth+"px;height:"+l*r.cellwidth+"px;z-index:"+ --a+'" title="'+l+","+f+'"></div>';s.append(c)}i.find(".tbl-sel").mousedown(e.proxy(function(t){t.preventDefault();var n=e(t.currentTarget).attr("title"),r=n.split(","),i=this.options.bbmode?"[table]":'<table class="wbb-table" cellspacing="5" cellpadding="0">';for(var s=1;s<=r[0];s++){i+=this.options.bbmode?" [tr]n":"<tr>";for(var o=1;o<=r[1];o++)i+=this.options.bbmode?" [td][/td]n":"<td></td>";i+=this.options.bbmode?"[/tr]n":"</tr>"}i+=this.options.bbmode?"[/table]":"</table>",this.insertAtCursor(i)},this)),i.mousedown(e.proxy(function(e){e.preventDefault(),this.dropdownclick(".wbb-tbl",".wbb-list",e)},this))},buildSelect:function(t,n,r){var i=e('<div class="wysibb-toolbar-btn wbb-select wbb-'+n+'">').appendTo(t).append(this.strf('<span class="val">{title}</span><ins class="fonticon sar"></ins>',r)).append(this.strf('<span class="btn-tooltip">{title}<ins/></span>',{title:r.title})),s=e('<div class="wbb-list">').appendTo(i),o=i.find("span.val"),u=e.isArray(r.options)?r.options:r.options.split(",");for(var a=0;a<u.length;a++){var f=u[a];if(typeof f=="string"){var l=this.options.allButtons[f];l&&(l.html?e("<span>").addClass("option").attr("oid",f).attr("cmdvalue",l.exvalue).appendTo(s).append(this.strf(l.html,{seltext:l.title})):s.append(this.strf('<span class="option" oid="'+f+'" cmdvalue="'+l.exvalue+'">{title}</span>',l)))}else{var c={seltext:f.title};c[r.valueBBname]=f.exvalue,e("<span>").addClass("option").attr("oid",n).attr("cmdvalue",f.exvalue).appendTo(s).append(this.strf(r.html,c))}}this.controllers.push(i),i.bind("queryState",e.proxy(function(t){o.text(r.title),i.find(".option.selected").removeClass("selected"),i.find(".option").each(e.proxy(function(t,n){var r=e(n),i=this.queryState(r.attr("oid"),!0),s=r.attr("cmdvalue");if(s&&i==r.attr("cmdvalue")||!s&&i)return o.text(r.text()),r.addClass("selected"),!1},this))},this)),i.mousedown(e.proxy(function(e){e.preventDefault(),this.dropdownclick(".wbb-select",".wbb-list",e)},this)),i.find(".option").mousedown(e.proxy(function(t){t.preventDefault();var n=e(t.currentTarget).attr("oid"),r=e(t.currentTarget).attr("cmdvalue"),i=this.options.allButtons[n];this.execCommand(n,i.exvalue||r||!1),e(t.currentTarget).trigger("queryState")},this))},buildSmilebox:function(t,n,r){if(this.options.smileList&&this.options.smileList.length>0){var i=e(this.strf(r.buttonHTML,r)).addClass("btn-inner"),s=e('<div class="wysibb-toolbar-btn wbb-smilebox wbb-'+n+'">').appendTo(t).append(i).append(this.strf('<span class="btn-tooltip">{title}<ins/></span>',{title:r.title})),o=e('<div class="wbb-list">').appendTo(s);e.isArray(this.options.smileList)&&e.each(this.options.smileList,e.proxy(function(t,n){e("<span>").addClass("smile").appendTo(o).append(e(this.strf(n.img,this.options)).attr("title",n.title))},this)),s.mousedown(e.proxy(function(e){e.preventDefault(),this.dropdownclick(".wbb-smilebox",".wbb-list",e)},this)),s.find(".smile").mousedown(e.proxy(function(t){t.preventDefault(),this.insertAtCursor(this.options.bbmode?this.toBB(e(t.currentTarget).html()):e(e(t.currentTarget).html()))},this))}},updateUI:function(t){(!t||t.which>=8&&t.which<=46||t.which>90||t.type=="mouseup")&&e.each(this.controllers,e.proxy(function(e,t){t.trigger("queryState")},this)),this.disNonActiveButtons()},initModal:function(){this.$modal=e("#wbbmodal"),this.$modal.size()==0&&(e.log("Init modal"),this.$modal=e("<div>").attr("id","wbbmodal").prependTo(document.body).html('<div class="wbbm"><div class="wbbm-title"><span class="wbbm-title-text"></span><span class="wbbclose" title="'+CURLANG.close+'">×</span></div><div class="wbbm-content"></div><div class="wbbm-bottom"><button id="wbbm-submit" class="wbb-button">'+CURLANG.save+'</button><button id="wbbm-cancel" class="wbb-cancel-button">'+CURLANG.cancel+'</button><button id="wbbm-remove" class="wbb-remove-button">'+CURLANG.remove+"</button></div></div>").hide(),this.$modal.find("#wbbm-cancel,.wbbclose").click(e.proxy(this.closeModal,this)),this.$modal.bind("click",e.proxy(function(t){e(t.target).parents(".wbbm").size()==0&&this.closeModal()},this)),e(document).bind("keydown",e.proxy(this.escModal,this)))},initHotkeys:function(){e.log("initHotkeys"),this.hotkeys=[];var t="0123456789 abcdefghijklmnopqrstuvwxyz";e.each(this.options.allButtons,e.proxy(function(n,r){if(r.hotkey){var i=r.hotkey.split("+");if(i&&i.length>=2){var s=0,o=i.pop();e.each(i,function(t,n){switch(e.trim(n.toLowerCase())){case"ctrl":s+=1;break;case"shift":s+=4;break;case"alt":s+=7}}),s>0&&(this.hotkeys["m"+s]||(this.hotkeys["m"+s]=[]),this.hotkeys["m"+s]["k"+(t.indexOf(o)+48)]=n)}}},this))},presskey:function(e){if(e.ctrlKey==1||e.shiftKey==1||e.altKey==1){var t=(e.ctrlKey==1?1:0)+(e.shiftKey==1?4:0)+(e.altKey==1?7:0);if(this.hotkeys["m"+t]&&this.hotkeys["m"+t]["k"+e.which])return this.execCommand(this.hotkeys["m"+t]["k"+e.which],!1),e.preventDefault(),!1}},execCommand:function(t,n){e.log("execCommand: "+t);var r=this.options.allButtons[t];if(r.en!==!0)return!1;var i=this.queryState(t,n),s=this.isInClearTextBlock();if(s&&s!=t)return;if(r.excmd)if(this.options.bbmode){e.log("Native command in bbmode: "+t);if(i&&r.subInsert!=1)this.wbbRemoveCallback(t,n);else{var o={};r.valueBBname&&n&&(o[r.valueBBname]=n),this.insertAtCursor(this.getBBCodeByCommand(t,o))}}else this.execNativeCommand(r.excmd,n||!1);else r.cmd?r.cmd.call(this,t,n,i):this.wbbExecCommand.call(this,t,n,i);this.updateUI()},queryState:function(t,n){var r=this.options.allButtons[t];if(r.en!==!0)return!1;if(this.options.bbmode){if(r.bbSelector)for(var i=0;i<r.bbSelector.length;i++){var s=this.isBBContain(r.bbSelector[i]);if(s)return this.getParams(s,r.bbSelector[i],s[1])}return!1}if(!r.excmd){if(e.isArray(r.rootSelector))for(var i=0;i<r.rootSelector.length;i++){var a=this.isContain(this.getSelectNode(),r.rootSelector[i]);if(a)return this.getParams(a,r.rootSelector[i])}return!1}if(n)try{var o=(document.queryCommandValue(r.excmd)+"").replace(/'/g,"");return r.excmd=="foreColor"&&(o=this.rgbToHex(o)),o}catch(u){return!1}else try{return document.queryCommandState(r.excmd)}catch(u){return!1}},wbbExecCommand:function(t,n,r){e.log("wbbExecCommand");var i=this.options.allButtons[t];if(i)if(i.modal)e.isFunction(i.modal)?i.modal.call(this,t,i.modal,r):this.showModal.call(this,t,i.modal,r);else if(r&&i.subInsert!=1)this.wbbRemoveCallback(t);else{if(i.groupkey){var s=this.options.groups[i.groupkey];if(s){var o=this.getSelectNode();e.each(s,e.proxy(function(t,n){var r=this.isContain(o,n);if(r){var i=e("<span>").html(r.innerHTML),s=this.setUID(i);return e(r).replaceWith(i),this.selectNode(this.$editor.find("#"+s)[0]),!1}},this))}}this.wbbInsertCallback(t,n)}},wbbInsertCallback:function(t,n){typeof n!="object"&&(n={}),e.log("wbbInsertCallback: "+t);var r=this.getCodeByCommand(t,n);this.insertAtCursor(r);if(this.seltextID&&r.indexOf(this.seltextID)!=-1){var i=this.$body.find("#"+this.seltextID)[0];this.selectNode(i),e(i).removeAttr("id"),this.seltextID=!1}},wbbRemoveCallback:function(t,n){e.log("wbbRemoveCallback: "+t);var r=this.options.allButtons[t];if(this.options.bbmode){var i=this.getCursorPosBB(),s=0;e.each(r.bbSelector,e.proxy(function(t,r){var i=r.match(/{[sS]+?}/g);e.each(i,function(e,t){if(t.toLowerCase()=="{seltext}")return s=e,!1});var o=this.isBBContain(r);if(o)return this.txtArea.value=this.txtArea.value.substr(0,o[1])+this.txtArea.value.substr(o[1],this.txtArea.value.length-o[1]).replace(o[0][0],n===!0?"":o[0][s+1]),this.setCursorPosBB(o[1]),!1},this))}else{var o=this.getSelectNode();e.each(r.rootSelector,e.proxy(function(i,s){var u=this.isContain(o,s);if(!u)return!0;var a=e(u),f=this.options.rules[s][0][1];if(a.is("span[wbb]")||!a.is("span,font")){if(n===!0)a.remove();else if(f&&f.seltext&&f.seltext.sel){var l=a.find(f.seltext.sel).html();r.onlyClearText===!0&&(l=this.getHTML(l,!0,!0),l=l.replace(/{/g,"{").replace(/}/g,"}")),a.replaceWith(l)}else{var l=a.html();r.onlyClearText===!0&&(l=this.getHTML(l,!0),l=l.replace(/</g,"<").replace(/{/g,"{").replace(/}/g,"}")),a.replaceWith(l)}return!1}var c=this.getRange(),h=this.getSelectText(),p=this.getSelectNode();e.log("selHTML: "+h),h==""?h="":h=this.clearFromSubInsert(h,t);var d=this.elFromString(h),v=window.getSelection?c.cloneRange():this.body.createTextRange(),m=window.getSelection?c.cloneRange():this.body.createTextRange();if(window.getSelection){this.insertAtCursor('<span id="wbbdivide"></span>');var g=a.find("span#wbbdivide").get(0);v.setStart(u.firstChild,0),v.setEndBefore(g),m.setStartAfter(g),m.setEndAfter(u.lastChild)}else v.moveToElementText(u),m.moveToElementText(u),v.setEndPoint("EndToStart",c),m.setEndPoint("StartToEnd",c);var y=this.getSelectText(!1,v),b=this.getSelectText(!1,m);if(b!=""){var w=a.clone().html(b);a.after(w)}return n!==!0&&a.after(d),window.getSelection?(a.html(y),n!==!0&&this.selectNode(d)):a.replaceWith(y),!1},this))}},execNativeCommand:function(t,n){this.body.focus();if(t=="insertHTML"&&!window.getSelection){var r=this.lastRange?this.lastRange:document.selection.createRange();r.pasteHTML(n);var i=e("<div>").html(n).text(),s=i.indexOf("");s>-1&&(r.moveStart("character",-1*(i.length-s)),r.select()),this.lastRange=!1}else if(t=="insertHTML"){var o=this.getSelection(),u=this.elFromString(n),a=this.lastRange?this.lastRange:this.getRange();a.deleteContents(),a.insertNode(u),a.collapse(!1),o.removeAllRanges(),o.addRange(a)}else typeof n=="undefined"&&(n=!1),this.lastRange&&(e.log("Last range select"),this.selectLastRange()),document.execCommand(t,!1,n)},getCodeByCommand:function(e,t){return this.options.bbmode?this.getBBCodeByCommand(e,t):this.getHTMLByCommand(e,t)},getBBCodeByCommand:function(t,n){if(!this.options.allButtons[t])return"";typeof n=="undefined"&&(n={}),n=this.keysToLower(n),n.seltext||(n.seltext=this.getSelectText(!0));var r=this.options.allButtons[t].bbcode;r=r.replace(/{(.*?)([.*?])*}/g,function(e,t,r){if(r){var i;r&&(i=new RegExp(r+"+","i"));if(typeof n[t.toLowerCase()]!="undefined"&&n[t.toLowerCase()].toString().match(i)===null)return""}return typeof n[t.toLowerCase()]=="undefined"?"":n[t.toLowerCase()]});var i=null,s=0;if(this.options.allButtons[t].transform){var o=[];e.each(this.options.allButtons[t].transform,function(e,t){o.push(t)}),o=this.sortArray(o,-1),e.each(o,function(e,t){var r=!0,o=0,u={};t=t.replace(/{(.*?)([.*?])*}/g,function(e,t,i){var s;t=t.toLowerCase(),i&&(s=new RegExp(i+"+","i"));if(typeof n[t.toLowerCase()]=="undefined"||i&&n[t.toLowerCase()].toString().match(s)===null)r=!1;return typeof n[t]!="undefined"&&!u[t]&&(u[t]=1,o++),typeof n[t.toLowerCase()]=="undefined"?"":n[t.toLowerCase()]}),r&&o>s&&(i=t,s=o)})}return i||r},getHTMLByCommand:function(t,n){if(!this.options.allButtons[t])return"";n=this.keysToLower(n),typeof n=="undefined"&&(n={}),n.seltext||(n.seltext=this.getSelectText(!1),n["seltext"]==""?n.seltext="":(n.seltext=this.clearFromSubInsert(n.seltext,t),this.options.allButtons[t].onlyClearText===!0&&(n.seltext=this.toBB(n.seltext).replace(/</g,"<").replace(/n/g,"<br/>").replace(/s{3}/g,'<span class="wbbtab"></span>'))));var r="";this.seltextID="wbbid_"+ ++this.lastid,t!="link"&&t!="img"?n.seltext='<span id="'+this.seltextID+'">'+n.seltext+"</span>":r='<span id="'+this.seltextID+'"></span>';var i=this.options.allButtons[t].html;i=i.replace(/{(.*?)([.*?])*}/g,function(e,t,r){if(r){var i=new RegExp(r+"+","i");if(typeof n[t.toLowerCase()]!="undefined"&&n[t.toLowerCase()].toString().match(i)===null)return""}return typeof n[t.toLowerCase()]=="undefined"?"":n[t.toLowerCase()]});var s=null,o=0;if(this.options.allButtons[t].transform){var u=[];e.each(this.options.allButtons[t].transform,function(e,t){u.push(e)}),u=this.sortArray(u,-1),e.each(u,function(e,t){var r=!0,i=0,u={};t=t.replace(/{(.*?)([.*?])*}/g,function(e,t,s){var o;t=t.toLowerCase(),s&&(o=new RegExp(s+"+","i"));if(typeof n[t]=="undefined"||s&&n[t].toString().match(o)===null)r=!1;return typeof n[t]!="undefined"&&!u[t]&&(u[t]=1,i++),typeof n[t]=="undefined"?"":n[t]}),r&&i>o&&(s=t,o=i)})}return(s||i)+r},getSelection:function(){if(window.getSelection)return window.getSelection();if(document.selection)return this.options.bbmode?document.selection.createRange():document.selection.createRange()},getSelectText:function(t,n){if(t){this.txtArea.focus();if("selectionStart"in this.txtArea){var r=this.txtArea.selectionEnd-this.txtArea.selectionStart;return this.txtArea.value.substr(this.txtArea.selectionStart,r)}var i=document.selection.createRange();return i.text}return this.body.focus(),n||(n=this.getRange()),window.getSelection?n?e("<div>").append(n.cloneContents()).html():"":n.htmlText},getRange:function(){if(!window.getSelection)return this.options.bbmode===!0?document.selection.createRange():document.selection.createRange();var e=this.getSelection();if(e.getRangeAt&&e.rangeCount>0)return e.getRangeAt(0);if(e.anchorNode){var t=this.options.bbmode?document.createRange():document.createRange();return t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t}},insertAtCursor:function(t,n){typeof t!="string"&&(t=e("<div>").append(t).html());if(this.options.bbmode&&typeof n=="undefined"||n===!0){var r=t.replace(/.*([/S+?])$/,"$1"),i=this.getCursorPosBB()+(t.indexOf(r)!=-1&&t.match(/[.*]/)?t.indexOf(r):t.length);if(document.selection)this.txtArea.focus(),this.getSelection().text=t;else if(this.txtArea.selectionStart||this.txtArea.selectionStart=="0")this.txtArea.value=this.txtArea.value.substring(0,this.txtArea.selectionStart)+t+this.txtArea.value.substring(this.txtArea.selectionEnd,this.txtArea.value.length);i<0&&(i=0),this.setCursorPosBB(i)}else{this.execNativeCommand("insertHTML",t);var s=this.getSelectNode();e(s).closest("table,tr,td")||this.splitPrevNext(s)}},getSelectNode:function(e){return this.body.focus(),e||(e=this.getRange()),e?window.getSelection?e.commonAncestorContainer:e.parentElement():this.$body},getCursorPosBB:function(){var e=0;if("selectionStart"in this.txtArea)e=this.txtArea.selectionStart;else{this.txtArea.focus();var t=this.getRange(),n=document.body.createTextRange();n.moveToElementText(this.txtArea),n.setEndPoint("EndToStart",t),e=n.text.length}return e},setCursorPosBB:function(e){if(this.options.bbmode)if(window.getSelection)this.txtArea.selectionStart=e,this.txtArea.selectionEnd=e;else{var t=this.txtArea.createTextRange();t.collapse(!0),t.move("character",e),t.select()}},selectNode:function(e,t){t||(t=this.getRange());if(!t)return;if(window.getSelection){var n=this.getSelection();t.selectNodeContents(e),n.removeAllRanges(),n.addRange(t)}else t.moveToElementText(e),t.select()},selectRange:function(e){if(e)if(!window.getSelection)e.select();else{var t=this.getSelection();t.removeAllRanges(),t.addRange(e)}},cloneRange:function(e){if(e)return window.getSelection?e.cloneRange():e.duplicate()},getRangeClone:function(){return this.cloneRange(this.getRange())},saveRange:function(){this.setBodyFocus(),this.lastRange=this.getRangeClone()},selectLastRange:function(){this.lastRange&&(this.body.focus(),this.selectRange(this.lastRange),this.lastRange=!1)},setBodyFocus:function(){e.log("Set focus to WysiBB editor"),this.options.bbmode?this.$txtArea.is(":focus")||this.$txtArea.focus():this.$body.is(":focus")||this.$body.focus()},clearLastRange:function(){this.lastRange=!1},filterByNode:function(t){var n=e(t),r=n.get(0).tagName.toLowerCase(),i=r,s=this.getAttributeList(n.get(0));e.each(s,e.proxy(function(t,r){var s=n.attr(r);r.substr(0,1)=="_"&&(r=r.substr(1,r.length));if(s&&!s.match(/{.*?}/))if(r=="style"){var s=n.attr(r),o=s.split(";");e.each(o,function(t,n){n&&n.length>0&&(i+="["+r+'*="'+e.trim(n)+'"]')})}else i+="["+r+'="'+s+'"]';else if(s&&r=="style"){var u=s.substr(0,s.indexOf("{"));if(u&&u!=""){var s=s.substr(0,s.indexOf("{")),o=s.split(";");e.each(o,function(e,t){i+="["+r+'*="'+t+'"]'})}}else i+="["+r+"]"},this));var o=n.parent().children(i).index(n);return o>0&&(i+=":eq("+n.index()+")"),i},relFilterByNode:function(t,n){var r="";e.each(this.options.attrWrap,function(e,t){n=n.replace("["+t,"[_"+t)});while(t&&t.tagName!="BODY"&&!e(t).is(n))r=this.filterByNode(t)+" "+r,t&&(t=t.parentNode);return r},getRegexpReplace:function(e,t){return e=e.replace(/((|)|[|]|.|*|?|:|\)/g,"\$1").replace(/s+/g,"\s+").replace(t.replace(/((|)|[|]|.|*|?|:|\)/g,"\$1"),"(.+)").replace(/{S+?}/g,".*"),e},getBBCode:function(){return this.options.rules?this.options.bbmode?this.$txtArea.val():(this.clearEmpty(),this.removeLastBodyBR(),this.toBB(this.$body.html())):this.$txtArea.val()},toBB:function(t){if(!t)return"";var n=typeof t=="string"?e("<span>").html(t):e(t);n.find("div,blockquote,p").each(function(){this.nodeType!=3&&this.lastChild&&this.lastChild.tagName=="BR"&&e(this.lastChild).remove()}),n.is("div,blockquote,p")&&n[0].nodeType!=3&&n[0].lastChild&&n[0].lastChild.tagName=="BR"&&e(n[0].lastChild).remove(),n.find("ul > br, table > br, tr > br").remove();var r="";return e.each(this.options.srules,e.proxy(function(e,t){n.find(e).replaceWith(t[0])},this)),n.contents().each(e.proxy(function(t,n){var i=e(n);if(n.nodeType===3)r+=n.data.replace(/n+/,"").replace(/t/g," ");else{var s,o=!1;for(var u=0;u<this.rsellist.length;u++){var a=this.rsellist[u];if(i&&i.is(a)){var f=this.options.rules[a];for(var t=0;t<f.length;t++){var l=f[t][0],c=f[t][1],h=!1,p=!1,d=!1;i.is("br")||(l=l.replace(/n/g,"<br>")),l=l.replace(/{(.*?)([.*?])*}/g,e.proxy(function(t,r,s){var o=c[r.toLowerCase()];typeof o=="undefined"&&(e.log("Param: {"+r+"} not found in HTML representation."),h=!0);var u=o.sel?e(n).find(o.sel):e(n);if(o.attr&&!u.attr(o.attr))return h=!0,r;var a=o.attr?u.attr(o.attr):u.html();if(typeof a=="undefined"||a==null)return h=!0,r;var f=o.rgx;f&&o.attr=="style"&&f.substr(f.length-1,1)!=";"&&(f+=";"),o.attr=="style"&&a&&a.substr(a.length-1,1)!=";"&&(a+=";");var l=f?new RegExp(f,""):!1;if(l)if(a.match(l)){var v=a.match(l);v&&v.length==2&&(a=v[1])}else a="";if(o.attr&&h===!1)if(o.attr=="style"){p=!0;var m="",g=o.rgx.replace(/^.*?/,"").replace(/.*$/,"").replace(/;$/,"");e(u.attr("style").split(";")).each(function(e,t){t&&t!=""&&(t.match(g)||(m+=t+";"))}),m==""?u.removeAttr("style"):u.attr("style",m)}else o.rgx===!1&&(p=!0,d=!0,u.removeAttr(o.attr));return i.is("table,tr,td,font")&&(p=!0),a||""},this));if(h)continue;if(i.is("img,br,hr")){r+=l,i=null;break}if(!p||!!i.attr("notkeep")){i.is("iframe")?r+=l:(i.empty().html(l),r+=this.toBB(i),i=null);break}i.is("table,tr,td")?(l=this.fixTableTransform(l),r+=this.toBB(e("<span>").html(l)),i=null):e.support.htmlSerialize?i.empty().append(e("<span>").html(l)):i.empty().html("<span>"+l+"</span>")}}}if(!i||i.is("iframe,img"))return!0;r+=this.toBB(i)}},this)),r},getHTML:function(t,n,r){if(!this.options.bbmode&&!n)return this.$body.html();r||(t=t.replace(/</g,"<").replace(/{/g,"{").replace(/}/g,"}")),t=t.replace(/[code]([sS]*?)[/code]/g,function(e){return e=e.substr("[code]".length,e.length-"[code]".length-"[/code]".length).replace(/[/g,"[").replace(/]/g,"]"),"[code]"+e+"[/code]"}),e.each(this.options.btnlist,e.proxy(function(n,r){if(r!="|"&&r!="-"){var i=!0;if(!this.options.allButtons[r]||!this.options.allButtons[r].transform)return!0;e.each(this.options.allButtons[r].transform,e.proxy(function(n,r){n=n.replace(/n/g,"");var i=[];r=r.replace(/((|)|[|]|.|*|?|:|\|\)/g,"\$1"),r=r.replace(/{(.*?)(\[.*?\])*}/gi,e.proxy(function(e,t,n){return i.push(t),n?(n=n.replace(/\/g,""),"("+n+"*?)"):"([\s\S]*?)"},this));var s=0,o;while((o=(new RegExp(r,"mgi")).exec(t))!=null)if(o){var u={};e.each(i,e.proxy(function(e,t){u[t]=o[e+1]},this));var a=n;a=a.replace(/{(.*?)([.*?])}/g,"{$1}"),a=this.strf(a,u),t=t.replace(o[0],a)}},this))}},this)),e.each(this.options.systr,function(e,n){n=n.replace(/((|)|[|]|.|*|?|:|\|\)/g,"\$1").replace(" ","\s"),t=t.replace(new RegExp(n,"g"),e)});var i=e(this.elFromString("<div>"+t+"</div>"));return this.getHTMLSmiles(i),i.html()},getHTMLSmiles:function(t){e(t).contents().filter(function(){return this.nodeType==3}).each(e.proxy(this.smileRPL,this))},smileRPL:function(t,n){var r=n.data;e.each(this.options.smileList,e.proxy(function(t,i){var s=r.indexOf(i.bbcode);if(s!=-1){var o=r.substring(s+i.bbcode.length,r.length),u=document.createTextNode(o);return n.data=r=n.data.substr(0,s),e(n).after(u).after(this.strf(i.img,this.options)),this.getHTMLSmiles(n.parentNode),!1}this.getHTMLSmiles(n)},this))},setUID:function(t,n){var r="wbbid_"+ ++this.lastid;return t&&e(t).attr(n||"id",r),r},keysToLower:function(t){return e.each(t,function(e,n){e!=e.toLowerCase()&&(delete t[e],t[e.toLowerCase()]=n)}),t},strf:function(t,n){return n=this.keysToLower(e.extend({},n)),t.replace(/{([w.]*)}/g,function(t,r){r=r.toLowerCase();var i=r.split("."),s=n[i.shift().toLowerCase()];return e.each(i,function(){s=s[this]}),s===null||s===undefined?"":s})},elFromString:function(t){if(t.indexOf("<")!=-1&&t.indexOf(">")!=-1){var n=document.createElement("SPAN");return e(n).html(t),this.setUID(n,"wbb"),e(n).contents().size()>1?n:n.firstChild}return document.createTextNode(t)},isContain:function(t,n){while(t&&!e(t).hasClass("wysibb")){if(e(t).is(n))return t;if(!t)return null;t=t.parentNode}},isBBContain:function(e){var t=this.getCursorPosBB(),n=this.prepareRGX(e),r=new RegExp(n,"g"),i,s=0;while((i=r.exec(this.txtArea.value))!=null){var o=this.txtArea.value.indexOf(i[0],s);if(t>o&&t<o+i[0].length)return[i,o];s=o+1}},prepareRGX:function(e){return e.replace(/([|]|)|(|.|*|?|:|||\)/g,"\$1").replace(/{.*?}/g,"([\s\S]*?)")},checkForLastBR:function(t){t||(n=this.body),t.nodeType==3&&(t=t.parentNode);var n=e(t);n.is("span[id*='wbbid']")&&(n=n.parent());if(this.options.bbmode===!1&&n.is("div,blockquote,code")&&n.contents().size()>0){var r=n[0].lastChild;(!r||r&&r.tagName!="BR")&&n.append("<br/>")}this.$body.contents().size()>0&&this.body.lastChild.tagName!="BR"&&this.$body.append("<br/>")},getAttributeList:function(t){var n=[];return e.each(t.attributes,function(e,t){t.specified&&n.push(t.name)}),n},clearFromSubInsert:function(t,n){if(this.options.allButtons[n]&&this.options.allButtons[n].rootSelector){var r=e("<div>").html(t);return e.each(this.options.allButtons[n].rootSelector,e.proxy(function(t,n){var i=!1;typeof this.options.rules[n][0][1]["seltext"]!="undefined"&&(i=this.options.rules[n][0][1].seltext.sel);var s=!0;return r.find("*").each(function(){e(this).is(n)&&(i&&i.sel?e(this).replaceWith(e(this).find(i.sel.toLowerCase()).html()):e(this).replaceWith(e(this).html()),s=!1)}),s},this)),r.html()}return t},splitPrevNext:function(t){t.nodeType==3&&(t=t.parentNode);var n=this.filterByNode(t).replace(/:eq.*$/g,"");e(t.nextSibling).is(n)&&(e(t).append(e(t.nextSibling).html()),e(t.nextSibling).remove()),e(t.previousSibling).is(n)&&(e(t).prepend(e(t.previousSibling).html()),e(t.previousSibling).remove())},modeSwitch:function(){this.options.bbmode?(this.$body.html(this.getHTML(this.$txtArea.val())),this.$txtArea.hide().removeAttr("wbbsync").val(""),this.$body.css("min-height",this.$txtArea.height()).show().focus()):(this.$txtArea.val(this.getBBCode()).css("min-height",this.$body.height()),this.$body.hide(),this.$txtArea.show().focus()),this.options.bbmode=!this.options.bbmode},clearEmpty:function(){function t(){if(!e(this).is("span,font,a,b,i,u,s"))return!1;if(!e(this).hasClass("wbbtab")&&e.trim(e(this).html()).length==0)return!0;if(e(this).children().size()>0){e(this).children().filter(t).remove();if(e(this).html().length==0&&this.tagName!="BODY")return!0}}this.$body.children().filter(t).remove()},dropdownclick:function(t,n,r){var i=e(r.currentTarget).closest(t);if(i.hasClass("dis"))return;i.attr("wbbshow")?(i.removeAttr("wbbshow"),e(document).unbind("mousedown",this.dropdownhandler),document&&e(document).unbind("mousedown",this.dropdownhandler),this.lastRange=!1):(this.saveRange(),this.$editor.find("*[wbbshow]").each(function(t,n){e(n).removeClass("on").find(e(n).attr("wbbshow")).hide().end().removeAttr("wbbshow")}),i.attr("wbbshow",n),e(document.body).bind("mousedown",e.proxy(function(e){this.dropdownhandler(i,t,n,e)},this)),this.$body&&this.$body.bind("mousedown",e.proxy(function(e){this.dropdownhandler(i,t,n,e)},this))),i.find(n).toggle(),i.toggleClass("on")},dropdownhandler:function(t,n,r,i){e(i.target).parents(n).size()==0&&(t.removeClass("on").find(r).hide(),e(document).unbind("mousedown",this.dropdownhandler),this.$body&&this.$body.unbind("mousedown",this.dropdownhandler))},rgbToHex:function(e){if(e.substr(0,1)=="#")return e;if(e.indexOf("rgb")==-1){var t=parseInt(e);return t=(t&255)<<16|t&65280|(t&16711680)>>>16,"#"+t.toString(16)}var n=/(.*?)rgb((d+),s*(d+),s*(d+))/.exec(e);return"#"+this.dec2hex(parseInt(n[2]))+this.dec2hex(parseInt(n[3]))+this.dec2hex(parseInt(n[4]))},dec2hex:function(e){return e>15?e.toString(16):"0"+e.toString(16)},sync:function(){this.options.bbmode?this.$body.html(this.getHTML(this.txtArea.value,!0)):this.$txtArea.attr("wbbsync",1).val(this.getBBCode())},clearPaste:function(t){var n=e(t);e.each(this.options.rules,e.proxy(function(t,r){var i=n.find(t).attr("wbbkeep",1);if(i.size()>0){var s=r[0][1];e.each(s,function(e,t){t.sel&&i.find(t.sel).attr("wbbkeep",1)})}},this)),n.find("*[wbbkeep!='1']").each(e.proxy(function(t,n){var r=e(n);r.is("div,p")&&(r.children().size()==0||n.lastChild.tagName!="BR")&&r.after("<br/>")},this)),n.find("*[wbbkeep]").removeAttr("wbbkeep").removeAttr("style"),e.log(n.html()),n.html(this.getHTML(this.toBB(n),!0)),e.log(n.html())},sortArray:function(e,t){return e.sort(function(e,n){return(e.length-n.length)*(t||1)}),e},smileFind:function(){if(this.options.smilefind){var t=e(this.options.smilefind).find("img[alt]");t.size()>0&&(this.options.smileList=[],t.each(e.proxy(function(t,n){var r=e(n);this.options.smileList.push({title:r.attr("title"),bbcode:r.attr("alt"),img:r.removeAttr("alt").removeAttr("title")[0].outerHTML})},this)))}},destroy:function(){this.$editor.replaceWith(this.$txtArea),this.$txtArea.removeClass("wysibb-texarea").show(),this.$modal.remove(),this.$txtArea.data("wbb",null)},pressTab:function(e){e&&e.which==9&&(e.preventDefault&&e.preventDefault(),this.options.bbmode?this.insertAtCursor(" ",!1):this.insertAtCursor('<span class="wbbtab"></span>',!1))},removeLastBodyBR:function(){this.body.lastChild&&this.body.lastChild.nodeType!=3&&this.body.lastChild.tagName=="BR"&&(this.body.removeChild(this.body.lastChild),this.removeLastBodyBR())},traceTextareaEvent:function(t){e(t.target).closest("div.wysibb").size()==0&&(e(document.activeElement).is("div.wysibb-body")&&this.saveRange(),setTimeout(e.proxy(function(){var n=this.$txtArea.val();this.options.bbmode===!1&&n!=""&&e(t.target).closest("div.wysibb").size()==0&&!this.$txtArea.attr("wbbsync")&&(this.selectLastRange(),this.insertAtCursor(this.getHTML(n,!0)),this.$txtArea.val("")),e(document.activeElement).is("div.wysibb-body")&&(this.lastRange=!1)},this),100))},txtAreaInitContent:function(){this.$body.html(this.getHTML(this.txtArea.value,!0))},getValidationRGX:function(e){return e.match(/[S+]/)?e.replace(/.*(\*[S+]).*/,"$1"):""},smileConversion:function(){var t=this.getSelectNode();if(t.nodeType==3){var n=t.data;n.length>=2&&!this.isInClearTextBlock(t)&&e(t).parents("a").size()==0&&e.each(this.options.srules,e.proxy(function(r,i){var s=i[0],o=n.indexOf(s);if(o!=-1){var u=n.substring(o+s.length,n.length),a=document.createTextNode(u),f=document.createElement("SPAN");return t.data=t.data.substr(0,o),e(t).after(a).after(f).after(this.strf(i[1],this.options)),this.selectNode(f),!1}},this))}},isInClearTextBlock:function(){if(this.cleartext){var t=!1;return e.each(this.cleartext,e.proxy(function(e,n){if(this.queryState(n))return t=n,!1},this)),t}return!1},wrapAttrs:function(t){return e.each(this.options.attrWrap,function(e,n){t=t.replace(n+'="',"_"+n+'="')}),t},unwrapAttrs:function(t){return e.each(this.options.attrWrap,function(e,n){t=t.replace("_"+n+'="',n+'="')}),t},disNonActiveButtons:function(){this.isInClearTextBlock()?this.$toolbar.find(".wysibb-toolbar-btn:not(.on,.mswitch)").addClass("dis"):this.$toolbar.find(".wysibb-toolbar-btn.dis").removeClass("dis")},showModal:function(t,n,r){e.log("showModal: "+t),this.saveRange();var i=this.$modal.find(".wbbm-content").html(""),s=this.$modal.find(".wbbm").removeClass("hastabs");this.$modal.find("span.wbbm-title-text").html(n.title);if(n.tabs&&n.tabs.length>1){s.addClass("hastabs");var o=e('<div class="wbbm-tablist">').appendTo(i).append("<ul>").children("ul");e.each(n.tabs,e.proxy(function(e,t){e==0&&(t.on="on"),o.append(this.strf("<li class="{on}" onClick="$(this).parent().find('.on').removeClass('on');$(this).addClass('on');$(this).parents('.wbbm-content').find('.tab-cont').hide();$(this).parents('.wbbm-content').find('.tab"+e+"').show()">{title}</li>",t))},this))}n.width&&s.css("width",n.width);var u=e('<div class="wbbm-cont">').appendTo(i);r?s.find("#wbbm-remove").show():s.find("#wbbm-remove").hide(),e.each(n.tabs,e.proxy(function(t,n){var i=e("<div>").addClass("tab-cont tab"+t).attr("tid",t).appendTo(u);t>0&&i.hide(),n.html?i.html(this.strf(n.html,this.options)):e.each(n.input,e.proxy(function(t,n){n.value=r[n.param.toLowerCase()],n.param.toLowerCase()=="seltext"&&(!n.value||n["value"]=="")&&(n.value=this.getSelectText(this.options.bbmode)),n.value&&n["value"].indexOf("<span id='wbbid")==0&&e(n.value).is("span[id*='wbbid']")&&(n.value=e(n.value).html()),n.type&&n.type=="div"?i.append(this.strf('<div class="wbbm-inp-row"><label>{title}</label><div class="inp-text div-modal-text" contenteditable="true" name="{param}">{value}</div></div>',n)):i.append(this.strf('<div class="wbbm-inp-row"><label>{title}</label><input class="inp-text modal-text" type="text" name="{param}" value="{value}"/></div>',n))},this))},this)),e.isFunction(n.onLoad)&&n.onLoad.call(this,t,n,r),s.find("#wbbm-submit").click(e.proxy(function(){if(e.isFunction(n.onSubmit)){var i=n.onSubmit.call(this,t,n,r);if(i===!1)return}var s={},o=!0;this.$modal.find(".wbbm-inperr").remove(),this.$modal.find(".wbbm-brdred").removeClass("wbbm-brdred"),e.each(this.$modal.find(".tab-cont:visible .inp-text"),e.proxy(function(t,r){var i=e(r).parents(".tab-cont").attr("tid"),u=e(r).attr("name").toLowerCase(),a="";e(r).is("input,textrea")?a=e(r).val():a=e(r).html();var f=n.tabs[i].input[t].validation;typeof f!="undefined"&&(a.match(new RegExp(f,"i"))||(o=!1,e(r).after('<span class="wbbm-inperr">'+CURLANG.validation_err+"</span>").addClass("wbbm-brdred"))),s[u]=a},this)),o&&(e.log("Last range: "+this.lastRange),this.selectLastRange(),r&&this.wbbRemoveCallback(t,!0),this.wbbInsertCallback(t,s),this.closeModal(),this.updateUI())},this)),s.find("#wbbm-remove").click(e.proxy(function(){this.selectLastRange(),this.wbbRemoveCallback(t),this.closeModal(),this.updateUI()},this)),e(document.body).css("overflow","hidden"),e("body").height()>e(window).height()&&e(document.body).css("padding-right","18px"),this.$modal.show(),s.css("margin-top",(e(window).height()-s.outerHeight())/3+"px"),setTimeout(e.proxy(function(){this.$modal.find(".inp-text:visible")[0].focus()},this),10)},escModal:function(e){e.which==27&&this.closeModal()},closeModal:function(){return e(document.body).css("overflow","auto").css("padding-right","0").unbind("keyup",this.escModal),this.$modal.find("#wbbm-submit,#wbbm-remove").unbind("click"),this.$modal.hide(),this.lastRange=!1,this},getParams:function(t,n,r){var i={};if(this.options.bbmode){var s=n.match(/{[sS]+?}/g);n=this.prepareRGX(n);var o=new RegExp(n,"g"),u=this.txtArea.value;r>0&&(u=u.substr(r,u.length-r));var a=o.exec(u);a&&e.each(s,function(e,t){i[t.replace(/{|}/g,"").replace(/"/g,"'").toLowerCase()]=a[e+1]})}else{var f=this.options.rules[n][0][1];e.each(f,e.proxy(function(n,r){var s="";r.attr!==!1?s=e(t).attr(r.attr):r.sel!==!1?s=e(t).find(r.sel).html():s=e(t).html();if(s){if(r.rgx!==!1){var o=s.match(new RegExp(r.rgx));o&&o.length==2&&(s=o[1])}i[n]=s.replace(/"/g,"'")}},this))}return i},imgLoadModal:function(){e.log("imgLoadModal"),this.options.imgupload===!0?(this.$modal.find("#imguploader").dragfileupload({url:this.strf(this.options.img_uploadurl,this.options),extraParams:{maxwidth:this.options.img_maxwidth,maxheight:this.options.img_maxheight},themePrefix:this.options.themePrefix,themeName:this.options.themeName,success:e.proxy(function(e){this.$txtArea.insertImage(e.image_link,e.thumb_link),this.closeModal(),this.updateUI()},this)}),e.support.htmlSerialize||(e.log("IE not posting form by security reason, show default file upload"),this.$modal.find("#nicebtn").hide(),this.$modal.find("#fileupl").css("opacity",1)),this.$modal.find("#fileupl").bind("change",function(){e("#fupform").submit()}),this.$modal.find("#fupform").bind("submit",e.proxy(function(t){e(t.target).parents("#imguploader").hide().after('<div class="loader"><img src="'+this.options.themePrefix+"/"+this.options.themeName+'/img/loader.gif" /><br/><span>'+CURLANG.loading+"</span></div>").parent().css("text-align","center")},this))):(this.$modal.find(".hastabs").removeClass("hastabs"),this.$modal.find("#imguploader").parents(".tab-cont").remove(),this.$modal.find(".wbbm-tablist").remove())},imgSubmitModal:function(){e.log("imgSubmitModal")},printObjectInIE:function(t){try{e.log(JSON.stringify(t))}catch(n){}},checkFilter:function(t,n){e.log("node: "+e(t).get(0).outerHTML+" filter: "+n+" res: "+e(t).is(n.toLowerCase()))},debug:function(t){if(this.options.debug===!0){var n=(new Date).getTime();typeof console!="undefined"?console.log(n-this.startTime+" ms: "+t):e("#exlog").append("<p>"+(n-this.startTime)+" ms: "+t+"</p>"),this.startTime=n}},isChrome:function(){return window.chrome?!0:!1},fixTableTransform:function(t){return t?e.inArray("table",this.options.buttons)==-1?t.replace(/<(/*?(table|tr|td|tbody))[^>]*>/ig,""):t.replace(/<(/*?(table|tr|td))[^>]*>/ig,"[$1]".toLowerCase()).replace(/</*tbody[^>]*>/ig,""):""}},e.log=function(t){typeof wbbdebug!="undefined"&&wbbdebug===!0&&(typeof console!="undefined"?console.log(t):e("#exlog").append("<p>"+t+"</p>"))},e.fn.wysibb=function(t){return this.each(function(){var n=e(this).data("wbb");n||new e.wysibb(this,t)})},e.fn.wdrag=function(t){t.scope||(t.scope=this);var n={x:0,y:0,height:0},r;t.scope.drag_mousedown=function(i){i.preventDefault(),n={x:i.pageX,y:i.pageY,height:t.height,sheight:t.scope.$body.height()},r=!0,e(document).bind("mousemove",e.proxy(t.scope.drag_mousemove,this)),e(this).addClass("drag")},t.scope.drag_mouseup=function(n){r===!0&&(n.preventDefault(),e(document).unbind("mousemove",t.scope.drag_mousemove),e(this).removeClass("drag"),r=!1)},t.scope.drag_mousemove=function(e){e.preventDefault();var r=0,i=0;t.axisX&&(r=e.pageX-n.x),t.axisY&&(i=e.pageY-n.y);if(i!=0){var s=n.sheight+i;s>n.height&&s<=t.scope.options.resize_maxheight&&(t.scope.options.bbmode==1?t.scope.$txtArea.css(t.scope.options.autoresize===!0?"min-height":"height",s+"px"):t.scope.$body.css(t.scope.options.autoresize===!0?"min-height":"height",s+"px"))}},e(this).bind("mousedown",t.scope.drag_mousedown),e(document).bind("mouseup",e.proxy(t.scope.drag_mouseup,this))},e.fn.getDoc=function(){return this.data("wbb").doc},e.fn.getSelectText=function(e){return this.data("wbb").getSelectText(e)},e.fn.bbcode=function(e){return typeof e!="undefined"?(this.data("wbb").options.bbmode?this.data("wbb").$txtArea.val(e):this.data("wbb").$body.html(this.data("wbb").getHTML(e)),this):this.data("wbb").getBBCode()},e.fn.htmlcode=function(e){if(!this.data("wbb").options.onlyBBMode&&this.data("wbb").inited===!0)return typeof e!="undefined"?(this.data("wbb").$body.html(e),this):this.data("wbb").getHTML(this.data("wbb").$txtArea.val())},e.fn.getBBCode=function(){return this.data("wbb").getBBCode()},e.fn.getHTML=function(){var e=this.data("wbb");return e.getHTML(e.$txtArea.val())},e.fn.getHTMLByCommand=function(e,t){return this.data("wbb").getHTMLByCommand(e,t)},e.fn.getBBCodeByCommand=function(e,t){return this.data("wbb").getBBCodeByCommand(e,t)},e.fn.insertAtCursor=function(e,t){return this.data("wbb").insertAtCursor(e,t),this.data("wbb")},e.fn.execCommand=function(e,t){return this.data("wbb").execCommand(e,t),this.data("wbb")},e.fn.insertImage=function(e,t){var n=this.data("wbb"),r=t?n.getCodeByCommand("link",{url:e,seltext:n.getCodeByCommand("img",{src:t})}):n.getCodeByCommand("img",{src:e});return this.insertAtCursor(r),n},e.fn.sync=function(){return this.data("wbb").sync(),this.data("wbb")},e.fn.destroy=function(){this.data("wbb").destroy()},e.fn.queryState=function(e){return this.data("wbb").queryState(e)}}(jQuery),function(e){"use strict";function t(t,n){this.$block=e(t),this.opt=e.extend({url:!1,success:!1,extraParams:!1,fileParam:"img",validation:".(jpg|png|gif|jpeg)$",t1:CURLANG.fileupload_text1,t2:CURLANG.fileupload_text2},n)}e.fn.dragfileupload=function(e){return this.each(function(){var n=new t(this,e);n.init()})},t.prototype={init:function(){if(window.FormData!=null){this.$block.addClass("drag"),this.$block.prepend('<div class="p2">'+this.opt.t2+"</div>"),this.$block.prepend('<div class="p">'+this.opt.t1+"</div>"),this.$block.bind("dragover",function(){return e(this).addClass("dragover"),!1}),this.$block.bind("dragleave",function(){return e(this).removeClass("dragover"),!1});var t=e.proxy(function(e){var t=parseInt(e.loaded/e.total*100,10);this.$loader.children("span").text(CURLANG.loading+": "+t+"%")},this),n=jQuery.ajaxSettings.xhr();n.upload&&n.upload.addEventListener("progress",t,!1),this.$block[0].ondrop=e.proxy(function(t){t.preventDefault(),this.$block.removeClass("dragover");var r=t.dataTransfer.files[0];if(this.opt.validation&&!r.name.match(new RegExp(this.opt.validation)))return this.error(CURLANG.validation_err),!1;var i=new FormData;i.append(this.opt.fileParam,r),this.opt.extraParams&&e.each(this.opt.extraParams,function(e,t){i.append(e,t)}),this.$loader=e('<div class="loader"><img src="'+this.opt.themePrefix+"/"+this.opt.themeName+'/img/loader.gif" /><br/><span>'+CURLANG.loading+"</span></div>"),this.$block.html(this.$loader),e.ajax({type:"POST",url:this.opt.url,data:i,processData:!1,contentType:!1,xhr:function(){return n},dataType:"json",success:e.proxy(function(e){e&&e.status==1?this.opt.success(e):this.error(e.msg||CURLANG.error_onupload)},this),error:e.proxy(function(e,t,n){this.error(CURLANG.error_onupload)},this)})},this)}},error:function(e){this.$block.find(".upl-error").remove().end().append('<span class="upl-error">'+e+"</span>").addClass("wbbm-brdred")}}}(jQuery);
?>