// wmonkeypatch.js
if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wmonkeypatch={init:function(){var n=this;var e=this.$source.wcfIdentify();var b=this.indentingStart;this.indentingStart=function(p){if(n.mpIndentingStart(p)){b.call(n,p)}};var o=this.buildEventKeydown;this.buildEventKeydown=function(q){var p={cancel:false,event:q};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","keydown_"+e,p);if(p.cancel!==true){return o.call(n,q)}return false};var m=this.buildEventKeyup;this.buildEventKeyup=function(q){var p={cancel:false,event:q};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","keyup_"+e,p);if(p.cancel!==true){return m.call(n,q)}return false};var l=this.toggleCode;this.toggleCode=function(q){var p=n.normalize(n.$editor.css("height"));l.call(n,q);n.$source.height(p)};var i=this.modalInit;this.modalInit=function(r,q,p,s){n.mpModalInit();i.call(n,r,q,p,s)};var j=this.modalShowOnDesktop;this.modalShowOnDesktop=function(){j.call(n);$(document.body).css("overflow",false)};var g=this.destroy;this.destroy=function(){n.callback("destroy",false,{});g.call(n)};var f=this.sync;this.sync=function(q,p){if(p===true){f.call(n,q)}};var h=this.buttonActiveObserver;this.buttonActiveObserver=function(p,q){h.call(n,p,q);n.mpButtonActiveObserver(p,q)};if(this.opts.activeButtons){this.$editor.off("mouseup.redactor keyup.redactor").on("mouseup.redactor keyup.redactor",$.proxy(this.buttonActiveObserver,this))}this.$toolbar.find("a.re-indent, a.re-outdent").addClass("redactor_button_disabled");var d=this.imageResizeControls;this.imageResizeControls=function(p){if(!p.data("attachmentID")){d.call(n,p)}return false};var a=this.imageEdit;this.imageEdit=function(p){a.call(n,p);$("#redactor_image_source").val($(p).prop("src"))};var k=this.imageSave;this.imageSave=function(p){$(p).prop("src",$("#redactor_image_source").val());k.call(n,p)};var c=this.buildEventKeydownBackspace;this.buildEventKeydownBackspace=function(r,q,p){if(c.call(n,r,q,p)!==false){return n.mpBuildEventKeydownBackspace(r,q,p)}return false};this.setOption("modalOpenedCallback",$.proxy(this.modalOpenedCallback,this));this.setOption("dropdownShowCallback",$.proxy(this.dropdownShowCallback,this));this.modalTemplatesInit()},cleanRemoveSpaces:function(b,a){return b},mpButtonActiveObserver:function(d,g){var b=this.getParent();b=(b===false)?null:$(b);var a=this;var c=this.$editor.get()[0];var f=function(e,j,h,k,l){var i=a.$toolbar.find(j);if(b&&b.closest(e,c).length!=0){i[(h?"removeClass":"addClass")](k)}else{if(l&&!a.opts.visual){return}i[(h?"addClass":"removeClass")](k)}};f("ul","a.re-indent, a.re-outdent",true,"redactor_button_disabled");f("inline.inlineCode","a.re-__wcf_tt",false,"redactor_act");f("blockquote.quoteBox","a.re-__wcf_quote",false,"redactor_button_disabled",true);f("sub","a.re-subscript",false,"redactor_act");f("sup","a.re-superscript",false,"redactor_act")},inlineRemoveStyle:function(a){this.selectionSave();this.inlineEachNodes(function(b){$(b).css(a,"");this.removeEmptyAttr(b,"style")});this.$editor.find("inline").each(function(c,d){if(!d.attributes.length){var b=$(d);b.replaceWith(b.html())}});this.selectionRestore();this.sync()},inlineMethods:function(e,b,g){this.bufferSet();this.selectionSave();var c=this.getRange();var d=this.getElement();if((c.collapsed||c.startContainer===c.endContainer)&&d&&!this.nodeTestBlocks(d)){$(d)[e](b,g)}else{var f,a=g;switch(b){case"font-size":f="fontSize";a=4;break;case"font-family":f="fontName";break;case"color":f="foreColor";break;case"background-color":f="backColor";break}if(e==="addClass"){f="fontSize";a=4}this.document.execCommand(f,false,a);var h=this.$editor.find("font");$.each(h,$.proxy(function(j,k){this.inlineSetMethods(e,k,b,g)},this))}this.selectionRestore();this.sync()},mpIndentingStart:function(a){if(this.getBlock().tagName=="LI"){return true}return false},modalTemplatesInit:function(){this.setOption("modal_image",'<fieldset><dl><dt><label for="redactor_file_link">'+this.opts.curLang.image_web_link+'</label></dt><dd><input type="text" name="redactor_image_source" id="redactor_image_source" class="long" /></dd></dl><dl><dt><label for="redactor_form_image_align">'+this.opts.curLang.image_position+'</label></dt><dd><select id="redactor_form_image_align"><option value="none">'+this.opts.curLang.none+'</option><option value="left">'+this.opts.curLang.left+'</option><option value="right">'+this.opts.curLang.right+'</option></select></dd></dl></fieldset><div class="formSubmit"><button id="redactor_upload_btn">'+this.opts.curLang.insert+"</button></div>");this.setOption("modal_image_edit",this.getOption("modal_image").replace('<button id="redactor_upload_btn">'+this.opts.curLang.insert+"</button>",'<button id="redactorSaveBtn">'+this.opts.curLang.save+"</button>"));this.setOption("modal_link",'<fieldset><dl><dt><label for="redactor_link_url">URL</label></dt><dd><input type="text" id="redactor_link_url" class="long" /></dd></dl><dl><dt><label for="redactor_link_url_text">'+this.opts.curLang.text+'</label></dt><dd><input type="text" id="redactor_link_url_text" class="long" /></dd></dl></fieldset><div class="formSubmit"><button id="redactor_insert_link_btn">'+this.opts.curLang.insert+"</button></div>");this.setOption("modal_table",'<fieldset><dl><dt><label for="redactor_table_rows">'+this.opts.curLang.rows+'</label></dt><dd><input type="number" size="5" value="2" min="0" id="redactor_table_rows" class="tiny" /></dd></dl><dl><dt><label for="redactor_table_columns">'+this.opts.curLang.columns+'</label></dt><dd><input type="number" size="5" value="3" min="0" id="redactor_table_columns" class="tiny" /></dd></dl></fieldset><div class="formSubmit"><button id="redactor_insert_table_btn">'+this.opts.curLang.insert+"</button></div>");this.setOption("modal_quote",'<fieldset><dl><dt><label for="redactorQuoteAuthor">'+WCF.Language.get("wcf.bbcode.quote.edit.author")+'</label></dt><dd><input type="text" id="redactorQuoteAuthor" class="long" /></dd></dl><dl><dt><label for="redactorQuoteLink">'+WCF.Language.get("wcf.bbcode.quote.edit.link")+'</label></dt><dd><input type="text" id="redactorQuoteLink" class="long" /></dd></dl></fieldset><div class="formSubmit"><button id="redactorEditQuote">'+this.opts.curLang.save+"</button></div>")},mpModalInit:function(){if(!$("#redactor_modal_overlay").length){this.$overlay=$('<div id="redactor_modal_overlay" class="dialogOverlay" />').css({height:"100%",zIndex:50000}).hide().appendTo(document.body)}if(!$("#redactor_modal").length){this.$modal=$('<div id="redactor_modal" class="dialogContainer" />').css({display:"none",zIndex:50001}).appendTo(document.body);$('<header class="dialogTitlebar"><span id="redactor_modal_header" class="dialogTitle" /><a id="redactor_modal_close" class="dialogCloseButton" /></header>').appendTo(this.$modal);$('<div class="dialogContent"><div id="redactor_modal_inner" /></div>').appendTo(this.$modal)}this.$modal.children(".dialogContent").removeClass("dialogForm")},modalOpenedCallback:function(){var a=0;if(this.$modal.find(".formSubmit").length){a=this.$modal.find(".formSubmit").outerHeight();this.$modal.children(".dialogContent").addClass("dialogForm").css({marginBottom:a+"px"})}else{this.$modal.children(".dialogContent").removeClass("dialogForm").css({marginBottom:"0px"})}if(!this.isMobile()){var b=this.$modal.getDimensions("outer");this.$modal.css({marginLeft:-1*Math.round(b.width/2)+"px",marginTop:-1*Math.round(b.height/2)+"px"})}},dropdownShowCallback:function(a){if(!a.dropdown.hasClass("dropdownMenu")){a.dropdown.addClass("dropdownMenu");a.dropdown.children(".redactor_separator_drop").replaceWith('<li class="dropdownDivider" />');a.dropdown.children("a").wrap("<li />")}},inlineEachNodes:function(e){var b=this.getRange(),c=this.getElement(),a=this.getNodes(),d;if(b.collapsed||b.startContainer===b.endContainer&&c){a=$(c);d=true}$.each(a,$.proxy(function(g,j){if(!d&&j.tagName!=="INLINE"){var f=this.getSelectionText();var k=$(j).parent().text();var h=this.removeZeroWidthSpace(f)==this.removeZeroWidthSpace(k);if(h&&j.parentNode.tagName==="INLINE"&&!$(j.parentNode).hasClass("redactor_editor")){j=j.parentNode}else{return}}e.call(this,j)},this))},imageCallbackLink:function(){var a=$.trim($("#redactor_image_source").val());if(a.length){var c="";var d=$("#redactor_form_image_align").val();switch(d){case"left":c=' style="float: left;"';break;case"right":c=' style="float: right;"';break}var b='<img id="image-marker" src="'+a+'"'+c+" />";this.imageInsert(b,true)}else{this.modalClose()}},observeLinks:function(){this.$editor.find("a:not(.redactorQuoteEdit)").on("click",$.proxy(this.linkObserver,this));this.$editor.on("click.redactor",$.proxy(function(a){this.linkObserverTooltipClose(a)},this));$(document).on("click.redactor",$.proxy(function(a){this.linkObserverTooltipClose(a)},this))},observeImages:function(){if(this.opts.observeImages===false){return false}this.$editor.find("img:not(.smiley)").each($.proxy(function(a,c){if(this.browser("msie")){$(c).attr("unselectable","on")}var b=$(c).parent();if(!b.hasClass("royalSlider")&&!b.hasClass("fotorama")){this.imageResize(c)}},this));this.$editor.find(".fotorama, .royalSlider").on("click",$.proxy(this.editGallery,this))},mpBuildEventKeydownBackspace:function(c,d,b){var a=$.trim((d.textContent)?d.textContent:d.innerText);if(a==""&&b.parentNode&&b.parentNode.tagName=="BLOCKQUOTE"){var e=b.parentNode.parentNode;$(b.parentNode).remove();this.selectionStart(e);return false}},cleanGetTabs:function(){return""},cleanRemoveEmptyTags:function(a){return a}};
// wupload.js
-if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wupload={_boundGlobalUploadEvents:false,_wUploadDropArea:{},_timer:null,_isDragging:false,_isFile:false,init:function(){var a=".redactor_"+this.$source.wcfIdentify();$(document).on("dragover"+a,$.proxy(this._dragOver,this));$(document).on("dragleave"+a,$.proxy(this._dragLeave,this));$(document).on("drop"+a,$.proxy(function(b){b.preventDefault();this._revertDropArea(undefined,this.$source.wcfIdentify())},this));if(!this._boundGlobalUploadEvents){this._boundGlobalUploadEvents=true;$(document).on("dragend",function(b){b.preventDefault()})}WCF.System.Event.addListener("com.woltlab.wcf.attachment","autoInsert_"+this.$source.wcfIdentify(),$.proxy(this.insertPastedImageAttachment,this))},_dragOver:function(c){c=c.originalEvent;if(!c.dataTransfer||!c.dataTransfer.types){return}if(c.dataTransfer.types[0]!=="Files"&&c.dataTransfer.types[0]!=="application/x-moz-file"){this._isFile=false;return}this._isFile=true;c.preventDefault();if(!this._isDragging){var b=this.$source.wcfIdentify();if(this._wUploadDropArea[b]===undefined){this._wUploadDropArea[b]=$('<div class="redactorDropArea">'+WCF.Language.get("wcf.attachment.dragAndDrop.dropHere")+"</div>").hide().appendTo(document.body);this._wUploadDropArea[b].on("dragover",$.proxy(this._hoverDropArea,this)).on("dragleave",$.proxy(this._revertDropArea,this)).on("drop",$.proxy(this._drop,this))}var a=(this.inWysiwygMode())?this.$editor.getDimensions("outer"):this.$source.getDimensions("outer");var d=(this.inWysiwygMode())?this.$editor.getOffsets("offset"):this.$source.getOffsets("offset");this._wUploadDropArea[b].css({height:a.height+"px",left:d.left+"px",lineHeight:a.height+"px",top:d.top+"px",width:a.width+"px"}).show();this._isDragging=true}c.preventDefault()},_hoverDropArea:function(a){this._wUploadDropArea[this.$source.wcfIdentify()].addClass("active").text(WCF.Language.get("wcf.attachment.dragAndDrop.dropNow"))},_revertDropArea:function(c,a){if(!this._isFile){return}var b=a||this.$source.wcfIdentify();this._wUploadDropArea[b].removeClass("active").text(WCF.Language.get("wcf.attachment.dragAndDrop.dropHere"));if(a){this._wUploadDropArea[b].hide()}},_dragLeave:function(){if(!this._isDragging||!this._isFile){return}if(this._timer===null){var a=this;this._timer=new WCF.PeriodicalExecuter(function(b){b.stop();if(!a._isDragging){a._wUploadDropArea[a.$source.wcfIdentify()].hide()}},100)}else{this._timer.resume()}this._isDragging=false},_drop:function(b){if(!this._isFile){return}b=b.originalEvent||b;if(b.dataTransfer&&b.dataTransfer.files.length==1){b.preventDefault();var a=this.$source.wcfIdentify();this._revertDropArea(undefined,a);WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","upload_"+a,{file:b.dataTransfer.files[0]})}},pasteClipboardUploadMozilla:function(){this.$editor.find("img[data-mozilla-paste-image]").each($.proxy(function(d,g){var f=$(g);var a=f.prop("src").split(",");var e=a[0].split(";")[0].split(":")[1];var c=a[1];var b={blob:WCF.base64toBlob(c,e),uploadID:null};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","upload_"+this.$source.wcfIdentify(),b);f.replaceWith('<span class="redactor-pastedImageFromClipboard-'+b.uploadID+'" />')},this))},insertPastedImageAttachment:function(b){var a=this.$editor.find("span.redactor-pastedImageFromClipboard-"+b.uploadID);a.before(b.attachment);a.remove()}};
+if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wupload={_boundGlobalUploadEvents:false,_wUploadDropArea:{},_timer:null,_isDragging:false,_isFile:false,init:function(){var a=".redactor_"+this.$source.wcfIdentify();$(document).on("dragover"+a,$.proxy(this._dragOver,this));$(document).on("dragleave"+a,$.proxy(this._dragLeave,this));$(document).on("drop"+a,$.proxy(function(b){b.preventDefault();this._revertDropArea(undefined,this.$source.wcfIdentify())},this));if(!this._boundGlobalUploadEvents){this._boundGlobalUploadEvents=true;$(document).on("dragend",function(b){b.preventDefault()})}WCF.System.Event.addListener("com.woltlab.wcf.attachment","autoInsert_"+this.$source.wcfIdentify(),$.proxy(this.insertPastedImageAttachment,this))},_dragOver:function(c){c=c.originalEvent;if(!c.dataTransfer||!c.dataTransfer.types){return}if(c.dataTransfer.types[0]!=="application/x-moz-file"&&c.dataTransfer.types.indexOf("Files")===-1){this._isFile=false;return}this._isFile=true;c.preventDefault();if(!this._isDragging){var b=this.$source.wcfIdentify();if(this._wUploadDropArea[b]===undefined){this._wUploadDropArea[b]=$('<div class="redactorDropArea">'+WCF.Language.get("wcf.attachment.dragAndDrop.dropHere")+"</div>").hide().appendTo(document.body);this._wUploadDropArea[b].on("dragover",$.proxy(this._hoverDropArea,this)).on("dragleave",$.proxy(this._revertDropArea,this)).on("drop",$.proxy(this._drop,this))}var a=(this.inWysiwygMode())?this.$editor.getDimensions("outer"):this.$source.getDimensions("outer");var d=(this.inWysiwygMode())?this.$editor.getOffsets("offset"):this.$source.getOffsets("offset");this._wUploadDropArea[b].css({height:a.height+"px",left:d.left+"px",lineHeight:a.height+"px",top:d.top+"px",width:a.width+"px"}).show();this._isDragging=true}c.preventDefault()},_hoverDropArea:function(a){this._wUploadDropArea[this.$source.wcfIdentify()].addClass("active").text(WCF.Language.get("wcf.attachment.dragAndDrop.dropNow"))},_revertDropArea:function(c,a){if(!this._isFile){return}var b=a||this.$source.wcfIdentify();this._wUploadDropArea[b].removeClass("active").text(WCF.Language.get("wcf.attachment.dragAndDrop.dropHere"));if(a){this._wUploadDropArea[b].hide()}},_dragLeave:function(){if(!this._isDragging||!this._isFile){return}if(this._timer===null){var a=this;this._timer=new WCF.PeriodicalExecuter(function(b){b.stop();if(!a._isDragging){a._wUploadDropArea[a.$source.wcfIdentify()].hide()}},100)}else{this._timer.resume()}this._isDragging=false},_drop:function(c){if(!this._isFile){return}c=c.originalEvent||c;if(c.dataTransfer&&c.dataTransfer.files.length){c.preventDefault();var b=this.$source.wcfIdentify();this._revertDropArea(undefined,b);for(var d=0;d<c.dataTransfer.files.length;d++){var a=c.dataTransfer.files[d];if(a.type){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","upload_"+b,{file:a})}}}},pasteClipboardUploadMozilla:function(){this.$editor.find("img[data-mozilla-paste-image]").each($.proxy(function(d,g){var f=$(g);var a=f.prop("src").split(",");var e=a[0].split(";")[0].split(":")[1];var c=a[1];var b={blob:WCF.base64toBlob(c,e),uploadID:null};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","upload_"+this.$source.wcfIdentify(),b);f.replaceWith('<span class="redactor-pastedImageFromClipboard-'+b.uploadID+'" />')},this))},insertPastedImageAttachment:function(b){var a=this.$editor.find("span.redactor-pastedImageFromClipboard-"+b.uploadID);a.before(b.attachment);a.remove()}};
// wutil.js
if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wutil={_autosaveWorker:null,init:function(){this.$source.parents("form").submit($.proxy(this.submit,this));if(this.getOption("wautosave").active){this.autosaveEnable();if(this.getOption("wautosave").saveOnInit||this.$source.data("saveOnInit")){this.setOption("wAutosaveOnce",true)}else{this.autosaveRestore()}}this.setOption("autosave",false);var b=this.destroy;var a=this;this.destroy=function(){a.autosaveDisable();b.call(a)}},insertAtCaret:function(b){if(this.opts.visual){console.debug("insertAtCaret() failed: Editor is in WYSIWYG-mode.");return false}this.$source.focus();var c=this.$source.getCaret();if(c==-1){console.debug("insertAtCaret() failed: Source is not input[type=text], input[type=password] or textarea.")}var a=this.$source.val();a=a.substr(0,c)+b+a.substr(c);this.$source.val(a);return true},insertDynamic:function(a,b){if(this.inWysiwygMode()){this.insertHtml(a)}else{if(b===undefined||b===null){b=a}this.insertAtCaret(b)}},setOption:function(a,b){this.opts[a]=b},getOption:function(a){if(this.opts[a]){return this.opts[a]}return null},inPlainMode:function(){return !this.opts.visual},inWysiwygMode:function(){return(this.opts.visual)},replaceRangesWith:function(a){getSelection().removeAllRanges();getSelection().addRange(a)},getText:function(){if(this.inWysiwygMode()){this.wSync()}return this.$source.val()},submit:function(){if(this.inWysiwygMode()){this.wSync()}this.autosavePurge()},reset:function(){if(this.inWysiwygMode()){this.$editor.html("<p>"+this.opts.invisibleSpace+"</p>");this.sync()}else{this.$source.val("")}WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","reset",{wysiwygContainerID:this.$source.wcfIdentify()})},autosaveEnable:function(a){if(!this.getOption("wautosave").active){this.setOption("wautosave",{active:true,key:a})}if(this._autosaveWorker===null){this._autosaveWorker=new WCF.PeriodicalExecuter($.proxy(this._saveTextToStorage,this),60*1000)}return true},_saveTextToStorage:function(){localStorage.setItem(this.getOption("wautosave").key,this.getText())},autosaveDisable:function(){if(!this.getOption("wautosave").active){return false}this._autosaveWorker.stop();this._autosaveWorker=null;this.setOption("wautosave",{active:false,key:""});return true},autosavePurge:function(){localStorage.removeItem(this.getOption("wautosave").key)},autosaveRestore:function(){var a=this.getOption("wautosave");var b=localStorage.getItem(a.key);if(b!==null){if(this.inWysiwygMode()){this.setOption("wOriginalValue",b)}else{this.$source.val(b)}return true}return false},buttonReplace:function(d,b,e,g,f){var a=this.buttonGet(d);var c=this.buttonAddAfter(d,b,e,g,f);if(a.parent().hasClass("separator")){c.parent().addClass("separator")}a.parent().remove();return c},removeZeroWidthSpace:function(a){var b="";for(var e=0,d=a.length;e<d;e++){var c=a.charCodeAt(e).toString(16);if(c!="200b"){b+=a[e]}}return b},wSync:function(){this.sync(undefined,true);this.$source.val(this.convertFromHtml(this.cleanHtml(this.$source.val())))},getSource:function(){return this.$source},getName:function(){return this.$source.wcfIdentify()},selectionEndOfEditor:function(){this.selectionEnd(this.$editor.children(":last")[0])},isCaret:function(a){var b=(a)?a:this.getRange();return b.collapsed},isEndOfElement:function(a){var c=this.getRange();if(!this.isCaret(c)){console.debug("case#1");return false}if(c.endContainer.nodeType===Element.TEXT_NODE){if(c.endOffset<c.endContainer.length){console.debug("case#2");return false}}if(!this.isNodeWithin(c.endContainer,a)){console.debug("case#3");return false}var b=c.endContainer;while(b!==a){if(b.nextSibling){console.debug("case#4");return false}b=b.parentNode}return true},isNodeWithin:function(c,b){var a=$(c);while(a[0]!==this.$editor[0]){if(a[0]===b){return true}a=a.parent()}return false},containsTag:function(b,a){switch(b.nodeType){case Element.ELEMENT_NODE:if(b.tagName===a){return true}case Element.DOCUMENT_FRAGMENT_NODE:for(var c=0;c<b.childNodes.length;c++){if(this.containsTag(b.childNodes[c],a)){return true}}return false;break;default:return false;break}},replaceText:function(b){var a=false;if(this.inWysiwygMode()){this.toggle();a=true}this.$source.val(b);if(a){this.toggle()}}};