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 t={};t.insert_table={title:this.lang.get("insert_table"),func:this.table.show},t.insert_row_above={title:this.lang.get("insert_row_above"),func:this.table.addRowAbove},t.insert_row_below={title:this.lang.get("insert_row_below"),func:this.table.addRowBelow},t.insert_column_left={title:this.lang.get("insert_column_left"),func:this.table.addColumnLeft},t.insert_column_right={title:this.lang.get("insert_column_right"),func:this.table.addColumnRight},t.add_head={title:this.lang.get("add_head"),func:this.table.addHead},t.delete_head={title:this.lang.get("delete_head"),func:this.table.deleteHead},t.delete_column={title:this.lang.get("delete_column"),func:this.table.deleteColumn},t.delete_row={title:this.lang.get("delete_row"),func:this.table.deleteRow},t.delete_table={title:this.lang.get("delete_table"),func:this.table.deleteTable},this.observe.addButton("td","table"),this.observe.addButton("th","table");var e=this.button.addBefore("link","table",this.lang.get("table"));this.button.addDropdown(e,t)},show:function(){this.modal.addTemplate("table",this.table.getTemplate()),this.modal.load("table",this.lang.get("insert_table"),300),this.modal.createCancelButton();var t=this.modal.createActionButton(this.lang.get("insert"));t.on("click",this.table.insert),this.selection.save(),this.modal.show(),$("#redactor-table-rows").focus()},insert:function(){var t,e,i,a,s=$("#redactor-table-rows").val(),l=$("#redactor-table-columns").val(),n=$("<div>"),r=Math.floor(99999*Math.random()),o=$('<table id="table'+r+'"><tbody></tbody></table>');for(t=0;s>t;t++){for(e=$("<tr>"),i=0;l>i;i++)a=$("<td>"+this.opts.invisibleSpace+"</td>"),0===t&&0===i&&a.append(this.selection.getMarker()),$(e).append(a);o.append(e)}n.append(o);var d=n.html();if(this.modal.close(),this.selection.restore(),!this.table.getTable()){this.buffer.set();var h=this.selection.getBlock()||this.selection.getCurrent();h&&"BODY"!=h.tagName?("LI"==h.tagName&&(h=$(h).closest("ul, ol")),$(h).after(d)):this.insert.html(d),this.selection.restore();var c=this.$editor.find("#table"+r);if(!this.opts.linebreaks&&(this.utils.browser("mozilla")||this.utils.browser("msie"))){var b=c.next();0===b.length&&c.after(this.opts.emptyHtml)}this.observe.buttons(),c.find("span.redactor-selection-marker").remove(),c.removeAttr("id"),this.code.sync(),this.core.setCallback("insertedTable",c)}},getTable:function(){var t=$(this.selection.getParent()).closest("table");return this.utils.isRedactorParent(t)?0===t.size()?!1:t:!1},restoreAfterDelete:function(t){this.selection.restore(),t.find("span.redactor-selection-marker").remove(),this.code.sync()},deleteTable:function(){var t=this.table.getTable();if(t){this.buffer.set();var e=t.next();this.opts.linebreaks||0===e.length?this.caret.setAfter(t):this.caret.setStart(e),t.remove(),this.code.sync()}},deleteRow:function(){var t=this.table.getTable();if(t){var e=$(this.selection.getCurrent());this.buffer.set();var i=e.closest("tr"),a=i.prev().length?i.prev():i.next();if(a.length){var s=a.children("td, th").first();s.length&&s.prepend(this.selection.getMarker())}i.remove(),this.table.restoreAfterDelete(t)}},deleteColumn:function(){var t=this.table.getTable();if(t){this.buffer.set();var e=$(this.selection.getCurrent()),i=e.closest("td, th"),a=i[0].cellIndex;t.find("tr").each($.proxy(function(t,e){var i=$(e),s=0>a-1?a+1:a-1;0===t&&i.find("td, th").eq(s).prepend(this.selection.getMarker()),i.find("td, th").eq(a).remove()},this)),this.table.restoreAfterDelete(t)}},addHead:function(){var t=this.table.getTable();if(t){if(this.buffer.set(),0!==t.find("thead").size())return void this.table.deleteHead();var e=t.find("tr").first().clone();e.find("td").html(this.opts.invisibleSpace),$thead=$("<thead></thead>").append(e),t.prepend($thead),this.code.sync()}},deleteHead:function(){var t=this.table.getTable();if(t){var e=t.find("thead");0!==e.size()&&(this.buffer.set(),e.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(t){var e=this.table.getTable();if(e){this.buffer.set();var i=$(this.selection.getCurrent()),a=i.closest("tr"),s=a.clone();s.find("th").replaceWith(function(){var t=$("<td>");return t[0].attributes=this.attributes,t.append($(this).contents())}),s.find("td").html(this.opts.invisibleSpace),"after"==t?a.after(s):a.before(s),this.code.sync()}},addColumn:function(t){var e=this.table.getTable();if(e){var i=0,a=$(this.selection.getCurrent());this.buffer.set();var s=a.closest("tr"),l=a.closest("td, th");s.find("td, th").each($.proxy(function(t,e){$(e)[0]===l[0]&&(i=t)},this)),e.find("tr").each($.proxy(function(e,a){var s=$(a).find("td, th").eq(i),l=s.clone();l.html(this.opts.invisibleSpace),"after"==t?s.after(l):s.before(l)},this)),this.code.sync()}}}};
// wautosave.js
-if(!RedactorPlugins)var RedactorPlugins={};RedactorPlugins.wautosave=function(){"use strict";var e=!1,t="",a=null,s=null,o=!1,i=null,n=null;return{init:function(){i=this.$textarea[0],this.wutil.getOption("woltlab.autosave").active&&(this.wautosave.enable(),this.wutil.getOption("woltlab.autosave").saveOnInit||this.$textarea.data("saveOnInit")?this.wutil.setOption("woltlab.autosaveOnce",!0):this.wautosave.restore()),this.wutil.setOption("autosave",!1);var e=this.core.destroy;this.core.destroy=function(){this.wautosave.disable(),e.call(this)}.bind(this)},enable:function(e){this.wutil.getOption("woltlab.autosave").active||this.wutil.setOption("woltlab.autosave",{active:!0,key:e}),null===n&&(this.wautosave.purgeOutdated(),n=new WCF.PeriodicalExecuter(this.wautosave.save.bind(this),15e3))},save:function(a){a!==!0&&(a=!1);var i=this.wutil.getText();if(t!==i||a)try{localStorage.setItem(this.wutil.getOption("woltlab.autosave").key,JSON.stringify({content:i,timestamp:Date.now()})),t=i,e=!0,null===s&&(s=new WCF.PeriodicalExecuter(function(t){if(o!==!0){if(e===!1)return t.stop(),void(s=null);this.wautosave.showNotice("saved"),e=!1}}.bind(this),12e4))}catch(e){console.debug("[wautosave.save] Unable to access local storage: "+e.message)}},disable:function(){this.wutil.getOption("woltlab.autosave").active&&(n.stop(),n=null,this.wutil.setOption("woltlab.autosave",{active:!1,key:""}))},purge:function(){try{localStorage.removeItem(this.wutil.getOption("woltlab.autosave").key)}catch(e){console.debug("[wautosave.purge] Unable to access local storage: "+e.message)}},restore:function(){var e=this.wutil.getOption("woltlab.autosave"),t=null;try{t=localStorage.getItem(e.key)}catch(e){console.debug("[wutil.autosaveRestore] Unable to access local storage: "+e.message)}try{null!==t&&(t=JSON.parse(t))}catch(e){t=null}return null!==t&&t.content?e.lastEditTime&&1e3*e.lastEditTime>t.timestamp?(this.wautosave.purge(),!1):e.prompt?(this.autosave.showNotice("prompt",t),!1):(this.wutil.inWysiwygMode()?this.wutil.setOption("woltlab.originalValue",t.content):i.value=t.content,this.wautosave.showNotice("restored",{timestamp:t.timestamp}),!0):!1},showNotice:function(e,t){if(null===a){a=$('<div class="redactorAutosaveNotice"><span class="redactorAutosaveMessage" /></div>'),a.appendTo(this.$box);var s=function(e){(null===e||"opacity"===e.originalEvent.propertyName)&&(a.hasClass("open")&&null!==e?a.data("callbackOpen")&&a.data("callbackOpen")():(a.data("callbackClose")&&a.data("callbackClose")(),a.removeData("callbackClose"),a.removeData("callbackOpen"),a.removeClass("redactorAutosaveNoticeIcons"),a.empty(),$('<span class="redactorAutosaveMessage" />').appendTo(a)))}.bind(this);a.on("transitionend webkitTransitionEnd",s)}var o="",n="";switch(e){case"prompt":$('<span class="icon icon16 fa-info blue jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.version",{date:new Date(t.timestamp).toLocaleString()})+'"></span>').prependTo(a);var l=$('<span class="icon icon16 fa-check green pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.prompt.confirm")+'"></span>').appendTo(a),c=$('<span class="icon icon16 fa-times red pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.prompt.discard")+'"></span>').appendTo(a);l.click(function(){this.wutil.replaceText(t.content),s(null),this.wautosave.showNotice("restored",t)}.bind(this)),c.click(function(){this.wautosave.purge(),a.removeClass("open")}.bind(this)),o=WCF.Language.get("wcf.message.autosave.prompt"),a.addClass("redactorAutosaveNoticeIcons"),n=WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+i.id,function(e){WCF.System.Event.removeListener("com.woltlab.wcf.redactor","keydown_"+i.id,n),setTimeout(function(){a.removeClass("open")},3e3)}.bind(this));break;case"restored":$('<span class="icon icon16 fa-info blue jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.version",{date:new Date(t.timestamp).toLocaleString()})+'"></span>').prependTo(a);var l=$('<span class="icon icon16 fa-check green pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.confirm")+'"></span>').appendTo(a),c=$('<span class="icon icon16 fa-times red pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.revert")+'"></span>').appendTo(a);l.click(function(){a.removeClass("open")}),c.click(function(){WCF.System.Confirmation.show(WCF.Language.get("wcf.message.autosave.restored.revert.confirmMessage"),function(e){"confirm"===e&&(this.wutil.reset(),this.wautosave.purge(),a.removeClass("open"))}.bind(this))}.bind(this)),o=WCF.Language.get("wcf.message.autosave.restored"),a.addClass("redactorAutosaveNoticeIcons"),n=WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+i.id,function(e){WCF.System.Event.removeListener("com.woltlab.wcf.redactor","keydown_"+i.id,n),setTimeout(function(){l.trigger("click")},3e3)}.bind(this));break;case"saved":if(a.hasClass("open"))return;setTimeout(function(){a.removeClass("open")},2e3),o=WCF.Language.get("wcf.message.autosave.saved")}a.children("span.redactorAutosaveMessage").text(o),a.addClass("open"),"saved"!==e&&WCF.DOMNodeInsertedHandler.execute()},purgeOutdated:function(){var e=0,t=this.wutil.getOption("woltlab.autosave").prefix,a=t+"_wcf_master";try{e=localStorage.getItem(a)}catch(e){console.debug("[wautosave.purgeOutdated] Unable to access local storage: "+e.message)}if(0!==e){var s,o=Date.now()-6048e5;if(null===e||o>e){var i=new RegExp("^"+t+"_");for(var n in localStorage)if(n.match(i)&&n!==a){s=localStorage.getItem(n);try{s=JSON.parse(s)}catch(e){s={timestamp:0}}if(null===s||!s.timestamp||s.timestamp<o)try{localStorage.removeItem(n)}catch(e){console.debug("[wautosave.purgeOutdated] Unable to access local storage: "+e.message)}}try{localStorage.setItem(a,Date.now())}catch(e){console.debug("[wautosave.purgeOutdated] Unable to access local storage: "+e.message)}}}},autosavePause:function(){o=!0},autosaveResume:function(){o=!1}}};
+if(!RedactorPlugins)var RedactorPlugins={};RedactorPlugins.wautosave=function(){"use strict";var e=!1,t="",a=null,s=null,o=!1,i=null,n=null;return{init:function(){i=this.$textarea[0],this.wutil.getOption("woltlab.autosave").active&&(this.wautosave.enable(),this.wutil.getOption("woltlab.autosave").saveOnInit||this.$textarea.data("saveOnInit")?this.wutil.setOption("woltlab.autosaveOnce",!0):this.wautosave.restore()),this.wutil.setOption("autosave",!1);var e=this.core.destroy;this.core.destroy=function(){this.wautosave.disable(),e.call(this)}.bind(this)},enable:function(e){this.wutil.getOption("woltlab.autosave").active||this.wutil.setOption("woltlab.autosave",{active:!0,key:e}),null===n&&(this.wautosave.purgeOutdated(),n=new WCF.PeriodicalExecuter(this.wautosave.save.bind(this),15e3))},save:function(a){a!==!0&&(a=!1);var i=this.wutil.getText();if(t!==i||a)try{localStorage.setItem(this.wutil.getOption("woltlab.autosave").key,JSON.stringify({content:i,timestamp:Date.now()})),t=i,e=!0,null===s&&(s=new WCF.PeriodicalExecuter(function(t){if(o!==!0){if(e===!1)return t.stop(),void(s=null);this.wautosave.showNotice("saved"),e=!1}}.bind(this),12e4))}catch(e){console.debug("[wautosave.save] Unable to access local storage: "+e.message)}},disable:function(){this.wutil.getOption("woltlab.autosave").active&&(n.stop(),n=null,this.wutil.setOption("woltlab.autosave",{active:!1,key:""}))},purge:function(){try{localStorage.removeItem(this.wutil.getOption("woltlab.autosave").key)}catch(e){console.debug("[wautosave.purge] Unable to access local storage: "+e.message)}},restore:function(){var e=this.wutil.getOption("woltlab.autosave"),t=null;try{t=localStorage.getItem(e.key)}catch(e){console.debug("[wutil.autosaveRestore] Unable to access local storage: "+e.message)}try{null!==t&&(t=JSON.parse(t))}catch(e){t=null}return null!==t&&t.content?e.lastEditTime&&1e3*e.lastEditTime>t.timestamp?(this.wautosave.purge(),!1):e.prompt?(this.autosave.showNotice("prompt",t),!1):(this.wutil.inWysiwygMode()?this.wutil.setOption("woltlab.originalValue",t.content):i.value=t.content,this.wautosave.showNotice("restored",{timestamp:t.timestamp}),!0):!1},showNotice:function(e,t){if(null===a){a=$('<div class="redactorAutosaveNotice"><span class="redactorAutosaveMessage" /></div>'),a.appendTo(this.$box);var s=function(e){(null===e||"opacity"===e.originalEvent.propertyName)&&(a.hasClass("open")&&null!==e?a.data("callbackOpen")&&a.data("callbackOpen")():(a.data("callbackClose")&&a.data("callbackClose")(),a.removeData("callbackClose"),a.removeData("callbackOpen"),a.removeClass("redactorAutosaveNoticeIcons"),a.empty(),$('<span class="redactorAutosaveMessage" />').appendTo(a)))}.bind(this);a.on("transitionend webkitTransitionEnd",s)}var o="",n="";switch(e){case"prompt":$('<span class="icon icon16 fa-info blue jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.version",{date:new Date(t.timestamp).toLocaleString()})+'"></span>').prependTo(a);var l=$('<span class="icon icon16 fa-check green pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.prompt.confirm")+'"></span>').appendTo(a),c=$('<span class="icon icon16 fa-times red pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.prompt.discard")+'"></span>').appendTo(a);l.click(function(){this.wutil.replaceText(t.content),s(null),this.wautosave.showNotice("restored",t)}.bind(this)),c.click(function(){this.wautosave.purge(),a.removeClass("open")}.bind(this)),o=WCF.Language.get("wcf.message.autosave.prompt"),a.addClass("redactorAutosaveNoticeIcons"),n=WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+i.id,function(e){WCF.System.Event.removeListener("com.woltlab.wcf.redactor","keydown_"+i.id,n),setTimeout(function(){a.removeClass("open")},3e3)}.bind(this));break;case"restored":$('<span class="icon icon16 fa-info blue jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.version",{date:new Date(t.timestamp).toLocaleString()})+'"></span>').prependTo(a);var l=$('<span class="icon icon16 fa-check green pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.confirm")+'"></span>').appendTo(a),c=$('<span class="icon icon16 fa-times red pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.revert")+'"></span>').appendTo(a);l.click(function(){a.removeClass("open")}),c.click(function(){WCF.System.Confirmation.show(WCF.Language.get("wcf.message.autosave.restored.revert.confirmMessage"),function(e){"confirm"===e&&(this.wutil.reset(),this.wautosave.purge(),a.removeClass("open"))}.bind(this))}.bind(this)),o=WCF.Language.get("wcf.message.autosave.restored"),a.addClass("redactorAutosaveNoticeIcons"),n=WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+i.id,function(e){WCF.System.Event.removeListener("com.woltlab.wcf.redactor","keydown_"+i.id,n),setTimeout(function(){l.trigger("click")},3e3)}.bind(this));break;case"saved":if(a.hasClass("open"))return;setTimeout(function(){a.removeClass("open")},2e3),o=WCF.Language.get("wcf.message.autosave.saved")}a.children("span.redactorAutosaveMessage").text(o),a.addClass("open"),"saved"!==e&&WCF.DOMNodeInsertedHandler.execute()},purgeOutdated:function(){var e=0,t=this.wutil.getOption("woltlab.autosave").prefix,a=t+"_wcf_master";try{e=localStorage.getItem(a)}catch(e){console.debug("[wautosave.purgeOutdated] Unable to access local storage: "+e.message)}if(0!==e){var s,o=Date.now()-6048e5;if(null===e||o>e){var i=new RegExp("^"+t+"_");for(var n in localStorage)if(n.match(i)&&n!==a){s=localStorage.getItem(n);try{s=JSON.parse(s)}catch(e){s={timestamp:0}}if(null===s||!s.timestamp||s.timestamp<o)try{localStorage.removeItem(n)}catch(e){console.debug("[wautosave.purgeOutdated] Unable to access local storage: "+e.message)}}try{localStorage.setItem(a,Date.now())}catch(e){console.debug("[wautosave.purgeOutdated] Unable to access local storage: "+e.message)}}}},pause:function(){o=!0},resume:function(){o=!1}}};
// wbbcode.js
if(!RedactorPlugins)var RedactorPlugins={};RedactorPlugins.wbbcode=function(){"use strict";var e=!1;return{init:function(){var t=this.$textarea.wcfIdentify();this.opts.initCallback=function(){window.addEventListener("unload",function(e){this.code.startSync(),this.$textarea.val(this.wbbcode.convertFromHtml(this.$textarea.val()))}.bind(this)),$.browser.msie&&this.$editor.addClass("msie"),this.$textarea[0].setAttribute("data-is-dirty",!0);var e=$.trim(this.wutil.getOption("woltlab.originalValue"));e.length&&(this.wutil.replaceText(e),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 i=this.clean.onSync;this.clean.onSync=function(t){return t=t.replace(/\u200C/g,"__wcf_zwnj__"),t=t.replace(/\u200D/g,"__wcf_zwj__"),e===!0?e=!1:t=t.replace(/<p><br([^>]+)?><\/p>/g,"<p>@@@wcf_empty_line@@@</p>"),t=i.call(this,t),t=t.replace(/__wcf_zwnj__/g,""),t.replace(/__wcf_zwj__/g,"")}.bind(this),this.wutil.getOption("woltlab.autosaveOnce")&&(this.wutil.saveTextToStorage(),delete this.opts.woltlab.autosaveOnce);var a=this.button.get("table");if(a.length){var o=a.data("dropdown");o.find(".redactor-dropdown-add_head").parent().remove(),o.find(".redactor-dropdown-delete_head").parent().remove(),$('<li class="dropdownDivider" />').insertBefore(o.find(".redactor-dropdown-delete_table").parent()),a.click($.proxy(this.wbbcode._tableButtonClick,this))}WCF.System.Event.addListener("com.woltlab.wcf.redactor","insertBBCode_quote_"+t,$.proxy(function(e){e.cancel=!0,this.wbbcode._handleInsertQuote()},this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor","insertBBCode_code_"+t,$.proxy(function(e){e.cancel=!0,this.wbbcode._handleInsertCode(null,!0)},this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+t,$.proxy(this.wbbcode._keydownCallback,this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor","keyup_"+t,$.proxy(this.wbbcode._keyupCallback,this)),this.code.sync=function(){};var n=$(".redactor-toolbar-tooltip-html:not(.jsWbbcode)").addClass("jsWbbcode").text(WCF.Language.get("wcf.bbcode.button.toggleBBCode")),r=function(e){for(var t=e[0].querySelectorAll("br:not(:empty)"),i=0,a=t.length;a>i;i++)t[0].innerHTML=""};this.code.toggle=function(){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"),n.text(WCF.Language.get("wcf.bbcode.button.toggleHTML"))):(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"),n.text(WCF.Language.get("wcf.bbcode.button.toggleBBCode")),this.wutil.fixDOM(),r(this.$editor),this.wutil.saveSelection())}.bind(this),this.wutil.setOption("clickCallback",function(e){this.wutil.saveSelection(),e.target===this.$editor[0]&&this.$editor[0].lastElementChild&&"BLOCKQUOTE"===this.$editor[0].lastElementChild.tagName&&this.wutil.setCaretAfter($(this.$editor[0].lastElementChild))}.bind(this));var l=this.opts.verifiedTags.indexOf("ul");l>-1&&this.opts.verifiedTags.splice(l,1),WCF.System.Event.addListener("com.woltlab.wcf.redactor","observe_load_"+t,function(e){this.wbbcode.observeCodeListings(),this.wbbcode.observeQuotes()}.bind(this)),WCF.System.Event.addListener("com.woltlab.wcf.redactor","fixFormatting_"+t,$.proxy(this.wbbcode.fixFormatting,this))},_tableButtonClick:function(e){var t=$(e.currentTarget);if(t.hasClass("dropact")){var i=this.selection.getBlock()||this.selection.getCurrent(),a=t.data("dropdown");a.children("li").show();var o=a.find("> li > .redactor-dropdown-insert_table").parent();"TD"==i.tagName?o.hide():o.nextAll().hide()}},insertSmiley:function(e,t,i){if(i&&this.wbbcode.registerSmiley(e,t),this.opts.visual){var a=null;window.getSelection().rangeCount&&window.getSelection().getRangeAt(0).collapsed&&(a=window.getSelection().getRangeAt(0).startContainer,a.nodeType===Node.TEXT_NODE&&(a=a.parentElement),this.utils.isRedactorParent(a)||(a=null)),this.insert.html('<img src="'+t+'" class="smiley" alt="'+e+'" id="redactorSmiley">',!1);var o=document.getElementById("redactorSmiley");if(o.removeAttribute("id"),null!==a){var n=window.getSelection().getRangeAt(0).startContainer;n.nodeType===Node.TEXT_NODE&&(n=n.parentElement),a!==n&&a.appendChild(o)}var r=function(e){return null===e?!1:(e.nodeType===Node.ELEMENT_NODE&&"SPAN"===e.nodeName||e.nodeType===Node.TEXT_NODE)&&" "===e.textContent?!0:!1},l=o.parentElement;if(!r(o.previousSibling)){var s=document.createTextNode(" ");l.insertBefore(s,o)}if(!r(o.nextSibling)){var s=document.createTextNode(" ");l.lastChild===o?l.appendChild(s):l.insertBefore(s,o.nextSibling)}}else this.wutil.insertAtCaret(" "+e+" ")},registerSmiley:function(e,t){return __REDACTOR_SMILIES[e]?!1:(__REDACTOR_SMILIES[e]=t,!0)},convertFromHtml:function(e){var t={html:e};return WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertFromHtml",t),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","convertFromHtml",t),t.html=__REDACTOR_AMD_DEPENDENCIES.BbcodeFromHTML.convert(t.html),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertFromHtml",t),t.html},convertToHtml:function(e){var t={data:e};return WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","beforeConvertToHtml",t),t.data=__REDACTOR_AMD_DEPENDENCIES.BbcodeToHTML.convert(t.data,{attachments:{images:this.wbbcode._getImageAttachments(),thumbnailUrl:this.wutil.getOption("woltlab.attachmentThumbnailUrl"),url:this.wutil.getOption("woltlab.attachmentUrl")}}),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterConvertToHtml",t),t.data},_pasteBeforeCallback:function(e){var t=document.createElement("div");t.innerHTML=e,document.body.appendChild(t);for(var i,a,o,n,r={1:24,2:22,3:18,4:14,5:12,6:10},l=1;6>=l;l++)for(a=t.getElementsByTagName("H"+l);a.length;)i=a[0],o=r[l],i.style.fontSize&&(n=window.getComputedStyle(i),o=Math.round(n.getPropertyValue("font-size").replace(/px$/,"")),o=o>24?24:o>22?22:o>18?22:o>14?14:o>12?14:o>10?12:10),i.outerHTML='<span style="font-size: '+o+'pt" data-verified="redactor" rel="font-size: '+o+'pt">'+i.innerHTML+"</span>";document.body.removeChild(t),a=t.querySelectorAll("div,p,span");for(var l=0,s=a.length;s>l;l++)a[0].className&&(a[0].className="");for(a=t.getElementsByTagName("WBR");a.length;)a[0].parentNode.removeChild(a[0]);return t.innerHTML},_pasteCallback:function(e){return e=e.replace(/style="([^"]+)"/,function(e,t){for(var i=t.split(";"),a=[],o=0,n=i.length;n>o;o++){var r=i[o];r.match(/^\s*background-color/)||a.push(r)}return'style="'+a.join(";")+'"'}),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","afterPaste",{html:e}),e},insertAttachment:function(e,t){e=parseInt(e);var i=this.wutil.getOption("woltlab.attachment"+(t?"":"Thumbnail")+"Url"),a=this.wbbcode._getImageAttachments();if(i&&void 0!==a[e]){var o="";t&&(o=' style="width: '+a[e].width+"px; max-height: "+a[e].height+"px; max-width: "+a[e].width+'px;"'),this.wutil.insertDynamic('<img src="'+i.replace(/987654321/,e)+'" class="redactorEmbeddedAttachment'+(t?"":" redactorDisableResize")+'" data-attachment-id="'+e+'"'+o+" />","[attach="+e+(t?",none,"+a[e].width:"")+"][/attach]")}else this.wutil.insertDynamic("[attach="+e+"][/attach]")},removeAttachment:function(e){this.opts.visual&&this.$editor.find("img.redactorEmbeddedAttachment").each(function(t,i){var a=$(i);a.data("attachmentID")==e&&a.remove()})},_getImageAttachments:function(){var e=this.wutil.getOption("woltlab.attachmentImages")||[];if(e.length)return delete this.opts.attachmentImages,e;var t={imageAttachments:{}};return WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","getImageAttachments_"+this.$textarea.wcfIdentify(),t),t.imageAttachments},_keydownCallback:function(e){switch(e.event.which){case $.ui.keyCode.BACKSPACE:case $.ui.keyCode.DELETE:case $.ui.keyCode.DOWN:case $.ui.keyCode.ENTER:case $.ui.keyCode.UP:case $.ui.keyCode.RIGHT:case 83:break;default:return}this.selection.get();var t=this.selection.getCurrent(),i=this.selection.getParent();i=i?$(i):i;var a=i?i.closest("blockquote.quoteBox",this.$editor.get()[0]):{length:0};switch(e.event.which){case $.ui.keyCode.BACKSPACE:if(this.wutil.isCaret()){var o=!1;if(a.length){for(var n=!0,r=0;r<a[0].children.length;r++){var l=a[0].children[r];if("DIV"===l.tagName&&l.textContent.replace(/\u200b/,"").length){n=!1;break}}if(n)o=!0;else{var s=null===this.selection.implicitRange?this.range:this.selection.implicitRange;if(0===s.startOffset)for(var c,d=s.startContainer;null!==(d=d.parentNode);)if(c=d.previousSibling,null!==c){c.nodeType===Node.ELEMENT_NODE&&"HEADER"===c.nodeName&&(o=!0);break}}}else{var h=null===this.selection.implicitRange?this.range:this.selection.implicitRange,u=h.startContainer;if(u.nodeType===Node.TEXT_NODE&&(0===h.startOffset||1===h.startOffset&&""===u.textContent)&&(u.previousSibling||(u=u.parentElement)),u.nodeType===Node.ELEMENT_NODE){var v=u.previousSibling;v&&v.nodeType===Node.ELEMENT_NODE&&"BLOCKQUOTE"===v.tagName&&(a=v,o=!0)}}if(o){var g=window.getSelection();g.rangeCount&&g.removeAllRanges();var m=document.createRange();m.selectNode(a[0]||a),g.addRange(m),e.cancel=!0}}break;case $.ui.keyCode.DELETE:if(this.wutil.isCaret()&&this.wutil.isEndOfElement(t)){var f=t.nextElementSibling;if(f&&"BLOCKQUOTE"===f.tagName){var g=window.getSelection();g.rangeCount&&g.removeAllRanges();var m=document.createRange();m.selectNode(f),g.addRange(m),e.cancel=!0}}break;case $.ui.keyCode.DOWN:var b=$(t);if(b.next("blockquote").length)this.caret.setStart(b.next().children("div:first")),e.cancel=!0;else if(i)if(i.next("blockquote").length)this.caret.setStart(i.next().children("div:first")),e.cancel=!0;else if(a.length){var p=b.closest("div",a[0]);p.next().length||(a.next().length?this.caret.setStart(a.next()):this.wutil.setCaretAfter(a),e.cancel=!0)}break;case $.ui.keyCode.ENTER:a.length?(this.keydown.blockquote=!1,this.keydown.enterWithinBlockquote=!0):"KBD"===t.nodeName&&(e.cancel=!0);break;case $.ui.keyCode.UP:if(!i||!a.length)return;var p=$(t).closest("div",a[0]),w=p.prev();if("DIV"===w[0].tagName)return;if("BLOCKQUOTE"===w[0].tagName)return;var C=a.prev();0===C.length?this.wutil.setCaretBefore(a):"BLOCKQUOTE"===C[0].tagName?this.caret.sendEnd(C.children("div:last")):(""==$.trim(C.html())&&C.html(this.opts.invisibleSpace),this.caret.setEnd(C)),e.cancel=!0;break;case $.ui.keyCode.RIGHT:var s=window.getSelection().getRangeAt(0);if(s.startContainer.nodeType===Node.TEXT_NODE&&s.startContainer.length===s.startOffset){if(t=t.parentNode,"KBD"!==t.nodeName)return;var E=this.$editor[0];t.nextElementSibling===E.lastElementChild&&(t=t.nextElementSibling,""===t.textContent&&(t.textContent="")),t===E.lastElementChild&&this.wutil.selectionEndOfEditor()}break;case 83:if($.browser.mobile)return;var y=!1;if(navigator.platform.match(/^Mac/)?e.event.ctrlKey&&e.event.altKey&&(y=!0):e.event.altKey&&!e.event.ctrlKey&&(y=!0),y){var _={cancel:!1};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","submitEditor_"+this.$textarea.wcfIdentify(),_),_.cancel&&(e.cancel=!0)}}},_keyupCallback:function(e){switch(e.event.which){case $.ui.keyCode.BACKSPACE:case $.ui.keyCode.DELETE:this.$editor.find("blockquote").each(function(e,t){var i=$(t);i.children("header").length||i.remove()});break;case $.ui.keyCode.ENTER:for(var t=0,i=this.$editor[0].children.length;i>t;t++){var a=this.$editor[0].children[t];if(a.nodeType===Node.ELEMENT_NODE&&"P"===a.tagName&&!(a.textContent.length>0||a.children.length>1||"BR"===a.children[0].tagName)){for(a=a.children[0];1===a.children.length;)a=a.children[0];if(0===a.children.length&&"BR"===a.tagName){var o=a.parentNode,n=document.createTextNode("");o.appendChild(n),o.removeChild(a)}}}}},observeQuotes:function(){this.$editor.find(".redactorQuoteEdit").off("click.wbbcode").on("click.wbbcode",$.proxy(this.wbbcode._observeQuotesClick,this))},_observeQuotesClick:function(e){var t=$(e.currentTarget).closest("header"),i=$('<span class="redactor-link-tooltip" />');$('<a href="#">'+WCF.Language.get("wcf.bbcode.quote.edit")+"</a>").click($.proxy(function(t){t.preventDefault(),this.wbbcode._openQuoteEditOverlay($(e.currentTarget).closest("blockquote.quoteBox"),!1),$(".redactor-link-tooltip").remove()},this)).appendTo(i);var a=t.offset();i.css({left:a.left+"px",top:a.top+20+"px"}),$(".redactor-link-tooltip").remove(),i.appendTo(document.body),this.selection.remove()},observeCodeListings:function(){this.$editor.find(".codeBox").each(function(e,t){var i=$(t),a=i.find(".redactorEditCodeBox");a.length||(a=$('<div class="redactorEditCodeBox"><div>'+WCF.Language.get("wcf.bbcode.code.edit")+"</div></div>").insertAfter(i.find("> div > div > h3"))),a.off("click.wbbcode").on("click.wbbcode",function(){this.wbbcode._handleInsertCode(i,!1)}.bind(this))}.bind(this))},_openQuoteEditOverlay:function(t,i){this.modal.load("quote",WCF.Language.get("wcf.bbcode.quote."+(i?"insert":"edit")),400);var a=this.modal.createActionButton(this.lang.get("save"));i?(this.selection.save(),a.click($.proxy(function(){var t=$("#redactorQuoteAuthor").val(),i=WCF.String.escapeHTML($("#redactorQuoteLink").val());this.selection.restore(),e=!0;var a=this.selection.getHtml();this.utils.isEmpty(a)&&(a="");var o=this.wbbcode.insertQuoteBBCode(t,i,a);null!==o&&(a.length||($.browser.mozilla&&o.children("br[type=_moz]").replaceWith("<div>"+this.opts.invisibleSpace+"</div>"),this.caret.setStart(o.children("div")[0]))),this.modal.close()},this))):($("#redactorQuoteAuthor").val(t.data("author")),$("#redactorQuoteLink").val(WCF.String.unescapeHTML(t.attr("cite"))),a.click($.proxy(function(){var e=$("#redactorQuoteAuthor").val();t.data("author",e),t.attr("data-author",e),t.prop("cite",WCF.String.escapeHTML($("#redactorQuoteLink").val())),this.wbbcode._updateQuoteHeader(t),this.modal.close()},this))),this.modal.show()},_updateQuoteHeader:function(e){var t=e.data("author"),i=e.attr("cite");i&&(i=WCF.String.escapeHTML(i)),e.find("> header > h3").empty().append(this.wbbcode._buildQuoteHeader(t,i))},insertQuoteBBCode:function(e,t,i,a){var o="[quote]",n="[/quote]";e&&(o=t?"[quote='"+e+"','"+t+"']":"[quote='"+e+"']");var r=null;if(this.wutil.inWysiwygMode()){var l=WCF.getUUID(),s="";a?s=this.wbbcode.convertToHtml(o+a+n):(s=this.wbbcode.convertToHtml(o+l+n),s=s.replace(l,i.replace(/^<p>/,"").replace(/<\/p>$/,""))),s=s.replace(/^<p>/,"").replace(/<\/p>$/,""),s=s.replace(/<blockquote/,'<blockquote id="'+l+'"'),window.getSelection().rangeCount||(this.wutil.restoreSelection(),window.getSelection().rangeCount||(this.$editor.focus(),window.getSelection().rangeCount||this.wutil.selectionEndOfEditor(),this.wutil.saveSelection())),window.getSelection().getRangeAt(0).deleteContents(),this.wutil.restoreSelection();for(var c=window.getSelection().getRangeAt(0),d=c.startContainer;d;){var h=d.parentNode;if(h===this.$editor[0])break;d=h}if(d&&d.parentNode===this.$editor[0]&&d.innerHTML.length&&(""===d.innerHTML?this.caret.setEnd(d):this.wutil.setCaretAfter(d)),this.insert.html(s,!1),r=this.$editor.find("#"+l),r.length){var u=r.find("> div");if(1==u.length)""===u[0].innerHTML&&(u[0].innerHTML=this.opts.invisibleSpace);else if($.browser.mozilla){var v=r.find("> div > br[type=_moz]");v.length&&($("<div>"+this.opts.invisibleSpace+"</div>").insertBefore(v),v.remove())}r.removeAttr("id"),this.wutil.setCaretAfter(r[0]);var g=r[0].previousElementSibling;null!==g&&"P"===g.nodeName&&""===g.innerHTML&&(g=g.previousElementSibling,null===g||"P"!==g.nodeName||""!==g.innerHTML&&"<br>"!==g.innerHTML||g.parentNode.removeChild(g.nextElementSibling))}this.wbbcode.observeQuotes(),this.wbbcode.fixBlockLevelElements(),this.$toolbar.find("a.re-__wcf_quote").removeClass("redactor-button-disabled")}else this.wutil.insertAtCaret(o+a+n);return this.wutil.saveSelection(),r},_buildQuoteHeader:function(e,t){var i="";return!e&&t&&(e=t,t=""),e?(t&&(i+='<a href="'+t+'" tabindex="-1">'),i+=WCF.Language.get("wcf.bbcode.quote.title.javascript",{quoteAuthor:WCF.String.unescapeHTML(e)}),t&&(i+="</a>")):i="<small>"+WCF.Language.get("wcf.bbcode.quote.title.clickToSet")+"</small>",i},_handleInsertQuote:function(){this.wbbcode._openQuoteEditOverlay(null,!0)},_handleInsertCode:function(e,t){this.modal.load("code",WCF.Language.get("wcf.bbcode.code."+(t?"insert":"edit")),400);var i=this.modal.createActionButton(this.lang.get("save")).addClass("buttonPrimary");if(t){this.selection.get();var a=this.selection.getText();this.selection.save(),this.modal.show();var o=$("#redactorCodeBox").focus();o.val(a),i.click($.proxy(function(){var e=$("#redactorCodeBox"),t=$("#redactorCodeFilename"),i=$("#redactorCodeHighlighter"),a=$("#redactorCodeLineNumber"),o=e.val().replace(/^\n+/,"").replace(/\n+$/,"");if(0===$.trim(o).length)return void(e.next("small.innerError").length||$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(e));var n=$.trim(t.val().replace(/['"]/g,"")),r="[code="+i.val()+","+a.val()+(n.length?",'"+n+"'":"")+"]";r.match(/\[code=([^,]+),(\d+)\]/)&&(r="[code="+RegExp.$2+","+RegExp.$1+"]"),r+=o,r+="[/code]",this.wutil.adjustSelectionForBlockElement(),this.wutil.saveSelection();var l=this.wbbcode.convertToHtml(r);this.buffer.set(),this.insert.html(l,!1);var e=this.$editor.find(".codeBox:not(.jsRedactorCodeBox)");this.wbbcode.observeCodeListings(),this.wbbcode.fixBlockLevelElements(),e.attr("contenteditable","false"),this.wutil.setCaretAfter(e[0]),this.modal.close()},this))}else{var n=this.modal.createActionButton(WCF.Language.get("wcf.global.button.delete"));n.click(function(){this.buffer.set(),e.remove(),this.modal.close()}.bind(this)),this.modal.show();var o=$("#redactorCodeBox").focus(),r=$("#redactorCodeFilename"),l=$("#redactorCodeHighlighter"),s=$("#redactorCodeLineNumber");l.val(e.data("highlighter")),r.val(e.data("filename")||"");var c=e.find("> div > ol");s.val(parseInt(c.prop("start")));var d="";c.children("li").each(function(e,t){d+=$(t).text().replace(/^\u200b$/,"")+"\n"}),o.val(d.replace(/^\n+/,"").replace(/\n+$/,"")),i.click($.proxy(function(){var t=o.val().replace(/^\n+/,"").replace(/\n+$/,"");if(0===$.trim(t).length)return void(o.next("small.innerError").length||$('<small class="innerError">'+WCF.Language.get("wcf.global.form.error.empty")+"</small>").insertAfter(o));var i=l.val();e.data("highlighter",i),e.attr("data-highlighter",i);var a=__REDACTOR_CODE_HIGHLIGHTERS[i],n=$.trim(r.val().replace(/['"]/g,""));n?(a+=": "+WCF.String.escapeHTML(n),e.data("filename",n),e.attr("data-filename",n)):(e.removeAttr("data-filename"),e.removeData("filename")),e.data("highlighter",l.val()),e.find("> div > div > h3").html(a);var c=e.find("> div > ol").empty(),d=parseInt(s.val());c.prop("start",d>1?d:1),t=t.split("\n");for(var h="",u=0;u<t.length;u++)h+="<li>"+WCF.String.escapeHTML(t[u])+"</li>";c.append($(h)),this.modal.close()},this))}},fixBlockLevelElements:function(){return},fixFormatting:function(e){for(var t=function(e){e.style.removeProperty("text-align");for(var i=0;i<e.children.length;i++)t(e.children[i])},i=0;i<this.alignment.blocks.length;i++){var a=this.alignment.blocks[i];switch(a.tagName){case"BLOCKQUOTE":a.style.removeProperty("text-align"),t(a.children[0]);break;case"DIV":/\bcodeBox\b/.test(a.className)&&t(a)}}}}};