Updating minified JavaScript files
authorwoltlab.com <woltlab@woltlab.com>
Fri, 14 Aug 2015 15:31:48 +0000 (17:31 +0200)
committerwoltlab.com <woltlab@woltlab.com>
Fri, 14 Aug 2015 15:31:48 +0000 (17:31 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wcombined.min.js
wcfsetup/install/files/js/WCF.Combined.min.js

index 6e03390d8e2347e2acbe3b254a876d2014e01b1f..67b15882d4646fb3fb7df0fed636821ac65ab828 100644 (file)
@@ -1,7 +1,7 @@
 // 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(){window.addEventListener("unload",(function(j){this.code.startSync();this.$textarea.val(this.wbbcode.convertFromHtml(this.$textarea.val()))}).bind(this));if($.browser.msie){this.$editor.addClass("msie")}this.$textarea[0].setAttribute("data-is-dirty",true);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){i=i.replace(/\u200C/g,"__wcf_zwnj__");i=i.replace(/\u200D/g,"__wcf_zwj__");if(a===true){a=false}else{i=i.replace(/<p><br([^>]+)?><\/p>/g,"<p>@@@wcf_empty_line@@@</p>")}i=d.call(this,i);i=i.replace(/__wcf_zwnj__/g,"\u200C");return i.replace(/__wcf_zwj__/g,"\u200D")}).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(j,i,e){if(e){this.wbbcode.registerSmiley(j,i)}if(this.opts.visual){var f=null;if(window.getSelection().rangeCount&&window.getSelection().getRangeAt(0).collapsed){f=window.getSelection().getRangeAt(0).startContainer;if(f.nodeType===Node.TEXT_NODE){f=f.parentElement}if(!this.utils.isRedactorParent(f)){f=null}}this.insert.html('<img src="'+i+'" class="smiley" alt="'+j+'" id="redactorSmiley">',false);var b=document.getElementById("redactorSmiley");b.removeAttribute("id");if(f!==null){var d=window.getSelection().getRangeAt(0).startContainer;if(d.nodeType===Node.TEXT_NODE){d=d.parentElement}if(f!==d){f.appendChild(b)}}var h=function(k){if(k===null){return false}if((k.nodeType===Node.ELEMENT_NODE&&k.nodeName==="SPAN")||k.nodeType===Node.TEXT_NODE){if(k.textContent==="\u00A0"){return true}}return false};var g=b.parentElement;if(!h(b.previousSibling)){var c=document.createTextNode("\u00A0");g.insertBefore(c,b)}if(!h(b.nextSibling)){var c=document.createTextNode("\u00A0");if(g.lastChild===b){g.appendChild(c)}else{g.insertBefore(c,b.nextSibling)}}}else{this.wutil.insertAtCaret(" "+j+" ")}},registerSmiley:function(b,c){if(__REDACTOR_SMILIES[b]){return false}__REDACTOR_SMILIES[b]=c;return true},convertFromHtml:function(n){var w=[];WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertFromHtml",{html:n});n=n.replace(/(<[^>]+?) data-redactor-tag="[^"]+"/g,"$1");n=n.replace(/(<[^>]+?) rel="[^"]+"/g,"$1");n=n.replace(/&#(8203|x200b);/g,"");n=n.replace(/&trade;/gi,"\u2122");n=n.replace(/&copy;/gi,"\u00a9");n=n.replace(/&hellip;/gi,"\u2026");n=n.replace(/&mdash;/gi,"\u2014");n=n.replace(/&dash;/gi,"\u2010");var s={};n=n.replace(/<div([^>]+?)class="codeBox[^"]+"([^>]*?)>\n*<div>[\s\S]+?<ol start="(\d+)">([\s\S]+?)<\/ol>\n*<\/div>\n*<\/div>/g,function(F,D,C,E,B){var J=D+" "+C;var G="";var H="";if(J.match(/data-highlighter="([a-zA-Z]+)"/)){G=RegExp.$1}if(J.match(/data-filename="([^"]+)"/)){H=$.trim(RegExp.$1)}var I=WCF.getUUID();s[I]={codeContent:B.replace(/<li>/g,"").replace(/<\/li>/g,"\n").replace(/\n$/,""),filename:H.replace(/['"]/g,""),highlighter:(G==="plain"?"":G),lineNumber:(E>1?E:0)};return"@@@"+I+"@@@"});n=n.replace(/\r?\n/g,"");n=n.replace(/<a[^>]*?><\/a>/g,"");n=n.replace(/<p><\/p><table/g,"<table");n=n.replace(/<\/table><p><\/p>/g,"</table>");for(var A in s){n=n.replace(new RegExp("<p></p>@@@"+A+"@@@<p></p>"),"@@@"+A+"@@@")}n=n.replace(/<p><\/p><p>(?!<br>)/g,"<p>@@@wcf_empty_line@@@</p><p>");n=n.replace(/<br( \/)?><\/p>/g,"</p>");var h=n.split(/(<\/?(?:div|p)>)/);var i="";var y="";for(var b=0;b<h.length;b++){var z=h[b];if(z=="<p>"||z=="<div>"){continue}else{if(z=="</p>"||z=="</div>"){y=$.trim(y);if(y!="@@@wcf_empty_line@@@"){y+="\n"}i+=y;y=""}else{if(b==0||b+1==h.length){i+=z}else{y+=z}}}}if(y){i+=y;y=""}n=i;n=n.replace(/@@@wcf_empty_line@@@/g,"\n");n=n.replace(/\n\n$/,"\n");n=n.replace(/<br>$/,"");n=n.replace(/<br>/g,"\n");n=n.replace(/<br>/g,"");n=n.replace(/&nbsp;/gi," ");n=n.replace(/<blockquote([^>]+)>\n?<header[^>]*?>[\s\S]*?<\/header>/gi,function(D,C,F){var G;var E="";var B="";if(C.match(/data-author="([^"]+)"/)){E=WCF.String.unescapeHTML(RegExp.$1)}if(C.match(/cite="([^"]+)"/)){B=WCF.String.unescapeHTML(RegExp.$1)}if(B){G="[quote='"+E+"','"+B+"']"}else{if(E){G="[quote='"+E+"']"}else{G="[quote]"}}return G});n=n.replace(/(?:\n*)<\/blockquote>\n?/gi,"\n[/quote]\n");n=n.replace(/<a [^>]*?href=(["'])mailto:(.+?)\1.*?>([\s\S]+?)<\/a>/gi,"[email=$2]$3[/email]");n=n.replace(/<a[^>]+><\/a>/,"");n=n.replace(/<a [^>]*?href=(["'])(.+?)\1.*?>([\s\S]+?)<\/a>/gi,function(D,B,C,E){if(C==E){return"[url]"+C+"[/url]"}return"[url='"+C+"']"+E+"[/url]"});n=n.replace(/<(?:b|strong)>/gi,function(){if(w.indexOf("b")===-1){w.push("b")}return"[b]"});n=n.replace(/<\/(?:b|strong)>/gi,"[/b]");n=n.replace(/<(?:i|em)>/gi,function(){if(w.indexOf("i")===-1){w.push("i")}return"[i]"});n=n.replace(/<\/(?:i|em)>/gi,"[/i]");n=n.replace(/<u>/gi,function(){if(w.indexOf("u")===-1){w.push("u")}return"[u]"});n=n.replace(/<\/u>/gi,"[/u]");n=n.replace(/<sub>/gi,function(){if(w.indexOf("sub")===-1){w.push("sub")}return"[sub]"});n=n.replace(/<\/sub>/gi,"[/sub]");n=n.replace(/<sup>/gi,function(){if(w.indexOf("sup")===-1){w.push("sup")}return"[sup]"});n=n.replace(/<\/sup>/gi,"[/sup]");n=n.replace(/<(?:s(trike)?|del)>/gi,function(){if(w.indexOf("s")===-1){w.push("s")}return"[s]"});n=n.replace(/<\/(?:s(trike)?|del)>/gi,"[/s]");var f=n.split(/(<\/?span[^>]*>)/);var y=[];var p=[];var q="";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=p.pop();var i=e.start+y.pop()+e.end;if(y.length){y[y.length-1]+=i}else{q+=i}}else{if(j.match(/^<span/)){if(j.match(/^<span(?:.*?)style="([^"]+)"(?:[^>]*?)>/)){var l=RegExp.$1;var v;var o;if(l.match(/(?:^|;\s*)color: ?rgb\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\);?/i)){var u=RegExp.$1;var c=RegExp.$2;var g=RegExp.$3;var r=("0123456789ABCDEF".charAt((u-u%16)/16)+""+"0123456789ABCDEF".charAt(u%16))+""+("0123456789ABCDEF".charAt((c-c%16)/16)+""+"0123456789ABCDEF".charAt(c%16))+""+("0123456789ABCDEF".charAt((g-g%16)/16)+""+"0123456789ABCDEF".charAt(g%16));v="[color=#"+r+"]";o="[/color=#"+r+"]";if(w.indexOf("color")===-1){w.push("color")}}else{if(l.match(/(?:^|;\s*)color: ?([^;]+);?/i)){v="[color="+RegExp.$1+"]";o="[/color="+RegExp.$1+"]";if(w.indexOf("color")===-1){w.push("color")}}else{if(l.match(/font-size: ?(\d+)(pt|px);?/i)){if(RegExp.$2=="pt"){v="[size="+RegExp.$1+"]";o="[/size="+RegExp.$1+"]";if(w.indexOf("size")===-1){w.push("size")}}else{if(d[RegExp.$1]){v="[size="+d[RegExp.$1]+"]";o="[/size="+d[RegExp.$1]+"]";if(w.indexOf("size")===-1){w.push("size")}}else{v="";o=""}}}else{if(l.match(/font-family: ?([^;]+);?/)){v="[font='"+RegExp.$1.replace(/'/g,"")+"']";o="[/font='"+RegExp.$1.replace(/'/g,"")+"']";if(w.indexOf("font")===-1){w.push("font")}}else{v='<span style="'+l+'">';o="</span>"}}}}y[y.length]="";p[y.length]={start:v,end:o}}else{if(j.match(/^<span class="inlineCode">/)){y[y.length]="";p[y.length]={start:"[tt]",end:"[/tt]"}}else{y[y.length]="";p[y.length]={start:"",end:""}}}}else{if(y.length){y[y.length-1]+=j}else{q+=j}}}}n=q;n=n.replace(/<(div|p) style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)\n/gi,function(C,B,E,D){if(w.indexOf("align")===-1){w.push("align")}return"[align="+E+"]"+$.trim(D)+"[/align="+E+"]\n"});if(w.length){var m=true;while(m){m=false;n=n.replace(new RegExp("\\[\\/((?:"+w.join("|")+")=[^\\]]+?)\\]\n\\[\\1\\]","gi"),function(){m=true;return"\n"})}n=n.replace(new RegExp("\\[\\/("+w.join("|")+")=[^\\]]+?\\]","gi"),"[/$1]")}n=n.replace(/ ?<img [^>]*?alt="([^"]+?)"[^>]*?class="smiley"[^>]*?> ?/gi," $1 ");n=n.replace(/ ?<img [^>]*?class="smiley"[^>]*?alt="([^"]+?)"[^>]*?> ?/gi," $1 ");n=n.replace(/<img([^>]*?)class="[^"]*redactorEmbeddedAttachment[^"]*"([^>]*?)>/gi,function(E,H,J){var K=H+" "+J;var G;if(K.match(/data-attachment-id="(\d+)"/)){G=RegExp.$1}else{return E}var D="none";var C=null;if(K.match(/style="([^"]+)"/)){var F=RegExp.$1.split(";");for(var I=0;I<F.length;I++){var B=$.trim(F[I]);if(B.match(/^float: (left|right)$/)){D=RegExp.$1}else{if(B.match(/^width: (\d+)px$/)){C=RegExp.$1}}}if(C!==null){return"[attach="+G+","+D+","+C+"][/attach]"}else{if(D!=="none"){return"[attach="+G+","+D+"][/attach]"}}}return"[attach="+G+"][/attach]"});n=n.replace(/<img([^>]*)?src=(["'])([^"']+?)\2([^>]*)?>/gi,function(G,I,M,C,L){var J=I+" "+L;var E="";if(J.match(/style="([^"]+)"/)){E=RegExp.$1}var F="none";var D=0;var H=E.split(";");for(var K=0;K<H.length;K++){var B=H[K];if(B.match(/float: (left|right|none)/)){F=RegExp.$1}else{if(B.match(/width: (\d+)px/)){D=parseInt(RegExp.$1)}}}if(D){return"[img='"+C+"',"+F+","+D+"][/img]"}else{if(F!=="none"){return"[img='"+C+"',"+F+"][/img]"}}return"[img]"+C+"[/img]"});n=n.replace(/<li>/gi,"[*]");n=n.replace(/<\/li>/gi,"\n");n=n.replace(/<ul>/gi,"[list]");n=n.replace(/<(ol|ul style="list-style-type: decimal")>/gi,"[list=1]");n=n.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]");n=n.replace(/<\/(ul|ol)>/gi,"[/list]");n=n.replace(/\n?\[list\]/g,"\n[list]");n=n.replace(/\[\/list\]\n\[\*\]/g,"[/list][*]");n=n.replace(/\[\/list\]\n\[\/list\]/g,"[/list][/list]");n=n.replace(/<table[^>]*>/gi,"[table]\n");n=n.replace(/<\/table>\n?/gi,"[/table]\n");n=n.replace(/<tbody>([\s\S]*?)<\/tbody>/,function(B,C){return $.trim(C)});n=n.replace(/<tr><\/tr>/gi,"");n=n.replace(/<tr>/gi,"[tr]\n");n=n.replace(/<\/tr>/gi,"[/tr]\n");n=n.replace(/<td style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)<\/td>/gi,"[td][align=$1]$2[/align][/td]");n=n.replace(/(\t)*<td>(\t)*/gi,"[td]");n=n.replace(/(\t)*<\/td>/gi,"[/td]\n");var x={};n.replace(/<span id="selection-marker-\d+" class="redactor-selection-marker"><\/span>/,function(B){var C=B.hashCode();x[C]=B.replace(/\$/g,"$$$$");return"@@"+C+"@@"});WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","convertFromHtml",{html:n});n=n.replace(/<[^(<|>)]+>/g,"");if($.getLength(x)){for(var k in x){var t=new RegExp("@@"+k+"@@","g");data=data.replace(t,x[k])}}if($.getLength(s)){$.each(s,function(D,F){var C=0;if(F.highlighter){C++}if(F.lineNumber){C++}if(F.filename){C++}var B="";switch(C){case 1:if(F.highlighter){B=F.highlighter}else{if(F.filename){B="'"+F.filename+"'"}else{B=F.lineNumber}}break;case 2:if(F.lineNumber){B=F.lineNumber}if(F.highlighter){if(B.length){B+=","}B+=F.highlighter}if(F.filename){if(B.length){B+=","}B+="'"+F.filename+"'"}break;case 3:B=F.highlighter+","+F.lineNumber+",'"+F.filename+"'";break}var E="[code"+(B.length?"="+B:"")+"]"+F.codeContent+"[/code]\n";n=n.replace(new RegExp("@@@"+D+"@@@\n?","g"),E)})}n=n.replace(/&lt;/g,"<");n=n.replace(/&gt;/g,">");n=n.replace(/&amp;/g,"&");n=n.replace(/%28/g,"(");n=n.replace(/%29/g,")");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertFromHtml",{html:n});n=$.trim(n);if(n.length){n+="\n"}return n},convertToHtml:function(I){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertToHtml",{data:I});I=this.wutil.removeZeroWidthSpace(I);I=I.replace(/&/g,"&amp;");I=I.replace(/</g,"&lt;");I=I.replace(/>/g,"&gt;");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|i|s|sub|sup|u)\]\[\1\]/gi,"[$1]");I=I.replace(/\[(\/(?:b|i|s|sub|sup|u))\]\[\1\]/gi,"[$1]");I=I.replace(/\[(b|i|s|sub|sup|u)\]\[\/\1\]/gi,"");I=I.replace(/\[b\]([\s\S]*?)\[\/b]/gi,(function(J,K){return this.wbbcode._expandFormatting(K,"<strong>","</strong>")}).bind(this));I=I.replace(/\[i\]([\s\S]*?)\[\/i]/gi,(function(J,K){return this.wbbcode._expandFormatting(K,"<em>","</em>")}).bind(this));I=I.replace(/\[u\]([\s\S]*?)\[\/u]/gi,(function(J,K){return this.wbbcode._expandFormatting(K,"<u>","</u>")}).bind(this));I=I.replace(/\[s\]([\s\S]*?)\[\/s]/gi,(function(J,K){return this.wbbcode._expandFormatting(K,"<del>","</del>")}).bind(this));I=I.replace(/\[sub\]([\s\S]*?)\[\/sub]/gi,(function(J,K){return this.wbbcode._expandFormatting(K,"<sub>","</sub>")}).bind(this));I=I.replace(/\[sup\]([\s\S]*?)\[\/sup]/gi,(function(J,K){return this.wbbcode._expandFormatting(K,"<sup>","</sup>")}).bind(this));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){return this.wbbcode._expandFormatting(L,'<span style="font-size: '+K+'pt">',"</span>")}).bind(this));I=I.replace(/\[color=([#a-z0-9]*?)\]([\s\S]*?)\[\/color\]/gi,(function(K,J,L){return this.wbbcode._expandFormatting(L,'<span style="color: '+J+'">',"</span>")}).bind(this));I=I.replace(/\[font='?([a-z,\- ]*?)'?\]([\s\S]*?)\[\/font\]/gi,(function(K,J,L){return this.wbbcode._expandFormatting(L,'<span style="font-family: '+J+'">',"</span>")}).bind(this));I=I.replace(/\[align=(left|right|center|justify)\]([\s\S]*?)\[\/align\]/gi,(function(J,L,K){return this.wbbcode._expandFormatting(K,'<p style="text-align: '+L+'">',"</p>")}).bind(this));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.lastIndexOf("[/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="&#8203;"}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,"&lt;").replace(/>/g,"&gt;");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())||RegExp.$1.toUpperCase()==="TABLE"){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>"}}I=I.replace(/<td>([\s\S]+?)<\/td>/g,function(J,K){K=K.replace(/<br(?: \/)?>(<[uo]l)/g,"$1");return"<td>"+K.replace(/<p><br(?: \/)?><\/p>/g,"<br>").replace(/<p>/g,"").replace(/<\/p>/g,"<br>").replace(/<br>$/,"")+"</td>"});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(=(['"]).+?\2)?\]([\S\s]*)\[\/quote\]/gi,function(N,L,M,P){var T="";var O="";if(L){L=L.substr(1);L=L.split(",");switch(L.length){case 1:T=L[0];break;case 2:T=L[0];O=L[1];break}T=WCF.String.escapeHTML(G($.trim(T)));O=WCF.String.escapeHTML(G($.trim(O)))}var U='<blockquote class="quoteBox container containerPadding quoteBoxSimple" cite="'+O+'" data-author="'+T+'"><header contenteditable="false"><h3>'+r.wbbcode._buildQuoteHeader(T,O)+'</h3><a class="redactorQuoteEdit"></a></header>';P=$.trim(P);var K="";if(P.length){var S=P.split("\n");for(var R=0;R<S.length;R++){var Q=S[R];if(Q.length===0){Q=r.opts.invisibleSpace}else{if(Q.match(/^@@([0-9\-]+)@@$/)){if(WCF.inArray(RegExp.$1,E)){K+=Q;continue}}}K+="<div>"+Q+"</div>"}}else{K="<div>"+r.opts.invisibleSpace+"</div>"}U+=K;U+="</blockquote>";return U})};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))}}I=I.replace(/<(?:div|p)><(blockquote|div)/g,"<$1");I=I.replace(/<\/(blockquote|div)><\/(?:div|p)>/g,"</$1>");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(/^\[tt\]([\s\S]+)\[\/tt\]/,(function(J,L){var K=L.split("\n");L="";for(var O=0,N=K.length;O<N;O++){var M=K[O];if(M.length){if(L.length){L+="</p><p>"}L+="[tt]"+M+"[/tt]"}else{if(O===0||(O+1)===N){continue}if(L.match(/\[\/tt\]$/)){L+="</p><p>"+this.opts.invisibleSpace+""}else{L+="</p><p><br>"}}}return L}).bind(this));i=i.replace(/^\[code([^\]]*)\]([\S\s]*)\[\/code\]$/,(function(M,U,O){var N="plain";var S=0;var Q="";if(U){U=U.substring(1);U=U.split(",");var P=function(W){return W.match(/^\d+$/)};var L=function(W){return(W.indexOf(".")!==-1)||(W.match(/^(["']).*\1$/))};var K=function(W){return(__REDACTOR_CODE_HIGHLIGHTERS[W]!==undefined)};var J=function(W){return W.replace(/^(["'])(.*)\1$/,"$2")};switch(U.length){case 1:if(P(U[0])){S=(parseInt(U[0])>1)?U[0]:0}else{if(L(U[0])){Q=J(U[0])}else{if(K(U[0])){N=U[0]}}}break;case 2:if(P(U[0])){S=(parseInt(U[0])>1)?U[0]:0;if(K(U[1])){N=U[1]}else{if(L(U[1])){Q=J(U[1])}}}else{if(K(U[0])){N=U[0]}if(L(U[1])){Q=J(U[1])}}break;case 3:if(K(U[0])){N=U[0]}if(P(U[1])){S=U[1]}if(L(U[2])){Q=J(U[2])}break}}O=O.replace(/^\n+/,"").replace(/\n+$/,"").split(/\n/);var V="";for(var T=0;T<O.length;T++){var R=O[T];if(!R.length){R=this.opts.invisibleSpace}V+="<li>"+R+"</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="'+(S>1?S:1)+'">'+V+"</ol></div></div>"}).bind(this));I=I.replace(z,i)}}WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertToHtml",{data:I});return I},_expandFormatting:function(e,c,f){if(!e.length){return c+this.opts.invisibleSpace+f}var b=e.indexOf("[/td]");if(b!==-1){var d=e.substring(0,b);if(d.indexOf("[td]")===-1){return c+d+f+e.substring(b)}}var d=e.split("\n");e="";for(var i=0,h=d.length;i<h;i++){var g=d[i];if(g.length===0){g=this.opts.invisibleSpace}if(e.length){e+="\n"}e+=c+g+f}return e},_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(/<o:p>&nbsp;<\/o:p>/g,"<br>");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>");b=b.replace(/<(?:div|p|span)[^>]+>/gi,function(d){return d.replace(/ class="[^"]+"/,"")});b=b.replace(/<\/?wbr[^>]*>/g,"");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforePaste",{html:b});return b},_pasteCallback:function(b){b=b.replace(/\[size=(\d+)\]/g,'<p><span style="font-size: $1pt">');b=b.replace(/\[\/size\]/g,"</span></p>");b=b.replace(/style="([^"]+)"/,function(c,e){var d=e.split(";");var g=[];for(var i=0,f=d.length;i<f;i++){var h=d[i];if(!h.match(/^\s*background-color/)){g.push(h)}}return'style="'+g.join(";")+'"'});WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterPaste",{html:b});return b;b=b.replace(/<img([^>]+)>/g,function(c,d){c=c.replace(/data-mozilla-paste-image="0"/,'data-mozilla-paste-image="0" style="display:none"');return c});return b},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(x){switch(x.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 p=this.selection.getCurrent();var n=this.selection.getParent();n=(n)?$(n):n;var j=(n)?n.closest("blockquote.quoteBox",this.$editor.get()[0]):{length:0};switch(x.event.which){case $.ui.keyCode.BACKSPACE:if(this.wutil.isCaret()){var h=false;if(j.length){var k=true;for(var b=0;b<j[0].children.length;b++){var w=j[0].children[b];if(w.tagName==="DIV"){if(w.textContent.replace(/\u200b/,"").length){k=false;break}}}if(k){h=true}else{var m=(this.selection.implicitRange===null)?this.range:this.selection.implicitRange;if(m.startOffset===0){var d=m.startContainer,o;while((d=d.parentNode)!==null){o=d.previousSibling;if(o!==null){if(o.nodeType===Node.ELEMENT_NODE&&o.nodeName==="HEADER"){h=true}break}}}}}else{var f=(this.selection.implicitRange===null)?this.range:this.selection.implicitRange;var q=f.startContainer;if(q.nodeType===Node.TEXT_NODE){if(f.startOffset===0||(f.startOffset===1&&q.textContent==="\u200b")){if(!q.previousSibling){q=q.parentElement}}}if(q.nodeType===Node.ELEMENT_NODE){var i=q.previousSibling;if(i&&i.nodeType===Node.ELEMENT_NODE&&i.tagName==="BLOCKQUOTE"){j=i;h=true}}}if(h){var t=window.getSelection();if(t.rangeCount){t.removeAllRanges()}var r=document.createRange();r.selectNode(j[0]||j);t.addRange(r);x.cancel=true}}break;case $.ui.keyCode.DELETE:if(this.wutil.isCaret()&&this.wutil.isEndOfElement(p)){var v=p.nextElementSibling;if(v&&v.tagName==="BLOCKQUOTE"){var t=window.getSelection();if(t.rangeCount){t.removeAllRanges()}var r=document.createRange();r.selectNode(v);t.addRange(r);x.cancel=true}}break;case $.ui.keyCode.DOWN:var e=$(p);if(e.next("blockquote").length){this.caret.setStart(e.next().children("div:first"));x.cancel=true}else{if(n){if(n.next("blockquote").length){this.caret.setStart(n.next().children("div:first"));x.cancel=true}else{if(j.length){var s=e.closest("div",j[0]);if(!s.next().length){if(j.next().length){this.caret.setStart(j.next())}else{this.wutil.setCaretAfter(j)}x.cancel=true}}}}}break;case $.ui.keyCode.ENTER:if(j.length){this.keydown.blockquote=false;this.keydown.enterWithinBlockquote=true}break;case $.ui.keyCode.UP:if(!n||!j.length){return}var s=$(p).closest("div",j[0]);var u=s.prev();if(u[0].tagName==="DIV"){return}else{if(u[0].tagName==="BLOCKQUOTE"){return}}var l=j.prev();if(l.length===0){this.wutil.setCaretBefore(j)}else{if(l[0].tagName==="BLOCKQUOTE"){this.caret.sendEnd(l.children("div:last"))}else{if($.trim(l.html())==""){l.html(this.opts.invisibleSpace)}this.caret.setEnd(l)}}x.cancel=true;break;case 83:if($.browser.mobile){return}var c=false;if(navigator.platform.match(/^Mac/)){if(x.event.ctrlKey&&x.event.altKey){c=true}}else{if(x.event.altKey&&!x.event.ctrlKey){c=true}}if(c){var g={cancel:false};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","submitEditor_"+this.$textarea.wcfIdentify(),g);if(g.cancel){x.cancel=true}}break}},_keyupCallback:function(d){switch(d.event.which){case $.ui.keyCode.BACKSPACE:case $.ui.keyCode.DELETE:this.$editor.find("blockquote").each(function(h,j){var i=$(j);if(!i.children("header").length){i.remove()}});break;case $.ui.keyCode.ENTER:for(var g=0,f=this.$editor[0].children.length;g<f;g++){var c=this.$editor[0].children[g];if(c.nodeType!==Node.ELEMENT_NODE||c.tagName!=="P"){continue}if(c.textContent.length>0){continue}if(c.children.length>1||c.children[0].tagName==="BR"){continue}c=c.children[0];while(c.children.length===1){c=c.children[0]}if(c.children.length===0&&c.tagName==="BR"){var e=c.parentNode;var b=document.createTextNode("\u200b");e.appendChild(b);e.removeChild(c)}}break}},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("> header > h3").empty().append(this.wbbcode._buildQuoteHeader(d,b))},insertQuoteBBCode:function(g,l,i,j){var k="[quote]";var c="[/quote]";if(g){if(l){k="[quote='"+g+"','"+l+"']"}else{k="[quote='"+g+"']"}}var p=null;if(this.wutil.inWysiwygMode()){var o=WCF.getUUID();var e="";if(j){e=this.wbbcode.convertToHtml(k+j+c)}else{e=this.wbbcode.convertToHtml(k+o+c);e=e.replace(o,i.replace(/^<p>/,"").replace(/<\/p>$/,""))}e=e.replace(/^<p>/,"").replace(/<\/p>$/,"");e=e.replace(/<blockquote/,'<blockquote id="'+o+'"');if(!window.getSelection().rangeCount){this.wutil.restoreSelection();if(!window.getSelection().rangeCount){this.$editor.focus();if(!window.getSelection().rangeCount){this.wutil.selectionEndOfEditor()}this.wutil.saveSelection()}}window.getSelection().getRangeAt(0).deleteContents();this.wutil.restoreSelection();var h=window.getSelection().getRangeAt(0);var b=h.startContainer;while(b){var f=b.parentNode;if(f===this.$editor[0]){break}b=f}if(b&&b.parentNode===this.$editor[0]){if(b.innerHTML.length){if(b.innerHTML==="\u200b"){this.caret.setEnd(b)}else{this.wutil.setCaretAfter(b)}}}this.insert.html(e,false);p=this.$editor.find("#"+o);if(p.length){var n=p.find("> div");if(n.length==1){if(n[0].innerHTML===""){n[0].innerHTML=this.opts.invisibleSpace}}else{if($.browser.mozilla){var m=p.find("> div > br[type=_moz]");if(m.length){$("<div>"+this.opts.invisibleSpace+"</div>").insertBefore(m);m.remove()}}}p.removeAttr("id");this.wutil.setCaretAfter(p[0]);var d=p[0].previousElementSibling;if(d!==null&&d.nodeName==="P"&&d.innerHTML==="\u200B"){d=d.previousElementSibling;if(d!==null&&d.nodeName==="P"&&(d.innerHTML==="\u200B"||d.innerHTML==="<br>")){d.parentNode.removeChild(d.nextElementSibling)}}}this.wbbcode.observeQuotes();this.wbbcode.fixBlockLevelElements();this.$toolbar.find("a.re-__wcf_quote").removeClass("redactor-button-disabled")}else{this.wutil.insertAtCaret(k+j+c)}this.wutil.saveSelection();return p},_buildQuoteHeader:function(c,d){var b="";if(!c&&d){c=d;d=""}if(c){if(d){b+='<a href="'+d+'" tabindex="-1">'}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+"'":"")+"]";if(r.match(/\[code=([^,]+),(\d+)\]/)){r="[code="+RegExp.$2+","+RegExp.$1+"]"}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().replace(/^\u200b$/,"")+"\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(){var b=(function(e,c){var d=e[c];if(d&&d.nodeType===Node.ELEMENT_NODE&&d.tagName==="P"){if(!d.innerHTML.length){d.parentElement.removeChild(d)}}}).bind(this);this.$editor.find("blockquote, .codeBox").each(function(){b(this,"previousElementSibling");b(this,"nextElementSibling")})},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(){window.addEventListener("unload",(function(j){this.code.startSync();this.$textarea.val(this.wbbcode.convertFromHtml(this.$textarea.val()))}).bind(this));if($.browser.msie){this.$editor.addClass("msie")}this.$textarea[0].setAttribute("data-is-dirty",true);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){i=i.replace(/\u200C/g,"__wcf_zwnj__");i=i.replace(/\u200D/g,"__wcf_zwj__");if(a===true){a=false}else{i=i.replace(/<p><br([^>]+)?><\/p>/g,"<p>@@@wcf_empty_line@@@</p>")}i=d.call(this,i);i=i.replace(/__wcf_zwnj__/g,"\u200C");return i.replace(/__wcf_zwj__/g,"\u200D")}).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.wutil.fixDOM();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){if(i.target===this.$editor[0]){if(this.$editor[0].lastElementChild&&this.$editor[0].lastElementChild.tagName==="BLOCKQUOTE"){this.wutil.setCaretAfter($(this.$editor[0].lastElementChild))}}setTimeout(this.wutil.saveSelection.bind(this),10)}).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(j,i,e){if(e){this.wbbcode.registerSmiley(j,i)}if(this.opts.visual){this.wutil.restoreSelection();var f=null;if(window.getSelection().rangeCount&&window.getSelection().getRangeAt(0).collapsed){f=window.getSelection().getRangeAt(0).startContainer;if(f.nodeType===Node.TEXT_NODE){f=f.parentElement}if(!this.utils.isRedactorParent(f)){f=null}}this.insert.html('<img src="'+i+'" class="smiley" alt="'+j+'" id="redactorSmiley">',false);var b=document.getElementById("redactorSmiley");b.removeAttribute("id");if(f!==null){var d=window.getSelection().getRangeAt(0).startContainer;if(d.nodeType===Node.TEXT_NODE){d=d.parentElement}if(f!==d){f.appendChild(b)}}var h=function(k){if(k===null){return false}if((k.nodeType===Node.ELEMENT_NODE&&k.nodeName==="SPAN")||k.nodeType===Node.TEXT_NODE){if(k.textContent==="\u00A0"){return true}}return false};var g=b.parentElement;if(!h(b.previousSibling)){var c=document.createTextNode("\u00A0");g.insertBefore(c,b)}if(!h(b.nextSibling)){var c=document.createTextNode("\u00A0");if(g.lastChild===b){g.appendChild(c)}else{g.insertBefore(c,b.nextSibling)}}this.wutil.saveSelection()}else{this.wutil.insertAtCaret(" "+j+" ")}},registerSmiley:function(b,c){if(__REDACTOR_SMILIES[b]){return false}__REDACTOR_SMILIES[b]=c;return true},convertFromHtml:function(n){var w=[];WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertFromHtml",{html:n});n=n.replace(/(<[^>]+?) data-redactor-tag="[^"]+"/g,"$1");n=n.replace(/(<[^>]+?) rel="[^"]+"/g,"$1");n=n.replace(/&#(8203|x200b);/g,"");n=n.replace(/&trade;/gi,"\u2122");n=n.replace(/&copy;/gi,"\u00a9");n=n.replace(/&hellip;/gi,"\u2026");n=n.replace(/&mdash;/gi,"\u2014");n=n.replace(/&dash;/gi,"\u2010");var s={};n=n.replace(/<div([^>]+?)class="codeBox[^"]+"([^>]*?)>\n*<div>[\s\S]+?<ol start="(\d+)">([\s\S]+?)<\/ol>\n*<\/div>\n*<\/div>/g,function(F,D,C,E,B){var J=D+" "+C;var G="";var H="";if(J.match(/data-highlighter="([a-zA-Z]+)"/)){G=RegExp.$1}if(J.match(/data-filename="([^"]+)"/)){H=$.trim(RegExp.$1)}var I=WCF.getUUID();s[I]={codeContent:B.replace(/<li>/g,"").replace(/<\/li>/g,"\n").replace(/\n$/,""),filename:H.replace(/['"]/g,""),highlighter:(G==="plain"?"":G),lineNumber:(E>1?E:0)};return"@@@"+I+"@@@"});n=n.replace(/\r?\n/g,"");n=n.replace(/<a[^>]*?><\/a>/g,"");n=n.replace(/<p><\/p><table/g,"<table");n=n.replace(/<\/table><p><\/p>/g,"</table>");for(var A in s){n=n.replace(new RegExp("<p></p>@@@"+A+"@@@<p></p>"),"@@@"+A+"@@@")}n=n.replace(/<p><\/p><p>(?!<br>)/g,"<p>@@@wcf_empty_line@@@</p><p>");n=n.replace(/<br( \/)?><\/p>/g,"</p>");var h=n.split(/(<\/?(?:div|p)>)/);var i="";var y="";for(var b=0;b<h.length;b++){var z=h[b];if(z=="<p>"||z=="<div>"){continue}else{if(z=="</p>"||z=="</div>"){y=$.trim(y);if(y!="@@@wcf_empty_line@@@"){y+="\n"}i+=y;y=""}else{if(b==0||b+1==h.length){i+=z}else{y+=z}}}}if(y){i+=y;y=""}n=i;n=n.replace(/@@@wcf_empty_line@@@/g,"\n");n=n.replace(/\n\n$/,"\n");n=n.replace(/<br>$/,"");n=n.replace(/<br>/g,"\n");n=n.replace(/<br>/g,"");n=n.replace(/&nbsp;/gi," ");n=n.replace(/<blockquote([^>]+)>\n?<header[^>]*?>[\s\S]*?<\/header>/gi,function(D,C,F){var G;var E="";var B="";if(C.match(/data-author="([^"]+)"/)){E=WCF.String.unescapeHTML(RegExp.$1)}if(C.match(/cite="([^"]+)"/)){B=WCF.String.unescapeHTML(RegExp.$1)}if(B){G="[quote='"+E+"','"+B+"']"}else{if(E){G="[quote='"+E+"']"}else{G="[quote]"}}return G});n=n.replace(/(?:\n*)<\/blockquote>\n?/gi,"\n[/quote]\n");n=n.replace(/<a [^>]*?href=(["'])mailto:(.+?)\1.*?>([\s\S]+?)<\/a>/gi,"[email=$2]$3[/email]");n=n.replace(/<a[^>]+><\/a>/,"");n=n.replace(/<a [^>]*?href=(["'])(.+?)\1.*?>([\s\S]+?)<\/a>/gi,function(D,B,C,E){if(C==E){return"[url]"+C+"[/url]"}return"[url='"+C+"']"+E+"[/url]"});n=n.replace(/<(?:b|strong)>/gi,function(){if(w.indexOf("b")===-1){w.push("b")}return"[b]"});n=n.replace(/<\/(?:b|strong)>/gi,"[/b]");n=n.replace(/<(?:i|em)>/gi,function(){if(w.indexOf("i")===-1){w.push("i")}return"[i]"});n=n.replace(/<\/(?:i|em)>/gi,"[/i]");n=n.replace(/<u>/gi,function(){if(w.indexOf("u")===-1){w.push("u")}return"[u]"});n=n.replace(/<\/u>/gi,"[/u]");n=n.replace(/<sub>/gi,function(){if(w.indexOf("sub")===-1){w.push("sub")}return"[sub]"});n=n.replace(/<\/sub>/gi,"[/sub]");n=n.replace(/<sup>/gi,function(){if(w.indexOf("sup")===-1){w.push("sup")}return"[sup]"});n=n.replace(/<\/sup>/gi,"[/sup]");n=n.replace(/<(?:s(trike)?|del)>/gi,function(){if(w.indexOf("s")===-1){w.push("s")}return"[s]"});n=n.replace(/<\/(?:s(trike)?|del)>/gi,"[/s]");var f=n.split(/(<\/?span[^>]*>)/);var y=[];var p=[];var q="";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=p.pop();var i=e.start+y.pop()+e.end;if(y.length){y[y.length-1]+=i}else{q+=i}}else{if(j.match(/^<span/)){if(j.match(/^<span(?:.*?)style="([^"]+)"(?:[^>]*?)>/)){var l=RegExp.$1;var v;var o;if(l.match(/(?:^|;\s*)color: ?rgb\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\);?/i)){var u=RegExp.$1;var c=RegExp.$2;var g=RegExp.$3;var r=("0123456789ABCDEF".charAt((u-u%16)/16)+""+"0123456789ABCDEF".charAt(u%16))+""+("0123456789ABCDEF".charAt((c-c%16)/16)+""+"0123456789ABCDEF".charAt(c%16))+""+("0123456789ABCDEF".charAt((g-g%16)/16)+""+"0123456789ABCDEF".charAt(g%16));v="[color=#"+r+"]";o="[/color=#"+r+"]";if(w.indexOf("color")===-1){w.push("color")}}else{if(l.match(/(?:^|;\s*)color: ?([^;]+);?/i)){v="[color="+RegExp.$1+"]";o="[/color="+RegExp.$1+"]";if(w.indexOf("color")===-1){w.push("color")}}else{if(l.match(/font-size: ?(\d+)(pt|px);?/i)){if(RegExp.$2=="pt"){v="[size="+RegExp.$1+"]";o="[/size="+RegExp.$1+"]";if(w.indexOf("size")===-1){w.push("size")}}else{if(d[RegExp.$1]){v="[size="+d[RegExp.$1]+"]";o="[/size="+d[RegExp.$1]+"]";if(w.indexOf("size")===-1){w.push("size")}}else{v="";o=""}}}else{if(l.match(/font-family: ?([^;]+);?/)){v="[font='"+RegExp.$1.replace(/'/g,"")+"']";o="[/font='"+RegExp.$1.replace(/'/g,"")+"']";if(w.indexOf("font")===-1){w.push("font")}}else{v='<span style="'+l+'">';o="</span>"}}}}y[y.length]="";p[y.length]={start:v,end:o}}else{if(j.match(/^<span class="inlineCode">/)){y[y.length]="";p[y.length]={start:"[tt]",end:"[/tt]"}}else{y[y.length]="";p[y.length]={start:"",end:""}}}}else{if(y.length){y[y.length-1]+=j}else{q+=j}}}}n=q;n=n.replace(/<(div|p) style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)\n/gi,function(C,B,E,D){if(w.indexOf("align")===-1){w.push("align")}return"[align="+E+"]"+$.trim(D)+"[/align="+E+"]\n"});if(w.length){var m=true;while(m){m=false;n=n.replace(new RegExp("\\[\\/((?:"+w.join("|")+")=[^\\]]+?)\\]\n\\[\\1\\]","gi"),function(){m=true;return"\n"})}n=n.replace(new RegExp("\\[\\/("+w.join("|")+")=[^\\]]+?\\]","gi"),"[/$1]")}n=n.replace(/ ?<img [^>]*?alt="([^"]+?)"[^>]*?class="smiley"[^>]*?> ?/gi," $1 ");n=n.replace(/ ?<img [^>]*?class="smiley"[^>]*?alt="([^"]+?)"[^>]*?> ?/gi," $1 ");n=n.replace(/<img([^>]*?)class="[^"]*redactorEmbeddedAttachment[^"]*"([^>]*?)>/gi,function(E,H,J){var K=H+" "+J;var G;if(K.match(/data-attachment-id="(\d+)"/)){G=RegExp.$1}else{return E}var D="none";var C=null;if(K.match(/style="([^"]+)"/)){var F=RegExp.$1.split(";");for(var I=0;I<F.length;I++){var B=$.trim(F[I]);if(B.match(/^float: (left|right)$/)){D=RegExp.$1}else{if(B.match(/^width: (\d+)px$/)){C=RegExp.$1}}}if(C!==null){return"[attach="+G+","+D+","+C+"][/attach]"}else{if(D!=="none"){return"[attach="+G+","+D+"][/attach]"}}}return"[attach="+G+"][/attach]"});n=n.replace(/<img([^>]*)?src=(["'])([^"']+?)\2([^>]*)?>/gi,function(G,I,M,C,L){var J=I+" "+L;var E="";if(J.match(/style="([^"]+)"/)){E=RegExp.$1}var F="none";var D=0;var H=E.split(";");for(var K=0;K<H.length;K++){var B=H[K];if(B.match(/float: (left|right|none)/)){F=RegExp.$1}else{if(B.match(/width: (\d+)px/)){D=parseInt(RegExp.$1)}}}if(D){return"[img='"+C+"',"+F+","+D+"][/img]"}else{if(F!=="none"){return"[img='"+C+"',"+F+"][/img]"}}return"[img]"+C+"[/img]"});n=n.replace(/<li>/gi,"[*]");n=n.replace(/<\/li>/gi,"\n");n=n.replace(/<ul>/gi,"[list]");n=n.replace(/<(ol|ul style="list-style-type: decimal")>/gi,"[list=1]");n=n.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]");n=n.replace(/<\/(ul|ol)>/gi,"[/list]");n=n.replace(/\n?\[list\]/g,"\n[list]");n=n.replace(/\[\/list\]\n\[\*\]/g,"[/list][*]");n=n.replace(/\[\/list\]\n\[\/list\]/g,"[/list][/list]");n=n.replace(/<table[^>]*>/gi,"[table]\n");n=n.replace(/<\/table>\n?/gi,"[/table]\n");n=n.replace(/<tbody>([\s\S]*?)<\/tbody>/,function(B,C){return $.trim(C)});n=n.replace(/<tr><\/tr>/gi,"");n=n.replace(/<tr>/gi,"[tr]\n");n=n.replace(/<\/tr>/gi,"[/tr]\n");n=n.replace(/<td style="text-align: ?(left|center|right|justify);? ?">([\s\S]*?)<\/td>/gi,"[td][align=$1]$2[/align][/td]");n=n.replace(/(\t)*<td>(\t)*/gi,"[td]");n=n.replace(/(\t)*<\/td>/gi,"[/td]\n");var x={};n.replace(/<span id="selection-marker-\d+" class="redactor-selection-marker"><\/span>/,function(B){var C=B.hashCode();x[C]=B.replace(/\$/g,"$$$$");return"@@"+C+"@@"});WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","convertFromHtml",{html:n});n=n.replace(/<[^(<|>)]+>/g,"");if($.getLength(x)){for(var k in x){var t=new RegExp("@@"+k+"@@","g");data=data.replace(t,x[k])}}if($.getLength(s)){$.each(s,function(D,F){var C=0;if(F.highlighter){C++}if(F.lineNumber){C++}if(F.filename){C++}var B="";switch(C){case 1:if(F.highlighter){B=F.highlighter}else{if(F.filename){B="'"+F.filename+"'"}else{B=F.lineNumber}}break;case 2:if(F.lineNumber){B=F.lineNumber}if(F.highlighter){if(B.length){B+=","}B+=F.highlighter}if(F.filename){if(B.length){B+=","}B+="'"+F.filename+"'"}break;case 3:B=F.highlighter+","+F.lineNumber+",'"+F.filename+"'";break}var E="[code"+(B.length?"="+B:"")+"]"+F.codeContent+"[/code]\n";n=n.replace(new RegExp("@@@"+D+"@@@\n?","g"),E)})}n=n.replace(/&lt;/g,"<");n=n.replace(/&gt;/g,">");n=n.replace(/&amp;/g,"&");n=n.replace(/%28/g,"(");n=n.replace(/%29/g,")");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertFromHtml",{html:n});n=$.trim(n);if(n.length){n+="\n"}return n},convertToHtml:function(I){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertToHtml",{data:I});I=this.wutil.removeZeroWidthSpace(I);I=I.replace(/&/g,"&amp;");I=I.replace(/</g,"&lt;");I=I.replace(/>/g,"&gt;");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|i|s|sub|sup|u)\]\[\1\]/gi,"[$1]");I=I.replace(/\[(\/(?:b|i|s|sub|sup|u))\]\[\1\]/gi,"[$1]");I=I.replace(/\[(b|i|s|sub|sup|u)\]\[\/\1\]/gi,"");I=I.replace(/\[b\]([\s\S]*?)\[\/b]/gi,(function(J,K){return this.wbbcode._expandFormatting(K,"<strong>","</strong>")}).bind(this));I=I.replace(/\[i\]([\s\S]*?)\[\/i]/gi,(function(J,K){return this.wbbcode._expandFormatting(K,"<em>","</em>")}).bind(this));I=I.replace(/\[u\]([\s\S]*?)\[\/u]/gi,(function(J,K){return this.wbbcode._expandFormatting(K,"<u>","</u>")}).bind(this));I=I.replace(/\[s\]([\s\S]*?)\[\/s]/gi,(function(J,K){return this.wbbcode._expandFormatting(K,"<del>","</del>")}).bind(this));I=I.replace(/\[sub\]([\s\S]*?)\[\/sub]/gi,(function(J,K){return this.wbbcode._expandFormatting(K,"<sub>","</sub>")}).bind(this));I=I.replace(/\[sup\]([\s\S]*?)\[\/sup]/gi,(function(J,K){return this.wbbcode._expandFormatting(K,"<sup>","</sup>")}).bind(this));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){return this.wbbcode._expandFormatting(L,'<span style="font-size: '+K+'pt">',"</span>")}).bind(this));I=I.replace(/\[color=([#a-z0-9]*?)\]([\s\S]*?)\[\/color\]/gi,(function(K,J,L){return this.wbbcode._expandFormatting(L,'<span style="color: '+J+'">',"</span>")}).bind(this));I=I.replace(/\[font='?([a-z,\- ]*?)'?\]([\s\S]*?)\[\/font\]/gi,(function(K,J,L){return this.wbbcode._expandFormatting(L,'<span style="font-family: '+J+'">',"</span>")}).bind(this));I=I.replace(/\[align=(left|right|center|justify)\]([\s\S]*?)\[\/align\]/gi,(function(J,L,K){return this.wbbcode._expandFormatting(K,'<p style="text-align: '+L+'">',"</p>")}).bind(this));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.lastIndexOf("[/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="&#8203;"}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,"&lt;").replace(/>/g,"&gt;");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())||RegExp.$1.toUpperCase()==="TABLE"){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>"}}I=I.replace(/<td>([\s\S]+?)<\/td>/g,function(J,K){K=K.replace(/<br(?: \/)?>(<[uo]l)/g,"$1");return"<td>"+K.replace(/<p><br(?: \/)?><\/p>/g,"<br>").replace(/<p>/g,"").replace(/<\/p>/g,"<br>").replace(/<br>$/,"")+"</td>"});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(=(['"]).+?\2)?\]([\S\s]*)\[\/quote\]/gi,function(N,L,M,P){var T="";var O="";if(L){L=L.substr(1);L=L.split(",");switch(L.length){case 1:T=L[0];break;case 2:T=L[0];O=L[1];break}T=WCF.String.escapeHTML(G($.trim(T)));O=WCF.String.escapeHTML(G($.trim(O)))}var U='<blockquote class="quoteBox container containerPadding quoteBoxSimple" cite="'+O+'" data-author="'+T+'"><header contenteditable="false"><h3>'+r.wbbcode._buildQuoteHeader(T,O)+'</h3><a class="redactorQuoteEdit"></a></header>';P=$.trim(P);var K="";if(P.length){var S=P.split("\n");for(var R=0;R<S.length;R++){var Q=S[R];if(Q.length===0){Q=r.opts.invisibleSpace}else{if(Q.match(/^@@([0-9\-]+)@@$/)){if(WCF.inArray(RegExp.$1,E)){K+=Q;continue}}}K+="<div>"+Q+"</div>"}}else{K="<div>"+r.opts.invisibleSpace+"</div>"}U+=K;U+="</blockquote>";return U})};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))}}I=I.replace(/<(?:div|p)><(blockquote|div)/g,"<$1");I=I.replace(/<\/(blockquote|div)><\/(?:div|p)>/g,"</$1>");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(/^\[tt\]([\s\S]+)\[\/tt\]/,(function(J,L){var K=L.split("\n");L="";for(var O=0,N=K.length;O<N;O++){var M=K[O];if(M.length){if(L.length){L+="</p><p>"}L+="[tt]"+M+"[/tt]"}else{if(O===0||(O+1)===N){continue}if(L.match(/\[\/tt\]$/)){L+="</p><p>"+this.opts.invisibleSpace+""}else{L+="</p><p><br>"}}}return L}).bind(this));i=i.replace(/^\[code([^\]]*)\]([\S\s]*)\[\/code\]$/,(function(M,U,O){var N="plain";var S=0;var Q="";if(U){U=U.substring(1);U=U.split(",");var P=function(W){return W.match(/^\d+$/)};var L=function(W){return(W.indexOf(".")!==-1)||(W.match(/^(["']).*\1$/))};var K=function(W){return(__REDACTOR_CODE_HIGHLIGHTERS[W]!==undefined)};var J=function(W){return W.replace(/^(["'])(.*)\1$/,"$2")};switch(U.length){case 1:if(P(U[0])){S=(parseInt(U[0])>1)?U[0]:0}else{if(L(U[0])){Q=J(U[0])}else{if(K(U[0])){N=U[0]}}}break;case 2:if(P(U[0])){S=(parseInt(U[0])>1)?U[0]:0;if(K(U[1])){N=U[1]}else{if(L(U[1])){Q=J(U[1])}}}else{if(K(U[0])){N=U[0]}if(L(U[1])){Q=J(U[1])}}break;case 3:if(K(U[0])){N=U[0]}if(P(U[1])){S=U[1]}if(L(U[2])){Q=J(U[2])}break}}O=O.replace(/^\n+/,"").replace(/\n+$/,"").split(/\n/);var V="";for(var T=0;T<O.length;T++){var R=O[T];if(!R.length){R=this.opts.invisibleSpace}V+="<li>"+R+"</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="'+(S>1?S:1)+'">'+V+"</ol></div></div>"}).bind(this));I=I.replace(z,i)}}WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertToHtml",{data:I});return I},_expandFormatting:function(e,c,f){if(!e.length){return c+this.opts.invisibleSpace+f}var b=e.indexOf("[/td]");if(b!==-1){var d=e.substring(0,b);if(d.indexOf("[td]")===-1){return c+d+f+e.substring(b)}}var d=e.split("\n");e="";for(var i=0,h=d.length;i<h;i++){var g=d[i];if(g.length===0){g=this.opts.invisibleSpace}if(e.length){e+="\n"}e+=c+g+f}return e},_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(/<o:p>&nbsp;<\/o:p>/g,"<br>");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>");b=b.replace(/<(?:div|p|span)[^>]+>/gi,function(d){return d.replace(/ class="[^"]+"/,"")});b=b.replace(/<\/?wbr[^>]*>/g,"");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforePaste",{html:b});return b},_pasteCallback:function(b){b=b.replace(/\[size=(\d+)\]/g,'<p><span style="font-size: $1pt">');b=b.replace(/\[\/size\]/g,"</span></p>");b=b.replace(/style="([^"]+)"/,function(c,e){var d=e.split(";");var g=[];for(var i=0,f=d.length;i<f;i++){var h=d[i];if(!h.match(/^\s*background-color/)){g.push(h)}}return'style="'+g.join(";")+'"'});WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterPaste",{html:b});return b;b=b.replace(/<img([^>]+)>/g,function(c,d){c=c.replace(/data-mozilla-paste-image="0"/,'data-mozilla-paste-image="0" style="display:none"');return c});return b},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(x){switch(x.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 p=this.selection.getCurrent();var n=this.selection.getParent();n=(n)?$(n):n;var j=(n)?n.closest("blockquote.quoteBox",this.$editor.get()[0]):{length:0};switch(x.event.which){case $.ui.keyCode.BACKSPACE:if(this.wutil.isCaret()){var h=false;if(j.length){var k=true;for(var b=0;b<j[0].children.length;b++){var w=j[0].children[b];if(w.tagName==="DIV"){if(w.textContent.replace(/\u200b/,"").length){k=false;break}}}if(k){h=true}else{var m=(this.selection.implicitRange===null)?this.range:this.selection.implicitRange;if(m.startOffset===0){var d=m.startContainer,o;while((d=d.parentNode)!==null){o=d.previousSibling;if(o!==null){if(o.nodeType===Node.ELEMENT_NODE&&o.nodeName==="HEADER"){h=true}break}}}}}else{var f=(this.selection.implicitRange===null)?this.range:this.selection.implicitRange;var q=f.startContainer;if(q.nodeType===Node.TEXT_NODE){if(f.startOffset===0||(f.startOffset===1&&q.textContent==="\u200b")){if(!q.previousSibling){q=q.parentElement}}}if(q.nodeType===Node.ELEMENT_NODE){var i=q.previousSibling;if(i&&i.nodeType===Node.ELEMENT_NODE&&i.tagName==="BLOCKQUOTE"){j=i;h=true}}}if(h){var t=window.getSelection();if(t.rangeCount){t.removeAllRanges()}var r=document.createRange();r.selectNode(j[0]||j);t.addRange(r);x.cancel=true}}break;case $.ui.keyCode.DELETE:if(this.wutil.isCaret()&&this.wutil.isEndOfElement(p)){var v=p.nextElementSibling;if(v&&v.tagName==="BLOCKQUOTE"){var t=window.getSelection();if(t.rangeCount){t.removeAllRanges()}var r=document.createRange();r.selectNode(v);t.addRange(r);x.cancel=true}}break;case $.ui.keyCode.DOWN:var e=$(p);if(e.next("blockquote").length){this.caret.setStart(e.next().children("div:first"));x.cancel=true}else{if(n){if(n.next("blockquote").length){this.caret.setStart(n.next().children("div:first"));x.cancel=true}else{if(j.length){var s=e.closest("div",j[0]);if(!s.next().length){if(j.next().length){this.caret.setStart(j.next())}else{this.wutil.setCaretAfter(j)}x.cancel=true}}}}}break;case $.ui.keyCode.ENTER:if(j.length){this.keydown.blockquote=false;this.keydown.enterWithinBlockquote=true}break;case $.ui.keyCode.UP:if(!n||!j.length){return}var s=$(p).closest("div",j[0]);var u=s.prev();if(u[0].tagName==="DIV"){return}else{if(u[0].tagName==="BLOCKQUOTE"){return}}var l=j.prev();if(l.length===0){this.wutil.setCaretBefore(j)}else{if(l[0].tagName==="BLOCKQUOTE"){this.caret.sendEnd(l.children("div:last"))}else{if($.trim(l.html())==""){l.html(this.opts.invisibleSpace)}this.caret.setEnd(l)}}x.cancel=true;break;case 83:if($.browser.mobile){return}var c=false;if(navigator.platform.match(/^Mac/)){if(x.event.ctrlKey&&x.event.altKey){c=true}}else{if(x.event.altKey&&!x.event.ctrlKey){c=true}}if(c){var g={cancel:false};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","submitEditor_"+this.$textarea.wcfIdentify(),g);if(g.cancel){x.cancel=true}}break}},_keyupCallback:function(d){switch(d.event.which){case $.ui.keyCode.BACKSPACE:case $.ui.keyCode.DELETE:this.$editor.find("blockquote").each(function(h,j){var i=$(j);if(!i.children("header").length){i.remove()}});break;case $.ui.keyCode.ENTER:for(var g=0,f=this.$editor[0].children.length;g<f;g++){var c=this.$editor[0].children[g];if(c.nodeType!==Node.ELEMENT_NODE||c.tagName!=="P"){continue}if(c.textContent.length>0){continue}if(c.children.length>1||c.children[0].tagName==="BR"){continue}c=c.children[0];while(c.children.length===1){c=c.children[0]}if(c.children.length===0&&c.tagName==="BR"){var e=c.parentNode;var b=document.createTextNode("\u200b");e.appendChild(b);e.removeChild(c)}}break}},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("> header > h3").empty().append(this.wbbcode._buildQuoteHeader(d,b))},insertQuoteBBCode:function(g,l,i,j){var k="[quote]";var c="[/quote]";if(g){if(l){k="[quote='"+g+"','"+l+"']"}else{k="[quote='"+g+"']"}}var p=null;if(this.wutil.inWysiwygMode()){var o=WCF.getUUID();var e="";if(j){e=this.wbbcode.convertToHtml(k+j+c)}else{e=this.wbbcode.convertToHtml(k+o+c);e=e.replace(o,i.replace(/^<p>/,"").replace(/<\/p>$/,""))}e=e.replace(/^<p>/,"").replace(/<\/p>$/,"");e=e.replace(/<blockquote/,'<blockquote id="'+o+'"');if(!window.getSelection().rangeCount){this.wutil.restoreSelection();if(!window.getSelection().rangeCount){this.$editor.focus();if(!window.getSelection().rangeCount){this.wutil.selectionEndOfEditor()}this.wutil.saveSelection()}}window.getSelection().getRangeAt(0).deleteContents();this.wutil.restoreSelection();var h=window.getSelection().getRangeAt(0);var b=h.startContainer;while(b){var f=b.parentNode;if(f===this.$editor[0]){break}b=f}if(b&&b.parentNode===this.$editor[0]){if(b.innerHTML.length){if(b.innerHTML==="\u200b"){this.caret.setEnd(b)}else{this.wutil.setCaretAfter(b)}}}this.insert.html(e,false);p=this.$editor.find("#"+o);if(p.length){var n=p.find("> div");if(n.length==1){if(n[0].innerHTML===""){n[0].innerHTML=this.opts.invisibleSpace}}else{if($.browser.mozilla){var m=p.find("> div > br[type=_moz]");if(m.length){$("<div>"+this.opts.invisibleSpace+"</div>").insertBefore(m);m.remove()}}}p.removeAttr("id");this.wutil.setCaretAfter(p[0]);var d=p[0].previousElementSibling;if(d!==null&&d.nodeName==="P"&&d.innerHTML==="\u200B"){d=d.previousElementSibling;if(d!==null&&d.nodeName==="P"&&(d.innerHTML==="\u200B"||d.innerHTML==="<br>")){d.parentNode.removeChild(d.nextElementSibling)}}}this.wbbcode.observeQuotes();this.wbbcode.fixBlockLevelElements();this.$toolbar.find("a.re-__wcf_quote").removeClass("redactor-button-disabled")}else{this.wutil.insertAtCaret(k+j+c)}this.wutil.saveSelection();return p},_buildQuoteHeader:function(c,d){var b="";if(!c&&d){c=d;d=""}if(c){if(d){b+='<a href="'+d+'" tabindex="-1">'}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+"'":"")+"]";if(r.match(/\[code=([^,]+),(\d+)\]/)){r="[code="+RegExp.$2+","+RegExp.$1+"]"}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().replace(/^\u200b$/,"")+"\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(){var b=(function(e,c){var d=e[c];if(d&&d.nodeType===Node.ELEMENT_NODE&&d.tagName==="P"){if(!d.innerHTML.length){d.parentElement.removeChild(d)}}}).bind(this);this.$editor.find("blockquote, .codeBox").each(function(){b(this,"previousElementSibling");b(this,"nextElementSibling")})},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 i=0,f=__REDACTOR_BUTTONS.length;i<f;i++){this.wbutton._addBBCodeButton(__REDACTOR_BUTTONS[i])}var d={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 e={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 c=this.wutil.getOption("buttons");var g="";for(var i=0,f=c.length;i<f;i++){var a=c[i];if(a=="separator"){this.button.get(g).parent().addClass("separator");continue}var h=this.button.get(a);if(h.length){if(d[a]){this.button.setAwesome(a,d[a])}if(a==="table"&&g){h.parent().insertAfter(this.button.get(g).parent())}}else{this.wbutton._addCoreButton(a,(e[a]?e[a]:null),(d[a]?d[a]:null),g)}g=a}this.button.addCallback(this.button.get("image"),$.proxy(this.wbutton.insertImage,this));if(this.utils.isDesktop()){var b=this.button.addAfter("html","undo",WCF.Language.get("wcf.bbcode.button.undo"));var j=this.button.addAfter("undo","redo",WCF.Language.get("wcf.bbcode.button.redo"));this.button.addCallback(b,this.buffer.undo);this.button.addCallback(j,this.buffer.redo);j.parent().addClass("separator")}},_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();c=c.replace(/<p>@@@wcf_empty_line@@@<\/p>/g,"<p><br></p>");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
index 01cbaf95a2039920253018dc94aa126c1670ad4b..3932fdcb237fc6d3569196a522389bf130821483 100755 (executable)
@@ -106,7 +106,7 @@ window.matchMedia||(window.matchMedia=function(){var c=window.styleMedia||window
 (function (window, undefined) {"use strict";WCF.Location={};WCF.Location.Util={getLocation:function(c,a){var b=WCF.Location.GoogleMaps.Settings.get("accessUserLocation");if(navigator.geolocation&&b!==null&&b){navigator.geolocation.getCurrentPosition(function(d){c(d.coords.latitude,d.coords.longitude)},function(){c(undefined,undefined)},{timeout:a||5000})}else{c(undefined,undefined)}}};WCF.Location.GoogleMaps={};WCF.Location.GoogleMaps.Settings={_settings:{},get:function(a){if(a===undefined){return this._settings}if(this._settings[a]!==undefined){return this._settings[a]}return null},set:function(b,c){if($.isPlainObject(b)){for(var a in b){this._settings[a]=b[a]}}else{this._settings[b]=c}}};WCF.Location.GoogleMaps.Map=Class.extend({_map:null,_markers:[],init:function(b,a){this._mapContainer=$("#"+b);this._mapOptions=$.extend(true,this._getDefaultMapOptions(),a);this._map=new google.maps.Map(this._mapContainer[0],this._mapOptions);this._markers=[];if(this._mapContainer.parents(".sidebar").length){enquire.register("screen and (max-width: 800px)",{setup:$.proxy(this._addSidebarMapListener,this),deferSetup:true})}this.refresh()},_addInfoWindowEventListener:function(a,b){google.maps.event.addListener(a,"click",$.proxy(function(){b.open(this._map,a)},this))},_addSidebarMapListener:function(){$(".content > .mobileSidebarToggleButton").click($.proxy(this.refresh,this))},_getDefaultMapOptions:function(){var a={};a.center=new google.maps.LatLng(WCF.Location.GoogleMaps.Settings.get("defaultLatitude"),WCF.Location.GoogleMaps.Settings.get("defaultLongitude"));a.disableDoubleClickZoom=WCF.Location.GoogleMaps.Settings.get("disableDoubleClickZoom");a.draggable=WCF.Location.GoogleMaps.Settings.get("draggable");switch(WCF.Location.GoogleMaps.Settings.get("mapType")){case"map":a.mapTypeId=google.maps.MapTypeId.ROADMAP;break;case"satellite":a.mapTypeId=google.maps.MapTypeId.SATELLITE;break;case"physical":a.mapTypeId=google.maps.MapTypeId.TERRAIN;break;case"hybrid":default:a.mapTypeId=google.maps.MapTypeId.HYBRID;break}a.mapTypeControl=WCF.Location.GoogleMaps.Settings.get("mapTypeControl")!="off";if(a.mapTypeControl){switch(WCF.Location.GoogleMaps.Settings.get("mapTypeControl")){case"dropdown":a.mapTypeControlOptions={style:google.maps.MapTypeControlStyle.DROPDOWN_MENU};break;case"horizontalBar":a.mapTypeControlOptions={style:google.maps.MapTypeControlStyle.HORIZONTAL_BAR};break;default:a.mapTypeControlOptions={style:google.maps.MapTypeControlStyle.DEFAULT};break}}a.scaleControl=WCF.Location.GoogleMaps.Settings.get("scaleControl");a.scrollwheel=WCF.Location.GoogleMaps.Settings.get("scrollwheel");a.zoom=WCF.Location.GoogleMaps.Settings.get("zoom");return a},addDraggableMarker:function(c,b){var a=new google.maps.Marker({clickable:false,draggable:true,map:this._map,position:new google.maps.LatLng(c,b),zIndex:1});this._markers.push(a);return a},addMarker:function(g,e,f,d,c){var b=new google.maps.Marker({map:this._map,position:new google.maps.LatLng(g,e),title:f});if(d){b.setIcon(d)}if(c){var a=new google.maps.InfoWindow({content:c});this._addInfoWindowEventListener(b,a);b.infoWindow=a}this._markers.push(b);return b},getMarkers:function(){return this._markers},getMap:function(){return this._map},refresh:function(){var a=this._map.getCenter();google.maps.event.trigger(this._map,"resize");this._map.setCenter(a)},refreshBounds:function(){var f=null;var c=null;var d=null;var g=null;for(var a in this._markers){var e=this._markers[a];var h=e.getPosition().lat();var b=e.getPosition().lng();if(f===null){f=c=h;d=g=b}else{if(f>h){f=h}else{if(c<h){c=h}}if(d>h){d=h}else{if(g<b){g=b}}}}this._map.fitBounds(new google.maps.LatLngBounds(new google.maps.LatLng(f,d),new google.maps.LatLng(c,g)))},removeMarkers:function(){for(var a in this._markers){this._markers[a].setMap(null)}this._markers=[]},setBounds:function(a,b){this._map.fitBounds(new google.maps.LatLngBounds(new google.maps.LatLng(b.latitude,b.longitude),new google.maps.LatLng(a.latitude,a.longitude)))},setCenter:function(b,a){this._map.setCenter(new google.maps.LatLng(b,a))}});WCF.Location.GoogleMaps.LargeMap=WCF.Location.GoogleMaps.Map.extend({_actionClassName:null,_additionalParameters:{},_locationSearch:null,_locationSearchInputSelector:null,_markerClusterer:null,_objectIDs:[],_previousNorthEast:null,_previousSouthWest:null,init:function(e,b,d,c,a){this._super(e,b);this._actionClassName=d;this._locationSearchInputSelector=c||"";this._additionalParameters=a||{};this._objectIDs=[];if(this._locationSearchInputSelector){this._locationSearch=new WCF.Location.GoogleMaps.LocationSearch(c,$.proxy(this._centerMap,this))}this._markerClusterer=new MarkerClusterer(this._map,this._markers,{maxZoom:17,imagePath:"//google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/images/m"});this._markerSpiderfier=new OverlappingMarkerSpiderfier(this._map,{keepSpiderfied:true,markersWontHide:true,markersWontMove:true});this._markerSpiderfier.addListener("click",$.proxy(function(f){if(f.infoWindow){f.infoWindow.open(this._map,f)}},this));this._proxy=new WCF.Action.Proxy({showLoadingOverlay:false,success:$.proxy(this._success,this)});this._previousNorthEast=null;this._previousSouthWest=null;google.maps.event.addListener(this._map,"idle",$.proxy(this._loadMarkers,this))},_addInfoWindowEventListener:function(a,b){},_centerMap:function(a){this.setCenter(a.location.lat(),a.location.lng());$(this._locationSearchInputSelector).val(a.label)},_loadMarkers:function(){var a=this._map.getBounds().getNorthEast();var b=this._map.getBounds().getSouthWest();if(this._previousNorthEast&&this._previousNorthEast.lat()>=a.lat()&&this._previousNorthEast.lng()>=a.lng()&&this._previousSouthWest.lat()<=b.lat()&&this._previousSouthWest.lng()<=b.lng()){return false}this._previousNorthEast=a;this._previousSouthWest=b;this._proxy.setOption("data",{actionName:"getMapMarkers",className:this._actionClassName,parameters:$.extend(this._additionalParameters,{excludedObjectIDs:this._objectIDs,eastLongitude:a.lng(),northLatitude:a.lat(),southLatitude:b.lat(),westLongitude:b.lng()})});this._proxy.sendRequest();return true},_success:function(d,e,c){if(d.returnValues&&d.returnValues.markers){for(var a in d.returnValues.markers){var b=d.returnValues.markers[a];this.addMarker(b.latitude,b.longitude,b.title,null,b.infoWindow);if(b.objectID){this._objectIDs.push(b.objectID)}else{if(b.objectIDs){this._objectIDs=this._objectIDs.concat(b.objectIDs)}}}}},addMarker:function(f,d,e,c,b){var a=this._super(f,d,e,c,b);this._markerClusterer.addMarker(a);this._markerSpiderfier.addMarker(a);return a}});WCF.Location.GoogleMaps.SuggestionMap=WCF.Location.GoogleMaps.LargeMap.extend({_locationSuggestionsButton:null,_suggestionSelectionCallback:null,init:function(f,c,e,d,a){this._super(f,c,e,d,a);var b=$('<div class="gmnoprint googleMapsCustomControlContainer"><div class="gm-style-mtc"><div class="googleMapsCustomControl">'+WCF.Language.get("wcf.map.showLocationSuggestions")+"</div></div></div>");this._locationSuggestionsButton=b.find(".googleMapsCustomControl").click($.proxy(this._toggleLocationSuggestions,this));this._map.controls[google.maps.ControlPosition.TOP_RIGHT].push(b.get(0))},_loadMarkers:function(){if(!this._locationSuggestionsButton.hasClass("active")){return}if(!this._super()){this._loadSuggestions=false}},_success:function(c,d,b){var a=this._markers.length;this._super(c,d,b);if(this._loadSuggestions&&a==this._markers.length){this._loadSuggestions=false;new WCF.System.Notification(WCF.Language.get("wcf.map.noLocationSuggestions"),"info").show()}},_toggleLocationSuggestions:function(){var a=!this._locationSuggestionsButton.hasClass("active");if(a){this._loadSuggestions=true}this.showSuggestions(a)},addMarker:function(h,f,g,e,d){var a=$(d);var c=$('<a class="googleMapsUseLocationSuggestionLink" />').text(WCF.Language.get("wcf.map.useLocationSuggestion")).click(this._suggestionSelectionCallback);a.append($('<p class="marginTopTiny" />').append(c));var b=this._super(h,f,g,"//mt.google.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png",a.get(0));c.data("marker",b);return b},setSuggestionSelectionCallback:function(a){this._suggestionSelectionCallback=a},showSuggestions:function(c){if(c===undefined){c=true}this._locationSuggestionsButton.toggleClass("active",c);var b=[];for(var e=0,d=this._markers.length;e<d;e++){var a=this._markers[e];if(!a.draggable){a.setVisible(c);if(c){b.push(a)}}}this._markerClusterer.clearMarkers();if(c){this._markerClusterer.addMarkers(b)}this._loadMarkers()}});WCF.Location.GoogleMaps.LocationSearch=WCF.Search.Base.extend({_geocoder:null,init:function(b,e,a,c,d){this._super(b,e,a,c,d);this.setDelay(500);this._geocoder=new google.maps.Geocoder()},_createListItem:function(b){var a=$("<li><span>"+WCF.String.escapeHTML(b.formatted_address)+"</span></li>").appendTo(this._list);a.data("location",b.geometry.location).data("label",b.formatted_address).click($.proxy(this._executeCallback,this));this._itemCount++;return a},_keyUp:function(b){switch(b.which){case $.ui.keyCode.LEFT:case $.ui.keyCode.RIGHT:return;break;case $.ui.keyCode.UP:this._selectPreviousItem();return;break;case $.ui.keyCode.DOWN:this._selectNextItem();return;break;case $.ui.keyCode.ENTER:return this._selectElement(b);break}var a=this._getSearchString(b);if(a===""){this._clearList(true)}else{if(a.length>=this._triggerLength){if(this._delay){if(this._timer!==null){this._timer.stop()}this._timer=new WCF.PeriodicalExecuter($.proxy(function(){this._geocoder.geocode({address:a},$.proxy(this._success,this));this._timer.stop();this._timer=null},this),this._delay)}else{this._geocoder.geocode({address:a},$.proxy(this._success,this))}}else{this._clearList(false)}}},_success:function(d,b){this._clearList(false);if(b!=google.maps.GeocoderStatus.OK){return}if($.getLength(d)){var c=0;for(var a in d){this._createListItem(d[a]);if(++c==10){break}}}else{if(!this._handleEmptyResult()){return}}WCF.CloseOverlayHandler.addCallback("WCF.Search.Base",$.proxy(function(){this._clearList()},this));var e=this._searchInput.parents(".dropdown").wcfIdentify();if(!WCF.Dropdown.getDropdownMenu(e).hasClass("dropdownOpen")){WCF.Dropdown.toggleDropdown(e)}this._itemIndex=-1;if(!WCF.Dropdown.getDropdown(e).data("disableAutoFocus")){this._selectNextItem()}}});WCF.Location.GoogleMaps.LocationInput=Class.extend({_locationSearch:null,_map:null,_marker:null,init:function(e,b,a,f,d,c){this._searchInput=a;if(c){this._map=new WCF.Location.GoogleMaps.SuggestionMap(e,b,c);this._map.setSuggestionSelectionCallback($.proxy(this._useSuggestion,this))}else{this._map=new WCF.Location.GoogleMaps.Map(e,b)}this._locationSearch=new WCF.Location.GoogleMaps.LocationSearch(a,$.proxy(this._setMarkerByLocation,this));if(f&&d){this._marker=this._map.addDraggableMarker(f,d)}else{this._marker=this._map.addDraggableMarker(WCF.Location.GoogleMaps.Settings.get("defaultLatitude"),WCF.Location.GoogleMaps.Settings.get("defaultLongitude"));WCF.Location.Util.getLocation($.proxy(function(h,g){if(h!==undefined&&g!==undefined){WCF.Location.GoogleMaps.Util.moveMarker(this._marker,h,g);WCF.Location.GoogleMaps.Util.focusMarker(this._marker)}},this))}this._marker.addListener("dragend",$.proxy(this._updateLocation,this))},_useSuggestion:function(b){var a=$(b.currentTarget).data("marker");this._marker.setPosition(a.getPosition());this._updateLocation();this._map.showSuggestions(false)},_updateLocation:function(){WCF.Location.GoogleMaps.Util.reverseGeocoding($.proxy(function(a){if(a!==null){$(this._searchInput).val(a)}},this),this._marker)},_setMarkerByLocation:function(a){this._marker.setPosition(a.location);WCF.Location.GoogleMaps.Util.focusMarker(this._marker);$(this._searchInput).val(a.label)},getMap:function(){return this._map},getMarker:function(){return this._marker}});WCF.Location.GoogleMaps.Util={_geocoder:null,focusMarker:function(a){a.getMap().setCenter(a.getPosition())},getMarkerPosition:function(a){return{latitude:a.getPosition().lat(),longitude:a.getPosition().lng()}},moveMarker:function(a,d,b,c){a.setPosition(new google.maps.LatLng(d,b));if(c){google.maps.event.trigger(a,"dragend")}},reverseGeocoding:function(f,a,e,c,b){if(a){e=a.getPosition().lat();c=a.getPosition().lng()}if(this._geocoder===null){this._geocoder=new google.maps.Geocoder()}var d=new google.maps.LatLng(e,c);this._geocoder.geocode({latLng:d},function(h,g){if(g==google.maps.GeocoderStatus.OK){f((b?h:h[0].formatted_address))}else{f(null)}})}}; })(this);
 
 // WCF.Message.js
-(function (window, undefined) {"use strict";WCF.Message={};WCF.Message.BBCode={};WCF.Message.BBCode.CodeViewer=Class.extend({_dialog:null,init:function(){this._dialog=null;this._initCodeBoxes();WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.BBCode.CodeViewer",$.proxy(this._initCodeBoxes,this));WCF.DOMNodeInsertedHandler.execute()},_initCodeBoxes:function(){$(".codeBox:not(.jsCodeViewer)").each($.proxy(function(a,c){var b=$(c).addClass("jsCodeViewer");$('<span class="icon icon16 icon-copy pointer jsTooltip" title="'+WCF.Language.get("wcf.message.bbcode.code.copy")+'" />').appendTo(b.find("div > h3")).click($.proxy(this._click,this))},this))},_click:function(b){var a="";$(b.currentTarget).parents("div").next("ol").children("li").each(function(c,d){if(a){a+="\n"}a+=$(d).text().replace(/\n+$/,"")});if(this._dialog===null){this._dialog=$('<div><textarea cols="60" rows="12" readonly="readonly" /></div>').hide().appendTo(document.body);this._dialog.children("textarea").val(a);this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.bbcode.code.copy")})}else{this._dialog.children("textarea").val(a);this._dialog.wcfDialog("open")}this._dialog.children("textarea").select()}});WCF.Message.EditHistory=Class.extend({_oldIDInputs:null,_newIDInputs:null,_containerSelector:"",_buttonSelector:".jsRevertButton",init:function(c,b,a,d){this._oldIDInputs=c;this._newIDInputs=b;this._containerSelector=a;this._buttonSelector=(d)?d:".jsRevertButton";this.proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._initInputs();this._initElements()},_initInputs:function(){var a=this;this._newIDInputs.change(function(c){var b=parseInt($(this).val());if($(this).val()==="current"){b=Infinity}a._oldIDInputs.each(function(d){var e=parseInt($(this).val());if($(this).val()==="current"){e=Infinity}if(e>=b){$(this).disable()}else{$(this).enable()}})});this._oldIDInputs.change(function(b){var c=parseInt($(this).val());if($(this).val()==="current"){c=Infinity}a._newIDInputs.each(function(e){var d=parseInt($(this).val());if($(this).val()==="current"){d=Infinity}if(d<=c){$(this).disable()}else{$(this).enable()}})});this._oldIDInputs.filter(":checked").change();this._newIDInputs.filter(":checked").change()},_initElements:function(){var a=this;$(this._containerSelector).each(function(c,b){var d=$(b);d.find(a._buttonSelector).click($.proxy(a._click,a))})},_click:function(c){var a=$(c.currentTarget);c.preventDefault();if(a.data("confirmMessage")){var b=this;WCF.System.Confirmation.show(a.data("confirmMessage"),function(d){if(d==="cancel"){return}b._sendRequest(a)})}else{this._sendRequest(a)}},_sendRequest:function(a){this.proxy.setOption("data",{actionName:"revert",className:"wcf\\data\\edit\\history\\entry\\EditHistoryEntryAction",objectIDs:[$(a).data("objectID")]});this.proxy.sendRequest()},_success:function(b,c,a){window.location.reload(true)}});WCF.Message.FormGuard=Class.extend({init:function(){var a=$("form.jsFormGuard").removeClass("jsFormGuard").submit(function(){$(this).find(".formSubmit input[type=submit]").disable()});$(window).unload(function(){a.find(".formSubmit input[type=submit]").enable()})}});WCF.Message.Preview=Class.extend({_className:"",_messageFieldID:"",_messageField:null,_proxy:null,_previewButton:null,_previewButtonLabel:"",init:function(b,a,c){this._className=b;this._messageFieldID=$.wcfEscapeID(a);this._messageField=$("#"+this._messageFieldID);if(!this._messageField.length){console.debug("[WCF.Message.Preview] Unable to find message field identified by '"+this._messageFieldID+"'");return}c=$.wcfEscapeID(c);this._previewButton=$("#"+c);if(!this._previewButton.length){console.debug("[WCF.Message.Preview] Unable to find preview button identified by '"+c+"'");return}this._previewButton.click($.proxy(this._click,this));this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),success:$.proxy(this._success,this)})},_click:function(b){var a=this._getMessage();if(a===null){console.debug("[WCF.Message.Preview] Unable to access Redactor instance of '"+this._messageFieldID+"'");return}this._proxy.setOption("data",{actionName:"getMessagePreview",className:this._className,parameters:this._getParameters(a)});this._proxy.sendRequest();this._previewButtonLabel=this._previewButton.html();this._previewButton.html(WCF.Language.get("wcf.global.loading")).disable();b.stopPropagation();return false},_getParameters:function(b){var a={};$("#settings_"+this._messageFieldID).find("input[type=checkbox]").each(function(c,e){var d=$(e);if(d.is(":checked")){a[d.prop("name")]=d.prop("value")}});return{data:{message:b},options:a}},_getMessage:function(){if(!$.browser.redactor){return $.trim(this._messageField.val())}else{if(this._messageField.data("redactor")){return this._messageField.redactor("wutil.getText")}}return null},_success:function(b,c,a){this._previewButton.html(this._previewButtonLabel).enable();this._messageField.parent().children("small.innerError").remove();this._handleResponse(b)},_handleResponse:function(a){},_failure:function(a){if(a===null||a.returnValues===undefined||a.returnValues.errorType===undefined){return true}this._previewButton.html(this._previewButtonLabel).enable();var b=this._messageField.next("small.innerError").empty();if(!b.length){b=$('<small class="innerError" />').appendTo(this._messageField.parent())}b.html(a.returnValues.errorType);return false}});WCF.Message.DefaultPreview=WCF.Message.Preview.extend({_attachmentObjectType:null,_attachmentObjectID:null,_tmpHash:null,init:function(b,a,c){this._super("wcf\\data\\bbcode\\MessagePreviewAction","text","previewButton");this._attachmentObjectType=b||null;this._attachmentObjectID=a||null;this._tmpHash=c||null},_handleResponse:function(b){var a=$("#previewContainer");if(!a.length){a=$('<div class="container containerPadding marginTop" id="previewContainer"><fieldset><legend>'+WCF.Language.get("wcf.global.preview")+'</legend><div class="messageTextPreview"></div></fieldset>').prependTo($("#messageContainer")).wcfFadeIn()}a.find("div:eq(0)").html(b.returnValues.message);new WCF.Effect.Scroll().scrollTo(a)},_getParameters:function(b){var a=this._super(b);if(this._attachmentObjectType!=null){a.attachmentObjectType=this._attachmentObjectType;a.attachmentObjectID=this._attachmentObjectID;a.tmpHash=this._tmpHash}return a}});WCF.Message.Multilingualism=Class.extend({_availableLanguages:{},_languageID:0,_languageInput:null,init:function(c,d,a){this._availableLanguages=d;this._languageID=c||0;this._languageInput=$("#languageID");this._updateLabel();this._languageInput.find(".dropdownMenu > li").click($.proxy(this._click,this));if(!a){var b=this._languageInput.find(".dropdownMenu");$('<li class="dropdownDivider" />').appendTo(b);$('<li><span><span class="badge">'+this._availableLanguages[0]+"</span></span></li>").click($.proxy(this._disable,this)).appendTo(b)}this._languageInput.parents("form").submit($.proxy(this._submit,this))},_click:function(a){this._languageID=$(a.currentTarget).data("languageID");this._updateLabel()},_disable:function(){this._languageID=0;this._updateLabel()},_updateLabel:function(){this._languageInput.find(".dropdownToggle > span").text(this._availableLanguages[this._languageID])},_submit:function(){this._languageInput.next("input[name=languageID]").prop("value",this._languageID)}});WCF.Message.SmileyCategories=Class.extend({_cache:[],_proxy:null,_wysiwygSelector:"",init:function(a){this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._wysiwygSelector=a;$("#smilies-"+this._wysiwygSelector).on("messagetabmenushow",$.proxy(this._click,this))},_click:function(b,c){var a=parseInt(c.activeTab.tab.data("smileyCategoryID"));if(!a){return}if(c.activeTab.container.children("ul.smileyList").length){return}if(this._cache[a]!==undefined){c.activeTab.container.html(this._cache[a])}this._proxy.setOption("data",{actionName:"getSmilies",className:"wcf\\data\\smiley\\category\\SmileyCategoryAction",objectIDs:[a]});this._proxy.sendRequest()},_success:function(c,d,b){var a=parseInt(c.returnValues.smileyCategoryID);this._cache[a]=c.returnValues.template;$("#smilies-"+this._wysiwygSelector+"-"+a).html(c.returnValues.template)}});WCF.Message.Smilies=Class.extend({_redactor:null,_wysiwygSelector:"",init:function(a){this._wysiwygSelector=a;WCF.System.Dependency.Manager.register("Redactor_"+this._wysiwygSelector,$.proxy(function(){this._redactor=$("#"+this._wysiwygSelector).redactor("core.getObject");$(".messageTabMenu[data-wysiwyg-container-id="+this._wysiwygSelector+"]").on("click",".jsSmiley",$.proxy(this._smileyClick,this))},this))},_smileyClick:function(d){var b=$(d.currentTarget);var a=b.data("smileyCode");var c=b.data("smileyPath");this._redactor.wbbcode.insertSmiley(a,c,true)}});WCF.Message.QuickReply=Class.extend({_container:null,_messageField:null,_notification:null,_pendingSave:false,_proxy:null,_quickReplyButtons:null,_quoteManager:null,_scrollHandler:null,_successMessageNonVisible:"",init:function(d,b){this._container=$("#messageQuickReply");this._container.children(".message").addClass("jsInvalidQuoteTarget");this._messageField=$("#text");this._pendingSave=false;if(!this._container||!this._messageField){return}var a=this._container.find(".formSubmit");var c=a.find("button[data-type=save]").removeAttr("accesskey").click($.proxy(this._save,this));if(d){a.find("button[data-type=extended]").click($.proxy(this._prepareExtended,this))}a.find("button[data-type=cancel]").click($.proxy(this._cancel,this));if(b){this._quoteManager=b}this._quickReplyButtons=$(".jsQuickReply").data("__api",this).click($.proxy(this.click,this));this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),showLoadingOverlay:false,success:$.proxy(this._success,this)});this._scroll=new WCF.Effect.Scroll();this._notification=new WCF.System.Notification(WCF.Language.get("wcf.global.success.add"));this._successMessageNonVisible="";WCF.System.Event.addListener("com.woltlab.wcf.redactor","submitEditor_text",function(e){e.cancel=true;c.trigger("click")})},click:function(b){this._container.toggle();if(this._container.is(":visible")){this._quickReplyButtons.each(function(){var c=$(this);if(c.parent()[0].tagName==="LI"){c.parent().hide()}else{c.hide()}});setTimeout((function(){$(document).trigger("resize");if(!$.browser.mobile||!$.browser.chrome){this._scroll.scrollTo(this._container,true)}}).bind(this),100);WCF.Message.Submit.registerButton("text",this._container.find(".formSubmit button[data-type=save]"));if(this._quoteManager){var a=true;if($.browser.redactor){if(this._messageField.data("redactor")){this._editorCallback(this._messageField.redactor("wutil.isEmptyEditor"))}}else{a=(!this._messageField.val().length);this._editorCallback(a)}}}if(b!==null){b.stopPropagation();return false}},_editorCallback:function(a){if(a){this._quoteManager.insertQuotes(this._getClassName(),this._getObjectID(),$.proxy(this._insertQuotes,this))}if($.browser.redactor){this._messageField.redactor("wutil.selectionEndOfEditor")}else{this._messageField.focus()}},getContainer:function(){return this._container},_insertQuotes:function(b){if(!b.returnValues.template){return}if($.browser.redactor){var a=WCF.String.unescapeHTML(b.returnValues.template);a=this._messageField.redactor("wbbcode.convertToHtml",a);a=a.replace(/<p><blockquote/,"<blockquote");a=a.replace(/blockquote><\/p>/,"blockquote>");this._messageField.redactor("focus.setEnd");this._messageField.redactor("wutil.insertDynamic",a,b.returnValues.template);this._messageField.redactor("wutil.selectionEndOfEditor");this._messageField.redactor("wbbcode.observeQuotes")}else{this._messageField.val(b.returnValues.template)}},_save:function(){if(this._pendingSave){return}var a="";if($.browser.redactor){a=this._messageField.redactor("wutil.getText")}else{a=$.trim(this._messageField.val())}var d=this._messageField.parent().find("small.innerError");if(a===""||a==="0"){if(!d.length){d=$('<small class="innerError" />').appendTo(this._messageField.parent())}d.html(WCF.Language.get("wcf.global.form.error.empty"));return}else{d.remove()}this._pendingSave=true;this._proxy.setOption("data",{actionName:"quickReply",className:this._getClassName(),interfaceName:"wcf\\data\\IMessageQuickReplyAction",parameters:this._getParameters(a)});this._proxy.sendRequest();var b=this._container.find(".messageQuickReplyContent .messageBody");$('<span class="icon icon48 icon-spinner" />').appendTo(b);var c=b.children(".redactor-box").hide();c.next().hide();b.next().hide()},_getParameters:function(b){var a={objectID:this._getObjectID(),data:{message:b},lastPostTime:this._container.data("lastPostTime"),pageNo:this._container.data("pageNo"),removeQuoteIDs:(this._quoteManager===null?[]:this._quoteManager.getQuotesMarkedForRemoval())};if(this._container.data("anchor")){a.anchor=this._container.data("anchor")}WCF.System.Event.fireEvent("com.woltlab.wcf.messageOptionsInline","submit_"+this._messageField.wcfIdentify(),a.data);return a},_cancel:function(){this._revertQuickReply(true);if($.browser.redactor){this._messageField.redactor("wutil.reset")}else{this._messageField.val("")}},_revertQuickReply:function(b){var a=this._container.find(".messageQuickReplyContent .messageBody");if(b){this._container.hide();a.children("small.innerError").remove()}a.children(".icon-spinner").remove();a.children(".redactor-box").show().next().show();a.next().show();this._quickReplyButtons.each(function(){var c=$(this);if(c.parent()[0].tagName==="LI"){c.parent().show()}else{c.show()}})},_prepareExtended:function(){this._pendingSave=true;if(this._quoteManager!==null){this._quoteManager.markQuotesForRemoval()}var a="";if($.browser.redactor){a=this._messageField.redactor("wutil.getText");if(a.length){this._messageField.redactor("wutil.saveTextToStorage",true)}else{this._messageField.redactor("wutil.autosavePurge")}}else{a=$.trim(this._messageField.val())}var b={containerID:this._getObjectID(),message:a};WCF.System.Event.fireEvent("com.woltlab.wcf.messageOptionsInline","prepareExtended_"+this._messageField.wcfIdentify(),b);new WCF.Action.Proxy({autoSend:true,data:{actionName:"jumpToExtended",className:this._getClassName(),interfaceName:"wcf\\data\\IExtendedMessageQuickReplyAction",parameters:b},success:(function(c){this._messageField.redactor("wutil.saveTextToStorage");window.location=c.returnValues.url}).bind(this)})},_success:function(c,d,b){if($.browser.redactor){this._messageField.redactor("wutil.autosavePause");this._messageField.redactor("wutil.autosavePurge")}if(c.returnValues.url){window.location=c.returnValues.url}else{if(c.returnValues.template){var a=$(""+c.returnValues.template);if(this._container.data("sortOrder")=="DESC"){a.insertAfter(this._container)}else{a.insertBefore(this._container)}this._container.data("lastPostTime",c.returnValues.lastPostTime);this._notification.show(undefined,undefined,WCF.Language.get("wcf.global.success.add"));this._updateHistory(a.wcfIdentify())}else{var a=(this._successMessageNonVisible)?this._successMessageNonVisible:"wcf.global.success.add";this._notification.show(undefined,5000,WCF.Language.get(a))}if($.browser.redactor){this._messageField.redactor("wutil.reset");this._messageField.redactor("wutil.autosaveResume")}else{this._messageField.val("")}this._revertQuickReply(true);if(this._quoteManager!==null){this._quoteManager.countQuotes()}this._pendingSave=false}},_failure:function(b){this._pendingSave=false;this._revertQuickReply(false);if(b===null||b.returnValues===undefined||b.returnValues.errorType===undefined){return true}var a=this._container.find(".messageQuickReplyContent .messageBody");var c=a.children("small.innerError").empty();if(!c.length){c=$('<small class="innerError" />').appendTo(a)}c.html(b.returnValues.errorType);return false},_getClassName:function(){return""},_getObjectID:function(){return 0},_updateHistory:function(a){window.location.hash=a}});WCF.Message.InlineEditor=Class.extend({_activeElementID:"",_container:{},_containerID:0,_dropdowns:{},_messageContainerSelector:".jsMessage",_messageEditorIDPrefix:"messageEditor",_notification:null,_proxy:null,_quoteManager:null,_supportExtendedForm:false,init:function(a,c,b){this._activeElementID="";this._container={};this._containerID=parseInt(a);this._dropdowns={};this._quoteManager=b||null;this._supportExtendedForm=(c)?true:false;this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),showLoadingOverlay:false,success:$.proxy(this._success,this)});this._notification=new WCF.System.Notification(WCF.Language.get("wcf.global.success.edit"));this.initContainers();WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.InlineEditor",$.proxy(this.initContainers,this))},initContainers:function(){$(this._messageContainerSelector).each($.proxy(function(b,a){var e=$(a);var c=e.wcfIdentify();if(!this._container[c]){this._container[c]=e;if(e.data("canEditInline")){var d=e.find(".jsMessageEditButton:eq(0)").data("containerID",c).click($.proxy(this._clickInline,this));if(e.data("canEdit")){d.dblclick($.proxy(this._click,this))}}else{if(e.data("canEdit")){e.find(".jsMessageEditButton:eq(0)").data("containerID",c).click($.proxy(this._click,this))}}}},this))},_click:function(c,a){var b=(c===null)?a:$(c.currentTarget).data("containerID");if(this._activeElementID===""){this._activeElementID=b;this._prepare();this._proxy.setOption("data",{actionName:"beginEdit",className:this._getClassName(),interfaceName:"wcf\\data\\IMessageInlineEditorAction",parameters:{containerID:this._containerID,objectID:this._container[b].data("objectID")}});this._proxy.setOption("failure",$.proxy(function(){this._cancel()},this));this._proxy.sendRequest()}else{var d=new WCF.System.Notification(WCF.Language.get("wcf.message.error.editorAlreadyInUse"),"warning");d.show()}if(this._dropdowns[this._container[b].data("objectID")]){this._dropdowns[this._container[b].data("objectID")].removeClass("dropdownOpen")}if(c!==null){c.stopPropagation();return false}},_clickInline:function(c){var d=$(c.currentTarget);if(!d.hasClass("dropdownToggle")){var b=d.data("containerID");d.addClass("dropdownToggle").parent().addClass("dropdown");var a=$('<ul class="dropdownMenu" />').insertAfter(d);this._initDropdownMenu(b,a);WCF.DOMNodeInsertedHandler.execute();this._dropdowns[this._container[b].data("objectID")]=a;WCF.Dropdown.registerCallback(d.parent().wcfIdentify(),$.proxy(this._toggleDropdown,this));d.trigger("click")}c.stopPropagation();return false},_failure:function(b){this._revertEditor();if(b===null||b.returnValues===undefined||b.returnValues.errorType===undefined){return true}var a=this._container[this._activeElementID].find(".messageBody .messageInlineEditor");var c=a.children("small.innerError").empty();if(!c.length){c=$('<small class="innerError" />').insertBefore(a.children(".formSubmit"))}c.html(b.returnValues.errorType);return false},_toggleDropdown:function(a,b){WCF.Dropdown.getDropdown(a).parents(".messageOptions").toggleClass("forceOpen")},_initDropdownMenu:function(a,b){},_prepare:function(){var b=this._container[this._activeElementID].find(".messageBody");$('<span class="icon icon48 icon-spinner" />').appendTo(b);var a=b.find(".messageText").hide();a.parent().children(".jsInlineEditorHideContent").hide();b.children(".attachmentThumbnailList, .attachmentFileList").hide()},_cancel:function(){var b=this._container[this._activeElementID].removeClass("jsInvalidQuoteTarget");this._destroyEditor();var a=b.find(".messageBody");a.children(".icon-spinner").remove();a.find(".messageText").show();a.children(".attachmentThumbnailList, .attachmentFileList").show();a.find(".jsInlineEditorHideContent").show();this._container[this._activeElementID].find(".messageOptions").removeClass("forceHidden");this._activeElementID="";if(this._quoteManager){this._quoteManager.clearAlternativeEditor()}},_success:function(b,c,a){switch(b.returnValues.actionName){case"beginEdit":this._showEditor(b);break;case"save":this._showMessage(b);break}},_showEditor:function(g){this._proxy.setOption("failure",$.proxy(this._failure,this));var e=this._messageEditorIDPrefix+this._container[this._activeElementID].data("objectID");var d=this._container[this._activeElementID].addClass("jsInvalidQuoteTarget").find(".messageBody");d.children(".icon-spinner").remove();var c=d.children("div:eq(0)");$(""+g.returnValues.template).appendTo(c);var b=c.find(".formSubmit");var f=b.find("button[data-type=save]").click($.proxy(this._save,this));if(this._supportExtendedForm){b.find("button[data-type=extended]").click($.proxy(this._prepareExtended,this))}b.find("button[data-type=cancel]").click($.proxy(this._cancel,this));WCF.Message.Submit.registerButton(this._messageEditorIDPrefix+this._container[this._activeElementID].data("objectID"),f);WCF.System.Event.addListener("com.woltlab.wcf.redactor","submitEditor_"+e,function(h){h.cancel=true;f.trigger("click")});this._container[this._activeElementID].find(".messageOptions").addClass("forceHidden");var a=$("#"+e);if($.browser.redactor){new WCF.PeriodicalExecuter($.proxy(function(h){h.stop();if(this._quoteManager){this._quoteManager.setAlternativeEditor(a)}new WCF.Effect.Scroll().scrollTo(this._container[this._activeElementID],true)},this),250)}else{a.focus()}},_revertEditor:function(){var a=this._container[this._activeElementID].removeClass("jsInvalidQuoteTarget").find(".messageBody");a.children("span.icon-spinner").remove();a.children("div:eq(0)").children(":not(.messageText)").show();a.children(".attachmentThumbnailList, .attachmentFileList").show();a.find(".jsInlineEditorHideContent").show();if(this._quoteManager){this._quoteManager.clearAlternativeEditor()}},_save:function(){var d=this._container[this._activeElementID];var c=d.data("objectID");var a="";if($.browser.redactor){a=$("#"+this._messageEditorIDPrefix+c).redactor("wutil.getText")}else{a=$("#"+this._messageEditorIDPrefix+c).val()}var b={containerID:this._containerID,data:{message:a},objectID:c,removeQuoteIDs:(this._quoteManager===null?[]:this._quoteManager.getQuotesMarkedForRemoval())};WCF.System.Event.fireEvent("com.woltlab.wcf.messageOptionsInline","submit_"+this._messageEditorIDPrefix+c,b);this._proxy.setOption("data",{actionName:"save",className:this._getClassName(),interfaceName:"wcf\\data\\IMessageInlineEditorAction",parameters:b});this._proxy.sendRequest();this._hideEditor()},_prepareExtended:function(){var c=this._container[this._activeElementID];var b=c.data("objectID");var a="";if($.browser.redactor){a=$("#"+this._messageEditorIDPrefix+b).redactor("wutil.getText")}else{a=$("#"+this._messageEditorIDPrefix+b).val()}new WCF.Action.Proxy({autoSend:true,data:{actionName:"jumpToExtended",className:this._getClassName(),parameters:{containerID:this._containerID,message:a,messageID:b}},success:function(e,f,d){window.location=e.returnValues.url}})},_hideEditor:function(){var a=this._container[this._activeElementID].removeClass("jsInvalidQuoteTarget").find(".messageBody");$('<span class="icon icon48 icon-spinner" />').appendTo(a);a.children("div:eq(0)").children().hide();a.children(".attachmentThumbnailList, .attachmentFileList").show();a.find(".jsInlineEditorHideContent").show();if(this._quoteManager){this._quoteManager.clearAlternativeEditor()}},_showMessage:function(c){var d=this._container[this._activeElementID].removeClass("jsInvalidQuoteTarget");var b=d.find(".messageBody");b.children(".icon-spinner").remove();var a=b.children("div:eq(0)");a.parent().children(".jsInlineEditorHideContent").show();this._container[this._activeElementID].find(".messageOptions").removeClass("forceHidden");this._destroyEditor();a.children(".messageText").html(c.returnValues.message).show();if(c.returnValues.attachmentList==undefined){b.children(".attachmentThumbnailList, .attachmentFileList").show()}else{b.children(".attachmentThumbnailList, .attachmentFileList").remove();if(c.returnValues.attachmentList){$(c.returnValues.attachmentList).insertAfter(b.children("div:eq(0)"))}}this._activeElementID="";this._updateHistory(this._getHash(d.data("objectID")));this._notification.show();if(this._quoteManager){this._quoteManager.clearAlternativeEditor();this._quoteManager.countQuotes()}},_destroyEditor:function(){var b=this._container[this._activeElementID];if($.browser.redactor){var a=$("#"+this._messageEditorIDPrefix+b.data("objectID"));a.redactor("wutil.autosavePause");a.redactor("wutil.autosavePurge");a.redactor("core.destroy")}b.find(".messageBody > div > .messageInlineEditor").remove();WCF.System.Event.removeAllListeners("com.woltlab.wcf.messageOptionsInline","submit_"+this._messageEditorIDPrefix+b.data("objectID"))},_getClassName:function(){return""},_getHash:function(a){return"#message"+a},_updateHistory:function(a){window.location.hash=a}});WCF.Message.Submit={_buttons:{},registerButton:function(b,a){if(!WCF.Browser.isChrome()){return}this._buttons[b]=$(a)},execute:function(a){if(!this._buttons[a]){return}this._buttons[a].trigger("click")}};WCF.Message.Quote={};WCF.Message.Quote.Handler=Class.extend({_activeContainerID:"",_className:"",_containers:{},_containerSelector:"",_copyQuote:null,_message:"",_messageBodySelector:"",_objectID:0,_objectType:"",_proxy:null,_quoteManager:null,init:function(e,d,b,a,c,f,g){this._className=d;if(this._className==""){console.debug("[WCF.Message.QuoteManager] Empty class name given, aborting.");return}this._objectType=b;if(this._objectType==""){console.debug("[WCF.Message.QuoteManager] Empty object type name given, aborting.");return}this._containerSelector=a;this._message="";this._messageBodySelector=c;this._messageContentSelector=f;this._objectID=0;this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._initContainers();g=(g&&e.supportPaste())?true:false;this._initCopyQuote(g);$(document).mouseup($.proxy(this._mouseUp,this));this._quoteManager=e;this._quoteManager.register(this._objectType,this);WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.Quote.Handler"+b.hashCode(),$.proxy(this._initContainers,this))},_initContainers:function(){var a=this;$(this._containerSelector).each(function(c,b){var e=$(b);var d=e.wcfIdentify();if(!a._containers[d]){a._containers[d]=e;if(e.hasClass("jsInvalidQuoteTarget")){return true}if(a._messageBodySelector!==null){e=e.find(a._messageBodySelector).data("containerID",d)}e.mousedown($.proxy(a._mouseDown,a));a._containers[d].find(".jsQuoteMessage").click($.proxy(a._saveFullQuote,a))}})},_mouseDown:function(b){this._copyQuote.hide();var c=$(b.currentTarget);if(this._messageBodySelector){c=this._containers[c.data("containerID")]}if(c.hasClass("jsInvalidQuoteTarget")){this._activeContainerID="";return}else{var a=b.target;while(a!==c[0]){if(a.tagName==="BLOCKQUOTE"){this._activeContainerID="";return}a=a.parentElement}}this._activeContainerID=c.wcfIdentify();if($.browser.mozilla){c.find("img").each(function(){var d=$(this);d.data("__alt",d.attr("alt")).removeAttr("alt")})}},_getNodeText:function(e){var a=function(f){switch(f.tagName){case"BLOCKQUOTE":case"H3":case"SCRIPT":return NodeFilter.FILTER_REJECT;break;default:return NodeFilter.FILTER_ACCEPT;break}};a.acceptNode=a;var b=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,a,true);var d="";while(b.nextNode()){var c=b.currentNode;if(c.nodeType===Node.ELEMENT_NODE){switch(c.tagName){case"BR":case"LI":case"UL":d+="\n";break;case"TD":if(!$.browser.msie){d+="\n"}break}}else{d+=c.nodeValue.replace(/\n/g,"")}}return d},_mouseUp:function(a){if(this._activeContainerID==""){this._copyQuote.hide();return}var l=this._containers[this._activeContainerID];var e=this._getSelectedText();var h=$.trim(e);if(h==""){this._copyQuote.hide();return}var c=(this._messageBodySelector)?l.find(this._messageContentSelector)[0]:l[0];var j=a.target;while(j!==l[0]){if(j===null||j.tagName==="BLOCKQUOTE"){this._copyQuote.hide();return}j=j.parentElement}var d=window.getSelection().getRangeAt(0);if(!this._elementInsideContainer(d.startContainer,c)||!this._elementInsideContainer(d.endContainer,c)){this._copyQuote.hide();return}var f=this._getNodeText(c);if(this._normalize(f).indexOf(this._normalize(h))===-1){return}this._copyQuote.show();var i=this._getBoundingRectangle(l,window.getSelection());var g=this._copyQuote.getDimensions("outer");var b=(i.right-i.left)/2-(g.width/2)+i.left;this._copyQuote.css({top:i.top-g.height-7+"px",left:b+"px"});this._copyQuote.hide();this._activeContainerID="";var k=this;new WCF.PeriodicalExecuter(function(m){m.stop();var n=$.trim(k._getSelectedText());if(n!=""){k._copyQuote.show();k._message=n;k._objectID=l.data("objectID");if($.browser.mozilla){l.find("img").each(function(){var o=$(this);o.attr("alt",o.data("__alt"))})}}},10)},_elementInsideContainer:function(b,a){if(b.nodeType===Node.TEXT_NODE){b=b.parentNode}while(b){if(b===a){return true}b=b.parentNode}return false},_normalize:function(a){return a.replace(/\r?\n|\r/g,"\n").replace(/\s/g," ").replace(/\s{2,}/g," ")},_getOffset:function(c,d){c.collapse(d);var f=WCF.getRandomID();var a=document.createElement("span");a.innerHTML='<span id="'+f+'"></span>';var g=document.createDocumentFragment(),b;while(b=a.firstChild){g.appendChild(b)}c.insertNode(g);a=$("#"+f);var e=a.offset();e.top=e.top-$(window).scrollTop();a.remove();return e},_getBoundingRectangle:function(a,d){var c=null;if(document.createRange&&typeof document.createRange().getBoundingClientRect!="undefined"){if(d.rangeCount>0){var b=d.getRangeAt(0).getBoundingClientRect();c={left:b.left,right:b.right,top:b.top+$(document).scrollTop()}}}else{if(document.selection&&document.selection.type!="Control"){var e=document.selection.createRange();c={left:e.boundingLeft,right:e.boundingRight,top:e.boundingTop}}}return c},_saveSelection:function(d){if(window.getSelection&&document.createRange){var c=window.getSelection().getRangeAt(0);var b=c.cloneRange();b.selectNodeContents(d);b.setEnd(c.startContainer,c.startOffset);var f=b.toString().length;return{start:f,end:f+c.toString().length}}else{var a=document.selection.createRange();var e=document.body.createTextRange();e.moveToElementText(d);e.setEndPoint("EndToStart",a);var f=e.text.length;return{start:f,end:f+a.text.length}}},_restoreSelection:function(j,k){if(window.getSelection&&document.createRange){var a=0,g=document.createRange();g.setStart(j,0);g.collapse(true);var f=[j],c,d=false,l=false;while(!l&&(c=f.pop())){if(c.nodeType==Node.TEXT_NODE){var h=a+c.length;if(!d&&k.start>=a&&k.start<=h){g.setStart(c,k.start-a);d=true}if(d&&k.end>=a&&k.end<=h){g.setEnd(c,k.end-a);l=true}a=h}else{var e=c.childNodes.length;while(e--){f.push(c.childNodes[e])}}}var b=window.getSelection();b.removeAllRanges();b.addRange(g)}else{var m=document.body.createTextRange();m.moveToElementText(j);m.collapse(true);m.moveEnd("character",k.end);m.moveStart("character",k.start);m.select()}},_initCopyQuote:function(b){this._copyQuote=$("#quoteManagerCopy");if(!this._copyQuote.length){this._copyQuote=$('<div id="quoteManagerCopy" class="balloonTooltip"><span class="jsQuoteManagerStore">'+WCF.Language.get("wcf.message.quote.quoteSelected")+'</span><span class="pointer"><span></span></span></div>').hide().appendTo(document.body);var a=this._copyQuote.children("span.jsQuoteManagerStore").click($.proxy(this._saveQuote,this));if(b){$('<span class="jsQuoteManagerQuoteAndInsert">'+WCF.Language.get("wcf.message.quote.quoteAndReply")+"</span>").click($.proxy(this._saveAndInsertQuote,this)).insertAfter(a)}}},_getSelectedText:function(){var a=window.getSelection();if(a.rangeCount){return this._getNodeText(a.getRangeAt(0).cloneContents())}return""},_saveFullQuote:function(b){var a=$(b.currentTarget);this._proxy.setOption("data",{actionName:"saveFullQuote",className:this._className,interfaceName:"wcf\\data\\IMessageQuoteAction",objectIDs:[a.data("objectID")]});this._proxy.sendRequest();if(a.data("isQuoted")){a.data("isQuoted",false).children("a").removeClass("active")}else{a.data("isQuoted",true).children("a").addClass("active")}var c=a.parents(".buttonGroupNavigation");if(c.hasClass("jsMobileButtonGroupNavigation")){c.children(".dropdownLabel").trigger("click")}b.stopPropagation();return false},_saveQuote:function(a){a=(a===true)?true:false;this._proxy.setOption("data",{actionName:"saveQuote",className:this._className,interfaceName:"wcf\\data\\IMessageQuoteAction",objectIDs:[this._objectID],parameters:{message:this._message,renderQuote:a}});this._proxy.sendRequest()},_saveAndInsertQuote:function(){this._saveQuote(true)},_success:function(c,d,b){if(c.returnValues.count!==undefined){if(c.returnValues.fullQuoteMessageIDs!==undefined){c.returnValues.fullQuoteObjectIDs=c.returnValues.fullQuoteMessageIDs}var a=(c.returnValues.fullQuoteObjectIDs!==undefined)?c.returnValues.fullQuoteObjectIDs:{};this._quoteManager.updateCount(c.returnValues.count,a)}switch(c.actionName){case"saveQuote":case"saveFullQuote":if(c.returnValues.renderedQuote){WCF.System.Event.fireEvent("com.woltlab.wcf.message.quote","insert",{forceInsert:(c.actionName==="saveQuote"?true:false),quote:c.returnValues.renderedQuote})}break}},updateFullQuoteObjectIDs:function(b){for(var a in this._containers){this._containers[a].find(".jsQuoteMessage").each(function(c,d){var e=$(d).data("isQuoted",0);e.children("a").removeClass("active");if(WCF.inArray(e.data("objectID"),b)){e.data("isQuoted",1).children("a").addClass("active")}})}}});WCF.Message.Quote.Manager=Class.extend({_buttons:{},_count:0,_dialog:null,_editorElement:null,_editorElementAlternative:null,_form:null,_handlers:{},_hasTemplate:false,_insertQuotes:true,_proxy:null,_removeOnSubmit:[],_showQuotes:null,_supportPaste:false,init:function(c,a,b,d){this._buttons={insert:null,remove:null};this._count=parseInt(c)||0;this._dialog=null;this._editorElement=null;this._editorElementAlternative=null;this._form=null;this._handlers={};this._hasTemplate=false;this._insertQuotes=true;this._removeOnSubmit=[];this._showQuotes=null;this._supportPaste=false;if(a){this._editorElement=$("#"+a);if(this._editorElement.length){this._supportPaste=true;this._form=this._editorElement.parents("form:eq(0)");if(this._form.length){this._form.submit($.proxy(this._submit,this));this._removeOnSubmit=d||[]}else{this._form=null;this._supportPaste=(b===true)?true:false}}}this._proxy=new WCF.Action.Proxy({showLoadingOverlay:false,success:$.proxy(this._success,this),url:"index.php/MessageQuote/?t="+SECURITY_TOKEN+SID_ARG_2ND});this._toggleShowQuotes();WCF.System.Event.addListener("com.woltlab.wcf.message.quote","insert",(function(e){this._insertQuote(null,undefined,e)}).bind(this))},setAlternativeEditor:function(a){this._editorElementAlternative=a},clearAlternativeEditor:function(){this._editorElementAlternative=null},register:function(a,b){this._handlers[a]=b},updateCount:function(d,c){this._count=parseInt(d)||0;this._toggleShowQuotes();for(var a in this._handlers){var b=c[a]||[];this._handlers[a].updateFullQuoteObjectIDs(b)}},insertQuotes:function(a,b,c){if(!this._insertQuotes){this._insertQuotes=true;return}new WCF.Action.Proxy({autoSend:true,data:{actionName:"getRenderedQuotes",className:a,interfaceName:"wcf\\data\\IMessageQuoteAction",parameters:{parentObjectID:b}},success:c})},_toggleShowQuotes:function(){if(!this._count){if(this._showQuotes!==null){this._showQuotes.hide()}}else{if(this._showQuotes===null){this._showQuotes=$("#showQuotes");if(!this._showQuotes.length){this._showQuotes=$('<div id="showQuotes" class="balloonTooltip" />').click($.proxy(this._click,this)).appendTo(document.body)}}var a=WCF.Language.get("wcf.message.quote.showQuotes").replace(/#count#/,this._count);this._showQuotes.text(a).show()}this._hasTemplate=false},_click:function(){if(this._hasTemplate){this._dialog.wcfDialog("open")}else{this._proxy.showLoadingOverlayOnce();this._proxy.setOption("data",{actionName:"getQuotes",supportPaste:this._supportPaste});this._proxy.sendRequest()}},renderDialog:function(c){if(this._dialog===null){this._dialog=$("#messageQuoteList");if(!this._dialog.length){this._dialog=$('<div id="messageQuoteList" />').hide().appendTo(document.body)}}this._dialog.html(c);var a=$('<div class="formSubmit" />').appendTo(this._dialog);if(this._supportPaste){this._buttons.insert=$('<button class="buttonPrimary">'+WCF.Language.get("wcf.message.quote.insertAllQuotes")+"</button>").click($.proxy(this._insertSelected,this)).appendTo(a)}this._buttons.remove=$("<button>"+WCF.Language.get("wcf.message.quote.removeAllQuotes")+"</button>").click($.proxy(this._removeSelected,this)).appendTo(a);this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.quote.manageQuotes")});this._dialog.wcfDialog("render");this._hasTemplate=true;var d=this._dialog.find(".jsInsertQuote");if(this._supportPaste){d.click($.proxy(this._insertQuote,this))}else{d.hide()}this._dialog.find("input.jsCheckbox").change($.proxy(this._changeButtons,this));if(this._removeOnSubmit.length){var b=this;this._dialog.find("input.jsRemoveQuote").each(function(f,e){var g=$(e).change($.proxy(this._change,this));if(WCF.inArray(g.parent("li").attr("data-quote-id"),b._removeOnSubmit)){g.attr("checked","checked")}})}},_changeButtons:function(){if(this._dialog.find("input.jsCheckbox:checked").length){if(this._supportPaste){this._buttons.insert.html(WCF.Language.get("wcf.message.quote.insertSelectedQuotes"))}this._buttons.remove.html(WCF.Language.get("wcf.message.quote.removeSelectedQuotes"))}else{if(this._supportPaste){this._buttons.insert.html(WCF.Language.get("wcf.message.quote.insertAllQuotes"))}this._buttons.remove.html(WCF.Language.get("wcf.message.quote.removeAllQuotes"))}},_change:function(c){var d=$(c.currentTarget);var b=d.parent("li").attr("data-quote-id");if(d.prop("checked")){this._removeOnSubmit.push(b)}else{for(var a in this._removeOnSubmit){if(this._removeOnSubmit[a]==b){delete this._removeOnSubmit[a];break}}}},_insertSelected:function(){if(this._editorElementAlternative===null){var a=$(".jsQuickReply:eq(0)").data("__api");if(a&&!a.getContainer().is(":visible")){this._insertQuotes=false;a.click(null)}}if(!this._dialog.find("input.jsCheckbox:checked").length){this._dialog.find("input.jsCheckbox").prop("checked","checked")}this._dialog.find("input.jsCheckbox:checked").each($.proxy(function(c,b){this._insertQuote(null,b)},this));this._dialog.wcfDialog("close")},_insertQuote:function(b,l,e){var i=null,m,a,h;if(e===undefined){i=(b===null)?$(l).parents("li"):$(b.currentTarget).parents("li");m=$.trim(i.children("div.jsFullQuote").text());var g=i.parents("article.message");a=g.attr("data-username");h=g.data("link")}else{m=e.quote.text;a=e.quote.username;h=e.quote.link}if($.browser.redactor){if(this._editorElementAlternative===null){var k=true;if(b!==null||e!==null){var d=$(".jsQuickReply:eq(0)").data("__api");if(d&&!d.getContainer().is(":visible")){if(e.forceInsert){this._insertQuotes=false;d.click(null)}else{k=false}}}if(k){this._editorElement.redactor("wbbcode.insertQuoteBBCode",a,h,m,m)}}else{this._editorElementAlternative.redactor("wbbcode.insertQuoteBBCode",a,h,m,m)}}else{m="[quote='"+a+"','"+h+"']"+m+"[/quote]";var f=(this._editorElementAlternative===null)?this._editorElement:this._editorElementAlternative;var j=f.val();m+="\n\n";if(j.length==0){f.val(m)}else{var c=f.getCaret();f.val(j.substr(0,c)+m+j.substr(c))}}if(i!==null){this._removeOnSubmit.push(i.attr("data-quote-id"))}if(b!==null){this._dialog.wcfDialog("close")}},_removeSelected:function(){if(!this._dialog.find("input.jsCheckbox:checked").length){this._dialog.find("input.jsCheckbox").prop("checked","checked")}var b=[];this._dialog.find("input.jsCheckbox:checked").each(function(e,d){b.push($(d).parents("li").attr("data-quote-id"))});if(b.length){var c=[];for(var a in this._handlers){c.push(a)}this._proxy.setOption("data",{actionName:"remove",getFullQuoteObjectIDs:this._handlers.length>0,objectTypes:c,quoteIDs:b});this._proxy.sendRequest();this._dialog.wcfDialog("close")}},_submit:function(){if(this._supportPaste&&this._removeOnSubmit.length>0){var a=this._form.find(".formSubmit");for(var b in this._removeOnSubmit){$('<input type="hidden" name="__removeQuoteIDs[]" value="'+this._removeOnSubmit[b]+'" />').appendTo(a)}}},getQuotesMarkedForRemoval:function(){return this._removeOnSubmit},markQuotesForRemoval:function(){if(this._removeOnSubmit.length){this._proxy.setOption("data",{actionName:"markForRemoval",quoteIDs:this._removeOnSubmit});this._proxy.suppressErrors();this._proxy.sendRequest()}},removeMarkedQuotes:function(){if(this._removeOnSubmit.length){this._proxy.setOption("data",{actionName:"removeMarkedQuotes",getFullQuoteObjectIDs:this._handlers.length>0});this._proxy.sendRequest()}},countQuotes:function(){var b=[];for(var a in this._handlers){b.push(a)}this._proxy.setOption("data",{actionName:"count",getFullQuoteObjectIDs:(b.length>0),objectTypes:b});this._proxy.sendRequest()},_success:function(c,d,b){if(c===null){return}if(c.count!==undefined){var a=(c.fullQuoteObjectIDs!==undefined)?c.fullQuoteObjectIDs:{};this.updateCount(c.count,a)}if(c.template!==undefined){if($.trim(c.template)==""){this.updateCount(0,{})}else{this.renderDialog(c.template)}}},supportPaste:function(){return this._supportPaste}});WCF.Message.Share={};WCF.Message.Share.Content=Class.extend({_cache:{},_dialog:null,init:function(){this._cache={};this._dialog=null;this._initLinks();WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.Share.Content",$.proxy(this._initLinks,this))},_initLinks:function(){$("a.jsButtonShare").removeClass("jsButtonShare").click($.proxy(this._click,this))},_click:function(e){e.preventDefault();var a=$(e.currentTarget);var b=a.prop("href");var d=(a.data("linkTitle")?a.data("linkTitle"):b);var c=b.hashCode();if(this._cache[c]===undefined){var g=false;if(this._dialog===null){this._dialog=$("<div />").hide().appendTo(document.body);g=true}else{this._dialog.empty()}var f=$('<fieldset><legend><label for="__sharePermalink">'+WCF.Language.get("wcf.message.share.permalink")+"</label></legend></fieldset>").appendTo(this._dialog);$('<input type="text" id="__sharePermalink" class="long" readonly="readonly" />').attr("value",b).appendTo(f);var f=$('<fieldset><legend><label for="__sharePermalinkBBCode">'+WCF.Language.get("wcf.message.share.permalink.bbcode")+"</label></legend></fieldset>").appendTo(this._dialog);$('<input type="text" id="__sharePermalinkBBCode" class="long" readonly="readonly" />').attr("value","[url='"+b+"']"+d+"[/url]").appendTo(f);var f=$('<fieldset><legend><label for="__sharePermalinkHTML">'+WCF.Language.get("wcf.message.share.permalink.html")+"</label></legend></fieldset>").appendTo(this._dialog);$('<input type="text" id="__sharePermalinkHTML" class="long" readonly="readonly" />').attr("value",'<a href="'+b+'">'+WCF.String.escapeHTML(d)+"</a>").appendTo(f);this._cache[c]=this._dialog.html();if(g){this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.share")})}else{this._dialog.wcfDialog("open")}}else{this._dialog.html(this._cache[c]).wcfDialog("open")}this._enableSelection()},_enableSelection:function(){var a=this._dialog.find("input").click(function(){$(this).select()});if(navigator.userAgent.match(/iP(ad|hone|od)/)){a.keydown(function(){return false}).removeAttr("readonly").click(function(){this.setSelectionRange(0,9999)})}}});WCF.Message.Share.Page=Class.extend({_dialog:null,_fetchObjectCount:false,_pageDescription:"",_pageURL:"",_privacySettings:{},_provider:{},_proxy:null,init:function(a,b){this._dialog=null;this._fetchObjectCount=(a===true)?true:false;this._pageDescription=encodeURIComponent($('meta[property="og:title"]').prop("content"));this._pageURL=encodeURIComponent($('meta[property="og:url"]').prop("content"));this._privacySettings=$.extend({facebook:false,google:false,twitter:false,reddit:false},b||{});this._proxy=null;this._initProvider()},_initProvider:function(){var c=$(".messageShareButtons");var a=this;this._provider={facebook:{fetch:function(){a._fetchFacebook()},link:c.find(".jsShareFacebook"),share:function(){a._share("facebook","https://www.facebook.com/sharer.php?u={pageURL}&t={text}",true)}},google:{fetch:undefined,link:c.find(".jsShareGoogle"),share:function(){a._share("google","https://plus.google.com/share?url={pageURL}",true)}},reddit:{fetch:function(){a._fetchReddit()},link:c.find(".jsShareReddit"),share:function(){a._share("reddit","https://ssl.reddit.com/submit?url={pageURL}",true)}},twitter:{fetch:function(){a._fetchTwitter()},link:c.find(".jsShareTwitter"),share:function(){a._share("twitter","https://twitter.com/share?url={pageURL}&text={text}",false)}}};$.each(this._provider,function(e,d){if(a._privacySettings[e]){if(a._fetchObjectCount&&d.fetch){d.fetch()}}else{d.link.addClass("disabled")}d.link.data("provider",e).click($.proxy(a._click,a))});if(WCF.User.userID&&!c.find(".jsShowPrivacySettings").length){var b=$('<li class="jsShowPrivacySettings"><a><span class="icon icon32 fa-gear jsTooltip" title="'+WCF.Language.get("wcf.message.share.privacy")+'" /></a></li>');b.appendTo(c.children("ul")).children("a").click($.proxy(this._openPrivacySettings,this))}},_click:function(b){var a=$(b.currentTarget);var c=a.data("provider");if(a.hasClass("disabled")){if(WCF.User.userID){this._openPrivacySettings()}else{a.removeClass("disabled")}}else{this._provider[c].share()}},_openPrivacySettings:function(){if(this._proxy===null){this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)})}this._proxy.setOption("data",{actionName:"getSocialNetworkPrivacySettings",className:"wcf\\data\\user\\UserAction"});this._proxy.sendRequest()},_success:function(b,c,a){switch(b.actionName){case"getSocialNetworkPrivacySettings":this._renderDialog(b);break;case"saveSocialNetworkPrivacySettings":this._updatePrivacySettings(b);break}},_renderDialog:function(a){if(this._dialog===null){this._dialog=$("<div />").hide().appendTo(document.body);this._dialog.html(a.returnValues.template);this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.share.privacy")})}else{this._dialog.html(a.returnValues.template);this._dialog.wcfDialog("open")}this._dialog.find("input[type=submit]").click($.proxy(this._save,this))},_save:function(){this._proxy.setOption("data",{actionName:"saveSocialNetworkPrivacySettings",className:"wcf\\data\\user\\UserAction",parameters:{facebook:(this._dialog.find("input[name=facebook]").is(":checked")),google:(this._dialog.find("input[name=google]").is(":checked")),reddit:(this._dialog.find("input[name=reddit]").is(":checked")),twitter:(this._dialog.find("input[name=twitter]").is(":checked"))}});this._proxy.sendRequest();this._dialog.wcfDialog("close")},_updatePrivacySettings:function(b){this._privacySettings=$.extend(this._privacySettings,b.returnValues.settings);var a=this;$.each(b.returnValues.settings,function(d,c){a._privacySettings[d]=(c)?true:false;if(c){a._provider[d].link.removeClass("disabled");if(a._fetchObjectCount&&a._provider[d].fetch){a._provider[d].fetch()}}else{a._provider[d].link.addClass("disabled")}});new WCF.System.Notification().show()},_share:function(c,a,b){window.open(a.replace(/{pageURL}/,this._pageURL).replace(/{text}/,this._pageDescription+(b?" "+this._pageURL:"")),c,"height=600,width=600")},_fetchCount:function(b,d,c){var a={autoSend:true,dataType:"jsonp",showLoadingOverlay:false,success:d,suppressErrors:true,type:"GET",url:b.replace(/{pageURL}/,this._pageURL)};if(c){a.jsonp=c}new WCF.Action.Proxy(a)},_fetchFacebook:function(){this._fetchCount("https://graph.facebook.com/?id={pageURL}",$.proxy(function(a){if(a.shares){this._provider.facebook.link.children("span.badge").show().text(a.shares)}},this))},_fetchTwitter:function(){if(window.location.protocol.match(/^https/)){return}this._fetchCount("http://urls.api.twitter.com/1/urls/count.json?url={pageURL}",$.proxy(function(a){if(a.count){this._provider.twitter.link.children("span.badge").show().text(a.count)}},this))},_fetchReddit:function(){if(window.location.protocol.match(/^https/)){return}this._fetchCount("http://www.reddit.com/api/info.json?url={pageURL}",$.proxy(function(a){if(a.data.children.length){this._provider.reddit.link.children("span.badge").show().text(a.data.children[0].data.score)}},this),"jsonp")}});WCF.Message.UserMention=Class.extend({_caretPosition:null,_className:"wcf\\data\\user\\UserAction",_dropdown:null,_dropdownMenu:null,_itemIndex:-1,_lineHeight:null,_mentionStart:"",_redactor:null,_timer:null,init:function(a){if($.browser.mobile&&$.browser.mozilla){return}this._textarea=$("#"+a);this._redactor=this._textarea.redactor("core.getObject");this._dropdown=this._textarea.redactor("core.getEditor");this._dropdownMenu=$('<ul class="dropdownMenu userSuggestionList" />').appendTo(this._textarea.parent());WCF.Dropdown.initDropdownFragment(this._dropdown,this._dropdownMenu);this._proxy=new WCF.Action.Proxy({autoAbortPrevious:true,success:$.proxy(this._success,this)});WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+a,$.proxy(this._keydown,this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","keyup_"+a,$.proxy(this._keyup,this))},_clearList:function(){this._hideList();this._dropdownMenu.empty()},_click:function(a){if($.browser.mozilla&&this._caretPosition.startContainer.nodeName=="P"){var b=this._caretPosition.startContainer.childNodes[this._caretPosition.startOffset-1];this._caretPosition=document.createRange();this._caretPosition.selectNodeContents(b);this._caretPosition.collapse()}this._redactor.wutil.replaceRangesWith(this._caretPosition);this._setUsername($(a.currentTarget).data("username"))},_createListItem:function(c){var b=$("<li />").data("username",c.label).click($.proxy(this._click,this)).appendTo(this._dropdownMenu);var a=$("<div />").addClass("box16").appendTo(b);a.append($(c.icon).addClass("framed"));a.append($("<div />").append($("<span />").text(c.label)))},_getDropdownMenuPosition:function(){var e=getSelection().getRangeAt(0).cloneRange();var a=document.createRange();a.setStart(e.startContainer,e.startOffset-(this._mentionStart.length+1));a.setEnd(e.startContainer,e.startOffset);this._redactor.wutil.replaceRangesWith(a);var f=getSelection().getRangeAt(0);var b=f.getBoundingClientRect();var d=$(window);var c={top:Math.round(b.bottom)+d.scrollTop(),left:Math.round(b.left)+d.scrollLeft()};if(this._lineHeight===null){this._lineHeight=Math.round(b.bottom-b.top)}this._redactor.wutil.replaceRangesWith(e);this._caretPosition=e;return c},_setUsername:function(g){if(this._timer!==null){this._timer.stop();this._timer=null}this._proxy.abortPrevious();var e=getSelection().getRangeAt(0).cloneRange();this._redactor.buffer.set();var d=e.startContainer;var c=e.startOffset-(this._mentionStart.length+1);if(c<0){d=d.previousSibling;c=d.length-(this._mentionStart.length+1)-(e.startOffset-1)}var a=document.createRange();a.setStart(d,c);a.setEnd(e.startContainer,e.startOffset);this._redactor.wutil.replaceRangesWith(a);var f=getSelection().getRangeAt(0);f.deleteContents();f.collapse(true);if(g.indexOf("'")!==-1){g=g.replace(/'/g,"''")}g="'"+g+"'";var b=document.createTextNode("@"+g);f.insertNode(b);var a=document.createRange();a.setStart(b,g.length+1);a.setEnd(b,g.length+1);this._redactor.wutil.replaceRangesWith(a);this._hideList()},_getParameters:function(){return{data:{includeUserGroups:false,searchString:this._mentionStart}}},_getTextLineInFrontOfCaret:function(){if(this._redactor.selection.getHtml().length){return""}var f=getSelection().getRangeAt(0);if($.browser.mozilla&&f.startContainer.nodeType==3){f.startContainer.parentNode.normalize()}var c=f.startContainer.textContent.substr(0,f.startOffset);var a=c;c="";var b=false;for(var e=0;e<a.length;e++){var d=a.charCodeAt(e).toString(16);if(d!="200b"&&(!/\s/.test(a[e])||((d=="a0"||d=="20")&&!b))){if(d=="a0"||d=="20"){b=true}if(a[e]==="@"&&e&&/\s/.test(a[e-1])){b=false;c=""}c+=a[e]}else{b=false;c=""}}return c},_hideList:function(){this._dropdown.removeClass("dropdownOpen");this._dropdownMenu.removeClass("dropdownOpen");this._itemIndex=-1},_keydown:function(a){if(this._redactor.wutil.inPlainMode()){return}if(this._dropdownMenu.is(":visible")){switch(a.event.which){case $.ui.keyCode.ENTER:a.event.preventDefault();a.cancel=true;this._dropdownMenu.children("li").eq(this._itemIndex).trigger("click");break;case $.ui.keyCode.UP:a.cancel=true;a.event.preventDefault();this._selectItem(this._itemIndex-1);break;case $.ui.keyCode.DOWN:a.cancel=true;a.event.preventDefault();this._selectItem(this._itemIndex+1);break}}},_keyup:function(c){if(this._redactor.wutil.inPlainMode()){return true}if(this._timer!==null){this._timer.stop();this._timer=null}this._proxy.abortPrevious();if(c.event.which===$.ui.keyCode.ENTER){return}if(this._dropdownMenu.is(":visible")&&c.event.which in {13:1,38:1,40:1}){return}var b=this._getTextLineInFrontOfCaret();if(b){var a=b.match(/@([^,]{3,})$/);if(a){if(!a.index||b[a.index-1].match(/\s/)){this._mentionStart=a[1];if(this._timer!==null){this._timer.stop()}this._timer=new WCF.PeriodicalExecuter($.proxy(function(){this._proxy.setOption("data",{actionName:"getSearchResultList",className:this._className,interfaceName:"wcf\\data\\ISearchAction",parameters:this._getParameters()});this._proxy.sendRequest();this._timer.stop();this._timer=null},this),500)}}else{this._hideList()}}else{this._hideList()}},_selectItem:function(a){var b=this._dropdownMenu.children("li");if(a<0){a=b.length-1}else{if(a+1>b.length){a=0}}b.removeClass("dropdownNavigationItem");b.eq(a).addClass("dropdownNavigationItem");this._itemIndex=a},_showList:function(){this._dropdown.addClass("dropdownOpen");this._dropdownMenu.addClass("dropdownOpen")},_success:function(c,e,b){this._clearList(false);if($.getLength(c.returnValues)){for(var d in c.returnValues){var a=c.returnValues[d];this._createListItem(a)}this._updateSuggestionListPosition();this._showList()}},_updateSuggestionListPosition:function(){try{var b=this._getDropdownMenuPosition();b.top+=5;this._dropdownMenu.css(b);this._selectItem(0);if(b.top+this._dropdownMenu.outerHeight()+10>$(window).height()+$(document).scrollTop()){this._dropdownMenu.addClass("dropdownArrowBottom");this._dropdownMenu.css({top:b.top-this._dropdownMenu.outerHeight()-2*this._lineHeight+5})}else{this._dropdownMenu.removeClass("dropdownArrowBottom")}}catch(a){}}});$.widget("wcf.messageTabMenu",{_tabs:[],_tabsByName:{},options:{collapsible:true},_create:function(){var c=this.element.find("> nav > ul > li:not(.jsFlexibleMenuDropdown)");var b=this.element.find("> div, > fieldset");if(c.length!=b.length){console.debug("[wcf.messageTabMenu] Amount of tabs does not equal amount of tab containers, aborting.");return}var a=this.element.data("preselect");this._tabs=[];this._tabsByName={};for(var g=0;g<c.length;g++){var f=$(c[g]);var d=$(b[g]);var h=f.data("name");if(h===undefined){var i=f.children("a").prop("href");if(i!==undefined){if(i.match(/#([a-zA-Z_-]+)$/)){h=RegExp.$1}}if(h===undefined){h=f.wcfIdentify();console.debug("[wcf.messageTabMenu] Missing name attribute, assuming generic ID '"+h+"'")}}this._tabs.push({container:d,name:h,tab:f});this._tabsByName[h]=g;var j=f.children("a").data("index",g).click($.proxy(this._showTab,this));if(a==h){j.trigger("click")}}if(a===true&&this._tabs.length){this._tabs[0].tab.children("a").trigger("click")}var e=this.element.data("collapsible");if(e!==undefined){this.options.collapsible=e}},destroy:function(){$.Widget.prototype.destroy.apply(this,arguments);this.element.remove()},_showTab:function(f,c,d){var b=(f===null)?c:$(f.currentTarget).data("index");d=(!this.options.collapsible||d===true)?true:false;var a=null;for(var g=0;g<this._tabs.length;g++){var e=this._tabs[g];if(g==b){if(!e.tab.hasClass("active")){e.tab.addClass("active");e.container.addClass("active");a=e;continue}else{if(d===true){continue}}}e.tab.removeClass("active");e.container.removeClass("active")}if(f!==null){f.preventDefault();f.stopPropagation()}if(a!==null){this._trigger("show",{},{activeTab:a})}$(window).trigger("resize")},showTab:function(a,b){if(!$.isNumeric(a)){if(this._tabsByName[a]!==undefined){a=this._tabsByName[a]}}if(this._tabs[a]===undefined){console.debug("[wcf.messageTabMenu] Cannot locate tab identified by '"+a+"'");return}this._showTab(null,a,b)},getTab:function(a){if(this._tabsByName[a]!==undefined){return this._tabs[this._tabsByName[a]].tab}return null},getContainer:function(a){if(this._tabsByName[a]!==undefined){return this._tabs[this._tabsByName[a]].container}return null}}); })(this);
+(function (window, undefined) {"use strict";WCF.Message={};WCF.Message.BBCode={};WCF.Message.BBCode.CodeViewer=Class.extend({_dialog:null,init:function(){this._dialog=null;this._initCodeBoxes();WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.BBCode.CodeViewer",$.proxy(this._initCodeBoxes,this));WCF.DOMNodeInsertedHandler.execute()},_initCodeBoxes:function(){$(".codeBox:not(.jsCodeViewer)").each($.proxy(function(a,c){var b=$(c).addClass("jsCodeViewer");$('<span class="icon icon16 icon-copy pointer jsTooltip" title="'+WCF.Language.get("wcf.message.bbcode.code.copy")+'" />').appendTo(b.find("div > h3")).click($.proxy(this._click,this))},this))},_click:function(b){var a="";$(b.currentTarget).parents("div").next("ol").children("li").each(function(c,d){if(a){a+="\n"}a+=$(d).text().replace(/\n+$/,"")});if(this._dialog===null){this._dialog=$('<div><textarea cols="60" rows="12" readonly="readonly" /></div>').hide().appendTo(document.body);this._dialog.children("textarea").val(a);this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.bbcode.code.copy")})}else{this._dialog.children("textarea").val(a);this._dialog.wcfDialog("open")}this._dialog.children("textarea").select()}});WCF.Message.EditHistory=Class.extend({_oldIDInputs:null,_newIDInputs:null,_containerSelector:"",_buttonSelector:".jsRevertButton",init:function(c,b,a,d){this._oldIDInputs=c;this._newIDInputs=b;this._containerSelector=a;this._buttonSelector=(d)?d:".jsRevertButton";this.proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._initInputs();this._initElements()},_initInputs:function(){var a=this;this._newIDInputs.change(function(c){var b=parseInt($(this).val());if($(this).val()==="current"){b=Infinity}a._oldIDInputs.each(function(d){var e=parseInt($(this).val());if($(this).val()==="current"){e=Infinity}if(e>=b){$(this).disable()}else{$(this).enable()}})});this._oldIDInputs.change(function(b){var c=parseInt($(this).val());if($(this).val()==="current"){c=Infinity}a._newIDInputs.each(function(e){var d=parseInt($(this).val());if($(this).val()==="current"){d=Infinity}if(d<=c){$(this).disable()}else{$(this).enable()}})});this._oldIDInputs.filter(":checked").change();this._newIDInputs.filter(":checked").change()},_initElements:function(){var a=this;$(this._containerSelector).each(function(c,b){var d=$(b);d.find(a._buttonSelector).click($.proxy(a._click,a))})},_click:function(c){var a=$(c.currentTarget);c.preventDefault();if(a.data("confirmMessage")){var b=this;WCF.System.Confirmation.show(a.data("confirmMessage"),function(d){if(d==="cancel"){return}b._sendRequest(a)})}else{this._sendRequest(a)}},_sendRequest:function(a){this.proxy.setOption("data",{actionName:"revert",className:"wcf\\data\\edit\\history\\entry\\EditHistoryEntryAction",objectIDs:[$(a).data("objectID")]});this.proxy.sendRequest()},_success:function(b,c,a){window.location.reload(true)}});WCF.Message.FormGuard=Class.extend({init:function(){var a=$("form.jsFormGuard").removeClass("jsFormGuard").submit(function(){$(this).find(".formSubmit input[type=submit]").disable()});$(window).unload(function(){a.find(".formSubmit input[type=submit]").enable()})}});WCF.Message.Preview=Class.extend({_className:"",_messageFieldID:"",_messageField:null,_proxy:null,_previewButton:null,_previewButtonLabel:"",init:function(b,a,c){this._className=b;this._messageFieldID=$.wcfEscapeID(a);this._messageField=$("#"+this._messageFieldID);if(!this._messageField.length){console.debug("[WCF.Message.Preview] Unable to find message field identified by '"+this._messageFieldID+"'");return}c=$.wcfEscapeID(c);this._previewButton=$("#"+c);if(!this._previewButton.length){console.debug("[WCF.Message.Preview] Unable to find preview button identified by '"+c+"'");return}this._previewButton.click($.proxy(this._click,this));this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),success:$.proxy(this._success,this)})},_click:function(b){var a=this._getMessage();if(a===null){console.debug("[WCF.Message.Preview] Unable to access Redactor instance of '"+this._messageFieldID+"'");return}this._proxy.setOption("data",{actionName:"getMessagePreview",className:this._className,parameters:this._getParameters(a)});this._proxy.sendRequest();this._previewButtonLabel=this._previewButton.html();this._previewButton.html(WCF.Language.get("wcf.global.loading")).disable();b.stopPropagation();return false},_getParameters:function(b){var a={};$("#settings_"+this._messageFieldID).find("input[type=checkbox]").each(function(c,e){var d=$(e);if(d.is(":checked")){a[d.prop("name")]=d.prop("value")}});return{data:{message:b},options:a}},_getMessage:function(){if(!$.browser.redactor){return $.trim(this._messageField.val())}else{if(this._messageField.data("redactor")){return this._messageField.redactor("wutil.getText")}}return null},_success:function(b,c,a){this._previewButton.html(this._previewButtonLabel).enable();this._messageField.parent().children("small.innerError").remove();this._handleResponse(b)},_handleResponse:function(a){},_failure:function(a){if(a===null||a.returnValues===undefined||a.returnValues.errorType===undefined){return true}this._previewButton.html(this._previewButtonLabel).enable();var b=this._messageField.next("small.innerError").empty();if(!b.length){b=$('<small class="innerError" />').appendTo(this._messageField.parent())}b.html(a.returnValues.errorType);return false}});WCF.Message.DefaultPreview=WCF.Message.Preview.extend({_attachmentObjectType:null,_attachmentObjectID:null,_tmpHash:null,init:function(b,a,c){this._super("wcf\\data\\bbcode\\MessagePreviewAction","text","previewButton");this._attachmentObjectType=b||null;this._attachmentObjectID=a||null;this._tmpHash=c||null},_handleResponse:function(b){var a=$("#previewContainer");if(!a.length){a=$('<div class="container containerPadding marginTop" id="previewContainer"><fieldset><legend>'+WCF.Language.get("wcf.global.preview")+'</legend><div class="messageTextPreview"></div></fieldset>').prependTo($("#messageContainer")).wcfFadeIn()}a.find("div:eq(0)").html(b.returnValues.message);new WCF.Effect.Scroll().scrollTo(a)},_getParameters:function(b){var a=this._super(b);if(this._attachmentObjectType!=null){a.attachmentObjectType=this._attachmentObjectType;a.attachmentObjectID=this._attachmentObjectID;a.tmpHash=this._tmpHash}return a}});WCF.Message.Multilingualism=Class.extend({_availableLanguages:{},_languageID:0,_languageInput:null,init:function(c,d,a){this._availableLanguages=d;this._languageID=c||0;this._languageInput=$("#languageID");this._updateLabel();this._languageInput.find(".dropdownMenu > li").click($.proxy(this._click,this));if(!a){var b=this._languageInput.find(".dropdownMenu");$('<li class="dropdownDivider" />').appendTo(b);$('<li><span><span class="badge">'+this._availableLanguages[0]+"</span></span></li>").click($.proxy(this._disable,this)).appendTo(b)}this._languageInput.parents("form").submit($.proxy(this._submit,this))},_click:function(a){this._languageID=$(a.currentTarget).data("languageID");this._updateLabel()},_disable:function(){this._languageID=0;this._updateLabel()},_updateLabel:function(){this._languageInput.find(".dropdownToggle > span").text(this._availableLanguages[this._languageID])},_submit:function(){this._languageInput.next("input[name=languageID]").prop("value",this._languageID)}});WCF.Message.SmileyCategories=Class.extend({_cache:[],_proxy:null,_wysiwygSelector:"",init:function(a){this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._wysiwygSelector=a;$("#smilies-"+this._wysiwygSelector).on("messagetabmenushow",$.proxy(this._click,this))},_click:function(b,c){var a=parseInt(c.activeTab.tab.data("smileyCategoryID"));if(!a){return}if(c.activeTab.container.children("ul.smileyList").length){return}if(this._cache[a]!==undefined){c.activeTab.container.html(this._cache[a])}this._proxy.setOption("data",{actionName:"getSmilies",className:"wcf\\data\\smiley\\category\\SmileyCategoryAction",objectIDs:[a]});this._proxy.sendRequest()},_success:function(c,d,b){var a=parseInt(c.returnValues.smileyCategoryID);this._cache[a]=c.returnValues.template;$("#smilies-"+this._wysiwygSelector+"-"+a).html(c.returnValues.template)}});WCF.Message.Smilies=Class.extend({_redactor:null,_wysiwygSelector:"",init:function(a){this._wysiwygSelector=a;WCF.System.Dependency.Manager.register("Redactor_"+this._wysiwygSelector,$.proxy(function(){this._redactor=$("#"+this._wysiwygSelector).redactor("core.getObject");$(".messageTabMenu[data-wysiwyg-container-id="+this._wysiwygSelector+"]").on("click",".jsSmiley",$.proxy(this._smileyClick,this))},this))},_smileyClick:function(d){var b=$(d.currentTarget);var a=b.data("smileyCode");var c=b.data("smileyPath");this._redactor.wbbcode.insertSmiley(a,c,true)}});WCF.Message.QuickReply=Class.extend({_container:null,_messageField:null,_notification:null,_pendingSave:false,_proxy:null,_quickReplyButtons:null,_quoteManager:null,_scrollHandler:null,_successMessageNonVisible:"",init:function(d,b){this._container=$("#messageQuickReply");this._container.children(".message").addClass("jsInvalidQuoteTarget");this._messageField=$("#text");this._pendingSave=false;if(!this._container||!this._messageField){return}var a=this._container.find(".formSubmit");var c=a.find("button[data-type=save]").removeAttr("accesskey").click($.proxy(this._save,this));if(d){a.find("button[data-type=extended]").click($.proxy(this._prepareExtended,this))}a.find("button[data-type=cancel]").click($.proxy(this._cancel,this));if(b){this._quoteManager=b}this._quickReplyButtons=$(".jsQuickReply").data("__api",this).click($.proxy(this.click,this));this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),showLoadingOverlay:false,success:$.proxy(this._success,this)});this._scroll=new WCF.Effect.Scroll();this._notification=new WCF.System.Notification(WCF.Language.get("wcf.global.success.add"));this._successMessageNonVisible="";WCF.System.Event.addListener("com.woltlab.wcf.redactor","submitEditor_text",function(e){e.cancel=true;c.trigger("click")})},click:function(b){this._container.toggle();if(this._container.is(":visible")){this._quickReplyButtons.each(function(){var c=$(this);if(c.parent()[0].tagName==="LI"){c.parent().hide()}else{c.hide()}});setTimeout((function(){$(document).trigger("resize");if(!$.browser.mobile||!$.browser.chrome){this._scroll.scrollTo(this._container,true)}}).bind(this),100);WCF.Message.Submit.registerButton("text",this._container.find(".formSubmit button[data-type=save]"));if(this._quoteManager){var a=true;if($.browser.redactor){if(this._messageField.data("redactor")){this._editorCallback(this._messageField.redactor("wutil.isEmptyEditor"))}}else{a=(!this._messageField.val().length);this._editorCallback(a)}}}if(b!==null){b.stopPropagation();return false}},_editorCallback:function(a){if(a){this._quoteManager.insertQuotes(this._getClassName(),this._getObjectID(),$.proxy(this._insertQuotes,this))}if($.browser.redactor){this._messageField.redactor("wutil.selectionEndOfEditor")}else{this._messageField.focus()}},getContainer:function(){return this._container},_insertQuotes:function(b){if(!b.returnValues.template){return}if($.browser.redactor){var a=WCF.String.unescapeHTML(b.returnValues.template);a=this._messageField.redactor("wbbcode.convertToHtml",a);a=a.replace(/<p><blockquote/,"<blockquote");a=a.replace(/blockquote><\/p>/,"blockquote>");this._messageField.redactor("focus.setEnd");this._messageField.redactor("wutil.insertDynamic",a,b.returnValues.template);this._messageField.redactor("wutil.selectionEndOfEditor");this._messageField.redactor("wbbcode.observeQuotes")}else{this._messageField.val(b.returnValues.template)}},_save:function(){if(this._pendingSave){return}var a="";if($.browser.redactor){a=this._messageField.redactor("wutil.getText")}else{a=$.trim(this._messageField.val())}var d=this._messageField.parent().find("small.innerError");if(a===""||a==="0"){if(!d.length){d=$('<small class="innerError" />').appendTo(this._messageField.parent())}d.html(WCF.Language.get("wcf.global.form.error.empty"));return}else{d.remove()}this._pendingSave=true;this._proxy.setOption("data",{actionName:"quickReply",className:this._getClassName(),interfaceName:"wcf\\data\\IMessageQuickReplyAction",parameters:this._getParameters(a)});this._proxy.sendRequest();var b=this._container.find(".messageQuickReplyContent .messageBody");$('<span class="icon icon48 icon-spinner" />').appendTo(b);var c=b.children(".redactor-box").hide();c.next().hide();b.next().hide()},_getParameters:function(b){var a={objectID:this._getObjectID(),data:{message:b},lastPostTime:this._container.data("lastPostTime"),pageNo:this._container.data("pageNo"),removeQuoteIDs:(this._quoteManager===null?[]:this._quoteManager.getQuotesMarkedForRemoval())};if(this._container.data("anchor")){a.anchor=this._container.data("anchor")}WCF.System.Event.fireEvent("com.woltlab.wcf.messageOptionsInline","submit_"+this._messageField.wcfIdentify(),a.data);return a},_cancel:function(){this._revertQuickReply(true);if($.browser.redactor){this._messageField.redactor("wutil.reset")}else{this._messageField.val("")}},_revertQuickReply:function(b){var a=this._container.find(".messageQuickReplyContent .messageBody");if(b){this._container.hide();a.children("small.innerError").remove()}a.children(".icon-spinner").remove();a.children(".redactor-box").show().next().show();a.next().show();this._quickReplyButtons.each(function(){var c=$(this);if(c.parent()[0].tagName==="LI"){c.parent().show()}else{c.show()}})},_prepareExtended:function(){this._pendingSave=true;if(this._quoteManager!==null){this._quoteManager.markQuotesForRemoval()}var a="";if($.browser.redactor){a=this._messageField.redactor("wutil.getText");if(a.length){this._messageField.redactor("wutil.saveTextToStorage",true)}else{this._messageField.redactor("wutil.autosavePurge")}}else{a=$.trim(this._messageField.val())}var b={containerID:this._getObjectID(),message:a};WCF.System.Event.fireEvent("com.woltlab.wcf.messageOptionsInline","prepareExtended_"+this._messageField.wcfIdentify(),b);new WCF.Action.Proxy({autoSend:true,data:{actionName:"jumpToExtended",className:this._getClassName(),interfaceName:"wcf\\data\\IExtendedMessageQuickReplyAction",parameters:b},success:(function(c){this._messageField.redactor("wutil.saveTextToStorage");window.location=c.returnValues.url}).bind(this)})},_success:function(c,d,b){if($.browser.redactor){this._messageField.redactor("wutil.autosavePause");this._messageField.redactor("wutil.autosavePurge")}if(c.returnValues.url){window.location=c.returnValues.url}else{if(c.returnValues.template){var a=$(""+c.returnValues.template);if(this._container.data("sortOrder")=="DESC"){a.insertAfter(this._container)}else{a.insertBefore(this._container)}this._container.data("lastPostTime",c.returnValues.lastPostTime);this._notification.show(undefined,undefined,WCF.Language.get("wcf.global.success.add"));this._updateHistory(a.wcfIdentify())}else{var a=(this._successMessageNonVisible)?this._successMessageNonVisible:"wcf.global.success.add";this._notification.show(undefined,5000,WCF.Language.get(a))}if($.browser.redactor){this._messageField.redactor("wutil.reset");this._messageField.redactor("wutil.autosaveResume")}else{this._messageField.val("")}this._revertQuickReply(true);if(this._quoteManager!==null){this._quoteManager.countQuotes()}this._pendingSave=false}},_failure:function(b){this._pendingSave=false;this._revertQuickReply(false);if(b===null||b.returnValues===undefined||b.returnValues.errorType===undefined){return true}var a=this._container.find(".messageQuickReplyContent .messageBody");var c=a.children("small.innerError").empty();if(!c.length){c=$('<small class="innerError" />').appendTo(a)}c.html(b.returnValues.errorType);return false},_getClassName:function(){return""},_getObjectID:function(){return 0},_updateHistory:function(a){window.location.hash=a}});WCF.Message.InlineEditor=Class.extend({_activeElementID:"",_container:{},_containerID:0,_dropdowns:{},_messageContainerSelector:".jsMessage",_messageEditorIDPrefix:"messageEditor",_notification:null,_proxy:null,_quoteManager:null,_supportExtendedForm:false,init:function(a,c,b){this._activeElementID="";this._container={};this._containerID=parseInt(a);this._dropdowns={};this._quoteManager=b||null;this._supportExtendedForm=(c)?true:false;this._proxy=new WCF.Action.Proxy({failure:$.proxy(this._failure,this),showLoadingOverlay:false,success:$.proxy(this._success,this)});this._notification=new WCF.System.Notification(WCF.Language.get("wcf.global.success.edit"));this.initContainers();WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.InlineEditor",$.proxy(this.initContainers,this))},initContainers:function(){$(this._messageContainerSelector).each($.proxy(function(b,a){var e=$(a);var c=e.wcfIdentify();if(!this._container[c]){this._container[c]=e;if(e.data("canEditInline")){var d=e.find(".jsMessageEditButton:eq(0)").data("containerID",c).click($.proxy(this._clickInline,this));if(e.data("canEdit")){d.dblclick($.proxy(this._click,this))}}else{if(e.data("canEdit")){e.find(".jsMessageEditButton:eq(0)").data("containerID",c).click($.proxy(this._click,this))}}}},this))},_click:function(c,a){var b=(c===null)?a:$(c.currentTarget).data("containerID");if(this._activeElementID===""){this._activeElementID=b;this._prepare();this._proxy.setOption("data",{actionName:"beginEdit",className:this._getClassName(),interfaceName:"wcf\\data\\IMessageInlineEditorAction",parameters:{containerID:this._containerID,objectID:this._container[b].data("objectID")}});this._proxy.setOption("failure",$.proxy(function(){this._cancel()},this));this._proxy.sendRequest()}else{var d=new WCF.System.Notification(WCF.Language.get("wcf.message.error.editorAlreadyInUse"),"warning");d.show()}if(this._dropdowns[this._container[b].data("objectID")]){this._dropdowns[this._container[b].data("objectID")].removeClass("dropdownOpen")}if(c!==null){c.stopPropagation();return false}},_clickInline:function(c){var d=$(c.currentTarget);if(!d.hasClass("dropdownToggle")){var b=d.data("containerID");d.addClass("dropdownToggle").parent().addClass("dropdown");var a=$('<ul class="dropdownMenu" />').insertAfter(d);this._initDropdownMenu(b,a);WCF.DOMNodeInsertedHandler.execute();this._dropdowns[this._container[b].data("objectID")]=a;WCF.Dropdown.registerCallback(d.parent().wcfIdentify(),$.proxy(this._toggleDropdown,this));d.trigger("click")}c.stopPropagation();return false},_failure:function(b){this._revertEditor();if(b===null||b.returnValues===undefined||b.returnValues.errorType===undefined){return true}var a=this._container[this._activeElementID].find(".messageBody .messageInlineEditor");var c=a.children("small.innerError").empty();if(!c.length){c=$('<small class="innerError" />').insertBefore(a.children(".formSubmit"))}c.html(b.returnValues.errorType);return false},_toggleDropdown:function(a,b){WCF.Dropdown.getDropdown(a).parents(".messageOptions").toggleClass("forceOpen")},_initDropdownMenu:function(a,b){},_prepare:function(){var b=this._container[this._activeElementID].find(".messageBody");$('<span class="icon icon48 icon-spinner" />').appendTo(b);var a=b.find(".messageText").hide();a.parent().children(".jsInlineEditorHideContent").hide();b.children(".attachmentThumbnailList, .attachmentFileList").hide()},_cancel:function(){var b=this._container[this._activeElementID].removeClass("jsInvalidQuoteTarget");this._destroyEditor();var a=b.find(".messageBody");a.children(".icon-spinner").remove();a.find(".messageText").show();a.children(".attachmentThumbnailList, .attachmentFileList").show();a.find(".jsInlineEditorHideContent").show();this._container[this._activeElementID].find(".messageOptions").removeClass("forceHidden");this._activeElementID="";if(this._quoteManager){this._quoteManager.clearAlternativeEditor()}},_success:function(b,c,a){switch(b.returnValues.actionName){case"beginEdit":this._showEditor(b);break;case"save":this._showMessage(b);break}},_showEditor:function(g){this._proxy.setOption("failure",$.proxy(this._failure,this));var e=this._messageEditorIDPrefix+this._container[this._activeElementID].data("objectID");var d=this._container[this._activeElementID].addClass("jsInvalidQuoteTarget").find(".messageBody");d.children(".icon-spinner").remove();var c=d.children("div:eq(0)");$(""+g.returnValues.template).appendTo(c);var b=c.find(".formSubmit");var f=b.find("button[data-type=save]").click($.proxy(this._save,this));if(this._supportExtendedForm){b.find("button[data-type=extended]").click($.proxy(this._prepareExtended,this))}b.find("button[data-type=cancel]").click($.proxy(this._cancel,this));WCF.Message.Submit.registerButton(this._messageEditorIDPrefix+this._container[this._activeElementID].data("objectID"),f);WCF.System.Event.addListener("com.woltlab.wcf.redactor","submitEditor_"+e,function(h){h.cancel=true;f.trigger("click")});this._container[this._activeElementID].find(".messageOptions").addClass("forceHidden");var a=$("#"+e);if($.browser.redactor){new WCF.PeriodicalExecuter($.proxy(function(h){h.stop();if(this._quoteManager){this._quoteManager.setAlternativeEditor(a)}new WCF.Effect.Scroll().scrollTo(this._container[this._activeElementID],true)},this),250)}else{a.focus()}},_revertEditor:function(){var a=this._container[this._activeElementID].removeClass("jsInvalidQuoteTarget").find(".messageBody");a.children("span.icon-spinner").remove();a.children("div:eq(0)").children(":not(.messageText)").show();a.children(".attachmentThumbnailList, .attachmentFileList").show();a.find(".jsInlineEditorHideContent").show();if(this._quoteManager){this._quoteManager.clearAlternativeEditor()}},_save:function(){var d=this._container[this._activeElementID];var c=d.data("objectID");var a="";if($.browser.redactor){a=$("#"+this._messageEditorIDPrefix+c).redactor("wutil.getText")}else{a=$("#"+this._messageEditorIDPrefix+c).val()}var b={containerID:this._containerID,data:{message:a},objectID:c,removeQuoteIDs:(this._quoteManager===null?[]:this._quoteManager.getQuotesMarkedForRemoval())};WCF.System.Event.fireEvent("com.woltlab.wcf.messageOptionsInline","submit_"+this._messageEditorIDPrefix+c,b);this._proxy.setOption("data",{actionName:"save",className:this._getClassName(),interfaceName:"wcf\\data\\IMessageInlineEditorAction",parameters:b});this._proxy.sendRequest();this._hideEditor()},_prepareExtended:function(){var c=this._container[this._activeElementID];var b=c.data("objectID");var a="";if($.browser.redactor){a=$("#"+this._messageEditorIDPrefix+b).redactor("wutil.getText")}else{a=$("#"+this._messageEditorIDPrefix+b).val()}new WCF.Action.Proxy({autoSend:true,data:{actionName:"jumpToExtended",className:this._getClassName(),parameters:{containerID:this._containerID,message:a,messageID:b}},success:function(e,f,d){window.location=e.returnValues.url}})},_hideEditor:function(){var a=this._container[this._activeElementID].removeClass("jsInvalidQuoteTarget").find(".messageBody");$('<span class="icon icon48 icon-spinner" />').appendTo(a);a.children("div:eq(0)").children().hide();a.children(".attachmentThumbnailList, .attachmentFileList").show();a.find(".jsInlineEditorHideContent").show();if(this._quoteManager){this._quoteManager.clearAlternativeEditor()}},_showMessage:function(c){var d=this._container[this._activeElementID].removeClass("jsInvalidQuoteTarget");var b=d.find(".messageBody");b.children(".icon-spinner").remove();var a=b.children("div:eq(0)");a.parent().children(".jsInlineEditorHideContent").show();this._container[this._activeElementID].find(".messageOptions").removeClass("forceHidden");this._destroyEditor();a.children(".messageText").html(c.returnValues.message).show();if(c.returnValues.attachmentList==undefined){b.children(".attachmentThumbnailList, .attachmentFileList").show()}else{b.children(".attachmentThumbnailList, .attachmentFileList").remove();if(c.returnValues.attachmentList){$(c.returnValues.attachmentList).insertAfter(b.children("div:eq(0)"))}}this._activeElementID="";this._updateHistory(this._getHash(d.data("objectID")));this._notification.show();if(this._quoteManager){this._quoteManager.clearAlternativeEditor();this._quoteManager.countQuotes()}},_destroyEditor:function(){var b=this._container[this._activeElementID];if($.browser.redactor){var a=$("#"+this._messageEditorIDPrefix+b.data("objectID"));a.redactor("wutil.autosavePause");a.redactor("wutil.autosavePurge");a.redactor("core.destroy")}b.find(".messageBody > div > .messageInlineEditor").remove();WCF.System.Event.removeAllListeners("com.woltlab.wcf.messageOptionsInline","submit_"+this._messageEditorIDPrefix+b.data("objectID"))},_getClassName:function(){return""},_getHash:function(a){return"#message"+a},_updateHistory:function(a){window.location.hash=a}});WCF.Message.Submit={_buttons:{},registerButton:function(b,a){if(!WCF.Browser.isChrome()){return}this._buttons[b]=$(a)},execute:function(a){if(!this._buttons[a]){return}this._buttons[a].trigger("click")}};WCF.Message.Quote={};WCF.Message.Quote.Handler=Class.extend({_activeContainerID:"",_className:"",_containers:{},_containerSelector:"",_copyQuote:null,_message:"",_messageBodySelector:"",_objectID:0,_objectType:"",_proxy:null,_quoteManager:null,init:function(e,d,b,a,c,f,g){this._className=d;if(this._className==""){console.debug("[WCF.Message.QuoteManager] Empty class name given, aborting.");return}this._objectType=b;if(this._objectType==""){console.debug("[WCF.Message.QuoteManager] Empty object type name given, aborting.");return}this._containerSelector=a;this._message="";this._messageBodySelector=c;this._messageContentSelector=f;this._objectID=0;this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._initContainers();g=(g&&e.supportPaste())?true:false;this._initCopyQuote(g);$(document).mouseup($.proxy(this._mouseUp,this));this._quoteManager=e;this._quoteManager.register(this._objectType,this);WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.Quote.Handler"+b.hashCode(),$.proxy(this._initContainers,this))},_initContainers:function(){var a=this;$(this._containerSelector).each(function(c,b){var e=$(b);var d=e.wcfIdentify();if(!a._containers[d]){a._containers[d]=e;if(e.hasClass("jsInvalidQuoteTarget")){return true}if(a._messageBodySelector!==null){e=e.find(a._messageBodySelector).data("containerID",d)}e.mousedown($.proxy(a._mouseDown,a));a._containers[d].find(".jsQuoteMessage").click($.proxy(a._saveFullQuote,a))}})},_mouseDown:function(b){this._copyQuote.hide();var c=$(b.currentTarget);if(this._messageBodySelector){c=this._containers[c.data("containerID")]}if(c.hasClass("jsInvalidQuoteTarget")){this._activeContainerID="";return}else{var a=b.target;while(a!==c[0]){if(a.tagName==="BLOCKQUOTE"){this._activeContainerID="";return}a=a.parentElement}}this._activeContainerID=c.wcfIdentify();if($.browser.mozilla){c.find("img").each(function(){var d=$(this);d.data("__alt",d.attr("alt")).removeAttr("alt")})}},_getNodeText:function(e){var a=function(f){switch(f.tagName){case"BLOCKQUOTE":case"H3":case"SCRIPT":return NodeFilter.FILTER_REJECT;break;default:return NodeFilter.FILTER_ACCEPT;break}};a.acceptNode=a;var b=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,a,true);var d="";while(b.nextNode()){var c=b.currentNode;if(c.nodeType===Node.ELEMENT_NODE){switch(c.tagName){case"BR":case"LI":case"UL":d+="\n";break;case"TD":if(!$.browser.msie){d+="\n"}break}}else{d+=c.nodeValue.replace(/\n/g,"")}}return d},_mouseUp:function(a){if(this._activeContainerID==""){this._copyQuote.hide();return}var l=this._containers[this._activeContainerID];var e=this._getSelectedText();var h=$.trim(e);if(h==""){this._copyQuote.hide();return}var c=(this._messageBodySelector)?l.find(this._messageContentSelector)[0]:l[0];var j=a.target;while(j!==l[0]){if(j===null||j.tagName==="BLOCKQUOTE"){this._copyQuote.hide();return}j=j.parentElement}var d=window.getSelection().getRangeAt(0);if(!this._elementInsideContainer(d.startContainer,c)||!this._elementInsideContainer(d.endContainer,c)){this._copyQuote.hide();return}var f=this._getNodeText(c);if(this._normalize(f).indexOf(this._normalize(h))===-1){return}this._copyQuote.show();var i=this._getBoundingRectangle(l,window.getSelection());var g=this._copyQuote.getDimensions("outer");var b=(i.right-i.left)/2-(g.width/2)+i.left;this._copyQuote.css({top:i.top-g.height-7+"px",left:b+"px"});this._copyQuote.hide();this._activeContainerID="";var k=this;new WCF.PeriodicalExecuter(function(m){m.stop();var n=$.trim(k._getSelectedText());if(n!=""){k._copyQuote.show();k._message=n;k._objectID=l.data("objectID");if($.browser.mozilla){l.find("img").each(function(){var o=$(this);o.attr("alt",o.data("__alt"))})}}},10)},_elementInsideContainer:function(b,a){if(b.nodeType===Node.TEXT_NODE){b=b.parentNode}while(b){if(b===a){return true}b=b.parentNode}return false},_normalize:function(a){return a.replace(/\r?\n|\r/g,"\n").replace(/\s/g," ").replace(/\s{2,}/g," ")},_getOffset:function(c,d){c.collapse(d);var f=WCF.getRandomID();var a=document.createElement("span");a.innerHTML='<span id="'+f+'"></span>';var g=document.createDocumentFragment(),b;while(b=a.firstChild){g.appendChild(b)}c.insertNode(g);a=$("#"+f);var e=a.offset();e.top=e.top-$(window).scrollTop();a.remove();return e},_getBoundingRectangle:function(a,d){var c=null;if(document.createRange&&typeof document.createRange().getBoundingClientRect!="undefined"){if(d.rangeCount>0){var b=d.getRangeAt(0).getBoundingClientRect();c={left:b.left,right:b.right,top:b.top+$(document).scrollTop()}}}else{if(document.selection&&document.selection.type!="Control"){var e=document.selection.createRange();c={left:e.boundingLeft,right:e.boundingRight,top:e.boundingTop}}}return c},_saveSelection:function(d){if(window.getSelection&&document.createRange){var c=window.getSelection().getRangeAt(0);var b=c.cloneRange();b.selectNodeContents(d);b.setEnd(c.startContainer,c.startOffset);var f=b.toString().length;return{start:f,end:f+c.toString().length}}else{var a=document.selection.createRange();var e=document.body.createTextRange();e.moveToElementText(d);e.setEndPoint("EndToStart",a);var f=e.text.length;return{start:f,end:f+a.text.length}}},_restoreSelection:function(j,k){if(window.getSelection&&document.createRange){var a=0,g=document.createRange();g.setStart(j,0);g.collapse(true);var f=[j],c,d=false,l=false;while(!l&&(c=f.pop())){if(c.nodeType==Node.TEXT_NODE){var h=a+c.length;if(!d&&k.start>=a&&k.start<=h){g.setStart(c,k.start-a);d=true}if(d&&k.end>=a&&k.end<=h){g.setEnd(c,k.end-a);l=true}a=h}else{var e=c.childNodes.length;while(e--){f.push(c.childNodes[e])}}}var b=window.getSelection();b.removeAllRanges();b.addRange(g)}else{var m=document.body.createTextRange();m.moveToElementText(j);m.collapse(true);m.moveEnd("character",k.end);m.moveStart("character",k.start);m.select()}},_initCopyQuote:function(b){this._copyQuote=$("#quoteManagerCopy");if(!this._copyQuote.length){this._copyQuote=$('<div id="quoteManagerCopy" class="balloonTooltip"><span class="jsQuoteManagerStore">'+WCF.Language.get("wcf.message.quote.quoteSelected")+'</span><span class="pointer"><span></span></span></div>').hide().appendTo(document.body);var a=this._copyQuote.children("span.jsQuoteManagerStore").click($.proxy(this._saveQuote,this));if(b){$('<span class="jsQuoteManagerQuoteAndInsert">'+WCF.Language.get("wcf.message.quote.quoteAndReply")+"</span>").click($.proxy(this._saveAndInsertQuote,this)).insertAfter(a)}}},_getSelectedText:function(){var a=window.getSelection();if(a.rangeCount){return this._getNodeText(a.getRangeAt(0).cloneContents())}return""},_saveFullQuote:function(b){var a=$(b.currentTarget);this._proxy.setOption("data",{actionName:"saveFullQuote",className:this._className,interfaceName:"wcf\\data\\IMessageQuoteAction",objectIDs:[a.data("objectID")]});this._proxy.sendRequest();if(a.data("isQuoted")){a.data("isQuoted",false).children("a").removeClass("active")}else{a.data("isQuoted",true).children("a").addClass("active")}var c=a.parents(".buttonGroupNavigation");if(c.hasClass("jsMobileButtonGroupNavigation")){c.children(".dropdownLabel").trigger("click")}b.stopPropagation();return false},_saveQuote:function(a){a=(a===true)?true:false;this._proxy.setOption("data",{actionName:"saveQuote",className:this._className,interfaceName:"wcf\\data\\IMessageQuoteAction",objectIDs:[this._objectID],parameters:{message:this._message,renderQuote:a}});this._proxy.sendRequest()},_saveAndInsertQuote:function(){this._saveQuote(true)},_success:function(c,d,b){if(c.returnValues.count!==undefined){if(c.returnValues.fullQuoteMessageIDs!==undefined){c.returnValues.fullQuoteObjectIDs=c.returnValues.fullQuoteMessageIDs}var a=(c.returnValues.fullQuoteObjectIDs!==undefined)?c.returnValues.fullQuoteObjectIDs:{};this._quoteManager.updateCount(c.returnValues.count,a)}switch(c.actionName){case"saveQuote":case"saveFullQuote":if(c.returnValues.renderedQuote){WCF.System.Event.fireEvent("com.woltlab.wcf.message.quote","insert",{forceInsert:(c.actionName==="saveQuote"?true:false),quote:c.returnValues.renderedQuote})}break}},updateFullQuoteObjectIDs:function(b){for(var a in this._containers){this._containers[a].find(".jsQuoteMessage").each(function(c,d){var e=$(d).data("isQuoted",0);e.children("a").removeClass("active");if(WCF.inArray(e.data("objectID"),b)){e.data("isQuoted",1).children("a").addClass("active")}})}}});WCF.Message.Quote.Manager=Class.extend({_buttons:{},_count:0,_dialog:null,_editorElement:null,_editorElementAlternative:null,_form:null,_handlers:{},_hasTemplate:false,_insertQuotes:true,_proxy:null,_removeOnSubmit:[],_showQuotes:null,_supportPaste:false,init:function(c,a,b,d){this._buttons={insert:null,remove:null};this._count=parseInt(c)||0;this._dialog=null;this._editorElement=null;this._editorElementAlternative=null;this._form=null;this._handlers={};this._hasTemplate=false;this._insertQuotes=true;this._removeOnSubmit=[];this._showQuotes=null;this._supportPaste=false;if(a){this._editorElement=$("#"+a);if(this._editorElement.length){this._supportPaste=true;this._form=this._editorElement.parents("form:eq(0)");if(this._form.length){this._form.submit($.proxy(this._submit,this));this._removeOnSubmit=d||[]}else{this._form=null;this._supportPaste=(b===true)?true:false}}}this._proxy=new WCF.Action.Proxy({showLoadingOverlay:false,success:$.proxy(this._success,this),url:"index.php/MessageQuote/?t="+SECURITY_TOKEN+SID_ARG_2ND});this._toggleShowQuotes();WCF.System.Event.addListener("com.woltlab.wcf.message.quote","insert",(function(e){this._insertQuote(null,undefined,e)}).bind(this))},setAlternativeEditor:function(a){this._editorElementAlternative=a},clearAlternativeEditor:function(){this._editorElementAlternative=null},register:function(a,b){this._handlers[a]=b},updateCount:function(d,c){this._count=parseInt(d)||0;this._toggleShowQuotes();for(var a in this._handlers){var b=c[a]||[];this._handlers[a].updateFullQuoteObjectIDs(b)}},insertQuotes:function(a,b,c){if(!this._insertQuotes){this._insertQuotes=true;return}new WCF.Action.Proxy({autoSend:true,data:{actionName:"getRenderedQuotes",className:a,interfaceName:"wcf\\data\\IMessageQuoteAction",parameters:{parentObjectID:b}},success:c})},_toggleShowQuotes:function(){if(!this._count){if(this._showQuotes!==null){this._showQuotes.hide()}}else{if(this._showQuotes===null){this._showQuotes=$("#showQuotes");if(!this._showQuotes.length){this._showQuotes=$('<div id="showQuotes" class="balloonTooltip" />').click($.proxy(this._click,this)).appendTo(document.body)}}var a=WCF.Language.get("wcf.message.quote.showQuotes").replace(/#count#/,this._count);this._showQuotes.text(a).show()}this._hasTemplate=false},_click:function(){if(this._hasTemplate){this._dialog.wcfDialog("open")}else{this._proxy.showLoadingOverlayOnce();this._proxy.setOption("data",{actionName:"getQuotes",supportPaste:this._supportPaste});this._proxy.sendRequest()}},renderDialog:function(c){if(this._dialog===null){this._dialog=$("#messageQuoteList");if(!this._dialog.length){this._dialog=$('<div id="messageQuoteList" />').hide().appendTo(document.body)}}this._dialog.html(c);var a=$('<div class="formSubmit" />').appendTo(this._dialog);if(this._supportPaste){this._buttons.insert=$('<button class="buttonPrimary">'+WCF.Language.get("wcf.message.quote.insertAllQuotes")+"</button>").click($.proxy(this._insertSelected,this)).appendTo(a)}this._buttons.remove=$("<button>"+WCF.Language.get("wcf.message.quote.removeAllQuotes")+"</button>").click($.proxy(this._removeSelected,this)).appendTo(a);this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.quote.manageQuotes")});this._dialog.wcfDialog("render");this._hasTemplate=true;var d=this._dialog.find(".jsInsertQuote");if(this._supportPaste){d.click($.proxy(this._insertQuote,this))}else{d.hide()}this._dialog.find("input.jsCheckbox").change($.proxy(this._changeButtons,this));if(this._removeOnSubmit.length){var b=this;this._dialog.find("input.jsRemoveQuote").each(function(f,e){var g=$(e).change($.proxy(this._change,this));if(WCF.inArray(g.parent("li").attr("data-quote-id"),b._removeOnSubmit)){g.attr("checked","checked")}})}},_changeButtons:function(){if(this._dialog.find("input.jsCheckbox:checked").length){if(this._supportPaste){this._buttons.insert.html(WCF.Language.get("wcf.message.quote.insertSelectedQuotes"))}this._buttons.remove.html(WCF.Language.get("wcf.message.quote.removeSelectedQuotes"))}else{if(this._supportPaste){this._buttons.insert.html(WCF.Language.get("wcf.message.quote.insertAllQuotes"))}this._buttons.remove.html(WCF.Language.get("wcf.message.quote.removeAllQuotes"))}},_change:function(c){var d=$(c.currentTarget);var b=d.parent("li").attr("data-quote-id");if(d.prop("checked")){this._removeOnSubmit.push(b)}else{for(var a in this._removeOnSubmit){if(this._removeOnSubmit[a]==b){delete this._removeOnSubmit[a];break}}}},_insertSelected:function(){if(this._editorElementAlternative===null){var a=$(".jsQuickReply:eq(0)").data("__api");if(a&&!a.getContainer().is(":visible")){this._insertQuotes=false;a.click(null)}}if(!this._dialog.find("input.jsCheckbox:checked").length){this._dialog.find("input.jsCheckbox").prop("checked","checked")}this._dialog.find("input.jsCheckbox:checked").each($.proxy(function(c,b){this._insertQuote(null,b)},this));this._dialog.wcfDialog("close")},_insertQuote:function(b,l,e){var i=null,m,a,h;if(e===undefined){i=(b===null)?$(l).parents("li"):$(b.currentTarget).parents("li");m=$.trim(i.children("div.jsFullQuote").text());var g=i.parents("article.message");a=g.attr("data-username");h=g.data("link")}else{m=e.quote.text;a=e.quote.username;h=e.quote.link}if($.browser.redactor){if(this._editorElementAlternative===null){var k=true;if(b!==null||e!==null){var d=$(".jsQuickReply:eq(0)").data("__api");if(d&&!d.getContainer().is(":visible")){if(e.forceInsert){this._insertQuotes=false;d.click(null)}else{k=false}}}if(k&&this._editorElement.length){this._editorElement.redactor("wbbcode.insertQuoteBBCode",a,h,m,m)}}else{this._editorElementAlternative.redactor("wbbcode.insertQuoteBBCode",a,h,m,m)}}else{m="[quote='"+a+"','"+h+"']"+m+"[/quote]";var f=(this._editorElementAlternative===null)?this._editorElement:this._editorElementAlternative;var j=f.val();m+="\n\n";if(j.length==0){f.val(m)}else{var c=f.getCaret();f.val(j.substr(0,c)+m+j.substr(c))}}if(i!==null){this._removeOnSubmit.push(i.attr("data-quote-id"))}if(b!==null){this._dialog.wcfDialog("close")}},_removeSelected:function(){if(!this._dialog.find("input.jsCheckbox:checked").length){this._dialog.find("input.jsCheckbox").prop("checked","checked")}var b=[];this._dialog.find("input.jsCheckbox:checked").each(function(e,d){b.push($(d).parents("li").attr("data-quote-id"))});if(b.length){var c=[];for(var a in this._handlers){c.push(a)}this._proxy.setOption("data",{actionName:"remove",getFullQuoteObjectIDs:this._handlers.length>0,objectTypes:c,quoteIDs:b});this._proxy.sendRequest();this._dialog.wcfDialog("close")}},_submit:function(){if(this._supportPaste&&this._removeOnSubmit.length>0){var a=this._form.find(".formSubmit");for(var b in this._removeOnSubmit){$('<input type="hidden" name="__removeQuoteIDs[]" value="'+this._removeOnSubmit[b]+'" />').appendTo(a)}}},getQuotesMarkedForRemoval:function(){return this._removeOnSubmit},markQuotesForRemoval:function(){if(this._removeOnSubmit.length){this._proxy.setOption("data",{actionName:"markForRemoval",quoteIDs:this._removeOnSubmit});this._proxy.suppressErrors();this._proxy.sendRequest()}},removeMarkedQuotes:function(){if(this._removeOnSubmit.length){this._proxy.setOption("data",{actionName:"removeMarkedQuotes",getFullQuoteObjectIDs:this._handlers.length>0});this._proxy.sendRequest()}},countQuotes:function(){var b=[];for(var a in this._handlers){b.push(a)}this._proxy.setOption("data",{actionName:"count",getFullQuoteObjectIDs:(b.length>0),objectTypes:b});this._proxy.sendRequest()},_success:function(c,d,b){if(c===null){return}if(c.count!==undefined){var a=(c.fullQuoteObjectIDs!==undefined)?c.fullQuoteObjectIDs:{};this.updateCount(c.count,a)}if(c.template!==undefined){if($.trim(c.template)==""){this.updateCount(0,{})}else{this.renderDialog(c.template)}}},supportPaste:function(){return this._supportPaste}});WCF.Message.Share={};WCF.Message.Share.Content=Class.extend({_cache:{},_dialog:null,init:function(){this._cache={};this._dialog=null;this._initLinks();WCF.DOMNodeInsertedHandler.addCallback("WCF.Message.Share.Content",$.proxy(this._initLinks,this))},_initLinks:function(){$("a.jsButtonShare").removeClass("jsButtonShare").click($.proxy(this._click,this))},_click:function(e){e.preventDefault();var a=$(e.currentTarget);var b=a.prop("href");var d=(a.data("linkTitle")?a.data("linkTitle"):b);var c=b.hashCode();if(this._cache[c]===undefined){var g=false;if(this._dialog===null){this._dialog=$("<div />").hide().appendTo(document.body);g=true}else{this._dialog.empty()}var f=$('<fieldset><legend><label for="__sharePermalink">'+WCF.Language.get("wcf.message.share.permalink")+"</label></legend></fieldset>").appendTo(this._dialog);$('<input type="text" id="__sharePermalink" class="long" readonly="readonly" />').attr("value",b).appendTo(f);var f=$('<fieldset><legend><label for="__sharePermalinkBBCode">'+WCF.Language.get("wcf.message.share.permalink.bbcode")+"</label></legend></fieldset>").appendTo(this._dialog);$('<input type="text" id="__sharePermalinkBBCode" class="long" readonly="readonly" />').attr("value","[url='"+b+"']"+d+"[/url]").appendTo(f);var f=$('<fieldset><legend><label for="__sharePermalinkHTML">'+WCF.Language.get("wcf.message.share.permalink.html")+"</label></legend></fieldset>").appendTo(this._dialog);$('<input type="text" id="__sharePermalinkHTML" class="long" readonly="readonly" />').attr("value",'<a href="'+b+'">'+WCF.String.escapeHTML(d)+"</a>").appendTo(f);this._cache[c]=this._dialog.html();if(g){this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.share")})}else{this._dialog.wcfDialog("open")}}else{this._dialog.html(this._cache[c]).wcfDialog("open")}this._enableSelection()},_enableSelection:function(){var a=this._dialog.find("input").click(function(){$(this).select()});if(navigator.userAgent.match(/iP(ad|hone|od)/)){a.keydown(function(){return false}).removeAttr("readonly").click(function(){this.setSelectionRange(0,9999)})}}});WCF.Message.Share.Page=Class.extend({_dialog:null,_fetchObjectCount:false,_pageDescription:"",_pageURL:"",_privacySettings:{},_provider:{},_proxy:null,init:function(a,b){this._dialog=null;this._fetchObjectCount=(a===true)?true:false;this._pageDescription=encodeURIComponent($('meta[property="og:title"]').prop("content"));this._pageURL=encodeURIComponent($('meta[property="og:url"]').prop("content"));this._privacySettings=$.extend({facebook:false,google:false,twitter:false,reddit:false},b||{});this._proxy=null;this._initProvider()},_initProvider:function(){var c=$(".messageShareButtons");var a=this;this._provider={facebook:{fetch:function(){a._fetchFacebook()},link:c.find(".jsShareFacebook"),share:function(){a._share("facebook","https://www.facebook.com/sharer.php?u={pageURL}&t={text}",true)}},google:{fetch:undefined,link:c.find(".jsShareGoogle"),share:function(){a._share("google","https://plus.google.com/share?url={pageURL}",true)}},reddit:{fetch:function(){a._fetchReddit()},link:c.find(".jsShareReddit"),share:function(){a._share("reddit","https://ssl.reddit.com/submit?url={pageURL}",true)}},twitter:{fetch:function(){a._fetchTwitter()},link:c.find(".jsShareTwitter"),share:function(){a._share("twitter","https://twitter.com/share?url={pageURL}&text={text}",false)}}};$.each(this._provider,function(e,d){if(a._privacySettings[e]){if(a._fetchObjectCount&&d.fetch){d.fetch()}}else{d.link.addClass("disabled")}d.link.data("provider",e).click($.proxy(a._click,a))});if(WCF.User.userID&&!c.find(".jsShowPrivacySettings").length){var b=$('<li class="jsShowPrivacySettings"><a><span class="icon icon32 fa-gear jsTooltip" title="'+WCF.Language.get("wcf.message.share.privacy")+'" /></a></li>');b.appendTo(c.children("ul")).children("a").click($.proxy(this._openPrivacySettings,this))}},_click:function(b){var a=$(b.currentTarget);var c=a.data("provider");if(a.hasClass("disabled")){if(WCF.User.userID){this._openPrivacySettings()}else{a.removeClass("disabled")}}else{this._provider[c].share()}},_openPrivacySettings:function(){if(this._proxy===null){this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)})}this._proxy.setOption("data",{actionName:"getSocialNetworkPrivacySettings",className:"wcf\\data\\user\\UserAction"});this._proxy.sendRequest()},_success:function(b,c,a){switch(b.actionName){case"getSocialNetworkPrivacySettings":this._renderDialog(b);break;case"saveSocialNetworkPrivacySettings":this._updatePrivacySettings(b);break}},_renderDialog:function(a){if(this._dialog===null){this._dialog=$("<div />").hide().appendTo(document.body);this._dialog.html(a.returnValues.template);this._dialog.wcfDialog({title:WCF.Language.get("wcf.message.share.privacy")})}else{this._dialog.html(a.returnValues.template);this._dialog.wcfDialog("open")}this._dialog.find("input[type=submit]").click($.proxy(this._save,this))},_save:function(){this._proxy.setOption("data",{actionName:"saveSocialNetworkPrivacySettings",className:"wcf\\data\\user\\UserAction",parameters:{facebook:(this._dialog.find("input[name=facebook]").is(":checked")),google:(this._dialog.find("input[name=google]").is(":checked")),reddit:(this._dialog.find("input[name=reddit]").is(":checked")),twitter:(this._dialog.find("input[name=twitter]").is(":checked"))}});this._proxy.sendRequest();this._dialog.wcfDialog("close")},_updatePrivacySettings:function(b){this._privacySettings=$.extend(this._privacySettings,b.returnValues.settings);var a=this;$.each(b.returnValues.settings,function(d,c){a._privacySettings[d]=(c)?true:false;if(c){a._provider[d].link.removeClass("disabled");if(a._fetchObjectCount&&a._provider[d].fetch){a._provider[d].fetch()}}else{a._provider[d].link.addClass("disabled")}});new WCF.System.Notification().show()},_share:function(c,a,b){window.open(a.replace(/{pageURL}/,this._pageURL).replace(/{text}/,this._pageDescription+(b?" "+this._pageURL:"")),c,"height=600,width=600")},_fetchCount:function(b,d,c){var a={autoSend:true,dataType:"jsonp",showLoadingOverlay:false,success:d,suppressErrors:true,type:"GET",url:b.replace(/{pageURL}/,this._pageURL)};if(c){a.jsonp=c}new WCF.Action.Proxy(a)},_fetchFacebook:function(){this._fetchCount("https://graph.facebook.com/?id={pageURL}",$.proxy(function(a){if(a.shares){this._provider.facebook.link.children("span.badge").show().text(a.shares)}},this))},_fetchTwitter:function(){if(window.location.protocol.match(/^https/)){return}this._fetchCount("http://urls.api.twitter.com/1/urls/count.json?url={pageURL}",$.proxy(function(a){if(a.count){this._provider.twitter.link.children("span.badge").show().text(a.count)}},this))},_fetchReddit:function(){if(window.location.protocol.match(/^https/)){return}this._fetchCount("http://www.reddit.com/api/info.json?url={pageURL}",$.proxy(function(a){if(a.data.children.length){this._provider.reddit.link.children("span.badge").show().text(a.data.children[0].data.score)}},this),"jsonp")}});WCF.Message.UserMention=Class.extend({_caretPosition:null,_className:"wcf\\data\\user\\UserAction",_dropdown:null,_dropdownMenu:null,_itemIndex:-1,_lineHeight:null,_mentionStart:"",_redactor:null,_timer:null,init:function(a){if($.browser.mobile&&$.browser.mozilla){return}this._textarea=$("#"+a);this._redactor=this._textarea.redactor("core.getObject");this._dropdown=this._textarea.redactor("core.getEditor");this._dropdownMenu=$('<ul class="dropdownMenu userSuggestionList" />').appendTo(this._textarea.parent());WCF.Dropdown.initDropdownFragment(this._dropdown,this._dropdownMenu);this._proxy=new WCF.Action.Proxy({autoAbortPrevious:true,success:$.proxy(this._success,this)});WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+a,$.proxy(this._keydown,this));WCF.System.Event.addListener("com.woltlab.wcf.redactor","keyup_"+a,$.proxy(this._keyup,this))},_clearList:function(){this._hideList();this._dropdownMenu.empty()},_click:function(a){if($.browser.mozilla&&this._caretPosition.startContainer.nodeName=="P"){var b=this._caretPosition.startContainer.childNodes[this._caretPosition.startOffset-1];this._caretPosition=document.createRange();this._caretPosition.selectNodeContents(b);this._caretPosition.collapse()}this._redactor.wutil.replaceRangesWith(this._caretPosition);this._setUsername($(a.currentTarget).data("username"))},_createListItem:function(c){var b=$("<li />").data("username",c.label).click($.proxy(this._click,this)).appendTo(this._dropdownMenu);var a=$("<div />").addClass("box16").appendTo(b);a.append($(c.icon).addClass("framed"));a.append($("<div />").append($("<span />").text(c.label)))},_getDropdownMenuPosition:function(){var e=getSelection().getRangeAt(0).cloneRange();var a=document.createRange();a.setStart(e.startContainer,e.startOffset-(this._mentionStart.length+1));a.setEnd(e.startContainer,e.startOffset);this._redactor.wutil.replaceRangesWith(a);var f=getSelection().getRangeAt(0);var b=f.getBoundingClientRect();var d=$(window);var c={top:Math.round(b.bottom)+d.scrollTop(),left:Math.round(b.left)+d.scrollLeft()};if(this._lineHeight===null){this._lineHeight=Math.round(b.bottom-b.top)}this._redactor.wutil.replaceRangesWith(e);this._caretPosition=e;return c},_setUsername:function(g){if(this._timer!==null){this._timer.stop();this._timer=null}this._proxy.abortPrevious();var e=getSelection().getRangeAt(0).cloneRange();this._redactor.buffer.set();var d=e.startContainer;var c=e.startOffset-(this._mentionStart.length+1);if(c<0){d=d.previousSibling;c=d.length-(this._mentionStart.length+1)-(e.startOffset-1)}var a=document.createRange();a.setStart(d,c);a.setEnd(e.startContainer,e.startOffset);this._redactor.wutil.replaceRangesWith(a);var f=getSelection().getRangeAt(0);f.deleteContents();f.collapse(true);if(g.indexOf("'")!==-1){g=g.replace(/'/g,"''")}g="'"+g+"'";var b=document.createTextNode("@"+g);f.insertNode(b);var a=document.createRange();a.setStart(b,g.length+1);a.setEnd(b,g.length+1);this._redactor.wutil.replaceRangesWith(a);this._hideList()},_getParameters:function(){return{data:{includeUserGroups:false,searchString:this._mentionStart}}},_getTextLineInFrontOfCaret:function(){if(this._redactor.selection.getHtml().length){return""}var f=getSelection().getRangeAt(0);if($.browser.mozilla&&f.startContainer.nodeType==3){f.startContainer.parentNode.normalize()}var c=f.startContainer.textContent.substr(0,f.startOffset);var a=c;c="";var b=false;for(var e=0;e<a.length;e++){var d=a.charCodeAt(e).toString(16);if(d!="200b"&&(!/\s/.test(a[e])||((d=="a0"||d=="20")&&!b))){if(d=="a0"||d=="20"){b=true}if(a[e]==="@"&&e&&/\s/.test(a[e-1])){b=false;c=""}c+=a[e]}else{b=false;c=""}}return c},_hideList:function(){this._dropdown.removeClass("dropdownOpen");this._dropdownMenu.removeClass("dropdownOpen");this._itemIndex=-1},_keydown:function(a){if(this._redactor.wutil.inPlainMode()){return}if(this._dropdownMenu.is(":visible")){switch(a.event.which){case $.ui.keyCode.ENTER:a.event.preventDefault();a.cancel=true;this._dropdownMenu.children("li").eq(this._itemIndex).trigger("click");break;case $.ui.keyCode.UP:a.cancel=true;a.event.preventDefault();this._selectItem(this._itemIndex-1);break;case $.ui.keyCode.DOWN:a.cancel=true;a.event.preventDefault();this._selectItem(this._itemIndex+1);break}}},_keyup:function(c){if(this._redactor.wutil.inPlainMode()){return true}if(this._timer!==null){this._timer.stop();this._timer=null}this._proxy.abortPrevious();if(c.event.which===$.ui.keyCode.ENTER){return}if(this._dropdownMenu.is(":visible")&&c.event.which in {13:1,38:1,40:1}){return}var b=this._getTextLineInFrontOfCaret();if(b){var a=b.match(/@([^,]{3,})$/);if(a){if(!a.index||b[a.index-1].match(/\s/)){this._mentionStart=a[1];if(this._timer!==null){this._timer.stop()}this._timer=new WCF.PeriodicalExecuter($.proxy(function(){this._proxy.setOption("data",{actionName:"getSearchResultList",className:this._className,interfaceName:"wcf\\data\\ISearchAction",parameters:this._getParameters()});this._proxy.sendRequest();this._timer.stop();this._timer=null},this),500)}}else{this._hideList()}}else{this._hideList()}},_selectItem:function(a){var b=this._dropdownMenu.children("li");if(a<0){a=b.length-1}else{if(a+1>b.length){a=0}}b.removeClass("dropdownNavigationItem");b.eq(a).addClass("dropdownNavigationItem");this._itemIndex=a},_showList:function(){this._dropdown.addClass("dropdownOpen");this._dropdownMenu.addClass("dropdownOpen")},_success:function(c,e,b){this._clearList(false);if($.getLength(c.returnValues)){for(var d in c.returnValues){var a=c.returnValues[d];this._createListItem(a)}this._updateSuggestionListPosition();this._showList()}},_updateSuggestionListPosition:function(){try{var b=this._getDropdownMenuPosition();b.top+=5;this._dropdownMenu.css(b);this._selectItem(0);if(b.top+this._dropdownMenu.outerHeight()+10>$(window).height()+$(document).scrollTop()){this._dropdownMenu.addClass("dropdownArrowBottom");this._dropdownMenu.css({top:b.top-this._dropdownMenu.outerHeight()-2*this._lineHeight+5})}else{this._dropdownMenu.removeClass("dropdownArrowBottom")}}catch(a){}}});$.widget("wcf.messageTabMenu",{_tabs:[],_tabsByName:{},options:{collapsible:true},_create:function(){var c=this.element.find("> nav > ul > li:not(.jsFlexibleMenuDropdown)");var b=this.element.find("> div, > fieldset");if(c.length!=b.length){console.debug("[wcf.messageTabMenu] Amount of tabs does not equal amount of tab containers, aborting.");return}var a=this.element.data("preselect");this._tabs=[];this._tabsByName={};for(var g=0;g<c.length;g++){var f=$(c[g]);var d=$(b[g]);var h=f.data("name");if(h===undefined){var i=f.children("a").prop("href");if(i!==undefined){if(i.match(/#([a-zA-Z_-]+)$/)){h=RegExp.$1}}if(h===undefined){h=f.wcfIdentify();console.debug("[wcf.messageTabMenu] Missing name attribute, assuming generic ID '"+h+"'")}}this._tabs.push({container:d,name:h,tab:f});this._tabsByName[h]=g;var j=f.children("a").data("index",g).click($.proxy(this._showTab,this));if(a==h){j.trigger("click")}}if(a===true&&this._tabs.length){this._tabs[0].tab.children("a").trigger("click")}var e=this.element.data("collapsible");if(e!==undefined){this.options.collapsible=e}},destroy:function(){$.Widget.prototype.destroy.apply(this,arguments);this.element.remove()},_showTab:function(f,c,d){var b=(f===null)?c:$(f.currentTarget).data("index");d=(!this.options.collapsible||d===true)?true:false;var a=null;for(var g=0;g<this._tabs.length;g++){var e=this._tabs[g];if(g==b){if(!e.tab.hasClass("active")){e.tab.addClass("active");e.container.addClass("active");a=e;continue}else{if(d===true){continue}}}e.tab.removeClass("active");e.container.removeClass("active")}if(f!==null){f.preventDefault();f.stopPropagation()}if(a!==null){this._trigger("show",{},{activeTab:a})}$(window).trigger("resize")},showTab:function(a,b){if(!$.isNumeric(a)){if(this._tabsByName[a]!==undefined){a=this._tabsByName[a]}}if(this._tabs[a]===undefined){console.debug("[wcf.messageTabMenu] Cannot locate tab identified by '"+a+"'");return}this._showTab(null,a,b)},getTab:function(a){if(this._tabsByName[a]!==undefined){return this._tabs[this._tabsByName[a]].tab}return null},getContainer:function(a){if(this._tabsByName[a]!==undefined){return this._tabs[this._tabsByName[a]].container}return null}}); })(this);
 
 // WCF.Poll.js
 (function (window, undefined) {"use strict";WCF.Poll={};WCF.Poll.Management=Class.extend({_container:null,_count:0,_inputSize:0,_maxOptions:0,init:function(a,c,d){this._count=0;this._maxOptions=d||-1;this._container=$("#"+a).children("ol:eq(0)");if(!this._container.length){console.debug("[WCF.Poll.Management] Invalid container id given, aborting.");return}c=c||[];this._createOptionList(c);$(window).resize($.proxy(this._resize,this));this._container.parents("form").submit($.proxy(this._submit,this));new WCF.Sortable.List(a,"",undefined,undefined,true);this._resize();var b=this;this._container.closest(".messageTabMenu").on("messagetabmenushow",function(e,f){if(f.activeTab.name=="poll"){b._resize()}})},_createOptionList:function(b){for(var d=0,c=b.length;d<c;d++){var a=b[d];this._createOption(a.optionValue,a.optionID)}this._createOption()},_createOption:function(f,d,c){f=f||"";d=parseInt(d)||0;c=c||null;var b=$('<li class="sortableNode" />').data("optionID",d);if(c===null){b.appendTo(this._container)}else{b.insertAfter(c)}var a=$('<span class="sortableButtonContainer" />').appendTo(b);$('<span class="icon icon16 icon-plus jsTooltip jsAddOption pointer" title="'+WCF.Language.get("wcf.poll.button.addOption")+'" />').click($.proxy(this._addOption,this)).appendTo(a);$('<span class="icon icon16 icon-remove jsTooltip jsDeleteOption pointer" title="'+WCF.Language.get("wcf.poll.button.removeOption")+'" />').click($.proxy(this._removeOption,this)).appendTo(a);var e=$('<input type="text" value="'+f+'" maxlength="255" />').css({width:this._inputSize+"px"}).keydown($.proxy(this._keyDown,this)).appendTo(b);if(c!==null){e.focus()}WCF.DOMNodeInsertedHandler.execute();this._count++;if(this._count===this._maxOptions){this._container.find("span.jsAddOption").removeClass("pointer").addClass("disabled")}},_keyDown:function(a){if(a.which!==13){return true}$(a.currentTarget).prev(".sortableButtonContainer").children(".jsAddOption").trigger("click");a.preventDefault();a.stopPropagation();return false},_addOption:function(b){if(this._count===this._maxOptions){return false}var a=$(b.currentTarget).parents("li");this._createOption(undefined,undefined,a)},_removeOption:function(a){$(a.currentTarget).parents("li").remove();this._count--;this._container.find("span.jsAddOption").addClass("pointer").removeClass("disabled");if(this._container.children("li").length==0){this._createOption()}},_resize:function(){var d=this._container.innerWidth();var c=this._container.children("li:eq(0)");var b=c.children(".sortableButtonContainer").outerWidth();var a=d-b;if(a!=this._inputSize){this._inputSize=a;this._container.find("li > input").css({width:this._inputSize+"px"})}},_submit:function(){var a=[];this._container.children("li").each(function(f,i){var h=$(i);var g=$.trim(h.children("input").val());if(g!=""){a.push({optionID:h.data("optionID"),optionValue:g})}});if(a.length){var b=this._container.parents("form").find(".formSubmit");for(var e=0,d=a.length;e<d;e++){var c=a[e];$('<input type="hidden" name="pollOptions['+e+']" />').val(c.optionID+"_"+c.optionValue).appendTo(b)}}}});WCF.Poll.Manager=Class.extend({_cache:{},_canViewParticipants:{},_canViewResult:{},_canVote:{},_inputElements:{},_participants:{},_polls:{},_proxy:null,init:function(a){var c=$(a);if(!c.length){console.debug("[WCF.Poll.Manager] Given selector '"+a+"' does not match, aborting.");return}this._cache={};this._canViewParticipants={};this._canViewResult={};this._inputElements={};this._participants={};this._polls={};this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this),url:"index.php/Poll/?t="+SECURITY_TOKEN+SID_ARG_2ND});var b=this;c.each(function(e,g){var f=$(g);var d=f.data("pollID");if(b._polls[d]===undefined){b._cache[d]={result:"",vote:""};b._polls[d]=f;b._canViewParticipants[d]=(f.data("canViewParticipants"))?true:false;b._canViewResult[d]=(f.data("canViewResult"))?true:false;b._canVote[d]=(f.data("canVote"))?true:false;b._bindListeners(d);if(f.data("inVote")){b._prepareVote(d)}b._toggleButtons(d)}})},_bindListeners:function(a){this._polls[a].find(".jsButtonPollShowParticipants").data("pollID",a).click($.proxy(this._showParticipants,this));this._polls[a].find(".jsButtonPollShowResult").data("pollID",a).click($.proxy(this._showResult,this));this._polls[a].find(".jsButtonPollShowVote").data("pollID",a).click($.proxy(this._showVote,this));this._polls[a].find(".jsButtonPollVote").data("pollID",a).click($.proxy(this._vote,this))},_showResult:function(b,c){var a=(b===null)?c:$(b.currentTarget).data("pollID");if(!this._canViewResult[a]){return}if(!this._polls[a].data("inVote")){return}if(!this._cache[a].result){this._proxy.setOption("data",{actionName:"getResult",pollID:a});this._proxy.sendRequest()}else{this._polls[a].find(".pollInnerContainer").html(this._cache[a].result);this._polls[a].data("inVote",false);this._toggleButtons(a)}},_showParticipants:function(b){var a=$(b.currentTarget).data("pollID");if(!this._participants[a]){this._participants[a]=new WCF.User.List("wcf\\data\\poll\\PollAction",this._polls[a].data("question"),{pollID:a})}this._participants[a].open()},_showVote:function(b,c){var a=(b===null)?c:$(b.currentTarget).data("pollID");if(!this._canVote[a]){return}if(this._polls[a].data("inVote")){return}if(!this._cache[a].vote){this._proxy.setOption("data",{actionName:"getVote",pollID:a});this._proxy.sendRequest()}else{this._polls[a].find(".pollInnerContainer").html(this._cache[a].vote);this._polls[a].data("inVote",true);this._prepareVote(a);this._toggleButtons(a)}},_success:function(c,d,b){if(!c||!c.actionName){return}var a=c.pollID;if(c.resultTemplate){this._cache[a].result=c.resultTemplate}if(c.voteTemplate){this._cache[a].vote=c.voteTemplate}switch(c.actionName){case"getResult":this._showResult(null,a);break;case"getVote":this._showVote(null,a);break;case"vote":this._canViewResult[a]=true;this._canVote[a]=(c.canVote)?true:false;this._showResult(null,a);break}},_prepareVote:function(c){this._polls[c].find(".jsButtonPollVote").disable();var d=this._polls[c].find(".pollInnerContainer > .jsPollVote");var a=this;this._inputElements[c]=d.find("input").change(function(){a._handleVoteButton(c)});this._handleVoteButton(c);var b=d.data("maxVotes");if(this._inputElements[c].filter("[type=checkbox]").length){this._inputElements[c].change(function(){a._enforceMaxVotes(c,b)});this._enforceMaxVotes(c,b)}},_enforceMaxVotes:function(c,b){var a=this._inputElements[c];if(a.filter(":checked").length==b){a.filter(":not(:checked)").disable()}else{a.enable()}},_handleVoteButton:function(b){var a=this._inputElements[b];var c=this._polls[b].find(".jsButtonPollVote");if(a.filter(":checked").length){c.enable()}else{c.disable()}},_toggleButtons:function(c){var a=this._polls[c].children(".formSubmit");a.find(".jsButtonPollShowParticipants, .jsButtonPollShowResult, .jsButtonPollShowVote, .jsButtonPollVote").hide();var b=true;if(this._polls[c].data("inVote")){b=false;a.find(".jsButtonPollVote").show();if(this._canViewResult[c]){a.find(".jsButtonPollShowResult").show()}}else{if(this._canVote[c]){b=false;a.find(".jsButtonPollShowVote").show()}if(this._canViewParticipants[c]){b=false;a.find(".jsButtonPollShowParticipants").show()}}if(b){a.hide()}},_vote:function(c){var a=$(c.currentTarget).data("pollID");if(!this._canVote[a]){return}var b=[];this._inputElements[a].each(function(e,d){var f=$(d);if(f.is(":checked")){b.push(f.data("optionID"))}});if(b.length){this._proxy.setOption("data",{actionName:"vote",optionIDs:b,pollID:a});this._proxy.sendRequest()}}}); })(this);