Updating minified JavaScript files
authorWoltLab <woltlab@woltlab.com>
Wed, 6 Jan 2021 14:44:19 +0000 (14:44 +0000)
committerWoltLab <woltlab@woltlab.com>
Wed, 6 Jan 2021 14:44:19 +0000 (14:44 +0000)
wcfsetup/install/files/js/3rdParty/redactor2/redactor.combined.min.js

index 88cd472e1607f18c5729331f2d206985951d8a1f..8f322ad873c6c863be5b9c7c200189210f4bb549 100644 (file)
@@ -1,7 +1,7 @@
 // redactor.combined.min.js -- DO NOT EDIT
 
 // redactor.js
-(function (window, undefined) { !function(g){"use strict";Function.prototype.bind||(Function.prototype.bind=function(t){var e=this;return function(){return e.apply(t)}});var i=0,h=null;function l(t,e){return new l.prototype.init(t,e)}"function"==typeof window.require&&require(["Environment"],function(t){h=t}),g.fn.redactor=function(r){var n=[],s=Array.prototype.slice.call(arguments,1);return"string"==typeof r?this.each(function(){var t,e,i=g.data(this,"redactor");"-1"!==r.search(/\./)?void 0!==i[(t=r.split("."))[0]]&&(t=i[t[0]][t[1]]):t=i[r],void 0!==i&&g.isFunction(t)?void 0!==(e=t.apply(i,s))&&e!==i&&n.push(e):g.error('No such method "'+r+'" for Redactor')}):this.each(function(){g.data(this,"redactor",{}),g.data(this,"redactor",l(this,r))}),0===n.length?this:1===n.length?n[0]:n},g.Redactor=l,g.Redactor.VERSION="2.99",g.Redactor.modules=["air","autosave","block","buffer","build","button","caret","clean","code","core","detect","dropdown","events","file","focus","image","indent","inline","insert","keydown","keyup","lang","line","link","linkify","list","marker","modal","observe","offset","paragraphize","paste","placeholder","progress","selection","shortcuts","storage","toolbar","upload","uploads3","utils","browser"],g.Redactor.settings={},g.Redactor.opts={animation:!1,lang:"en",direction:"ltr",spellcheck:!0,overrideStyles:!0,stylesClass:!1,scrollTarget:document,focus:!1,focusEnd:!1,clickToEdit:!1,structure:!1,tabindex:!1,minHeight:!1,maxHeight:!1,maxWidth:!1,plugins:!1,callbacks:{},placeholder:!1,linkify:!0,enterKey:!0,pastePlainText:!1,pasteImages:!0,pasteLinks:!0,pasteBlockTags:["pre","h1","h2","h3","h4","h5","h6","table","tbody","thead","tfoot","th","tr","td","ul","ol","li","blockquote","p","figure","figcaption"],pasteInlineTags:["br","strong","ins","code","del","span","samp","kbd","sup","sub","mark","var","cite","small","b","u","em","i"],preClass:!1,preSpaces:4,tabAsSpaces:!1,tabKey:!0,autosave:!1,autosaveName:!1,autosaveFields:!1,imageUpload:null,imageUploadParam:"file",imageUploadFields:!1,imageUploadForms:!1,imageTag:"figure",imageEditable:!0,imageCaption:!0,imagePosition:!1,imageResizable:!1,imageFloatMargin:"10px",dragImageUpload:!0,multipleImageUpload:!0,clipboardImageUpload:!0,fileUpload:null,fileUploadParam:"file",fileUploadFields:!1,fileUploadForms:!1,dragFileUpload:!0,s3:!1,linkNewTab:!1,linkTooltip:!0,linkNofollow:!1,linkSize:30,linkValidation:!0,pasteLinkTarget:!1,videoContainerClass:"video-container",toolbar:!0,toolbarFixed:!0,toolbarFixedTarget:document,toolbarFixedTopOffset:0,toolbarExternal:!1,toolbarOverflow:!1,air:!1,airWidth:!1,formatting:["p","blockquote","pre","h1","h2","h3","h4","h5","h6"],formattingAdd:!1,buttons:["format","bold","italic","deleted","lists","image","file","link","horizontalrule"],buttonsTextLabeled:!1,buttonsHide:[],buttonsHideOnMobile:[],script:!0,removeNewlines:!1,removeComments:!0,replaceTags:{b:"strong",i:"em",strike:"del"},keepStyleAttr:[],keepInlineOnEnter:!1,shortcuts:{"ctrl+shift+m, meta+shift+m":{func:"inline.removeFormat"},"ctrl+b, meta+b":{func:"inline.format",params:["bold"]},"ctrl+i, meta+i":{func:"inline.format",params:["italic"]},"ctrl+h, meta+h":{func:"inline.format",params:["superscript"]},"ctrl+l, meta+l":{func:"inline.format",params:["subscript"]},"ctrl+k, meta+k":{func:"link.show"},"ctrl+shift+7":{func:"list.toggle",params:["orderedlist"]},"ctrl+shift+8":{func:"list.toggle",params:["unorderedlist"]}},shortcutsAdd:!1,activeButtons:["deleted","italic","bold"],activeButtonsStates:{b:"bold",strong:"bold",i:"italic",em:"italic",del:"deleted",strike:"deleted"},langs:{en:{format:"Format",image:"Image",file:"File",link:"Link",bold:"Bold",italic:"Italic",deleted:"Strikethrough",underline:"Underline","bold-abbr":"B","italic-abbr":"I","deleted-abbr":"S","underline-abbr":"U",lists:"Lists","link-insert":"Insert link","link-edit":"Edit link","link-in-new-tab":"Open link in new tab",unlink:"Unlink",cancel:"Cancel",close:"Close",insert:"Insert",save:"Save",delete:"Delete",text:"Text",edit:"Edit",title:"Title",paragraph:"Normal text",quote:"Quote",code:"Code",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",filename:"Name",optional:"optional",unorderedlist:"Unordered List",orderedlist:"Ordered List",outdent:"Outdent",indent:"Indent",horizontalrule:"Line","upload-label":"Drop file here or ",caption:"Caption",bulletslist:"Bullets",numberslist:"Numbers","image-position":"Position",none:"None",left:"Left",right:"Right",center:"Center","accessibility-help-label":"Rich text editor"}},type:"textarea",inline:!1,inlineTags:["a","span","strong","strike","b","u","em","i","code","del","ins","samp","kbd","sup","sub","mark","var","cite","small"],blockTags:["pre","ul","ol","li","p","h1","h2","h3","h4","h5","h6","dl","dt","dd","div","td","blockquote","output","figcaption","figure","address","section","header","footer","aside","article","iframe"],paragraphize:!0,paragraphizeBlocks:["table","div","pre","form","ul","ol","h1","h2","h3","h4","h5","h6","dl","blockquote","figcaption","address","section","header","footer","aside","article","object","style","script","iframe","select","input","textarea","button","option","map","area","math","hr","fieldset","legend","hgroup","nav","figure","details","menu","summary","p"],emptyHtml:"<p>&#x200b;</p>",invisibleSpace:"&#x200b;",emptyHtmlRendered:g("").html("​").html(),imageTypes:["image/png","image/jpeg","image/gif"],userAgent:navigator.userAgent.toLowerCase(),observe:{dropdowns:[]},regexps:{linkyoutube:/https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.\-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/gi,linkvimeo:/https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/,linkimage:/((https?|www)[^\s]+\.)(jpe?g|png|gif)(\?[^\s-]+)?/gi,url:/(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/gi}},l.fn=g.Redactor.prototype={keyCode:{BACKSPACE:8,DELETE:46,UP:38,DOWN:40,ENTER:13,SPACE:32,ESC:27,TAB:9,CTRL:17,META:91,SHIFT:16,ALT:18,RIGHT:39,LEFT:37,LEFT_WIN:91},init:function(t,e){if(this.$element=g(t),this.uuid=i++,this.sBuffer=[],this.sRebuffer=[],this.loadOptions(e),this.loadModules(),this.opts.clickToEdit&&!this.$element.hasClass("redactor-click-to-edit"))return this.loadToEdit(e);this.$element.hasClass("redactor-click-to-edit")&&this.$element.removeClass("redactor-click-to-edit"),this.reIsBlock=new RegExp("^("+this.opts.blockTags.join("|").toUpperCase()+")$","i"),this.reIsInline=new RegExp("^("+this.opts.inlineTags.join("|").toUpperCase()+")$","i"),this.opts.dragImageUpload=null!==this.opts.imageUpload&&this.opts.dragImageUpload,this.opts.dragFileUpload=null!==this.opts.fileUpload&&this.opts.dragFileUpload,this.formatting={},this.lang.load(),g.extend(this.opts.shortcuts,this.opts.shortcutsAdd),this.$editor=this.$element,this.detectType(),this.core.callback("start"),this.core.callback("startToEdit"),this.start=!0,this.build.start()},detectType:function(){this.build.isInline()||this.opts.inline?this.opts.type="inline":this.build.isTag("DIV")?this.opts.type="div":this.build.isTag("PRE")&&(this.opts.type="pre")},loadToEdit:function(t){this.$element.on("click.redactor-click-to-edit",g.proxy(function(){this.initToEdit(t)},this)),this.$element.addClass("redactor-click-to-edit")},initToEdit:function(e){g.extend(e.callbacks,{startToEdit:function(){this.insert.node(this.marker.get(),!1)},initToEdit:function(){this.selection.restore(),this.clickToCancelStorage=this.code.get(),g(this.opts.clickToCancel).off(".redactor-click-to-edit"),g(this.opts.clickToCancel).show().on("click.redactor-click-to-edit",g.proxy(function(t){t.preventDefault(),this.core.destroy(),this.events.syncFire=!1,this.$element.html(this.clickToCancelStorage),this.core.callback("cancel",this.clickToCancelStorage),this.events.syncFire=!0,this.clickToCancelStorage="",g(this.opts.clickToCancel).hide(),g(this.opts.clickToSave).hide(),this.$element.on("click.redactor-click-to-edit",g.proxy(function(){this.initToEdit(e)},this)),this.$element.addClass("redactor-click-to-edit")},this)),g(this.opts.clickToSave).off(".redactor-click-to-edit"),g(this.opts.clickToSave).show().on("click.redactor-click-to-edit",g.proxy(function(t){t.preventDefault(),this.core.destroy(),this.core.callback("save",this.code.get()),g(this.opts.clickToCancel).hide(),g(this.opts.clickToSave).hide(),this.$element.on("click.redactor-click-to-edit",g.proxy(function(){this.initToEdit(e)},this)),this.$element.addClass("redactor-click-to-edit")},this))}}),this.$element.redactor(e),this.$element.off(".redactor-click-to-edit")},loadOptions:function(t){var e={};void 0!==g.Redactor.settings.namespace&&!this.$element.hasClass(g.Redactor.settings.namespace)||(e=g.Redactor.settings),this.opts=g.extend({},g.Redactor.opts,this.$element.data(),t),this.opts=g.extend({},this.opts,e)},getModuleMethods:function(e){return Object.getOwnPropertyNames(e).filter(function(t){return"function"==typeof e[t]})},loadModules:function(){for(var t=g.Redactor.modules.length,e=0;e<t;e++)this.bindModuleMethods(g.Redactor.modules[e])},bindModuleMethods:function(t){if(void 0!==this[t]){this[t]=this[t]();for(var e=this.getModuleMethods(this[t]),i=e.length,r=0;r<i;r++)this[t][e[r]]=this[t][e[r]].bind(this)}},air:function(){return{enabled:!1,collapsed:function(){},collapsedEnd:function(){},build:function(){},append:function(){},createContainer:function(){},show:function(){},bindHide:function(){},hide:function(){}}},autosave:function(){return{enabled:!1,html:!1,init:function(){},is:function(){},send:function(){},getHiddenFields:function(){},success:function(){},disable:function(){}}},block:function(){return{format:function(t,e,i,r){if(t="quote"===t?"blockquote":t,this.block.tags=["p","blockquote","pre","h1","h2","h3","h4","h5","h6","div","figure"],-1!==g.inArray(t,this.block.tags))return"p"===t&&void 0===e&&(e="class"),this.buffer.set(),this.utils.isCollapsed()?this.block.formatCollapsed(t,e,i,r):this.block.formatUncollapsed(t,e,i,r)},formatCollapsed:function(t,e,i,r){this.selection.save();var n=this.selection.block(),s=n.tagName.toLowerCase();if(-1!==g.inArray(s,this.block.tags)){var o,a,l=!1;if(s===t&&void 0===e&&(t="p",l=!0),l&&(this.block.removeAllClass(),this.block.removeAllAttr()),"blockquote"===s&&this.utils.isEndOfElement(n)?(this.marker.remove(),(o=document.createElement("p")).innerHTML=this.opts.invisibleSpace,g(n).after(o),this.caret.start(o),0!==(a=g(n).children().last()).length&&"BR"===a[0].tagName&&a.remove()):o=this.utils.replaceToTag(n,t),"object"==typeof e)for(var c in r=i,e)o=this.block.setAttr(o,c,e[c],r);else o=this.block.setAttr(o,e,i,r);return"pre"===t&&1===o.length&&g(o).html(g.trim(g(o).html())),this.selection.restore(),this.block.removeInlineTags(o),o}this.selection.restore()},formatUncollapsed:function(t,e,i,r){this.selection.save();var n=[],s=this.selection.blocks();s[0]&&(g(s[0]).hasClass("redactor-in")||g(s[0]).hasClass("redactor-box"))&&(s=this.core.editor().find(this.opts.blockTags.join(", ")));for(var o,a=s.length,l=0;l<a;l++){var c=s[l].tagName.toLowerCase();if(-1!==g.inArray(c,this.block.tags)&&"figure"!==c){var h=this.utils.replaceToTag(s[l],t);if("object"==typeof e)for(var d in r=i,e)h=this.block.setAttr(h,d,e[d],r);else h=this.block.setAttr(h,e,i,r);n.push(h),this.block.removeInlineTags(h)}}return this.selection.restore(),"pre"===t&&0!==n.length&&(o=n[0],g.each(n,function(t,e){0!==t&&(g(o).append("\n"+g.trim(e.html())),g(e).remove())}),(n=[]).push(o)),n},removeInlineTags:function(t){t=t[0]||t;var e,i=this.opts.inlineTags;-1!==g.inArray(t.tagName,["PRE","H1","H2","H3","H4","H5","H6"])&&("PRE"!==t.tagName&&(e=i.indexOf("a"),i.splice(e,1)),g(t).find(i.join(",")).not(".redactor-selection-marker").contents().unwrap())},setAttr:function(t,e,i,r){if(void 0===e)return t;var n=void 0===r?"replace":r;return t="class"===e?this.block[n+"Class"](i,t):"remove"===n||"removeAll"===n?this.block[n+"Attr"](e,t):this.block[n+"Attr"](e,i,t)},getBlocks:function(t){if(t=void 0===t?this.selection.blocks():t,g(t).hasClass("redactor-box")){var i=[],e=this.core.editor().children();return g.each(e,g.proxy(function(t,e){this.utils.isBlock(e)&&i.push(e)},this)),i}return t},replaceClass:function(t,e){return g(this.block.getBlocks(e)).removeAttr("class").addClass(t)[0]},toggleClass:function(t,e){return g(this.block.getBlocks(e)).toggleClass(t)[0]},addClass:function(t,e){return g(this.block.getBlocks(e)).addClass(t)[0]},removeClass:function(t,e){return g(this.block.getBlocks(e)).removeClass(t)[0]},removeAllClass:function(t){return g(this.block.getBlocks(t)).removeAttr("class")[0]},replaceAttr:function(t,e,i){return i=this.block.removeAttr(t,i),g(i).attr(t,e)[0]},toggleAttr:function(i,r,t){t=this.block.getBlocks(t);var n=this,s=[];return g.each(t,function(t,e){g(e).attr(i)?s.push(n.block.removeAttr(i,e)):s.push(n.block.addAttr(i,r,e))}),s},addAttr:function(t,e,i){return g(this.block.getBlocks(i)).attr(t,e)[0]},removeAttr:function(t,e){return g(this.block.getBlocks(e)).removeAttr(t)[0]},removeAllAttr:function(t){t=this.block.getBlocks(t);var i=[];return g.each(t,function(t,e){if(void 0!==e.attributes)for(;e.attributes.length;)e.removeAttribute(e.attributes[0].name);i.push(e)}),i}}},buffer:function(){return{set:function(t){void 0===t&&this.buffer.clear(),void 0===t||"undo"===t?this.buffer.setUndo():this.buffer.setRedo()},setUndo:function(){var t=this.selection.saveInstant(),e=this.sBuffer[this.sBuffer.length-1],i=this.core.editor().html();void 0!==e&&e[0]===i||this.sBuffer.push([i,t])},setRedo:function(){var t=this.selection.saveInstant();this.sRebuffer.push([this.core.editor().html(),t])},add:function(){this.sBuffer.push([this.core.editor().html(),0])},undo:function(){var t;0!==this.sBuffer.length&&(t=this.sBuffer.pop(),this.buffer.set("redo"),this.core.editor().html(t[0]),this.selection.restoreInstant(t[1]),this.selection.restore(),this.observe.load())},redo:function(){var t;0!==this.sRebuffer.length&&(t=this.sRebuffer.pop(),this.buffer.set("undo"),this.core.editor().html(t[0]),this.selection.restoreInstant(t[1]),this.selection.restore(),this.observe.load())},clear:function(){this.sRebuffer=[]}}},build:function(){return{start:function(){if("textarea"!==this.opts.type)throw new Error("Only `<textarea>` types are allowed.");this.build.startTextarea(),this.build.setIn(),this.build.setId(),this.build.enableEditor(),this.build.setOptions(),this.build.callEditor()},createContainerBox:function(){this.$box=g('<div class="redactor-box" role="application" />')},setIn:function(){this.core.editor().addClass("redactor-in")},setId:function(){var t="textarea"===this.opts.type?"redactor-uuid-"+this.uuid:this.$element.attr("id");this.core.editor().attr("id",void 0===t?"redactor-uuid-"+this.uuid:t)},getName:function(){var t=this.$element.attr("name");return void 0===t?"content-"+this.uuid:t},buildTextarea:function(){},loadFromTextarea:function(){this.$editor=g("<div />"),this.$textarea=this.$element,this.$element.attr("name",this.build.getName()),this.$box.insertAfter(this.$element).append(this.$editor).append(this.$element),this.build.setStartAttrs(),this.$editor.addClass("redactor-layer"),this.opts.overrideStyles&&this.$editor.addClass("redactor-styles"),this.$element.hide(),this.$box.prepend('<span class="redactor-voice-label" id="redactor-voice-'+this.uuid+'" aria-hidden="false">'+this.lang.get("accessibility-help-label")+"</span>")},setStartAttrs:function(){this.$editor.attr({"aria-labelledby":"redactor-voice-"+this.uuid,role:"presentation"})},startTextarea:function(){this.build.createContainerBox(),this.build.loadFromTextarea(),this.code.start(this.core.textarea().val()),this.core.textarea().val(this.clean.onSync(this.$editor.html()))},isTag:function(t){return this.$element[0].tagName===t},isInline:function(){return!this.build.isTag("TEXTAREA")&&!this.build.isTag("DIV")&&!this.build.isTag("PRE")},enableEditor:function(){this.core.editor().attr({contenteditable:!0})},setOptions:function(){"inline"===this.opts.type&&(this.opts.enterKey=!1),"inline"!==this.opts.type&&"pre"!==this.opts.type||(this.opts.toolbarMobile=!1,this.opts.toolbar=!1),this.core.editor().attr("spellcheck",this.opts.spellcheck),this.opts.structure&&this.core.editor().addClass("redactor-structure"),this.opts.stylesClass&&this.core.editor().addClass(this.opts.stylesClass),"textarea"===this.opts.type&&(this.core.box().attr("dir",this.opts.direction),this.core.editor().attr("dir",this.opts.direction),this.opts.tabindex&&this.core.editor().attr("tabindex",this.opts.tabindex),this.opts.minHeight?this.core.editor().css("min-height",this.opts.minHeight):this.core.editor().css("min-height","40px"),this.opts.maxHeight&&this.core.editor().css("max-height",this.opts.maxHeight),this.opts.maxWidth&&this.core.editor().css({"max-width":this.opts.maxWidth,margin:"auto"}))},callEditor:function(){this.build.disableBrowsersEditing(),this.events.init(),this.build.setHelpers(),this.toolbarsButtons=this.button.init(),this.toolbar.build(),this.core.editor().on("mouseup.redactor-observe."+this.uuid+" keyup.redactor-observe."+this.uuid+" focus.redactor-observe."+this.uuid+" touchstart.redactor-observe."+this.uuid,g.proxy(this.observe.toolbar,this)),this.core.element().on("blur.callback.redactor",g.proxy(function(){this.button.setInactiveAll()},this)),this.modal.templates(),this.build.plugins(),this.code.html=this.code.cleaned(this.core.editor().html()),this.core.callback("init"),this.core.callback("initToEdit"),this.start=!1},setHelpers:function(){this.opts.focus?setTimeout(this.focus.start,100):this.opts.focusEnd&&setTimeout(this.focus.end,100)},disableBrowsersEditing:function(){try{document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1),document.execCommand("AutoUrlDetect",!1,!1)}catch(t){}},plugins:function(){this.opts.plugins&&g.each(this.opts.plugins,g.proxy(function(t,e){var i="undefined"!=typeof RedactorPlugins&&void 0!==RedactorPlugins[e]?RedactorPlugins:l.fn;if(g.isFunction(i[e])){this[e]=i[e]();for(var r,n,s=this.getModuleMethods(this[e]),o=s.length,a=0;a<o;a++)this[e][s[a]]=this[e][s[a]].bind(this);void 0!==this[e].langs&&(r={},void 0!==this[e].langs[this.opts.lang]?r=this[e].langs[this.opts.lang]:void 0===this[e].langs[this.opts.lang]&&void 0!==this[e].langs.en&&(r=this[e].langs.en),n=this,g.each(r,function(t,e){void 0===n.opts.curLang[t]&&(n.opts.curLang[t]=e)})),"function"==typeof this[e].init&&this[e].init()}},this))}}},button:function(){return{toolbar:function(){return void 0!==this.button.$toolbar&&this.button.$toolbar?this.button.$toolbar:this.$toolbar},init:function(){return{format:{title:this.lang.get("format"),icon:!0,dropdown:{p:{title:this.lang.get("paragraph"),func:"block.format"},blockquote:{title:this.lang.get("quote"),func:"block.format"},pre:{title:this.lang.get("code"),func:"block.format"},h1:{title:this.lang.get("heading1"),func:"block.format"},h2:{title:this.lang.get("heading2"),func:"block.format"},h3:{title:this.lang.get("heading3"),func:"block.format"},h4:{title:this.lang.get("heading4"),func:"block.format"},h5:{title:this.lang.get("heading5"),func:"block.format"},h6:{title:this.lang.get("heading6"),func:"block.format"}}},bold:{title:this.lang.get("bold-abbr"),icon:!0,label:this.lang.get("bold"),func:"inline.format"},italic:{title:this.lang.get("italic-abbr"),icon:!0,label:this.lang.get("italic"),func:"inline.format"},deleted:{title:this.lang.get("deleted-abbr"),icon:!0,label:this.lang.get("deleted"),func:"inline.format"},underline:{title:this.lang.get("underline-abbr"),icon:!0,label:this.lang.get("underline"),func:"inline.format"},lists:{title:this.lang.get("lists"),icon:!0,dropdown:{unorderedlist:{title:"&bull; "+this.lang.get("unorderedlist"),func:"list.toggle"},orderedlist:{title:"1. "+this.lang.get("orderedlist"),func:"list.toggle"},outdent:{title:"< "+this.lang.get("outdent"),func:"indent.decrease",observe:{element:"li",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}},indent:{title:"> "+this.lang.get("indent"),func:"indent.increase",observe:{element:"li",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}}}},ul:{title:"&bull; "+this.lang.get("bulletslist"),icon:!0,func:"list.toggle"},ol:{title:"1. "+this.lang.get("numberslist"),icon:!0,func:"list.toggle"},outdent:{title:this.lang.get("outdent"),icon:!0,func:"indent.decrease"},indent:{title:this.lang.get("indent"),icon:!0,func:"indent.increase"},image:{title:this.lang.get("image"),icon:!0,func:"image.show"},file:{title:this.lang.get("file"),icon:!0,func:"file.show"},link:{title:this.lang.get("link"),icon:!0,dropdown:{link:{title:this.lang.get("link-insert"),func:"link.show",observe:{element:"a",in:{title:this.lang.get("link-edit")},out:{title:this.lang.get("link-insert")}}},unlink:{title:this.lang.get("unlink"),func:"link.unlink",observe:{element:"a",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}}}},horizontalrule:{title:this.lang.get("horizontalrule"),icon:!0,func:"line.insert"}}},setFormatting:function(){for(var t in this.toolbarsButtons.format.dropdown)this.toolbarsButtons.format.dropdown.hasOwnProperty(t)&&-1===this.opts.formatting.indexOf(t)&&delete this.toolbarsButtons.format.dropdown[t]},hideButtons:function(){0!==this.opts.buttonsHide.length&&this.button.hideButtonsSlicer(this.opts.buttonsHide)},hideButtonsOnMobile:function(){this.detect.isMobile()&&0!==this.opts.buttonsHideOnMobile.length&&this.button.hideButtonsSlicer(this.opts.buttonsHideOnMobile)},hideButtonsSlicer:function(t){g.each(t,g.proxy(function(t,e){var i=this.opts.buttons.indexOf(e);-1!==i&&this.opts.buttons.splice(i,1)},this))},load:function(i){this.button.buttons=[],this.opts.buttons.forEach(function(t){var e;("image"!==t||this.image.is())&&this.toolbarsButtons.hasOwnProperty(t)&&((e=elCreate("li")).appendChild(this.button.build(t,this.toolbarsButtons[t])[0]),i[0].appendChild(e))}.bind(this))},buildButtonTooltip:function(){},build:function(t,e){var i,r=g('<a href="javascript:void(null);" rel="'+t+'" />');return r.addClass("re-button re-"+t),r.attr({role:"button",tabindex:"-1"}),r.html(e.title),(e.func||e.command||e.dropdown)&&this.button.setEvent(r,t,e),e.dropdown&&(r.addClass("redactor-toolbar-link-dropdown").attr("aria-haspopup",!0),i=g('<ul class="dropdownMenu redactor-dropdown-menu redactor-dropdown-menu-'+r[0].rel+'" data-dropdown-allow-flip="horizontal" data-dropdown-ignore-page-scroll="true" />'),r.data("dropdown",i),this.dropdown.build(t,i,e.dropdown),this.button.setupDropdown(r[0],i[0])),this.button.buttons.push(r),r},setupDropdown:function(e,i){require(["Ui/SimpleDropdown"],function(t){t.initFragment(e,i),t.registerCallback(e.id,function(t,e){"close"===e&&this.dropdown.hideOut()}.bind(this)),elData(e,"a11y-mouse-event","mousedown"),elData(e,"aria-expanded",!1),e.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation()})}.bind(this))},getButtons:function(){return this.button.toolbar().find("a.re-button")},getButtonsKeys:function(){return this.button.buttons},setEvent:function(r,n,s){r.on("mousedown",g.proxy(function(t){if(t.preventDefault(),r.hasClass("redactor-button-disabled"))return!1;var e="func",i=s.func;return s.command?(e="command",i=s.command):s.dropdown&&(i=!(e="dropdown")),this.button.toggle(t,n,e,i),!1},this))},toggle:function(t,e,i,r,n){!this.detect.isIe()&&this.detect.isDesktop()||(this.utils.freezeScroll(),t.returnValue=!1),"command"===i?this.inline.format(r):"dropdown"===i?this.dropdown.show(t,e):this.button.clickCallback(t,r,e,n),"dropdown"!==i&&this.dropdown.hideAll(!1),!this.detect.isIe()&&this.detect.isDesktop()||this.utils.unfreezeScroll()},clickCallback:function(t,e,i,r){var n;if(t instanceof Event?t.preventDefault():t&&t.originalEvent&&t.originalEvent.preventDefault(),r=void 0===r?i:r,g.isFunction(e))e.call(this,i);else if("-1"!==e.search(/\./)){if(void 0===this[(n=e.split("."))[0]])return;"object"==typeof r?this[n[0]][n[1]].apply(this,r):this[n[0]][n[1]].call(this,r)}else"object"==typeof r?this[e].apply(this,r):this[e].call(this,r);this.observe.buttons(t,i)},all:function(){return this.button.buttons},get:function(t){if(!1!==this.opts.toolbar)return this.button.toolbar().find("a.re-"+t)},set:function(t,e){if(!1!==this.opts.toolbar){var i=this.button.toolbar().find("a.re-"+t);return i.html(e).attr("aria-label",e),i}},add:function(t,e){if(!0!==this.button.isAdded(t))return g();var i=this.button.build(t,{title:e});return this.button.toolbar().append(g("<li>").append(i)),i},addFirst:function(t,e){if(!0!==this.button.isAdded(t))return g();var i=this.button.build(t,{title:e});return this.button.toolbar().prepend(g("<li>").append(i)),i},addAfter:function(t,e,i){if(!0!==this.button.isAdded(e))return g();var r=this.button.build(e,{title:i}),n=this.button.get(t);return 0!==n.length?n.parent().after(g("<li>").append(r)):this.button.toolbar().append(g("<li>").append(r)),r},addBefore:function(t,e,i){if(!0!==this.button.isAdded(e))return g();var r=this.button.build(e,{title:i}),n=this.button.get(t);return 0!==n.length?n.parent().before(g("<li>").append(r)):this.button.toolbar().append(g("<li>").append(r)),r},isAdded:function(t){var e=this.opts.buttonsHideOnMobile.indexOf(t);return!(!1===this.opts.toolbar||-1!==e&&this.detect.isMobile())},setIcon:function(t,e){this.opts.buttonsTextLabeled||t.html(e).addClass("re-button-icon")},changeIcon:function(t,e){var i=this.button.get(t);0!==i.length&&i.find("i").removeAttr("class").addClass("re-icon-"+e)},addCallback:function(e,i){var r,n;void 0!==e&&!1!==this.opts.toolbar&&(r="dropdown"===i?"dropdown":"func",n=e.attr("rel"),e.on("mousedown",g.proxy(function(t){return!e.hasClass("redactor-button-disabled")&&void this.button.toggle(t,n,r,i)},this)))},addDropdown:function(t,e){if(!1!==this.opts.toolbar){t.addClass("redactor-toolbar-link-dropdown").attr("aria-haspopup",!0);var i=t.attr("rel");this.button.addCallback(t,"dropdown");var r=g('<ul class="dropdownMenu redactor-dropdown-menu redactor-dropdown-menu-'+i+'" data-dropdown-allow-flip="horizontal" data-dropdown-ignore-page-scroll="true" />');return t.data("dropdown",r),e&&(this.dropdown.build(i,r,e),this.button.setupDropdown(t[0],r[0])),r}},setActive:function(t){this.button.get(t).addClass("redactor-act").attr({"aria-pressed":!0,tabindex:0})},setInactive:function(t){this.button.get(t).removeClass("redactor-act").attr({"aria-pressed":!1,tabindex:"html"===t?0:-1})},setInactiveAll:function(t){var e=this.button.toolbar().find("a.re-button");void 0!==t&&(e=e.not(".re-"+t)),e.removeClass("redactor-act").attr({"aria-pressed":!1,tabindex:"html"===t?0:-1})},disable:function(t){this.button.get(t).addClass("redactor-button-disabled").attr("aria-disabled",!0)},enable:function(t){this.button.get(t).removeClass("redactor-button-disabled").attr("aria-disabled",!1)},disableAll:function(t){var e=this.button.toolbar().find("a.re-button");void 0!==t&&(Array.isArray(t)||(t=[t]),t=t.map(function(t){return".re-"+t}),e=e.not(t.join(","))),e.addClass("redactor-button-disabled").attr("aria-disabled",!0)},enableAll:function(){this.button.toolbar().find("a.re-button").removeClass("redactor-button-disabled").attr("aria-disabled",!1)},remove:function(t){this.button.get(t).remove()}}},caret:function(){return{set:function(t,e,i){var r=this.core.editor().scrollTop();this.core.editor().focus(),this.core.editor().scrollTop(r),i=void 0===i?0:1,t=t[0]||t,e=e[0]||e;var n=this.selection.get(),s=this.selection.range(n);try{s.setStart(t,0),s.setEnd(e,i)}catch(t){}this.selection.update(n,s)},prepare:function(t){return this.detect.isFirefox()&&void 0!==this.start&&this.core.editor().focus(),t[0]||t},start:function(t){var e,i;if(t=this.caret.prepare(t)){if("BR"===t.tagName)return this.caret.before(t);var r=g(t).children().first(),n=this.utils.isInlineTag(t.tagName);""===t.innerHTML||n?this.caret.setStartEmptyOrInline(t,n):r&&0!==r.length&&this.utils.isInlineTag(r[0].tagName)&&""===r.text()?this.caret.setStartEmptyOrInline(r[0],!0):((e=window.getSelection()).removeAllRanges(),(i=document.createRange()).selectNodeContents(t),i.collapse(!0),e.addRange(i))}},setStartEmptyOrInline:function(t,e){var i=window.getSelection(),r=document.createRange(),n=document.createTextNode("​");r.setStart(t,0),r.insertNode(n),r.setStartAfter(n),r.collapse(!0),i.removeAllRanges(),i.addRange(r),e||this.core.editor().on("keydown.redactor-remove-textnode",function(){g(n).remove(),g(this).off("keydown.redactor-remove-textnode")})},end:function(t){var e,i;if(t=this.caret.prepare(t)){if("BR"!==t.tagName&&""===t.innerHTML)return this.caret.start(t);if("BR"===t.tagName){var r=document.createElement("span");return r.className="redactor-invisible-space",r.innerHTML="&#x200b;",g(t).after(r),(e=window.getSelection()).removeAllRanges(),(i=document.createRange()).setStartBefore(r),i.setEndBefore(r),e.addRange(i),void g(r).replaceWith(function(){return g(this).contents()})}if(t.lastChild&&1===t.lastChild.nodeType)return this.caret.after(t.lastChild);if((e=window.getSelection()).getRangeAt||e.rangeCount)try{(i=e.getRangeAt(0)).selectNodeContents(t),i.collapse(!1),e.removeAllRanges(),e.addRange(i)}catch(t){}}},after:function(t){var e,i,r,n;if(t=this.caret.prepare(t)){if("BR"===t.tagName)return this.caret.end(t);this.utils.isBlockTag(t.tagName)?void 0===(i=this.caret.next(t))?this.caret.end(t):("TABLE"===i.tagName?i=g(i).find("th, td").first()[0]:"UL"!==i.tagName&&"OL"!==i.tagName||(i=g(i).find("li").first()[0]),this.caret.start(i)):(r=document.createTextNode("​"),(n=window.getSelection()).removeAllRanges(),(e=document.createRange()).setStartAfter(t),e.insertNode(r),e.setStartAfter(r),e.collapse(!0),n.addRange(e))}},before:function(t){var e,i,r;(t=this.caret.prepare(t))&&(this.utils.isBlockTag(t.tagName)?void 0===(r=this.caret.prev(t))?this.caret.start(t):("TABLE"===r.tagName?r=g(r).find("th, td").last()[0]:"UL"!==r.tagName&&"OL"!==r.tagName||(r=g(r).find("li").last()[0]),this.caret.end(r)):((e=window.getSelection()).removeAllRanges(),(i=document.createRange()).setStartBefore(t),i.collapse(!0),e.addRange(i)))},next:function(t){var e=g(t).next();return e.hasClass("redactor-script-tag, redactor-selection-marker")?e.next()[0]:e[0]},prev:function(t){var e=g(t).prev();return e.hasClass("redactor-script-tag, redactor-selection-marker")?e.prev()[0]:e[0]},offset:function(t){return this.offset.get(t)}}},clean:function(){return{onSet:function(t){t=this.clean.savePreCode(t),this.opts.script&&(t=t.replace(/<script(.*?[^>]?)>([\w\W]*?)<\/script>/gi,'<pre class="redactor-script-tag" $1>$2</pre>')),t=(t=(t=(t=(t=t.replace(/\$/g,"&#36;")).replace(/&amp;/g,"&")).replace(/<a href="(.*?[^>]?)®(.*?[^>]?)">/gi,'<a href="$1&reg$2">')).replace(/<span id="selection-marker-1"(.*?[^>]?)>​<\/span>/gi,"###marker1###")).replace(/<span id="selection-marker-2"(.*?[^>]?)>​<\/span>/gi,"###marker2###");var e,i=this,r=g("<div/>").html(g.parseHTML(t,document,!0)),n=this.opts.replaceTags;n&&(e=Object.keys(this.opts.replaceTags),r.find(e.join(",")).each(function(t,e){i.utils.replaceToTag(e,n[e.tagName.toLowerCase()])})),r.find("span, a").attr("data-redactor-span",!0),r.find(this.opts.inlineTags.join(",")).each(function(){var t=g(this);t.attr("style")&&t.attr("data-redactor-style-cache",t.attr("style"))}),t=r.html();var s=["font","html","head","link","body","meta","applet"];return this.opts.script||s.push("script"),t=this.clean.stripTags(t,s),this.opts.removeComments&&(t=t.replace(/<!--[\s\S]*?-->/gi,"")),-1!==(t=(t=(t=this.paragraphize.load(t)).replace("###marker1###",'<span id="selection-marker-1" class="redactor-selection-marker">​</span>')).replace("###marker2###",'<span id="selection-marker-2" class="redactor-selection-marker">​</span>')).search(/^(||\s||<br\s?\/?>||&nbsp;)$/i)?this.opts.emptyHtml:t},onGet:function(t){return this.clean.onSync(t)},onSync:function(i){if(-1!==(i=(i=i.replace(/\u200B/g,"")).replace(/&#x200b;/gi,"")).search(/^<p>(||\s||<br\s?\/?>||&nbsp;)<\/p>$/i))return"";i=(i=(i=(i=i.replace(/<span(.*?)id="redactor-image-box"(.*?[^>])>([\w\W]*?)<img(.*?)><\/span>/gi,"$3<img$4>")).replace(/<span(.*?)id="redactor-image-resizer"(.*?[^>])>(.*?)<\/span>/gi,"")).replace(/<span(.*?)id="redactor-image-editter"(.*?[^>])>(.*?)<\/span>/gi,"")).replace(/<img(.*?)style="(.*?)opacity: 0\.5;(.*?)"(.*?)>/gi,'<img$1style="$2$3"$4>');var t=g("<div/>").html(g.parseHTML(i,document,!0));t.find('*[style=""]').removeAttr("style"),t.find('*[class=""]').removeAttr("class"),t.find('*[rel=""]').removeAttr("rel"),t.find('*[data-image=""]').removeAttr("data-image"),t.find('*[alt=""]').removeAttr("alt"),t.find('*[title=""]').removeAttr("title"),t.find("*[data-redactor-style-cache]").removeAttr("data-redactor-style-cache"),t.find(".redactor-invisible-space, .redactor-unlink").each(function(){g(this).contents().unwrap()}),t.find("span, a").removeAttr("data-redactor-span data-redactor-style-cache").each(function(){0===this.attributes.length&&g(this).contents().unwrap()}),t.find("img").removeAttr("rel"),t.find(".redactor-selection-marker, #redactor-insert-marker").remove(),i=t.html(),this.opts.script&&(i=i.replace(/<pre class="redactor-script-tag"(.*?[^>]?)>([\w\W]*?)<\/pre>/gi,"<script$1>$2<\/script>")),i=(i=(i=(i=(i=this.clean.restoreFormTags(i)).replace(new RegExp("<br\\s?/?></h","gi"),"</h")).replace(new RegExp("<br\\s?/?></li>","gi"),"</li>")).replace(new RegExp("</li><br\\s?/?>","gi"),"</li>")).replace(/<pre>/gi,"<pre>\n"),this.opts.preClass&&(i=i.replace(/<pre>/gi,'<pre class="'+this.opts.preClass+'">')),this.opts.linkNofollow&&(i=(i=i.replace(/<a(.*?)rel="nofollow"(.*?[^>])>/gi,"<a$1$2>")).replace(/<a(.*?[^>])>/gi,'<a$1 rel="nofollow">'));return g.each({"™":"&trade;","©":"&copy;","…":"&hellip;","—":"&mdash;","‐":"&dash;"},function(t,e){i=i.replace(new RegExp(t,"g"),e)}),i=(i=i.replace(/&amp;/g,"&")).replace(/\n{2,}/g,"\n"),this.opts.removeNewlines&&(i=i.replace(/\r?\n/g,"")),i},onPaste:function(t,e,i){return!0!==i&&(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2")).replace(/<b(.*?)id="docs-internal-guid(.*?)">([\w\W]*?)<\/b>/gi,"$3")).replace(/<span[^>]*(font-style: italic; font-weight: bold|font-weight: bold; font-style: italic)[^>]*>([\w\W]*?)<\/span>/gi,"<b><i>$2</i></b>")).replace(/<span[^>]*(font-style: italic; font-weight: 700|font-weight: 700; font-style: italic)[^>]*>([\w\W]*?)<\/span>/gi,"<b><i>$2</i></b>")).replace(/<span[^>]*font-style: italic[^>]*>([\w\W]*?)<\/span>/gi,"<i>$1</i>")).replace(/<span[^>]*font-weight: bold[^>]*>([\w\W]*?)<\/span>/gi,"<b>$1</b>")).replace(/<span[^>]*font-weight: 700[^>]*>([\w\W]*?)<\/span>/gi,"<b>$1</b>")).replace(/<o:p[^>]*>/gi,"")).replace(/<\/o:p>/gi,""),this.clean.isHtmlMsWord(t)&&(t=this.clean.cleanMsWord(t))),t=g.trim(t),e.pre?this.opts.preSpaces&&(t=t.replace(/\t/g,new Array(this.opts.preSpaces+1).join(" "))):(t=this.clean.replaceBrToNl(t),t=this.clean.removeTagsInsidePre(t)),!0!==i&&(t=this.clean.removeEmptyInlineTags(t),!1===e.encode&&(t=t.replace(/&/g,"&amp;"),t=this.clean.convertTags(t,e),t=this.clean.getPlainText(t),t=this.clean.reconvertTags(t,e))),e.text&&(t=this.clean.replaceNbspToSpaces(t),t=this.clean.getPlainText(t)),e.lists&&(t=t.replace("\n","<br>")),e.encode&&(t=this.clean.encodeHtml(t)),e.paragraphize&&(t=(t=t.replace(/ \n/g," ")).replace(/\n /g," "),t=(t=this.paragraphize.load(t)).replace(/<p><\/p>/g,"")),t=(t=t.replace(/<li><p>/g,"<li>")).replace(/<\/p><\/li>/g,"</li>")},getCurrentType:function(t,e){var i=this.selection.blocks(),r={text:!1,encode:!1,paragraphize:!0,line:this.clean.isHtmlLine(t),blocks:this.clean.isHtmlBlocked(t),pre:!1,lists:!1,block:!0,inline:!0,links:!0,images:!0};return 1===i.length&&this.utils.isCurrentOrParent(["h1","h2","h3","h4","h5","h6","a","figcaption"])?(r.text=!0,r.paragraphize=!1,r.inline=!1,r.images=!1,r.links=!1,r.line=!0):"inline"===this.opts.type||!1===this.opts.enterKey?(r.paragraphize=!1,r.block=!1,r.line=!0):1===i.length&&this.utils.isCurrentOrParent(["li"])?(r.lists=!0,r.block=!1,r.paragraphize=!1,r.images=!1):1===i.length&&this.utils.isCurrentOrParent(["th","td","blockquote"])?(r.block=!1,r.paragraphize=!1):("pre"===this.opts.type||1===i.length&&this.utils.isCurrentOrParent("pre"))&&(r.inline=!1,r.block=!1,r.encode=!0,r.pre=!0,r.paragraphize=!1,r.images=!1,r.links=!1),!0===r.line&&(r.paragraphize=!1),!0===e&&(r.text=!1),r},isHtmlBlocked:function(t){var e=t.match(new RegExp("</("+this.opts.blockTags.join("|").toUpperCase()+")>","gi")),i=t.match(new RegExp("<hr(.*?[^>])>","gi"));return null!==e||null!==i},isHtmlLine:function(t){if(this.clean.isHtmlBlocked(t))return!1;var e=t.match(/<br\s?\/?>/gi),i=t.match(/\n/gi);return!e&&!i},isHtmlMsWord:function(t){return t.match(/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i)},removeEmptyInlineTags:function(t){var e=this.opts.inlineTags,i=g("<div/>").html(g.parseHTML(t,document,!0)),r=this,n=i.find("span"),s=i.find(e.join(","));return s.removeAttr("style"),s.each(function(){var t=g(this).html();0===this.attributes.length&&r.utils.isEmpty(t)&&g(this).replaceWith(function(){return g(this).contents()})}),n.each(function(){g(this).html();0===this.attributes.length&&g(this).replaceWith(function(){return g(this).contents()})}),t=(t=(t=(t=i.html()).replace("\x3c!--?php","<?php")).replace("\x3c!--?","<?")).replace("?--\x3e","?>"),i.remove(),t},cleanMsWord:function(t){t=(t=(t=(t=(t=t.replace(/<!--[\s\S]*?-->/g,"")).replace(/<o:p>[\s\S]*?<\/o:p>/gi,"")).replace(/\n/g," ")).replace(/<\/p>/gi,'</p><p><br data-redactor="br"></p>')).replace(/<\/div>|<\/li>|<\/td>/gi,"\n\n");var l=g("<div/>").html(t);elBySelAll("br",l[0],function(t){if("br"===elData(t,"redactor"))t.removeAttribute("data-redactor");else{var e=t.parentNode;if(e&&"P"===e.nodeName){for(var i=elCreate("p");t.nextSibling;)i.appendChild(t.nextSibling);e.parentNode.insertBefore(i,e.nextSibling),elRemove(t)}}});var c=!1,h=1,d=[];return l.find("p[style]").each(function(){var t=g(this).attr("style").match(/mso\-list\:l([0-9]+)\slevel([0-9]+)/);if(t){var e=parseInt(t[1]),i=parseInt(t[2]),r=g(this).html().match(/^[\w]+\./)?"ol":"ul",n=g("<li/>").html(g(this).html());if(n.html(n.html().replace(/^([\w\.]+)</,"<")),n.find("span:first").remove(),1==i&&-1==g.inArray(e,d)){var s=g("<"+r+"/>").attr({"data-level":i,"data-list":e}).html(n);g(this).replaceWith(s),c=e,d.push(e)}else{if(h<i){for(var o=l.find('[data-level="'+h+'"][data-list="'+c+'"]'),a=h;a<i;a++)(s=g("<"+r+"/>")).appendTo(o.find("li").last()),o=s;o.attr({"data-level":i,"data-list":e}).html(n)}else{l.find('[data-level="'+i+'"][data-list="'+e+'"]').last().append(n)}h=i,c=e,g(this).remove()}}}),l.find("[data-level][data-list]").removeAttr("data-level data-list"),elBySelAll("ol, ul",l[0],function(i){["nextElementSibling","previousElementSibling"].forEach(function(t){for(var e=i[t];e&&"P"===e.nodeName&&""===e.className&&"<br>"===e.innerHTML;)elRemove(e),e=i[t]})}),t=l.html()},replaceNbspToSpaces:function(t){return t.replace("&nbsp;"," ")},replaceBrToNl:function(t){return t.replace(/<br\s?\/?>/gi,"\n")},replaceNlToBr:function(t){return t.replace(/\n/g,"<br />")},convertTags:function(t,e){var i=g("<div>").html(t);i.find("iframe").remove();var r=i.find("a");if(r.removeAttr("style"),!1!==this.opts.pasteLinkTarget&&r.attr("target",this.opts.pasteLinkTarget),e.links&&this.opts.pasteLinks&&i.find("a").each(function(t,e){if(e.href){for(var i,r='#####[a href="'+e.href+'"',n=0,s=e.attributes.length;n<s;n++)"href"!==(i=e.attributes.item(n)).name&&(r+=" "+i.name+'="'+i.value+'"');e.outerHTML=r+"]#####"+e.innerHTML+"#####[/a]#####"}}),t=i.html(),e.images&&this.opts.pasteImages&&(t=t.replace(/<img(.*?)src="(.*?)"(.*?[^>])>/gi,'#####[img$1src="$2"$3]#####')),this.opts.pastePlainText)return t;for(var n=e.lists?["ul","ol","li"]:this.opts.pasteBlockTags,s=e.block||e.lists?e.inline?n.concat(this.opts.pasteInlineTags):n:e.inline?this.opts.pasteInlineTags:[],o=s.length,a=0;a<o;a++)t=t.replace(new RegExp("</"+s[a]+">","gi"),"###/"+s[a]+"###"),t="td"===s[a]||"th"===s[a]?t.replace(new RegExp("<"+s[a]+'(.*?[^>])((colspan|rowspan)="(.*?[^>])")?(.*?[^>])>',"gi"),"###"+s[a]+" $2###"):this.utils.isInlineTag(s[a])?(t=(t=t.replace(new RegExp("<"+s[a]+'([^>]*)class="([^>]*)"[^>]*>',"gi"),"###"+s[a]+' class="$2"###')).replace(new RegExp("<"+s[a]+'([^>]*)data-redactor-style-cache="([^>]*)"[^>]*>',"gi"),"###"+s[a]+' cache="$2"###')).replace(new RegExp("<"+s[a]+"[^>]*>","gi"),"###"+s[a]+"###"):t.replace(new RegExp("<"+s[a]+"[^>]*>","gi"),"###"+s[a]+"###");return t},reconvertTags:function(t,e){if((e.links&&this.opts.pasteLinks||e.images&&this.opts.pasteImages)&&(t=(t=t.replace(new RegExp("#####\\[","gi"),"<")).replace(new RegExp("\\]#####","gi"),">")),this.opts.pastePlainText)return t;for(var i=e.lists?["ul","ol","li"]:this.opts.pasteBlockTags,r=e.block||e.lists?e.inline?i.concat(this.opts.pasteInlineTags):i:e.inline?this.opts.pasteInlineTags:[],n=r.length,s=0;s<n;s++)t=t.replace(new RegExp("###/"+r[s]+"###","gi"),"</"+r[s]+">");for(s=0;s<n;s++)t=t.replace(new RegExp("###"+r[s]+"###","gi"),"<"+r[s]+">");for(var o,s=0;s<n;s++){"td"===r[s]||"th"===r[s]?t=t.replace(new RegExp("###"+r[s]+"s?(.*?[^#])###","gi"),"<"+r[s]+"$1>"):this.utils.isInlineTag(r[s])&&(o="span"===r[s]?' data-redactor-span="true"':"",t=(t=t.replace(new RegExp("###"+r[s]+' cache="(.*?[^#])"###',"gi"),"<"+r[s]+' style="$1"'+o+' data-redactor-style-cache="$1">')).replace(new RegExp("###"+r[s]+"s?(.*?[^#])###","gi"),"<"+r[s]+"$1>"))}return t},cleanPre:function(t){t=void 0===t?g(this.selection.block()).closest("pre",this.core.editor()[0]):t,g(t).find("br").replaceWith(function(){return document.createTextNode("\n")}),g(t).find("p").replaceWith(function(){return g(this).contents()})},removeTagsInsidePre:function(t){var e=g("<div />").append(t);return e.find("pre").replaceWith(function(){var t=g(this).html();return t=(t=t.replace(/<br\s?\/?>|<\/p>|<\/div>|<\/li>|<\/td>/gi,"\n")).replace(/(<([^>]+)>)/gi,""),g("<pre />").append(t)}),t=e.html(),e.remove(),t},getPlainText:function(t){t=(t=(t=(t=(t=(t=t.replace(/<!--[\s\S]*?-->/gi,"")).replace(/<style[\s\S]*?style>/gi,"")).replace(/<p><\/p>/g,"")).replace(/<\/div>|<\/li>|<\/td>/gi,"\n")).replace(/<\/p>/gi,"\n\n")).replace(/<\/H[1-6]>/gi,"\n\n");var e=document.createElement("div");return e.innerHTML=t,t=e.textContent||e.innerText,g.trim(t)},savePreCode:function(t){return t=this.clean.savePreFormatting(t),t=this.clean.saveCodeFormatting(t),t=this.clean.restoreSelectionMarkers(t)},savePreFormatting:function(a){var t=a.match(/<pre(.*?)>([\w\W]*?)<\/pre>/gi);return null===t||g.each(t,g.proxy(function(t,e){var i,r,n,s=[],o=!1;e.match(/<pre(.*?)>(([\n\r\s]+)?)<code(.*?)>/i)?(o=!0,i=(s=e.match(/<pre(.*?)>(([\n\r\s]+)?)<code(.*?)>([\w\W]*?)<\/code>(([\n\r\s]+)?)<\/pre>/i))[5],r=s[1],n=s[4]):(i=(s=e.match(/<pre(.*?)>([\w\W]*?)<\/pre>/i))[2],r=s[1]),i=(i=i.replace(/<br\s?\/?>/g,"\n")).replace(/&nbsp;/g," "),this.opts.preSpaces&&(i=i.replace(/\t/g,new Array(this.opts.preSpaces+1).join(" "))),i=(i=this.clean.encodeEntities(i)).replace(/\$/g,"&#36;"),a=o?a.replace(e,"<pre"+r+"><code"+n+">"+i+"</code></pre>"):a.replace(e,"<pre"+r+">"+i+"</pre>")},this)),a},saveCodeFormatting:function(r){var t=r.match(/<code(.*?)>([\w\W]*?)<\/code>/gi);return null===t||g.each(t,g.proxy(function(t,e){var i=e.match(/<code(.*?)>([\w\W]*?)<\/code>/i);i[2]=i[2].replace(/&nbsp;/g," "),i[2]=this.clean.encodeEntities(i[2]),i[2]=i[2].replace(/\$/g,"&#36;"),r=r.replace(e,"<code"+i[1]+">"+i[2]+"</code>")},this)),r},restoreSelectionMarkers:function(t){return t=t.replace(/&lt;span id=&quot;selection-marker-([0-9])&quot; class=&quot;redactor-selection-marker&quot;&gt;​&lt;\/span&gt;/g,'<span id="selection-marker-$1" class="redactor-selection-marker">​</span>')},saveFormTags:function(t){return t},restoreFormTags:function(t){return t.replace(/<section(.*?) rel="redactor-form-tag"(.*?)>([\w\W]*?)<\/section>/gi,"<form$1$2>$3</form>")},encodeHtml:function(t){return t=(t=(t=(t=t.replace(/”/g,'"')).replace(/“/g,'"')).replace(/‘/g,"'")).replace(/’/g,"'"),t=this.clean.encodeEntities(t)},encodeEntities:function(t){return t=(t=String(t).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"')).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},stripTags:function(t,i){if(void 0===i)return t.replace(/(<([^>]+)>)/gi,"");return t.replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,function(t,e){return-1===i.indexOf(e.toLowerCase())?t:""})},removeMarkers:function(t){return t.replace(/<span(.*?[^>]?)class="redactor-selection-marker"(.*?[^>]?)>([\w\W]*?)<\/span>/gi,"")},removeSpaces:function(t){return t=(t=(t=(t=(t=(t=(t=(t=(t=g.trim(t)).replace(/\n/g,"")).replace(/[\t]*/g,"")).replace(/\n\s*\n/g,"\n")).replace(/^[\s\n]*/g," ")).replace(/[\s\n]*$/g," ")).replace(/>\s{2,}</g,"> <")).replace(/\n\n/g,"\n")).replace(/\u200B/g,"")},removeSpacesHard:function(t){return t=(t=(t=(t=(t=(t=(t=(t=(t=g.trim(t)).replace(/\n/g,"")).replace(/[\t]*/g,"")).replace(/\n\s*\n/g,"\n")).replace(/^[\s\n]*/g,"")).replace(/[\s\n]*$/g,"")).replace(/>\s{2,}</g,"><")).replace(/\n\n/g,"\n")).replace(/\u200B/g,"")},normalizeCurrentHeading:function(){var t=this.selection.block();this.utils.isCurrentOrParentHeader()&&t&&t.normalize()}}},code:function(){return{syncFire:!0,html:!1,start:function(t){t=(t=g.trim(t)).replace(/^(<span id="selection-marker-1" class="redactor-selection-marker">​<\/span>)/,""),t=(t=this.clean.onSet(t)).replace(/<p><span id="selection-marker-1" class="redactor-selection-marker">​<\/span><\/p>/,""),this.events.stopDetectChanges(),this.core.editor().html(t),this.observe.load(),this.events.startDetectChanges()},set:function(t,e){t=g.trim(t),(e=e||{}).start&&(this.start=e.start),"textarea"===this.opts.type?t=this.clean.onSet(t):"div"===this.opts.type&&""===t&&(t=this.opts.emptyHtml),this.core.editor().html(t),"textarea"===this.opts.type&&this.code.sync()},get:function(){if("textarea"===this.opts.type)return this.core.textarea().val();var t=this.core.editor().html();return t=this.clean.onGet(t)},sync:function(){if(this.code.syncFire){var t=this.core.editor().html(),e=this.code.cleaned(t);if(!this.code.isSync(e)){if(this.code.html=e,"textarea"!==this.opts.type)return this.core.callback("sync",t),void this.core.callback("change",t);"textarea"===this.opts.type&&setTimeout(g.proxy(function(){this.code.startSync(t)},this),10)}}},startSync:function(t){t=this.core.callback("syncBefore",t),t=this.clean.onSync(t),this.core.textarea().val(t),this.core.callback("sync",t),!1===this.start&&this.core.callback("change",t),this.start=!1},isSync:function(t){var e=!1!==this.code.html&&this.code.html;return!1!==e&&e===t},cleaned:function(t){return t=t.replace(/\u200B/g,""),this.clean.removeMarkers(t)}}},core:function(){return{id:function(){return this.$editor.attr("id")},element:function(){return this.$element},editor:function(){return void 0===this.$editor?g():this.$editor},textarea:function(){return this.$textarea},box:function(){return"textarea"===this.opts.type?this.$box:this.$element},toolbar:function(){return!!this.$toolbar&&this.$toolbar},air:function(){return!!this.$air&&this.$air},object:function(){return g.extend({},this)},structure:function(){this.core.editor().toggleClass("redactor-structure")},addEvent:function(t){this.core.event=t},getEvent:function(){return this.core.event},callback:function(t,e,i){var r=!1,n=g._data(this.core.element()[0],"events");if(void 0!==n&&void 0!==n[t])for(var s,o,a=n[t].length,l=0;l<a;l++){"callback.redactor"===n[t][l].namespace&&(s=n[t][l].handler,r=void 0===(o=void 0===i?[e]:[e,i])?s.call(this,e):s.call(this,e,o))}if(r)return r;if(void 0===this.opts.callbacks[t])return void 0===i?e:i;var c=this.opts.callbacks[t];return g.isFunction(c)?void 0===i?c.call(this,e):c.call(this,e,i):void 0===i?e:i},destroy:function(){this.opts.destroyed=!0,this.core.callback("destroy"),g("#redactor-voice-"+this.uuid).remove(),this.core.editor().removeClass("redactor-in redactor-styles redactor-structure redactor-layer-img-edit"),this.core.editor().off("keydown.redactor-remove-textnode"),this.core.editor().off(".redactor-observe."+this.uuid),this.$element.off(".redactor").removeData("redactor"),this.core.editor().off(".redactor"),g(document).off(".redactor-air."+this.uuid),g(document).off("mousedown.redactor-blur."+this.uuid),g(document).off("mousedown.redactor."+this.uuid),g(document).off("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid),g(window).off(".redactor-toolbar."+this.uuid),g(window).off("touchmove.redactor."+this.uuid),g("body").off("scroll.redactor."+this.uuid),g(this.opts.toolbarFixedTarget).off("scroll.redactor."+this.uuid);var i=this;!1!==this.opts.plugins&&g.each(this.opts.plugins,function(t,e){g(window).off(".redactor-plugin-"+e),g(document).off(".redactor-plugin-"+e),g("body").off(".redactor-plugin-"+e),i.core.editor().off(".redactor-plugin-"+e)}),this.$element.off("click.redactor-click-to-edit"),this.$element.removeClass("redactor-click-to-edit"),this.core.editor().removeClass("redactor-layer"),this.core.editor().removeAttr("contenteditable");var t=this.code.get();this.opts.toolbar&&this.$toolbar&&this.$toolbar.find("a").each(function(){var t=g(this);t.data("dropdown")&&(t.data("dropdown").remove(),t.data("dropdown",{}))}),"textarea"===this.opts.type&&(this.$box.after(this.$element),this.$box.remove(),this.$element.val(t).show()),this.opts.toolbar&&this.$toolbar&&this.$toolbar.remove(),this.$modalBox&&this.$modalBox.remove(),this.$modalOverlay&&this.$modalOverlay.remove(),g(".redactor-link-tooltip").remove()}}},detect:function(){return{isWebkit:function(){return/webkit/.test(this.opts.userAgent)},isFirefox:function(){return-1<this.opts.userAgent.indexOf("firefox")},isIe:function(t){if(document.documentMode||/Edge/.test(navigator.userAgent))return"edge";var e=RegExp("msie"+(isNaN(t)?"":"\\s"+t),"i").test(navigator.userAgent);return e=e||!!navigator.userAgent.match(/Trident.*rv[ :]*11\./)},isMobile:function(){return/(iPhone|iPod|BlackBerry|Android)/.test(navigator.userAgent)},isDesktop:function(){return!/(iPhone|iPod|iPad|BlackBerry|Android)/.test(navigator.userAgent)},isIpad:function(){return/iPad/.test(navigator.userAgent)}}},dropdown:function(){return{active:!1,button:!1,key:!1,position:[],getDropdown:function(){return this.dropdown.active},build:function(t,e,i){var r,n,s=document.createDocumentFragment();for(var o in i){i.hasOwnProperty(o)&&(r=i[o],n=this.dropdown.buildItem(o,r),this.observe.addDropdown(g(n),o,r),s.appendChild(n))}for(var a=!1,l=0,c=s.childNodes.length;l<c;l++)if(s.childNodes[l].nodeType===Node.ELEMENT_NODE){a=!0;break}a&&(e[0].rel=t,e[0].appendChild(s))},buildFormatting:function(){},buildItem:function(e,i){var t=elCreate("li");return void 0!==i.classname&&t.classList.add(i.classname),0===e.toLowerCase().indexOf("divider")?t.classList.add("redactor-dropdown-divider"):(t.innerHTML='<a href="#" class="redactor-dropdown-'+e+'" role="button"><span>'+i.title+"</span></a>",g(t.children[0]).on("mousedown",function(t){t.preventDefault(),this.dropdown.buildClick(t,e,i)}.bind(this))),t},buildClick:function(t,e,i){var r;g(t.target).hasClass("redactor-dropdown-link-inactive")||(r=this.dropdown.buildCommand(i),void 0!==i.args?this.button.toggle(t,e,r.type,r.callback,i.args):this.button.toggle(t,e,r.type,r.callback))},buildCommand:function(t){var e={type:"func"};return e.callback=t.func,t.command?(e.type="command",e.callback=t.command):t.dropdown&&(e.type="dropdown",e.callback=t.dropdown),e},show:function(t,e){this.detect.isDesktop()&&this.core.editor().focus(),this.dropdown.hideAll(!1,e),this.dropdown.key=e,this.dropdown.button=this.button.get(this.dropdown.key),require(["Ui/SimpleDropdown"],function(t){var e=this.dropdown.button[0].id;t.toggleDropdown(e),t.isOpen(e)?(this.dropdown.active=g(t.getDropdownMenu(e)),this.core.callback("dropdownShow",{dropdown:this.dropdown.active,key:this.dropdown.key,button:this.dropdown.button}),this.button.setActive(this.dropdown.key),this.dropdown.button.addClass("dropact").attr("aria-expanded",!0),this.dropdown.enableCallback()):this.dropdown.hide()}.bind(this)),t.preventDefault()},showIsFixedToolbar:function(){},showIsUnFixedToolbar:function(){},enableEvents:function(){},enableCallback:function(){this.core.callback("dropdownShown",{dropdown:this.dropdown.active,key:this.dropdown.key,button:this.dropdown.button})},getButtonPosition:function(){},closeHandler:function(){},hideAll:function(t,e){this.dropdown.hideOut(e)},hide:function(){this.dropdown.hideOut()},hideOut:function(t){var e;!1!==this.dropdown.active&&this.dropdown.button[0].rel!==t&&(this.core.callback("dropdownHide",this.dropdown.active),e=this.dropdown.button[0].id,require(["Ui/SimpleDropdown"],function(t){t.close(e)}),this.dropdown.button.removeClass("redactor-act dropact").attr("aria-expanded",!1),this.dropdown.button=!1,this.dropdown.key=!1,this.dropdown.active=!1)}}},events:function(){return{focused:!1,blured:!0,dropImage:!1,stopChanges:!1,stopDetectChanges:function(){this.events.stopChanges=!0},startDetectChanges:function(){var t=this;setTimeout(function(){t.events.stopChanges=!1},1)},dragover:function(t){t.preventDefault(),"IMG"===t.target.tagName&&g(t.target).addClass("redactor-image-dragover")},dragleave:function(t){this.core.editor().find("img").removeClass("redactor-image-dragover")},drop:function(t){return t=t.originalEvent||t,this.core.editor().find("img").removeClass("redactor-image-dragover"),"inline"===this.opts.type||"pre"===this.opts.type?(t.preventDefault(),!1):void 0===window.FormData||!t.dataTransfer||(0===t.dataTransfer.files.length?this.events.onDrop(t):(this.events.onDropUpload(t),void this.core.callback("drop",t)))},click:function(t){var e=this.core.getEvent(),i="click"!==e&&"arrow"!==e&&"click";this.core.addEvent(i),this.utils.disableSelectAll(),this.core.callback("click",t)},focus:function(t){var e,i;this.rtePaste||(this.events.isCallback("focus")&&this.core.callback("focus",t),this.events.focused=!0,(this.events.blured=!1)===this.selection.current()&&(e=this.selection.get(),(i=this.selection.range(e)).setStart(this.core.editor()[0],0),i.setEnd(this.core.editor()[0],0),this.selection.update(e,i)))},blur:function(t){this.start||this.rtePaste||0===g(t.target).closest("#"+this.core.id()+", .redactor-toolbar, .redactor-dropdown, #redactor-modal-box").length&&(!this.events.blured&&this.events.isCallback("blur")&&this.core.callback("blur",t),this.events.focused=!1,this.events.blured=!0)},touchImageEditing:function(){var t=-1;this.events.imageEditing=!1,g(window).on("touchmove.redactor."+this.uuid,g.proxy(function(){this.events.imageEditing=!0,-1!==t&&clearTimeout(t),t=setTimeout(g.proxy(function(){this.events.imageEditing=!1},this),500)},this))},init:function(){this.core.editor().on("dragover.redactor dragenter.redactor",g.proxy(this.events.dragover,this)),this.core.editor().on("dragleave.redactor",g.proxy(this.events.dragleave,this)),this.core.editor().on("drop.redactor",g.proxy(this.events.drop,this)),this.core.editor().on("click.redactor",g.proxy(this.events.click,this)),this.core.editor().on("paste.redactor",g.proxy(this.paste.init,this)),this.core.editor().on("keydown.redactor",g.proxy(this.keydown.init,this)),this.core.editor().on("keyup.redactor",g.proxy(this.keyup.init,this)),this.core.editor().on("focus.redactor",g.proxy(this.events.focus,this)),g(document).on("mousedown.redactor-blur."+this.uuid,g.proxy(this.events.blur,this)),this.events.touchImageEditing(),this.events.createObserver(),this.events.setupObserver()},createObserver:function(){var e=this;this.events.observer=new MutationObserver(function(t){t.forEach(g.proxy(e.events.iterateObserver,e))})},iterateObserver:function(t){var e=!1;("textarea"!==this.opts.type&&"div"!==this.opts.type||this.detect.isFirefox()||t.target!==this.core.editor()[0])&&("class"!==t.attributeName||t.target!==this.core.editor()[0])&&"data-vivaldi-spatnav-clickable"!=t.attributeName||(e=!0),e||(this.observe.load(),this.events.changeHandler())},setupObserver:function(){this.events.observer.observe(this.core.editor()[0],{attributes:!0,subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0})},changeHandler:function(){this.events.stopChanges||this.code.sync()},onDropUpload:function(t){if(t.preventDefault(),t.stopPropagation(),(this.opts.dragImageUpload||this.opts.dragFileUpload)&&(null!==this.opts.imageUpload||null!==this.opts.fileUpload)){"IMG"===t.target.tagName&&(this.events.dropImage=t.target);for(var e=t.dataTransfer.files,i=e.length,r=0;r<i;r++)this.upload.directUpload(e[r],t)}},onDrop:function(t){this.core.callback("drop",t)},isCallback:function(t){return void 0!==this.opts.callbacks[t]&&g.isFunction(this.opts.callbacks[t])},stopDetect:function(){this.events.stopDetectChanges()},startDetect:function(){this.events.startDetectChanges()}}},file:function(){return{is:function(){},show:function(){},insert:function(){},release:function(){},text:function(t){}}},focus:function(){return{start:function(){var t;this.core.editor().focus(),"inline"===this.opts.type||!1!==(t=this.focus.first())&&this.caret.start(t)},end:function(){this.core.editor().focus();var t,e,i,r=this.opts.inline?this.core.editor():this.focus.last();0!==r.length&&(t=this.focus.lastChild(r),this.detect.isWebkit()||!1===t?(e=this.selection.get(),null!==(i=this.selection.range(e))?(i.selectNodeContents(r[0]),i.collapse(!1),this.selection.update(e,i)):this.caret.end(r)):this.caret.end(t))},first:function(){var t=this.core.editor().children().first();return(0!==t.length||0!==t[0].length&&"BR"!==t[0].tagName&&"HR"!==t[0].tagName&&3!==t[0].nodeType)&&("UL"===t[0].tagName||"OL"===t[0].tagName?t.find("li").first():t)},last:function(){return this.core.editor().children().last()},lastChild:function(t){var e=t[0].lastChild;return!(null===e||!this.utils.isInlineTag(e.tagName))&&e},is:function(){return this.core.editor()[0]===document.activeElement}}},image:function(){return{is:function(){return!(!this.opts.imageUpload||!this.opts.imageUpload&&!this.opts.s3)},show:function(){this.modal.load("image",this.lang.get("image"),700),this.upload.init("#redactor-modal-image-droparea",this.opts.imageUpload,this.image.insert),this.modal.show()},insert:function(t,e,i){if(void 0!==t.error)return this.modal.close(),this.events.dropImage=!1,void this.core.callback("imageUploadError",t,i);if(!1!==this.events.dropImage)return r=g(this.events.dropImage),this.core.callback("imageDelete",r[0].src,r),r.attr("src",t.url),this.events.dropImage=!1,void this.core.callback("imageUpload",r,t);var r,n=g("<"+this.opts.imageTag+">");(r=g("<img>")).attr("src",t.url);var s=void 0===t.id?"":t.id,o=void 0===t.s3?"image":"s3";r.attr("data-"+o,s),n.append(r);var a,l,c=this.utils.isTag(this.selection.current(),"pre");e?(this.marker.remove(),a=this.insert.nodeToPoint(i,this.marker.get()),l=g(a).next(),this.selection.restore(),this.buffer.set(),void 0!==l&&0!==l.length&&"IMG"===l[0].tagName?(this.core.callback("imageDelete",l[0].src,l),l.closest("figure, p",this.core.editor()[0]).replaceWith(n)):c?g(c).after(n):this.insert.node(n)):(this.modal.close(),this.buffer.set(),c?g(c).after(n):this.insert.node(n)),this.caret.after(n),this.events.dropImage=!1;var h=r[0].nextSibling,d=n.next(),u=g(h).text().replace(/\u200B/g,""),p=d.text().replace(/\u200B/g,"");""===u&&g(h).remove(),1===d.length&&"FIGURE"===d[0].tagName&&""===p&&d.remove(),null!==e?this.core.callback("imageUpload",r,t):this.core.callback("imageInserted",r,t)},setEditable:function(e){var t;e.on("dragstart",function(t){t.preventDefault()}),this.opts.imageResizable?(t=g.proxy(function(t){this.observe.image=e,this.image.resizer=this.image.loadEditableControls(e),g(document).on("mousedown.redactor-image-resize-hide."+this.uuid,g.proxy(this.image.hideResize,this)),this.image.resizer&&this.image.resizer.on("mousedown.redactor touchstart.redactor",g.proxy(function(t){this.image.setResizable(t,e)},this))},this),e.off("mousedown.redactor").on("mousedown.redactor",g.proxy(this.image.hideResize,this)),e.off("click.redactor touchstart.redactor").on("click.redactor touchstart.redactor",t)):e.off("click.redactor touchstart.redactor").on("click.redactor touchstart.redactor",g.proxy(function(t){setTimeout(g.proxy(function(){this.image.showEdit(e)},this),200)},this))},setResizable:function(t,e){t.preventDefault(),this.image.resizeHandle={x:t.pageX,y:t.pageY,el:e,ratio:e.width()/e.height(),h:e.height()},(t=t.originalEvent||t).targetTouches&&(this.image.resizeHandle.x=t.targetTouches[0].pageX,this.image.resizeHandle.y=t.targetTouches[0].pageY),this.image.startResize()},startResize:function(){g(document).on("mousemove.redactor-image-resize touchmove.redactor-image-resize",g.proxy(this.image.moveResize,this)),g(document).on("mouseup.redactor-image-resize touchend.redactor-image-resize",g.proxy(this.image.stopResize,this))},moveResize:function(t){t.preventDefault(),t=t.originalEvent||t;var e=this.image.resizeHandle.h;t.targetTouches?e+=t.targetTouches[0].pageY-this.image.resizeHandle.y:e+=t.pageY-this.image.resizeHandle.y;var i=Math.round(e*this.image.resizeHandle.ratio);e<50||i<100||this.core.editor().width()<=i||(this.image.resizeHandle.el.attr({width:i,height:e}),this.image.resizeHandle.el.width(i),this.image.resizeHandle.el.height(e),this.code.sync())},stopResize:function(){this.handle=!1,g(document).off(".redactor-image-resize"),this.image.hideResize()},hideResize:function(t){var e;t&&0!==g(t.target).closest("#redactor-image-box",this.$editor[0]).length||(t&&"IMG"==t.target.tagName&&g(t.target),0!==(e=this.$editor.find("#redactor-image-box")).length&&(g("#redactor-image-editter").remove(),g("#redactor-image-resizer").remove(),e.find("img").css({marginTop:e[0].style.marginTop,marginBottom:e[0].style.marginBottom,marginLeft:e[0].style.marginLeft,marginRight:e[0].style.marginRight}),e.css("margin",""),e.find("img").css("opacity",""),e.replaceWith(function(){return g(this).contents()}),g(document).off("mousedown.redactor-image-resize-hide."+this.uuid),void 0!==this.image.resizeHandle&&this.image.resizeHandle.el.attr("rel",this.image.resizeHandle.el.attr("style"))))},loadResizableControls:function(t,e){if(!this.opts.imageResizable||this.detect.isMobile())return e.append(t),!1;var i=g('<span id="redactor-image-resizer" data-redactor="verified"></span>');return this.detect.isDesktop()||i.css({width:"15px",height:"15px"}),i.attr("contenteditable",!1),e.append(i),e.append(t),i},loadEditableControls:function(t){if(0===g("#redactor-image-box").length){var e,i=g('<span id="redactor-image-box" data-redactor="verified">');return i.css("float",t.css("float")).attr("contenteditable",!1),"auto"!=t[0].style.margin?(i.css({marginTop:t[0].style.marginTop,marginBottom:t[0].style.marginBottom,marginLeft:t[0].style.marginLeft,marginRight:t[0].style.marginRight}),t.css("margin","")):i.css({display:"block",margin:"auto"}),t.css("opacity",".5").after(i),this.opts.imageEditable&&(this.image.editter=g('<span id="redactor-image-editter" data-redactor="verified">'+this.lang.get("edit")+"</span>"),this.image.editter.attr("contenteditable",!1),this.image.editter.on("click",g.proxy(function(){this.image.showEdit(t)},this)),i.append(this.image.editter),e=this.image.editter.innerWidth(),this.image.editter.css("margin-left","-"+e/2+"px")),this.image.loadResizableControls(t,i)}},showEdit:function(t){var e,i,r,n,s;this.events.imageEditing||(e=(this.observe.image=t).closest("a",this.$editor[0]),r=0!==(i=t.closest("figure",this.$editor[0])).length?i:t,this.modal.load("image-edit",this.lang.get("edit"),705),this.image.buttonDelete=this.modal.getDeleteButton().text(this.lang.get("delete")),this.image.buttonSave=this.modal.getActionButton().text(this.lang.get("save")),this.image.buttonDelete.on("click",g.proxy(this.image.remove,this)),this.image.buttonSave.on("click",g.proxy(this.image.update,this)),!1===this.opts.imageCaption?g("#redactor-image-caption").val("").hide().prev().hide():0!==(n=t.closest(this.opts.imageTag,this.$editor[0]).find("figcaption"))&&g("#redactor-image-caption").val(n.text()).show(),this.opts.imagePosition?(s=(0!==i.length?"center"===r.css("text-align"):"block"==r.css("display")&&"none"==r.css("float"))?"center":r.css("float"),g("#redactor-image-align").val(s)):g(".redactor-image-position-option").hide(),g("#redactor-image-preview").html(g('<img src="'+t.attr("src")+'" style="max-width: 100%;">')),g("#redactor-image-title").val(t.attr("alt")),0!==e.length&&(g("#redactor-image-link").val(e.attr("href")),"_blank"===e.attr("target")&&g("#redactor-image-link-blank").prop("checked",!0)),g(".redactor-link-tooltip").remove(),this.modal.show(),this.detect.isDesktop()&&g("#redactor-image-title").focus())},update:function(){var t=this.observe.image,e=t.closest("a",this.core.editor()[0]),i=g("#redactor-image-title").val().replace(/(<([^>]+)>)/gi,"");t.attr("alt",i).attr("title",i),this.image.setFloating(t);var r,n,s,o,a,l=g.trim(g("#redactor-image-link").val()).replace(/(<([^>]+)>)/gi,"");""!==l?(r="((xn--)?[a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,}",n=new RegExp("^(http|ftp|https)://"+r,"i"),s=new RegExp("^"+r,"i"),-1===l.search(n)&&0===l.search(s)&&this.opts.linkProtocol&&(l=this.opts.linkProtocol+"://"+l),o=!!g("#redactor-image-link-blank").prop("checked"),0===e.length?(a=g('<a href="'+l+'" id="redactor-img-tmp">'+this.utils.getOuterHtml(t)+"</a>"),o&&a.attr("target","_blank"),t=t.replaceWith(a),(e=this.core.editor().find("#redactor-img-tmp")).removeAttr("id")):(e.attr("href",l),o?e.attr("target","_blank"):e.removeAttr("target"))):0!==e.length&&e.replaceWith(this.utils.getOuterHtml(t)),this.image.addCaption(t,e),this.modal.close(),this.buffer.set()},setFloating:function(t){var e=t.closest("figure",this.$editor[0]),i=0!==e.length?e:t,r="",n="",s="",o="";switch(g("#redactor-image-align").val()){case"left":r="left",s="0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin+" 0";break;case"right":r="right",s="0 0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin;break;case"center":0!==e.length?o="center":(n="block",s="auto")}i.css({float:r,display:n,margin:s,"text-align":o}),i.attr("rel",t.attr("style"))},addCaption:function(t,e){var i=g("#redactor-image-caption").val(),r=0!==e.length?e:t,n=r.next();0!==n.length&&"FIGCAPTION"===n[0].tagName||(n=!1),""!==i?!1===n?(n=g("<figcaption />").text(i),r.after(n)):n.text(i):!1!==n&&n.remove()},remove:function(t,e,i){e=void 0===e?g(this.observe.image):e,"boolean"!=typeof t&&this.buffer.set(),this.events.stopDetectChanges();var r,n,s=e.closest("a",this.core.editor()[0]),o=e.closest(this.opts.imageTag,this.core.editor()[0]);e.parent();if(!1===this.core.callback("imageDelete",t,e[0]))return t&&t.preventDefault(),!1;0!==g("#redactor-image-box").length&&g("#redactor-image-box").parent(),0!==o.length?(n=o.prev(),r=o.next(),o.remove()):0!==s.length?(s.parent(),s.remove()):e.remove(),g("#redactor-image-box").remove(),!1!==t&&(r&&0!==r.length?this.caret.start(r):n&&0!==n.length&&this.caret.end(n)),"boolean"!=typeof t&&this.modal.close(),this.utils.restoreScroll(),this.observe.image=!1,this.events.startDetectChanges(),this.code.sync()}}},indent:function(){return{increase:function(){var t,e,i,r,n,s;this.list.get()&&(e=(t=g(this.selection.current()).closest("li")).closest("ul, ol",this.core.editor()[0]),0!==(i=t.closest("li").prev()).length&&"LI"===i[0].tagName&&(this.buffer.set(),this.utils.isCollapsed()?(n=e[0].tagName,s=g("<"+n+" />"),this.selection.save(),1===(r=i.find("ol").first()).length?r.append(t):(n=e[0].tagName,(s=g("<"+n+" />")).append(t),i.append(s))):(document.execCommand("indent"),this.selection.save(),this.indent.removeEmpty(),this.indent.normalize()),this.selection.restore()))},decrease:function(){if(this.list.get()){g(this.selection.current()).closest("li").closest("ul, ol",this.core.editor()[0]);this.buffer.set(),document.execCommand("outdent");var t=g(this.selection.current()).closest("li",this.core.editor()[0]);this.utils.isCollapsed()&&this.indent.repositionItem(t);var e=null;if(0===t.length){var i=this.selection.block();if(i&&-1!==i.nodeName.indexOf("-")){for(this.selection.save(),e=elCreate("div");i.childNodes.length;)e.appendChild(i.childNodes[0]);i.appendChild(e),this.selection.restore()}document.execCommand("formatblock",!1,"p");var r=(t=g(this.selection.current())).next();0!==r.length&&"BR"===r[0].tagName&&r.remove()}if(this.selection.save(),null!==e){for(var n=e.parentNode;e.childNodes.length;)n.insertBefore(e.childNodes[0],e);n.removeChild(e)}this.indent.removeEmpty(),this.indent.normalize(),this.selection.restore()}},repositionItem:function(t){var e=t.next();0===e.length||"UL"===e[0].tagName&&"OL"===e[0].tagName||t.append(e);var i=t.prev();0!==i.length&&"LI"!==i[0].tagName&&(this.selection.save(),t.parents("li",this.core.editor()[0]).after(t),this.selection.restore())},normalize:function(){this.core.editor().find("li").each(g.proxy(function(t,e){var i=g(e),r="";0!==this.opts.keepStyleAttr.length&&(r=","+this.opts.keepStyleAttr.join(",")),i.find(this.opts.inlineTags.join(",")).not("img"+r).removeAttr("style");var n,s=i.parent();0===s.length||"LI"!==s[0].tagName?0===(n=i.next()).length||"UL"!==n[0].tagName&&"OL"!==n[0].tagName||i.append(n):s.after(i)},this))},removeEmpty:function(t){var e=this.core.editor().find("ul, ol"),i=this.core.editor().find("li");i.each(g.proxy(function(t,e){this.indent.removeItemEmpty(e)},this)),e.each(g.proxy(function(t,e){this.indent.removeItemEmpty(e)},this)),i.each(g.proxy(function(t,e){this.indent.removeItemEmpty(e)},this))},removeItemEmpty:function(t){""===t.innerHTML.replace(/[\t\s\n]/g,"").replace(/<span><\/span>/g,"")&&g(t).remove()}}},inline:function(){return{format:function(t,e,i,r){var n;this.utils.isCurrentOrParent(["PRE","CODE"])||(n=this.inline.getParams(e,i,r),t=this.inline.arrangeTag(t),this.buffer.set(),this.utils.isCollapsed()?this.inline.formatCollapsed(t,n):this.inline.formatUncollapsed(t,n))},formatCollapsed:function(t,e){var i,r,n,s=this.selection.inline();s?(r=s.tagName.toLowerCase())===t?this.utils.isEmpty(s.innerHTML)?(this.caret.after(s),g(s).remove()):(n=this.inline.insertBreakpoint(s,r),this.caret.after(n)):0===g(s).closest(t).length?(i=this.inline.insertInline(t),i=this.inline.setParams(i,e)):(n=this.inline.insertBreakpoint(s,r),this.caret.after(n)):(i=this.inline.insertInline(t),i=this.inline.setParams(i,e))},formatUncollapsed:function(n,s){this.selection.save();var t=this.inline.getClearedNodes();this.inline.setNodesStriked(t,n,s),this.selection.restore(),document.execCommand("strikethrough"),this.selection.saveInstant();for(var e,i,r=this.core.editor()[0].querySelectorAll('[style*="line-through"]'),o=0,a=r.length;o<a;o++)e=r[0],i=document.createElement("strike"),e.parentNode.insertBefore(i,e),i.appendChild(e),e.style.removeProperty("text-decoration");var l=this;this.core.editor().find("strike").each(function(){var t=l.utils.replaceToTag(this,n);l.inline.setParams(t[0],s);var e=t.find(n),i=t.parent(),r=i.parent();if(0!==r.length&&r[0].tagName.toLowerCase()===n&&r.html()==i[0].outerHTML)return t.replaceWith(function(){return g(this).contents()}),void r.replaceWith(function(){return g(this).contents()});0!==e.length&&l.inline.cleanInsideOrParent(e,s),i.html()==t[0].outerHTML&&l.inline.cleanInsideOrParent(i,s),l.detect.isFirefox()&&l.core.editor().find(n+":empty").remove()}),this.selection.restoreInstant()},cleanInsideOrParent:function(t,e){if(e)for(var i in e.data)this.inline.removeSpecificAttr(t,i,e.data[i])},getClearedNodes:function(){for(var t=this.selection.nodes(),e=[],i=t.length,r=0,n=0;n<i;n++)if(g(t[n]).hasClass("redactor-selection-marker")){r=n+2;break}for(n=0;n<i;n++)r<=n&&!this.utils.isBlockTag(t[n].tagName)&&e.push(t[n]);return e},isConvertableAttr:function(t,e,i){var r=g(t).attr(e);if(r)if("style"===e){for(var n=(i=g.trim(i).replace(/;$/,"")).split(";"),s=0,o=0;o<n.length;o++){var a,l=n[o].split(":"),c=g.trim(l[0]),h=g.trim(l[1]);-1!==c.search(/color/)?!(a=g(t).css(c))||a!==h&&this.utils.rgb2hex(a)!==h||s++:g(t).css(c)===h&&s++}if(s===n.length)return 1}else if(r===i)return 1;return 0},isConvertable:function(t,e,i,r){if(e===i){if(!r)return!0;var n=0;for(var s in r.data)n+=this.inline.isConvertableAttr(t,s,r.data[s]);if(n===Object.keys(r.data).length)return!0}return!1},setNodesStriked:function(t,e,i){for(var r=0;r<t.length;r++){var n=t[r].tagName?t[r].tagName.toLowerCase():void 0,s=t[r].parentNode,o=s&&s.tagName?s.tagName.toLowerCase():void 0;this.inline.isConvertable(s,o,e,i)&&g(s).replaceWith(function(){return g("<strike>").append(g(this).contents())}).attr("data-redactor-inline-converted"),this.inline.isConvertable(t[r],n,e,i)&&g(t[r]).replaceWith(function(){return g("<strike>").append(g(this).contents())})}},insertBreakpoint:function(t,e){var i=document.createElement("span");i.id="redactor-inline-breakpoint",i=this.insert.node(i);var r=this.utils.isEndOfElement(t)?"":"<"+e+">",n=(n=this.utils.getOuterHtml(t)).replace(/<span id="redactor-inline-breakpoint"><\/span>/i,"</"+e+">"+r),s=g(n);return g(t).replaceWith(s),r&&this.utils.cloneAttributes(t,s.last()),s.first()},insertInline:function(t){var e=document.createElement(t);return this.insert.node(e),this.caret.start(e),e},arrangeTag:function(t){var e=["b","bold","i","italic","underline","strikethrough","deleted","superscript","subscript"],i=["strong","strong","em","em","u","del","del","sup","sub"];t=t.toLowerCase();for(var r=0;r<e.length;r++)t===e[r]&&(t=i[r]);return t},getStyleParams:function(t){for(var e={},i=t.trim().replace(/;$/,"").split(";"),r=0;r<i.length;r++){var n=i[r].split(":");n&&(e[n[0].trim()]=n[1].trim())}return e},getParams:function(t,e,i){var r=!1,n="toggle";return"object"==typeof t?(r=t,n=void 0!==e?e:n):void 0!==t&&void 0!==e&&((r={})[t]=e,n=void 0!==i?i:n),!!r&&{func:n,data:r}},setParams:function(t,e){if(e)for(var i in e.data){var r=g(t);"style"===i?(t=this.inline[e.func+"Style"](e.data[i],t),r.attr("data-redactor-style-cache",r.attr("style"))):t="class"===i?this.inline[e.func+"Class"](e.data[i],t):"remove"===e.func?this.inline[e.func+"Attr"](i,t):this.inline[e.func+"Attr"](i,e.data[i],t),"style"===i&&"SPAN"===t.tagName&&r.attr("data-redactor-span",!0)}return t},eachInline:function(t,e){var i,r=void 0===t?this.selection.inlines():[t];if(r)for(var n=0;n<r.length;n++)i=e(r[n])[0];return i},replaceClass:function(e,t){return this.inline.eachInline(t,function(t){return g(t).removeAttr("class").addClass(e)})},toggleClass:function(e,t){return this.inline.eachInline(t,function(t){return g(t).toggleClass(e)})},addClass:function(e,t){return this.inline.eachInline(t,function(t){return g(t).addClass(e)})},removeClass:function(e,t){return this.inline.eachInline(t,function(t){return g(t).removeClass(e)})},removeAllClass:function(t){return this.inline.eachInline(t,function(t){return g(t).removeAttr("class")})},replaceAttr:function(e,t,i){return this.inline.eachInline(i,function(t){return g(t).removeAttr(e).attr(e.value)})},toggleAttr:function(e,t,i){return this.inline.eachInline(i,function(t){return g(t).attr(e)?g(t).removeAttr(e):g(t).attr(e.value)})},addAttr:function(e,i,t){return this.inline.eachInline(t,function(t){return g(t).attr(e,i)})},removeAttr:function(i,t){return this.inline.eachInline(t,function(t){var e=g(t);return e.removeAttr(i),"style"===i&&e.removeAttr("data-redactor-style-cache"),e})},removeAllAttr:function(t){return this.inline.eachInline(t,function(t){for(var e=g(t),i=t.attributes.length,r=0;r<i;r++)e.removeAttr(t.attributes[r].name);return e})},removeSpecificAttr:function(t,e,i){var r,n=g(t);"style"===e?(r=i.split(":")[0].trim(),n.css(r,""),this.utils.removeEmptyAttr(t,"style")&&n.removeAttr("data-redactor-style-cache")):n.removeAttr(e)[0]},hasParentStyle:function(t){var e=t.parent();return 1===e.length&&e[0].tagName===t[0].tagName&&e.html()===t[0].outerHTML&&e},addParentStyle:function(t){var e,i=this.inline.hasParentStyle(t);return i?(e=this.inline.getStyleParams(t.attr("style")),i.css(e),i.attr("data-redactor-style-cache",i.attr("style")),t.replaceWith(function(){return g(this).contents()})):t.attr("data-redactor-style-cache",t.attr("style")),t},replaceStyle:function(r,t){r=this.inline.getStyleParams(r);var n=this;return this.inline.eachInline(t,function(t){var e=g(t);e.removeAttr("style").css(r);var i=e.attr("style");return i&&e.attr("style",i.replace(/"/g,"'")),e=n.inline.addParentStyle(e)})},toggleStyle:function(o,t){o=this.inline.getStyleParams(o);var a=this;return this.inline.eachInline(t,function(t){var e=g(t);for(var i in o){var r=o[i],n=e.css(i);(n=a.utils.isRgb(n)?a.utils.rgb2hex(n):n.replace(/"/g,""))===(r=a.utils.isRgb(r)?a.utils.rgb2hex(r):r.replace(/"/g,""))?e.css(i,""):e.css(i,r)}var s=e.attr("style");return s&&e.attr("style",s.replace(/"/g,"'")),a.utils.removeEmptyAttr(t,"style")?e.removeAttr("data-redactor-style-cache"):e=a.inline.addParentStyle(e),e})},addStyle:function(r,t){r=this.inline.getStyleParams(r);var n=this;return this.inline.eachInline(t,function(t){var e=g(t);e.css(r);var i=e.attr("style");return i&&e.attr("style",i.replace(/"/g,"'")),e=n.inline.addParentStyle(e)})},removeStyle:function(r,t){r=this.inline.getStyleParams(r);var n=this;return this.inline.eachInline(t,function(t){var e=g(t);for(var i in r)e.css(i,"");return n.utils.removeEmptyAttr(t,"style")?e.removeAttr("data-redactor-style-cache"):e.attr("data-redactor-style-cache",e.attr("style")),e})},removeAllStyle:function(t){return this.inline.eachInline(t,function(t){return g(t).removeAttr("style").removeAttr("data-redactor-style-cache")})},removeStyleRule:function(t){var e=this.selection.parent(),i=this.selection.inlines();this.buffer.set(),e&&"SPAN"===e.tagName&&this.inline.removeStyleRuleAttr(g(e),t);for(var r=0;r<i.length;r++){var n=i[r],s=g(n);-1==g.inArray(n.tagName.toLowerCase(),this.opts.inlineTags)||s.hasClass("redactor-selection-marker")||this.inline.removeStyleRuleAttr(s,t)}},removeStyleRuleAttr:function(t,e){t.css(e,""),this.utils.removeEmptyAttr(t,"style")?t.removeAttr("data-redactor-style-cache"):t.attr("data-redactor-style-cache",t.attr("style"))},update:function(t,e,i,r){t=this.inline.arrangeTag(t);var n=this.inline.getParams(e,i,r),s=this.selection.inlines(),o=[];if(s)for(var a=0;a<s.length;a++){var l=s[a];"*"!==t&&l.tagName.toLowerCase()!==t||o.push(this.inline.setParams(l,n))}return o},removeFormat:function(){this.selection.save();for(var t=this.inline.getClearedNodes(),e=0;e<t.length;e++)1===t[e].nodeType&&g(t[e]).replaceWith(function(){return g(this).contents()});this.selection.restore()}}},insert:function(){return{set:function(t){this.code.set(t),this.focus.end()},html:function(t,e){this.core.editor().focus();var i=this.selection.block(),r=this.selection.inline();void 0===e&&(e=this.clean.getCurrentType(t,!0),t=this.clean.onPaste(t,e,!0)),t=g.parseHTML(t);var n,s,o,a=g(t).last(),l=this.selection.get(),c=this.selection.range(l);if(c.deleteContents(),this.selection.update(l,c),e.lists){var h=g(t);if(0!==h.length&&("UL"===h[0].tagName||"OL"===h[0].tagName))return void this.insert.appendLists(i,h)}e.blocks&&i?this.utils.isSelectAll()?(this.core.editor().html(t),this.focus.end()):!1===(n=this.utils.breakBlockTag())?this.insert.placeHtml(t):(g(t).children().last().append(this.marker.get()),"start"===n.type?n.$block.before(t):n.$block.after(t),this.selection.restore(),this.core.editor().find("p").each(function(){""===g.trim(this.innerHTML)&&g(this).remove()})):(r&&((s=g("<div/>").html(t)).find(r.tagName.toLowerCase()).each(function(){g(this).contents().unwrap()}),t=s.html(),t=g.parseHTML(t),a=g(t).last()),this.utils.isSelectAll()?(o=g(this.opts.emptyHtml),this.core.editor().html("").append(o),o.html(t),this.caret.end(o)):this.insert.placeHtml(t)),this.utils.disableSelectAll(),e.pre&&this.clean.cleanPre(),this.caret.end(a)},text:function(t){t=t.toString(),t=g.trim(t);var e,i,r,n,s,o=document.createElement("div");o.innerHTML=t,void 0!==(t=o.textContent||o.innerText)&&(this.core.editor().focus(),e=this.selection.blocks(),t=t.replace(/\n/g," "),this.utils.isSelectAll()?(i=g(this.opts.emptyHtml),this.core.editor().html("").append(i),i.html(t),this.caret.end(i)):(r=this.selection.get(),n=document.createTextNode(t),r.getRangeAt&&r.rangeCount&&((s=r.getRangeAt(0)).deleteContents(),s.insertNode(n),s.setStartAfter(n),s.collapse(!0),this.selection.update(r,s)),1<e.length&&(g(n).wrap("<p>"),this.caret.after(n))),this.utils.disableSelectAll(),this.clean.normalizeCurrentHeading())},raw:function(t){this.core.editor().focus();var e=this.selection.get(),i=this.selection.range(e);i.deleteContents();var r=document.createElement("div");r.innerHTML=t;for(var n,s,o=document.createDocumentFragment();n=r.firstChild;)s=o.appendChild(n);i.insertNode(o),s&&((i=i.cloneRange()).setStartAfter(s),i.collapse(!0),e.removeAllRanges(),e.addRange(i))},node:function(t,e){void 0!==this.start&&this.core.editor().focus(),t=t[0]||t;var i,r=this.selection.block(),n=this.utils.isBlockTag(t.tagName),s=!0;return this.utils.isSelectAll()?(n?this.core.editor().html(t):this.core.editor().html(g("<p>").html(t)),this.code.sync()):n&&r?!1===(i=this.utils.breakBlockTag())?this.insert.placeNode(t,e):("start"===i.type?i.$block.before(t):i.$block.after(t),this.core.editor().find("p:empty").remove()):s=this.insert.placeNode(t,e),this.utils.disableSelectAll(),s&&this.caret.end(t),t},appendLists:function(t,e){var i,r,n=g(t),s=this.utils.isEmpty(t.innerHTML);s||this.utils.isEndOfElement(t)?(i=n,e.find("li").each(function(){i.after(this),i=g(this)}),s&&n.remove()):this.utils.isStartOfElement(t)?e.find("li").each(function(){n.before(this),i=g(this)}):(r=this.selection.extractEndOfNode(t),n.after(g("<li>").append(r)),n.append(e),i=e),this.marker.remove(),i&&this.caret.end(i)},placeHtml:function(t){var e=document.createElement("span");e.id="redactor-insert-marker",e=this.insert.node(e),g(e).before(t),this.selection.restore(),this.caret.after(e),g(e).remove()},placeNode:function(t,e){var i=this.selection.get(),r=this.selection.range(i);if(null==r)return!1;!1!==e&&r.deleteContents(),r.insertNode(t),r.collapse(!1),this.selection.update(i,r)},nodeToPoint:function(t,e){if(e=e[0]||e,this.utils.isEmpty())return e=this.utils.isBlock(e)?e:g("<p />").append(e),this.core.editor().html(e),e;var i,r,n,s=t.clientX,o=t.clientY;return document.caretPositionFromPoint?(i=document.caretPositionFromPoint(s,o),(r=document.getSelection().getRangeAt(0)).setStart(i.offsetNode,i.offset),r.collapse(!0),r.insertNode(e)):document.caretRangeFromPoint?(r=document.caretRangeFromPoint(s,o)).insertNode(e):void 0!==document.body.createTextRange&&((r=document.body.createTextRange()).moveToPoint(s,o),(n=r.duplicate()).moveToPoint(s,o),r.setEndPoint("EndToEnd",n),r.select()),e},nodeToCaretPositionFromPoint:function(t,e){this.insert.nodeToPoint(t,e)},marker:function(){this.marker.insert()}}},keydown:function(){return{init:function(t){if(!this.rtePaste){var e=t.which,i=37<=e&&e<=40;if(this.keydown.ctrl=t.ctrlKey||t.metaKey,this.keydown.parent=this.selection.parent(),this.keydown.current=this.selection.current(),this.keydown.block=this.selection.block(),this.keydown.pre=this.utils.isTag(this.keydown.current,"pre"),this.keydown.blockquote=this.utils.isTag(this.keydown.current,"blockquote"),this.keydown.figcaption=this.utils.isTag(this.keydown.current,"figcaption"),this.keydown.figure=this.utils.isTag(this.keydown.current,"figure"),!1===this.core.callback("keydown",t))return t.preventDefault(),!1;if(this.shortcuts.init(t,e),this.keydown.checkEvents(i,e),this.keydown.setupBuffer(t,e),this.utils.isSelectAll()&&(e===this.keyCode.ENTER||e===this.keyCode.BACKSPACE||e===this.keyCode.DELETE))return t.preventDefault(),this.code.set(this.opts.emptyHtml),void this.events.changeHandler();if(this.keydown.addArrowsEvent(i),this.keydown.setupSelectAll(t,e),this.opts.enterKey||e!==this.keyCode.ENTER){if(this.opts.enterKey&&e===this.keyCode.DOWN&&this.keydown.onArrowDown(),this.opts.enterKey&&e===this.keyCode.UP&&this.keydown.onArrowUp(),("textarea"===this.opts.type||"div"===this.opts.type)&&this.keydown.current&&3===this.keydown.current.nodeType&&g(this.keydown.parent).hasClass("redactor-in")&&this.keydown.wrapToParagraph(),!this.keyup.lastShiftKey&&e===this.keyCode.SPACE&&(t.ctrlKey||t.shiftKey))return t.preventDefault(),this.keydown.onShiftSpace();if(e===this.keyCode.ENTER&&(t.ctrlKey||t.shiftKey)&&(null===h||"ios"!==h.platform()))return t.preventDefault(),this.keydown.onShiftEnter(t);if(e===this.keyCode.ENTER&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey)return this.keydown.onEnter(t);if(e===this.keyCode.TAB||t.metaKey&&221===e||t.metaKey&&219===e)return this.keydown.onTab(t,e);if(this.detect.isFirefox()&&e===this.keyCode.BACKSPACE&&this.keydown.block&&"P"===this.keydown.block.tagName&&this.utils.isStartOfElement(this.keydown.block))if(0!==(r=g(this.keydown.block).prev()).length)return t.preventDefault(),r.append(this.marker.get()),r.append(g(this.keydown.block).html()),g(this.keydown.block).remove(),void this.selection.restore();if(e===this.keyCode.BACKSPACE||e===this.keyCode.DELETE){if(this.observe.image&&void 0!==this.observe.image&&0!==g("#redactor-image-box").length){t.preventDefault();var r=this.observe.image.closest("figure, p").prev();return this.image.remove(!1),this.observe.image=!1,void(r&&0!==r.length?this.caret.end(r):this.core.editor().focus())}this.keydown.onBackspaceAndDeleteBefore()}if(e===this.keyCode.DELETE){var n=g(this.keydown.block).next();if(this.utils.isEndOfElement(this.keydown.block)&&0!==n.length&&"FIGURE"===n[0].tagName)return n.remove(),!1;if(!(!this.keydown.block||"LI"!==this.keydown.block.tagName)&&this.keydown.block){var s=g(this.keydown.block).parents("ul, ol").last(),o=s.next();if(this.utils.isRedactorParent(s)&&this.utils.isEndOfElement(s)&&0!==o.length&&("UL"===o[0].tagName||"OL"===o[0].tagName))return t.preventDefault(),s.append(o.contents()),o.remove(),!1}if(this.utils.isEndOfElement(this.keydown.block)&&0!==n.length&&"PRE"===n[0].tagName)return g(this.keydown.block).append(n.text()),n.remove(),!1}if(e===this.keyCode.DELETE&&0!==g("#redactor-image-box").length&&this.image.remove(),e===this.keyCode.BACKSPACE){if(this.detect.isFirefox()&&this.line.removeOnBackspace(t),this.list.combineAfterAndBefore(this.keydown.block))return void t.preventDefault();var a=this.selection.block();if(a&&"LI"===a.tagName&&this.utils.isCollapsed()&&this.utils.isStartOfElement())return this.indent.decrease(),void t.preventDefault();this.keydown.removeInvisibleSpace(),this.keydown.removeEmptyListInTable(t)}e!==this.keyCode.BACKSPACE&&e!==this.keyCode.DELETE||this.keydown.onBackspaceAndDeleteAfter(t)}else{t.preventDefault();var l=this.selection.get(),c=this.selection.range(l);c.collapsed||c.deleteContents()}}},onShiftSpace:function(){return this.buffer.set(),this.insert.raw("&nbsp;"),!1},onShiftEnter:function(t){return this.buffer.set(),this.keydown.pre?this.keydown.insertNewLine(t):this.insert.raw("<br>")},onBackspaceAndDeleteBefore:function(){this.utils.saveScroll()},onBackspaceAndDeleteAfter:function(e){setTimeout(g.proxy(function(){this.code.syncFire=!1,this.keydown.removeEmptyLists();var t="";0!==this.opts.keepStyleAttr.length&&(t=","+this.opts.keepStyleAttr.join(",")),this.core.editor().find("*[style]").not("img, figure, iframe, #redactor-image-box, #redactor-image-editter, [data-redactor-style-cache], [data-redactor-span]"+t).removeAttr("style"),this.keydown.formatEmpty(e),this.code.syncFire=!0},this),1)},onEnter:function(t){if(!1===this.core.callback("enter",t))return t.preventDefault(),!1;if(this.keydown.blockquote&&!0===this.keydown.exitFromBlockquote(t))return!1;if(this.keydown.pre)return this.keydown.insertNewLine(t);if(this.keydown.blockquote||this.keydown.figcaption)return this.keydown.insertBreakLine(t);if(this.keydown.figure)setTimeout(g.proxy(function(){this.keydown.replaceToParagraph("FIGURE")},this),1);else if(this.keydown.block){if(setTimeout(g.proxy(function(){this.keydown.replaceToParagraph("DIV")},this),1),"LI"===this.keydown.block.tagName){var e=this.selection.current(),i=g(e).closest("li",this.$editor[0]),r=i.parents("ul,ol",this.$editor[0]).last();if(0!==i.length&&this.utils.isEmpty(i.html())&&0===r.next().length&&this.utils.isEmpty(r.find("li").last().html())){r.find("li").last().remove();var n=g(this.opts.emptyHtml);return r.after(n),this.caret.start(n),!1}}}else if(!this.keydown.block)return this.keydown.insertParagraph(t);this.detect.isFirefox()&&this.utils.isInline(this.keydown.parent)?this.keydown.insertBreakLine(t):this.opts.keepInlineOnEnter||setTimeout(g.proxy(function(){var t,e,i,r,n=this.selection.inline();n&&this.utils.isEmpty(n.innerHTML)&&(t=this.selection.block(),g(n).remove(),(e=document.createRange()).setStart(t,0),i=document.createTextNode("​"),e.insertNode(i),e.setStartAfter(i),e.collapse(!0),(r=window.getSelection()).removeAllRanges(),r.addRange(e))},this),1)},checkEvents:function(t,e){t||"click"!==this.core.getEvent()&&"arrow"!==this.core.getEvent()||(this.core.addEvent(!1),this.keydown.checkKeyEvents(e)&&this.buffer.set())},checkKeyEvents:function(t){var e=this.keyCode,i=[e.BACKSPACE,e.DELETE,e.ENTER,e.ESC,e.TAB,e.CTRL,e.META,e.ALT,e.SHIFT];return-1===g.inArray(t,i)},addArrowsEvent:function(t){t&&("click"!==this.core.getEvent()&&"arrow"!==this.core.getEvent()?this.core.addEvent("arrow"):this.core.addEvent(!1))},setupBuffer:function(t,e){return this.keydown.ctrl&&90===e&&!t.shiftKey&&!t.altKey&&this.sBuffer.length?(t.preventDefault(),void this.buffer.undo()):this.keydown.ctrl&&90===e&&t.shiftKey&&!t.altKey&&0!==this.sRebuffer.length?(t.preventDefault(),void this.buffer.redo()):void(this.keydown.ctrl||e!==this.keyCode.SPACE&&e!==this.keyCode.BACKSPACE&&e!==this.keyCode.DELETE&&(e!==this.keyCode.ENTER||t.ctrlKey||t.shiftKey)||this.buffer.set())},exitFromBlockquote:function(t){if(this.utils.isEndOfElement(this.keydown.blockquote)&&-1!==this.clean.removeSpacesHard(g(this.keydown.blockquote).html()).search(/(<br\s?\/?>){1}$/i)){t.preventDefault(),g(this.keydown.blockquote).children().last().filter("br").remove(),g(this.keydown.blockquote).children().last().filter("span").remove();var e=g(this.opts.emptyHtml);return g(this.keydown.blockquote).after(e),this.caret.start(e),!0}},onArrowDown:function(){for(var t=[this.keydown.blockquote,this.keydown.pre,this.keydown.figcaption],e=0;e<t.length;e++)if(t[e])return this.keydown.insertAfterLastElement(t[e]),!1},onArrowUp:function(){for(var t=[this.keydown.blockquote,this.keydown.pre,this.keydown.figcaption],e=0;e<t.length;e++)if(t[e])return this.keydown.insertBeforeFirstElement(t[e]),!1},insertAfterLastElement:function(t){var e,i;this.utils.isEndOfElement(t)&&(e=this.core.editor().contents().last(),0===("FIGCAPTION"===t.tagName?g(this.keydown.block).parent().next():g(this.keydown.block).next()).length&&(0!==e.length||e[0]===t?(i=g(this.opts.emptyHtml),"FIGCAPTION"===t.tagName?g(t).parent().after(i):g(t).after(i),this.caret.start(i)):this.caret.start(e)))},insertBeforeFirstElement:function(t){var e;this.utils.isStartOfElement()&&(1<this.core.editor().contents().length&&this.core.editor().contents().first()[0]!==t||(e=g(this.opts.emptyHtml),g(t).before(e),this.caret.start(e)))},onTab:function(t,e){if(!this.opts.tabKey)return!0;var i=this.keydown.block&&"LI"===this.keydown.block.tagName;if(this.utils.isEmpty(this.code.get())||!i&&!this.keydown.pre&&!1===this.opts.tabAsSpaces)return!0;t.preventDefault(),this.buffer.set();var r,n=i&&this.utils.isStartOfElement(this.keydown.block);return this.keydown.pre&&!t.shiftKey?(r=this.opts.preSpaces?document.createTextNode(Array(this.opts.preSpaces+1).join(" ")):document.createTextNode("\t"),this.insert.node(r)):!1===this.opts.tabAsSpaces||n?t.metaKey&&219===e||(!t.metaKey||221!==e)&&t.shiftKey?this.indent.decrease():this.indent.increase():(r=document.createTextNode(Array(this.opts.tabAsSpaces+1).join(" ")),this.insert.node(r)),!1},setupSelectAll:function(t,e){this.keydown.ctrl&&65===e?this.utils.enableSelectAll():e===this.keyCode.LEFT_WIN||this.keydown.ctrl||this.utils.disableSelectAll()},insertNewLine:function(t){t.preventDefault();var e=document.createTextNode("\n"),i=this.selection.get(),r=this.selection.range(i);return r.deleteContents(),r.insertNode(e),this.caret.after(e),!1},insertParagraph:function(t){t.preventDefault();var e=document.createElement("p");e.innerHTML="<br>";var i=this.selection.get(),r=this.selection.range(i);return r.deleteContents(),r.insertNode(e),this.caret.start(e),!1},insertBreakLine:function(t){return this.keydown.insertBreakLineProcessing(t)},insertDblBreakLine:function(t){return this.keydown.insertBreakLineProcessing(t,!0)},insertBreakLineProcessing:function(t,e){t.stopPropagation();var i,r=document.createElement("br");return this.insert.node(r),!0===e?(i=document.createElement("br"),this.insert.node(i),this.caret.after(i)):this.caret.after(r),!1},wrapToParagraph:function(){var t=g(this.keydown.current),e=g("<p>").append(t.clone());t.replaceWith(e);var i=g(e).next();void 0!==i[0]&&"BR"===i[0].tagName&&i.remove(),this.caret.end(e)},replaceToParagraph:function(t){var i=this.selection.block(),e=g(i).prev(),r=i.innerHTML.replace(/<br\s?\/?>/gi,"");if(i.tagName===t&&this.utils.isEmpty(r)&&!g(i).hasClass("redactor-in")){var n=document.createElement("p");return g(i).replaceWith(n),this.keydown.setCaretToParagraph(n),!1}if("P"===i.tagName)return g(i).removeAttr("class").removeAttr("style"),this.detect.isIe()&&this.utils.isEmpty(r)&&this.utils.isInline(this.keydown.parent)&&g(i).on("input",g.proxy(function(){var t,e=this.selection.parent();this.utils.isInline(e)&&(t=g(e).html(),g(i).html(t),this.caret.end(i)),g(i).off("keyup")},this)),!1;if(e.hasClass(this.opts.videoContainerClass)){e.removeAttr("class");n=document.createElement("p");return e.replaceWith(n),this.keydown.setCaretToParagraph(n),!1}},setCaretToParagraph:function(t){var e=document.createRange();e.setStart(t,0);var i=document.createTextNode("​");e.insertNode(i),e.setStartAfter(i),e.collapse(!0);var r=window.getSelection();r.removeAllRanges(),r.addRange(e)},removeInvisibleSpace:function(){var t=g(this.keydown.current);0===t.text().search(/^\u200B$/g)&&t.remove()},removeEmptyListInTable:function(t){var e=g(this.keydown.current),i=g(this.keydown.parent),r=e.closest("td",this.$editor[0]);if(0!==r.length&&e.closest("li",this.$editor[0])&&1===i.children("li").length){if(!this.utils.isEmpty(e.text()))return;t.preventDefault(),e.remove(),i.remove(),this.caret.start(r)}},removeEmptyLists:function(){function t(){""===g.trim(this.innerHTML).replace(/\/t\/n/g,"")&&g(this).remove()}this.core.editor().find("li").each(t),this.core.editor().find("ul, ol").each(t)},formatEmpty:function(t){var e,i=g.trim(this.core.editor().html());if(this.utils.isEmpty(i))return t.preventDefault(),"inline"===this.opts.type||"pre"===this.opts.type?(this.core.editor().html(this.marker.html()),this.selection.restore()):(e=function(){this.core.editor().html(this.opts.emptyHtml),this.focus.start()}.bind(this),null!==h&&"ios"===h.platform()?setTimeout(e,50):e()),!1}}},keyup:function(){return{init:function(t){if(!this.rtePaste){var e,i=t.which;if(this.keyup.block=this.selection.block(),this.keyup.current=this.selection.current(),this.keyup.parent=this.selection.parent(),this.keyup.lastShiftKey=t.shiftKey,!1===this.core.callback("keyup",t))return t.preventDefault(),!1;if(i===this.keyCode.ENTER&&this.keyup.block&&"FIGURE"===this.keyup.block.tagName){var r=g(this.keyup.block).prev();if(0!==r.length&&"FIGURE"===r[0].tagName){var n=this.utils.replaceToTag(r,"p");return void this.caret.start(n)}}if(i===this.keyCode.BACKSPACE||i===this.keyCode.DELETE){if(this.utils.isSelectAll())return void this.focus.start();if(this.keyup.block&&this.keydown.block&&"FIGURE"===this.keyup.block.tagName&&this.utils.isStartOfElement(this.keydown.block)){t.preventDefault(),this.selection.save(),g(this.keyup.block).find("figcaption").remove(),g(this.keyup.block).find("img").first().remove(),this.utils.replaceToTag(this.keyup.block,"p");var s=this.marker.find();return g("html, body").animate({scrollTop:s.position().top+20},500),void this.selection.restore()}this.keyup.block&&"P"===this.keyup.block.tagName&&(e=g(this.keyup.block).find("img").length,""===g(this.keyup.block).text().replace(/\u200B/g,"")&&0!==e&&this.utils.replaceToTag(this.keyup.block,"figure")),this.keyup.block&&"FIGURE"===this.keyup.block.tagName&&0===g(this.keyup.block).find("img").length&&(this.selection.save(),this.utils.replaceToTag(this.keyup.block,"p"),this.selection.restore())}}}}},lang:function(){return{load:function(){this.opts.curLang=this.opts.langs[this.opts.lang]},get:function(t){return void 0!==this.opts.curLang[t]?this.opts.curLang[t]:""}}},line:function(){return{insert:function(){this.buffer.set(),this.insert.html(this.line.getLineHtml());var t=this.core.editor().find("#redactor-hr-tmp-id");return t.removeAttr("id"),this.core.callback("insertedLine",t),t},getLineHtml:function(){var t='<hr id="redactor-hr-tmp-id" />';return!this.detect.isFirefox()&&this.utils.isEmpty()&&(t+="<p>"+this.opts.emptyHtml+"</p>"),t},removeOnBackspace:function(t){var e,i;this.utils.isCollapsed()&&(0===(e=g(this.selection.block())).length||!this.utils.isStartOfElement(e)||(i=e.prev())&&0!==i.length&&"HR"===i[0].tagName&&(t.preventDefault(),i.remove()))}}},link:function(){return{get:function(){return g(this.selection.inlines("a"))},is:function(){var t=this.selection.nodes(),e=g(this.selection.current()).closest("a",this.core.editor()[0]);return!(0===e.length||1<t.length)&&e},unlink:function(t){void 0!==t&&t.preventDefault&&t.preventDefault(),this.buffer.set();var e,i=this.selection.inlines("a");0!==i.length&&(e=this.link.replaceLinksToText(i),this.observe.closeAllTooltip(),this.core.callback("deletedLink",e))},insert:function(t,e){var i,r=this.link.is();return(!0===e||!1!==(t=this.link.buildLinkFromObject(r,t)))&&(this.buffer.set(),t=this.core.callback("beforeInsertingLink",t),!1===r?(r=g("<a />"),r=this.link.update(r,t),i=(r=g(this.insert.node(r))).parent(),!1===this.utils.isRedactorParent(i)&&r.wrap("<p>"),i.hasClass("redactor-unlink")&&i.replaceWith(function(){return g(this).contents()}),this.caret.after(r),this.core.callback("insertedLink",r)):(r=this.link.update(r,t),this.caret.after(r)),r)},update:function(t,e){return t.text(e.text),t.attr("href",e.url),this.link.target(t,e.target),t},target:function(t,e){return e?t.attr("target","_blank"):t.removeAttr("target")},show:function(t){void 0!==t&&t.preventDefault&&t.preventDefault(),this.observe.closeAllTooltip();var e=this.link.is();this.link.buildModal(e);var i=this.link.buildLinkFromElement(e);i.url=this.link.removeSelfHostFromUrl(i.url),this.opts.linkNewTab&&!e&&(i.target=!0),this.link.setModalValues(i),this.modal.show(),this.detect.isDesktop()&&g("#redactor-link-url").focus()},setModalValues:function(t){g("#redactor-link-blank").prop("checked",t.target),g("#redactor-link-url").val(t.url),g("#redactor-link-url-text").val(t.text)},buildModal:function(t){this.modal.load("link",this.lang.get(!1===t?"link-insert":"link-edit"),600),this.modal.getActionButton().text(this.lang.get(!1===t?"insert":"save")).on("click",g.proxy(this.link.callback,this))},callback:function(){var t=this.link.buildLinkFromModal();if(!1===t)return!1;this.modal.close(),this.link.insert(t,!0)},cleanUrl:function(t){return void 0===t?"":g.trim(t.replace(/[^\W\w\D\d+&\'@#/%?=~_|!:,.;\(\)]/gi,""))},cleanText:function(t){return void 0===t?"":g.trim(t.replace(/(<([^>]+)>)/gi,""))},getText:function(t){return""===t.text&&""!==t.url?this.link.truncateUrl(t.url.replace(/<|>/g,"")):t.text},isUrl:function(t){return!!new RegExp("^((https?|ftp):\\/\\/)?(([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(t)&&t},isMailto:function(t){return-1!==t.search("@")&&!1===/(http|ftp|https):\/\//i.test(t)},isEmpty:function(t){return""===t.url||""===t.text&&""===t.url},truncateUrl:function(t){return t.length>this.opts.linkSize?t.substring(0,this.opts.linkSize)+"...":t},parse:function(t){return this.link.isMailto(t.url)?t.url="mailto:"+t.url.replace("mailto:",""):0!==t.url.search("#")&&this.opts.linkValidation&&(t.url=this.link.isUrl(t.url)?"http://"+t.url.replace(/(ftp|https?):\/\//gi,""):t.url),!this.link.isEmpty(t)&&!1!==t.url&&t},buildLinkFromModal:function(){var t={};return t.url=this.link.cleanUrl(g("#redactor-link-url").val()),t.text=this.link.cleanText(g("#redactor-link-url-text").val()),t.text=this.link.getText(t),t.target=!!g("#redactor-link-blank").prop("checked"),this.link.parse(t)},buildLinkFromObject:function(t,e){return e.url=this.link.cleanUrl(e.url),e.text=void 0===e.text&&this.selection.is()?this.selection.text():this.link.cleanText(e.text),e.text=this.link.getText(e),e.target=!1===t?e.target:this.link.buildTarget(t),this.link.parse(e)},buildLinkFromElement:function(t){var e={url:"",text:this.selection.is()?this.selection.text():"",target:!1};return!1!==t&&(e.url=t.attr("href"),e.text=t.text(),e.target=this.link.buildTarget(t)),e},buildTarget:function(t){return void 0!==t.attr("target")&&"_blank"===t.attr("target")},removeSelfHostFromUrl:function(t){var e=self.location.href.replace("#","").replace(/\/$/i,"");return t.replace(/^\/\#/,"#").replace(e,"").replace("mailto:","")},replaceLinksToText:function(t){var n,e=g.each(t,function(t,e){var i=g(e),r=g('<span class="redactor-unlink" />').append(i.contents());return i.replaceWith(r),0===t&&(n=r),i});return 1===t.length&&this.selection.isCollapsed()&&this.caret.after(n),e}}},linkify:function(){return{isKey:function(){},isLink:function(){},isFiltered:function(){},handler:function(){},format:function(){},convertVideoLinks:function(){},convertImages:function(){},convertLinks:function(){}}},list:function(){return{toggle:function(t){if(!this.utils.inBlocks(["table","td","th","tr"])){t=(t="unorderedlist"===(t="orderedlist"===t?"ol":t)?"ul":t).toLowerCase(),this.buffer.set(),this.selection.save();var e=this.list._getBlocks(),i=this.selection.block(),r=g(i).parents("ul, ol").last();return 0===e.length&&0!==r.length&&(e=[r.get(0)]),e=this.list._isUnformat(t,e)?this.list._unformat(t,e):this.list._format(t,e),this.selection.restore(),e}},get:function(){var t=this.selection.current(),e=g(t).closest("ul, ol",this.core.editor()[0]);return 0!==e.length&&e},combineAfterAndBefore:function(t){var e=g(t).prev(),i=g(t).next(),r=t&&"P"===t.tagName&&("<br>"===t.innerHTML||""===t.innerHTML),n=1===e.closest("ol, ul",this.core.editor()[0]).length&&1===i.closest("ol, ul",this.core.editor()[0]).length;return!(!r||!n)&&(e.children("li").last().append(this.marker.get()),e.append(i.contents()),this.selection.restore(),!0)},_getBlocks:function(){for(var t=[],e=this.selection.blocks(),i=0;i<e.length;i++){g(e[i]).parent().hasClass("redactor-in")&&t.push(e[i])}return t},_isUnformat:function(t,e){for(var i,r=0,n=0;n<e.length;n++){3!==e[n].nodeType&&((i=e[n].tagName.toLowerCase())!==t&&"figure"!==i||r++)}return r===e.length},_uniteBlocks:function(t,e){for(var i=0,r={0:[]},n=!1,s=0;s<t.length;s++){var o=g(t[s]).closest("th, td");0!==o.length?(o.get(0)!==n&&(r[++i]=[]),this.list._isUniteBlock(t[s],e)&&r[i].push(t[s])):this.list._isUniteBlock(t[s],e)?r[i].push(t[s]):r[++i]=[],n=o.get()}return r},_isUniteBlock:function(t,e){return 3===t.nodeType||-1!==e.indexOf(t.tagName.toLowerCase())},_createList:function(t,e,i){var r=e[e.length-1],n=g(r),s=g("<"+t+">");return n.after(s),s},_createListItem:function(t){var e,i=g("<li>");return 3===t.nodeType?i.append(t):(e=g(t),i.append(e.contents()),e.remove()),i},_format:function(t,e){var i=this.list._uniteBlocks(e,["p","div","blockquote","pre","h1","h2","h3","h4","h5","h6","ul","ol"]),r=[];for(var n in i){for(var s=i[n],o=this.list._createList(t,i[n]),a=0;a<s.length;a++){var l=3===s[a].nodeType||"UL"!==s[a].tagName&&"OL"!==s[a].tagName?this.list._createListItem(s[a]):g(s[a]).contents();o.append(l)}r.push(o.get(0))}return r},_unformat:function(t,e){if(1===e.length){var i=g(e[0]),r=i.find("li"),n=this.selection.blocks(["li"]),s=this.selection.block(),o=g(s).closest("li");if(0===n.length&&0!==o.length&&(n=[o.get(0)]),n.length===r.length)return this.list._unformatEntire(e[0]);var a=this.list._getItemsPosition(r,n);if("Top"===a)return this.list._unformatAtSide("before",n,i);if("Bottom"===a)return n.reverse(),this.list._unformatAtSide("after",n,i);if("Middle"===a){var l=g(n[n.length-1]),c=!1,h=!1,d=g("<"+i.get(0).tagName.toLowerCase()+">");r.each(function(t,e){var i;c&&((i=g(e)).children("ul, ol").length,0!==i.closest(".redactor-split-item").length||!1!==h&&0!==i.closest(h).length||i.addClass("redactor-split-item"),h=i),e===l.get(0)&&(c=!0)}),r.filter(".redactor-split-item").each(function(t,e){g(e).removeClass("redactor-split-item"),d.append(e)}),i.after(d),n.reverse();for(var u=0;u<n.length;u++){var p=g(n[u]),f=this.list._createUnformatContainer(p);i.after(f),f.find("ul, ol").remove(),p.remove()}return}}else for(u=0;u<e.length;u++)3!==e[u].nodeType&&e[u].tagName.toLowerCase()===t&&this.list._unformatEntire(e[u])},_unformatEntire:function(t){var n=g(t);n.find("li").each(function(t,e){var i=g(e),r=this.list._createUnformatContainer(i);i.remove(),n.before(r)}.bind(this)),n.remove()},_unformatAtSide:function(t,n,e){for(var i=0;i<n.length;i++){var r=g(n[i]),s=this.list._createUnformatContainer(r);e[t](s);var o=s.find("ul, ol").first();r.append(o),o.each(function(t,e){var i=g(e),r=i.closest("li");r.get(0)===n[t]&&(i.unwrap(),r.addClass("r-unwrapped"))}),this.utils.isEmpty(r.html())&&r.remove()}e.find(".r-unwrapped").each(function(t){var e=g(t);""===e.html().trim()?e.remove():e.removeClass("r-unwrapped")})},_getItemsPosition:function(t,e){var i="Middle",r=e[0],n=e[e.length-1],s=t.first().get(0),o=t.last().get(0);return s===r&&o!==n?i="Top":s!==r&&o===n&&(i="Bottom"),i},_createUnformatContainer:function(t){var e=g("<p>");return e.append(t.contents()),e}}},marker:function(){return{get:function(t){t=void 0===t?1:t;var e=document.createElement("span");return e.id="selection-marker-"+t,e.className="redactor-selection-marker",e.innerHTML=this.opts.invisibleSpace,e},html:function(t){return this.utils.getOuterHtml(this.marker.get(t))},find:function(t){return t=void 0===t?1:t,this.core.editor().find("span#selection-marker-"+t)},insert:function(){var t=this.selection.get(),e=this.selection.range(t);this.marker.insertNode(e,this.marker.get(1),!0),e&&!1===e.collapsed&&this.marker.insertNode(e,this.marker.get(2),!1)},remove:function(){this.core.editor().find(".redactor-selection-marker").each(this.marker.iterateRemove)},insertNode:function(t,e,i){var r=this.selection.parent();if(null!==t&&0!==g(r).closest(".redactor-in").length){t=t.cloneRange();try{t.collapse(i),t.insertNode(e)}catch(t){this.focus.start()}}},iterateRemove:function(t,e){var i=g(e),r=i.text().replace(/\u200B/g,"");i.parent()[0];""===r?i.remove():i.replaceWith(function(){return g(this).contents()})}}},modal:function(){return{callbacks:{},templates:function(){this.opts.modal={"image-edit":"",image:"",file:"",link:String()+'<div class="redactor-modal-tab" data-title="General"><section><label>URL</label><input type="url" id="redactor-link-url" aria-label="URL" /></section><section><label>'+this.lang.get("text")+'</label><input type="text" id="redactor-link-url-text" aria-label="'+this.lang.get("text")+'" /></section><section><label class="checkbox"><input type="checkbox" id="redactor-link-blank"> '+this.lang.get("link-in-new-tab")+'</label></section><section><button id="redactor-modal-button-action">'+this.lang.get("insert")+'</button><button id="redactor-modal-button-cancel">'+this.lang.get("cancel")+"</button></section></div>"},g.extend(this.opts,this.opts.modal)},addCallback:function(t,e){this.modal.callbacks[t]=e},addTemplate:function(t,e){this.opts.modal[t]=e},getTemplate:function(t){return this.opts.modal[t]},getModal:function(){return this.$modalBody},getActionButton:function(){return this.$modalBody.find("#redactor-modal-button-action")},getCancelButton:function(){return this.$modalBody.find("#redactor-modal-button-cancel")},getDeleteButton:function(){return this.$modalBody.find("#redactor-modal-button-delete")},load:function(){},show:function(){},buildWidth:function(){},buildTabber:function(){},showTab:function(){},setTitle:function(){},setContent:function(){this.$modalBody.html(this.modal.getTemplate(this.modal.templateName)),this.modal.getCancelButton().on("mousedown",g.proxy(this.modal.close,this))},setDraggable:function(){},setEnter:function(){},build:function(){this.modal.buildOverlay(),this.$modalBox=g('<div id="redactor-modal-box"/>').hide(),this.$modal=g('<div id="redactor-modal" role="dialog" />'),this.$modalHeader=g('<div id="redactor-modal-header" />'),this.$modalClose=g('<button type="button" id="redactor-modal-close" aria-label="'+this.lang.get("close")+'" />').html("&times;"),this.$modalBody=g('<div id="redactor-modal-body" />'),this.$modal.append(this.$modalHeader),this.$modal.append(this.$modalBody),this.$modal.append(this.$modalClose),this.$modalBox.append(this.$modal),this.$modalBox.appendTo(document.body)},buildOverlay:function(){this.$modalOverlay=g('<div id="redactor-modal-overlay">').hide(),g("body").prepend(this.$modalOverlay)},enableEvents:function(){},disableEvents:function(){},closeHandler:function(){},close:function(){}}},observe:function(){return{load:function(){void 0===this.opts.destroyed&&(this.observe.links(),this.observe.images())},isCurrent:function(t,e){return void 0===e&&(e=g(this.selection.current())),e.is(t)||0<e.parents(t).length},toolbar:function(){this.observe.buttons(),this.observe.dropdowns()},buttons:function(t,e){var n=this.selection.current(),s=this.selection.parent();!1!==t?this.button.setInactiveAll():this.button.setInactiveAll(e),!1!==t||"html"===e?this.utils.isRedactorParent(n)&&("none"!==this.core.editor().css("display")&&(this.utils.isCurrentOrParentHeader()||this.utils.isCurrentOrParent(["table","pre","blockquote","li"])?this.button.disable("horizontalrule"):this.button.enable("horizontalrule")),g.each(this.opts.activeButtonsStates,g.proxy(function(t,e){var i=g(s).closest(t,this.$editor[0]),r=g(n).closest(t,this.$editor[0]);(0===i.length||this.utils.isRedactorParent(i))&&this.utils.isRedactorParent(r)&&(0===i.length&&0===r.closest(t,this.$editor[0]).length||this.button.setActive(e))},this))):-1!==g.inArray(e,this.opts.activeButtons)&&this.button.toggleActive(e)},dropdowns:function(){var a=g("<div />").html(this.selection.html()).find("a").length,l=g(this.selection.current()),c=this.utils.isRedactorParent(l);g.each(this.opts.observe.dropdowns,g.proxy(function(t,e){var i=e.observe,r=i.element,n=e.item,s=void 0!==i.in&&i.in,o=void 0!==i.out&&i.out;0<l.closest(r).length&&c||"a"===r&&0!==a?this.observe.setDropdownProperties(n,s,o):this.observe.setDropdownProperties(n,o,s)},this))},setDropdownProperties:function(t,e,i){i&&void 0!==i.attr&&this.observe.setDropdownAttr(t,i.attr,!0),void 0!==e.attr&&this.observe.setDropdownAttr(t,e.attr),void 0!==e.title&&t.find("span").text(e.title)},setDropdownAttr:function(i,t,r){g.each(t,function(t,e){"class"===t?r?i.removeClass(e):i.addClass(e):r?i.removeAttr(t):i.attr(t,e)})},addDropdown:function(t,e,i){void 0!==i.observe&&(i.item=t,this.opts.observe.dropdowns.push(i))},images:function(){this.opts.imageEditable&&(this.core.editor().addClass("redactor-layer-img-edit"),this.core.editor().find("img").each(g.proxy(function(t,e){var i=g(e);i.closest("a",this.$editor[0]).on("click",function(t){t.preventDefault()}),this.image.setEditable(i)},this)))},links:function(){this.opts.linkTooltip&&this.core.editor().find("a").each(g.proxy(function(t,e){var i=g(e);!0!==i.data("cached")&&(i.data("cached",!0),i.on("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,g.proxy(this.observe.showTooltip,this)))},this))},getTooltipPosition:function(t){return t.offset()},showTooltip:function(t){var e,i,r,n,s,o,a,l,c,h,d=g(t.target);"IMG"!==d[0].tagName&&("A"!==d[0].tagName&&(d=d.closest("a",this.$editor[0])),"A"===d[0].tagName&&(e=d,i=this.observe.getTooltipPosition(e),r=g('<span class="redactor-link-tooltip"></span>'),void 0===(n=e.attr("href"))&&(n=""),24<n.length&&(n=n.substring(0,24)+"..."),s=g('<a href="'+e.attr("href")+'" target="_blank" />').html(n).addClass("redactor-link-tooltip-action"),o=g('<a href="#" />').html(this.lang.get("edit")).on("click",g.proxy(this.link.show,this)).addClass("redactor-link-tooltip-action"),a=g('<a href="#" />').html(this.lang.get("unlink")).on("click",g.proxy(this.link.unlink,this)).addClass("redactor-link-tooltip-action"),r.append(s).append(" | ").append(o).append(" | ").append(a),l=parseInt(e.css("line-height"),10),c=Math.ceil((t.pageY-i.top)/l),h=i.top+c*l,r.css({top:h+"px",left:i.left+"px"}),g(".redactor-link-tooltip").remove(),g("body").append(r),this.core.editor().on("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,g.proxy(this.observe.closeTooltip,this)),g(document).on("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,g.proxy(this.observe.closeTooltip,this))))},closeAllTooltip:function(){g(".redactor-link-tooltip").remove()},closeTooltip:function(t){var e=(t=t.originalEvent||t).target,i=g(e).closest("a",this.$editor[0]);0!==i.length&&"A"===i[0].tagName&&"A"!==e.tagName||"A"===e.tagName&&this.utils.isRedactorParent(e)||g(e).hasClass("redactor-link-tooltip-action")||(this.observe.closeAllTooltip(),this.core.editor().off("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,g.proxy(this.observe.closeTooltip,this)),g(document).off("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,g.proxy(this.observe.closeTooltip,this)))}}},offset:function(){return{get:function(t){var e=this.offset.clone(t);if(!1===e)return 0;var i=document.createElement("div");return i.appendChild(e.cloneContents()),i.innerHTML=i.innerHTML.replace(/<img(.*?[^>])>$/gi,"i"),g.trim(g(i).text()).replace(/[\t\n\r\n]/g,"").replace(/\u200B/g,"").length},clone:function(t){var e=this.selection.get(),i=this.selection.range(e);if(null===i&&void 0===t)return!1;if(!1===(t=void 0===t?this.$editor:t))return!1;t=t[0]||t;var r=i.cloneRange();return r.selectNodeContents(t),r.setEnd(i.endContainer,i.endOffset),r},set:function(t,e){e=void 0===e?t:e,this.focus.is()||this.focus.start();for(var i,r=this.selection.get(),n=this.selection.range(r),s=0,o=document.createTreeWalker(this.$editor[0],NodeFilter.SHOW_TEXT,null,null);null!==(i=o.nextNode());)if(t<(s+=i.nodeValue.length)&&(n.setStart(i,i.nodeValue.length+t-s),t=1/0),e<=s){n.setEnd(i,i.nodeValue.length+e-s);break}n.collapse(!1),this.selection.update(r,n)}}},paragraphize:function(){return{load:function(t){return!1===this.opts.paragraphize||"inline"===this.opts.type||"pre"===this.opts.type?t:""===t||"<p></p>"===t?this.opts.emptyHtml:(t+="\n",this.paragraphize.safes=[],this.paragraphize.z=0,t=(t=(t=t.replace(/(<br\s?\/?>){1,}\n?<\/blockquote>/gi,"</blockquote>")).replace(/<\/pre>/gi,"</pre>\n\n")).replace(/<p>\s<br><\/p>/gi,"<p></p>"),t=(t=this.paragraphize.getSafes(t)).replace("<br>","\n"),t=this.paragraphize.convert(t),t=this.paragraphize.clear(t),t=(t=this.paragraphize.restoreSafes(t)).replace(new RegExp("<br\\s?/?>\n?<("+this.opts.paragraphizeBlocks.join("|")+")(.*?[^>])>","gi"),"<p><br /></p>\n<$1$2>"),g.trim(t))},getSafes:function(t){var e=g("<div />").append(t);return e.find("blockquote p").replaceWith(function(){return g(this).append("<br />").contents()}),e.find(this.opts.paragraphizeBlocks.join(", ")).each(g.proxy(function(t,e){return this.paragraphize.z++,this.paragraphize.safes[this.paragraphize.z]=e.outerHTML,g(e).replaceWith("\n#####replace"+this.paragraphize.z+"#####\n\n")},this)),e.find("span.redactor-selection-marker").each(g.proxy(function(t,e){return this.paragraphize.z++,this.paragraphize.safes[this.paragraphize.z]=e.outerHTML,g(e).replaceWith("\n#####replace"+this.paragraphize.z+"#####\n\n")},this)),e.html()},restoreSafes:function(i){return g.each(this.paragraphize.safes,function(t,e){e=void 0!==e?e.replace(/\$/g,"&#36;"):e,i=i.replace("#####replace"+t+"#####",e)}),i},convert:function(t){t=(t=(t=(t=t.replace(/\r\n/g,"xparagraphmarkerz")).replace(/\n/g,"xparagraphmarkerz")).replace(/\r/g,"xparagraphmarkerz")).replace(/\s+/g," ");return t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t="<p>"+(t=(t=(t=g.trim(t)).replace(/xparagraphmarkerzxparagraphmarkerz/gi,"</p><p>")).replace(/xparagraphmarkerz/gi,"<br>"))+"</p>").replace("<p></p>","")).replace("\r\n\r\n","")).replace(/<\/p><p>/g,"</p>\r\n\r\n<p>")).replace(new RegExp("<br\\s?/?></p>","g"),"</p>")).replace(new RegExp("<p><br\\s?/?>","g"),"<p>")).replace(new RegExp("<p><br\\s?/?>","g"),"<p>")).replace(new RegExp("<br\\s?/?></p>","g"),"</p>")).replace(/<p>&nbsp;<\/p>/gi,"")).replace(/<p>\s?<br>&nbsp;<\/p>/gi,"")).replace(/<p>\s?<br>/gi,"<p>")},clear:function(t){return t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/<p>(.*?)#####replace(.*?)#####\s?<\/p>/gi,"<p>$1</p>#####replace$2#####")).replace(/(<br\s?\/?>){2,}<\/p>/gi,"</p>")).replace(new RegExp("</blockquote></p>","gi"),"</blockquote>")).replace(new RegExp("<p></blockquote>","gi"),"</blockquote>")).replace(new RegExp("<p><blockquote>","gi"),"<blockquote>")).replace(new RegExp("<blockquote></p>","gi"),"<blockquote>")).replace(new RegExp("<p><p ","gi"),"<p ")).replace(new RegExp("<p><p>","gi"),"<p>")).replace(new RegExp("</p></p>","gi"),"</p>")).replace(new RegExp("<p>\\s?</p>","gi"),"")).replace(new RegExp("\n</p>","gi"),"</p>")).replace(new RegExp("<p>\t?\t?\n?<p>","gi"),"<p>")).replace(new RegExp("<p>\t*</p>","gi"),"")}}},paste:function(){return{init:function(t){this.rtePaste=!0;var r=!("pre"!==this.opts.type&&!this.utils.isCurrentOrParent("pre"));this.detect.isDesktop()&&!this.paste.pre&&this.opts.clipboardImageUpload&&this.opts.imageUpload&&this.paste.detectClipboardUpload(t)?this.detect.isIe()&&setTimeout(g.proxy(this.paste.clipboardUpload,this),100):(this.utils.saveScroll(),this.selection.save(),this.paste.createPasteBox(r),g(window).on("scroll.redactor-freeze",g.proxy(function(){g(window).scrollTop(this.saveBodyScroll)},this)),setTimeout(g.proxy(function(){var t=this.paste.getPasteBoxCode(r);this.buffer.set(),this.selection.restore(),this.utils.restoreScroll();var e=this.clean.getCurrentType(t),t=this.clean.onPaste(t,e),i=this.core.callback("paste",t);t=void 0===i?t:i,this.paste.insert(t,e),this.rtePaste=!1,r&&this.clean.cleanPre(),g(window).off("scroll.redactor-freeze")},this),1))},getPasteBoxCode:function(t){var e=t?this.$pasteBox.val():this.$pasteBox.html();return this.$pasteBox.remove(),e},createPasteBox:function(t){var e={position:"fixed",width:"1px",top:0,left:"-9999px"};this.$pasteBox=t?g("<textarea>").css(e):g("<div>").attr("contenteditable","true").css(e),this.paste.appendPasteBox(),this.$pasteBox.focus()},appendPasteBox:function(){var t;this.detect.isIe()?this.core.box().append(this.$pasteBox):0<(t=g(".modal-body:visible")).length?t.append(this.$pasteBox):g("body").prepend(this.$pasteBox)},detectClipboardUpload:function(t){var e=(t=t.originalEvent||t).clipboardData;if(this.detect.isIe()||this.detect.isFirefox())return!1;if(-1!==e.types.indexOf("public.tiff"))return t.preventDefault(),!1;if(e.items&&e.items.length){var i=e.items[0].getAsFile();if(null===i)return!1;var r=new FileReader;return r.readAsDataURL(i),r.onload=g.proxy(this.paste.insertFromClipboard,this),!0}},clipboardUpload:function(){var t=this.$editor.find("img");g.each(t,g.proxy(function(t,i){var e,r;-1!==i.src.search(/^data\:image/i)&&(e=window.FormData?new FormData:null,window.FormData&&(this.upload.direct=!0,this.upload.type="image",this.upload.url=this.opts.imageUpload,this.upload.callback=g.proxy(function(t){var e;this.detect.isIe()?g(i).wrap(g("<figure />")):(e=g(i).parent(),this.utils.replaceToTag(e,"figure")),i.src=t.url,this.core.callback("imageUpload",g(i),t)},this),r=this.utils.dataURItoBlob(i.src),e.append("clipboard",1),e.append(this.opts.imageUploadParam,r),this.upload.send(e,!1),this.code.sync(),this.rtePaste=!1))},this))},insertFromClipboard:function(t){var e,i=window.FormData?new FormData:null;window.FormData&&(this.upload.direct=!0,this.upload.type="image",this.upload.url=this.opts.imageUpload,this.upload.callback=this.image.insert,e=this.utils.dataURItoBlob(t.target.result),i.append("clipboard",1),i.append(this.opts.imageUploadParam,e),this.upload.send(i,t),this.rtePaste=!1)},insert:function(t,e){e.pre?this.insert.raw(t):e.text?this.insert.text(t):this.insert.html(t,e),this.detect.isFirefox()&&this.opts.imageUpload&&this.opts.clipboardImageUpload&&setTimeout(g.proxy(this.paste.clipboardUpload,this),100)}}},placeholder:function(){return{enable:function(){},show:function(){},update:function(){},hide:function(){},is:function(){},init:function(){},enabled:function(){},enableEvents:function(){},disableEvents:function(){},build:function(){},buildPosition:function(){},getPosition:function(){},isEditorEmpty:function(){},isAttr:function(){},destroy:function(){}}},progress:function(){return{$box:null,$bar:null,target:document.body,show:function(){},hide:function(){},update:function(){},is:function(){},build:function(){},destroy:function(){}}},selection:function(){return{get:function(){return window.getSelection?window.getSelection():document.selection&&"Control"!==document.selection.type?document.selection:null},range:function(t){return void 0===t&&(t=this.selection.get()),t.getRangeAt&&t.rangeCount?t.getRangeAt(0):null},is:function(){return!this.selection.isCollapsed()},isRedactor:function(){var t=this.selection.range();if(null!==t){var e=t.startContainer.parentNode;if(g(e).hasClass("redactor-in")||0!==g(e).parents(".redactor-in").length)return!0}return!1},isCollapsed:function(){var t=this.selection.get();return null!==t&&t.isCollapsed},update:function(t,e){null!==e&&(t.removeAllRanges(),t.addRange(e))},current:function(){var t=this.selection.get();return null!==t&&t.anchorNode},parent:function(){var t=this.selection.current();return null!==t&&t.parentNode},block:function(t){for(t=t||this.selection.current();t;){if(this.utils.isBlockTag(t.tagName))return!g(t).hasClass("redactor-in")&&t;t=t.parentNode}return!1},inline:function(t){for(t=t||this.selection.current();t;){if(this.utils.isInlineTag(t.tagName))return!g(t).hasClass("redactor-in")&&t;t=t.parentNode}return!1},element:function(t){for(t=t||this.selection.current();t;){if(1===t.nodeType)return!g(t).hasClass("redactor-in")&&t;t=t.parentNode}return!1},prev:function(){return null!==this.selection.current()&&this.selection.current().previousSibling},next:function(){return null!==this.selection.current()&&this.selection.current().nextSibling},blocks:function(t){var i=[],e=this.selection.nodes(t);g.each(e,g.proxy(function(t,e){this.utils.isBlock(e)&&i.push(e)},this));var r=this.selection.block();return 0===i.length&&!1===r?[]:0===i.length&&!1!==r?[r]:i},inlines:function(t){var i=[],e=this.selection.nodes(t);g.each(e,g.proxy(function(t,e){this.utils.isInline(e)&&i.push(e)},this));var r=this.selection.inline();return 0===i.length&&!1===r?[]:0===i.length&&!1!==r?[r]:i},nodes:function(t){var r=void 0===t?[]:g.isArray(t)?t:[t],e=this.selection.get(),i=this.selection.range(e),n=[],s=[];if(this.utils.isCollapsed())n=[this.selection.current()];else{var o=i.startContainer,a=i.endContainer;if(o===a)return[o];for(;o&&o!==a;)n.push(o=this.selection.nextNode(o));for(o=i.startContainer;o&&o!==i.commonAncestorContainer;)n.unshift(o),o=o.parentNode}return g.each(n,function(t,e){if(e){var i=1===e.nodeType&&e.tagName.toLowerCase();if(g(e).hasClass("redactor-script-tag")||g(e).hasClass("redactor-selection-marker"))return;if(i&&0!==r.length&&-1===g.inArray(i,r))return;s.push(e)}}),0===s.length?[]:s},nextNode:function(t){if(t.hasChildNodes())return t.firstChild;for(;t&&!t.nextSibling;)t=t.parentNode;return t?t.nextSibling:null},save:function(){this.marker.insert(),this.savedSel=this.core.editor().html()},restore:function(t){var e=this.marker.find(1),i=this.marker.find(2);this.detect.isFirefox()&&this.core.editor().focus(),0!==e.length&&0!==i.length?this.caret.set(e,i):0!==e.length?this.caret.start(e):this.core.editor().focus(),!1!==t&&(this.marker.remove(),this.savedSel=!1)},saveInstant:function(){var t=this.core.editor()[0],e=t.ownerDocument.defaultView.getSelection();if(e.getRangeAt&&e.rangeCount){var i=e.getRangeAt(0),r=i.cloneRange();r.selectNodeContents(t),r.setEnd(i.startContainer,i.startOffset);var n=r.toString().length;return this.saved={start:n,end:n+i.toString().length,node:i.startContainer},this.saved}},restoreInstant:function(t){if(void 0!==t||this.saved){this.saved=void 0!==t?t:this.saved;var e=this.core.editor().find(this.saved.node);if(0===e.length||0!==e.text().trim().replace(/\u200B/g,"").length){var i,r=this.core.editor()[0],n=r.ownerDocument,s=n.defaultView,o=0;(i=n.createRange()).setStart(r,0),i.collapse(!0);for(var a,l,c=[r],h=!1,d=!1;!d&&(a=c.pop());)if(3==a.nodeType){var u=o+a.length;!h&&this.saved.start>=o&&this.saved.start<=u&&(i.setStart(a,this.saved.start-o),h=!0),h&&this.saved.end>=o&&this.saved.end<=u&&(i.setEnd(a,this.saved.end-o),d=!0),o=u}else for(var p=a.childNodes.length;p--;)c.push(a.childNodes[p]);(l=s.getSelection()).removeAllRanges(),l.addRange(i)}else try{(i=document.createRange()).setStart(e[0],0),(l=window.getSelection()).removeAllRanges(),l.addRange(i)}catch(t){}}},node:function(t){g(t).prepend(this.marker.get(1)),g(t).append(this.marker.get(2)),this.selection.restore()},all:function(){this.core.editor().focus();var t=this.selection.get(),e=this.selection.range(t);e.selectNodeContents(this.core.editor()[0]),this.selection.update(t,e)},remove:function(){this.selection.get().removeAllRanges()},replace:function(t){this.insert.html(t)},text:function(){return this.selection.get().toString()},html:function(){var t="",e=this.selection.get();if(e.rangeCount){for(var i=document.createElement("div"),r=e.rangeCount,n=0;n<r;++n)i.appendChild(e.getRangeAt(n).cloneContents());t=this.clean.onGet(i.innerHTML)}return t},extractEndOfNode:function(t){var e=this.selection.get(),i=this.selection.range(e),r=i.cloneRange();return r.selectNodeContents(t),r.setStart(i.endContainer,i.endOffset),r.extractContents()},removeMarkers:function(){this.marker.remove()},marker:function(t){return this.marker.get(t)},markerHtml:function(t){return this.marker.html(t)}}},shortcuts:function(){return{hotkeysSpecialKeys:{8:"backspace",9:"tab",10:"return",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",59:";",61:"=",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},hotkeysShiftNums:{"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"},init:function(i,t){if(!1===this.opts.shortcuts)return!i.ctrlKey&&!i.metaKey||66!==t&&73!==t||i.preventDefault(),!1;g.each(this.opts.shortcuts,g.proxy(function(t,e){this.shortcuts.build(i,t,e)},this))},build:function(t,e,i){for(var r=g.proxy(function(){this.shortcuts.buildHandler(i)},this),n=e.split(","),s=n.length,o=0;o<s;o++)"string"==typeof n[o]&&this.shortcuts.handler(t,g.trim(n[o]),r)},buildHandler:function(t){var e;"-1"!==t.func.search(/\./)?void 0!==this[(e=t.func.split("."))[0]]&&this[e[0]][e[1]].apply(this,t.params):this[t.func].apply(this,t.params)},handler:function(i,t,e){t=t.toLowerCase().split(" ");var r=this.shortcuts.hotkeysSpecialKeys[i.keyCode],n=String.fromCharCode(i.which).toLowerCase(),s="",o={};g.each(["alt","ctrl","meta","shift"],function(t,e){i[e+"Key"]&&r!==e&&(s+=e+"+")}),r&&(o[s+r]=!0),n&&(o[s+n]=!0,o[s+this.shortcuts.hotkeysShiftNums[n]]=!0,"shift+"===s&&(o[this.shortcuts.hotkeysShiftNums[n]]=!0));for(var a=t.length,l=0;l<a;l++)if(o[t[l]])return i.preventDefault(),e.apply(this,arguments)}}},storage:function(){return{data:[],add:function(){},status:function(){},observe:function(){},changes:function(){}}},toolbar:function(){return{build:function(){this.button.hideButtons(),this.button.hideButtonsOnMobile(),this.$toolbarBox=g('<div class="redactor-toolbar-box" />'),this.$toolbarBox[0].innerHTML='<ul class="redactor-toolbar" id="redactor-toolbar-'+this.uuid+'" role="toolbar"></ul>',this.$toolbar=g(this.$toolbarBox[0].children[0]),this.$box[0].insertBefore(this.$toolbarBox[0],this.$box[0].firstChild),this.button.$toolbar=this.$toolbar,this.button.setFormatting(),this.button.load(this.$toolbar),require(["Core"],function(t){this.$toolbar[0].addEventListener("keydown",this.toolbar.keydown.bind(this,t))}.bind(this))},createContainer:function(){},append:function(){},setOverflow:function(){},setFixed:function(){},setUnfixed:function(){},getBoxTop:function(){},observeScroll:function(){},observeScrollResize:function(){},observeScrollEnable:function(){},observeScrollDisable:function(){},setDropdownsFixed:function(){},unsetDropdownsFixed:function(){},setDropdownPosition:function(){},keydown:function(t,e){var i=document.activeElement;if(i.classList.contains("re-button")){if(-1!==[13,32,35,36,37,39,40].indexOf(e.which)){if(13===e.which||32===e.which)return e.preventDefault(),void require(["Core"],function(t){t.triggerEvent(i,"mousedown")});if(40!==e.which){e.preventDefault();var r,n=Array.prototype.slice.call(elBySelAll(".re-button",this.$toolbar[0])),s=null;null!==(s=35===e.which?n[n.length-1]:36===e.which?n[0]:(r=n.indexOf(i),37===e.which?-1===--r&&(r=n.length-1):39===e.which&&++r===n.length&&(r=0),n[r]))&&s.focus()}else{if("true"!==elAttr(i,"aria-haspopup"))return;e.preventDefault(),t.triggerEvent(i,"mousedown");var o=g(i).data("dropdown"),a=elBySel("li",o[0]);a&&a.focus()}}}}}},upload:function(){return{init:function(){},directUpload:function(){},onDrop:function(){},traverseFile:function(){},setConfig:function(){},getType:function(){},getHiddenFields:function(){},send:function(){},onDrag:function(){},onDragLeave:function(){},clearImageFields:function(){},addImageFields:function(){},removeImageFields:function(){},clearFileFields:function(){},addFileFields:function(){},removeFileFields:function(){}}},uploads3:function(){return{send:function(){},executeOnSignedUrl:function(){},createCORSRequest:function(){},sendToS3:function(){}}},utils:function(){return{isEmpty:function(t){return t=(t=(t=(t=(t=(t=(t=(t=(t=(t=void 0===t?this.core.editor().html():t).replace(/[\u200B-\u200D\uFEFF]/g,"")).replace(/&nbsp;/gi,"")).replace(/<\/?br\s?\/?>/g,"")).replace(/\s/g,"")).replace(/^<p>[^\W\w\D\d]*?<\/p>$/i,"")).replace(/<iframe(.*?[^>])>$/i,"iframe")).replace(/<source(.*?[^>])>$/i,"source")).replace(/<[^\/>][^>]*><\/[^>]+>/gi,"")).replace(/<[^\/>][^>]*><\/[^>]+>/gi,""),""===(t=g.trim(t))},isElement:function(e){try{return e instanceof HTMLElement}catch(t){return"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument}},strpos:function(t,e,i){var r=t.indexOf(e,i);return 0<=r&&r},dataURItoBlob:function(t){for(var e=(0<=t.split(",")[0].indexOf("base64")?atob:unescape)(t.split(",")[1]),i=t.split(",")[0].split(":")[1].split(";")[0],r=new Uint8Array(e.length),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return new Blob([r],{type:i})},getOuterHtml:function(t){return g("<div>").append(g(t).eq(0).clone()).html()},cloneAttributes:function(t,e){t=t[0]||t,e=g(e);for(var i=t.attributes,r=i.length;r--;){var n=i[r];e.attr(n.name,n.value)}return e},breakBlockTag:function(){var t=this.selection.block();if(!t)return!1;var e=this.utils.isEmpty(t.innerHTML),i=t.tagName.toLowerCase();if("pre"===i||"li"===i||"td"===i||"th"===i)return!1;if(!e&&this.utils.isStartOfElement(t))return{$block:g(t),$next:g(t).next(),type:"start"};if(!e&&this.utils.isEndOfElement(t))return{$block:g(t),$next:g(t).next(),type:"end"};var r=this.selection.extractEndOfNode(t),n=g("<"+i+" />").append(r),n=this.utils.cloneAttributes(t,n);return g(t).after(n),{$block:g(t),$next:n,type:"break"}},inBlocks:function(t){t=g.isArray(t)?t:[t];for(var e,i=this.selection.blocks(),r=i.length,n=!1,s=0;s<r;s++){!1!==i[s]&&(e=i[s].tagName.toLowerCase(),-1!==g.inArray(e,t)&&(n=!0))}return n},inInlines:function(t){t=g.isArray(t)?t:[t];for(var e=this.selection.inlines(),i=e.length,r=!1,n=0;n<i;n++){var s=e[n].tagName.toLowerCase();-1!==g.inArray(s,t)&&(r=!0)}return r},isTag:function(t,e){var i=g(t).closest(e,this.core.editor()[0]);return 1===i.length&&i[0]},isBlock:function(t){return null!==t&&((t=t[0]||t)&&this.utils.isBlockTag(t.tagName))},isBlockTag:function(t){return void 0!==t&&this.reIsBlock.test(t)},isInline:function(t){return(t=t[0]||t)&&this.utils.isInlineTag(t.tagName)},isInlineTag:function(t){return void 0!==t&&this.reIsInline.test(t)},isRedactorParent:function(t){return!!t&&(0!==g(t).parents(".redactor-in").length&&!g(t).hasClass("redactor-in")&&t)},isCurrentOrParentHeader:function(){return this.utils.isCurrentOrParent(["H1","H2","H3","H4","H5","H6"])},isCurrentOrParent:function(t){var i=this.selection.parent(),r=this.selection.current();if(g.isArray(t)){var n=0;return g.each(t,g.proxy(function(t,e){this.utils.isCurrentOrParentOne(r,i,e)&&n++},this)),0!==n}return this.utils.isCurrentOrParentOne(r,i,t)},isCurrentOrParentOne:function(t,e,i){return i=i.toUpperCase(),e&&e.tagName===i?e:!(!t||t.tagName!==i)&&t},isEditorRelative:function(){var t=this.core.editor().css("position");return-1!==g.inArray(["absolute","fixed","relative"],t)},setEditorRelative:function(){this.core.editor().addClass("redactor-relative")},getScrollTarget:function(){var t=g(this.opts.scrollTarget);return 0!==t.length?t:g(document)},freezeScroll:function(){this.freezeScrollTop=this.utils.getScrollTarget().scrollTop(),this.utils.getScrollTarget().scrollTop(this.freezeScrollTop)},unfreezeScroll:function(){void 0!==this.freezeScrollTop&&this.utils.getScrollTarget().scrollTop(this.freezeScrollTop)},saveScroll:function(){this.tmpScrollTop=this.utils.getScrollTarget().scrollTop()},restoreScroll:function(){void 0!==this.tmpScrollTop&&this.utils.getScrollTarget().scrollTop(this.tmpScrollTop)},isStartOfElement:function(t){return!(void 0===t&&!(t=this.selection.block()))&&0===this.offset.get(t)},isEndOfElement:function(t){if(void 0===t&&!(t=this.selection.block()))return!1;var e=g.trim(g(t).text()).replace(/[\t\n\r\n]/g,"").replace(/\u200B/g,"");return this.offset.get(t)===e.length},removeEmptyAttr:function(t,e){var i=g(t);return void 0===i.attr(e)||""===i.attr(e)&&(i.removeAttr(e),!0)},replaceToTag:function(t,e){var i;return g(t).replaceWith(function(){i=g("<"+e+" />").append(g(this).contents());for(var t=0;t<this.attributes.length;t++)i.attr(this.attributes[t].name,this.attributes[t].value);return i}),i},isSelectAll:function(){return this.selectAll},enableSelectAll:function(){this.selectAll=!0},disableSelectAll:function(){this.selectAll=!1},disableBodyScroll:function(){},measureScrollbar:function(){var t=g("body"),e=document.createElement("div");e.className="redactor-scrollbar-measure",t.append(e);var i=e.offsetWidth-e.clientWidth;return t[0].removeChild(e),i},enableBodyScroll:function(){},appendFields:function(t,i){if(!t)return i;if("object"==typeof t)return g.each(t,function(t,e){null!==e&&0===e.toString().indexOf("#")&&(e=g(e).val()),i.append(t,e)}),i;var e=g(t);if(0===e.length)return i;return e.each(function(){i.append(g(this).attr("name"),g(this).val())}),i},appendForms:function(t,i){if(!t)return i;var e=g(t);if(0===e.length)return i;var r=e.serializeArray();return g.each(r,function(t,e){i.append(e.name,e.value)}),i},isRgb:function(t){return 0===t.search(/^rgb/i)},rgb2hex:function(t){return(t=t.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&4===t.length?"#"+("0"+parseInt(t[1],10).toString(16)).slice(-2)+("0"+parseInt(t[2],10).toString(16)).slice(-2)+("0"+parseInt(t[3],10).toString(16)).slice(-2):""},isCollapsed:function(){return this.selection.isCollapsed()},isMobile:function(){return this.detect.isMobile()},isDesktop:function(){return this.detect.isDesktop()},isPad:function(){return this.detect.isIpad()}}},browser:function(){return{webkit:function(){return this.detect.isWebkit()},ff:function(){return this.detect.isFirefox()},ie:function(){return this.detect.isIe()}}}},g(window).on("load.tools.redactor",function(){g('[data-tools="redactor"]').redactor()}),l.prototype.init.prototype=l.prototype}(jQuery),function(s){function r(t,e,i,r){var n={duration:.5,iterate:1,delay:0,prefix:"redactor-",timing:"linear"};this.animation=e,this.slide="slideDown"===this.animation||"slideUp"===this.animation,this.$element=s(t),this.prefixes=["","-moz-","-o-animation-","-webkit-"],this.queue=[],"function"==typeof i?(r=i,this.opts=n):this.opts=s.extend(n,i),this.slide&&this.$element.height(this.$element.height()),this.init(r)}s.fn.redactorAnimation=function(t,e,i){return this.each(function(){new r(this,t,e,i)})},r.prototype={init:function(t){this.queue.push(this.animation),this.clean(),"show"===this.animation?(this.opts.timing="linear",this.$element.removeClass("hide").show(),"function"==typeof t&&t(this)):"hide"===this.animation?(this.opts.timing="linear",this.$element.hide(),"function"==typeof t&&t(this)):this.animate(t)},animate:function(t){this.$element.addClass("redactor-animated").css("display","").removeClass("hide"),this.$element.addClass(this.opts.prefix+this.queue[0]),this.set(this.opts.duration+"s",this.opts.delay+"s",this.opts.iterate,this.opts.timing);var e=1<this.queue.length?null:t;this.complete("AnimationEnd",s.proxy(function(){this.$element.hasClass(this.opts.prefix+this.queue[0])&&(this.clean(),this.queue.shift(),this.queue.length&&this.animate(t))},this),e)},set:function(t,e,i,r){for(var n=this.prefixes.length;n--;)this.$element.css(this.prefixes[n]+"animation-duration",t),this.$element.css(this.prefixes[n]+"animation-delay",e),this.$element.css(this.prefixes[n]+"animation-iteration-count",i),this.$element.css(this.prefixes[n]+"animation-timing-function",r)},clean:function(){this.$element.removeClass("redactor-animated"),this.$element.removeClass(this.opts.prefix+this.queue[0]),this.set("","","","")},complete:function(t,e,i){this.$element.one(t.toLowerCase()+" webkit"+t+" o"+t+" MS"+t,s.proxy(function(){"function"==typeof e&&e(),"function"==typeof i&&i(this);-1!==s.inArray(this.animation,["fadeOut","slideUp","zoomOut","slideOutUp","slideOutRight","slideOutLeft"])&&this.$element.css("display","none"),this.slide&&this.$element.css("height","")},this))}}}(jQuery); })(this);
+(function (window, undefined) { !function(m){"use strict";Function.prototype.bind||(Function.prototype.bind=function(t){var e=this;return function(){return e.apply(t)}});var i=0,h=null;function l(t,e){return new l.prototype.init(t,e)}"function"==typeof window.require&&require(["Environment"],function(t){h=t}),m.fn.redactor=function(n){var r=[],s=Array.prototype.slice.call(arguments,1);return"string"==typeof n?this.each(function(){var t,e,i=m.data(this,"redactor");"-1"!==n.search(/\./)?void 0!==i[(t=n.split("."))[0]]&&(t=i[t[0]][t[1]]):t=i[n],void 0!==i&&m.isFunction(t)?void 0!==(e=t.apply(i,s))&&e!==i&&r.push(e):m.error('No such method "'+n+'" for Redactor')}):this.each(function(){m.data(this,"redactor",{}),m.data(this,"redactor",l(this,n))}),0===r.length?this:1===r.length?r[0]:r},m.Redactor=l,m.Redactor.VERSION="2.99",m.Redactor.modules=["air","autosave","block","buffer","build","button","caret","clean","code","core","detect","dropdown","events","file","focus","image","indent","inline","insert","keydown","keyup","lang","line","link","linkify","list","marker","modal","observe","offset","paragraphize","paste","placeholder","progress","selection","shortcuts","storage","toolbar","upload","uploads3","utils","browser"],m.Redactor.settings={},m.Redactor.opts={animation:!1,lang:"en",direction:"ltr",spellcheck:!0,overrideStyles:!0,stylesClass:!1,scrollTarget:document,focus:!1,focusEnd:!1,clickToEdit:!1,structure:!1,tabindex:!1,minHeight:!1,maxHeight:!1,maxWidth:!1,plugins:!1,callbacks:{},placeholder:!1,linkify:!0,enterKey:!0,pastePlainText:!1,pasteImages:!0,pasteLinks:!0,pasteBlockTags:["pre","h1","h2","h3","h4","h5","h6","table","tbody","thead","tfoot","th","tr","td","ul","ol","li","blockquote","p","figure","figcaption"],pasteInlineTags:["br","strong","ins","code","del","span","samp","kbd","sup","sub","mark","var","cite","small","b","u","em","i"],preClass:!1,preSpaces:4,tabAsSpaces:!1,tabKey:!0,autosave:!1,autosaveName:!1,autosaveFields:!1,imageUpload:null,imageUploadParam:"file",imageUploadFields:!1,imageUploadForms:!1,imageTag:"figure",imageEditable:!0,imageCaption:!0,imagePosition:!1,imageResizable:!1,imageFloatMargin:"10px",dragImageUpload:!0,multipleImageUpload:!0,clipboardImageUpload:!0,fileUpload:null,fileUploadParam:"file",fileUploadFields:!1,fileUploadForms:!1,dragFileUpload:!0,s3:!1,linkNewTab:!1,linkTooltip:!0,linkNofollow:!1,linkSize:30,linkValidation:!0,pasteLinkTarget:!1,videoContainerClass:"video-container",toolbar:!0,toolbarFixed:!0,toolbarFixedTarget:document,toolbarFixedTopOffset:0,toolbarExternal:!1,toolbarOverflow:!1,air:!1,airWidth:!1,formatting:["p","blockquote","pre","h1","h2","h3","h4","h5","h6"],formattingAdd:!1,buttons:["format","bold","italic","deleted","lists","image","file","link","horizontalrule"],buttonsTextLabeled:!1,buttonsHide:[],buttonsHideOnMobile:[],script:!0,removeNewlines:!1,removeComments:!0,replaceTags:{b:"strong",i:"em",strike:"del"},keepStyleAttr:[],keepInlineOnEnter:!1,shortcuts:{"ctrl+shift+m, meta+shift+m":{func:"inline.removeFormat"},"ctrl+b, meta+b":{func:"inline.format",params:["bold"]},"ctrl+i, meta+i":{func:"inline.format",params:["italic"]},"ctrl+h, meta+h":{func:"inline.format",params:["superscript"]},"ctrl+l, meta+l":{func:"inline.format",params:["subscript"]},"ctrl+k, meta+k":{func:"link.show"},"ctrl+shift+7":{func:"list.toggle",params:["orderedlist"]},"ctrl+shift+8":{func:"list.toggle",params:["unorderedlist"]}},shortcutsAdd:!1,activeButtons:["deleted","italic","bold"],activeButtonsStates:{b:"bold",strong:"bold",i:"italic",em:"italic",del:"deleted",strike:"deleted"},langs:{en:{format:"Format",image:"Image",file:"File",link:"Link",bold:"Bold",italic:"Italic",deleted:"Strikethrough",underline:"Underline","bold-abbr":"B","italic-abbr":"I","deleted-abbr":"S","underline-abbr":"U",lists:"Lists","link-insert":"Insert link","link-edit":"Edit link","link-in-new-tab":"Open link in new tab",unlink:"Unlink",cancel:"Cancel",close:"Close",insert:"Insert",save:"Save",delete:"Delete",text:"Text",edit:"Edit",title:"Title",paragraph:"Normal text",quote:"Quote",code:"Code",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",filename:"Name",optional:"optional",unorderedlist:"Unordered List",orderedlist:"Ordered List",outdent:"Outdent",indent:"Indent",horizontalrule:"Line","upload-label":"Drop file here or ",caption:"Caption",bulletslist:"Bullets",numberslist:"Numbers","image-position":"Position",none:"None",left:"Left",right:"Right",center:"Center","accessibility-help-label":"Rich text editor"}},type:"textarea",inline:!1,inlineTags:["a","span","strong","strike","b","u","em","i","code","del","ins","samp","kbd","sup","sub","mark","var","cite","small"],blockTags:["pre","ul","ol","li","p","h1","h2","h3","h4","h5","h6","dl","dt","dd","div","td","blockquote","output","figcaption","figure","address","section","header","footer","aside","article","iframe"],paragraphize:!0,paragraphizeBlocks:["table","div","pre","form","ul","ol","h1","h2","h3","h4","h5","h6","dl","blockquote","figcaption","address","section","header","footer","aside","article","object","style","script","iframe","select","input","textarea","button","option","map","area","math","hr","fieldset","legend","hgroup","nav","figure","details","menu","summary","p"],emptyHtml:"<p>&#x200b;</p>",invisibleSpace:"&#x200b;",emptyHtmlRendered:m("").html("​").html(),imageTypes:["image/png","image/jpeg","image/gif"],userAgent:navigator.userAgent.toLowerCase(),observe:{dropdowns:[]},regexps:{linkyoutube:/https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.\-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/gi,linkvimeo:/https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/,linkimage:/((https?|www)[^\s]+\.)(jpe?g|png|gif)(\?[^\s-]+)?/gi,url:/(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/gi}},l.fn=m.Redactor.prototype={keyCode:{BACKSPACE:8,DELETE:46,UP:38,DOWN:40,ENTER:13,SPACE:32,ESC:27,TAB:9,CTRL:17,META:91,SHIFT:16,ALT:18,RIGHT:39,LEFT:37,LEFT_WIN:91},init:function(t,e){if(this.$element=m(t),this.uuid=i++,this.sBuffer=[],this.sRebuffer=[],this.loadOptions(e),this.loadModules(),this.opts.clickToEdit&&!this.$element.hasClass("redactor-click-to-edit"))return this.loadToEdit(e);this.$element.hasClass("redactor-click-to-edit")&&this.$element.removeClass("redactor-click-to-edit"),this.reIsBlock=new RegExp("^("+this.opts.blockTags.join("|").toUpperCase()+")$","i"),this.reIsInline=new RegExp("^("+this.opts.inlineTags.join("|").toUpperCase()+")$","i"),this.opts.dragImageUpload=null!==this.opts.imageUpload&&this.opts.dragImageUpload,this.opts.dragFileUpload=null!==this.opts.fileUpload&&this.opts.dragFileUpload,this.formatting={},this.lang.load(),m.extend(this.opts.shortcuts,this.opts.shortcutsAdd),this.$editor=this.$element,this.detectType(),this.core.callback("start"),this.core.callback("startToEdit"),this.start=!0,this.build.start()},detectType:function(){this.build.isInline()||this.opts.inline?this.opts.type="inline":this.build.isTag("DIV")?this.opts.type="div":this.build.isTag("PRE")&&(this.opts.type="pre")},loadToEdit:function(t){this.$element.on("click.redactor-click-to-edit",m.proxy(function(){this.initToEdit(t)},this)),this.$element.addClass("redactor-click-to-edit")},initToEdit:function(e){m.extend(e.callbacks,{startToEdit:function(){this.insert.node(this.marker.get(),!1)},initToEdit:function(){this.selection.restore(),this.clickToCancelStorage=this.code.get(),m(this.opts.clickToCancel).off(".redactor-click-to-edit"),m(this.opts.clickToCancel).show().on("click.redactor-click-to-edit",m.proxy(function(t){t.preventDefault(),this.core.destroy(),this.events.syncFire=!1,this.$element.html(this.clickToCancelStorage),this.core.callback("cancel",this.clickToCancelStorage),this.events.syncFire=!0,this.clickToCancelStorage="",m(this.opts.clickToCancel).hide(),m(this.opts.clickToSave).hide(),this.$element.on("click.redactor-click-to-edit",m.proxy(function(){this.initToEdit(e)},this)),this.$element.addClass("redactor-click-to-edit")},this)),m(this.opts.clickToSave).off(".redactor-click-to-edit"),m(this.opts.clickToSave).show().on("click.redactor-click-to-edit",m.proxy(function(t){t.preventDefault(),this.core.destroy(),this.core.callback("save",this.code.get()),m(this.opts.clickToCancel).hide(),m(this.opts.clickToSave).hide(),this.$element.on("click.redactor-click-to-edit",m.proxy(function(){this.initToEdit(e)},this)),this.$element.addClass("redactor-click-to-edit")},this))}}),this.$element.redactor(e),this.$element.off(".redactor-click-to-edit")},loadOptions:function(t){var e={};void 0!==m.Redactor.settings.namespace&&!this.$element.hasClass(m.Redactor.settings.namespace)||(e=m.Redactor.settings),this.opts=m.extend({},m.Redactor.opts,this.$element.data(),t),this.opts=m.extend({},this.opts,e)},getModuleMethods:function(e){return Object.getOwnPropertyNames(e).filter(function(t){return"function"==typeof e[t]})},loadModules:function(){for(var t=m.Redactor.modules.length,e=0;e<t;e++)this.bindModuleMethods(m.Redactor.modules[e])},bindModuleMethods:function(t){if(void 0!==this[t]){this[t]=this[t]();for(var e=this.getModuleMethods(this[t]),i=e.length,n=0;n<i;n++)this[t][e[n]]=this[t][e[n]].bind(this)}},air:function(){return{enabled:!1,collapsed:function(){},collapsedEnd:function(){},build:function(){},append:function(){},createContainer:function(){},show:function(){},bindHide:function(){},hide:function(){}}},autosave:function(){return{enabled:!1,html:!1,init:function(){},is:function(){},send:function(){},getHiddenFields:function(){},success:function(){},disable:function(){}}},block:function(){return{format:function(t,e,i,n){if(t="quote"===t?"blockquote":t,this.block.tags=["p","blockquote","pre","h1","h2","h3","h4","h5","h6","div","figure"],-1!==m.inArray(t,this.block.tags))return"p"===t&&void 0===e&&(e="class"),this.buffer.set(),this.utils.isCollapsed()?this.block.formatCollapsed(t,e,i,n):this.block.formatUncollapsed(t,e,i,n)},formatCollapsed:function(t,e,i,n){this.selection.save();var r=this.selection.block(),s=r.tagName.toLowerCase();if(-1!==m.inArray(s,this.block.tags)){var o,a,l=!1;if(s===t&&void 0===e&&(t="p",l=!0),l&&(this.block.removeAllClass(),this.block.removeAllAttr()),"blockquote"===s&&this.utils.isEndOfElement(r)?(this.marker.remove(),(o=document.createElement("p")).innerHTML=this.opts.invisibleSpace,m(r).after(o),this.caret.start(o),0!==(a=m(r).children().last()).length&&"BR"===a[0].tagName&&a.remove()):o=this.utils.replaceToTag(r,t),"object"==typeof e)for(var c in n=i,e)o=this.block.setAttr(o,c,e[c],n);else o=this.block.setAttr(o,e,i,n);return"pre"===t&&1===o.length&&m(o).html(m.trim(m(o).html())),this.selection.restore(),this.block.removeInlineTags(o),o}this.selection.restore()},formatUncollapsed:function(t,e,i,n){this.selection.save();var r=[],s=this.selection.blocks();s[0]&&(m(s[0]).hasClass("redactor-in")||m(s[0]).hasClass("redactor-box"))&&(s=this.core.editor().find(this.opts.blockTags.join(", ")));for(var o,a=s.length,l=0;l<a;l++){var c=s[l].tagName.toLowerCase();if(-1!==m.inArray(c,this.block.tags)&&"figure"!==c){var h=this.utils.replaceToTag(s[l],t);if("object"==typeof e)for(var d in n=i,e)h=this.block.setAttr(h,d,e[d],n);else h=this.block.setAttr(h,e,i,n);r.push(h),this.block.removeInlineTags(h)}}return this.selection.restore(),"pre"===t&&0!==r.length&&(o=r[0],m.each(r,function(t,e){0!==t&&(m(o).append("\n"+m.trim(e.html())),m(e).remove())}),(r=[]).push(o)),r},removeInlineTags:function(t){t=t[0]||t;var e,i=this.opts.inlineTags;-1!==m.inArray(t.tagName,["PRE","H1","H2","H3","H4","H5","H6"])&&("PRE"!==t.tagName&&(e=i.indexOf("a"),i.splice(e,1)),m(t).find(i.join(",")).not(".redactor-selection-marker").contents().unwrap())},setAttr:function(t,e,i,n){if(void 0===e)return t;var r=void 0===n?"replace":n;return t="class"===e?this.block[r+"Class"](i,t):"remove"===r||"removeAll"===r?this.block[r+"Attr"](e,t):this.block[r+"Attr"](e,i,t)},getBlocks:function(t){if(t=void 0===t?this.selection.blocks():t,m(t).hasClass("redactor-box")){var i=[],e=this.core.editor().children();return m.each(e,m.proxy(function(t,e){this.utils.isBlock(e)&&i.push(e)},this)),i}return t},replaceClass:function(t,e){return m(this.block.getBlocks(e)).removeAttr("class").addClass(t)[0]},toggleClass:function(t,e){return m(this.block.getBlocks(e)).toggleClass(t)[0]},addClass:function(t,e){return m(this.block.getBlocks(e)).addClass(t)[0]},removeClass:function(t,e){return m(this.block.getBlocks(e)).removeClass(t)[0]},removeAllClass:function(t){return m(this.block.getBlocks(t)).removeAttr("class")[0]},replaceAttr:function(t,e,i){return i=this.block.removeAttr(t,i),m(i).attr(t,e)[0]},toggleAttr:function(i,n,t){t=this.block.getBlocks(t);var r=this,s=[];return m.each(t,function(t,e){m(e).attr(i)?s.push(r.block.removeAttr(i,e)):s.push(r.block.addAttr(i,n,e))}),s},addAttr:function(t,e,i){return m(this.block.getBlocks(i)).attr(t,e)[0]},removeAttr:function(t,e){return m(this.block.getBlocks(e)).removeAttr(t)[0]},removeAllAttr:function(t){t=this.block.getBlocks(t);var i=[];return m.each(t,function(t,e){if(void 0!==e.attributes)for(;e.attributes.length;)e.removeAttribute(e.attributes[0].name);i.push(e)}),i}}},buffer:function(){return{set:function(t){void 0===t&&this.buffer.clear(),void 0===t||"undo"===t?this.buffer.setUndo():this.buffer.setRedo()},setUndo:function(){var t=this.selection.saveInstant(),e=this.sBuffer[this.sBuffer.length-1],i=this.core.editor().html();void 0!==e&&e[0]===i||this.sBuffer.push([i,t])},setRedo:function(){var t=this.selection.saveInstant();this.sRebuffer.push([this.core.editor().html(),t])},add:function(){this.sBuffer.push([this.core.editor().html(),0])},undo:function(){var t;0!==this.sBuffer.length&&(t=this.sBuffer.pop(),this.buffer.set("redo"),this.core.editor().html(t[0]),this.selection.restoreInstant(t[1]),this.selection.restore(),this.observe.load())},redo:function(){var t;0!==this.sRebuffer.length&&(t=this.sRebuffer.pop(),this.buffer.set("undo"),this.core.editor().html(t[0]),this.selection.restoreInstant(t[1]),this.selection.restore(),this.observe.load())},clear:function(){this.sRebuffer=[]}}},build:function(){return{start:function(){if("textarea"!==this.opts.type)throw new Error("Only `<textarea>` types are allowed.");this.build.startTextarea(),this.build.setIn(),this.build.setId(),this.build.enableEditor(),this.build.setOptions(),this.build.callEditor()},createContainerBox:function(){this.$box=m('<div class="redactor-box" role="application" />')},setIn:function(){this.core.editor().addClass("redactor-in")},setId:function(){var t="textarea"===this.opts.type?"redactor-uuid-"+this.uuid:this.$element.attr("id");this.core.editor().attr("id",void 0===t?"redactor-uuid-"+this.uuid:t)},getName:function(){var t=this.$element.attr("name");return void 0===t?"content-"+this.uuid:t},buildTextarea:function(){},loadFromTextarea:function(){this.$editor=m("<div />"),this.$textarea=this.$element,this.$element.attr("name",this.build.getName()),this.$box.insertAfter(this.$element).append(this.$editor).append(this.$element),this.build.setStartAttrs(),this.$editor.addClass("redactor-layer"),this.opts.overrideStyles&&this.$editor.addClass("redactor-styles"),this.$element.hide(),this.$box.prepend('<span class="redactor-voice-label" id="redactor-voice-'+this.uuid+'" aria-hidden="false">'+this.lang.get("accessibility-help-label")+"</span>")},setStartAttrs:function(){this.$editor.attr({"aria-labelledby":"redactor-voice-"+this.uuid,role:"presentation"})},startTextarea:function(){this.build.createContainerBox(),this.build.loadFromTextarea(),this.code.start(this.core.textarea().val()),this.core.textarea().val(this.clean.onSync(this.$editor.html()))},isTag:function(t){return this.$element[0].tagName===t},isInline:function(){return!this.build.isTag("TEXTAREA")&&!this.build.isTag("DIV")&&!this.build.isTag("PRE")},enableEditor:function(){this.core.editor().attr({contenteditable:!0})},setOptions:function(){"inline"===this.opts.type&&(this.opts.enterKey=!1),"inline"!==this.opts.type&&"pre"!==this.opts.type||(this.opts.toolbarMobile=!1,this.opts.toolbar=!1),this.core.editor().attr("spellcheck",this.opts.spellcheck),this.opts.structure&&this.core.editor().addClass("redactor-structure"),this.opts.stylesClass&&this.core.editor().addClass(this.opts.stylesClass),"textarea"===this.opts.type&&(this.core.box().attr("dir",this.opts.direction),this.core.editor().attr("dir",this.opts.direction),this.opts.tabindex&&this.core.editor().attr("tabindex",this.opts.tabindex),this.opts.minHeight?this.core.editor().css("min-height",this.opts.minHeight):this.core.editor().css("min-height","40px"),this.opts.maxHeight&&this.core.editor().css("max-height",this.opts.maxHeight),this.opts.maxWidth&&this.core.editor().css({"max-width":this.opts.maxWidth,margin:"auto"}))},callEditor:function(){this.build.disableBrowsersEditing(),this.events.init(),this.build.setHelpers(),this.toolbarsButtons=this.button.init(),this.toolbar.build(),this.core.editor().on("mouseup.redactor-observe."+this.uuid+" keyup.redactor-observe."+this.uuid+" focus.redactor-observe."+this.uuid+" touchstart.redactor-observe."+this.uuid,m.proxy(this.observe.toolbar,this)),this.core.element().on("blur.callback.redactor",m.proxy(function(){this.button.setInactiveAll()},this)),this.modal.templates(),this.build.plugins(),this.code.html=this.code.cleaned(this.core.editor().html()),this.core.callback("init"),this.core.callback("initToEdit"),this.start=!1},setHelpers:function(){this.opts.focus?setTimeout(this.focus.start,100):this.opts.focusEnd&&setTimeout(this.focus.end,100)},disableBrowsersEditing:function(){try{document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1),document.execCommand("AutoUrlDetect",!1,!1)}catch(t){}},plugins:function(){this.opts.plugins&&m.each(this.opts.plugins,m.proxy(function(t,e){var i="undefined"!=typeof RedactorPlugins&&void 0!==RedactorPlugins[e]?RedactorPlugins:l.fn;if(m.isFunction(i[e])){this[e]=i[e]();for(var n,r,s=this.getModuleMethods(this[e]),o=s.length,a=0;a<o;a++)this[e][s[a]]=this[e][s[a]].bind(this);void 0!==this[e].langs&&(n={},void 0!==this[e].langs[this.opts.lang]?n=this[e].langs[this.opts.lang]:void 0===this[e].langs[this.opts.lang]&&void 0!==this[e].langs.en&&(n=this[e].langs.en),r=this,m.each(n,function(t,e){void 0===r.opts.curLang[t]&&(r.opts.curLang[t]=e)})),"function"==typeof this[e].init&&this[e].init()}},this))}}},button:function(){return{toolbar:function(){return void 0!==this.button.$toolbar&&this.button.$toolbar?this.button.$toolbar:this.$toolbar},init:function(){return{format:{title:this.lang.get("format"),icon:!0,dropdown:{p:{title:this.lang.get("paragraph"),func:"block.format"},blockquote:{title:this.lang.get("quote"),func:"block.format"},pre:{title:this.lang.get("code"),func:"block.format"},h1:{title:this.lang.get("heading1"),func:"block.format"},h2:{title:this.lang.get("heading2"),func:"block.format"},h3:{title:this.lang.get("heading3"),func:"block.format"},h4:{title:this.lang.get("heading4"),func:"block.format"},h5:{title:this.lang.get("heading5"),func:"block.format"},h6:{title:this.lang.get("heading6"),func:"block.format"}}},bold:{title:this.lang.get("bold-abbr"),icon:!0,label:this.lang.get("bold"),func:"inline.format"},italic:{title:this.lang.get("italic-abbr"),icon:!0,label:this.lang.get("italic"),func:"inline.format"},deleted:{title:this.lang.get("deleted-abbr"),icon:!0,label:this.lang.get("deleted"),func:"inline.format"},underline:{title:this.lang.get("underline-abbr"),icon:!0,label:this.lang.get("underline"),func:"inline.format"},lists:{title:this.lang.get("lists"),icon:!0,dropdown:{unorderedlist:{title:"&bull; "+this.lang.get("unorderedlist"),func:"list.toggle"},orderedlist:{title:"1. "+this.lang.get("orderedlist"),func:"list.toggle"},outdent:{title:"< "+this.lang.get("outdent"),func:"indent.decrease",observe:{element:"li",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}},indent:{title:"> "+this.lang.get("indent"),func:"indent.increase",observe:{element:"li",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}}}},ul:{title:"&bull; "+this.lang.get("bulletslist"),icon:!0,func:"list.toggle"},ol:{title:"1. "+this.lang.get("numberslist"),icon:!0,func:"list.toggle"},outdent:{title:this.lang.get("outdent"),icon:!0,func:"indent.decrease"},indent:{title:this.lang.get("indent"),icon:!0,func:"indent.increase"},image:{title:this.lang.get("image"),icon:!0,func:"image.show"},file:{title:this.lang.get("file"),icon:!0,func:"file.show"},link:{title:this.lang.get("link"),icon:!0,dropdown:{link:{title:this.lang.get("link-insert"),func:"link.show",observe:{element:"a",in:{title:this.lang.get("link-edit")},out:{title:this.lang.get("link-insert")}}},unlink:{title:this.lang.get("unlink"),func:"link.unlink",observe:{element:"a",out:{attr:{class:"redactor-dropdown-link-inactive","aria-disabled":!0}}}}}},horizontalrule:{title:this.lang.get("horizontalrule"),icon:!0,func:"line.insert"}}},setFormatting:function(){for(var t in this.toolbarsButtons.format.dropdown)this.toolbarsButtons.format.dropdown.hasOwnProperty(t)&&-1===this.opts.formatting.indexOf(t)&&delete this.toolbarsButtons.format.dropdown[t]},hideButtons:function(){0!==this.opts.buttonsHide.length&&this.button.hideButtonsSlicer(this.opts.buttonsHide)},hideButtonsOnMobile:function(){this.detect.isMobile()&&0!==this.opts.buttonsHideOnMobile.length&&this.button.hideButtonsSlicer(this.opts.buttonsHideOnMobile)},hideButtonsSlicer:function(t){m.each(t,m.proxy(function(t,e){var i=this.opts.buttons.indexOf(e);-1!==i&&this.opts.buttons.splice(i,1)},this))},load:function(i){this.button.buttons=[],this.opts.buttons.forEach(function(t){var e;("image"!==t||this.image.is())&&this.toolbarsButtons.hasOwnProperty(t)&&((e=elCreate("li")).appendChild(this.button.build(t,this.toolbarsButtons[t])[0]),i[0].appendChild(e))}.bind(this))},buildButtonTooltip:function(){},build:function(t,e){var i,n=m('<a href="javascript:void(null);" rel="'+t+'" />');return n.addClass("re-button re-"+t),n.attr({role:"button",tabindex:"-1"}),n.html(e.title),(e.func||e.command||e.dropdown)&&this.button.setEvent(n,t,e),e.dropdown&&(n.addClass("redactor-toolbar-link-dropdown").attr("aria-haspopup",!0),i=m('<ul class="dropdownMenu redactor-dropdown-menu redactor-dropdown-menu-'+n[0].rel+'" data-dropdown-allow-flip="horizontal" data-dropdown-ignore-page-scroll="true" />'),n.data("dropdown",i),this.dropdown.build(t,i,e.dropdown),this.button.setupDropdown(n[0],i[0])),this.button.buttons.push(n),n},setupDropdown:function(e,i){require(["Ui/SimpleDropdown"],function(t){t.initFragment(e,i),t.registerCallback(e.id,function(t,e){"close"===e&&this.dropdown.hideOut()}.bind(this)),elData(e,"a11y-mouse-event","mousedown"),elData(e,"aria-expanded",!1),e.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation()})}.bind(this))},getButtons:function(){return this.button.toolbar().find("a.re-button")},getButtonsKeys:function(){return this.button.buttons},setEvent:function(n,r,s){n.on("mousedown",m.proxy(function(t){if(t.preventDefault(),n.hasClass("redactor-button-disabled"))return!1;var e="func",i=s.func;return s.command?(e="command",i=s.command):s.dropdown&&(i=!(e="dropdown")),this.button.toggle(t,r,e,i),!1},this))},toggle:function(t,e,i,n,r){!this.detect.isIe()&&this.detect.isDesktop()||(this.utils.freezeScroll(),t.returnValue=!1),"command"===i?this.inline.format(n):"dropdown"===i?this.dropdown.show(t,e):this.button.clickCallback(t,n,e,r),"dropdown"!==i&&this.dropdown.hideAll(!1),!this.detect.isIe()&&this.detect.isDesktop()||this.utils.unfreezeScroll()},clickCallback:function(t,e,i,n){var r;if(t instanceof Event?t.preventDefault():t&&t.originalEvent&&t.originalEvent.preventDefault(),n=void 0===n?i:n,m.isFunction(e))e.call(this,i);else if("-1"!==e.search(/\./)){if(void 0===this[(r=e.split("."))[0]])return;"object"==typeof n?this[r[0]][r[1]].apply(this,n):this[r[0]][r[1]].call(this,n)}else"object"==typeof n?this[e].apply(this,n):this[e].call(this,n);this.observe.buttons(t,i)},all:function(){return this.button.buttons},get:function(t){if(!1!==this.opts.toolbar)return this.button.toolbar().find("a.re-"+t)},set:function(t,e){if(!1!==this.opts.toolbar){var i=this.button.toolbar().find("a.re-"+t);return i.html(e).attr("aria-label",e),i}},add:function(t,e){if(!0!==this.button.isAdded(t))return m();var i=this.button.build(t,{title:e});return this.button.toolbar().append(m("<li>").append(i)),i},addFirst:function(t,e){if(!0!==this.button.isAdded(t))return m();var i=this.button.build(t,{title:e});return this.button.toolbar().prepend(m("<li>").append(i)),i},addAfter:function(t,e,i){if(!0!==this.button.isAdded(e))return m();var n=this.button.build(e,{title:i}),r=this.button.get(t);return 0!==r.length?r.parent().after(m("<li>").append(n)):this.button.toolbar().append(m("<li>").append(n)),n},addBefore:function(t,e,i){if(!0!==this.button.isAdded(e))return m();var n=this.button.build(e,{title:i}),r=this.button.get(t);return 0!==r.length?r.parent().before(m("<li>").append(n)):this.button.toolbar().append(m("<li>").append(n)),n},isAdded:function(t){var e=this.opts.buttonsHideOnMobile.indexOf(t);return!(!1===this.opts.toolbar||-1!==e&&this.detect.isMobile())},setIcon:function(t,e){this.opts.buttonsTextLabeled||t.html(e).addClass("re-button-icon")},changeIcon:function(t,e){var i=this.button.get(t);0!==i.length&&i.find("i").removeAttr("class").addClass("re-icon-"+e)},addCallback:function(e,i){var n,r;void 0!==e&&!1!==this.opts.toolbar&&(n="dropdown"===i?"dropdown":"func",r=e.attr("rel"),e.on("mousedown",m.proxy(function(t){return!e.hasClass("redactor-button-disabled")&&void this.button.toggle(t,r,n,i)},this)))},addDropdown:function(t,e){if(!1!==this.opts.toolbar){t.addClass("redactor-toolbar-link-dropdown").attr("aria-haspopup",!0);var i=t.attr("rel");this.button.addCallback(t,"dropdown");var n=m('<ul class="dropdownMenu redactor-dropdown-menu redactor-dropdown-menu-'+i+'" data-dropdown-allow-flip="horizontal" data-dropdown-ignore-page-scroll="true" />');return t.data("dropdown",n),e&&(this.dropdown.build(i,n,e),this.button.setupDropdown(t[0],n[0])),n}},setActive:function(t){this.button.get(t).addClass("redactor-act").attr({"aria-pressed":!0,tabindex:0})},setInactive:function(t){this.button.get(t).removeClass("redactor-act").attr({"aria-pressed":!1,tabindex:"html"===t?0:-1})},setInactiveAll:function(t){var e=this.button.toolbar().find("a.re-button");void 0!==t&&(e=e.not(".re-"+t)),e.removeClass("redactor-act").attr({"aria-pressed":!1,tabindex:"html"===t?0:-1})},disable:function(t){this.button.get(t).addClass("redactor-button-disabled").attr("aria-disabled",!0)},enable:function(t){this.button.get(t).removeClass("redactor-button-disabled").attr("aria-disabled",!1)},disableAll:function(t){var e=this.button.toolbar().find("a.re-button");void 0!==t&&(Array.isArray(t)||(t=[t]),t=t.map(function(t){return".re-"+t}),e=e.not(t.join(","))),e.addClass("redactor-button-disabled").attr("aria-disabled",!0)},enableAll:function(){this.button.toolbar().find("a.re-button").removeClass("redactor-button-disabled").attr("aria-disabled",!1)},remove:function(t){this.button.get(t).remove()}}},caret:function(){return{set:function(t,e,i){var n=this.core.editor().scrollTop();this.core.editor().focus(),this.core.editor().scrollTop(n),i=void 0===i?0:1,t=t[0]||t,e=e[0]||e;var r=this.selection.get(),s=this.selection.range(r);try{s.setStart(t,0),s.setEnd(e,i)}catch(t){}this.selection.update(r,s)},prepare:function(t){return this.detect.isFirefox()&&void 0!==this.start&&this.core.editor().focus(),t[0]||t},start:function(t){var e,i;if(t=this.caret.prepare(t)){if("BR"===t.tagName)return this.caret.before(t);var n=m(t).children().first(),r=this.utils.isInlineTag(t.tagName);""===t.innerHTML||r?this.caret.setStartEmptyOrInline(t,r):n&&0!==n.length&&this.utils.isInlineTag(n[0].tagName)&&""===n.text()?this.caret.setStartEmptyOrInline(n[0],!0):((e=window.getSelection()).removeAllRanges(),(i=document.createRange()).selectNodeContents(t),i.collapse(!0),e.addRange(i))}},setStartEmptyOrInline:function(t,e){var i=window.getSelection(),n=document.createRange(),r=document.createTextNode("​");n.setStart(t,0),n.insertNode(r),n.setStartAfter(r),n.collapse(!0),i.removeAllRanges(),i.addRange(n),e||this.core.editor().on("keydown.redactor-remove-textnode",function(){m(r).remove(),m(this).off("keydown.redactor-remove-textnode")})},end:function(t){var e,i;if(t=this.caret.prepare(t)){if("BR"!==t.tagName&&""===t.innerHTML)return this.caret.start(t);if("BR"===t.tagName){var n=document.createElement("span");return n.className="redactor-invisible-space",n.innerHTML="&#x200b;",m(t).after(n),(e=window.getSelection()).removeAllRanges(),(i=document.createRange()).setStartBefore(n),i.setEndBefore(n),e.addRange(i),void m(n).replaceWith(function(){return m(this).contents()})}if(t.lastChild&&1===t.lastChild.nodeType)return this.caret.after(t.lastChild);if((e=window.getSelection()).getRangeAt||e.rangeCount)try{(i=e.getRangeAt(0)).selectNodeContents(t),i.collapse(!1),e.removeAllRanges(),e.addRange(i)}catch(t){}}},after:function(t){var e,i,n,r;if(t=this.caret.prepare(t)){if("BR"===t.tagName)return this.caret.end(t);this.utils.isBlockTag(t.tagName)?void 0===(i=this.caret.next(t))?this.caret.end(t):("TABLE"===i.tagName?i=m(i).find("th, td").first()[0]:"UL"!==i.tagName&&"OL"!==i.tagName||(i=m(i).find("li").first()[0]),this.caret.start(i)):(n=document.createTextNode("​"),(r=window.getSelection()).removeAllRanges(),(e=document.createRange()).setStartAfter(t),e.insertNode(n),e.setStartAfter(n),e.collapse(!0),r.addRange(e))}},before:function(t){var e,i,n;(t=this.caret.prepare(t))&&(this.utils.isBlockTag(t.tagName)?void 0===(n=this.caret.prev(t))?this.caret.start(t):("TABLE"===n.tagName?n=m(n).find("th, td").last()[0]:"UL"!==n.tagName&&"OL"!==n.tagName||(n=m(n).find("li").last()[0]),this.caret.end(n)):((e=window.getSelection()).removeAllRanges(),(i=document.createRange()).setStartBefore(t),i.collapse(!0),e.addRange(i)))},next:function(t){var e=m(t).next();return e.hasClass("redactor-script-tag, redactor-selection-marker")?e.next()[0]:e[0]},prev:function(t){var e=m(t).prev();return e.hasClass("redactor-script-tag, redactor-selection-marker")?e.prev()[0]:e[0]},offset:function(t){return this.offset.get(t)}}},clean:function(){return{onSet:function(t){t=this.clean.savePreCode(t),this.opts.script&&(t=t.replace(/<script(.*?[^>]?)>([\w\W]*?)<\/script>/gi,'<pre class="redactor-script-tag" $1>$2</pre>')),t=(t=(t=(t=(t=t.replace(/\$/g,"&#36;")).replace(/&amp;/g,"&")).replace(/<a href="(.*?[^>]?)®(.*?[^>]?)">/gi,'<a href="$1&reg$2">')).replace(/<span id="selection-marker-1"(.*?[^>]?)>​<\/span>/gi,"###marker1###")).replace(/<span id="selection-marker-2"(.*?[^>]?)>​<\/span>/gi,"###marker2###");var e,i=this,n=m("<div/>").html(m.parseHTML(t,document,!0)),r=this.opts.replaceTags;r&&(e=Object.keys(this.opts.replaceTags),n.find(e.join(",")).each(function(t,e){i.utils.replaceToTag(e,r[e.tagName.toLowerCase()])})),n.find("span, a").attr("data-redactor-span",!0),n.find(this.opts.inlineTags.join(",")).each(function(){var t=m(this);t.attr("style")&&t.attr("data-redactor-style-cache",t.attr("style"))}),t=n.html();var s=["font","html","head","link","body","meta","applet"];return this.opts.script||s.push("script"),t=this.clean.stripTags(t,s),this.opts.removeComments&&(t=t.replace(/<!--[\s\S]*?-->/gi,"")),-1!==(t=(t=(t=this.paragraphize.load(t)).replace("###marker1###",'<span id="selection-marker-1" class="redactor-selection-marker">​</span>')).replace("###marker2###",'<span id="selection-marker-2" class="redactor-selection-marker">​</span>')).search(/^(||\s||<br\s?\/?>||&nbsp;)$/i)?this.opts.emptyHtml:t},onGet:function(t){return this.clean.onSync(t)},onSync:function(i){if(-1!==(i=(i=i.replace(/\u200B/g,"")).replace(/&#x200b;/gi,"")).search(/^<p>(||\s||<br\s?\/?>||&nbsp;)<\/p>$/i))return"";i=(i=(i=(i=i.replace(/<span(.*?)id="redactor-image-box"(.*?[^>])>([\w\W]*?)<img(.*?)><\/span>/gi,"$3<img$4>")).replace(/<span(.*?)id="redactor-image-resizer"(.*?[^>])>(.*?)<\/span>/gi,"")).replace(/<span(.*?)id="redactor-image-editter"(.*?[^>])>(.*?)<\/span>/gi,"")).replace(/<img(.*?)style="(.*?)opacity: 0\.5;(.*?)"(.*?)>/gi,'<img$1style="$2$3"$4>');var t=m("<div/>").html(m.parseHTML(i,document,!0));t.find('*[style=""]').removeAttr("style"),t.find('*[class=""]').removeAttr("class"),t.find('*[rel=""]').removeAttr("rel"),t.find('*[data-image=""]').removeAttr("data-image"),t.find('*[alt=""]').removeAttr("alt"),t.find('*[title=""]').removeAttr("title"),t.find("*[data-redactor-style-cache]").removeAttr("data-redactor-style-cache"),t.find(".redactor-invisible-space, .redactor-unlink").each(function(){m(this).contents().unwrap()}),t.find("span, a").removeAttr("data-redactor-span data-redactor-style-cache").each(function(){0===this.attributes.length&&m(this).contents().unwrap()}),t.find("img").removeAttr("rel"),t.find(".redactor-selection-marker, #redactor-insert-marker").remove(),i=t.html(),this.opts.script&&(i=i.replace(/<pre class="redactor-script-tag"(.*?[^>]?)>([\w\W]*?)<\/pre>/gi,"<script$1>$2<\/script>")),i=(i=(i=(i=(i=this.clean.restoreFormTags(i)).replace(new RegExp("<br\\s?/?></h","gi"),"</h")).replace(new RegExp("<br\\s?/?></li>","gi"),"</li>")).replace(new RegExp("</li><br\\s?/?>","gi"),"</li>")).replace(/<pre>/gi,"<pre>\n"),this.opts.preClass&&(i=i.replace(/<pre>/gi,'<pre class="'+this.opts.preClass+'">')),this.opts.linkNofollow&&(i=(i=i.replace(/<a(.*?)rel="nofollow"(.*?[^>])>/gi,"<a$1$2>")).replace(/<a(.*?[^>])>/gi,'<a$1 rel="nofollow">'));return m.each({"™":"&trade;","©":"&copy;","…":"&hellip;","—":"&mdash;","‐":"&dash;"},function(t,e){i=i.replace(new RegExp(t,"g"),e)}),i=(i=i.replace(/&amp;/g,"&")).replace(/\n{2,}/g,"\n"),this.opts.removeNewlines&&(i=i.replace(/\r?\n/g,"")),i},onPaste:function(t,e,i){return!0!==i&&(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2")).replace(/<b(.*?)id="docs-internal-guid(.*?)">([\w\W]*?)<\/b>/gi,"$3")).replace(/<span[^>]*(font-style: italic; font-weight: bold|font-weight: bold; font-style: italic)[^>]*>([\w\W]*?)<\/span>/gi,"<b><i>$2</i></b>")).replace(/<span[^>]*(font-style: italic; font-weight: 700|font-weight: 700; font-style: italic)[^>]*>([\w\W]*?)<\/span>/gi,"<b><i>$2</i></b>")).replace(/<span[^>]*font-style: italic[^>]*>([\w\W]*?)<\/span>/gi,"<i>$1</i>")).replace(/<span[^>]*font-weight: bold[^>]*>([\w\W]*?)<\/span>/gi,"<b>$1</b>")).replace(/<span[^>]*font-weight: 700[^>]*>([\w\W]*?)<\/span>/gi,"<b>$1</b>")).replace(/<o:p[^>]*>/gi,"")).replace(/<\/o:p>/gi,""),this.clean.isHtmlMsWord(t)&&(t=this.clean.cleanMsWord(t))),t=m.trim(t),e.pre?this.opts.preSpaces&&(t=t.replace(/\t/g,new Array(this.opts.preSpaces+1).join(" "))):(t=this.clean.replaceBrToNl(t),t=this.clean.removeTagsInsidePre(t)),!0!==i&&(t=this.clean.removeEmptyInlineTags(t),!1===e.encode&&(t=t.replace(/&/g,"&amp;"),t=this.clean.convertTags(t,e),t=this.clean.getPlainText(t),t=this.clean.reconvertTags(t,e))),e.text&&(t=this.clean.replaceNbspToSpaces(t),t=this.clean.getPlainText(t)),e.lists&&(t=t.replace("\n","<br>")),e.encode&&(t=this.clean.encodeHtml(t)),e.paragraphize&&(t=(t=t.replace(/ \n/g," ")).replace(/\n /g," "),t=(t=this.paragraphize.load(t)).replace(/<p><\/p>/g,"")),t=(t=t.replace(/<li><p>/g,"<li>")).replace(/<\/p><\/li>/g,"</li>")},getCurrentType:function(t,e){var i=this.selection.blocks(),n={text:!1,encode:!1,paragraphize:!0,line:this.clean.isHtmlLine(t),blocks:this.clean.isHtmlBlocked(t),pre:!1,lists:!1,block:!0,inline:!0,links:!0,images:!0};return 1===i.length&&this.utils.isCurrentOrParent(["h1","h2","h3","h4","h5","h6","a","figcaption"])?(n.text=!0,n.paragraphize=!1,n.inline=!1,n.images=!1,n.links=!1,n.line=!0):"inline"===this.opts.type||!1===this.opts.enterKey?(n.paragraphize=!1,n.block=!1,n.line=!0):1===i.length&&this.utils.isCurrentOrParent(["li"])?(n.lists=!0,n.block=!1,n.paragraphize=!1,n.images=!1):1===i.length&&this.utils.isCurrentOrParent(["th","td","blockquote"])?(n.block=!1,n.paragraphize=!1):("pre"===this.opts.type||1===i.length&&this.utils.isCurrentOrParent("pre"))&&(n.inline=!1,n.block=!1,n.encode=!0,n.pre=!0,n.paragraphize=!1,n.images=!1,n.links=!1),!0===n.line&&(n.paragraphize=!1),!0===e&&(n.text=!1),n},isHtmlBlocked:function(t){var e=t.match(new RegExp("</("+this.opts.blockTags.join("|").toUpperCase()+")>","gi")),i=t.match(new RegExp("<hr(.*?[^>])>","gi"));return null!==e||null!==i},isHtmlLine:function(t){if(this.clean.isHtmlBlocked(t))return!1;var e=t.match(/<br\s?\/?>/gi),i=t.match(/\n/gi);return!e&&!i},isHtmlMsWord:function(t){return t.match(/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i)},removeEmptyInlineTags:function(t){var e=this.opts.inlineTags,i=m("<div/>").html(m.parseHTML(t,document,!0)),n=this,r=i.find("span"),s=i.find(e.join(","));return s.removeAttr("style"),s.each(function(){var t=m(this).html();0===this.attributes.length&&n.utils.isEmpty(t)&&m(this).replaceWith(function(){return m(this).contents()})}),r.each(function(){m(this).html();0===this.attributes.length&&m(this).replaceWith(function(){return m(this).contents()})}),t=(t=(t=(t=i.html()).replace("\x3c!--?php","<?php")).replace("\x3c!--?","<?")).replace("?--\x3e","?>"),i.remove(),t},cleanMsWord:function(t){t=(t=(t=(t=(t=t.replace(/<!--[\s\S]*?-->/g,"")).replace(/<o:p>[\s\S]*?<\/o:p>/gi,"")).replace(/\n/g," ")).replace(/<\/p>/gi,'</p><p><br data-redactor="br"></p>')).replace(/<\/div>|<\/li>|<\/td>/gi,"\n\n");var l=m("<div/>").html(t);elBySelAll("br",l[0],function(t){if("br"===elData(t,"redactor"))t.removeAttribute("data-redactor");else{var e=t.parentNode;if(e&&"P"===e.nodeName){for(var i=elCreate("p");t.nextSibling;)i.appendChild(t.nextSibling);e.parentNode.insertBefore(i,e.nextSibling),elRemove(t)}}});var c=!1,h=1,d=[];return l.find("p[style]").each(function(){var t=m(this).attr("style").match(/mso\-list\:l([0-9]+)\slevel([0-9]+)/);if(t){var e=parseInt(t[1]),i=parseInt(t[2]),n=m(this).html().match(/^[\w]+\./)?"ol":"ul",r=m("<li/>").html(m(this).html());if(r.html(r.html().replace(/^([\w\.]+)</,"<")),r.find("span:first").remove(),1==i&&-1==m.inArray(e,d)){var s=m("<"+n+"/>").attr({"data-level":i,"data-list":e}).html(r);m(this).replaceWith(s),c=e,d.push(e)}else{if(h<i){for(var o=l.find('[data-level="'+h+'"][data-list="'+c+'"]'),a=h;a<i;a++)(s=m("<"+n+"/>")).appendTo(o.find("li").last()),o=s;o.attr({"data-level":i,"data-list":e}).html(r)}else{l.find('[data-level="'+i+'"][data-list="'+e+'"]').last().append(r)}h=i,c=e,m(this).remove()}}}),l.find("[data-level][data-list]").removeAttr("data-level data-list"),elBySelAll("ol, ul",l[0],function(i){["nextElementSibling","previousElementSibling"].forEach(function(t){for(var e=i[t];e&&"P"===e.nodeName&&""===e.className&&"<br>"===e.innerHTML;)elRemove(e),e=i[t]})}),t=l.html()},replaceNbspToSpaces:function(t){return t.replace("&nbsp;"," ")},replaceBrToNl:function(t){return t.replace(/<br\s?\/?>/gi,"\n")},replaceNlToBr:function(t){return t.replace(/\n/g,"<br />")},convertTags:function(t,e){var i=m("<div>").html(t);i.find("iframe").remove();var n=i.find("a");if(n.removeAttr("style"),!1!==this.opts.pasteLinkTarget&&n.attr("target",this.opts.pasteLinkTarget),e.links&&this.opts.pasteLinks&&i.find("a").each(function(t,e){if(e.href){for(var i,n='#####[a href="'+e.href+'"',r=0,s=e.attributes.length;r<s;r++)"href"!==(i=e.attributes.item(r)).name&&(n+=" "+i.name+'="'+i.value+'"');e.outerHTML=n+"]#####"+e.innerHTML+"#####[/a]#####"}}),t=i.html(),e.images&&this.opts.pasteImages&&(t=t.replace(/<img(.*?)src="(.*?)"(.*?[^>])>/gi,'#####[img$1src="$2"$3]#####')),this.opts.pastePlainText)return t;for(var r=e.lists?["ul","ol","li"]:this.opts.pasteBlockTags,s=e.block||e.lists?e.inline?r.concat(this.opts.pasteInlineTags):r:e.inline?this.opts.pasteInlineTags:[],o=s.length,a=0;a<o;a++)t=t.replace(new RegExp("</"+s[a]+">","gi"),"###/"+s[a]+"###"),t="td"===s[a]||"th"===s[a]?t.replace(new RegExp("<"+s[a]+'(.*?[^>])((colspan|rowspan)="(.*?[^>])")?(.*?[^>])>',"gi"),"###"+s[a]+" $2###"):this.utils.isInlineTag(s[a])?(t=(t=t.replace(new RegExp("<"+s[a]+'([^>]*)class="([^>]*)"[^>]*>',"gi"),"###"+s[a]+' class="$2"###')).replace(new RegExp("<"+s[a]+'([^>]*)data-redactor-style-cache="([^>]*)"[^>]*>',"gi"),"###"+s[a]+' cache="$2"###')).replace(new RegExp("<"+s[a]+"[^>]*>","gi"),"###"+s[a]+"###"):t.replace(new RegExp("<"+s[a]+"[^>]*>","gi"),"###"+s[a]+"###");return t},reconvertTags:function(t,e){if((e.links&&this.opts.pasteLinks||e.images&&this.opts.pasteImages)&&(t=(t=t.replace(new RegExp("#####\\[","gi"),"<")).replace(new RegExp("\\]#####","gi"),">")),this.opts.pastePlainText)return t;for(var i=e.lists?["ul","ol","li"]:this.opts.pasteBlockTags,n=e.block||e.lists?e.inline?i.concat(this.opts.pasteInlineTags):i:e.inline?this.opts.pasteInlineTags:[],r=n.length,s=0;s<r;s++)t=t.replace(new RegExp("###/"+n[s]+"###","gi"),"</"+n[s]+">");for(s=0;s<r;s++)t=t.replace(new RegExp("###"+n[s]+"###","gi"),"<"+n[s]+">");for(var o,s=0;s<r;s++){"td"===n[s]||"th"===n[s]?t=t.replace(new RegExp("###"+n[s]+"s?(.*?[^#])###","gi"),"<"+n[s]+"$1>"):this.utils.isInlineTag(n[s])&&(o="span"===n[s]?' data-redactor-span="true"':"",t=(t=t.replace(new RegExp("###"+n[s]+' cache="(.*?[^#])"###',"gi"),"<"+n[s]+' style="$1"'+o+' data-redactor-style-cache="$1">')).replace(new RegExp("###"+n[s]+"s?(.*?[^#])###","gi"),"<"+n[s]+"$1>"))}return t},cleanPre:function(t){t=void 0===t?m(this.selection.block()).closest("pre",this.core.editor()[0]):t,m(t).find("br").replaceWith(function(){return document.createTextNode("\n")}),m(t).find("p").replaceWith(function(){return m(this).contents()})},removeTagsInsidePre:function(t){var e=m("<div />").append(t);return e.find("pre").replaceWith(function(){var t=m(this).html();return t=(t=t.replace(/<br\s?\/?>|<\/p>|<\/div>|<\/li>|<\/td>/gi,"\n")).replace(/(<([^>]+)>)/gi,""),m("<pre />").append(t)}),t=e.html(),e.remove(),t},getPlainText:function(t){t=(t=(t=(t=(t=(t=t.replace(/<!--[\s\S]*?-->/gi,"")).replace(/<style[\s\S]*?style>/gi,"")).replace(/<p><\/p>/g,"")).replace(/<\/div>|<\/li>|<\/td>/gi,"\n")).replace(/<\/p>/gi,"\n\n")).replace(/<\/H[1-6]>/gi,"\n\n");var e=document.createElement("div");return e.innerHTML=t,t=e.textContent||e.innerText,m.trim(t)},savePreCode:function(t){return t=this.clean.savePreFormatting(t),t=this.clean.saveCodeFormatting(t),t=this.clean.restoreSelectionMarkers(t)},savePreFormatting:function(a){var t=a.match(/<pre(.*?)>([\w\W]*?)<\/pre>/gi);return null===t||m.each(t,m.proxy(function(t,e){var i,n,r,s=[],o=!1;e.match(/<pre(.*?)>(([\n\r\s]+)?)<code(.*?)>/i)?(o=!0,i=(s=e.match(/<pre(.*?)>(([\n\r\s]+)?)<code(.*?)>([\w\W]*?)<\/code>(([\n\r\s]+)?)<\/pre>/i))[5],n=s[1],r=s[4]):(i=(s=e.match(/<pre(.*?)>([\w\W]*?)<\/pre>/i))[2],n=s[1]),i=(i=i.replace(/<br\s?\/?>/g,"\n")).replace(/&nbsp;/g," "),this.opts.preSpaces&&(i=i.replace(/\t/g,new Array(this.opts.preSpaces+1).join(" "))),i=(i=this.clean.encodeEntities(i)).replace(/\$/g,"&#36;"),a=o?a.replace(e,"<pre"+n+"><code"+r+">"+i+"</code></pre>"):a.replace(e,"<pre"+n+">"+i+"</pre>")},this)),a},saveCodeFormatting:function(n){var t=n.match(/<code(.*?)>([\w\W]*?)<\/code>/gi);return null===t||m.each(t,m.proxy(function(t,e){var i=e.match(/<code(.*?)>([\w\W]*?)<\/code>/i);i[2]=i[2].replace(/&nbsp;/g," "),i[2]=this.clean.encodeEntities(i[2]),i[2]=i[2].replace(/\$/g,"&#36;"),n=n.replace(e,"<code"+i[1]+">"+i[2]+"</code>")},this)),n},restoreSelectionMarkers:function(t){return t=t.replace(/&lt;span id=&quot;selection-marker-([0-9])&quot; class=&quot;redactor-selection-marker&quot;&gt;​&lt;\/span&gt;/g,'<span id="selection-marker-$1" class="redactor-selection-marker">​</span>')},saveFormTags:function(t){return t},restoreFormTags:function(t){return t.replace(/<section(.*?) rel="redactor-form-tag"(.*?)>([\w\W]*?)<\/section>/gi,"<form$1$2>$3</form>")},encodeHtml:function(t){return t=(t=(t=(t=t.replace(/”/g,'"')).replace(/“/g,'"')).replace(/‘/g,"'")).replace(/’/g,"'"),t=this.clean.encodeEntities(t)},encodeEntities:function(t){return t=(t=String(t).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"')).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},stripTags:function(t,i){if(void 0===i)return t.replace(/(<([^>]+)>)/gi,"");return t.replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,function(t,e){return-1===i.indexOf(e.toLowerCase())?t:""})},removeMarkers:function(t){return t.replace(/<span(.*?[^>]?)class="redactor-selection-marker"(.*?[^>]?)>([\w\W]*?)<\/span>/gi,"")},removeSpaces:function(t){return t=(t=(t=(t=(t=(t=(t=(t=(t=m.trim(t)).replace(/\n/g,"")).replace(/[\t]*/g,"")).replace(/\n\s*\n/g,"\n")).replace(/^[\s\n]*/g," ")).replace(/[\s\n]*$/g," ")).replace(/>\s{2,}</g,"> <")).replace(/\n\n/g,"\n")).replace(/\u200B/g,"")},removeSpacesHard:function(t){return t=(t=(t=(t=(t=(t=(t=(t=(t=m.trim(t)).replace(/\n/g,"")).replace(/[\t]*/g,"")).replace(/\n\s*\n/g,"\n")).replace(/^[\s\n]*/g,"")).replace(/[\s\n]*$/g,"")).replace(/>\s{2,}</g,"><")).replace(/\n\n/g,"\n")).replace(/\u200B/g,"")},normalizeCurrentHeading:function(){var t=this.selection.block();this.utils.isCurrentOrParentHeader()&&t&&t.normalize()}}},code:function(){return{syncFire:!0,html:!1,start:function(t){t=(t=m.trim(t)).replace(/^(<span id="selection-marker-1" class="redactor-selection-marker">​<\/span>)/,""),t=(t=this.clean.onSet(t)).replace(/<p><span id="selection-marker-1" class="redactor-selection-marker">​<\/span><\/p>/,""),this.events.stopDetectChanges(),this.core.editor().html(t),this.observe.load(),this.events.startDetectChanges()},set:function(t,e){t=m.trim(t),(e=e||{}).start&&(this.start=e.start),"textarea"===this.opts.type?t=this.clean.onSet(t):"div"===this.opts.type&&""===t&&(t=this.opts.emptyHtml),this.core.editor().html(t),"textarea"===this.opts.type&&this.code.sync()},get:function(){if("textarea"===this.opts.type)return this.core.textarea().val();var t=this.core.editor().html();return t=this.clean.onGet(t)},sync:function(){if(this.code.syncFire){var t=this.core.editor().html(),e=this.code.cleaned(t);if(!this.code.isSync(e)){if(this.code.html=e,"textarea"!==this.opts.type)return this.core.callback("sync",t),void this.core.callback("change",t);"textarea"===this.opts.type&&setTimeout(m.proxy(function(){this.code.startSync(t)},this),10)}}},startSync:function(t){t=this.core.callback("syncBefore",t),t=this.clean.onSync(t),this.core.textarea().val(t),this.core.callback("sync",t),!1===this.start&&this.core.callback("change",t),this.start=!1},isSync:function(t){var e=!1!==this.code.html&&this.code.html;return!1!==e&&e===t},cleaned:function(t){return t=t.replace(/\u200B/g,""),this.clean.removeMarkers(t)}}},core:function(){return{id:function(){return this.$editor.attr("id")},element:function(){return this.$element},editor:function(){return void 0===this.$editor?m():this.$editor},textarea:function(){return this.$textarea},box:function(){return"textarea"===this.opts.type?this.$box:this.$element},toolbar:function(){return!!this.$toolbar&&this.$toolbar},air:function(){return!!this.$air&&this.$air},object:function(){return m.extend({},this)},structure:function(){this.core.editor().toggleClass("redactor-structure")},addEvent:function(t){this.core.event=t},getEvent:function(){return this.core.event},callback:function(t,e,i){var n=!1,r=m._data(this.core.element()[0],"events");if(void 0!==r&&void 0!==r[t])for(var s,o,a=r[t].length,l=0;l<a;l++){"callback.redactor"===r[t][l].namespace&&(s=r[t][l].handler,n=void 0===(o=void 0===i?[e]:[e,i])?s.call(this,e):s.call(this,e,o))}if(n)return n;if(void 0===this.opts.callbacks[t])return void 0===i?e:i;var c=this.opts.callbacks[t];return m.isFunction(c)?void 0===i?c.call(this,e):c.call(this,e,i):void 0===i?e:i},destroy:function(){this.opts.destroyed=!0,this.core.callback("destroy"),m("#redactor-voice-"+this.uuid).remove(),this.core.editor().removeClass("redactor-in redactor-styles redactor-structure redactor-layer-img-edit"),this.core.editor().off("keydown.redactor-remove-textnode"),this.core.editor().off(".redactor-observe."+this.uuid),this.$element.off(".redactor").removeData("redactor"),this.core.editor().off(".redactor"),m(document).off(".redactor-air."+this.uuid),m(document).off("mousedown.redactor-blur."+this.uuid),m(document).off("mousedown.redactor."+this.uuid),m(document).off("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid),m(window).off(".redactor-toolbar."+this.uuid),m(window).off("touchmove.redactor."+this.uuid),m("body").off("scroll.redactor."+this.uuid),m(this.opts.toolbarFixedTarget).off("scroll.redactor."+this.uuid);var i=this;!1!==this.opts.plugins&&m.each(this.opts.plugins,function(t,e){m(window).off(".redactor-plugin-"+e),m(document).off(".redactor-plugin-"+e),m("body").off(".redactor-plugin-"+e),i.core.editor().off(".redactor-plugin-"+e)}),this.$element.off("click.redactor-click-to-edit"),this.$element.removeClass("redactor-click-to-edit"),this.core.editor().removeClass("redactor-layer"),this.core.editor().removeAttr("contenteditable");var t=this.code.get();this.opts.toolbar&&this.$toolbar&&this.$toolbar.find("a").each(function(){var t=m(this);t.data("dropdown")&&(t.data("dropdown").remove(),t.data("dropdown",{}))}),"textarea"===this.opts.type&&(this.$box.after(this.$element),this.$box.remove(),this.$element.val(t).show()),this.opts.toolbar&&this.$toolbar&&this.$toolbar.remove(),this.$modalBox&&this.$modalBox.remove(),this.$modalOverlay&&this.$modalOverlay.remove(),m(".redactor-link-tooltip").remove()}}},detect:function(){return{isWebkit:function(){return/webkit/.test(this.opts.userAgent)},isFirefox:function(){return-1<this.opts.userAgent.indexOf("firefox")},isIe:function(t){if(document.documentMode||/Edge/.test(navigator.userAgent))return"edge";var e=RegExp("msie"+(isNaN(t)?"":"\\s"+t),"i").test(navigator.userAgent);return e=e||!!navigator.userAgent.match(/Trident.*rv[ :]*11\./)},isMobile:function(){return/(iPhone|iPod|BlackBerry|Android)/.test(navigator.userAgent)},isDesktop:function(){return!/(iPhone|iPod|iPad|BlackBerry|Android)/.test(navigator.userAgent)},isIpad:function(){return/iPad/.test(navigator.userAgent)}}},dropdown:function(){return{active:!1,button:!1,key:!1,position:[],getDropdown:function(){return this.dropdown.active},build:function(t,e,i){var n,r,s=document.createDocumentFragment();for(var o in i){i.hasOwnProperty(o)&&(n=i[o],r=this.dropdown.buildItem(o,n),this.observe.addDropdown(m(r),o,n),s.appendChild(r))}for(var a=!1,l=0,c=s.childNodes.length;l<c;l++)if(s.childNodes[l].nodeType===Node.ELEMENT_NODE){a=!0;break}a&&(e[0].rel=t,e[0].appendChild(s))},buildFormatting:function(){},buildItem:function(e,i){var t=elCreate("li");return void 0!==i.classname&&t.classList.add(i.classname),0===e.toLowerCase().indexOf("divider")?t.classList.add("redactor-dropdown-divider"):(t.innerHTML='<a href="#" class="redactor-dropdown-'+e+'" role="button"><span>'+i.title+"</span></a>",m(t.children[0]).on("mousedown",function(t){t.preventDefault(),this.dropdown.buildClick(t,e,i)}.bind(this))),t},buildClick:function(t,e,i){var n;m(t.target).hasClass("redactor-dropdown-link-inactive")||(n=this.dropdown.buildCommand(i),void 0!==i.args?this.button.toggle(t,e,n.type,n.callback,i.args):this.button.toggle(t,e,n.type,n.callback))},buildCommand:function(t){var e={type:"func"};return e.callback=t.func,t.command?(e.type="command",e.callback=t.command):t.dropdown&&(e.type="dropdown",e.callback=t.dropdown),e},show:function(t,e){this.detect.isDesktop()&&this.core.editor().focus(),this.dropdown.hideAll(!1,e),this.dropdown.key=e,this.dropdown.button=this.button.get(this.dropdown.key),require(["Ui/SimpleDropdown"],function(t){var e=this.dropdown.button[0].id;t.toggleDropdown(e),t.isOpen(e)?(this.dropdown.active=m(t.getDropdownMenu(e)),this.core.callback("dropdownShow",{dropdown:this.dropdown.active,key:this.dropdown.key,button:this.dropdown.button}),this.button.setActive(this.dropdown.key),this.dropdown.button.addClass("dropact").attr("aria-expanded",!0),this.dropdown.enableCallback()):this.dropdown.hide()}.bind(this)),t.preventDefault()},showIsFixedToolbar:function(){},showIsUnFixedToolbar:function(){},enableEvents:function(){},enableCallback:function(){this.core.callback("dropdownShown",{dropdown:this.dropdown.active,key:this.dropdown.key,button:this.dropdown.button})},getButtonPosition:function(){},closeHandler:function(){},hideAll:function(t,e){this.dropdown.hideOut(e)},hide:function(){this.dropdown.hideOut()},hideOut:function(t){var e;!1!==this.dropdown.active&&this.dropdown.button[0].rel!==t&&(this.core.callback("dropdownHide",this.dropdown.active),e=this.dropdown.button[0].id,require(["Ui/SimpleDropdown"],function(t){t.close(e)}),this.dropdown.button.removeClass("redactor-act dropact").attr("aria-expanded",!1),this.dropdown.button=!1,this.dropdown.key=!1,this.dropdown.active=!1)}}},events:function(){return{focused:!1,blured:!0,dropImage:!1,stopChanges:!1,stopDetectChanges:function(){this.events.stopChanges=!0},startDetectChanges:function(){var t=this;setTimeout(function(){t.events.stopChanges=!1},1)},dragover:function(t){t.preventDefault(),"IMG"===t.target.tagName&&m(t.target).addClass("redactor-image-dragover")},dragleave:function(t){this.core.editor().find("img").removeClass("redactor-image-dragover")},drop:function(t){return t=t.originalEvent||t,this.core.editor().find("img").removeClass("redactor-image-dragover"),"inline"===this.opts.type||"pre"===this.opts.type?(t.preventDefault(),!1):void 0===window.FormData||!t.dataTransfer||(0===t.dataTransfer.files.length?this.events.onDrop(t):(this.events.onDropUpload(t),void this.core.callback("drop",t)))},click:function(t){var e=this.core.getEvent(),i="click"!==e&&"arrow"!==e&&"click";this.core.addEvent(i),this.utils.disableSelectAll(),this.core.callback("click",t)},focus:function(t){var e,i;this.rtePaste||(this.events.isCallback("focus")&&this.core.callback("focus",t),this.events.focused=!0,(this.events.blured=!1)===this.selection.current()&&(e=this.selection.get(),(i=this.selection.range(e)).setStart(this.core.editor()[0],0),i.setEnd(this.core.editor()[0],0),this.selection.update(e,i)))},blur:function(t){this.start||this.rtePaste||0===m(t.target).closest("#"+this.core.id()+", .redactor-toolbar, .redactor-dropdown, #redactor-modal-box").length&&(!this.events.blured&&this.events.isCallback("blur")&&this.core.callback("blur",t),this.events.focused=!1,this.events.blured=!0)},touchImageEditing:function(){var t=-1;this.events.imageEditing=!1,m(window).on("touchmove.redactor."+this.uuid,m.proxy(function(){this.events.imageEditing=!0,-1!==t&&clearTimeout(t),t=setTimeout(m.proxy(function(){this.events.imageEditing=!1},this),500)},this))},init:function(){this.core.editor().on("dragover.redactor dragenter.redactor",m.proxy(this.events.dragover,this)),this.core.editor().on("dragleave.redactor",m.proxy(this.events.dragleave,this)),this.core.editor().on("drop.redactor",m.proxy(this.events.drop,this)),this.core.editor().on("click.redactor",m.proxy(this.events.click,this)),this.core.editor().on("paste.redactor",m.proxy(this.paste.init,this)),this.core.editor().on("keydown.redactor",m.proxy(this.keydown.init,this)),this.core.editor().on("keyup.redactor",m.proxy(this.keyup.init,this)),this.core.editor().on("focus.redactor",m.proxy(this.events.focus,this)),m(document).on("mousedown.redactor-blur."+this.uuid,m.proxy(this.events.blur,this)),this.events.touchImageEditing(),this.events.createObserver(),this.events.setupObserver()},createObserver:function(){var e=this;this.events.observer=new MutationObserver(function(t){t.forEach(m.proxy(e.events.iterateObserver,e))})},iterateObserver:function(t){var e=!1;("textarea"!==this.opts.type&&"div"!==this.opts.type||this.detect.isFirefox()||t.target!==this.core.editor()[0])&&("class"!==t.attributeName||t.target!==this.core.editor()[0])&&"data-vivaldi-spatnav-clickable"!=t.attributeName||(e=!0),e||(this.observe.load(),this.events.changeHandler())},setupObserver:function(){this.events.observer.observe(this.core.editor()[0],{attributes:!0,subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0})},changeHandler:function(){this.events.stopChanges||this.code.sync()},onDropUpload:function(t){if(t.preventDefault(),t.stopPropagation(),(this.opts.dragImageUpload||this.opts.dragFileUpload)&&(null!==this.opts.imageUpload||null!==this.opts.fileUpload)){"IMG"===t.target.tagName&&(this.events.dropImage=t.target);for(var e=t.dataTransfer.files,i=e.length,n=0;n<i;n++)this.upload.directUpload(e[n],t)}},onDrop:function(t){this.core.callback("drop",t)},isCallback:function(t){return void 0!==this.opts.callbacks[t]&&m.isFunction(this.opts.callbacks[t])},stopDetect:function(){this.events.stopDetectChanges()},startDetect:function(){this.events.startDetectChanges()}}},file:function(){return{is:function(){},show:function(){},insert:function(){},release:function(){},text:function(t){}}},focus:function(){return{start:function(){var t;this.core.editor().focus(),"inline"===this.opts.type||!1!==(t=this.focus.first())&&this.caret.start(t)},end:function(){this.core.editor().focus();var t,e,i,n=this.opts.inline?this.core.editor():this.focus.last();0!==n.length&&(t=this.focus.lastChild(n),this.detect.isWebkit()||!1===t?(e=this.selection.get(),null!==(i=this.selection.range(e))?(i.selectNodeContents(n[0]),i.collapse(!1),this.selection.update(e,i)):this.caret.end(n)):this.caret.end(t))},first:function(){var t=this.core.editor().children().first();return(0!==t.length||0!==t[0].length&&"BR"!==t[0].tagName&&"HR"!==t[0].tagName&&3!==t[0].nodeType)&&("UL"===t[0].tagName||"OL"===t[0].tagName?t.find("li").first():t)},last:function(){return this.core.editor().children().last()},lastChild:function(t){var e=t[0].lastChild;return!(null===e||!this.utils.isInlineTag(e.tagName))&&e},is:function(){return this.core.editor()[0]===document.activeElement}}},image:function(){return{is:function(){return!(!this.opts.imageUpload||!this.opts.imageUpload&&!this.opts.s3)},show:function(){this.modal.load("image",this.lang.get("image"),700),this.upload.init("#redactor-modal-image-droparea",this.opts.imageUpload,this.image.insert),this.modal.show()},insert:function(t,e,i){if(void 0!==t.error)return this.modal.close(),this.events.dropImage=!1,void this.core.callback("imageUploadError",t,i);if(!1!==this.events.dropImage)return n=m(this.events.dropImage),this.core.callback("imageDelete",n[0].src,n),n.attr("src",t.url),this.events.dropImage=!1,void this.core.callback("imageUpload",n,t);var n,r=m("<"+this.opts.imageTag+">");(n=m("<img>")).attr("src",t.url);var s=void 0===t.id?"":t.id,o=void 0===t.s3?"image":"s3";n.attr("data-"+o,s),r.append(n);var a,l,c=this.utils.isTag(this.selection.current(),"pre");e?(this.marker.remove(),a=this.insert.nodeToPoint(i,this.marker.get()),l=m(a).next(),this.selection.restore(),this.buffer.set(),void 0!==l&&0!==l.length&&"IMG"===l[0].tagName?(this.core.callback("imageDelete",l[0].src,l),l.closest("figure, p",this.core.editor()[0]).replaceWith(r)):c?m(c).after(r):this.insert.node(r)):(this.modal.close(),this.buffer.set(),c?m(c).after(r):this.insert.node(r)),this.caret.after(r),this.events.dropImage=!1;var h=n[0].nextSibling,d=r.next(),u=m(h).text().replace(/\u200B/g,""),p=d.text().replace(/\u200B/g,"");""===u&&m(h).remove(),1===d.length&&"FIGURE"===d[0].tagName&&""===p&&d.remove(),null!==e?this.core.callback("imageUpload",n,t):this.core.callback("imageInserted",n,t)},setEditable:function(e){var t;e.on("dragstart",function(t){t.preventDefault()}),this.opts.imageResizable?(t=m.proxy(function(t){this.observe.image=e,this.image.resizer=this.image.loadEditableControls(e),m(document).on("mousedown.redactor-image-resize-hide."+this.uuid,m.proxy(this.image.hideResize,this)),this.image.resizer&&this.image.resizer.on("mousedown.redactor touchstart.redactor",m.proxy(function(t){this.image.setResizable(t,e)},this))},this),e.off("mousedown.redactor").on("mousedown.redactor",m.proxy(this.image.hideResize,this)),e.off("click.redactor touchstart.redactor").on("click.redactor touchstart.redactor",t)):e.off("click.redactor touchstart.redactor").on("click.redactor touchstart.redactor",m.proxy(function(t){setTimeout(m.proxy(function(){this.image.showEdit(e)},this),200)},this))},setResizable:function(t,e){t.preventDefault(),this.image.resizeHandle={x:t.pageX,y:t.pageY,el:e,ratio:e.width()/e.height(),h:e.height()},(t=t.originalEvent||t).targetTouches&&(this.image.resizeHandle.x=t.targetTouches[0].pageX,this.image.resizeHandle.y=t.targetTouches[0].pageY),this.image.startResize()},startResize:function(){m(document).on("mousemove.redactor-image-resize touchmove.redactor-image-resize",m.proxy(this.image.moveResize,this)),m(document).on("mouseup.redactor-image-resize touchend.redactor-image-resize",m.proxy(this.image.stopResize,this))},moveResize:function(t){t.preventDefault(),t=t.originalEvent||t;var e=this.image.resizeHandle.h;t.targetTouches?e+=t.targetTouches[0].pageY-this.image.resizeHandle.y:e+=t.pageY-this.image.resizeHandle.y;var i=Math.round(e*this.image.resizeHandle.ratio);e<50||i<100||this.core.editor().width()<=i||(this.image.resizeHandle.el.attr({width:i,height:e}),this.image.resizeHandle.el.width(i),this.image.resizeHandle.el.height(e),this.code.sync())},stopResize:function(){this.handle=!1,m(document).off(".redactor-image-resize"),this.image.hideResize()},hideResize:function(t){var e;t&&0!==m(t.target).closest("#redactor-image-box",this.$editor[0]).length||(t&&"IMG"==t.target.tagName&&m(t.target),0!==(e=this.$editor.find("#redactor-image-box")).length&&(m("#redactor-image-editter").remove(),m("#redactor-image-resizer").remove(),e.find("img").css({marginTop:e[0].style.marginTop,marginBottom:e[0].style.marginBottom,marginLeft:e[0].style.marginLeft,marginRight:e[0].style.marginRight}),e.css("margin",""),e.find("img").css("opacity",""),e.replaceWith(function(){return m(this).contents()}),m(document).off("mousedown.redactor-image-resize-hide."+this.uuid),void 0!==this.image.resizeHandle&&this.image.resizeHandle.el.attr("rel",this.image.resizeHandle.el.attr("style"))))},loadResizableControls:function(t,e){if(!this.opts.imageResizable||this.detect.isMobile())return e.append(t),!1;var i=m('<span id="redactor-image-resizer" data-redactor="verified"></span>');return this.detect.isDesktop()||i.css({width:"15px",height:"15px"}),i.attr("contenteditable",!1),e.append(i),e.append(t),i},loadEditableControls:function(t){if(0===m("#redactor-image-box").length){var e,i=m('<span id="redactor-image-box" data-redactor="verified">');return i.css("float",t.css("float")).attr("contenteditable",!1),"auto"!=t[0].style.margin?(i.css({marginTop:t[0].style.marginTop,marginBottom:t[0].style.marginBottom,marginLeft:t[0].style.marginLeft,marginRight:t[0].style.marginRight}),t.css("margin","")):i.css({display:"block",margin:"auto"}),t.css("opacity",".5").after(i),this.opts.imageEditable&&(this.image.editter=m('<span id="redactor-image-editter" data-redactor="verified">'+this.lang.get("edit")+"</span>"),this.image.editter.attr("contenteditable",!1),this.image.editter.on("click",m.proxy(function(){this.image.showEdit(t)},this)),i.append(this.image.editter),e=this.image.editter.innerWidth(),this.image.editter.css("margin-left","-"+e/2+"px")),this.image.loadResizableControls(t,i)}},showEdit:function(t){var e,i,n,r,s;this.events.imageEditing||(e=(this.observe.image=t).closest("a",this.$editor[0]),n=0!==(i=t.closest("figure",this.$editor[0])).length?i:t,this.modal.load("image-edit",this.lang.get("edit"),705),this.image.buttonDelete=this.modal.getDeleteButton().text(this.lang.get("delete")),this.image.buttonSave=this.modal.getActionButton().text(this.lang.get("save")),this.image.buttonDelete.on("click",m.proxy(this.image.remove,this)),this.image.buttonSave.on("click",m.proxy(this.image.update,this)),!1===this.opts.imageCaption?m("#redactor-image-caption").val("").hide().prev().hide():0!==(r=t.closest(this.opts.imageTag,this.$editor[0]).find("figcaption"))&&m("#redactor-image-caption").val(r.text()).show(),this.opts.imagePosition?(s=(0!==i.length?"center"===n.css("text-align"):"block"==n.css("display")&&"none"==n.css("float"))?"center":n.css("float"),m("#redactor-image-align").val(s)):m(".redactor-image-position-option").hide(),m("#redactor-image-preview").html(m('<img src="'+t.attr("src")+'" style="max-width: 100%;">')),m("#redactor-image-title").val(t.attr("alt")),0!==e.length&&(m("#redactor-image-link").val(e.attr("href")),"_blank"===e.attr("target")&&m("#redactor-image-link-blank").prop("checked",!0)),m(".redactor-link-tooltip").remove(),this.modal.show(),this.detect.isDesktop()&&m("#redactor-image-title").focus())},update:function(){var t=this.observe.image,e=t.closest("a",this.core.editor()[0]),i=m("#redactor-image-title").val().replace(/(<([^>]+)>)/gi,"");t.attr("alt",i).attr("title",i),this.image.setFloating(t);var n,r,s,o,a,l=m.trim(m("#redactor-image-link").val()).replace(/(<([^>]+)>)/gi,"");""!==l?(n="((xn--)?[a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,}",r=new RegExp("^(http|ftp|https)://"+n,"i"),s=new RegExp("^"+n,"i"),-1===l.search(r)&&0===l.search(s)&&this.opts.linkProtocol&&(l=this.opts.linkProtocol+"://"+l),o=!!m("#redactor-image-link-blank").prop("checked"),0===e.length?(a=m('<a href="'+l+'" id="redactor-img-tmp">'+this.utils.getOuterHtml(t)+"</a>"),o&&a.attr("target","_blank"),t=t.replaceWith(a),(e=this.core.editor().find("#redactor-img-tmp")).removeAttr("id")):(e.attr("href",l),o?e.attr("target","_blank"):e.removeAttr("target"))):0!==e.length&&e.replaceWith(this.utils.getOuterHtml(t)),this.image.addCaption(t,e),this.modal.close(),this.buffer.set()},setFloating:function(t){var e=t.closest("figure",this.$editor[0]),i=0!==e.length?e:t,n="",r="",s="",o="";switch(m("#redactor-image-align").val()){case"left":n="left",s="0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin+" 0";break;case"right":n="right",s="0 0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin;break;case"center":0!==e.length?o="center":(r="block",s="auto")}i.css({float:n,display:r,margin:s,"text-align":o}),i.attr("rel",t.attr("style"))},addCaption:function(t,e){var i=m("#redactor-image-caption").val(),n=0!==e.length?e:t,r=n.next();0!==r.length&&"FIGCAPTION"===r[0].tagName||(r=!1),""!==i?!1===r?(r=m("<figcaption />").text(i),n.after(r)):r.text(i):!1!==r&&r.remove()},remove:function(t,e,i){e=void 0===e?m(this.observe.image):e,"boolean"!=typeof t&&this.buffer.set(),this.events.stopDetectChanges();var n,r,s=e.closest("a",this.core.editor()[0]),o=e.closest(this.opts.imageTag,this.core.editor()[0]);e.parent();if(!1===this.core.callback("imageDelete",t,e[0]))return t&&t.preventDefault(),!1;0!==m("#redactor-image-box").length&&m("#redactor-image-box").parent(),0!==o.length?(r=o.prev(),n=o.next(),o.remove()):0!==s.length?(s.parent(),s.remove()):e.remove(),m("#redactor-image-box").remove(),!1!==t&&(n&&0!==n.length?this.caret.start(n):r&&0!==r.length&&this.caret.end(r)),"boolean"!=typeof t&&this.modal.close(),this.utils.restoreScroll(),this.observe.image=!1,this.events.startDetectChanges(),this.code.sync()}}},indent:function(){return{increase:function(){var t,e,i,n,r,s;this.list.get()&&(e=(t=m(this.selection.current()).closest("li")).closest("ul, ol",this.core.editor()[0]),0!==(i=t.closest("li").prev()).length&&"LI"===i[0].tagName&&(this.buffer.set(),this.utils.isCollapsed()?(r=e[0].tagName,s=m("<"+r+" />"),this.selection.save(),1===(n=i.find("ol").first()).length?n.append(t):(r=e[0].tagName,(s=m("<"+r+" />")).append(t),i.append(s))):(document.execCommand("indent"),this.selection.save(),this.indent.removeEmpty(),this.indent.normalize()),this.selection.restore()))},decrease:function(){if(this.list.get()){m(this.selection.current()).closest("li").closest("ul, ol",this.core.editor()[0]);this.buffer.set(),document.execCommand("outdent");var t=m(this.selection.current()).closest("li",this.core.editor()[0]);this.utils.isCollapsed()&&this.indent.repositionItem(t);var e=null;if(0===t.length){var i=this.selection.block();if(i&&-1!==i.nodeName.indexOf("-")){for(this.selection.save(),e=elCreate("div");i.childNodes.length;)e.appendChild(i.childNodes[0]);i.appendChild(e),this.selection.restore()}document.execCommand("formatblock",!1,"p");var n=(t=m(this.selection.current())).next();0!==n.length&&"BR"===n[0].tagName&&n.remove()}if(this.selection.save(),null!==e){for(var r=e.parentNode;e.childNodes.length;)r.insertBefore(e.childNodes[0],e);r.removeChild(e)}this.indent.removeEmpty(),this.indent.normalize(),this.selection.restore()}},repositionItem:function(t){var e=t.next();0===e.length||"UL"===e[0].tagName&&"OL"===e[0].tagName||t.append(e);var i=t.prev();0!==i.length&&"LI"!==i[0].tagName&&(this.selection.save(),t.parents("li",this.core.editor()[0]).after(t),this.selection.restore())},normalize:function(){this.core.editor().find("li").each(m.proxy(function(t,e){var i=m(e),n="";0!==this.opts.keepStyleAttr.length&&(n=","+this.opts.keepStyleAttr.join(",")),i.find(this.opts.inlineTags.join(",")).not("img"+n).removeAttr("style");var r,s=i.parent();0===s.length||"LI"!==s[0].tagName?0===(r=i.next()).length||"UL"!==r[0].tagName&&"OL"!==r[0].tagName||i.append(r):s.after(i)},this))},removeEmpty:function(t){var e=this.core.editor().find("ul, ol"),i=this.core.editor().find("li");i.each(m.proxy(function(t,e){this.indent.removeItemEmpty(e)},this)),e.each(m.proxy(function(t,e){this.indent.removeItemEmpty(e)},this)),i.each(m.proxy(function(t,e){this.indent.removeItemEmpty(e)},this))},removeItemEmpty:function(t){""===t.innerHTML.replace(/[\t\s\n]/g,"").replace(/<span><\/span>/g,"")&&m(t).remove()}}},inline:function(){return{format:function(t,e,i,n){var r;this.utils.isCurrentOrParent(["PRE","CODE"])||(r=this.inline.getParams(e,i,n),t=this.inline.arrangeTag(t),this.buffer.set(),this.utils.isCollapsed()?this.inline.formatCollapsed(t,r):this.inline.formatUncollapsed(t,r))},formatCollapsed:function(t,e){var i,n,r,s=this.selection.inline();s?(n=s.tagName.toLowerCase())===t?this.utils.isEmpty(s.innerHTML)?(this.caret.after(s),m(s).remove()):(r=this.inline.insertBreakpoint(s,n),this.caret.after(r)):0===m(s).closest(t).length?(i=this.inline.insertInline(t),i=this.inline.setParams(i,e)):(r=this.inline.insertBreakpoint(s,n),this.caret.after(r)):(i=this.inline.insertInline(t),i=this.inline.setParams(i,e))},formatUncollapsed:function(r,s){var t;this.selection.save();var e=window.getSelection().getRangeAt(0);if(null===e.cloneContents().querySelector(r)){(t=e.startContainer).nodeType===Node.TEXT_NODE&&(t=t.parentElement);var i=t.closest(r);if(null!==i&&this.core.editor()[0].contains(i)){var n=document.createElement(r);i.insertAdjacentElement("beforebegin",n);var o=document.createRange();o.selectNodeContents(i),o.setEnd(e.startContainer,e.startOffset),n.appendChild(o.extractContents());var a=document.createElement(r);i.insertAdjacentElement("afterend",a);var l=document.createRange();l.selectNodeContents(i),l.setStart(e.endContainer,e.endOffset),a.appendChild(l.extractContents());for(var c=i.parentElement;i.childNodes.length;)c.insertBefore(i.childNodes[0],i);return void i.remove()}}var h=this.inline.getClearedNodes();this.inline.setNodesStriked(h,r,s),this.selection.restore(),document.execCommand("strikethrough"),this.selection.saveInstant();for(var d,u=this.core.editor()[0].querySelectorAll('[style*="line-through"]'),p=0,f=u.length;p<f;p++)t=u[0],d=document.createElement("strike"),t.parentNode.insertBefore(d,t),d.appendChild(t),t.style.removeProperty("text-decoration");var g=this;this.core.editor().find("strike").each(function(){var t=g.utils.replaceToTag(this,r);g.inline.setParams(t[0],s);var e=t.find(r),i=t.parent(),n=i.parent();if(0!==n.length&&n[0].tagName.toLowerCase()===r&&n.html()==i[0].outerHTML)return t.replaceWith(function(){return m(this).contents()}),void n.replaceWith(function(){return m(this).contents()});0!==e.length&&g.inline.cleanInsideOrParent(e,s),i.html()==t[0].outerHTML&&g.inline.cleanInsideOrParent(i,s),g.detect.isFirefox()&&g.core.editor().find(r+":empty").remove()}),this.selection.restoreInstant()},cleanInsideOrParent:function(t,e){if(e)for(var i in e.data)this.inline.removeSpecificAttr(t,i,e.data[i])},getClearedNodes:function(){for(var t=this.selection.nodes(),e=[],i=t.length,n=0,r=0;r<i;r++)if(m(t[r]).hasClass("redactor-selection-marker")){n=r+2;break}for(r=0;r<i;r++)n<=r&&!this.utils.isBlockTag(t[r].tagName)&&e.push(t[r]);return e},isConvertableAttr:function(t,e,i){var n=m(t).attr(e);if(n)if("style"===e){for(var r=(i=m.trim(i).replace(/;$/,"")).split(";"),s=0,o=0;o<r.length;o++){var a,l=r[o].split(":"),c=m.trim(l[0]),h=m.trim(l[1]);-1!==c.search(/color/)?!(a=m(t).css(c))||a!==h&&this.utils.rgb2hex(a)!==h||s++:m(t).css(c)===h&&s++}if(s===r.length)return 1}else if(n===i)return 1;return 0},isConvertable:function(t,e,i,n){if(e===i){if(!n)return!0;var r=0;for(var s in n.data)r+=this.inline.isConvertableAttr(t,s,n.data[s]);if(r===Object.keys(n.data).length)return!0}return!1},setNodesStriked:function(t,e,i){for(var n=0;n<t.length;n++){var r=t[n].tagName?t[n].tagName.toLowerCase():void 0,s=t[n].parentNode,o=s&&s.tagName?s.tagName.toLowerCase():void 0;this.inline.isConvertable(s,o,e,i)&&m(s).replaceWith(function(){return m("<strike>").append(m(this).contents())}).attr("data-redactor-inline-converted"),this.inline.isConvertable(t[n],r,e,i)&&m(t[n]).replaceWith(function(){return m("<strike>").append(m(this).contents())})}},insertBreakpoint:function(t,e){var i=document.createElement("span");i.id="redactor-inline-breakpoint",i=this.insert.node(i);var n=this.utils.isEndOfElement(t)?"":"<"+e+">",r=(r=this.utils.getOuterHtml(t)).replace(/<span id="redactor-inline-breakpoint"><\/span>/i,"</"+e+">"+n),s=m(r);return m(t).replaceWith(s),n&&this.utils.cloneAttributes(t,s.last()),s.first()},insertInline:function(t){var e=document.createElement(t);return this.insert.node(e),this.caret.start(e),e},arrangeTag:function(t){var e=["b","bold","i","italic","underline","strikethrough","deleted","superscript","subscript"],i=["strong","strong","em","em","u","del","del","sup","sub"];t=t.toLowerCase();for(var n=0;n<e.length;n++)t===e[n]&&(t=i[n]);return t},getStyleParams:function(t){for(var e={},i=t.trim().replace(/;$/,"").split(";"),n=0;n<i.length;n++){var r=i[n].split(":");r&&(e[r[0].trim()]=r[1].trim())}return e},getParams:function(t,e,i){var n=!1,r="toggle";return"object"==typeof t?(n=t,r=void 0!==e?e:r):void 0!==t&&void 0!==e&&((n={})[t]=e,r=void 0!==i?i:r),!!n&&{func:r,data:n}},setParams:function(t,e){if(e)for(var i in e.data){var n=m(t);"style"===i?(t=this.inline[e.func+"Style"](e.data[i],t),n.attr("data-redactor-style-cache",n.attr("style"))):t="class"===i?this.inline[e.func+"Class"](e.data[i],t):"remove"===e.func?this.inline[e.func+"Attr"](i,t):this.inline[e.func+"Attr"](i,e.data[i],t),"style"===i&&"SPAN"===t.tagName&&n.attr("data-redactor-span",!0)}return t},eachInline:function(t,e){var i,n=void 0===t?this.selection.inlines():[t];if(n)for(var r=0;r<n.length;r++)i=e(n[r])[0];return i},replaceClass:function(e,t){return this.inline.eachInline(t,function(t){return m(t).removeAttr("class").addClass(e)})},toggleClass:function(e,t){return this.inline.eachInline(t,function(t){return m(t).toggleClass(e)})},addClass:function(e,t){return this.inline.eachInline(t,function(t){return m(t).addClass(e)})},removeClass:function(e,t){return this.inline.eachInline(t,function(t){return m(t).removeClass(e)})},removeAllClass:function(t){return this.inline.eachInline(t,function(t){return m(t).removeAttr("class")})},replaceAttr:function(e,t,i){return this.inline.eachInline(i,function(t){return m(t).removeAttr(e).attr(e.value)})},toggleAttr:function(e,t,i){return this.inline.eachInline(i,function(t){return m(t).attr(e)?m(t).removeAttr(e):m(t).attr(e.value)})},addAttr:function(e,i,t){return this.inline.eachInline(t,function(t){return m(t).attr(e,i)})},removeAttr:function(i,t){return this.inline.eachInline(t,function(t){var e=m(t);return e.removeAttr(i),"style"===i&&e.removeAttr("data-redactor-style-cache"),e})},removeAllAttr:function(t){return this.inline.eachInline(t,function(t){for(var e=m(t),i=t.attributes.length,n=0;n<i;n++)e.removeAttr(t.attributes[n].name);return e})},removeSpecificAttr:function(t,e,i){var n,r=m(t);"style"===e?(n=i.split(":")[0].trim(),r.css(n,""),this.utils.removeEmptyAttr(t,"style")&&r.removeAttr("data-redactor-style-cache")):r.removeAttr(e)[0]},hasParentStyle:function(t){var e=t.parent();return 1===e.length&&e[0].tagName===t[0].tagName&&e.html()===t[0].outerHTML&&e},addParentStyle:function(t){var e,i=this.inline.hasParentStyle(t);return i?(e=this.inline.getStyleParams(t.attr("style")),i.css(e),i.attr("data-redactor-style-cache",i.attr("style")),t.replaceWith(function(){return m(this).contents()})):t.attr("data-redactor-style-cache",t.attr("style")),t},replaceStyle:function(n,t){n=this.inline.getStyleParams(n);var r=this;return this.inline.eachInline(t,function(t){var e=m(t);e.removeAttr("style").css(n);var i=e.attr("style");return i&&e.attr("style",i.replace(/"/g,"'")),e=r.inline.addParentStyle(e)})},toggleStyle:function(o,t){o=this.inline.getStyleParams(o);var a=this;return this.inline.eachInline(t,function(t){var e=m(t);for(var i in o){var n=o[i],r=e.css(i);(r=a.utils.isRgb(r)?a.utils.rgb2hex(r):r.replace(/"/g,""))===(n=a.utils.isRgb(n)?a.utils.rgb2hex(n):n.replace(/"/g,""))?e.css(i,""):e.css(i,n)}var s=e.attr("style");return s&&e.attr("style",s.replace(/"/g,"'")),a.utils.removeEmptyAttr(t,"style")?e.removeAttr("data-redactor-style-cache"):e=a.inline.addParentStyle(e),e})},addStyle:function(n,t){n=this.inline.getStyleParams(n);var r=this;return this.inline.eachInline(t,function(t){var e=m(t);e.css(n);var i=e.attr("style");return i&&e.attr("style",i.replace(/"/g,"'")),e=r.inline.addParentStyle(e)})},removeStyle:function(n,t){n=this.inline.getStyleParams(n);var r=this;return this.inline.eachInline(t,function(t){var e=m(t);for(var i in n)e.css(i,"");return r.utils.removeEmptyAttr(t,"style")?e.removeAttr("data-redactor-style-cache"):e.attr("data-redactor-style-cache",e.attr("style")),e})},removeAllStyle:function(t){return this.inline.eachInline(t,function(t){return m(t).removeAttr("style").removeAttr("data-redactor-style-cache")})},removeStyleRule:function(t){var e=this.selection.parent(),i=this.selection.inlines();this.buffer.set(),e&&"SPAN"===e.tagName&&this.inline.removeStyleRuleAttr(m(e),t);for(var n=0;n<i.length;n++){var r=i[n],s=m(r);-1==m.inArray(r.tagName.toLowerCase(),this.opts.inlineTags)||s.hasClass("redactor-selection-marker")||this.inline.removeStyleRuleAttr(s,t)}},removeStyleRuleAttr:function(t,e){t.css(e,""),this.utils.removeEmptyAttr(t,"style")?t.removeAttr("data-redactor-style-cache"):t.attr("data-redactor-style-cache",t.attr("style"))},update:function(t,e,i,n){t=this.inline.arrangeTag(t);var r=this.inline.getParams(e,i,n),s=this.selection.inlines(),o=[];if(s)for(var a=0;a<s.length;a++){var l=s[a];"*"!==t&&l.tagName.toLowerCase()!==t||o.push(this.inline.setParams(l,r))}return o},removeFormat:function(){this.selection.save();for(var t=this.inline.getClearedNodes(),e=0;e<t.length;e++)1===t[e].nodeType&&m(t[e]).replaceWith(function(){return m(this).contents()});this.selection.restore()}}},insert:function(){return{set:function(t){this.code.set(t),this.focus.end()},html:function(t,e){this.core.editor().focus();var i=this.selection.block(),n=this.selection.inline();void 0===e&&(e=this.clean.getCurrentType(t,!0),t=this.clean.onPaste(t,e,!0)),t=m.parseHTML(t);var r,s,o,a=m(t).last(),l=this.selection.get(),c=this.selection.range(l);if(c.deleteContents(),this.selection.update(l,c),e.lists){var h=m(t);if(0!==h.length&&("UL"===h[0].tagName||"OL"===h[0].tagName))return void this.insert.appendLists(i,h)}e.blocks&&i?this.utils.isSelectAll()?(this.core.editor().html(t),this.focus.end()):!1===(r=this.utils.breakBlockTag())?this.insert.placeHtml(t):(m(t).children().last().append(this.marker.get()),"start"===r.type?r.$block.before(t):r.$block.after(t),this.selection.restore(),this.core.editor().find("p").each(function(){""===m.trim(this.innerHTML)&&m(this).remove()})):(n&&((s=m("<div/>").html(t)).find(n.tagName.toLowerCase()).each(function(){m(this).contents().unwrap()}),t=s.html(),t=m.parseHTML(t),a=m(t).last()),this.utils.isSelectAll()?(o=m(this.opts.emptyHtml),this.core.editor().html("").append(o),o.html(t),this.caret.end(o)):this.insert.placeHtml(t)),this.utils.disableSelectAll(),e.pre&&this.clean.cleanPre(),this.caret.end(a)},text:function(t){t=t.toString(),t=m.trim(t);var e,i,n,r,s,o=document.createElement("div");o.innerHTML=t,void 0!==(t=o.textContent||o.innerText)&&(this.core.editor().focus(),e=this.selection.blocks(),t=t.replace(/\n/g," "),this.utils.isSelectAll()?(i=m(this.opts.emptyHtml),this.core.editor().html("").append(i),i.html(t),this.caret.end(i)):(n=this.selection.get(),r=document.createTextNode(t),n.getRangeAt&&n.rangeCount&&((s=n.getRangeAt(0)).deleteContents(),s.insertNode(r),s.setStartAfter(r),s.collapse(!0),this.selection.update(n,s)),1<e.length&&(m(r).wrap("<p>"),this.caret.after(r))),this.utils.disableSelectAll(),this.clean.normalizeCurrentHeading())},raw:function(t){this.core.editor().focus();var e=this.selection.get(),i=this.selection.range(e);i.deleteContents();var n=document.createElement("div");n.innerHTML=t;for(var r,s,o=document.createDocumentFragment();r=n.firstChild;)s=o.appendChild(r);i.insertNode(o),s&&((i=i.cloneRange()).setStartAfter(s),i.collapse(!0),e.removeAllRanges(),e.addRange(i))},node:function(t,e){void 0!==this.start&&this.core.editor().focus(),t=t[0]||t;var i,n=this.selection.block(),r=this.utils.isBlockTag(t.tagName),s=!0;return this.utils.isSelectAll()?(r?this.core.editor().html(t):this.core.editor().html(m("<p>").html(t)),this.code.sync()):r&&n?!1===(i=this.utils.breakBlockTag())?this.insert.placeNode(t,e):("start"===i.type?i.$block.before(t):i.$block.after(t),this.core.editor().find("p:empty").remove()):s=this.insert.placeNode(t,e),this.utils.disableSelectAll(),s&&this.caret.end(t),t},appendLists:function(t,e){var i,n,r=m(t),s=this.utils.isEmpty(t.innerHTML);s||this.utils.isEndOfElement(t)?(i=r,e.find("li").each(function(){i.after(this),i=m(this)}),s&&r.remove()):this.utils.isStartOfElement(t)?e.find("li").each(function(){r.before(this),i=m(this)}):(n=this.selection.extractEndOfNode(t),r.after(m("<li>").append(n)),r.append(e),i=e),this.marker.remove(),i&&this.caret.end(i)},placeHtml:function(t){var e=document.createElement("span");e.id="redactor-insert-marker",e=this.insert.node(e),m(e).before(t),this.selection.restore(),this.caret.after(e),m(e).remove()},placeNode:function(t,e){var i=this.selection.get(),n=this.selection.range(i);if(null==n)return!1;!1!==e&&n.deleteContents(),n.insertNode(t),n.collapse(!1),this.selection.update(i,n)},nodeToPoint:function(t,e){if(e=e[0]||e,this.utils.isEmpty())return e=this.utils.isBlock(e)?e:m("<p />").append(e),this.core.editor().html(e),e;var i,n,r,s=t.clientX,o=t.clientY;return document.caretPositionFromPoint?(i=document.caretPositionFromPoint(s,o),(n=document.getSelection().getRangeAt(0)).setStart(i.offsetNode,i.offset),n.collapse(!0),n.insertNode(e)):document.caretRangeFromPoint?(n=document.caretRangeFromPoint(s,o)).insertNode(e):void 0!==document.body.createTextRange&&((n=document.body.createTextRange()).moveToPoint(s,o),(r=n.duplicate()).moveToPoint(s,o),n.setEndPoint("EndToEnd",r),n.select()),e},nodeToCaretPositionFromPoint:function(t,e){this.insert.nodeToPoint(t,e)},marker:function(){this.marker.insert()}}},keydown:function(){return{init:function(t){if(!this.rtePaste){var e=t.which,i=37<=e&&e<=40;if(this.keydown.ctrl=t.ctrlKey||t.metaKey,this.keydown.parent=this.selection.parent(),this.keydown.current=this.selection.current(),this.keydown.block=this.selection.block(),this.keydown.pre=this.utils.isTag(this.keydown.current,"pre"),this.keydown.blockquote=this.utils.isTag(this.keydown.current,"blockquote"),this.keydown.figcaption=this.utils.isTag(this.keydown.current,"figcaption"),this.keydown.figure=this.utils.isTag(this.keydown.current,"figure"),!1===this.core.callback("keydown",t))return t.preventDefault(),!1;if(this.shortcuts.init(t,e),this.keydown.checkEvents(i,e),this.keydown.setupBuffer(t,e),this.utils.isSelectAll()&&(e===this.keyCode.ENTER||e===this.keyCode.BACKSPACE||e===this.keyCode.DELETE))return t.preventDefault(),this.code.set(this.opts.emptyHtml),void this.events.changeHandler();if(this.keydown.addArrowsEvent(i),this.keydown.setupSelectAll(t,e),this.opts.enterKey||e!==this.keyCode.ENTER){if(this.opts.enterKey&&e===this.keyCode.DOWN&&this.keydown.onArrowDown(),this.opts.enterKey&&e===this.keyCode.UP&&this.keydown.onArrowUp(),("textarea"===this.opts.type||"div"===this.opts.type)&&this.keydown.current&&3===this.keydown.current.nodeType&&m(this.keydown.parent).hasClass("redactor-in")&&this.keydown.wrapToParagraph(),!this.keyup.lastShiftKey&&e===this.keyCode.SPACE&&(t.ctrlKey||t.shiftKey))return t.preventDefault(),this.keydown.onShiftSpace();if(e===this.keyCode.ENTER&&(t.ctrlKey||t.shiftKey)&&(null===h||"ios"!==h.platform()))return t.preventDefault(),this.keydown.onShiftEnter(t);if(e===this.keyCode.ENTER&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey)return this.keydown.onEnter(t);if(e===this.keyCode.TAB||t.metaKey&&221===e||t.metaKey&&219===e)return this.keydown.onTab(t,e);if(this.detect.isFirefox()&&e===this.keyCode.BACKSPACE&&this.keydown.block&&"P"===this.keydown.block.tagName&&this.utils.isStartOfElement(this.keydown.block))if(0!==(n=m(this.keydown.block).prev()).length)return t.preventDefault(),n.append(this.marker.get()),n.append(m(this.keydown.block).html()),m(this.keydown.block).remove(),void this.selection.restore();if(e===this.keyCode.BACKSPACE||e===this.keyCode.DELETE){if(this.observe.image&&void 0!==this.observe.image&&0!==m("#redactor-image-box").length){t.preventDefault();var n=this.observe.image.closest("figure, p").prev();return this.image.remove(!1),this.observe.image=!1,void(n&&0!==n.length?this.caret.end(n):this.core.editor().focus())}this.keydown.onBackspaceAndDeleteBefore()}if(e===this.keyCode.DELETE){var r=m(this.keydown.block).next();if(this.utils.isEndOfElement(this.keydown.block)&&0!==r.length&&"FIGURE"===r[0].tagName)return r.remove(),!1;if(!(!this.keydown.block||"LI"!==this.keydown.block.tagName)&&this.keydown.block){var s=m(this.keydown.block).parents("ul, ol").last(),o=s.next();if(this.utils.isRedactorParent(s)&&this.utils.isEndOfElement(s)&&0!==o.length&&("UL"===o[0].tagName||"OL"===o[0].tagName))return t.preventDefault(),s.append(o.contents()),o.remove(),!1}if(this.utils.isEndOfElement(this.keydown.block)&&0!==r.length&&"PRE"===r[0].tagName)return m(this.keydown.block).append(r.text()),r.remove(),!1}if(e===this.keyCode.DELETE&&0!==m("#redactor-image-box").length&&this.image.remove(),e===this.keyCode.BACKSPACE){if(this.detect.isFirefox()&&this.line.removeOnBackspace(t),this.list.combineAfterAndBefore(this.keydown.block))return void t.preventDefault();var a=this.selection.block();if(a&&"LI"===a.tagName&&this.utils.isCollapsed()&&this.utils.isStartOfElement())return this.indent.decrease(),void t.preventDefault();this.keydown.removeInvisibleSpace(),this.keydown.removeEmptyListInTable(t)}e!==this.keyCode.BACKSPACE&&e!==this.keyCode.DELETE||this.keydown.onBackspaceAndDeleteAfter(t)}else{t.preventDefault();var l=this.selection.get(),c=this.selection.range(l);c.collapsed||c.deleteContents()}}},onShiftSpace:function(){return this.buffer.set(),this.insert.raw("&nbsp;"),!1},onShiftEnter:function(t){return this.buffer.set(),this.keydown.pre?this.keydown.insertNewLine(t):this.insert.raw("<br>")},onBackspaceAndDeleteBefore:function(){this.utils.saveScroll()},onBackspaceAndDeleteAfter:function(e){setTimeout(m.proxy(function(){this.code.syncFire=!1,this.keydown.removeEmptyLists();var t="";0!==this.opts.keepStyleAttr.length&&(t=","+this.opts.keepStyleAttr.join(",")),this.core.editor().find("*[style]").not("img, figure, iframe, #redactor-image-box, #redactor-image-editter, [data-redactor-style-cache], [data-redactor-span]"+t).removeAttr("style"),this.keydown.formatEmpty(e),this.code.syncFire=!0},this),1)},onEnter:function(t){if(!1===this.core.callback("enter",t))return t.preventDefault(),!1;if(this.keydown.blockquote&&!0===this.keydown.exitFromBlockquote(t))return!1;if(this.keydown.pre)return this.keydown.insertNewLine(t);if(this.keydown.blockquote||this.keydown.figcaption)return this.keydown.insertBreakLine(t);if(this.keydown.figure)setTimeout(m.proxy(function(){this.keydown.replaceToParagraph("FIGURE")},this),1);else if(this.keydown.block){if(setTimeout(m.proxy(function(){this.keydown.replaceToParagraph("DIV")},this),1),"LI"===this.keydown.block.tagName){var e=this.selection.current(),i=m(e).closest("li",this.$editor[0]),n=i.parents("ul,ol",this.$editor[0]).last();if(0!==i.length&&this.utils.isEmpty(i.html())&&0===n.next().length&&this.utils.isEmpty(n.find("li").last().html())){n.find("li").last().remove();var r=m(this.opts.emptyHtml);return n.after(r),this.caret.start(r),!1}}}else if(!this.keydown.block)return this.keydown.insertParagraph(t);this.detect.isFirefox()&&this.utils.isInline(this.keydown.parent)?this.keydown.insertBreakLine(t):this.opts.keepInlineOnEnter||setTimeout(m.proxy(function(){var t,e,i,n,r=this.selection.inline();r&&this.utils.isEmpty(r.innerHTML)&&(t=this.selection.block(),m(r).remove(),(e=document.createRange()).setStart(t,0),i=document.createTextNode("​"),e.insertNode(i),e.setStartAfter(i),e.collapse(!0),(n=window.getSelection()).removeAllRanges(),n.addRange(e))},this),1)},checkEvents:function(t,e){t||"click"!==this.core.getEvent()&&"arrow"!==this.core.getEvent()||(this.core.addEvent(!1),this.keydown.checkKeyEvents(e)&&this.buffer.set())},checkKeyEvents:function(t){var e=this.keyCode,i=[e.BACKSPACE,e.DELETE,e.ENTER,e.ESC,e.TAB,e.CTRL,e.META,e.ALT,e.SHIFT];return-1===m.inArray(t,i)},addArrowsEvent:function(t){t&&("click"!==this.core.getEvent()&&"arrow"!==this.core.getEvent()?this.core.addEvent("arrow"):this.core.addEvent(!1))},setupBuffer:function(t,e){return this.keydown.ctrl&&90===e&&!t.shiftKey&&!t.altKey&&this.sBuffer.length?(t.preventDefault(),void this.buffer.undo()):this.keydown.ctrl&&90===e&&t.shiftKey&&!t.altKey&&0!==this.sRebuffer.length?(t.preventDefault(),void this.buffer.redo()):void(this.keydown.ctrl||e!==this.keyCode.SPACE&&e!==this.keyCode.BACKSPACE&&e!==this.keyCode.DELETE&&(e!==this.keyCode.ENTER||t.ctrlKey||t.shiftKey)||this.buffer.set())},exitFromBlockquote:function(t){if(this.utils.isEndOfElement(this.keydown.blockquote)&&-1!==this.clean.removeSpacesHard(m(this.keydown.blockquote).html()).search(/(<br\s?\/?>){1}$/i)){t.preventDefault(),m(this.keydown.blockquote).children().last().filter("br").remove(),m(this.keydown.blockquote).children().last().filter("span").remove();var e=m(this.opts.emptyHtml);return m(this.keydown.blockquote).after(e),this.caret.start(e),!0}},onArrowDown:function(){for(var t=[this.keydown.blockquote,this.keydown.pre,this.keydown.figcaption],e=0;e<t.length;e++)if(t[e])return this.keydown.insertAfterLastElement(t[e]),!1},onArrowUp:function(){for(var t=[this.keydown.blockquote,this.keydown.pre,this.keydown.figcaption],e=0;e<t.length;e++)if(t[e])return this.keydown.insertBeforeFirstElement(t[e]),!1},insertAfterLastElement:function(t){var e,i;this.utils.isEndOfElement(t)&&(e=this.core.editor().contents().last(),0===("FIGCAPTION"===t.tagName?m(this.keydown.block).parent().next():m(this.keydown.block).next()).length&&(0!==e.length||e[0]===t?(i=m(this.opts.emptyHtml),"FIGCAPTION"===t.tagName?m(t).parent().after(i):m(t).after(i),this.caret.start(i)):this.caret.start(e)))},insertBeforeFirstElement:function(t){var e;this.utils.isStartOfElement()&&(1<this.core.editor().contents().length&&this.core.editor().contents().first()[0]!==t||(e=m(this.opts.emptyHtml),m(t).before(e),this.caret.start(e)))},onTab:function(t,e){if(!this.opts.tabKey)return!0;var i=this.keydown.block&&"LI"===this.keydown.block.tagName;if(this.utils.isEmpty(this.code.get())||!i&&!this.keydown.pre&&!1===this.opts.tabAsSpaces)return!0;t.preventDefault(),this.buffer.set();var n,r=i&&this.utils.isStartOfElement(this.keydown.block);return this.keydown.pre&&!t.shiftKey?(n=this.opts.preSpaces?document.createTextNode(Array(this.opts.preSpaces+1).join(" ")):document.createTextNode("\t"),this.insert.node(n)):!1===this.opts.tabAsSpaces||r?t.metaKey&&219===e||(!t.metaKey||221!==e)&&t.shiftKey?this.indent.decrease():this.indent.increase():(n=document.createTextNode(Array(this.opts.tabAsSpaces+1).join(" ")),this.insert.node(n)),!1},setupSelectAll:function(t,e){this.keydown.ctrl&&65===e?this.utils.enableSelectAll():e===this.keyCode.LEFT_WIN||this.keydown.ctrl||this.utils.disableSelectAll()},insertNewLine:function(t){t.preventDefault();var e=document.createTextNode("\n"),i=this.selection.get(),n=this.selection.range(i);return n.deleteContents(),n.insertNode(e),this.caret.after(e),!1},insertParagraph:function(t){t.preventDefault();var e=document.createElement("p");e.innerHTML="<br>";var i=this.selection.get(),n=this.selection.range(i);return n.deleteContents(),n.insertNode(e),this.caret.start(e),!1},insertBreakLine:function(t){return this.keydown.insertBreakLineProcessing(t)},insertDblBreakLine:function(t){return this.keydown.insertBreakLineProcessing(t,!0)},insertBreakLineProcessing:function(t,e){t.stopPropagation();var i,n=document.createElement("br");return this.insert.node(n),!0===e?(i=document.createElement("br"),this.insert.node(i),this.caret.after(i)):this.caret.after(n),!1},wrapToParagraph:function(){var t=m(this.keydown.current),e=m("<p>").append(t.clone());t.replaceWith(e);var i=m(e).next();void 0!==i[0]&&"BR"===i[0].tagName&&i.remove(),this.caret.end(e)},replaceToParagraph:function(t){var i=this.selection.block(),e=m(i).prev(),n=i.innerHTML.replace(/<br\s?\/?>/gi,"");if(i.tagName===t&&this.utils.isEmpty(n)&&!m(i).hasClass("redactor-in")){var r=document.createElement("p");return m(i).replaceWith(r),this.keydown.setCaretToParagraph(r),!1}if("P"===i.tagName)return m(i).removeAttr("class").removeAttr("style"),this.detect.isIe()&&this.utils.isEmpty(n)&&this.utils.isInline(this.keydown.parent)&&m(i).on("input",m.proxy(function(){var t,e=this.selection.parent();this.utils.isInline(e)&&(t=m(e).html(),m(i).html(t),this.caret.end(i)),m(i).off("keyup")},this)),!1;if(e.hasClass(this.opts.videoContainerClass)){e.removeAttr("class");r=document.createElement("p");return e.replaceWith(r),this.keydown.setCaretToParagraph(r),!1}},setCaretToParagraph:function(t){var e=document.createRange();e.setStart(t,0);var i=document.createTextNode("​");e.insertNode(i),e.setStartAfter(i),e.collapse(!0);var n=window.getSelection();n.removeAllRanges(),n.addRange(e)},removeInvisibleSpace:function(){var t=m(this.keydown.current);0===t.text().search(/^\u200B$/g)&&t.remove()},removeEmptyListInTable:function(t){var e=m(this.keydown.current),i=m(this.keydown.parent),n=e.closest("td",this.$editor[0]);if(0!==n.length&&e.closest("li",this.$editor[0])&&1===i.children("li").length){if(!this.utils.isEmpty(e.text()))return;t.preventDefault(),e.remove(),i.remove(),this.caret.start(n)}},removeEmptyLists:function(){function t(){""===m.trim(this.innerHTML).replace(/\/t\/n/g,"")&&m(this).remove()}this.core.editor().find("li").each(t),this.core.editor().find("ul, ol").each(t)},formatEmpty:function(t){var e,i=m.trim(this.core.editor().html());if(this.utils.isEmpty(i))return t.preventDefault(),"inline"===this.opts.type||"pre"===this.opts.type?(this.core.editor().html(this.marker.html()),this.selection.restore()):(e=function(){this.core.editor().html(this.opts.emptyHtml),this.focus.start()}.bind(this),null!==h&&"ios"===h.platform()?setTimeout(e,50):e()),!1}}},keyup:function(){return{init:function(t){if(!this.rtePaste){var e,i=t.which;if(this.keyup.block=this.selection.block(),this.keyup.current=this.selection.current(),this.keyup.parent=this.selection.parent(),this.keyup.lastShiftKey=t.shiftKey,!1===this.core.callback("keyup",t))return t.preventDefault(),!1;if(i===this.keyCode.ENTER&&this.keyup.block&&"FIGURE"===this.keyup.block.tagName){var n=m(this.keyup.block).prev();if(0!==n.length&&"FIGURE"===n[0].tagName){var r=this.utils.replaceToTag(n,"p");return void this.caret.start(r)}}if(i===this.keyCode.BACKSPACE||i===this.keyCode.DELETE){if(this.utils.isSelectAll())return void this.focus.start();if(this.keyup.block&&this.keydown.block&&"FIGURE"===this.keyup.block.tagName&&this.utils.isStartOfElement(this.keydown.block)){t.preventDefault(),this.selection.save(),m(this.keyup.block).find("figcaption").remove(),m(this.keyup.block).find("img").first().remove(),this.utils.replaceToTag(this.keyup.block,"p");var s=this.marker.find();return m("html, body").animate({scrollTop:s.position().top+20},500),void this.selection.restore()}this.keyup.block&&"P"===this.keyup.block.tagName&&(e=m(this.keyup.block).find("img").length,""===m(this.keyup.block).text().replace(/\u200B/g,"")&&0!==e&&this.utils.replaceToTag(this.keyup.block,"figure")),this.keyup.block&&"FIGURE"===this.keyup.block.tagName&&0===m(this.keyup.block).find("img").length&&(this.selection.save(),this.utils.replaceToTag(this.keyup.block,"p"),this.selection.restore())}}}}},lang:function(){return{load:function(){this.opts.curLang=this.opts.langs[this.opts.lang]},get:function(t){return void 0!==this.opts.curLang[t]?this.opts.curLang[t]:""}}},line:function(){return{insert:function(){this.buffer.set(),this.insert.html(this.line.getLineHtml());var t=this.core.editor().find("#redactor-hr-tmp-id");return t.removeAttr("id"),this.core.callback("insertedLine",t),t},getLineHtml:function(){var t='<hr id="redactor-hr-tmp-id" />';return!this.detect.isFirefox()&&this.utils.isEmpty()&&(t+="<p>"+this.opts.emptyHtml+"</p>"),t},removeOnBackspace:function(t){var e,i;this.utils.isCollapsed()&&(0===(e=m(this.selection.block())).length||!this.utils.isStartOfElement(e)||(i=e.prev())&&0!==i.length&&"HR"===i[0].tagName&&(t.preventDefault(),i.remove()))}}},link:function(){return{get:function(){return m(this.selection.inlines("a"))},is:function(){var t=this.selection.nodes(),e=m(this.selection.current()).closest("a",this.core.editor()[0]);return!(0===e.length||1<t.length)&&e},unlink:function(t){void 0!==t&&t.preventDefault&&t.preventDefault(),this.buffer.set();var e,i=this.selection.inlines("a");0!==i.length&&(e=this.link.replaceLinksToText(i),this.observe.closeAllTooltip(),this.core.callback("deletedLink",e))},insert:function(t,e){var i,n=this.link.is();return(!0===e||!1!==(t=this.link.buildLinkFromObject(n,t)))&&(this.buffer.set(),t=this.core.callback("beforeInsertingLink",t),!1===n?(n=m("<a />"),n=this.link.update(n,t),i=(n=m(this.insert.node(n))).parent(),!1===this.utils.isRedactorParent(i)&&n.wrap("<p>"),i.hasClass("redactor-unlink")&&i.replaceWith(function(){return m(this).contents()}),this.caret.after(n),this.core.callback("insertedLink",n)):(n=this.link.update(n,t),this.caret.after(n)),n)},update:function(t,e){return t.text(e.text),t.attr("href",e.url),this.link.target(t,e.target),t},target:function(t,e){return e?t.attr("target","_blank"):t.removeAttr("target")},show:function(t){void 0!==t&&t.preventDefault&&t.preventDefault(),this.observe.closeAllTooltip();var e=this.link.is();this.link.buildModal(e);var i=this.link.buildLinkFromElement(e);i.url=this.link.removeSelfHostFromUrl(i.url),this.opts.linkNewTab&&!e&&(i.target=!0),this.link.setModalValues(i),this.modal.show(),this.detect.isDesktop()&&m("#redactor-link-url").focus()},setModalValues:function(t){m("#redactor-link-blank").prop("checked",t.target),m("#redactor-link-url").val(t.url),m("#redactor-link-url-text").val(t.text)},buildModal:function(t){this.modal.load("link",this.lang.get(!1===t?"link-insert":"link-edit"),600),this.modal.getActionButton().text(this.lang.get(!1===t?"insert":"save")).on("click",m.proxy(this.link.callback,this))},callback:function(){var t=this.link.buildLinkFromModal();if(!1===t)return!1;this.modal.close(),this.link.insert(t,!0)},cleanUrl:function(t){return void 0===t?"":m.trim(t.replace(/[^\W\w\D\d+&\'@#/%?=~_|!:,.;\(\)]/gi,""))},cleanText:function(t){return void 0===t?"":m.trim(t.replace(/(<([^>]+)>)/gi,""))},getText:function(t){return""===t.text&&""!==t.url?this.link.truncateUrl(t.url.replace(/<|>/g,"")):t.text},isUrl:function(t){return!!new RegExp("^((https?|ftp):\\/\\/)?(([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(t)&&t},isMailto:function(t){return-1!==t.search("@")&&!1===/(http|ftp|https):\/\//i.test(t)},isEmpty:function(t){return""===t.url||""===t.text&&""===t.url},truncateUrl:function(t){return t.length>this.opts.linkSize?t.substring(0,this.opts.linkSize)+"...":t},parse:function(t){return this.link.isMailto(t.url)?t.url="mailto:"+t.url.replace("mailto:",""):0!==t.url.search("#")&&this.opts.linkValidation&&(t.url=this.link.isUrl(t.url)?"http://"+t.url.replace(/(ftp|https?):\/\//gi,""):t.url),!this.link.isEmpty(t)&&!1!==t.url&&t},buildLinkFromModal:function(){var t={};return t.url=this.link.cleanUrl(m("#redactor-link-url").val()),t.text=this.link.cleanText(m("#redactor-link-url-text").val()),t.text=this.link.getText(t),t.target=!!m("#redactor-link-blank").prop("checked"),this.link.parse(t)},buildLinkFromObject:function(t,e){return e.url=this.link.cleanUrl(e.url),e.text=void 0===e.text&&this.selection.is()?this.selection.text():this.link.cleanText(e.text),e.text=this.link.getText(e),e.target=!1===t?e.target:this.link.buildTarget(t),this.link.parse(e)},buildLinkFromElement:function(t){var e={url:"",text:this.selection.is()?this.selection.text():"",target:!1};return!1!==t&&(e.url=t.attr("href"),e.text=t.text(),e.target=this.link.buildTarget(t)),e},buildTarget:function(t){return void 0!==t.attr("target")&&"_blank"===t.attr("target")},removeSelfHostFromUrl:function(t){var e=self.location.href.replace("#","").replace(/\/$/i,"");return t.replace(/^\/\#/,"#").replace(e,"").replace("mailto:","")},replaceLinksToText:function(t){var r,e=m.each(t,function(t,e){var i=m(e),n=m('<span class="redactor-unlink" />').append(i.contents());return i.replaceWith(n),0===t&&(r=n),i});return 1===t.length&&this.selection.isCollapsed()&&this.caret.after(r),e}}},linkify:function(){return{isKey:function(){},isLink:function(){},isFiltered:function(){},handler:function(){},format:function(){},convertVideoLinks:function(){},convertImages:function(){},convertLinks:function(){}}},list:function(){return{toggle:function(t){if(!this.utils.inBlocks(["table","td","th","tr"])){t=(t="unorderedlist"===(t="orderedlist"===t?"ol":t)?"ul":t).toLowerCase(),this.buffer.set(),this.selection.save();var e=this.list._getBlocks(),i=this.selection.block(),n=m(i).parents("ul, ol").last();return 0===e.length&&0!==n.length&&(e=[n.get(0)]),e=this.list._isUnformat(t,e)?this.list._unformat(t,e):this.list._format(t,e),this.selection.restore(),e}},get:function(){var t=this.selection.current(),e=m(t).closest("ul, ol",this.core.editor()[0]);return 0!==e.length&&e},combineAfterAndBefore:function(t){var e=m(t).prev(),i=m(t).next(),n=t&&"P"===t.tagName&&("<br>"===t.innerHTML||""===t.innerHTML),r=1===e.closest("ol, ul",this.core.editor()[0]).length&&1===i.closest("ol, ul",this.core.editor()[0]).length;return!(!n||!r)&&(e.children("li").last().append(this.marker.get()),e.append(i.contents()),this.selection.restore(),!0)},_getBlocks:function(){for(var t=[],e=this.selection.blocks(),i=0;i<e.length;i++){m(e[i]).parent().hasClass("redactor-in")&&t.push(e[i])}return t},_isUnformat:function(t,e){for(var i,n=0,r=0;r<e.length;r++){3!==e[r].nodeType&&((i=e[r].tagName.toLowerCase())!==t&&"figure"!==i||n++)}return n===e.length},_uniteBlocks:function(t,e){for(var i=0,n={0:[]},r=!1,s=0;s<t.length;s++){var o=m(t[s]).closest("th, td");0!==o.length?(o.get(0)!==r&&(n[++i]=[]),this.list._isUniteBlock(t[s],e)&&n[i].push(t[s])):this.list._isUniteBlock(t[s],e)?n[i].push(t[s]):n[++i]=[],r=o.get()}return n},_isUniteBlock:function(t,e){return 3===t.nodeType||-1!==e.indexOf(t.tagName.toLowerCase())},_createList:function(t,e,i){var n=e[e.length-1],r=m(n),s=m("<"+t+">");return r.after(s),s},_createListItem:function(t){var e,i=m("<li>");return 3===t.nodeType?i.append(t):(e=m(t),i.append(e.contents()),e.remove()),i},_format:function(t,e){var i=this.list._uniteBlocks(e,["p","div","blockquote","pre","h1","h2","h3","h4","h5","h6","ul","ol"]),n=[];for(var r in i){for(var s=i[r],o=this.list._createList(t,i[r]),a=0;a<s.length;a++){var l=3===s[a].nodeType||"UL"!==s[a].tagName&&"OL"!==s[a].tagName?this.list._createListItem(s[a]):m(s[a]).contents();o.append(l)}n.push(o.get(0))}return n},_unformat:function(t,e){if(1===e.length){var i=m(e[0]),n=i.find("li"),r=this.selection.blocks(["li"]),s=this.selection.block(),o=m(s).closest("li");if(0===r.length&&0!==o.length&&(r=[o.get(0)]),r.length===n.length)return this.list._unformatEntire(e[0]);var a=this.list._getItemsPosition(n,r);if("Top"===a)return this.list._unformatAtSide("before",r,i);if("Bottom"===a)return r.reverse(),this.list._unformatAtSide("after",r,i);if("Middle"===a){var l=m(r[r.length-1]),c=!1,h=!1,d=m("<"+i.get(0).tagName.toLowerCase()+">");n.each(function(t,e){var i;c&&((i=m(e)).children("ul, ol").length,0!==i.closest(".redactor-split-item").length||!1!==h&&0!==i.closest(h).length||i.addClass("redactor-split-item"),h=i),e===l.get(0)&&(c=!0)}),n.filter(".redactor-split-item").each(function(t,e){m(e).removeClass("redactor-split-item"),d.append(e)}),i.after(d),r.reverse();for(var u=0;u<r.length;u++){var p=m(r[u]),f=this.list._createUnformatContainer(p);i.after(f),f.find("ul, ol").remove(),p.remove()}return}}else for(u=0;u<e.length;u++)3!==e[u].nodeType&&e[u].tagName.toLowerCase()===t&&this.list._unformatEntire(e[u])},_unformatEntire:function(t){var r=m(t);r.find("li").each(function(t,e){var i=m(e),n=this.list._createUnformatContainer(i);i.remove(),r.before(n)}.bind(this)),r.remove()},_unformatAtSide:function(t,r,e){for(var i=0;i<r.length;i++){var n=m(r[i]),s=this.list._createUnformatContainer(n);e[t](s);var o=s.find("ul, ol").first();n.append(o),o.each(function(t,e){var i=m(e),n=i.closest("li");n.get(0)===r[t]&&(i.unwrap(),n.addClass("r-unwrapped"))}),this.utils.isEmpty(n.html())&&n.remove()}e.find(".r-unwrapped").each(function(t){var e=m(t);""===e.html().trim()?e.remove():e.removeClass("r-unwrapped")})},_getItemsPosition:function(t,e){var i="Middle",n=e[0],r=e[e.length-1],s=t.first().get(0),o=t.last().get(0);return s===n&&o!==r?i="Top":s!==n&&o===r&&(i="Bottom"),i},_createUnformatContainer:function(t){var e=m("<p>");return e.append(t.contents()),e}}},marker:function(){return{get:function(t){t=void 0===t?1:t;var e=document.createElement("span");return e.id="selection-marker-"+t,e.className="redactor-selection-marker",e.innerHTML=this.opts.invisibleSpace,e},html:function(t){return this.utils.getOuterHtml(this.marker.get(t))},find:function(t){return t=void 0===t?1:t,this.core.editor().find("span#selection-marker-"+t)},insert:function(){var t=this.selection.get(),e=this.selection.range(t);this.marker.insertNode(e,this.marker.get(1),!0),e&&!1===e.collapsed&&this.marker.insertNode(e,this.marker.get(2),!1)},remove:function(){this.core.editor().find(".redactor-selection-marker").each(this.marker.iterateRemove)},insertNode:function(t,e,i){var n=this.selection.parent();if(null!==t&&0!==m(n).closest(".redactor-in").length){t=t.cloneRange();try{t.collapse(i),t.insertNode(e)}catch(t){this.focus.start()}}},iterateRemove:function(t,e){var i=m(e),n=i.text().replace(/\u200B/g,"");i.parent()[0];""===n?i.remove():i.replaceWith(function(){return m(this).contents()})}}},modal:function(){return{callbacks:{},templates:function(){this.opts.modal={"image-edit":"",image:"",file:"",link:String()+'<div class="redactor-modal-tab" data-title="General"><section><label>URL</label><input type="url" id="redactor-link-url" aria-label="URL" /></section><section><label>'+this.lang.get("text")+'</label><input type="text" id="redactor-link-url-text" aria-label="'+this.lang.get("text")+'" /></section><section><label class="checkbox"><input type="checkbox" id="redactor-link-blank"> '+this.lang.get("link-in-new-tab")+'</label></section><section><button id="redactor-modal-button-action">'+this.lang.get("insert")+'</button><button id="redactor-modal-button-cancel">'+this.lang.get("cancel")+"</button></section></div>"},m.extend(this.opts,this.opts.modal)},addCallback:function(t,e){this.modal.callbacks[t]=e},addTemplate:function(t,e){this.opts.modal[t]=e},getTemplate:function(t){return this.opts.modal[t]},getModal:function(){return this.$modalBody},getActionButton:function(){return this.$modalBody.find("#redactor-modal-button-action")},getCancelButton:function(){return this.$modalBody.find("#redactor-modal-button-cancel")},getDeleteButton:function(){return this.$modalBody.find("#redactor-modal-button-delete")},load:function(){},show:function(){},buildWidth:function(){},buildTabber:function(){},showTab:function(){},setTitle:function(){},setContent:function(){this.$modalBody.html(this.modal.getTemplate(this.modal.templateName)),this.modal.getCancelButton().on("mousedown",m.proxy(this.modal.close,this))},setDraggable:function(){},setEnter:function(){},build:function(){this.modal.buildOverlay(),this.$modalBox=m('<div id="redactor-modal-box"/>').hide(),this.$modal=m('<div id="redactor-modal" role="dialog" />'),this.$modalHeader=m('<div id="redactor-modal-header" />'),this.$modalClose=m('<button type="button" id="redactor-modal-close" aria-label="'+this.lang.get("close")+'" />').html("&times;"),this.$modalBody=m('<div id="redactor-modal-body" />'),this.$modal.append(this.$modalHeader),this.$modal.append(this.$modalBody),this.$modal.append(this.$modalClose),this.$modalBox.append(this.$modal),this.$modalBox.appendTo(document.body)},buildOverlay:function(){this.$modalOverlay=m('<div id="redactor-modal-overlay">').hide(),m("body").prepend(this.$modalOverlay)},enableEvents:function(){},disableEvents:function(){},closeHandler:function(){},close:function(){}}},observe:function(){return{load:function(){void 0===this.opts.destroyed&&(this.observe.links(),this.observe.images())},isCurrent:function(t,e){return void 0===e&&(e=m(this.selection.current())),e.is(t)||0<e.parents(t).length},toolbar:function(){this.observe.buttons(),this.observe.dropdowns()},buttons:function(t,e){var r=this.selection.current(),s=this.selection.parent();!1!==t?this.button.setInactiveAll():this.button.setInactiveAll(e),!1!==t||"html"===e?this.utils.isRedactorParent(r)&&("none"!==this.core.editor().css("display")&&(this.utils.isCurrentOrParentHeader()||this.utils.isCurrentOrParent(["table","pre","blockquote","li"])?this.button.disable("horizontalrule"):this.button.enable("horizontalrule")),m.each(this.opts.activeButtonsStates,m.proxy(function(t,e){var i=m(s).closest(t,this.$editor[0]),n=m(r).closest(t,this.$editor[0]);(0===i.length||this.utils.isRedactorParent(i))&&this.utils.isRedactorParent(n)&&(0===i.length&&0===n.closest(t,this.$editor[0]).length||this.button.setActive(e))},this))):-1!==m.inArray(e,this.opts.activeButtons)&&this.button.toggleActive(e)},dropdowns:function(){var a=m("<div />").html(this.selection.html()).find("a").length,l=m(this.selection.current()),c=this.utils.isRedactorParent(l);m.each(this.opts.observe.dropdowns,m.proxy(function(t,e){var i=e.observe,n=i.element,r=e.item,s=void 0!==i.in&&i.in,o=void 0!==i.out&&i.out;0<l.closest(n).length&&c||"a"===n&&0!==a?this.observe.setDropdownProperties(r,s,o):this.observe.setDropdownProperties(r,o,s)},this))},setDropdownProperties:function(t,e,i){i&&void 0!==i.attr&&this.observe.setDropdownAttr(t,i.attr,!0),void 0!==e.attr&&this.observe.setDropdownAttr(t,e.attr),void 0!==e.title&&t.find("span").text(e.title)},setDropdownAttr:function(i,t,n){m.each(t,function(t,e){"class"===t?n?i.removeClass(e):i.addClass(e):n?i.removeAttr(t):i.attr(t,e)})},addDropdown:function(t,e,i){void 0!==i.observe&&(i.item=t,this.opts.observe.dropdowns.push(i))},images:function(){this.opts.imageEditable&&(this.core.editor().addClass("redactor-layer-img-edit"),this.core.editor().find("img").each(m.proxy(function(t,e){var i=m(e);i.closest("a",this.$editor[0]).on("click",function(t){t.preventDefault()}),this.image.setEditable(i)},this)))},links:function(){this.opts.linkTooltip&&this.core.editor().find("a").each(m.proxy(function(t,e){var i=m(e);!0!==i.data("cached")&&(i.data("cached",!0),i.on("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,m.proxy(this.observe.showTooltip,this)))},this))},getTooltipPosition:function(t){return t.offset()},showTooltip:function(t){var e,i,n,r,s,o,a,l,c,h,d=m(t.target);"IMG"!==d[0].tagName&&("A"!==d[0].tagName&&(d=d.closest("a",this.$editor[0])),"A"===d[0].tagName&&(e=d,i=this.observe.getTooltipPosition(e),n=m('<span class="redactor-link-tooltip"></span>'),void 0===(r=e.attr("href"))&&(r=""),24<r.length&&(r=r.substring(0,24)+"..."),s=m('<a href="'+e.attr("href")+'" target="_blank" />').html(r).addClass("redactor-link-tooltip-action"),o=m('<a href="#" />').html(this.lang.get("edit")).on("click",m.proxy(this.link.show,this)).addClass("redactor-link-tooltip-action"),a=m('<a href="#" />').html(this.lang.get("unlink")).on("click",m.proxy(this.link.unlink,this)).addClass("redactor-link-tooltip-action"),n.append(s).append(" | ").append(o).append(" | ").append(a),l=parseInt(e.css("line-height"),10),c=Math.ceil((t.pageY-i.top)/l),h=i.top+c*l,n.css({top:h+"px",left:i.left+"px"}),m(".redactor-link-tooltip").remove(),m("body").append(n),this.core.editor().on("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,m.proxy(this.observe.closeTooltip,this)),m(document).on("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,m.proxy(this.observe.closeTooltip,this))))},closeAllTooltip:function(){m(".redactor-link-tooltip").remove()},closeTooltip:function(t){var e=(t=t.originalEvent||t).target,i=m(e).closest("a",this.$editor[0]);0!==i.length&&"A"===i[0].tagName&&"A"!==e.tagName||"A"===e.tagName&&this.utils.isRedactorParent(e)||m(e).hasClass("redactor-link-tooltip-action")||(this.observe.closeAllTooltip(),this.core.editor().off("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,m.proxy(this.observe.closeTooltip,this)),m(document).off("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,m.proxy(this.observe.closeTooltip,this)))}}},offset:function(){return{get:function(t){var e=this.offset.clone(t);if(!1===e)return 0;var i=document.createElement("div");return i.appendChild(e.cloneContents()),i.innerHTML=i.innerHTML.replace(/<img(.*?[^>])>$/gi,"i"),m.trim(m(i).text()).replace(/[\t\n\r\n]/g,"").replace(/\u200B/g,"").length},clone:function(t){var e=this.selection.get(),i=this.selection.range(e);if(null===i&&void 0===t)return!1;if(!1===(t=void 0===t?this.$editor:t))return!1;t=t[0]||t;var n=i.cloneRange();return n.selectNodeContents(t),n.setEnd(i.endContainer,i.endOffset),n},set:function(t,e){e=void 0===e?t:e,this.focus.is()||this.focus.start();for(var i,n=this.selection.get(),r=this.selection.range(n),s=0,o=document.createTreeWalker(this.$editor[0],NodeFilter.SHOW_TEXT,null,null);null!==(i=o.nextNode());)if(t<(s+=i.nodeValue.length)&&(r.setStart(i,i.nodeValue.length+t-s),t=1/0),e<=s){r.setEnd(i,i.nodeValue.length+e-s);break}r.collapse(!1),this.selection.update(n,r)}}},paragraphize:function(){return{load:function(t){return!1===this.opts.paragraphize||"inline"===this.opts.type||"pre"===this.opts.type?t:""===t||"<p></p>"===t?this.opts.emptyHtml:(t+="\n",this.paragraphize.safes=[],this.paragraphize.z=0,t=(t=(t=t.replace(/(<br\s?\/?>){1,}\n?<\/blockquote>/gi,"</blockquote>")).replace(/<\/pre>/gi,"</pre>\n\n")).replace(/<p>\s<br><\/p>/gi,"<p></p>"),t=(t=this.paragraphize.getSafes(t)).replace("<br>","\n"),t=this.paragraphize.convert(t),t=this.paragraphize.clear(t),t=(t=this.paragraphize.restoreSafes(t)).replace(new RegExp("<br\\s?/?>\n?<("+this.opts.paragraphizeBlocks.join("|")+")(.*?[^>])>","gi"),"<p><br /></p>\n<$1$2>"),m.trim(t))},getSafes:function(t){var e=m("<div />").append(t);return e.find("blockquote p").replaceWith(function(){return m(this).append("<br />").contents()}),e.find(this.opts.paragraphizeBlocks.join(", ")).each(m.proxy(function(t,e){return this.paragraphize.z++,this.paragraphize.safes[this.paragraphize.z]=e.outerHTML,m(e).replaceWith("\n#####replace"+this.paragraphize.z+"#####\n\n")},this)),e.find("span.redactor-selection-marker").each(m.proxy(function(t,e){return this.paragraphize.z++,this.paragraphize.safes[this.paragraphize.z]=e.outerHTML,m(e).replaceWith("\n#####replace"+this.paragraphize.z+"#####\n\n")},this)),e.html()},restoreSafes:function(i){return m.each(this.paragraphize.safes,function(t,e){e=void 0!==e?e.replace(/\$/g,"&#36;"):e,i=i.replace("#####replace"+t+"#####",e)}),i},convert:function(t){t=(t=(t=(t=t.replace(/\r\n/g,"xparagraphmarkerz")).replace(/\n/g,"xparagraphmarkerz")).replace(/\r/g,"xparagraphmarkerz")).replace(/\s+/g," ");return t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t="<p>"+(t=(t=(t=m.trim(t)).replace(/xparagraphmarkerzxparagraphmarkerz/gi,"</p><p>")).replace(/xparagraphmarkerz/gi,"<br>"))+"</p>").replace("<p></p>","")).replace("\r\n\r\n","")).replace(/<\/p><p>/g,"</p>\r\n\r\n<p>")).replace(new RegExp("<br\\s?/?></p>","g"),"</p>")).replace(new RegExp("<p><br\\s?/?>","g"),"<p>")).replace(new RegExp("<p><br\\s?/?>","g"),"<p>")).replace(new RegExp("<br\\s?/?></p>","g"),"</p>")).replace(/<p>&nbsp;<\/p>/gi,"")).replace(/<p>\s?<br>&nbsp;<\/p>/gi,"")).replace(/<p>\s?<br>/gi,"<p>")},clear:function(t){return t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/<p>(.*?)#####replace(.*?)#####\s?<\/p>/gi,"<p>$1</p>#####replace$2#####")).replace(/(<br\s?\/?>){2,}<\/p>/gi,"</p>")).replace(new RegExp("</blockquote></p>","gi"),"</blockquote>")).replace(new RegExp("<p></blockquote>","gi"),"</blockquote>")).replace(new RegExp("<p><blockquote>","gi"),"<blockquote>")).replace(new RegExp("<blockquote></p>","gi"),"<blockquote>")).replace(new RegExp("<p><p ","gi"),"<p ")).replace(new RegExp("<p><p>","gi"),"<p>")).replace(new RegExp("</p></p>","gi"),"</p>")).replace(new RegExp("<p>\\s?</p>","gi"),"")).replace(new RegExp("\n</p>","gi"),"</p>")).replace(new RegExp("<p>\t?\t?\n?<p>","gi"),"<p>")).replace(new RegExp("<p>\t*</p>","gi"),"")}}},paste:function(){return{init:function(t){this.rtePaste=!0;var n=!("pre"!==this.opts.type&&!this.utils.isCurrentOrParent("pre"));this.detect.isDesktop()&&!this.paste.pre&&this.opts.clipboardImageUpload&&this.opts.imageUpload&&this.paste.detectClipboardUpload(t)?this.detect.isIe()&&setTimeout(m.proxy(this.paste.clipboardUpload,this),100):(this.utils.saveScroll(),this.selection.save(),this.paste.createPasteBox(n),m(window).on("scroll.redactor-freeze",m.proxy(function(){m(window).scrollTop(this.saveBodyScroll)},this)),setTimeout(m.proxy(function(){var t=this.paste.getPasteBoxCode(n);this.buffer.set(),this.selection.restore(),this.utils.restoreScroll();var e=this.clean.getCurrentType(t),t=this.clean.onPaste(t,e),i=this.core.callback("paste",t);t=void 0===i?t:i,this.paste.insert(t,e),this.rtePaste=!1,n&&this.clean.cleanPre(),m(window).off("scroll.redactor-freeze")},this),1))},getPasteBoxCode:function(t){var e=t?this.$pasteBox.val():this.$pasteBox.html();return this.$pasteBox.remove(),e},createPasteBox:function(t){var e={position:"fixed",width:"1px",top:0,left:"-9999px"};this.$pasteBox=t?m("<textarea>").css(e):m("<div>").attr("contenteditable","true").css(e),this.paste.appendPasteBox(),this.$pasteBox.focus()},appendPasteBox:function(){var t;this.detect.isIe()?this.core.box().append(this.$pasteBox):0<(t=m(".modal-body:visible")).length?t.append(this.$pasteBox):m("body").prepend(this.$pasteBox)},detectClipboardUpload:function(t){var e=(t=t.originalEvent||t).clipboardData;if(this.detect.isIe()||this.detect.isFirefox())return!1;if(-1!==e.types.indexOf("public.tiff"))return t.preventDefault(),!1;if(e.items&&e.items.length){var i=e.items[0].getAsFile();if(null===i)return!1;var n=new FileReader;return n.readAsDataURL(i),n.onload=m.proxy(this.paste.insertFromClipboard,this),!0}},clipboardUpload:function(){var t=this.$editor.find("img");m.each(t,m.proxy(function(t,i){var e,n;-1!==i.src.search(/^data\:image/i)&&(e=window.FormData?new FormData:null,window.FormData&&(this.upload.direct=!0,this.upload.type="image",this.upload.url=this.opts.imageUpload,this.upload.callback=m.proxy(function(t){var e;this.detect.isIe()?m(i).wrap(m("<figure />")):(e=m(i).parent(),this.utils.replaceToTag(e,"figure")),i.src=t.url,this.core.callback("imageUpload",m(i),t)},this),n=this.utils.dataURItoBlob(i.src),e.append("clipboard",1),e.append(this.opts.imageUploadParam,n),this.upload.send(e,!1),this.code.sync(),this.rtePaste=!1))},this))},insertFromClipboard:function(t){var e,i=window.FormData?new FormData:null;window.FormData&&(this.upload.direct=!0,this.upload.type="image",this.upload.url=this.opts.imageUpload,this.upload.callback=this.image.insert,e=this.utils.dataURItoBlob(t.target.result),i.append("clipboard",1),i.append(this.opts.imageUploadParam,e),this.upload.send(i,t),this.rtePaste=!1)},insert:function(t,e){e.pre?this.insert.raw(t):e.text?this.insert.text(t):this.insert.html(t,e),this.detect.isFirefox()&&this.opts.imageUpload&&this.opts.clipboardImageUpload&&setTimeout(m.proxy(this.paste.clipboardUpload,this),100)}}},placeholder:function(){return{enable:function(){},show:function(){},update:function(){},hide:function(){},is:function(){},init:function(){},enabled:function(){},enableEvents:function(){},disableEvents:function(){},build:function(){},buildPosition:function(){},getPosition:function(){},isEditorEmpty:function(){},isAttr:function(){},destroy:function(){}}},progress:function(){return{$box:null,$bar:null,target:document.body,show:function(){},hide:function(){},update:function(){},is:function(){},build:function(){},destroy:function(){}}},selection:function(){return{get:function(){return window.getSelection?window.getSelection():document.selection&&"Control"!==document.selection.type?document.selection:null},range:function(t){return void 0===t&&(t=this.selection.get()),t.getRangeAt&&t.rangeCount?t.getRangeAt(0):null},is:function(){return!this.selection.isCollapsed()},isRedactor:function(){var t=this.selection.range();if(null!==t){var e=t.startContainer.parentNode;if(m(e).hasClass("redactor-in")||0!==m(e).parents(".redactor-in").length)return!0}return!1},isCollapsed:function(){var t=this.selection.get();return null!==t&&t.isCollapsed},update:function(t,e){null!==e&&(t.removeAllRanges(),t.addRange(e))},current:function(){var t=this.selection.get();return null!==t&&t.anchorNode},parent:function(){var t=this.selection.current();return null!==t&&t.parentNode},block:function(t){for(t=t||this.selection.current();t;){if(this.utils.isBlockTag(t.tagName))return!m(t).hasClass("redactor-in")&&t;t=t.parentNode}return!1},inline:function(t){for(t=t||this.selection.current();t;){if(this.utils.isInlineTag(t.tagName))return!m(t).hasClass("redactor-in")&&t;t=t.parentNode}return!1},element:function(t){for(t=t||this.selection.current();t;){if(1===t.nodeType)return!m(t).hasClass("redactor-in")&&t;t=t.parentNode}return!1},prev:function(){return null!==this.selection.current()&&this.selection.current().previousSibling},next:function(){return null!==this.selection.current()&&this.selection.current().nextSibling},blocks:function(t){var i=[],e=this.selection.nodes(t);m.each(e,m.proxy(function(t,e){this.utils.isBlock(e)&&i.push(e)},this));var n=this.selection.block();return 0===i.length&&!1===n?[]:0===i.length&&!1!==n?[n]:i},inlines:function(t){var i=[],e=this.selection.nodes(t);m.each(e,m.proxy(function(t,e){this.utils.isInline(e)&&i.push(e)},this));var n=this.selection.inline();return 0===i.length&&!1===n?[]:0===i.length&&!1!==n?[n]:i},nodes:function(t){var n=void 0===t?[]:m.isArray(t)?t:[t],e=this.selection.get(),i=this.selection.range(e),r=[],s=[];if(this.utils.isCollapsed())r=[this.selection.current()];else{var o=i.startContainer,a=i.endContainer;if(o===a)return[o];for(;o&&o!==a;)r.push(o=this.selection.nextNode(o));for(o=i.startContainer;o&&o!==i.commonAncestorContainer;)r.unshift(o),o=o.parentNode}return m.each(r,function(t,e){if(e){var i=1===e.nodeType&&e.tagName.toLowerCase();if(m(e).hasClass("redactor-script-tag")||m(e).hasClass("redactor-selection-marker"))return;if(i&&0!==n.length&&-1===m.inArray(i,n))return;s.push(e)}}),0===s.length?[]:s},nextNode:function(t){if(t.hasChildNodes())return t.firstChild;for(;t&&!t.nextSibling;)t=t.parentNode;return t?t.nextSibling:null},save:function(){this.marker.insert(),this.savedSel=this.core.editor().html()},restore:function(t){var e=this.marker.find(1),i=this.marker.find(2);this.detect.isFirefox()&&this.core.editor().focus(),0!==e.length&&0!==i.length?this.caret.set(e,i):0!==e.length?this.caret.start(e):this.core.editor().focus(),!1!==t&&(this.marker.remove(),this.savedSel=!1)},saveInstant:function(){var t=this.core.editor()[0],e=t.ownerDocument.defaultView.getSelection();if(e.getRangeAt&&e.rangeCount){var i=e.getRangeAt(0),n=i.cloneRange();n.selectNodeContents(t),n.setEnd(i.startContainer,i.startOffset);var r=n.toString().length;return this.saved={start:r,end:r+i.toString().length,node:i.startContainer},this.saved}},restoreInstant:function(t){if(void 0!==t||this.saved){this.saved=void 0!==t?t:this.saved;var e=this.core.editor().find(this.saved.node);if(0===e.length||0!==e.text().trim().replace(/\u200B/g,"").length){var i,n=this.core.editor()[0],r=n.ownerDocument,s=r.defaultView,o=0;(i=r.createRange()).setStart(n,0),i.collapse(!0);for(var a,l,c=[n],h=!1,d=!1;!d&&(a=c.pop());)if(3==a.nodeType){var u=o+a.length;!h&&this.saved.start>=o&&this.saved.start<=u&&(i.setStart(a,this.saved.start-o),h=!0),h&&this.saved.end>=o&&this.saved.end<=u&&(i.setEnd(a,this.saved.end-o),d=!0),o=u}else for(var p=a.childNodes.length;p--;)c.push(a.childNodes[p]);(l=s.getSelection()).removeAllRanges(),l.addRange(i)}else try{(i=document.createRange()).setStart(e[0],0),(l=window.getSelection()).removeAllRanges(),l.addRange(i)}catch(t){}}},node:function(t){m(t).prepend(this.marker.get(1)),m(t).append(this.marker.get(2)),this.selection.restore()},all:function(){this.core.editor().focus();var t=this.selection.get(),e=this.selection.range(t);e.selectNodeContents(this.core.editor()[0]),this.selection.update(t,e)},remove:function(){this.selection.get().removeAllRanges()},replace:function(t){this.insert.html(t)},text:function(){return this.selection.get().toString()},html:function(){var t="",e=this.selection.get();if(e.rangeCount){for(var i=document.createElement("div"),n=e.rangeCount,r=0;r<n;++r)i.appendChild(e.getRangeAt(r).cloneContents());t=this.clean.onGet(i.innerHTML)}return t},extractEndOfNode:function(t){var e=this.selection.get(),i=this.selection.range(e),n=i.cloneRange();return n.selectNodeContents(t),n.setStart(i.endContainer,i.endOffset),n.extractContents()},removeMarkers:function(){this.marker.remove()},marker:function(t){return this.marker.get(t)},markerHtml:function(t){return this.marker.html(t)}}},shortcuts:function(){return{hotkeysSpecialKeys:{8:"backspace",9:"tab",10:"return",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",59:";",61:"=",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},hotkeysShiftNums:{"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"},init:function(i,t){if(!1===this.opts.shortcuts)return!i.ctrlKey&&!i.metaKey||66!==t&&73!==t||i.preventDefault(),!1;m.each(this.opts.shortcuts,m.proxy(function(t,e){this.shortcuts.build(i,t,e)},this))},build:function(t,e,i){for(var n=m.proxy(function(){this.shortcuts.buildHandler(i)},this),r=e.split(","),s=r.length,o=0;o<s;o++)"string"==typeof r[o]&&this.shortcuts.handler(t,m.trim(r[o]),n)},buildHandler:function(t){var e;"-1"!==t.func.search(/\./)?void 0!==this[(e=t.func.split("."))[0]]&&this[e[0]][e[1]].apply(this,t.params):this[t.func].apply(this,t.params)},handler:function(i,t,e){t=t.toLowerCase().split(" ");var n=this.shortcuts.hotkeysSpecialKeys[i.keyCode],r=String.fromCharCode(i.which).toLowerCase(),s="",o={};m.each(["alt","ctrl","meta","shift"],function(t,e){i[e+"Key"]&&n!==e&&(s+=e+"+")}),n&&(o[s+n]=!0),r&&(o[s+r]=!0,o[s+this.shortcuts.hotkeysShiftNums[r]]=!0,"shift+"===s&&(o[this.shortcuts.hotkeysShiftNums[r]]=!0));for(var a=t.length,l=0;l<a;l++)if(o[t[l]])return i.preventDefault(),e.apply(this,arguments)}}},storage:function(){return{data:[],add:function(){},status:function(){},observe:function(){},changes:function(){}}},toolbar:function(){return{build:function(){this.button.hideButtons(),this.button.hideButtonsOnMobile(),this.$toolbarBox=m('<div class="redactor-toolbar-box" />'),this.$toolbarBox[0].innerHTML='<ul class="redactor-toolbar" id="redactor-toolbar-'+this.uuid+'" role="toolbar"></ul>',this.$toolbar=m(this.$toolbarBox[0].children[0]),this.$box[0].insertBefore(this.$toolbarBox[0],this.$box[0].firstChild),this.button.$toolbar=this.$toolbar,this.button.setFormatting(),this.button.load(this.$toolbar),require(["Core"],function(t){this.$toolbar[0].addEventListener("keydown",this.toolbar.keydown.bind(this,t))}.bind(this))},createContainer:function(){},append:function(){},setOverflow:function(){},setFixed:function(){},setUnfixed:function(){},getBoxTop:function(){},observeScroll:function(){},observeScrollResize:function(){},observeScrollEnable:function(){},observeScrollDisable:function(){},setDropdownsFixed:function(){},unsetDropdownsFixed:function(){},setDropdownPosition:function(){},keydown:function(t,e){var i=document.activeElement;if(i.classList.contains("re-button")){if(-1!==[13,32,35,36,37,39,40].indexOf(e.which)){if(13===e.which||32===e.which)return e.preventDefault(),void require(["Core"],function(t){t.triggerEvent(i,"mousedown")});if(40!==e.which){e.preventDefault();var n,r=Array.prototype.slice.call(elBySelAll(".re-button",this.$toolbar[0])),s=null;null!==(s=35===e.which?r[r.length-1]:36===e.which?r[0]:(n=r.indexOf(i),37===e.which?-1===--n&&(n=r.length-1):39===e.which&&++n===r.length&&(n=0),r[n]))&&s.focus()}else{if("true"!==elAttr(i,"aria-haspopup"))return;e.preventDefault(),t.triggerEvent(i,"mousedown");var o=m(i).data("dropdown"),a=elBySel("li",o[0]);a&&a.focus()}}}}}},upload:function(){return{init:function(){},directUpload:function(){},onDrop:function(){},traverseFile:function(){},setConfig:function(){},getType:function(){},getHiddenFields:function(){},send:function(){},onDrag:function(){},onDragLeave:function(){},clearImageFields:function(){},addImageFields:function(){},removeImageFields:function(){},clearFileFields:function(){},addFileFields:function(){},removeFileFields:function(){}}},uploads3:function(){return{send:function(){},executeOnSignedUrl:function(){},createCORSRequest:function(){},sendToS3:function(){}}},utils:function(){return{isEmpty:function(t){return t=(t=(t=(t=(t=(t=(t=(t=(t=(t=void 0===t?this.core.editor().html():t).replace(/[\u200B-\u200D\uFEFF]/g,"")).replace(/&nbsp;/gi,"")).replace(/<\/?br\s?\/?>/g,"")).replace(/\s/g,"")).replace(/^<p>[^\W\w\D\d]*?<\/p>$/i,"")).replace(/<iframe(.*?[^>])>$/i,"iframe")).replace(/<source(.*?[^>])>$/i,"source")).replace(/<[^\/>][^>]*><\/[^>]+>/gi,"")).replace(/<[^\/>][^>]*><\/[^>]+>/gi,""),""===(t=m.trim(t))},isElement:function(e){try{return e instanceof HTMLElement}catch(t){return"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument}},strpos:function(t,e,i){var n=t.indexOf(e,i);return 0<=n&&n},dataURItoBlob:function(t){for(var e=(0<=t.split(",")[0].indexOf("base64")?atob:unescape)(t.split(",")[1]),i=t.split(",")[0].split(":")[1].split(";")[0],n=new Uint8Array(e.length),r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return new Blob([n],{type:i})},getOuterHtml:function(t){return m("<div>").append(m(t).eq(0).clone()).html()},cloneAttributes:function(t,e){t=t[0]||t,e=m(e);for(var i=t.attributes,n=i.length;n--;){var r=i[n];e.attr(r.name,r.value)}return e},breakBlockTag:function(){var t=this.selection.block();if(!t)return!1;var e=this.utils.isEmpty(t.innerHTML),i=t.tagName.toLowerCase();if("pre"===i||"li"===i||"td"===i||"th"===i)return!1;if(!e&&this.utils.isStartOfElement(t))return{$block:m(t),$next:m(t).next(),type:"start"};if(!e&&this.utils.isEndOfElement(t))return{$block:m(t),$next:m(t).next(),type:"end"};var n=this.selection.extractEndOfNode(t),r=m("<"+i+" />").append(n),r=this.utils.cloneAttributes(t,r);return m(t).after(r),{$block:m(t),$next:r,type:"break"}},inBlocks:function(t){t=m.isArray(t)?t:[t];for(var e,i=this.selection.blocks(),n=i.length,r=!1,s=0;s<n;s++){!1!==i[s]&&(e=i[s].tagName.toLowerCase(),-1!==m.inArray(e,t)&&(r=!0))}return r},inInlines:function(t){t=m.isArray(t)?t:[t];for(var e=this.selection.inlines(),i=e.length,n=!1,r=0;r<i;r++){var s=e[r].tagName.toLowerCase();-1!==m.inArray(s,t)&&(n=!0)}return n},isTag:function(t,e){var i=m(t).closest(e,this.core.editor()[0]);return 1===i.length&&i[0]},isBlock:function(t){return null!==t&&((t=t[0]||t)&&this.utils.isBlockTag(t.tagName))},isBlockTag:function(t){return void 0!==t&&this.reIsBlock.test(t)},isInline:function(t){return(t=t[0]||t)&&this.utils.isInlineTag(t.tagName)},isInlineTag:function(t){return void 0!==t&&this.reIsInline.test(t)},isRedactorParent:function(t){return!!t&&(0!==m(t).parents(".redactor-in").length&&!m(t).hasClass("redactor-in")&&t)},isCurrentOrParentHeader:function(){return this.utils.isCurrentOrParent(["H1","H2","H3","H4","H5","H6"])},isCurrentOrParent:function(t){var i=this.selection.parent(),n=this.selection.current();if(m.isArray(t)){var r=0;return m.each(t,m.proxy(function(t,e){this.utils.isCurrentOrParentOne(n,i,e)&&r++},this)),0!==r}return this.utils.isCurrentOrParentOne(n,i,t)},isCurrentOrParentOne:function(t,e,i){return i=i.toUpperCase(),e&&e.tagName===i?e:!(!t||t.tagName!==i)&&t},isEditorRelative:function(){var t=this.core.editor().css("position");return-1!==m.inArray(["absolute","fixed","relative"],t)},setEditorRelative:function(){this.core.editor().addClass("redactor-relative")},getScrollTarget:function(){var t=m(this.opts.scrollTarget);return 0!==t.length?t:m(document)},freezeScroll:function(){this.freezeScrollTop=this.utils.getScrollTarget().scrollTop(),this.utils.getScrollTarget().scrollTop(this.freezeScrollTop)},unfreezeScroll:function(){void 0!==this.freezeScrollTop&&this.utils.getScrollTarget().scrollTop(this.freezeScrollTop)},saveScroll:function(){this.tmpScrollTop=this.utils.getScrollTarget().scrollTop()},restoreScroll:function(){void 0!==this.tmpScrollTop&&this.utils.getScrollTarget().scrollTop(this.tmpScrollTop)},isStartOfElement:function(t){return!(void 0===t&&!(t=this.selection.block()))&&0===this.offset.get(t)},isEndOfElement:function(t){if(void 0===t&&!(t=this.selection.block()))return!1;var e=m.trim(m(t).text()).replace(/[\t\n\r\n]/g,"").replace(/\u200B/g,"");return this.offset.get(t)===e.length},removeEmptyAttr:function(t,e){var i=m(t);return void 0===i.attr(e)||""===i.attr(e)&&(i.removeAttr(e),!0)},replaceToTag:function(t,e){var i;return m(t).replaceWith(function(){i=m("<"+e+" />").append(m(this).contents());for(var t=0;t<this.attributes.length;t++)i.attr(this.attributes[t].name,this.attributes[t].value);return i}),i},isSelectAll:function(){return this.selectAll},enableSelectAll:function(){this.selectAll=!0},disableSelectAll:function(){this.selectAll=!1},disableBodyScroll:function(){},measureScrollbar:function(){var t=m("body"),e=document.createElement("div");e.className="redactor-scrollbar-measure",t.append(e);var i=e.offsetWidth-e.clientWidth;return t[0].removeChild(e),i},enableBodyScroll:function(){},appendFields:function(t,i){if(!t)return i;if("object"==typeof t)return m.each(t,function(t,e){null!==e&&0===e.toString().indexOf("#")&&(e=m(e).val()),i.append(t,e)}),i;var e=m(t);if(0===e.length)return i;return e.each(function(){i.append(m(this).attr("name"),m(this).val())}),i},appendForms:function(t,i){if(!t)return i;var e=m(t);if(0===e.length)return i;var n=e.serializeArray();return m.each(n,function(t,e){i.append(e.name,e.value)}),i},isRgb:function(t){return 0===t.search(/^rgb/i)},rgb2hex:function(t){return(t=t.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&4===t.length?"#"+("0"+parseInt(t[1],10).toString(16)).slice(-2)+("0"+parseInt(t[2],10).toString(16)).slice(-2)+("0"+parseInt(t[3],10).toString(16)).slice(-2):""},isCollapsed:function(){return this.selection.isCollapsed()},isMobile:function(){return this.detect.isMobile()},isDesktop:function(){return this.detect.isDesktop()},isPad:function(){return this.detect.isIpad()}}},browser:function(){return{webkit:function(){return this.detect.isWebkit()},ff:function(){return this.detect.isFirefox()},ie:function(){return this.detect.isIe()}}}},m(window).on("load.tools.redactor",function(){m('[data-tools="redactor"]').redactor()}),l.prototype.init.prototype=l.prototype}(jQuery),function(s){function n(t,e,i,n){var r={duration:.5,iterate:1,delay:0,prefix:"redactor-",timing:"linear"};this.animation=e,this.slide="slideDown"===this.animation||"slideUp"===this.animation,this.$element=s(t),this.prefixes=["","-moz-","-o-animation-","-webkit-"],this.queue=[],"function"==typeof i?(n=i,this.opts=r):this.opts=s.extend(r,i),this.slide&&this.$element.height(this.$element.height()),this.init(n)}s.fn.redactorAnimation=function(t,e,i){return this.each(function(){new n(this,t,e,i)})},n.prototype={init:function(t){this.queue.push(this.animation),this.clean(),"show"===this.animation?(this.opts.timing="linear",this.$element.removeClass("hide").show(),"function"==typeof t&&t(this)):"hide"===this.animation?(this.opts.timing="linear",this.$element.hide(),"function"==typeof t&&t(this)):this.animate(t)},animate:function(t){this.$element.addClass("redactor-animated").css("display","").removeClass("hide"),this.$element.addClass(this.opts.prefix+this.queue[0]),this.set(this.opts.duration+"s",this.opts.delay+"s",this.opts.iterate,this.opts.timing);var e=1<this.queue.length?null:t;this.complete("AnimationEnd",s.proxy(function(){this.$element.hasClass(this.opts.prefix+this.queue[0])&&(this.clean(),this.queue.shift(),this.queue.length&&this.animate(t))},this),e)},set:function(t,e,i,n){for(var r=this.prefixes.length;r--;)this.$element.css(this.prefixes[r]+"animation-duration",t),this.$element.css(this.prefixes[r]+"animation-delay",e),this.$element.css(this.prefixes[r]+"animation-iteration-count",i),this.$element.css(this.prefixes[r]+"animation-timing-function",n)},clean:function(){this.$element.removeClass("redactor-animated"),this.$element.removeClass(this.opts.prefix+this.queue[0]),this.set("","","","")},complete:function(t,e,i){this.$element.one(t.toLowerCase()+" webkit"+t+" o"+t+" MS"+t,s.proxy(function(){"function"==typeof e&&e(),"function"==typeof i&&i(this);-1!==s.inArray(this.animation,["fadeOut","slideUp","zoomOut","slideOutUp","slideOutRight","slideOutLeft"])&&this.$element.css("display","none"),this.slide&&this.$element.css("height","")},this))}}}(jQuery); })(this);
 
 // plugins/WoltLabArticle.js
 (function (window, undefined) { $.Redactor.prototype.WoltLabArticle=function(){"use strict";return{init:function(){var i=this.button.add("woltlabArticle","");require(["WoltLabSuite/Core/Ui/Redactor/Article"],function(t){new t(this,i[0])}.bind(this))}}}; })(this);