// WoltLabEvent.js
$.Redactor.prototype.WoltLabEvent=function(){"use strict";return{init:function(){this._callbacks=[],this._elementId=this.$element[0].id,require(["EventHandler"],this.WoltLabEvent._setEvents.bind(this))},_setEvents:function(t){var e=this.$element[0].id,i=this.observe.load;this.observe.load=function(){i.call(this),t.fire("com.woltlab.wcf.redactor","observe_load_"+e,{editor:this.$editor[0]})}.bind(this),this.opts.callbacks.keyup=function(i){var n={cancel:!1,event:i};return t.fire("com.woltlab.wcf.redactor","keyup_"+e,n),n.cancel===!1},t.add("com.woltlab.wcf.redactor2","getText_"+e,function(t){t.message=this.code.get()}.bind(this))},register:function(t,e){require(["EventHandler"],function(i){-1===this._callbacks.indexOf(t)&&(this.opts.callbacks[t]=function(e){var n={cancel:!1,event:e,redactor:this};return i.fire("com.woltlab.wcf.redactor2",t+"_"+this.WoltLabEvent._elementId,n),n.cancel===!1}.bind(this),this._callbacks.push(t)),require(["EventHandler"],function(i){i.add("com.woltlab.wcf.redactor2",t+"_"+this.WoltLabEvent._elementId,e)}.bind(this))}.bind(this))}}};
// WoltLabImage.js
-$.Redactor.prototype.WoltLabImage=function(){"use strict";return{init:function(){var e=this.button.add("woltlabImage","");this.button.addCallback(e,this.WoltLabImage.add);var t=this.image.showEdit;this.image.showEdit=function(e){t(e),elById("redactor-image-source").value=e[0].src;var a=elById("redactor-image-float");e[0].classList.contains("messageFloatObjectLeft")?a.value="left":e[0].classList.contains("messageFloatObjectRight")&&(a.value="right")};var a=this.image.update;this.image.update=function(){var e=elById("redactor-image-source"),t=function(e,t){$('<small class="innerError" />').text(t).insertAfter(e)},i=e.value.trim();if(""===i)return t(e,WCF.Language.get("wcf.global.form.error.empty"));if(!i.match(this.opts.regexps.url))return t(e,WCF.Language.get("wcf.editor.image.source.error.invalid"));var r=this.observe.image[0];r.src=i,r.classList.remove("messageFloatObjectLeft"),r.classList.remove("messageFloatObjectRight");var o=elById("redactor-image-float").value;("left"===o||"right"===o)&&r.classList.add("messageFloatObject"+WCF.String.ucfirst(o)),a(),r.removeAttribute("alt"),r.removeAttribute("title")}.bind(this),this.opts.modal["image-edit"]='<div class="section"><dl><dt><label for="redactor-image-source">'+WCF.Language.get("wcf.editor.image.source")+'</label></dt><dd><input type="text" id="redactor-image-source" class="long"><small>'+WCF.Language.get("wcf.editor.image.source.description")+'</small></dd></dl><dl><dt><label for="redactor-image-link">'+WCF.Language.get("wcf.editor.image.link")+'</label></dt><dd><input type="text" id="redactor-image-link" class="long"><small>'+WCF.Language.get("wcf.editor.image.link.description")+'</small></dd></dl><dl><dt><label for="redactor-image-float">'+WCF.Language.get("wcf.editor.image.float")+'</label></dt><dd><select id="redactor-image-float"><option value="none">'+WCF.Language.get("wcf.global.noSelection")+'</option><option value="left">'+WCF.Language.get("wcf.editor.image.float.left")+'</option><option value="right">'+WCF.Language.get("wcf.editor.image.float.right")+"</option></select><small>"+WCF.Language.get("wcf.editor.image.float.description")+'</small></dd></dl><input id="redactor-image-title" style="display: none"><div class="formSubmit"><button id="redactor-modal-button-action" class="buttonPrimary">Insert</button><button id="redactor-modal-button-delete" class="redactor-modal-button-offset">Delete</button></div></div>'},add:function(){this.modal.load("image-edit",WCF.Language.get("wcf.editor.image.insert")),this.modal.show(),this.modal.getDeleteButton().hide();var e=this.modal.getActionButton();e[0].addEventListener(WCF_CLICK_EVENT,this.WoltLabImage.insert)},insert:function(e){e.preventDefault(),this.modal.getModal().find(".innerError").remove();var t=elById("redactor-image-source"),a=function(e,t){$('<small class="innerError" />').text(t).insertAfter(e)},i=t.value.trim();if(""===i)return a(t,WCF.Language.get("wcf.global.form.error.empty"));if(!i.match(this.opts.regexps.url))return a(t,WCF.Language.get("wcf.editor.image.source.error.invalid"));var r=elById("redactor-image-link"),o=r.value.trim();if(""!==o&&!o.match(this.opts.regexps.url))return a(r,WCF.Language.get("wcf.editor.image.link.error.invalid"));var l=elById("redactor-image-float").value,s="";("left"===l||"right"===l)&&(s="messageFloatObject"+WCF.String.ucfirst(l));var d='<img src="'+WCF.String.escapeHTML(i)+'"'+(s?' class="'+s+'"':"")+">";o&&(d='<a href="'+WCF.String.escapeHTML(o)+'">'+d+"</a>"),this.modal.close(),this.insert.html(d)}}};
+$.Redactor.prototype.WoltLabImage=function(){"use strict";return{init:function(){var e=this.button.add("woltlabImage","");this.button.addCallback(e,this.WoltLabImage.add);var t=this.image.showEdit;this.image.showEdit=function(e){var a=e[0];if(!a.classList.contains("smiley")){t(e),elById("redactor-image-source").value=a.src;var i=elById("redactor-image-float");a.classList.contains("messageFloatObjectLeft")?i.value="left":a.classList.contains("messageFloatObjectRight")&&(i.value="right"),a.classList.contains("woltlabAttachment")&&elRemove(elById("redactor-image-source-container"))}};var a=this.image.update;this.image.update=function(){var e=this.observe.image[0],t=elById("redactor-image-source"),i=function(e,t){$('<small class="innerError" />').text(t).insertAfter(e)};if(!e.classList.contains("woltlabAttachment")){var r=t.value.trim();if(""===r)return i(t,WCF.Language.get("wcf.global.form.error.empty"));if(!r.match(this.opts.regexps.url))return i(t,WCF.Language.get("wcf.editor.image.source.error.invalid"));e.src=r}e.classList.remove("messageFloatObjectLeft"),e.classList.remove("messageFloatObjectRight");var o=elById("redactor-image-float").value;("left"===o||"right"===o)&&e.classList.add("messageFloatObject"+WCF.String.ucfirst(o)),a(),e.removeAttribute("alt"),e.removeAttribute("title")}.bind(this),this.opts.modal["image-edit"]='<div class="section"><dl id="redactor-image-source-container"><dt><label for="redactor-image-source">'+WCF.Language.get("wcf.editor.image.source")+'</label></dt><dd><input type="text" id="redactor-image-source" class="long"><small>'+WCF.Language.get("wcf.editor.image.source.description")+'</small></dd></dl><dl><dt><label for="redactor-image-link">'+WCF.Language.get("wcf.editor.image.link")+'</label></dt><dd><input type="text" id="redactor-image-link" class="long"><small>'+WCF.Language.get("wcf.editor.image.link.description")+'</small></dd></dl><dl><dt><label for="redactor-image-float">'+WCF.Language.get("wcf.editor.image.float")+'</label></dt><dd><select id="redactor-image-float"><option value="none">'+WCF.Language.get("wcf.global.noSelection")+'</option><option value="left">'+WCF.Language.get("wcf.editor.image.float.left")+'</option><option value="right">'+WCF.Language.get("wcf.editor.image.float.right")+"</option></select><small>"+WCF.Language.get("wcf.editor.image.float.description")+'</small></dd></dl><input id="redactor-image-title" style="display: none"><div class="formSubmit"><button id="redactor-modal-button-action" class="buttonPrimary">Insert</button><button id="redactor-modal-button-delete" class="redactor-modal-button-offset">Delete</button></div></div>'},add:function(){this.modal.load("image-edit",WCF.Language.get("wcf.editor.image.insert")),this.modal.show(),this.modal.getDeleteButton().hide();var e=this.modal.getActionButton();e[0].addEventListener(WCF_CLICK_EVENT,this.WoltLabImage.insert)},insert:function(e){e.preventDefault(),this.modal.getModal().find(".innerError").remove();var t=elById("redactor-image-source"),a=function(e,t){$('<small class="innerError" />').text(t).insertAfter(e)},i=t.value.trim();if(""===i)return a(t,WCF.Language.get("wcf.global.form.error.empty"));if(!i.match(this.opts.regexps.url))return a(t,WCF.Language.get("wcf.editor.image.source.error.invalid"));var r=elById("redactor-image-link"),o=r.value.trim();if(""!==o&&!o.match(this.opts.regexps.url))return a(r,WCF.Language.get("wcf.editor.image.link.error.invalid"));var l=elById("redactor-image-float").value,s="";("left"===l||"right"===l)&&(s="messageFloatObject"+WCF.String.ucfirst(l));var n='<img src="'+WCF.String.escapeHTML(i)+'"'+(s?' class="'+s+'"':"")+">";o&&(n='<a href="'+WCF.String.escapeHTML(o)+'">'+n+"</a>"),this.modal.close(),this.insert.html(n)}}};
// WoltLabLink.js
$.Redactor.prototype.WoltLabLink=function(){"use strict";var i=null;return{init:function(){this.link.show=this.WoltLabLink.show.bind(this),require(["WoltLab/WCF/Ui/Redactor/Link"],function(t){i=t})},show:function(t){"undefined"!=typeof t&&t.preventDefault&&t.preventDefault(),this.observe.closeAllTooltip();var e=this.link.is();i.showDialog({insert:e===!1,submitCallback:function(){var i=this.link.buildLinkFromModal();return i===!1?!1:(this.selection.restore(),this.link.insert(i,!0),!0)}.bind(this)});var n=this.link.buildLinkFromElement(e);n.url=this.link.removeSelfHostFromUrl(n.url),this.link.setModalValues(n),this.detect.isDesktop()&&$("#redactor-link-url").focus()}}};
// WoltLabMedia.js