// table.js
if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.table=function(){return{getTemplate:function(){return String()+'<section id="redactor-modal-table-insert"><label>'+this.lang.get("rows")+'</label><input type="text" size="5" value="2" id="redactor-table-rows" /><label>'+this.lang.get("columns")+'</label><input type="text" size="5" value="3" id="redactor-table-columns" /></section>'},init:function(){var b={};b.insert_table={title:this.lang.get("insert_table"),func:this.table.show};b.insert_row_above={title:this.lang.get("insert_row_above"),func:this.table.addRowAbove};b.insert_row_below={title:this.lang.get("insert_row_below"),func:this.table.addRowBelow};b.insert_column_left={title:this.lang.get("insert_column_left"),func:this.table.addColumnLeft};b.insert_column_right={title:this.lang.get("insert_column_right"),func:this.table.addColumnRight};b.add_head={title:this.lang.get("add_head"),func:this.table.addHead};b.delete_head={title:this.lang.get("delete_head"),func:this.table.deleteHead};b.delete_column={title:this.lang.get("delete_column"),func:this.table.deleteColumn};b.delete_row={title:this.lang.get("delete_row"),func:this.table.deleteRow};b.delete_table={title:this.lang.get("delete_table"),func:this.table.deleteTable};this.observe.addButton("td","table");this.observe.addButton("th","table");var a=this.button.addBefore("link","table",this.lang.get("table"));this.button.addDropdown(a,b)},show:function(){this.modal.addTemplate("table",this.table.getTemplate());this.modal.load("table",this.lang.get("insert_table"),300);this.modal.createCancelButton();var a=this.modal.createActionButton(this.lang.get("insert"));a.on("click",this.table.insert);this.selection.save();this.modal.show();$("#redactor-table-rows").focus()},insert:function(){var n=$("#redactor-table-rows").val(),c=$("#redactor-table-columns").val(),a=$("<div>"),b=Math.floor(Math.random()*99999),l=$('<table id="table'+b+'"><tbody></tbody></table>'),e,h,j,k;for(e=0;e<n;e++){h=$("<tr>");for(j=0;j<c;j++){k=$("<td>"+this.opts.invisibleSpace+"</td>");if(e===0&&j===0){k.append(this.selection.getMarker())}$(h).append(k)}l.append(h)}a.append(l);var f=a.html();this.modal.close();this.selection.restore();if(this.table.getTable()){return}this.buffer.set();var g=this.selection.getBlock()||this.selection.getCurrent();if(g&&g.tagName!="BODY"){if(g.tagName=="LI"){g=$(g).closest("ul, ol")}$(g).after(f)}else{this.insert.html(f)}this.selection.restore();var m=this.$editor.find("#table"+b);if(!this.opts.linebreaks&&(this.utils.browser("mozilla")||this.utils.browser("msie"))){var d=m.next();if(d.length===0){m.after(this.opts.emptyHtml)}}this.observe.buttons();m.find("span.redactor-selection-marker").remove();m.removeAttr("id");this.code.sync();this.core.setCallback("insertedTable",m)},getTable:function(){var a=$(this.selection.getParent()).closest("table");if(!this.utils.isRedactorParent(a)){return false}if(a.size()===0){return false}return a},restoreAfterDelete:function(a){this.selection.restore();a.find("span.redactor-selection-marker").remove();this.code.sync()},deleteTable:function(){var b=this.table.getTable();if(!b){return}this.buffer.set();var a=b.next();if(!this.opts.linebreaks&&a.length!==0){this.caret.setStart(a)}else{this.caret.setAfter(b)}b.remove();this.code.sync()},deleteRow:function(){var a=this.table.getTable();if(!a){return}var c=$(this.selection.getCurrent());this.buffer.set();var e=c.closest("tr");var b=e.prev().length?e.prev():e.next();if(b.length){var d=b.children("td, th").first();if(d.length){d.prepend(this.selection.getMarker())}}e.remove();this.table.restoreAfterDelete(a)},deleteColumn:function(){var c=this.table.getTable();if(!c){return}this.buffer.set();var d=$(this.selection.getCurrent());var a=d.closest("td, th");var b=a[0].cellIndex;c.find("tr").each($.proxy(function(f,g){var e=$(g);var h=b-1<0?b+1:b-1;if(f===0){e.find("td, th").eq(h).prepend(this.selection.getMarker())}e.find("td, th").eq(b).remove()},this));this.table.restoreAfterDelete(c)},addHead:function(){var a=this.table.getTable();if(!a){return}this.buffer.set();if(a.find("thead").size()!==0){this.table.deleteHead();return}var b=a.find("tr").first().clone();b.find("td").html(this.opts.invisibleSpace);$thead=$("<thead></thead>").append(b);a.prepend($thead);this.code.sync()},deleteHead:function(){var a=this.table.getTable();if(!a){return}var b=a.find("thead");if(b.size()===0){return}this.buffer.set();b.remove();this.code.sync()},addRowAbove:function(){this.table.addRow("before")},addRowBelow:function(){this.table.addRow("after")},addColumnLeft:function(){this.table.addColumn("before")},addColumnRight:function(){this.table.addColumn("after")},addRow:function(c){var a=this.table.getTable();if(!a){return}this.buffer.set();var b=$(this.selection.getCurrent());var d=b.closest("tr");var e=d.clone();e.find("th").replaceWith(function(){var f=$("<td>");f[0].attributes=this.attributes;return f.append($(this).contents())});e.find("td").html(this.opts.invisibleSpace);if(c=="after"){d.after(e)}else{d.before(e)}this.code.sync()},addColumn:function(d){var c=this.table.getTable();if(!c){return}var b=0;var e=$(this.selection.getCurrent());this.buffer.set();var f=e.closest("tr");var a=e.closest("td, th");f.find("td, th").each($.proxy(function(g,h){if($(h)[0]===a[0]){b=g}},this));c.find("tr").each($.proxy(function(g,j){var h=$(j).find("td, th").eq(b);var k=h.clone();k.html(this.opts.invisibleSpace);if(d=="after"){h.after(k)}else{h.before(k)}},this));this.code.sync()}}};
// wbbcode.js
-if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wbbcode=function(){var a=false;return{init:function(){var e=this.$textarea.wcfIdentify();this.opts.initCallback=(function(){if($.browser.msie){this.$editor.addClass("msie")}var i=$.trim(this.wutil.getOption("woltlab.originalValue"));if(i.length){this.wutil.replaceText(i);this.wutil.selectionEndOfEditor()}delete this.opts.woltlab.originalValue;$(document).trigger("resize");this.wutil.saveSelection()}).bind(this);this.opts.pasteBeforeCallback=$.proxy(this.wbbcode._pasteBeforeCallback,this);this.opts.pasteCallback=$.proxy(this.wbbcode._pasteCallback,this);var d=this.clean.onSync;this.clean.onSync=(function(i){if(a===true){a=false}else{i=i.replace(/<p><br([^>]+)?><\/p>/g,"<p>@@@wcf_empty_line@@@</p>")}return d.call(this,i)}).bind(this);if(this.wutil.getOption("woltlab.autosaveOnce")){this.wutil.saveTextToStorage();delete this.opts.woltlab.autosaveOnce}var c=this.button.get("table");if(c.length){var h=c.data("dropdown");h.find(".redactor-dropdown-add_head").parent().remove();h.find(".redactor-dropdown-delete_head").parent().remove();$('<li class="dropdownDivider" />').insertBefore(h.find(".redactor-dropdown-delete_table").parent());c.click($.proxy(this.wbbcode._tableButtonClick,this))}WCF.System.Event.addListener("com.woltlab.wcf.redactor","insertBBCode_quote_"+e,$.proxy(function(i){i.cancel=true;this.wbbcode._handleInsertQuote()},this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","insertBBCode_code_"+e,$.proxy(function(i){i.cancel=true;this.wbbcode._handleInsertCode(null,true)},this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+e,$.proxy(this.wbbcode._keydownCallback,this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","keyup_"+e,$.proxy(this.wbbcode._keyupCallback,this));this.code.sync=function(){};var f=$(".redactor-toolbar-tooltip-html:not(.jsWbbcode)").addClass("jsWbbcode").text(WCF.Language.get("wcf.bbcode.button.toggleBBCode"));var g=function(i){i.find("br").each(function(j,k){if(k.children.length){$(k).empty()}})};this.code.toggle=(function(){if(this.opts.visual){this.code.startSync();this.code.showCode();this.$textarea.val(this.wbbcode.convertFromHtml(this.$textarea.val()));this.button.get("html").children("i").removeClass("fa-square-o").addClass("fa-square");f.text(WCF.Language.get("wcf.bbcode.button.toggleHTML"))}else{this.$textarea.val(this.wbbcode.convertToHtml(this.$textarea.val()));this.code.offset=this.$textarea.val().length;this.code.showVisual();this.wbbcode.fixBlockLevelElements();this.wutil.selectionEndOfEditor();this.wbbcode.observeQuotes();this.wbbcode.observeCodeListings();this.button.get("html").children("i").removeClass("fa-square").addClass("fa-square-o");f.text(WCF.Language.get("wcf.bbcode.button.toggleBBCode"));this.wutil.fixDOM();g(this.$editor);this.wutil.saveSelection()}}).bind(this);this.wutil.setOption("clickCallback",(function(i){this.wutil.saveSelection();if(i.target===this.$editor[0]){if(this.$editor[0].lastElementChild&&this.$editor[0].lastElementChild.tagName==="BLOCKQUOTE"){this.wutil.setCaretAfter($(this.$editor[0].lastElementChild))}}}).bind(this));var b=this.opts.verifiedTags.indexOf("ul");if(b>-1){this.opts.verifiedTags.splice(b,1)}WCF.System.Event.addListener("com.woltlab.wcf.redactor","observe_load_"+e,(function(i){this.wbbcode.observeCodeListings();this.wbbcode.observeQuotes()}).bind(this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","fixFormatting_"+e,$.proxy(this.wbbcode.fixFormatting,this))},_tableButtonClick:function(c){var d=$(c.currentTarget);if(!d.hasClass("dropact")){return}var b=this.selection.getBlock()||this.selection.getCurrent();var e=d.data("dropdown");e.children("li").show();var f=e.find("> li > .redactor-dropdown-insert_table").parent();if(b.tagName=="TD"){f.hide()}else{f.nextAll().hide()}},insertSmiley:function(b,c,d){if(d){this.wbbcode.registerSmiley(b,c)}if(this.opts.visual){this.insert.html(' <img src="'+c+'" class="smiley" alt="'+b+'" /> ',false)}else{this.wutil.insertAtCaret(" "+b+" ")}},registerSmiley:function(b,c){if(__REDACTOR_SMILIES[b]){return false}__REDACTOR_SMILIES[b]=c;return true},convertFromHtml:function(m){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertFromHtml",{html:m});m=m.replace(/(<[^>]+?) data-redactor-tag="[^"]+"/g,"$1");m=m.replace(/(<[^>]+?) rel="[^"]+"/g,"$1");m=m.replace(/&#(8203|x200b);/g,"");m=m.replace(/™/gi,"\u2122");m=m.replace(/©/gi,"\u00a9");m=m.replace(/…/gi,"\u2026");m=m.replace(/—/gi,"\u2014");m=m.replace(/‐/gi,"\u2010");var r={};m=m.replace(/<div class="codeBox[^"]+"(.*?)>\n*<div>[\s\S]+?<ol start="(\d+)">([\s\S]+?)<\/ol>\n*<\/div>\n*<\/div>/g,function(B,C,z,E){var D="";var y="";if(C.match(/data-highlighter="([a-zA-Z]+)"/)){D=RegExp.$1}if(C.match(/data-filename="([^"]+)"/)){y=$.trim(RegExp.$1)}var A=WCF.getUUID();r[A]={codeContent:E.replace(/<li>/g,"").replace(/<\/li>/g,"\n").replace(/\n$/,""),filename:y.replace(/['"]/g,""),highlighter:(D==="plain"?"":D),lineNumber:(z>1?z:0)};return"@@@"+A+"@@@"});m=m.replace(/\r?\n/g,"");m=m.replace(/<a[^>]*?><\/a>/g,"");m=m.replace(/<p><\/p><p>(?!<br>)/g,"<p>@@@wcf_empty_line@@@</p><p>");m=m.replace(/<br( \/)?><\/p>/g,"</p>");var h=m.split(/(<\/?(?:div|p)>)/);var i="";var w="";for(var b=0;b<h.length;b++){var x=h[b];if(x=="<p>"||x=="<div>"){continue}else{if(x=="</p>"||x=="</div>"){w=$.trim(w);if(w!="@@@wcf_empty_line@@@"){w+="\n"}i+=w;w=""}else{if(b==0||b+1==h.length){i+=x}else{w+=x}}}}if(w){i+=w;w=""}m=i;m=m.replace(/@@@wcf_empty_line@@@/g,"\n");m=m.replace(/\n\n$/,"\n");m=m.replace(/<br>$/,"");m=m.replace(/<br>/g,"\n");m=m.replace(/<br>/g,"");m=m.replace(/ /gi," ");m=m.replace(/<blockquote([^>]+)>\n?<header[^>]*?>[\s\S]*?<\/header>/gi,function(A,z,C){var D;var B="";var y="";if(z.match(/data-author="([^"]+)"/)){B=WCF.String.unescapeHTML(RegExp.$1)}if(z.match(/cite="([^"]+)"/)){y=WCF.String.unescapeHTML(RegExp.$1)}if(y){D="[quote='"+B+"','"+y+"']"}else{if(B){D="[quote='"+B+"']"}else{D="[quote]"}}return D});m=m.replace(/(?:\n*)<\/blockquote>\n?/gi,"[/quote]\n");m=m.replace(/<a [^>]*?href=(["'])mailto:(.+?)\1.*?>([\s\S]+?)<\/a>/gi,"[email=$2]$3[/email]");m=m.replace(/<a[^>]+><\/a>/,"");m=m.replace(/<a [^>]*?href=(["'])(.+?)\1.*?>([\s\S]+?)<\/a>/gi,function(A,y,z,B){if(z==B){return"[url]"+z+"[/url]"}return"[url='"+z+"']"+B+"[/url]"});m=m.replace(/<(?:b|strong)>/gi,"[b]");m=m.replace(/<\/(?:b|strong)>/gi,"[/b]");m=m.replace(/<(?:i|em)>/gi,"[i]");m=m.replace(/<\/(?:i|em)>/gi,"[/i]");m=m.replace(/<u>/gi,"[u]");m=m.replace(/<\/u>/gi,"[/u]");m=m.replace(/<sub>/gi,"[sub]");m=m.replace(/<\/sub>/gi,"[/sub]");m=m.replace(/<sup>/gi,"[sup]");m=m.replace(/<\/sup>/gi,"[/sup]");m=m.replace(/<(?:s(trike)?|del)>/gi,"[s]");m=m.replace(/<\/(?:s(trike)?|del)>/gi,"[/s]");var f=m.split(/(<\/?span[^>]*>)/);var w=[];var o=[];var p="";var d={11:8,13:10,16:12,19:14,24:18,29:22,32:24,48:36};for(var b=0;b<f.length;b++){var j=f[b];if(j=="</span>"){var e=o.pop();var i=e.start+$.trim(w.pop())+e.end;if(w.length){w[w.length-1]+=i}else{p+=i}}else{if(j.match(/^<span/)){if(j.match(/^<span(?:.*?)style="([^"]+)"(?:[^>]*?)>/)){var l=RegExp.$1;var u;var n;if(l.match(/color: ?rgb\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\);?/i)){var t=RegExp.$1;var c=RegExp.$2;var g=RegExp.$3;var q=("0123456789ABCDEF".charAt((t-t%16)/16)+""+"0123456789ABCDEF".charAt(t%16))+""+("0123456789ABCDEF".charAt((c-c%16)/16)+""+"0123456789ABCDEF".charAt(c%16))+""+("0123456789ABCDEF".charAt((g-g%16)/16)+""+"0123456789ABCDEF".charAt(g%16));u="[color=#"+q+"]";n="[/color]"}else{if(l.match(/color: ?([^;]+);?/i)){u="[color="+RegExp.$1+"]";n="[/color]"}else{if(l.match(/font-size: ?(\d+)(pt|px);?/i)){if(RegExp.$2=="pt"){u="[size="+RegExp.$1+"]";n="[/size]"}else{if(d[RegExp.$1]){u="[size="+d[RegExp.$1]+"]";n="[/size]"}else{u="";n=""}}}else{if(l.match(/font-family: ?([^;]+);?/)){u="[font='"+RegExp.$1.replace(/'/g,"")+"']";n="[/font]"}else{u='<span style="'+l+'">';n="</span>"}}}}w[w.length]="";o[w.length]={start:u,end:n}}else{if(j.match(/^<span class="inlineCode">/)){w[w.length]="";o[w.length]={start:"[tt]",end:"[/tt]"}}else{w[w.length]="";o[w.length]={start:"",end:""}}}}else{if(w.length){w[w.length-1]+=j}else{p+=j}}}}m=p;m=m.replace(/<(div|p) style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)\n/gi,function(z,y,B,A){return"[align="+B+"]"+$.trim(A)+"[/align]\n"});m=m.replace(/ ?<img [^>]*?alt="([^"]+?)" class="smiley".*?> ?/gi," $1 ");m=m.replace(/ ?<img [^>]*?class="smiley" alt="([^"]+?)".*?> ?/gi," $1 ");m=m.replace(/<img(.*?)class="redactorEmbeddedAttachment"(.*?)>/gi,function(B,E,G){var H=E+" "+G;var D;if(H.match(/data-attachment-id="(\d+)"/)){D=RegExp.$1}else{return B}var A="none";var z=null;if(H.match(/style="([^"]+)"/)){var C=RegExp.$1.split(";");for(var F=0;F<C.length;F++){var y=$.trim(C[F]);if(y.match(/^float: (left|right)$/)){A=RegExp.$1}else{if(y.match(/^width: (\d+)px$/)){z=RegExp.$1}}}if(z!==null){return"[attach="+D+","+A+","+z+"][/attach]"}else{if(A!=="none"){return"[attach="+D+","+A+"][/attach]"}}}return"[attach="+D+"][/attach]"});m=m.replace(/<img [^>]*?src=(["'])([^"']+?)\1.*?style="([^"]+)".*?>/gi,function(D,G,z,A){var C="none";var B=0;var E=A.split(";");for(var F=0;F<E.length;F++){var y=E[F];if(y.match(/float: (left|right|none)/)){C=RegExp.$1}else{if(y.match(/width: (\d+)px/)){B=parseInt(RegExp.$1)}}}if(B){return"[img='"+z+"',"+C+","+B+"][/img]"}else{if(C!=="none"){return"[img='"+z+"',"+C+"][/img]"}}return"[img]"+z+"[/img]"});m=m.replace(/<img [^>]*?src=(["'])([^"']+?)\1.*?>/gi,"[img]$2[/img]");m=m.replace(/<li>/gi,"[*]");m=m.replace(/<\/li>/gi,"\n");m=m.replace(/<ul>/gi,"[list]");m=m.replace(/<(ol|ul style="list-style-type: decimal")>/gi,"[list=1]");m=m.replace(/<ul style="list-style-type: (none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)">/gi,"[list=$1]");m=m.replace(/<\/(ul|ol)>/gi,"[/list]");m=m.replace(/\n?\[list\]/g,"\n[list]");m=m.replace(/\[\/list\]\n\[\*\]/g,"[/list][*]");m=m.replace(/\[\/list\]\n\[\/list\]/g,"[/list][/list]");m=m.replace(/<table[^>]*>/gi,"[table]\n");m=m.replace(/<\/table>/gi,"[/table]\n");m=m.replace(/<tbody>([\s\S]*?)<\/tbody>/,function(y,z){return $.trim(z)});m=m.replace(/<tr><\/tr>/gi,"");m=m.replace(/<tr>/gi,"[tr]\n");m=m.replace(/<\/tr>/gi,"[/tr]\n");m=m.replace(/<td style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)<\/td>/gi,"[td][align=$1]$2[/align][/td]");m=m.replace(/(\t)*<td>(\t)*/gi,"[td]");m=m.replace(/(\t)*<\/td>/gi,"[/td]\n");var v={};m.replace(/<span id="selection-marker-\d+" class="redactor-selection-marker"><\/span>/,function(y){var z=y.hashCode();v[z]=y.replace(/\$/g,"$$$$");return"@@"+z+"@@"});WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","convertFromHtml",{html:m});m=m.replace(/<[^(<|>)]+>/g,"");if($.getLength(v)){for(var k in v){var s=new RegExp("@@"+k+"@@","g");data=data.replace(s,v[k])}}if($.getLength(r)){$.each(r,function(A,C){var z=0;if(C.highlighter){z++}if(C.lineNumber){z++}if(C.filename){z++}var y="";switch(z){case 1:if(C.highlighter){y=C.highlighter}else{if(C.filename){y="'"+C.filename+"'"}else{y=C.lineNumber}}break;case 2:if(C.highlighter){y=C.highlighter}if(C.lineNumber){if(y.length){y+=","}y+=C.lineNumber}if(C.filename){if(y.length){y+=","}y+="'"+C.filename+"'"}break;case 3:y=C.highlighter+","+C.lineNumber+",'"+C.filename+"'";break}var B="[code"+(y.length?"="+y:"")+"]"+C.codeContent+"[/code]\n";m=m.replace(new RegExp("@@@"+A+"@@@\n?","g"),B)})}m=m.replace(/</g,"<");m=m.replace(/>/g,">");m=m.replace(/&/g,"&");m=m.replace(/%28/g,"(");m=m.replace(/%29/g,")");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertFromHtml",{html:m});m=$.trim(m);if(m.length){m+="\n"}return m},convertToHtml:function(I){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertToHtml",{data:I});I=this.wutil.removeZeroWidthSpace(I);I=I.replace(/&/g,"&");I=I.replace(/</g,"<");I=I.replace(/>/g,">");var u=[];var o=new RegExp("\\[("+__REDACTOR_SOURCE_BBCODES.join("|")+")([\\S\\s]+?)\\[\\/\\1\\]","gi");I=I.replace(o,function(J){var K=J.hashCode();u.push({key:K,value:J.replace(/\$/g,"$$$$")});return"@@"+K+"@@"});I=I.replace(/\[url\]([^"]+?)\[\/url]/gi,'<a href="$1">$1</a>'+this.opts.invisibleSpace);I=I.replace(/\[url\='([^'"]+)']([\s\S]+?)\[\/url]/gi,'<a href="$1">$2</a>'+this.opts.invisibleSpace);I=I.replace(/\[url\=([^'"\]]+)]([\s\S]+?)\[\/url]/gi,'<a href="$1">$2</a>'+this.opts.invisibleSpace);I=I.replace(/\[email\]([^"]+?)\[\/email]/gi,'<a href="mailto:$1">$1</a>'+this.opts.invisibleSpace);I=I.replace(/\[email\=([^"\]]+)](.+?)\[\/email]/gi,'<a href="mailto:$1">$2</a>'+this.opts.invisibleSpace);I=I.replace(/\[b\]([\s\S]*?)\[\/b]/gi,"<strong>$1</strong>");I=I.replace(/\[i\]([\s\S]*?)\[\/i]/gi,"<em>$1</em>");I=I.replace(/\[u\]([\s\S]*?)\[\/u]/gi,"<u>$1</u>");I=I.replace(/\[s\]([\s\S]*?)\[\/s]/gi,"<strike>$1</strike>");I=I.replace(/\[sub\]([\s\S]*?)\[\/sub]/gi,"<sub>$1</sub>");I=I.replace(/\[sup\]([\s\S]*?)\[\/sup]/gi,"<sup>$1</sup>");I=I.replace(/\[img\]([^"]+?)\[\/img\]/gi,'<img src="$1" />');I=I.replace(/\[img='?([^"]*?)'?,'?(left|right)'?\]\[\/img\]/gi,function(K,L,M){var J="float: "+M+";";if(M==="left"){J+="margin: 0 15px 7px 0"}else{J+="margin: 0 0 7px 15px"}return'<img src="'+L+'" style="'+J+'" />'});I=I.replace(/\[img='?([^"]*?)'?,'?(left|right|none)'?,'?(\d+)'?\]\[\/img\]/gi,function(K,M,N,L){var J="float: "+N+"; width: "+L+"px;";if(N==="left"){J+="margin: 0 15px 7px 0"}else{J+="margin: 0 0 7px 15px"}return'<img src="'+M+'" style="'+J+'" />'});I=I.replace(/\[img='?([^"]*?)'?\]\[\/img\]/gi,'<img src="$1" />');I=I.replace(/\[size=(\d+)\]([\s\S]*?)\[\/size\]/gi,(function(J,K,L){L=$.trim(L);if(!L.length){L=this.opts.invisibleSpace}return'<span style="font-size: '+K+'pt">'+L+"</span>"}).bind(this));I=I.replace(/\[color=([#a-z0-9]*?)\]([\s\S]*?)\[\/color\]/gi,(function(K,J,L){L=$.trim(L);if(!L.length){L=this.opts.invisibleSpace}return'<span style="color: '+J+'">'+L+"</span>"}).bind(this));I=I.replace(/\[font='?([a-z,\- ]*?)'?\]([\s\S]*?)\[\/font\]/gi,(function(K,J,L){L=$.trim(L);if(!L.length){L=this.opts.invisibleSpace}return'<span style="font-family: '+J+'">'+L+"</span>"}).bind(this));I=I.replace(/\[align=(left|right|center|justify)\]([\s\S]*?)\[\/align\]/gi,'<div style="text-align: $1">$2</div>');var s=I.indexOf("[list");if(s>0){var h=I.substr(0,s);h=h.replace(/\[\*\]/g,"");I=h+I.substr(s)}var x=I.indexOf("[/list]");if(x===-1){I=I.replace(/\[\*\]/g,"");I=I.replace(/\[list[^\]]*\]/g,"")}else{var h=I.substr(x+7);h=h.replace(/\[\*\]/g,"");I=I.substr(0,x+7)+h}I=I.replace(/\[\*\]([\s\S]*?)(?=\[\*\]|\[\/list\])/gi,function(J,K){return"<li>"+$.trim(K)+"</li>"});I=I.replace(/\n*(\[list\]<\/li>)/g,"$1");I=I.replace(/\[list\]/gi,"<ul>");I=I.replace(/\[list=1\]/gi,'<ul style="list-style-type: decimal">');I=I.replace(/\[list=a\]/gi,'<ul style="list-style-type: lower-latin">');I=I.replace(/\[list=(none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)\]/gi,'<ul style="list-style-type: $1">');I=I.replace(/\[\/list\]/gi,"</ul>");I=I.replace(/\[table\]([\S\s]*?)\[\/table\]/gi,function(J,K){return"[table]"+$.trim(K)+"[/table]"});I=I.replace(/\[table\]\n*/gi,'<table border="1" cellspacing="1" cellpadding="1" style="width: 500px;">');I=I.replace(/\[\/table\](\n*)?/gi,function(J,K){if(K){if(K.match(/\n/g).length>2){K=K.replace(/^\n/,"")}return"</table>"+K}return"</table>"});I=I.replace(/\[tr\]\n*/gi,"<tr>");I=I.replace(/\[\/tr\]\n*/gi,"</tr>");I=I.replace(/\[td\]\n*/gi,"<td>");I=I.replace(/\[\/td\]\n*/gi,"</td>");I=I.replace(/<td>([\S\s]*?)<\/td>/gi,function(J,L){var K=$.trim(L);if(!K.length){K="​"}return"<td>"+K+"</td>"});var d=this.wutil.getOption("woltlab.attachmentUrl");var H=this.wutil.getOption("woltlab.attachmentThumbnailUrl");if(d){var F=this.wbbcode._getImageAttachments();I=I.replace(/\[attach=(\d+)\]\[\/attach\]/g,function(J,K,L){K=parseInt(K);if(F[K]!==undefined){return'<img src="'+H.replace(/987654321/,K)+'" class="redactorEmbeddedAttachment redactorDisableResize" data-attachment-id="'+K+'" />'}return J});I=I.replace(/\[attach=(\d+),(left|right|none)\]\[\/attach\]/g,function(K,L,M){L=parseInt(L);if(F[L]!==undefined){var J="";if(M==="left"||M==="right"){J="float: "+M+";";if(M==="left"){J+="margin: 0 15px 7px 0"}else{J+="margin: 0 0 7px 15px"}}J=' style="'+J+'"';return'<img src="'+H.replace(/987654321/,L)+'" class="redactorEmbeddedAttachment redactorDisableResize" data-attachment-id="'+L+'"'+J+" />"}return K});I=I.replace(/\[attach=(\d+),(left|right|none),(\d+)\]\[\/attach\]/g,function(K,M,N,L){M=parseInt(M);if(F[M]!==undefined){var J="width: "+L+"px; max-height: "+F[M].height+"px; max-width: "+F[M].width+"px;";if(N==="left"||N==="right"){J+="float: "+N+";";if(N==="left"){J+="margin: 0 15px 7px 0"}else{J+="margin: 0 0 7px 15px"}}J=' style="'+J+'"';return'<img src="'+d.replace(/987654321/,M)+'" class="redactorEmbeddedAttachment" data-attachment-id="'+M+'"'+J+" />"}return K})}for(var w in __REDACTOR_SMILIES){var k=w.replace(/</g,"<").replace(/>/g,">");var j=new RegExp("(\\s|>|^)"+WCF.String.escapeRegExp(k)+"(?=\\s|<|$)","gi");I=I.replace(j,'$1<img src="'+__REDACTOR_SMILIES[w]+'" class="smiley" alt="'+k+'" />')}I=I.replace(/(javascript):/gi,"$1<span></span>:");I=I.replace(/(\r|\r\n)/g,"\n");var B=[];var E=[];var g=I.split(/(\[(?:\/quote|quote|quote='[^']*?'(?:,'[^']*?')?|quote="[^"]*?"(?:,"[^"]*?")?)\])/i);var e=WCF.getUUID();while(true){var p=false;for(var b=0;b<g.length;b++){var D=g[b];if(D.toLowerCase()==="[/quote]"){p=true;var f="";var n=g.slice(0,b);var c=false;while(n.length){var C=n.pop();f=C+f;if(C.match(/^\[quote/i)){D=f+D;var m=WCF.getUUID();B.push({hashCode:m,content:D.replace(/\$/g,"$$$$")});E.push(m);D="@@"+m+"@@";c=true;break}}if(!c){n=g.slice(0,b);D=e}g=n.concat(D,g.slice(b+1));break}}if(!p){break}}I=g.join("");I=I.replace(new RegExp(e,"g"),"[/quote]");I=I.replace(/\n*$/,"");var y=[];I=I.replace(/(<li>[\s\S]*?<\/li>)/g,function(J){J=$.trim(J).replace(/\n/,"<br>");var K=WCF.getUUID();y.push({key:K,content:J});return K});var h=I.split("\n");I="";for(var b=0,l=h.length;b<l;b++){var t=$.trim(h[b]);if(t.match(/^<([a-z]+)/)||t.match(/<\/([a-z]+)>$/)){if(this.reIsBlock.test(RegExp.$1.toUpperCase())){if(t.match(/^<([a-z]+).*<\/\1>/)){I+=t}else{I+=t+"<br />"}}else{I+="<p>"+t+"</p>"}}else{if(!t){t="<br>"}else{if(t.match(/^@@([0-9\-]+)@@$/)){if(WCF.inArray(RegExp.$1,E)){I+=t;continue}}}I+="<p>"+t+"</p>"}}if(y.length){for(var b=y.length-1;b>=0;b--){I=I.replace(y[b].key,y[b].content)}}if(B.length){var G=function(J){return J.replace(/^['"]/,"").replace(/['"]$/,"")};var r=this;var q=function(J){return J.replace(/\[quote(=['"].+['"])?\]([\S\s]*)\[\/quote\]/gi,function(M,L,O){var S="";var N="";if(L){L=L.substr(1);L=L.split(",");switch(L.length){case 1:S=L[0];break;case 2:S=L[0];N=L[1];break}S=WCF.String.escapeHTML(G($.trim(S)));N=WCF.String.escapeHTML(G($.trim(N)))}var T='<blockquote class="quoteBox container containerPadding quoteBoxSimple" cite="'+N+'" data-author="'+S+'"><header contenteditable="false"><h3>'+r.wbbcode._buildQuoteHeader(S,N)+'</h3><a class="redactorQuoteEdit"></a></header>';O=$.trim(O);var K="";if(O.length){var R=O.split("\n");for(var Q=0;Q<R.length;Q++){var P=R[Q];if(P.length===0){P=r.opts.invisibleSpace}else{if(P.match(/^@@([0-9\-]+)@@$/)){if(WCF.inArray(RegExp.$1,E)){K+=P;continue}}}K+="<div>"+P+"</div>"}}else{K="<div>"+r.opts.invisibleSpace+"</div>"}T+=K;T+="</blockquote>";return T})};for(var b=B.length-1;b>=0;b--){var v=B[b];var z=new RegExp("@@"+v.hashCode+"@@","g");I=I.replace(z,q(v.content))}}if(u.length){for(var b=u.length-1;b>=0;b--){var A=u[b];var z=new RegExp("@@"+A.key+"@@","g");var i=A.value;i=i.replace(/^\[code([^\]]*)\]([\S\s]*)\[\/code\]$/,function(M,T,O){var N="plain";var R=0;var Q="";if(T){T=T.substring(1);T=T.split(",");var P=function(V){return V.match(/^\d+$/)};var L=function(V){return(V.indexOf(".")!==-1)};var K=function(V){return(__REDACTOR_CODE_HIGHLIGHTERS[T[0]]!==undefined)};var J=function(V){return V.replace(/^(["'])(.*)\1$/,"$2")};switch(T.length){case 1:if(P(T[0])){R=(parseInt(T[0])>1)?T[0]:0}else{if(L(T[0])){Q=J(T[0])}else{if(K(T[0])){N=T[0]}}}break;case 2:if(P(T[0])){R=(parseInt(T[0])>1)?T[0]:0;if(L(T[1])){Q=J(T[1])}else{if(K(T[1])){N=T[1]}}}else{if(K(T[0])){N=T[0]}if(L(T[1])){Q=J(T[1])}}break;case 3:if(K(T[0])){N=T[0]}if(P(T[1])){R=T[1]}if(L(T[2])){Q=J(T[2])}break}}O=O.replace(/^\n+/,"").replace(/\n+$/,"").split(/\n/);var U="";for(var S=0;S<O.length;S++){U+="<li>"+O[S]+"</li>"}return'<div class="codeBox container" contenteditable="false" data-highlighter="'+N+'"'+(Q?' data-filename="'+WCF.String.escapeHTML(Q)+'"':"")+"><div><div><h3>"+__REDACTOR_CODE_HIGHLIGHTERS[N]+(Q?": "+WCF.String.escapeHTML(Q):"")+'</h3></div><ol start="'+(R>1?R:1)+'">'+U+"</ol></div></div>"});I=I.replace(z,i)}}I=I.replace(/<p><(blockquote|div)/g,"<$1");I=I.replace(/<\/(blockquote|div)><\/p>/g,"</$1>");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertToHtml",{data:I});return I},_pasteBeforeCallback:function(b){var c={1:24,2:22,3:18,4:14,5:12,6:10};b=b.replace(/<h([1-6])([^>]*)>/g,function(g,j,i){if(i&&i.match(/style="([^"]+?)"/)){if(/font-size: ?(\d+|\d+\.\d+)(px|pt|em|rem|%)/.test(RegExp.$1)){var d=$('<div style="width: '+RegExp.$1+RegExp.$2+'; position: absolute;" />').appendTo(document.body);var f=parseInt(d[0].clientWidth);d.remove();var e=-1;var h=false;$.each(c,function(m,l){if(e===-1){e=m}else{if(Math.abs(f-l)<Math.abs(f-c[e])){e=m}}if(f==l){h=true}});if(!h){e=(e<6)?parseInt(e)+1:e}j=e}}return"[size="+c[j]+"]"});b=b.replace(/<\/h[1-6]>/g,"[/size]");b=b.replace(/<(article|header)[^>]+>/g,"<div>");b=b.replace(/<\/(article|header)>/g,"</div>");b=b.replace(/<(div|p)([^>]+)?><(div|p)([^>]+)?>/g,"<p>");b=b.replace(/<\/(div|p)><\/(div|p)>/g,"</p>");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforePaste",{html:b});return b},_pasteCallback:function(c){var b=WCF.getUUID();c=c.replace(/<p>([\s\S]*?)<\/p>/gi,function(d,e){if(e.match(/^<br( \/)?>$/)){return d}return d+"@@@"+b+"@@@"});c=c.replace(new RegExp("@@@"+b+"@@@(<p><br(?: /)?></p>)?","g"),function(d,e){if(e){return e}return"<p><br></p>"});c=c.replace(/\[size=(\d+)\]/g,'<p><span style="font-size: $1pt">');c=c.replace(/\[\/size\]/g,"</span></p>");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterPaste",{html:c});return c;c=c.replace(/<img([^>]+)>/g,function(d,e){d=d.replace(/data-mozilla-paste-image="0"/,'data-mozilla-paste-image="0" style="display:none"');return d});return c},insertAttachment:function(f,d){f=parseInt(f);var b=this.wutil.getOption("woltlab.attachment"+(!d?"Thumbnail":"")+"Url");var e=this.wbbcode._getImageAttachments();if(b&&e[f]!==undefined){var c="";if(d){c=' style="width: '+e[f].width+"px; max-height: "+e[f].height+"px; max-width: "+e[f].width+'px;"'}this.wutil.insertDynamic('<img src="'+b.replace(/987654321/,f)+'" class="redactorEmbeddedAttachment'+(!d?" redactorDisableResize":"")+'" data-attachment-id="'+f+'"'+c+" />","[attach="+f+(d?",none,"+e[f].width:"")+"][/attach]")}else{this.wutil.insertDynamic("[attach="+f+"][/attach]")}},removeAttachment:function(b){if(!this.opts.visual){return}this.$editor.find("img.redactorEmbeddedAttachment").each(function(c,e){var d=$(e);if(d.data("attachmentID")==b){d.remove()}})},_getImageAttachments:function(){var c=this.wutil.getOption("woltlab.attachmentImages")||[];if(c.length){delete this.opts.attachmentImages;return c}var b={imageAttachments:{}};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","getImageAttachments_"+this.$textarea.wcfIdentify(),b);return b.imageAttachments},_keydownCallback:function(u){switch(u.event.which){case $.ui.keyCode.BACKSPACE:case $.ui.keyCode.DELETE:case $.ui.keyCode.DOWN:case $.ui.keyCode.ENTER:case $.ui.keyCode.UP:case 83:break;default:return;break}this.selection.get();var m=this.selection.getCurrent();var l=this.selection.getParent();l=(l)?$(l):l;var i=(l)?l.closest("blockquote.quoteBox",this.$editor.get()[0]):{length:0};switch(u.event.which){case $.ui.keyCode.BACKSPACE:if(this.wutil.isCaret()){var g=false;if(i.length){var j=true;for(var b=0;b<i[0].children.length;b++){var t=i[0].children[b];if(t.tagName==="DIV"){if(t.textContent.replace(/\u200b/,"").length){j=false;break}}}if(j){g=true}}else{var d=(this.selection.implicitRange===null)?this.range:this.selection.implicitRange;var n=d.startContainer;if(n.nodeType===Node.TEXT_NODE){if(d.startOffset===0||(d.startOffset===1&&n.textContent==="\u200b")){if(!n.previousSibling){n=n.parentElement}}}if(n.nodeType===Node.ELEMENT_NODE){var h=n.previousSibling;if(h&&h.nodeType===Node.ELEMENT_NODE&&h.tagName==="BLOCKQUOTE"){i=h;g=true}}}if(g){var q=window.getSelection();if(q.rangeCount){q.removeAllRanges()}var o=document.createRange();o.selectNode(i[0]||i);q.addRange(o);u.cancel=true}}break;case $.ui.keyCode.DELETE:if(this.wutil.isCaret()&&this.wutil.isEndOfElement(m)){var s=m.nextElementSibling;if(s&&s.tagName==="BLOCKQUOTE"){var q=window.getSelection();if(q.rangeCount){q.removeAllRanges()}var o=document.createRange();o.selectNode(s);q.addRange(o);u.cancel=true}}break;case $.ui.keyCode.DOWN:var e=$(m);if(e.next("blockquote").length){this.caret.setStart(e.next().children("div:first"));u.cancel=true}else{if(l){if(l.next("blockquote").length){this.caret.setStart(l.next().children("div:first"));u.cancel=true}else{if(i.length){var p=e.closest("div",i[0]);if(!p.next().length){if(i.next().length){this.caret.setStart(i.next())}else{this.wutil.setCaretAfter(i)}u.cancel=true}}}}}break;case $.ui.keyCode.ENTER:if(i.length){this.keydown.blockquote=false;this.keydown.enterWithinBlockquote=true}break;case $.ui.keyCode.UP:if(!l||!i.length){return}var p=$(m).closest("div",i[0]);var r=p.prev();if(r[0].tagName==="DIV"){return}else{if(r[0].tagName==="BLOCKQUOTE"){return}}var k=i.prev();if(k.length===0){this.wutil.setCaretBefore(i)}else{if(k[0].tagName==="BLOCKQUOTE"){this.caret.sendEnd(k.children("div:last"))}else{if($.trim(k.html())==""){k.html(this.opts.invisibleSpace)}this.caret.setEnd(k)}}u.cancel=true;break;case 83:if($.browser.mobile){return}var c=false;if(navigator.platform.match(/^Mac/)){if(u.event.ctrlKey&&u.event.altKey){c=true}}else{if(u.event.altKey){c=true}}if(c){var f={cancel:false};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","submitEditor_"+this.$textarea.wcfIdentify(),f);if(f.cancel){u.cancel=true}}break}},_keyupCallback:function(b){if(b.event.which!==$.ui.keyCode.BACKSPACE&&b.event.which!==$.ui.keyCode.DELETE){return}this.$editor.find("blockquote").each(function(c,e){var d=$(e);if(!d.children("header").length){d.remove()}})},observeQuotes:function(){this.$editor.find(".redactorQuoteEdit").off("click.wbbcode").on("click.wbbcode",$.proxy(this.wbbcode._observeQuotesClick,this))},_observeQuotesClick:function(e){var c=$(e.currentTarget).closest("header");var d=$('<span class="redactor-link-tooltip" />');$('<a href="#">'+WCF.Language.get("wcf.bbcode.quote.edit")+"</a>").click($.proxy(function(f){f.preventDefault();this.wbbcode._openQuoteEditOverlay($(e.currentTarget).closest("blockquote.quoteBox"),false);$(".redactor-link-tooltip").remove()},this)).appendTo(d);var b=c.offset();d.css({left:b.left+"px",top:(b.top+20)+"px"});$(".redactor-link-tooltip").remove();d.appendTo(document.body);this.selection.remove()},observeCodeListings:function(){this.$editor.find(".codeBox").each((function(b,e){var c=$(e);var d=c.find(".redactorEditCodeBox");if(!d.length){d=$('<div class="redactorEditCodeBox"><div>'+WCF.Language.get("wcf.bbcode.code.edit")+"</div></div>").insertAfter(c.find("> div > div > h3"))}d.off("click.wbbcode").on("click.wbbcode",(function(){this.wbbcode._handleInsertCode(c,false)}).bind(this))}).bind(this))},_openQuoteEditOverlay:function(b,d){this.modal.load("quote",WCF.Language.get("wcf.bbcode.quote."+(d?"insert":"edit")),400);var c=this.modal.createActionButton(this.lang.get("save"));if(d){this.selection.save();c.click($.proxy(function(){var g=$("#redactorQuoteAuthor").val();var f=WCF.String.escapeHTML($("#redactorQuoteLink").val());this.selection.restore();a=true;var e=this.selection.getHtml();if(this.utils.isEmpty(e)){e=""}var h=this.wbbcode.insertQuoteBBCode(g,f,e);if(h!==null){if(!e.length){if($.browser.mozilla){h.children("br[type=_moz]").replaceWith("<div>"+this.opts.invisibleSpace+"</div>")}this.caret.setStart(h.children("div")[0])}}this.modal.close()},this))}else{$("#redactorQuoteAuthor").val(b.data("author"));$("#redactorQuoteLink").val(WCF.String.unescapeHTML(b.attr("cite")));c.click($.proxy(function(){var e=$("#redactorQuoteAuthor").val();b.data("author",e);b.attr("data-author",e);b.prop("cite",WCF.String.escapeHTML($("#redactorQuoteLink").val()));this.wbbcode._updateQuoteHeader(b);this.modal.close()},this))}this.modal.show()},_updateQuoteHeader:function(c){var d=c.data("author");var b=c.attr("cite");if(b){b=WCF.String.escapeHTML(b)}c.find("> div > header > h3").empty().append(this.wbbcode._buildQuoteHeader(d,b))},insertQuoteBBCode:function(d,i,e,f){var h="[quote]";var b="[/quote]";if(d){if(i){h="[quote='"+d+"','"+i+"']"}else{h="[quote='"+d+"']"}}var m=null;if(this.wutil.inWysiwygMode()){var g=(f)?this.wbbcode.convertToHtml(f):e;var l=WCF.getUUID();var c=this.wbbcode.convertToHtml(h+l+b);c=c.replace(l,g.replace(/^<p>/,"").replace(/<\/p>$/,""));c=c.replace(/^<p>/,"").replace(/<\/p>$/,"");c=c.replace(/<blockquote/,'<blockquote id="'+l+'"');this.insert.html(c,false);m=this.$editor.find("#"+l);if(m.length){var k=m.find("> div");if(k.length==1){if(k[0].innerHTML===""){k[0].innerHTML=this.opts.invisibleSpace}}else{if($.browser.mozilla){var j=m.find("> div > br[type=_moz]");if(j.length){$("<div>"+this.opts.invisibleSpace+"</div>").insertBefore(j);j.remove()}}}m.removeAttr("id");this.wutil.setCaretAfter(m[0])}this.wbbcode.observeQuotes();this.wbbcode.fixBlockLevelElements();this.$toolbar.find("a.re-__wcf_quote").removeClass("redactor-button-disabled")}else{this.wutil.insertAtCaret(h+f+b)}this.wutil.saveSelection();return m},_buildQuoteHeader:function(c,d){var b="";if(!c&&d){c=d;d=""}if(c){if(d){b+='<a href="'+d+'">'}b+=WCF.Language.get("wcf.bbcode.quote.title.javascript",{quoteAuthor:WCF.String.unescapeHTML(c)});if(d){b+="</a>"}}else{b="<small>"+WCF.Language.get("wcf.bbcode.quote.title.clickToSet")+"</small>"}return b},_handleInsertQuote:function(){this.wbbcode._openQuoteEditOverlay(null,true)},_handleInsertCode:function(d,f){this.modal.load("code",WCF.Language.get("wcf.bbcode.code."+(f?"insert":"edit")),400);var b=this.modal.createActionButton(this.lang.get("save")).addClass("buttonPrimary");if(f){this.selection.get();var c=this.selection.getText();this.selection.save();this.modal.show();var j=$("#redactorCodeBox").focus();j.val(c);b.click($.proxy(function(){var q=$("#redactorCodeBox");var n=$("#redactorCodeFilename");var s=$("#redactorCodeHighlighter");var t=$("#redactorCodeLineNumber");var p=q.val().replace(/^\n+/,"").replace(/\n+$/,"");if($.trim(p).length===0){if(!q.next("small.innerError").length){$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(q)}return}var o=$.trim(n.val().replace(/['"]/g,""));var r="[code="+s.val()+","+t.val()+(o.length?",'"+o+"'":"")+"]";r+=p;r+="[/code]";this.wutil.adjustSelectionForBlockElement();this.wutil.saveSelection();var m=this.wbbcode.convertToHtml(r);this.buffer.set();this.insert.html(m,false);var q=this.$editor.find(".codeBox:not(.jsRedactorCodeBox)");this.wbbcode.observeCodeListings();this.wbbcode.fixBlockLevelElements();q.attr("contenteditable","false");this.wutil.setCaretAfter(q[0]);this.modal.close()},this))}else{var h=this.modal.createActionButton(WCF.Language.get("wcf.global.button.delete"));h.click((function(){this.buffer.set();d.remove();this.modal.close()}).bind(this));this.modal.show();var j=$("#redactorCodeBox").focus();var i=$("#redactorCodeFilename");var g=$("#redactorCodeHighlighter");var k=$("#redactorCodeLineNumber");g.val(d.data("highlighter"));i.val(d.data("filename")||"");var e=d.find("> div > ol");k.val(parseInt(e.prop("start")));var l="";e.children("li").each(function(m,n){l+=$(n).text()+"\n"});j.val(l.replace(/^\n+/,"").replace(/\n+$/,""));b.click($.proxy(function(){var n=j.val().replace(/^\n+/,"").replace(/\n+$/,"");if($.trim(n).length===0){if(!j.next("small.innerError").length){$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(j)}return}var r=g.val();d.data("highlighter",r);d.attr("data-highlighter",r);var o=__REDACTOR_CODE_HIGHLIGHTERS[r];var m=$.trim(i.val().replace(/['"]/g,""));if(m){o+=": "+WCF.String.escapeHTML(m);d.data("filename",m);d.attr("data-filename",m)}else{d.removeAttr("data-filename");d.removeData("filename")}d.data("highlighter",g.val());d.find("> div > div > h3").html(o);var p=d.find("> div > ol").empty();var s=parseInt(k.val());p.prop("start",(s>1?s:1));n=n.split("\n");var q="";for(var t=0;t<n.length;t++){q+="<li>"+WCF.String.escapeHTML(n[t])+"</li>"}p.append($(q));this.modal.close()},this))}},fixBlockLevelElements:function(){return;var b=(function(e,d){var c="P";if(e.parentElement.tagName==="DIV"&&e.parentElement!==this.$editor[0]){e=e.parentElement;c="DIV"}if(e[d]===null||e[d].tagName!==c){$("<"+c+">"+this.opts.invisibleSpace+"</"+c+">")[(d==="previousElementSibling"?"insertBefore":"insertAfter")](e)}else{if(e.previousElementSibling.tagName===c){if(!e[d].innerHTML.length||e[d].innerHTML.toLowerCase()==="<p></p>"){$(e[d]).html(this.opts.invisibleSpace)}}}}).bind(this);this.$editor.find("blockquote, .codeBox").each((function(c,d){b(d,"previousElementSibling");b(d,"nextElementSibling")}).bind(this))},fixFormatting:function(d){var b=function(f){f.style.removeProperty("text-align");for(var g=0;g<f.children.length;g++){b(f.children[g])}};for(var e=0;e<this.alignment.blocks.length;e++){var c=this.alignment.blocks[e];switch(c.tagName){case"BLOCKQUOTE":c.style.removeProperty("text-align");b(c.children[0]);break;case"DIV":if(/\bcodeBox\b/.test(c.className)){b(c)}break}}}}};
+if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wbbcode=function(){var a=false;return{init:function(){var e=this.$textarea.wcfIdentify();this.opts.initCallback=(function(){if($.browser.msie){this.$editor.addClass("msie")}var i=$.trim(this.wutil.getOption("woltlab.originalValue"));if(i.length){this.wutil.replaceText(i);this.wutil.selectionEndOfEditor()}delete this.opts.woltlab.originalValue;$(document).trigger("resize");this.wutil.saveSelection()}).bind(this);this.opts.pasteBeforeCallback=$.proxy(this.wbbcode._pasteBeforeCallback,this);this.opts.pasteCallback=$.proxy(this.wbbcode._pasteCallback,this);var d=this.clean.onSync;this.clean.onSync=(function(i){if(a===true){a=false}else{i=i.replace(/<p><br([^>]+)?><\/p>/g,"<p>@@@wcf_empty_line@@@</p>")}return d.call(this,i)}).bind(this);if(this.wutil.getOption("woltlab.autosaveOnce")){this.wutil.saveTextToStorage();delete this.opts.woltlab.autosaveOnce}var c=this.button.get("table");if(c.length){var h=c.data("dropdown");h.find(".redactor-dropdown-add_head").parent().remove();h.find(".redactor-dropdown-delete_head").parent().remove();$('<li class="dropdownDivider" />').insertBefore(h.find(".redactor-dropdown-delete_table").parent());c.click($.proxy(this.wbbcode._tableButtonClick,this))}WCF.System.Event.addListener("com.woltlab.wcf.redactor","insertBBCode_quote_"+e,$.proxy(function(i){i.cancel=true;this.wbbcode._handleInsertQuote()},this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","insertBBCode_code_"+e,$.proxy(function(i){i.cancel=true;this.wbbcode._handleInsertCode(null,true)},this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+e,$.proxy(this.wbbcode._keydownCallback,this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","keyup_"+e,$.proxy(this.wbbcode._keyupCallback,this));this.code.sync=function(){};var f=$(".redactor-toolbar-tooltip-html:not(.jsWbbcode)").addClass("jsWbbcode").text(WCF.Language.get("wcf.bbcode.button.toggleBBCode"));var g=function(i){i.find("br").each(function(j,k){if(k.children.length){$(k).empty()}})};this.code.toggle=(function(){if(this.opts.visual){this.code.startSync();this.code.showCode();this.$textarea.val(this.wbbcode.convertFromHtml(this.$textarea.val()));this.button.get("html").children("i").removeClass("fa-square-o").addClass("fa-square");f.text(WCF.Language.get("wcf.bbcode.button.toggleHTML"))}else{this.$textarea.val(this.wbbcode.convertToHtml(this.$textarea.val()));this.code.offset=this.$textarea.val().length;this.code.showVisual();this.wbbcode.fixBlockLevelElements();this.wutil.selectionEndOfEditor();this.wbbcode.observeQuotes();this.wbbcode.observeCodeListings();this.button.get("html").children("i").removeClass("fa-square").addClass("fa-square-o");f.text(WCF.Language.get("wcf.bbcode.button.toggleBBCode"));this.wutil.fixDOM();g(this.$editor);this.wutil.saveSelection()}}).bind(this);this.wutil.setOption("clickCallback",(function(i){this.wutil.saveSelection();if(i.target===this.$editor[0]){if(this.$editor[0].lastElementChild&&this.$editor[0].lastElementChild.tagName==="BLOCKQUOTE"){this.wutil.setCaretAfter($(this.$editor[0].lastElementChild))}}}).bind(this));var b=this.opts.verifiedTags.indexOf("ul");if(b>-1){this.opts.verifiedTags.splice(b,1)}WCF.System.Event.addListener("com.woltlab.wcf.redactor","observe_load_"+e,(function(i){this.wbbcode.observeCodeListings();this.wbbcode.observeQuotes()}).bind(this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","fixFormatting_"+e,$.proxy(this.wbbcode.fixFormatting,this))},_tableButtonClick:function(c){var d=$(c.currentTarget);if(!d.hasClass("dropact")){return}var b=this.selection.getBlock()||this.selection.getCurrent();var e=d.data("dropdown");e.children("li").show();var f=e.find("> li > .redactor-dropdown-insert_table").parent();if(b.tagName=="TD"){f.hide()}else{f.nextAll().hide()}},insertSmiley:function(b,c,d){if(d){this.wbbcode.registerSmiley(b,c)}if(this.opts.visual){this.insert.html(' <img src="'+c+'" class="smiley" alt="'+b+'" /> ',false)}else{this.wutil.insertAtCaret(" "+b+" ")}},registerSmiley:function(b,c){if(__REDACTOR_SMILIES[b]){return false}__REDACTOR_SMILIES[b]=c;return true},convertFromHtml:function(m){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertFromHtml",{html:m});m=m.replace(/(<[^>]+?) data-redactor-tag="[^"]+"/g,"$1");m=m.replace(/(<[^>]+?) rel="[^"]+"/g,"$1");m=m.replace(/&#(8203|x200b);/g,"");m=m.replace(/™/gi,"\u2122");m=m.replace(/©/gi,"\u00a9");m=m.replace(/…/gi,"\u2026");m=m.replace(/—/gi,"\u2014");m=m.replace(/‐/gi,"\u2010");var r={};m=m.replace(/<div class="codeBox[^"]+"(.*?)>\n*<div>[\s\S]+?<ol start="(\d+)">([\s\S]+?)<\/ol>\n*<\/div>\n*<\/div>/g,function(B,C,z,E){var D="";var y="";if(C.match(/data-highlighter="([a-zA-Z]+)"/)){D=RegExp.$1}if(C.match(/data-filename="([^"]+)"/)){y=$.trim(RegExp.$1)}var A=WCF.getUUID();r[A]={codeContent:E.replace(/<li>/g,"").replace(/<\/li>/g,"\n").replace(/\n$/,""),filename:y.replace(/['"]/g,""),highlighter:(D==="plain"?"":D),lineNumber:(z>1?z:0)};return"@@@"+A+"@@@"});m=m.replace(/\r?\n/g,"");m=m.replace(/<a[^>]*?><\/a>/g,"");m=m.replace(/<p><\/p><p>(?!<br>)/g,"<p>@@@wcf_empty_line@@@</p><p>");m=m.replace(/<br( \/)?><\/p>/g,"</p>");var h=m.split(/(<\/?(?:div|p)>)/);var i="";var w="";for(var b=0;b<h.length;b++){var x=h[b];if(x=="<p>"||x=="<div>"){continue}else{if(x=="</p>"||x=="</div>"){w=$.trim(w);if(w!="@@@wcf_empty_line@@@"){w+="\n"}i+=w;w=""}else{if(b==0||b+1==h.length){i+=x}else{w+=x}}}}if(w){i+=w;w=""}m=i;m=m.replace(/@@@wcf_empty_line@@@/g,"\n");m=m.replace(/\n\n$/,"\n");m=m.replace(/<br>$/,"");m=m.replace(/<br>/g,"\n");m=m.replace(/<br>/g,"");m=m.replace(/ /gi," ");m=m.replace(/<blockquote([^>]+)>\n?<header[^>]*?>[\s\S]*?<\/header>/gi,function(A,z,C){var D;var B="";var y="";if(z.match(/data-author="([^"]+)"/)){B=WCF.String.unescapeHTML(RegExp.$1)}if(z.match(/cite="([^"]+)"/)){y=WCF.String.unescapeHTML(RegExp.$1)}if(y){D="[quote='"+B+"','"+y+"']"}else{if(B){D="[quote='"+B+"']"}else{D="[quote]"}}return D});m=m.replace(/(?:\n*)<\/blockquote>\n?/gi,"[/quote]\n");m=m.replace(/<a [^>]*?href=(["'])mailto:(.+?)\1.*?>([\s\S]+?)<\/a>/gi,"[email=$2]$3[/email]");m=m.replace(/<a[^>]+><\/a>/,"");m=m.replace(/<a [^>]*?href=(["'])(.+?)\1.*?>([\s\S]+?)<\/a>/gi,function(A,y,z,B){if(z==B){return"[url]"+z+"[/url]"}return"[url='"+z+"']"+B+"[/url]"});m=m.replace(/<(?:b|strong)>/gi,"[b]");m=m.replace(/<\/(?:b|strong)>/gi,"[/b]");m=m.replace(/<(?:i|em)>/gi,"[i]");m=m.replace(/<\/(?:i|em)>/gi,"[/i]");m=m.replace(/<u>/gi,"[u]");m=m.replace(/<\/u>/gi,"[/u]");m=m.replace(/<sub>/gi,"[sub]");m=m.replace(/<\/sub>/gi,"[/sub]");m=m.replace(/<sup>/gi,"[sup]");m=m.replace(/<\/sup>/gi,"[/sup]");m=m.replace(/<(?:s(trike)?|del)>/gi,"[s]");m=m.replace(/<\/(?:s(trike)?|del)>/gi,"[/s]");var f=m.split(/(<\/?span[^>]*>)/);var w=[];var o=[];var p="";var d={11:8,13:10,16:12,19:14,24:18,29:22,32:24,48:36};for(var b=0;b<f.length;b++){var j=f[b];if(j=="</span>"){var e=o.pop();var i=e.start+$.trim(w.pop())+e.end;if(w.length){w[w.length-1]+=i}else{p+=i}}else{if(j.match(/^<span/)){if(j.match(/^<span(?:.*?)style="([^"]+)"(?:[^>]*?)>/)){var l=RegExp.$1;var u;var n;if(l.match(/color: ?rgb\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\);?/i)){var t=RegExp.$1;var c=RegExp.$2;var g=RegExp.$3;var q=("0123456789ABCDEF".charAt((t-t%16)/16)+""+"0123456789ABCDEF".charAt(t%16))+""+("0123456789ABCDEF".charAt((c-c%16)/16)+""+"0123456789ABCDEF".charAt(c%16))+""+("0123456789ABCDEF".charAt((g-g%16)/16)+""+"0123456789ABCDEF".charAt(g%16));u="[color=#"+q+"]";n="[/color]"}else{if(l.match(/color: ?([^;]+);?/i)){u="[color="+RegExp.$1+"]";n="[/color]"}else{if(l.match(/font-size: ?(\d+)(pt|px);?/i)){if(RegExp.$2=="pt"){u="[size="+RegExp.$1+"]";n="[/size]"}else{if(d[RegExp.$1]){u="[size="+d[RegExp.$1]+"]";n="[/size]"}else{u="";n=""}}}else{if(l.match(/font-family: ?([^;]+);?/)){u="[font='"+RegExp.$1.replace(/'/g,"")+"']";n="[/font]"}else{u='<span style="'+l+'">';n="</span>"}}}}w[w.length]="";o[w.length]={start:u,end:n}}else{if(j.match(/^<span class="inlineCode">/)){w[w.length]="";o[w.length]={start:"[tt]",end:"[/tt]"}}else{w[w.length]="";o[w.length]={start:"",end:""}}}}else{if(w.length){w[w.length-1]+=j}else{p+=j}}}}m=p;m=m.replace(/<(div|p) style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)\n/gi,function(z,y,B,A){return"[align="+B+"]"+$.trim(A)+"[/align]\n"});m=m.replace(/ ?<img [^>]*?alt="([^"]+?)" class="smiley".*?> ?/gi," $1 ");m=m.replace(/ ?<img [^>]*?class="smiley" alt="([^"]+?)".*?> ?/gi," $1 ");m=m.replace(/<img(.*?)class="[^"]*redactorEmbeddedAttachment[^"]*"(.*?)>/gi,function(B,E,G){var H=E+" "+G;var D;if(H.match(/data-attachment-id="(\d+)"/)){D=RegExp.$1}else{return B}var A="none";var z=null;if(H.match(/style="([^"]+)"/)){var C=RegExp.$1.split(";");for(var F=0;F<C.length;F++){var y=$.trim(C[F]);if(y.match(/^float: (left|right)$/)){A=RegExp.$1}else{if(y.match(/^width: (\d+)px$/)){z=RegExp.$1}}}if(z!==null){return"[attach="+D+","+A+","+z+"][/attach]"}else{if(A!=="none"){return"[attach="+D+","+A+"][/attach]"}}}return"[attach="+D+"][/attach]"});m=m.replace(/<img [^>]*?src=(["'])([^"']+?)\1.*?style="([^"]+)".*?>/gi,function(D,G,z,A){var C="none";var B=0;var E=A.split(";");for(var F=0;F<E.length;F++){var y=E[F];if(y.match(/float: (left|right|none)/)){C=RegExp.$1}else{if(y.match(/width: (\d+)px/)){B=parseInt(RegExp.$1)}}}if(B){return"[img='"+z+"',"+C+","+B+"][/img]"}else{if(C!=="none"){return"[img='"+z+"',"+C+"][/img]"}}return"[img]"+z+"[/img]"});m=m.replace(/<img [^>]*?src=(["'])([^"']+?)\1.*?>/gi,"[img]$2[/img]");m=m.replace(/<li>/gi,"[*]");m=m.replace(/<\/li>/gi,"\n");m=m.replace(/<ul>/gi,"[list]");m=m.replace(/<(ol|ul style="list-style-type: decimal")>/gi,"[list=1]");m=m.replace(/<ul style="list-style-type: (none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)">/gi,"[list=$1]");m=m.replace(/<\/(ul|ol)>/gi,"[/list]");m=m.replace(/\n?\[list\]/g,"\n[list]");m=m.replace(/\[\/list\]\n\[\*\]/g,"[/list][*]");m=m.replace(/\[\/list\]\n\[\/list\]/g,"[/list][/list]");m=m.replace(/<table[^>]*>/gi,"[table]\n");m=m.replace(/<\/table>/gi,"[/table]\n");m=m.replace(/<tbody>([\s\S]*?)<\/tbody>/,function(y,z){return $.trim(z)});m=m.replace(/<tr><\/tr>/gi,"");m=m.replace(/<tr>/gi,"[tr]\n");m=m.replace(/<\/tr>/gi,"[/tr]\n");m=m.replace(/<td style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)<\/td>/gi,"[td][align=$1]$2[/align][/td]");m=m.replace(/(\t)*<td>(\t)*/gi,"[td]");m=m.replace(/(\t)*<\/td>/gi,"[/td]\n");var v={};m.replace(/<span id="selection-marker-\d+" class="redactor-selection-marker"><\/span>/,function(y){var z=y.hashCode();v[z]=y.replace(/\$/g,"$$$$");return"@@"+z+"@@"});WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","convertFromHtml",{html:m});m=m.replace(/<[^(<|>)]+>/g,"");if($.getLength(v)){for(var k in v){var s=new RegExp("@@"+k+"@@","g");data=data.replace(s,v[k])}}if($.getLength(r)){$.each(r,function(A,C){var z=0;if(C.highlighter){z++}if(C.lineNumber){z++}if(C.filename){z++}var y="";switch(z){case 1:if(C.highlighter){y=C.highlighter}else{if(C.filename){y="'"+C.filename+"'"}else{y=C.lineNumber}}break;case 2:if(C.highlighter){y=C.highlighter}if(C.lineNumber){if(y.length){y+=","}y+=C.lineNumber}if(C.filename){if(y.length){y+=","}y+="'"+C.filename+"'"}break;case 3:y=C.highlighter+","+C.lineNumber+",'"+C.filename+"'";break}var B="[code"+(y.length?"="+y:"")+"]"+C.codeContent+"[/code]\n";m=m.replace(new RegExp("@@@"+A+"@@@\n?","g"),B)})}m=m.replace(/</g,"<");m=m.replace(/>/g,">");m=m.replace(/&/g,"&");m=m.replace(/%28/g,"(");m=m.replace(/%29/g,")");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertFromHtml",{html:m});m=$.trim(m);if(m.length){m+="\n"}return m},convertToHtml:function(I){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertToHtml",{data:I});I=this.wutil.removeZeroWidthSpace(I);I=I.replace(/&/g,"&");I=I.replace(/</g,"<");I=I.replace(/>/g,">");var u=[];var o=new RegExp("\\[("+__REDACTOR_SOURCE_BBCODES.join("|")+")([\\S\\s]+?)\\[\\/\\1\\]","gi");I=I.replace(o,function(J){var K=J.hashCode();u.push({key:K,value:J.replace(/\$/g,"$$$$")});return"@@"+K+"@@"});I=I.replace(/\[url\]([^"]+?)\[\/url]/gi,'<a href="$1">$1</a>'+this.opts.invisibleSpace);I=I.replace(/\[url\='([^'"]+)']([\s\S]+?)\[\/url]/gi,'<a href="$1">$2</a>'+this.opts.invisibleSpace);I=I.replace(/\[url\=([^'"\]]+)]([\s\S]+?)\[\/url]/gi,'<a href="$1">$2</a>'+this.opts.invisibleSpace);I=I.replace(/\[email\]([^"]+?)\[\/email]/gi,'<a href="mailto:$1">$1</a>'+this.opts.invisibleSpace);I=I.replace(/\[email\=([^"\]]+)](.+?)\[\/email]/gi,'<a href="mailto:$1">$2</a>'+this.opts.invisibleSpace);I=I.replace(/\[b\]([\s\S]*?)\[\/b]/gi,"<strong>$1</strong>");I=I.replace(/\[i\]([\s\S]*?)\[\/i]/gi,"<em>$1</em>");I=I.replace(/\[u\]([\s\S]*?)\[\/u]/gi,"<u>$1</u>");I=I.replace(/\[s\]([\s\S]*?)\[\/s]/gi,"<strike>$1</strike>");I=I.replace(/\[sub\]([\s\S]*?)\[\/sub]/gi,"<sub>$1</sub>");I=I.replace(/\[sup\]([\s\S]*?)\[\/sup]/gi,"<sup>$1</sup>");I=I.replace(/\[img\]([^"]+?)\[\/img\]/gi,'<img src="$1" />');I=I.replace(/\[img='?([^"]*?)'?,'?(left|right)'?\]\[\/img\]/gi,function(K,L,M){var J="float: "+M+";";if(M==="left"){J+="margin: 0 15px 7px 0"}else{J+="margin: 0 0 7px 15px"}return'<img src="'+L+'" style="'+J+'" />'});I=I.replace(/\[img='?([^"]*?)'?,'?(left|right|none)'?,'?(\d+)'?\]\[\/img\]/gi,function(K,M,N,L){var J="float: "+N+"; width: "+L+"px;";if(N==="left"){J+="margin: 0 15px 7px 0"}else{J+="margin: 0 0 7px 15px"}return'<img src="'+M+'" style="'+J+'" />'});I=I.replace(/\[img='?([^"]*?)'?\]\[\/img\]/gi,'<img src="$1" />');I=I.replace(/\[size=(\d+)\]([\s\S]*?)\[\/size\]/gi,(function(J,K,L){L=$.trim(L);if(!L.length){L=this.opts.invisibleSpace}return'<span style="font-size: '+K+'pt">'+L+"</span>"}).bind(this));I=I.replace(/\[color=([#a-z0-9]*?)\]([\s\S]*?)\[\/color\]/gi,(function(K,J,L){L=$.trim(L);if(!L.length){L=this.opts.invisibleSpace}return'<span style="color: '+J+'">'+L+"</span>"}).bind(this));I=I.replace(/\[font='?([a-z,\- ]*?)'?\]([\s\S]*?)\[\/font\]/gi,(function(K,J,L){L=$.trim(L);if(!L.length){L=this.opts.invisibleSpace}return'<span style="font-family: '+J+'">'+L+"</span>"}).bind(this));I=I.replace(/\[align=(left|right|center|justify)\]([\s\S]*?)\[\/align\]/gi,'<div style="text-align: $1">$2</div>');var s=I.indexOf("[list");if(s>0){var h=I.substr(0,s);h=h.replace(/\[\*\]/g,"");I=h+I.substr(s)}var x=I.indexOf("[/list]");if(x===-1){I=I.replace(/\[\*\]/g,"");I=I.replace(/\[list[^\]]*\]/g,"")}else{var h=I.substr(x+7);h=h.replace(/\[\*\]/g,"");I=I.substr(0,x+7)+h}I=I.replace(/\[\*\]([\s\S]*?)(?=\[\*\]|\[\/list\])/gi,function(J,K){return"<li>"+$.trim(K)+"</li>"});I=I.replace(/\n*(\[list\]<\/li>)/g,"$1");I=I.replace(/\[list\]/gi,"<ul>");I=I.replace(/\[list=1\]/gi,'<ul style="list-style-type: decimal">');I=I.replace(/\[list=a\]/gi,'<ul style="list-style-type: lower-latin">');I=I.replace(/\[list=(none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)\]/gi,'<ul style="list-style-type: $1">');I=I.replace(/\[\/list\]/gi,"</ul>");I=I.replace(/\[table\]([\S\s]*?)\[\/table\]/gi,function(J,K){return"[table]"+$.trim(K)+"[/table]"});I=I.replace(/\[table\]\n*/gi,'<table border="1" cellspacing="1" cellpadding="1" style="width: 500px;">');I=I.replace(/\[\/table\](\n*)?/gi,function(J,K){if(K){if(K.match(/\n/g).length>2){K=K.replace(/^\n/,"")}return"</table>"+K}return"</table>"});I=I.replace(/\[tr\]\n*/gi,"<tr>");I=I.replace(/\[\/tr\]\n*/gi,"</tr>");I=I.replace(/\[td\]\n*/gi,"<td>");I=I.replace(/\[\/td\]\n*/gi,"</td>");I=I.replace(/<td>([\S\s]*?)<\/td>/gi,function(J,L){var K=$.trim(L);if(!K.length){K="​"}return"<td>"+K+"</td>"});var d=this.wutil.getOption("woltlab.attachmentUrl");var H=this.wutil.getOption("woltlab.attachmentThumbnailUrl");if(d){var F=this.wbbcode._getImageAttachments();I=I.replace(/\[attach=(\d+)\]\[\/attach\]/g,function(J,K,L){K=parseInt(K);if(F[K]!==undefined){return'<img src="'+H.replace(/987654321/,K)+'" class="redactorEmbeddedAttachment redactorDisableResize" data-attachment-id="'+K+'" />'}return J});I=I.replace(/\[attach=(\d+),(left|right|none)\]\[\/attach\]/g,function(K,L,M){L=parseInt(L);if(F[L]!==undefined){var J="";if(M==="left"||M==="right"){J="float: "+M+";";if(M==="left"){J+="margin: 0 15px 7px 0"}else{J+="margin: 0 0 7px 15px"}}J=' style="'+J+'"';return'<img src="'+H.replace(/987654321/,L)+'" class="redactorEmbeddedAttachment redactorDisableResize" data-attachment-id="'+L+'"'+J+" />"}return K});I=I.replace(/\[attach=(\d+),(left|right|none),(\d+)\]\[\/attach\]/g,function(K,M,N,L){M=parseInt(M);if(F[M]!==undefined){var J="width: "+L+"px; max-height: "+F[M].height+"px; max-width: "+F[M].width+"px;";if(N==="left"||N==="right"){J+="float: "+N+";";if(N==="left"){J+="margin: 0 15px 7px 0"}else{J+="margin: 0 0 7px 15px"}}J=' style="'+J+'"';return'<img src="'+d.replace(/987654321/,M)+'" class="redactorEmbeddedAttachment" data-attachment-id="'+M+'"'+J+" />"}return K})}for(var w in __REDACTOR_SMILIES){var k=w.replace(/</g,"<").replace(/>/g,">");var j=new RegExp("(\\s|>|^)"+WCF.String.escapeRegExp(k)+"(?=\\s|<|$)","gi");I=I.replace(j,'$1<img src="'+__REDACTOR_SMILIES[w]+'" class="smiley" alt="'+k+'" />')}I=I.replace(/(javascript):/gi,"$1<span></span>:");I=I.replace(/(\r|\r\n)/g,"\n");var B=[];var E=[];var g=I.split(/(\[(?:\/quote|quote|quote='[^']*?'(?:,'[^']*?')?|quote="[^"]*?"(?:,"[^"]*?")?)\])/i);var e=WCF.getUUID();while(true){var p=false;for(var b=0;b<g.length;b++){var D=g[b];if(D.toLowerCase()==="[/quote]"){p=true;var f="";var n=g.slice(0,b);var c=false;while(n.length){var C=n.pop();f=C+f;if(C.match(/^\[quote/i)){D=f+D;var m=WCF.getUUID();B.push({hashCode:m,content:D.replace(/\$/g,"$$$$")});E.push(m);D="@@"+m+"@@";c=true;break}}if(!c){n=g.slice(0,b);D=e}g=n.concat(D,g.slice(b+1));break}}if(!p){break}}I=g.join("");I=I.replace(new RegExp(e,"g"),"[/quote]");I=I.replace(/\n*$/,"");var y=[];I=I.replace(/(<li>[\s\S]*?<\/li>)/g,function(J){J=$.trim(J).replace(/\n/,"<br>");var K=WCF.getUUID();y.push({key:K,content:J});return K});var h=I.split("\n");I="";for(var b=0,l=h.length;b<l;b++){var t=$.trim(h[b]);if(t.match(/^<([a-z]+)/)||t.match(/<\/([a-z]+)>$/)){if(this.reIsBlock.test(RegExp.$1.toUpperCase())){if(t.match(/^<([a-z]+).*<\/\1>/)){I+=t}else{I+=t+"<br />"}}else{I+="<p>"+t+"</p>"}}else{if(!t){t="<br>"}else{if(t.match(/^@@([0-9\-]+)@@$/)){if(WCF.inArray(RegExp.$1,E)){I+=t;continue}}}I+="<p>"+t+"</p>"}}if(y.length){for(var b=y.length-1;b>=0;b--){I=I.replace(y[b].key,y[b].content)}}if(B.length){var G=function(J){return J.replace(/^['"]/,"").replace(/['"]$/,"")};var r=this;var q=function(J){return J.replace(/\[quote(=['"].+['"])?\]([\S\s]*)\[\/quote\]/gi,function(M,L,O){var S="";var N="";if(L){L=L.substr(1);L=L.split(",");switch(L.length){case 1:S=L[0];break;case 2:S=L[0];N=L[1];break}S=WCF.String.escapeHTML(G($.trim(S)));N=WCF.String.escapeHTML(G($.trim(N)))}var T='<blockquote class="quoteBox container containerPadding quoteBoxSimple" cite="'+N+'" data-author="'+S+'"><header contenteditable="false"><h3>'+r.wbbcode._buildQuoteHeader(S,N)+'</h3><a class="redactorQuoteEdit"></a></header>';O=$.trim(O);var K="";if(O.length){var R=O.split("\n");for(var Q=0;Q<R.length;Q++){var P=R[Q];if(P.length===0){P=r.opts.invisibleSpace}else{if(P.match(/^@@([0-9\-]+)@@$/)){if(WCF.inArray(RegExp.$1,E)){K+=P;continue}}}K+="<div>"+P+"</div>"}}else{K="<div>"+r.opts.invisibleSpace+"</div>"}T+=K;T+="</blockquote>";return T})};for(var b=B.length-1;b>=0;b--){var v=B[b];var z=new RegExp("@@"+v.hashCode+"@@","g");I=I.replace(z,q(v.content))}}if(u.length){for(var b=u.length-1;b>=0;b--){var A=u[b];var z=new RegExp("@@"+A.key+"@@","g");var i=A.value;i=i.replace(/^\[code([^\]]*)\]([\S\s]*)\[\/code\]$/,function(M,T,O){var N="plain";var R=0;var Q="";if(T){T=T.substring(1);T=T.split(",");var P=function(V){return V.match(/^\d+$/)};var L=function(V){return(V.indexOf(".")!==-1)};var K=function(V){return(__REDACTOR_CODE_HIGHLIGHTERS[T[0]]!==undefined)};var J=function(V){return V.replace(/^(["'])(.*)\1$/,"$2")};switch(T.length){case 1:if(P(T[0])){R=(parseInt(T[0])>1)?T[0]:0}else{if(L(T[0])){Q=J(T[0])}else{if(K(T[0])){N=T[0]}}}break;case 2:if(P(T[0])){R=(parseInt(T[0])>1)?T[0]:0;if(L(T[1])){Q=J(T[1])}else{if(K(T[1])){N=T[1]}}}else{if(K(T[0])){N=T[0]}if(L(T[1])){Q=J(T[1])}}break;case 3:if(K(T[0])){N=T[0]}if(P(T[1])){R=T[1]}if(L(T[2])){Q=J(T[2])}break}}O=O.replace(/^\n+/,"").replace(/\n+$/,"").split(/\n/);var U="";for(var S=0;S<O.length;S++){U+="<li>"+O[S]+"</li>"}return'<div class="codeBox container" contenteditable="false" data-highlighter="'+N+'"'+(Q?' data-filename="'+WCF.String.escapeHTML(Q)+'"':"")+"><div><div><h3>"+__REDACTOR_CODE_HIGHLIGHTERS[N]+(Q?": "+WCF.String.escapeHTML(Q):"")+'</h3></div><ol start="'+(R>1?R:1)+'">'+U+"</ol></div></div>"});I=I.replace(z,i)}}I=I.replace(/<p><(blockquote|div)/g,"<$1");I=I.replace(/<\/(blockquote|div)><\/p>/g,"</$1>");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertToHtml",{data:I});return I},_pasteBeforeCallback:function(b){var c={1:24,2:22,3:18,4:14,5:12,6:10};b=b.replace(/<h([1-6])([^>]*)>/g,function(g,j,i){if(i&&i.match(/style="([^"]+?)"/)){if(/font-size: ?(\d+|\d+\.\d+)(px|pt|em|rem|%)/.test(RegExp.$1)){var d=$('<div style="width: '+RegExp.$1+RegExp.$2+'; position: absolute;" />').appendTo(document.body);var f=parseInt(d[0].clientWidth);d.remove();var e=-1;var h=false;$.each(c,function(m,l){if(e===-1){e=m}else{if(Math.abs(f-l)<Math.abs(f-c[e])){e=m}}if(f==l){h=true}});if(!h){e=(e<6)?parseInt(e)+1:e}j=e}}return"[size="+c[j]+"]"});b=b.replace(/<\/h[1-6]>/g,"[/size]");b=b.replace(/<(article|header)[^>]+>/g,"<div>");b=b.replace(/<\/(article|header)>/g,"</div>");b=b.replace(/<(div|p)([^>]+)?><(div|p)([^>]+)?>/g,"<p>");b=b.replace(/<\/(div|p)><\/(div|p)>/g,"</p>");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforePaste",{html:b});return b},_pasteCallback:function(c){var b=WCF.getUUID();c=c.replace(/<p>([\s\S]*?)<\/p>/gi,function(d,e){if(e.match(/^<br( \/)?>$/)){return d}return d+"@@@"+b+"@@@"});c=c.replace(new RegExp("@@@"+b+"@@@(<p><br(?: /)?></p>)?","g"),function(d,e){if(e){return e}return"<p><br></p>"});c=c.replace(/\[size=(\d+)\]/g,'<p><span style="font-size: $1pt">');c=c.replace(/\[\/size\]/g,"</span></p>");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterPaste",{html:c});return c;c=c.replace(/<img([^>]+)>/g,function(d,e){d=d.replace(/data-mozilla-paste-image="0"/,'data-mozilla-paste-image="0" style="display:none"');return d});return c},insertAttachment:function(f,d){f=parseInt(f);var b=this.wutil.getOption("woltlab.attachment"+(!d?"Thumbnail":"")+"Url");var e=this.wbbcode._getImageAttachments();if(b&&e[f]!==undefined){var c="";if(d){c=' style="width: '+e[f].width+"px; max-height: "+e[f].height+"px; max-width: "+e[f].width+'px;"'}this.wutil.insertDynamic('<img src="'+b.replace(/987654321/,f)+'" class="redactorEmbeddedAttachment'+(!d?" redactorDisableResize":"")+'" data-attachment-id="'+f+'"'+c+" />","[attach="+f+(d?",none,"+e[f].width:"")+"][/attach]")}else{this.wutil.insertDynamic("[attach="+f+"][/attach]")}},removeAttachment:function(b){if(!this.opts.visual){return}this.$editor.find("img.redactorEmbeddedAttachment").each(function(c,e){var d=$(e);if(d.data("attachmentID")==b){d.remove()}})},_getImageAttachments:function(){var c=this.wutil.getOption("woltlab.attachmentImages")||[];if(c.length){delete this.opts.attachmentImages;return c}var b={imageAttachments:{}};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","getImageAttachments_"+this.$textarea.wcfIdentify(),b);return b.imageAttachments},_keydownCallback:function(u){switch(u.event.which){case $.ui.keyCode.BACKSPACE:case $.ui.keyCode.DELETE:case $.ui.keyCode.DOWN:case $.ui.keyCode.ENTER:case $.ui.keyCode.UP:case 83:break;default:return;break}this.selection.get();var m=this.selection.getCurrent();var l=this.selection.getParent();l=(l)?$(l):l;var i=(l)?l.closest("blockquote.quoteBox",this.$editor.get()[0]):{length:0};switch(u.event.which){case $.ui.keyCode.BACKSPACE:if(this.wutil.isCaret()){var g=false;if(i.length){var j=true;for(var b=0;b<i[0].children.length;b++){var t=i[0].children[b];if(t.tagName==="DIV"){if(t.textContent.replace(/\u200b/,"").length){j=false;break}}}if(j){g=true}}else{var d=(this.selection.implicitRange===null)?this.range:this.selection.implicitRange;var n=d.startContainer;if(n.nodeType===Node.TEXT_NODE){if(d.startOffset===0||(d.startOffset===1&&n.textContent==="\u200b")){if(!n.previousSibling){n=n.parentElement}}}if(n.nodeType===Node.ELEMENT_NODE){var h=n.previousSibling;if(h&&h.nodeType===Node.ELEMENT_NODE&&h.tagName==="BLOCKQUOTE"){i=h;g=true}}}if(g){var q=window.getSelection();if(q.rangeCount){q.removeAllRanges()}var o=document.createRange();o.selectNode(i[0]||i);q.addRange(o);u.cancel=true}}break;case $.ui.keyCode.DELETE:if(this.wutil.isCaret()&&this.wutil.isEndOfElement(m)){var s=m.nextElementSibling;if(s&&s.tagName==="BLOCKQUOTE"){var q=window.getSelection();if(q.rangeCount){q.removeAllRanges()}var o=document.createRange();o.selectNode(s);q.addRange(o);u.cancel=true}}break;case $.ui.keyCode.DOWN:var e=$(m);if(e.next("blockquote").length){this.caret.setStart(e.next().children("div:first"));u.cancel=true}else{if(l){if(l.next("blockquote").length){this.caret.setStart(l.next().children("div:first"));u.cancel=true}else{if(i.length){var p=e.closest("div",i[0]);if(!p.next().length){if(i.next().length){this.caret.setStart(i.next())}else{this.wutil.setCaretAfter(i)}u.cancel=true}}}}}break;case $.ui.keyCode.ENTER:if(i.length){this.keydown.blockquote=false;this.keydown.enterWithinBlockquote=true}break;case $.ui.keyCode.UP:if(!l||!i.length){return}var p=$(m).closest("div",i[0]);var r=p.prev();if(r[0].tagName==="DIV"){return}else{if(r[0].tagName==="BLOCKQUOTE"){return}}var k=i.prev();if(k.length===0){this.wutil.setCaretBefore(i)}else{if(k[0].tagName==="BLOCKQUOTE"){this.caret.sendEnd(k.children("div:last"))}else{if($.trim(k.html())==""){k.html(this.opts.invisibleSpace)}this.caret.setEnd(k)}}u.cancel=true;break;case 83:if($.browser.mobile){return}var c=false;if(navigator.platform.match(/^Mac/)){if(u.event.ctrlKey&&u.event.altKey){c=true}}else{if(u.event.altKey){c=true}}if(c){var f={cancel:false};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","submitEditor_"+this.$textarea.wcfIdentify(),f);if(f.cancel){u.cancel=true}}break}},_keyupCallback:function(b){if(b.event.which!==$.ui.keyCode.BACKSPACE&&b.event.which!==$.ui.keyCode.DELETE){return}this.$editor.find("blockquote").each(function(c,e){var d=$(e);if(!d.children("header").length){d.remove()}})},observeQuotes:function(){this.$editor.find(".redactorQuoteEdit").off("click.wbbcode").on("click.wbbcode",$.proxy(this.wbbcode._observeQuotesClick,this))},_observeQuotesClick:function(e){var c=$(e.currentTarget).closest("header");var d=$('<span class="redactor-link-tooltip" />');$('<a href="#">'+WCF.Language.get("wcf.bbcode.quote.edit")+"</a>").click($.proxy(function(f){f.preventDefault();this.wbbcode._openQuoteEditOverlay($(e.currentTarget).closest("blockquote.quoteBox"),false);$(".redactor-link-tooltip").remove()},this)).appendTo(d);var b=c.offset();d.css({left:b.left+"px",top:(b.top+20)+"px"});$(".redactor-link-tooltip").remove();d.appendTo(document.body);this.selection.remove()},observeCodeListings:function(){this.$editor.find(".codeBox").each((function(b,e){var c=$(e);var d=c.find(".redactorEditCodeBox");if(!d.length){d=$('<div class="redactorEditCodeBox"><div>'+WCF.Language.get("wcf.bbcode.code.edit")+"</div></div>").insertAfter(c.find("> div > div > h3"))}d.off("click.wbbcode").on("click.wbbcode",(function(){this.wbbcode._handleInsertCode(c,false)}).bind(this))}).bind(this))},_openQuoteEditOverlay:function(b,d){this.modal.load("quote",WCF.Language.get("wcf.bbcode.quote."+(d?"insert":"edit")),400);var c=this.modal.createActionButton(this.lang.get("save"));if(d){this.selection.save();c.click($.proxy(function(){var g=$("#redactorQuoteAuthor").val();var f=WCF.String.escapeHTML($("#redactorQuoteLink").val());this.selection.restore();a=true;var e=this.selection.getHtml();if(this.utils.isEmpty(e)){e=""}var h=this.wbbcode.insertQuoteBBCode(g,f,e);if(h!==null){if(!e.length){if($.browser.mozilla){h.children("br[type=_moz]").replaceWith("<div>"+this.opts.invisibleSpace+"</div>")}this.caret.setStart(h.children("div")[0])}}this.modal.close()},this))}else{$("#redactorQuoteAuthor").val(b.data("author"));$("#redactorQuoteLink").val(WCF.String.unescapeHTML(b.attr("cite")));c.click($.proxy(function(){var e=$("#redactorQuoteAuthor").val();b.data("author",e);b.attr("data-author",e);b.prop("cite",WCF.String.escapeHTML($("#redactorQuoteLink").val()));this.wbbcode._updateQuoteHeader(b);this.modal.close()},this))}this.modal.show()},_updateQuoteHeader:function(c){var d=c.data("author");var b=c.attr("cite");if(b){b=WCF.String.escapeHTML(b)}c.find("> div > header > h3").empty().append(this.wbbcode._buildQuoteHeader(d,b))},insertQuoteBBCode:function(d,i,e,f){var h="[quote]";var b="[/quote]";if(d){if(i){h="[quote='"+d+"','"+i+"']"}else{h="[quote='"+d+"']"}}var m=null;if(this.wutil.inWysiwygMode()){var g=(f)?this.wbbcode.convertToHtml(f):e;var l=WCF.getUUID();var c=this.wbbcode.convertToHtml(h+l+b);c=c.replace(l,g.replace(/^<p>/,"").replace(/<\/p>$/,""));c=c.replace(/^<p>/,"").replace(/<\/p>$/,"");c=c.replace(/<blockquote/,'<blockquote id="'+l+'"');this.insert.html(c,false);m=this.$editor.find("#"+l);if(m.length){var k=m.find("> div");if(k.length==1){if(k[0].innerHTML===""){k[0].innerHTML=this.opts.invisibleSpace}}else{if($.browser.mozilla){var j=m.find("> div > br[type=_moz]");if(j.length){$("<div>"+this.opts.invisibleSpace+"</div>").insertBefore(j);j.remove()}}}m.removeAttr("id");this.wutil.setCaretAfter(m[0])}this.wbbcode.observeQuotes();this.wbbcode.fixBlockLevelElements();this.$toolbar.find("a.re-__wcf_quote").removeClass("redactor-button-disabled")}else{this.wutil.insertAtCaret(h+f+b)}this.wutil.saveSelection();return m},_buildQuoteHeader:function(c,d){var b="";if(!c&&d){c=d;d=""}if(c){if(d){b+='<a href="'+d+'">'}b+=WCF.Language.get("wcf.bbcode.quote.title.javascript",{quoteAuthor:WCF.String.unescapeHTML(c)});if(d){b+="</a>"}}else{b="<small>"+WCF.Language.get("wcf.bbcode.quote.title.clickToSet")+"</small>"}return b},_handleInsertQuote:function(){this.wbbcode._openQuoteEditOverlay(null,true)},_handleInsertCode:function(d,f){this.modal.load("code",WCF.Language.get("wcf.bbcode.code."+(f?"insert":"edit")),400);var b=this.modal.createActionButton(this.lang.get("save")).addClass("buttonPrimary");if(f){this.selection.get();var c=this.selection.getText();this.selection.save();this.modal.show();var j=$("#redactorCodeBox").focus();j.val(c);b.click($.proxy(function(){var q=$("#redactorCodeBox");var n=$("#redactorCodeFilename");var s=$("#redactorCodeHighlighter");var t=$("#redactorCodeLineNumber");var p=q.val().replace(/^\n+/,"").replace(/\n+$/,"");if($.trim(p).length===0){if(!q.next("small.innerError").length){$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(q)}return}var o=$.trim(n.val().replace(/['"]/g,""));var r="[code="+s.val()+","+t.val()+(o.length?",'"+o+"'":"")+"]";r+=p;r+="[/code]";this.wutil.adjustSelectionForBlockElement();this.wutil.saveSelection();var m=this.wbbcode.convertToHtml(r);this.buffer.set();this.insert.html(m,false);var q=this.$editor.find(".codeBox:not(.jsRedactorCodeBox)");this.wbbcode.observeCodeListings();this.wbbcode.fixBlockLevelElements();q.attr("contenteditable","false");this.wutil.setCaretAfter(q[0]);this.modal.close()},this))}else{var h=this.modal.createActionButton(WCF.Language.get("wcf.global.button.delete"));h.click((function(){this.buffer.set();d.remove();this.modal.close()}).bind(this));this.modal.show();var j=$("#redactorCodeBox").focus();var i=$("#redactorCodeFilename");var g=$("#redactorCodeHighlighter");var k=$("#redactorCodeLineNumber");g.val(d.data("highlighter"));i.val(d.data("filename")||"");var e=d.find("> div > ol");k.val(parseInt(e.prop("start")));var l="";e.children("li").each(function(m,n){l+=$(n).text()+"\n"});j.val(l.replace(/^\n+/,"").replace(/\n+$/,""));b.click($.proxy(function(){var n=j.val().replace(/^\n+/,"").replace(/\n+$/,"");if($.trim(n).length===0){if(!j.next("small.innerError").length){$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(j)}return}var r=g.val();d.data("highlighter",r);d.attr("data-highlighter",r);var o=__REDACTOR_CODE_HIGHLIGHTERS[r];var m=$.trim(i.val().replace(/['"]/g,""));if(m){o+=": "+WCF.String.escapeHTML(m);d.data("filename",m);d.attr("data-filename",m)}else{d.removeAttr("data-filename");d.removeData("filename")}d.data("highlighter",g.val());d.find("> div > div > h3").html(o);var p=d.find("> div > ol").empty();var s=parseInt(k.val());p.prop("start",(s>1?s:1));n=n.split("\n");var q="";for(var t=0;t<n.length;t++){q+="<li>"+WCF.String.escapeHTML(n[t])+"</li>"}p.append($(q));this.modal.close()},this))}},fixBlockLevelElements:function(){return;var b=(function(e,d){var c="P";if(e.parentElement.tagName==="DIV"&&e.parentElement!==this.$editor[0]){e=e.parentElement;c="DIV"}if(e[d]===null||e[d].tagName!==c){$("<"+c+">"+this.opts.invisibleSpace+"</"+c+">")[(d==="previousElementSibling"?"insertBefore":"insertAfter")](e)}else{if(e.previousElementSibling.tagName===c){if(!e[d].innerHTML.length||e[d].innerHTML.toLowerCase()==="<p></p>"){$(e[d]).html(this.opts.invisibleSpace)}}}}).bind(this);this.$editor.find("blockquote, .codeBox").each((function(c,d){b(d,"previousElementSibling");b(d,"nextElementSibling")}).bind(this))},fixFormatting:function(d){var b=function(f){f.style.removeProperty("text-align");for(var g=0;g<f.children.length;g++){b(f.children[g])}};for(var e=0;e<this.alignment.blocks.length;e++){var c=this.alignment.blocks[e];switch(c.tagName){case"BLOCKQUOTE":c.style.removeProperty("text-align");b(c.children[0]);break;case"DIV":if(/\bcodeBox\b/.test(c.className)){b(c)}break}}}}};
// wbutton.js
if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wbutton=function(){return{_bbcodes:{},init:function(){this._bbcodes={};for(var h=0,e=__REDACTOR_BUTTONS.length;h<e;h++){this.wbutton._addBBCodeButton(__REDACTOR_BUTTONS[h])}var a={html:"fa-square-o",bold:"fa-bold",italic:"fa-italic",underline:"fa-underline",deleted:"fa-strikethrough",subscript:"fa-subscript",superscript:"fa-superscript",orderedlist:"fa-list-ol",unorderedlist:"fa-list-ul",outdent:"fa-outdent",indent:"fa-indent",link:"fa-link",alignment:"fa-align-left",table:"fa-table"};var d={fontcolor:WCF.Language.get("wcf.bbcode.button.fontColor"),fontfamily:WCF.Language.get("wcf.bbcode.button.fontFamily"),fontsize:WCF.Language.get("wcf.bbcode.button.fontSize"),image:WCF.Language.get("wcf.bbcode.button.image"),subscript:WCF.Language.get("wcf.bbcode.button.subscript"),superscript:WCF.Language.get("wcf.bbcode.button.superscript")};var b=this.wutil.getOption("buttons");var g="";for(var h=0,e=b.length;h<e;h++){var c=b[h];if(c=="separator"){this.button.get(g).parent().addClass("separator");continue}var f=this.button.get(c);if(f.length){if(a[c]){this.button.setAwesome(c,a[c])}if(c==="table"&&g){f.parent().insertAfter(this.button.get(g).parent())}}else{this.wbutton._addCoreButton(c,(d[c]?d[c]:null),(a[c]?a[c]:null),g)}g=c}this.button.addCallback(this.button.get("image"),$.proxy(this.wbutton.insertImage,this))},_addCoreButton:function(b,c,a,d){var f={title:(c===null?b:c)};if(b==="subscript"||b==="superscript"){f.command=b}var e=this.button.build(b,f);$("<li />").append(e).insertAfter(this.button.get(d).parent());if(a!==null){this.button.setAwesome(b,a)}},_addBBCodeButton:function(b){var c="__wcf_"+b.name;var a=this.button.add(c,b.label);this.button.addCallback(a,this.wbutton._insertBBCode);this._bbcodes[c]={name:b.name,voidElement:(b.voidElement===true)};if(b.icon.match(/^fa\-[a-z\-]+$/)){this.button.setAwesome(c,b.icon)}else{a.css("background-image","url("+__REDACTOR_ICON_PATH+b.icon+")")}},_insertBBCode:function(a){var d=this._bbcodes[a].name;var b={buttonName:a,cancel:false,redactor:this};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","insertBBCode_"+d+"_"+this.$textarea.wcfIdentify(),b);if(b.cancel===false){var c=this.selection.getHtml();if(false&&d==="tt"){var e=(this.selection.getParent())?$(this.selection.getParent()):null;if(e&&e.closest("inline.inlineCode",this.$editor.get()[0]).length){this.inline.toggleClass("inlineCode")}else{this.inline.toggleClass("inlineCode")}}else{this.buffer.set();if(this.utils.browser("mozilla")&&!c.length){var f=getSelection().getRangeAt(0).startContainer;if(f.nodeType===Node.ELEMENT_NODE&&f.tagName==="P"&&f.innerHTML==="<br>"){f.removeChild(f.children[0])}}if(this._bbcodes[a].voidElement){this.insert.html(c+this.selection.getMarkerAsHtml()+"["+d+"]",false)}else{this.insert.html("["+d+"]"+c+this.selection.getMarkerAsHtml()+"[/"+d+"]",false)}this.selection.restore()}}},insertImage:function(){this.image.show()},_insertImage:function(){var d=$("#redactor-image-link-source");var b=d.val().trim();if(b.length){this.buffer.set();var c=$("#redactor-image-align").val();var a="";if(c==="left"||c==="right"){a=' style="float: '+c+'"'}this.insert.html('<img src="'+b+'"'+a+">",false);this.modal.close();this.observe.images()}else{if(!d.next("small.innerError")){$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(d)}}}}};
// wfontcolor.js