// wupload.js
if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wupload={_boundGlobalUploadEvents:false,_wUploadDropArea:{},_timer:null,_isDragging: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"){return}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){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._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){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()}};
// 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.empty();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.toggle(false);this.$source.val(b);this.toggle(false);this.focusEnd()}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.cleanHtml(this.$source.val()));this._convertFromHtml()}};
+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.empty();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.toggle(false);this.$source.val(b);this.toggle(false);this.focusEnd()}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.cleanHtml(this.$source.val()));this._convertFromHtml()},getSource:function(){return this.$source},getName:function(){return this.$source.wcfIdentify()}};