Upgraded to Redactor II 2.7
authorAlexander Ebert <ebert@woltlab.com>
Wed, 21 Jun 2017 16:13:43 +0000 (18:13 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 21 Jun 2017 16:13:43 +0000 (18:13 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/redactor.js
wcfsetup/install/files/js/3rdParty/redactor2/redactor.min.js

index caea5a1bfc91af04bb38ac3cbb22ac746120a3bd..d06a92b5e6ad07cf1a38ff378fafbc0ca34c465b 100644 (file)
@@ -1,7 +1,7 @@
 /*
        Redactor II
-       Version 2.6
-       Updated: May 17, 2017
+       Version 2.7
+       Updated: June 17, 2017
 
        http://imperavi.com/redactor/
 
 
        // Options
        $.Redactor = Redactor;
-       $.Redactor.VERSION = '2.6';
+       $.Redactor.VERSION = '2.7';
        $.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',
                                                return this.caret.after(node.lastChild);
                                        }
 
-                                       sel = window.getSelection();
-                                       sel.removeAllRanges();
+                    var sel = window.getSelection();
+                    if (sel.getRangeAt || sel.rangeCount)
+                    {
+                        try {
+                            var range = sel.getRangeAt(0);
+                            range.selectNodeContents(node);
+                            range.collapse(false);
 
-                    try {
-                                       range = document.createRange();
-                                       range.selectNodeContents(node);
-                                       range.collapse(false);
-                                       sel.addRange(range);
-                                       }
-                                       catch(e) {}
+                            sel.removeAllRanges();
+                            sel.addRange(range);
+                        }
+                        catch(e) {}
+                    }
                                },
                                after: function(node)
                                {
                                        html = html.replace(/&amp;/g, '&');
 
                                        // remove empty paragpraphs
-                                       html = html.replace(/<p><\/p>/gi, "");
+                                       //html = html.replace(/<p><\/p>/gi, "");
 
                                        // remove new lines
                     html = html.replace(/\n{2,}/g, "\n");
 
                                        var command = this.dropdown.buildCommand(btnObject);
 
-                                       if (typeof btnObject.args !== ' undefined')
+                                       if (typeof btnObject.args !== 'undefined')
                                        {
                                                this.button.toggle(e, btnName, command.type, command.callback, btnObject.args);
                                        }
                                    }
 
                                        this.image.startResize();
-
-
                                },
                                startResize: function()
                                {
 
                                        if (height < 50 || width < 100) return;
 
-                                       var height = Math.round(this.image.resizeHandle.el.width() / this.image.resizeHandle.ratio);
-
                                        this.image.resizeHandle.el.attr({width: width, height: height});
                            this.image.resizeHandle.el.width(width);
                            this.image.resizeHandle.el.height(height);
                     var imageDeleteStop = this.core.callback('imageDelete', e, $image[0]);
                                        if (imageDeleteStop === false)
                                        {
-                                               e.preventDefault();
+                                               if (e) e.preventDefault();
                                                return false;
                                        }
 
                                                }
                                                else
                                                {
-                                               var $first = this.inline.insertBreakpoint($parent[0], currentTag);
+                                               var $first = this.inline.insertBreakpoint(inline, currentTag);
                             this.caret.after($first);
                                                }
                                }
                                        }
 
                                        this.utils.disableSelectAll();
-                                       this.linkify.format();
 
                                        if (data.pre) this.clean.cleanPre();
 
-                    // end focus
                     this.caret.end(endNode);
+                    this.linkify.format();
                                },
                                text: function(text)
                                {
                                                this.caret.after($el);
                                        }
 
+                                       return $el;
+
                                },
                                update: function($el, link)
                                {
                                                return;
                                        }
 
-
                                        this.core.editor().find(":not(iframe,img,a,pre,code,.redactor-unlink)").addBack().contents().filter($.proxy(this.linkify.isFiltered, this)).each($.proxy(this.linkify.handler, this));
 
                                        // collect
                                        if (this.opts.toolbarFixedTarget !== document)
                                        {
                                                var $el = $(this.opts.toolbarFixedTarget);
-                                               this.toolbarOffsetTop = ($el.length === 0) ? 0 : this.core.box().offset().top - $el.offset().top;
+                                               this.toolbar.toolbarOffsetTop = ($el.length === 0) ? 0 : this.core.box().offset().top - $el.offset().top;
                                        }
 
                                        // bootstrap modal fix
 
                         for (var i = 0; i < len; i++)
                         {
-                            this.upload.traverseFile(this.upload.$input[0].files[i], e);
+                            var index = (len - 1) - i;
+                            this.upload.traverseFile(this.upload.$input[0].files[index], e);
                         }
                                        }, this));
 
                                        }
 
                                        this.progress.show();
-                                       this.core.callback('uploadStart', e, formData);
-                                       this.upload.send(formData, e);
+                                       var stop = this.core.callback('uploadStart', e, formData);
+                                       if (stop !== false)
+                                       {
+                                       this.upload.send(formData, e);
+                                       }
                                },
                                setConfig: function(file)
                                {
                                        }, this);
 
                     // before send
-                    this.core.callback('uploadBeforeSend', xhr);
-
-                                       xhr.send(formData);
+                    var stop = this.core.callback('uploadBeforeSend', xhr);
+                    if (stop !== false)
+                    {
+                                           xhr.send(formData);
+                                       }
                                },
                                onDrag: function(e)
                                {
 
                                        return xhr;
                                },
-                               sendToS3: function(file, url, formData)
-                               {
-                                       var xhr = this.uploads3.createCORSRequest('PUT', url);
-                                       if (!xhr)
-                                       {
-                                               return;
-                                       }
 
-                                       xhr.onload = $.proxy(function()
-                                       {
-                                               var json;
-
-                                               this.progress.hide();
+                sendToS3: function(file, url, e)
+                {
+                    var xhr = this.uploads3.createCORSRequest('PUT', url);
+                    if (!xhr)
+                    {
+                        return;
+                    }
 
-                                               if (xhr.status !== 200)
-                                               {
-                                                       // error
-                                                       json = { error: true };
-                                                       this.upload.callback(json, this.upload.direct, xhr);
+                    xhr.onload = $.proxy(function()
+                    {
+                        var json;
+                        this.progress.hide();
 
-                                                       return;
-                                               }
+                        if (xhr.status !== 200)
+                        {
+                            // error
+                            json = { error: true };
+                            this.upload.callback(json, this.upload.direct, xhr);
 
-                                               var s3file = url.split('?');
+                            return;
+                        }
 
-                                               if (!s3file[0])
-                                               {
-                                                        // url parsing is fail
-                                                        return false;
-                                               }
+                        var s3file = url.split('?');
+                        if (!s3file[0])
+                        {
+                            // url parsing is fail
+                            return false;
+                        }
 
 
-                                               if (!this.upload.direct)
-                                               {
-                                                       this.upload.$droparea.removeClass('drag-drop');
-                                               }
+                        if (!this.upload.direct)
+                        {
+                            this.upload.$droparea.removeClass('drag-drop');
+                        }
 
-                                               json = { url: s3file[0], id: s3file[0], s3: true };
-                                               if (this.upload.type === 'file')
-                                               {
-                                                       var arr = s3file[0].split('/');
-                                                       json.name = arr[arr.length-1];
-                                               }
+                        json = { url: s3file[0], id: s3file[0], s3: true };
+                        if (this.upload.type === 'file')
+                        {
+                            var arr = s3file[0].split('/');
+                            json.name = arr[arr.length-1];
+                        }
 
-                                               this.upload.callback(json, this.upload.direct, e);
+                        this.upload.callback(json, this.upload.direct, e);
 
 
-                                       }, this);
+                    }, this);
 
-                                       xhr.onerror = function() {};
-                                       xhr.upload.onprogress = function(e) {};
+                    xhr.onerror = function() {};
+                    xhr.upload.onprogress = function(e) {};
 
-                                       xhr.setRequestHeader('Content-Type', file.type);
-                                       xhr.setRequestHeader('x-amz-acl', 'public-read');
+                    xhr.setRequestHeader('Content-Type', file.type);
+                    xhr.setRequestHeader('x-amz-acl', 'public-read');
 
-                                       xhr.send(formData);
+                    xhr.send(file);
 
-                               }
+                }
                        };
                },
 
index 4f81a47e7356b52f8feca86345855800c143756e..35941cda98416fce4f6fa0a3172a017538dc3bf2 100644 (file)
@@ -1,6 +1 @@
-!function(t){"use strict";function i(t,e){return new i.prototype.init(t,e)}Function.prototype.bind||(Function.prototype.bind=function(t){var e=this;return function(){return e.apply(t)}});var r=0;t.fn.redactor=function(e){var r=[],o=Array.prototype.slice.call(arguments,1);return"string"==typeof e?this.each(function(){var i,s=t.data(this,"redactor");if("-1"!==e.search(/\./)?(i=e.split("."),"undefined"!=typeof s[i[0]]&&(i=s[i[0]][i[1]])):i=s[e],"undefined"!=typeof s&&t.isFunction(i)){var n=i.apply(s,o);void 0!==n&&n!==s&&r.push(n)}else t.error('No such method "'+e+'" for Redactor')}):this.each(function(){t.data(this,"redactor",{}),t.data(this,"redactor",i(this,e))}),0===r.length?this:1===r.length?r[0]:r},t.Redactor=i,t.Redactor.VERSION="2.6",t.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"],t.Redactor.settings={},t.Redactor.opts={animation:!1,lang:"en",direction:"ltr",spellcheck:!0,overrideStyles:!0,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,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:[],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,buffer:[],rebuffer:[],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:t("").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}},i.fn=t.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(e,i){return this.$element=t(e),this.uuid=r++,this.loadOptions(i),this.loadModules(),this.opts.clickToEdit&&!this.$element.hasClass("redactor-click-to-edit")?this.loadToEdit(i):(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?!1:this.opts.dragImageUpload,this.opts.dragFileUpload=null===this.opts.fileUpload?!1:this.opts.dragFileUpload,this.formatting={},this.lang.load(),t.extend(this.opts.shortcuts,this.opts.shortcutsAdd),this.$editor=this.$element,this.detectType(),this.core.callback("start"),this.core.callback("startToEdit"),this.start=!0,void 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(e){this.$element.on("click.redactor-click-to-edit",t.proxy(function(){this.initToEdit(e)},this)),this.$element.addClass("redactor-click-to-edit")},initToEdit:function(e){t.extend(e.callbacks,{startToEdit:function(){this.insert.node(this.marker.get(),!1)},initToEdit:function(){this.selection.restore(),this.clickToCancelStorage=this.code.get(),t(this.opts.clickToCancel).off(".redactor-click-to-edit"),t(this.opts.clickToCancel).show().on("click.redactor-click-to-edit",t.proxy(function(i){i.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="",t(this.opts.clickToCancel).hide(),t(this.opts.clickToSave).hide(),this.$element.on("click.redactor-click-to-edit",t.proxy(function(){this.initToEdit(e)},this)),this.$element.addClass("redactor-click-to-edit")},this)),t(this.opts.clickToSave).off(".redactor-click-to-edit"),t(this.opts.clickToSave).show().on("click.redactor-click-to-edit",t.proxy(function(i){i.preventDefault(),this.core.destroy(),this.core.callback("save",this.code.get()),t(this.opts.clickToCancel).hide(),t(this.opts.clickToSave).hide(),this.$element.on("click.redactor-click-to-edit",t.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(e){var i={};"undefined"!=typeof t.Redactor.settings.namespace?this.$element.hasClass(t.Redactor.settings.namespace)&&(i=t.Redactor.settings):i=t.Redactor.settings,this.opts=t.extend({},t.Redactor.opts,this.$element.data(),e),this.opts=t.extend(!0,this.opts,i)},getModuleMethods:function(t){return Object.getOwnPropertyNames(t).filter(function(e){return"function"==typeof t[e]})},loadModules:function(){for(var e=t.Redactor.modules.length,i=0;e>i;i++)this.bindModuleMethods(t.Redactor.modules[i])},bindModuleMethods:function(t){if("undefined"!=typeof this[t]){this[t]=this[t]();for(var e=this.getModuleMethods(this[t]),i=e.length,r=0;i>r;r++)this[t][e[r]]=this[t][e[r]].bind(this)}},air:function(){return{enabled:!1,collapsed:function(){this.opts.air&&this.selection.get().collapseToStart()},collapsedEnd:function(){this.opts.air&&this.selection.get().collapseToEnd()},build:function(){this.detect.isMobile()||(this.button.hideButtons(),this.button.hideButtonsOnMobile(),0!==this.opts.buttons.length&&(this.$air=this.air.createContainer(),this.opts.airWidth!==!1&&this.$air.css("width",this.opts.airWidth),this.air.append(),this.button.$toolbar=this.$air,this.button.setFormatting(),this.button.load(this.$air),this.core.editor().on("mouseup.redactor",this,t.proxy(function(t){""!==this.selection.text()&&this.air.show(t)},this))))},append:function(){this.$air.appendTo("body")},createContainer:function(){return t("<ul>").addClass("redactor-air").attr({id:"redactor-air-"+this.uuid,role:"toolbar"}).hide()},show:function(e){this.selection.saveInstant(),t(".redactor-air").hide();var i=0,r=this.$air.innerWidth();t(window).width()<e.clientX+r&&(i=200),this.$air.css({left:e.clientX-i+"px",top:e.clientY+10+t(document).scrollTop()+"px"}).show(),this.air.enabled=!0,this.air.bindHide()},bindHide:function(){t(document).on("mousedown.redactor-air."+this.uuid,t.proxy(function(e){var i=t(e.target).closest(".redactor-dropdown").length;if(0===t(e.target).closest(this.$air).length&&0===i){var r=this.air.hide(e);r!==!1&&this.marker.remove()}},this)).on("keydown.redactor-air."+this.uuid,t.proxy(function(e){var i=e.which;if((this.utils.isRedactorParent(e.target)||t(e.target).hasClass("redactor-in"))&&0===t(e.target).closest("#redactor-modal").length){if(i===this.keyCode.ESC)this.selection.get().collapseToStart();else if(i===this.keyCode.BACKSPACE||i===this.keyCode.DELETE){var r=this.selection.get(),o=this.selection.range(r);o.deleteContents()}else i===this.keyCode.ENTER&&this.selection.get().collapseToEnd();this.air.enabled?this.air.hide(e):this.selection.get().collapseToStart()}},this))},hide:function(e){var i=e.ctrlKey||e.metaKey||e.shiftKey&&e.altKey;return i?!1:(this.button.setInactiveAll(),this.$air.fadeOut(100),this.air.enabled=!1,t(document).off("mousedown.redactor-air."+this.uuid),void t(document).off("keydown.redactor-air."+this.uuid))}}},autosave:function(){return{enabled:!1,html:!1,init:function(){this.opts.autosave&&(this.autosave.enabled=!0,this.autosave.name=this.opts.autosaveName?this.opts.autosaveName:this.$textarea.attr("name"))},is:function(){return this.autosave.enabled},send:function(){if(this.opts.autosave&&(this.autosave.source=this.code.get(),this.autosave.html!==this.autosave.source)){var e={};e.name=this.autosave.name,e[this.autosave.name]=this.autosave.source,e=this.autosave.getHiddenFields(e);var i=t.ajax({url:this.opts.autosave,type:"post",data:e});i.done(this.autosave.success)}},getHiddenFields:function(e){return this.opts.autosaveFields===!1||"object"!=typeof this.opts.autosaveFields?e:(t.each(this.opts.autosaveFields,t.proxy(function(i,r){null!==r&&0===r.toString().indexOf("#")&&(r=t(r).val()),e[i]=r},this)),e)},success:function(t){var e;try{e=JSON.parse(t)}catch(i){e=t}var r="undefined"==typeof e.error?"autosave":"autosaveError";this.core.callback(r,this.autosave.name,e),this.autosave.html=this.autosave.source},disable:function(){this.autosave.enabled=!1,clearInterval(this.autosaveTimeout)}}},block:function(){return{format:function(e,i,r,o){return e="quote"===e?"blockquote":e,this.block.tags=["p","blockquote","pre","h1","h2","h3","h4","h5","h6","div","figure"],-1!==t.inArray(e,this.block.tags)?("p"===e&&"undefined"==typeof i&&(i="class"),this.placeholder.hide(),this.buffer.set(),this.utils.isCollapsed()?this.block.formatCollapsed(e,i,r,o):this.block.formatUncollapsed(e,i,r,o)):void 0},formatCollapsed:function(e,i,r,o){this.selection.save();var s=this.selection.block(),n=s.tagName.toLowerCase();if(-1===t.inArray(n,this.block.tags))return void this.selection.restore();var a=!1;n===e&&void 0===i&&(e="p",a=!0),a&&(this.block.removeAllClass(),this.block.removeAllAttr());var l;if("blockquote"===n&&this.utils.isEndOfElement(s)){this.marker.remove(),l=document.createElement("p"),l.innerHTML=this.opts.invisibleSpace,t(s).after(l),this.caret.start(l);var c=t(s).children().last();0!==c.length&&"BR"===c[0].tagName&&c.remove()}else l=this.utils.replaceToTag(s,e);if("object"==typeof i){o=r;for(var d in i)l=this.block.setAttr(l,d,i[d],o)}else l=this.block.setAttr(l,i,r,o);return"pre"===e&&1===l.length&&t(l).html(t.trim(t(l).html())),this.selection.restore(),this.block.removeInlineTags(l),l},formatUncollapsed:function(e,i,r,o){this.selection.save();var s=[],n=this.selection.blocks();n[0]&&(t(n[0]).hasClass("redactor-in")||t(n[0]).hasClass("redactor-box"))&&(n=this.core.editor().find(this.opts.blockTags.join(", ")));for(var a=n.length,l=0;a>l;l++){var c=n[l].tagName.toLowerCase();if(-1!==t.inArray(c,this.block.tags)&&"figure"!==c){var d=this.utils.replaceToTag(n[l],e);if("object"==typeof i){o=r;for(var h in i)d=this.block.setAttr(d,h,i[h],o)}else d=this.block.setAttr(d,i,r,o);s.push(d),this.block.removeInlineTags(d)}}if(this.selection.restore(),"pre"===e&&0!==s.length){var u=s[0];t.each(s,function(e,i){0!==e&&(t(u).append("\n"+t.trim(i.html())),t(i).remove())}),s=[],s.push(u)}return s},removeInlineTags:function(e){e=e[0]||e;var i=this.opts.inlineTags,r=["PRE","H1","H2","H3","H4","H5","H6"];if(-1!==t.inArray(e.tagName,r)){if("PRE"!==e.tagName){var o=i.indexOf("a");i.splice(o,1)}t(e).find(i.join(",")).not(".redactor-selection-marker").contents().unwrap()}},setAttr:function(t,e,i,r){if("undefined"==typeof e)return t;var o="undefined"==typeof r?"replace":r;return t="class"===e?this.block[o+"Class"](i,t):"remove"===o?this.block[o+"Attr"](e,t):"removeAll"===o?this.block[o+"Attr"](e,t):this.block[o+"Attr"](e,i,t)},getBlocks:function(t){return"undefined"==typeof t?this.selection.blocks():t},replaceClass:function(e,i){return t(this.block.getBlocks(i)).removeAttr("class").addClass(e)[0]},toggleClass:function(e,i){return t(this.block.getBlocks(i)).toggleClass(e)[0]},addClass:function(e,i){return t(this.block.getBlocks(i)).addClass(e)[0]},removeClass:function(e,i){return t(this.block.getBlocks(i)).removeClass(e)[0]},removeAllClass:function(e){return t(this.block.getBlocks(e)).removeAttr("class")[0]},replaceAttr:function(e,i,r){return r=this.block.removeAttr(e,r),t(r).attr(e,i)[0]},toggleAttr:function(e,i,r){r=this.block.getBlocks(r);var o=this,s=[];return t.each(r,function(r,n){var a=t(n);a.attr(e)?s.push(o.block.removeAttr(e,n)):s.push(o.block.addAttr(e,i,n))}),s},addAttr:function(e,i,r){return t(this.block.getBlocks(r)).attr(e,i)[0]},removeAttr:function(e,i){return t(this.block.getBlocks(i)).removeAttr(e)[0]},removeAllAttr:function(e){e=this.block.getBlocks(e);var i=[];return t.each(e,function(e,r){"undefined"==typeof r.attributes&&i.push(r);for(var o=t(r),s=r.attributes.length,n=0;s>n;n++)o.removeAttr(r.attributes[n].name);i.push(o[0])}),i}}},buffer:function(){return{set:function(t){"undefined"==typeof t&&this.buffer.clear(),"undefined"==typeof t||"undo"===t?this.buffer.setUndo():this.buffer.setRedo()},setUndo:function(){var t=this.selection.saveInstant(),e=this.opts.buffer[this.opts.buffer.length-1],i=this.core.editor().html(),r="undefined"==typeof e||e[0]!==i;r&&this.opts.buffer.push([i,t])},setRedo:function(){var t=this.selection.saveInstant();this.opts.rebuffer.push([this.core.editor().html(),t])},add:function(){this.opts.buffer.push([this.core.editor().html(),0])},undo:function(){if(0!==this.opts.buffer.length){var t=this.opts.buffer.pop();this.buffer.set("redo"),this.core.editor().html(t[0]),this.selection.restoreInstant(t[1]),this.observe.load()}},redo:function(){if(0!==this.opts.rebuffer.length){var t=this.opts.rebuffer.pop();this.buffer.set("undo"),this.core.editor().html(t[0]),this.selection.restoreInstant(t[1]),this.observe.load()}},clear:function(){this.opts.rebuffer=[]}}},build:function(){return{start:function(){if("inline"===this.opts.type)this.opts.type="inline";else if("div"===this.opts.type){var e=t.trim(this.$editor.html());""===e&&this.$editor.html(this.opts.emptyHtml)}else"textarea"===this.opts.type&&this.build.startTextarea();this.build.setIn(),this.build.setId(),this.build.enableEditor(),this.build.setOptions(),this.build.callEditor()},createContainerBox:function(){this.$box=t('<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","undefined"==typeof t?"redactor-uuid-"+this.uuid:t)},getName:function(){var t=this.$element.attr("name");return"undefined"==typeof t?"content-"+this.uuid:t},loadFromTextarea:function(){this.$editor=t("<div />"),this.$textarea=this.$element,this.$element.attr("name",this.build.getName()),this.$box.insertAfter(this.$element).append(this.$editor).append(this.$element),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>"),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.opts.air=!1,this.opts.linkify=!1),this.core.editor().attr("spellcheck",this.opts.spellcheck),this.opts.structure&&this.core.editor().addClass("redactor-structure"),"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.opts.toolbar||this.opts.air)&&(this.toolbarsButtons=this.button.init()),this.opts.air?this.air.build():this.opts.toolbar&&this.toolbar.build(),this.detect.isMobile()&&this.opts.toolbarMobile&&this.opts.air&&(this.opts.toolbar=!0,this.toolbar.build()),(this.opts.air||this.opts.toolbar)&&(this.core.editor().on("mouseup.redactor-observe."+this.uuid+" keyup.redactor-observe."+this.uuid+" focus.redactor-observe."+this.uuid+" touchstart.redactor-observe."+this.uuid,t.proxy(this.observe.toolbar,this)),this.core.element().on("blur.callback.redactor",t.proxy(function(){this.button.setInactiveAll()},this))),this.modal.templates(),this.build.plugins(),this.autosave.init(),this.code.html=this.code.cleaned(this.core.editor().html()),this.core.callback("init"),this.core.callback("initToEdit"),this.storage.observe(),this.start=!1},setHelpers:function(){this.opts.linkify&&this.linkify.format(),this.placeholder.init(),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&&t.each(this.opts.plugins,t.proxy(function(e,r){var o="undefined"!=typeof RedactorPlugins&&"undefined"!=typeof RedactorPlugins[r]?RedactorPlugins:i.fn;if(t.isFunction(o[r])){this[r]=o[r]();for(var s=this.getModuleMethods(this[r]),n=s.length,a=0;n>a;a++)this[r][s[a]]=this[r][s[a]].bind(this);if("undefined"!=typeof this[r].langs){var l={};"undefined"!=typeof this[r].langs[this.opts.lang]?l=this[r].langs[this.opts.lang]:"undefined"==typeof this[r].langs[this.opts.lang]&&"undefined"!=typeof this[r].langs.en&&(l=this[r].langs.en);var c=this;t.each(l,function(t,e){"undefined"==typeof c.opts.curLang[t]&&(c.opts.curLang[t]=e)})}t.isFunction(this[r].init)&&this[r].init()}},this))}}},button:function(){return{toolbar:function(){return"undefined"!=typeof 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(){t.each(this.toolbarsButtons.format.dropdown,t.proxy(function(e,i){-1===t.inArray(e,this.opts.formatting)&&delete this.toolbarsButtons.format.dropdown[e]},this))},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(e){t.each(e,t.proxy(function(t,e){var i=this.opts.buttons.indexOf(e);-1!==i&&this.opts.buttons.splice(i,1)},this))},load:function(e){this.button.buttons=[],t.each(this.opts.buttons,t.proxy(function(i,r){!this.toolbarsButtons[r]||"file"===r&&!this.file.is()||"image"===r&&!this.image.is()||e.append(t("<li>").append(this.button.build(r,this.toolbarsButtons[r])))},this))},buildButtonTooltip:function(e,i){if(!this.opts.air&&!this.detect.isMobile()){var r=t("<span>");r.addClass("re-button-tooltip"),r.html(i),e.append(r),e.on("mouseover",function(){t(this).hasClass("redactor-button-disabled")||(r.show(),r.css("margin-left",-(r.innerWidth()/2)))}).on("mouseout",function(){r.hide()})}},build:function(e,i){if(this.opts.toolbar!==!1){var r="undefined"!=typeof i.label?i.label:i.title,o=t('<a href="javascript:void(null);" alt="'+r+'" rel="'+e+'" />');if(o.addClass("re-button re-"+e),o.attr({role:"button","aria-label":r,tabindex:"-1"}),"undefined"==typeof i.icon||this.opts.buttonsTextLabeled)o.html(i.title);else{var s=t("<i>");s.addClass("re-icon-"+e),o.append(s),o.addClass("re-button-icon"),this.button.buildButtonTooltip(o,r)}if((i.func||i.command||i.dropdown)&&this.button.setEvent(o,e,i),i.dropdown){o.addClass("redactor-toolbar-link-dropdown").attr("aria-haspopup",!0);var n=t('<ul class="redactor-dropdown redactor-dropdown-'+this.uuid+" redactor-dropdown-box-"+e+'" style="display: none;">');o.data("dropdown",n),this.dropdown.build(e,n,i.dropdown)}return this.button.buttons.push(o),o}},getButtons:function(){return this.button.toolbar().find("a.re-button")},getButtonsKeys:function(){return this.button.buttons},setEvent:function(e,i,r){e.on("mousedown",t.proxy(function(t){if(t.preventDefault(),e.hasClass("redactor-button-disabled"))return!1;var o="func",s=r.func;return r.command?(o="command",s=r.command):r.dropdown&&(o="dropdown",s=!1),this.button.toggle(t,i,o,s),!1},this))},toggle:function(t,e,i,r,o){!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,o),"dropdown"!==i&&this.dropdown.hideAll(!1),this.opts.air&&"dropdown"!==i&&this.air.hide(t),!this.detect.isIe()&&this.detect.isDesktop()||this.utils.unfreezeScroll()},clickCallback:function(e,i,r,o){var s;if(o="undefined"==typeof o?r:o,t.isFunction(i))i.call(this,r);else if("-1"!==i.search(/\./)){if(s=i.split("."),"undefined"==typeof this[s[0]])return;"object"==typeof o?this[s[0]][s[1]].apply(this,o):this[s[0]][s[1]].call(this,o)}else"object"==typeof o?this[i].apply(this,o):this[i].call(this,o);this.observe.buttons(e,r)},all:function(){return this.button.buttons},get:function(t){return this.opts.toolbar!==!1?this.button.toolbar().find("a.re-"+t):void 0},set:function(t,e){if(this.opts.toolbar!==!1){var i=this.button.toolbar().find("a.re-"+t);return i.html(e).attr("aria-label",e),i}},add:function(e,i){if(this.button.isAdded(e)!==!0)return t();var r=this.button.build(e,{title:i});return this.button.toolbar().append(t("<li>").append(r)),r},addFirst:function(e,i){if(this.button.isAdded(e)!==!0)return t();var r=this.button.build(e,{title:i});return this.button.toolbar().prepend(t("<li>").append(r)),r},addAfter:function(e,i,r){if(this.button.isAdded(i)!==!0)return t();var o=this.button.build(i,{title:r}),s=this.button.get(e);return 0!==s.length?s.parent().after(t("<li>").append(o)):this.button.toolbar().append(t("<li>").append(o)),o},addBefore:function(e,i,r){if(this.button.isAdded(i)!==!0)return t();var o=this.button.build(i,{title:r}),s=this.button.get(e);return 0!==s.length?s.parent().before(t("<li>").append(o)):this.button.toolbar().append(t("<li>").append(o)),o},isAdded:function(t){var e=this.opts.buttonsHideOnMobile.indexOf(t);return!(this.opts.toolbar===!1||-1!==e&&this.detect.isMobile())},setIcon:function(t,e){this.opts.buttonsTextLabeled||(t.html(e).addClass("re-button-icon"),this.button.buildButtonTooltip(t,t.attr("alt")))},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){if("undefined"!=typeof e&&this.opts.toolbar!==!1){var r="dropdown"===i?"dropdown":"func",o=e.attr("rel");e.on("mousedown",t.proxy(function(t){return e.hasClass("redactor-button-disabled")?!1:void this.button.toggle(t,o,r,i)},this))}},addDropdown:function(e,i){if(this.opts.toolbar!==!1){e.addClass("redactor-toolbar-link-dropdown").attr("aria-haspopup",!0);var r=e.attr("rel");this.button.addCallback(e,"dropdown");var o=t('<div class="redactor-dropdown redactor-dropdown-'+this.uuid+" redactor-dropdown-box-"+r+'" style="display: none;">');return e.data("dropdown",o),i&&this.dropdown.build(r,o,i),o}},setActive:function(t){this.button.get(t).addClass("redactor-act")},setInactive:function(t){this.button.get(t).removeClass("redactor-act")},setInactiveAll:function(t){var e=this.button.toolbar().find("a.re-button");"undefined"!=typeof t&&(e=e.not(".re-"+t)),e.removeClass("redactor-act")},disable:function(t){this.button.get(t).addClass("redactor-button-disabled")},enable:function(t){this.button.get(t).removeClass("redactor-button-disabled")},disableAll:function(t){var e=this.button.toolbar().find("a.re-button");"undefined"!=typeof t&&(e=e.not(".re-"+t)),e.addClass("redactor-button-disabled")},enableAll:function(){this.button.toolbar().find("a.re-button").removeClass("redactor-button-disabled")},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="undefined"==typeof i?0:1,t=t[0]||t,e=e[0]||e;var o=this.selection.get(),s=this.selection.range(o);try{s.setStart(t,0),s.setEnd(e,i)}catch(n){}this.selection.update(o,s)},prepare:function(t){return this.detect.isFirefox()&&"undefined"!=typeof this.start&&this.core.editor().focus(),t[0]||t},start:function(e){var i,r;if(e=this.caret.prepare(e)){if("BR"===e.tagName)return this.caret.before(e);var o=t(e).children().first(),s=this.utils.isInlineTag(e.tagName);""===e.innerHTML||s?this.caret.setStartEmptyOrInline(e,s):o&&0!==o.length&&this.utils.isInlineTag(o[0].tagName)&&""===o.text()?this.caret.setStartEmptyOrInline(o[0],!0):(i=window.getSelection(),i.removeAllRanges(),r=document.createRange(),r.selectNodeContents(e),r.collapse(!0),i.addRange(r))}},setStartEmptyOrInline:function(e,i){var r=window.getSelection(),o=document.createRange(),s=document.createTextNode("​");o.setStart(e,0),o.insertNode(s),o.setStartAfter(s),o.collapse(!0),r.removeAllRanges(),r.addRange(o),i||this.core.editor().on("keydown.redactor-remove-textnode",function(){t(s).remove(),t(this).off("keydown.redactor-remove-textnode")})},end:function(e){var i,r;if(e=this.caret.prepare(e)){if("BR"!==e.tagName&&""===e.innerHTML)return this.caret.start(e);if("BR"===e.tagName){var o=document.createElement("span");return o.className="redactor-invisible-space",o.innerHTML="&#x200b;",t(e).after(o),i=window.getSelection(),i.removeAllRanges(),r=document.createRange(),r.setStartBefore(o),r.setEndBefore(o),i.addRange(r),void t(o).replaceWith(function(){return t(this).contents()})}if(e.lastChild&&1===e.lastChild.nodeType)return this.caret.after(e.lastChild);
-i=window.getSelection(),i.removeAllRanges();try{r=document.createRange(),r.selectNodeContents(e),r.collapse(!1),i.addRange(r)}catch(s){}}},after:function(e){var i,r;if(e=this.caret.prepare(e)){if("BR"===e.tagName)return this.caret.end(e);if(this.utils.isBlockTag(e.tagName)){var o=this.caret.next(e);return void("undefined"==typeof o?this.caret.end(e):("TABLE"===o.tagName?o=t(o).find("th, td").first()[0]:"UL"!==o.tagName&&"OL"!==o.tagName||(o=t(o).find("li").first()[0]),this.caret.start(o)))}var s=document.createTextNode("​");i=window.getSelection(),i.removeAllRanges(),r=document.createRange(),r.setStartAfter(e),r.insertNode(s),r.setStartAfter(s),r.collapse(!0),i.addRange(r)}},before:function(e){var i,r;if(e=this.caret.prepare(e)){if(this.utils.isBlockTag(e.tagName)){var o=this.caret.prev(e);return void("undefined"==typeof o?this.caret.start(e):("TABLE"===o.tagName?o=t(o).find("th, td").last()[0]:"UL"!==o.tagName&&"OL"!==o.tagName||(o=t(o).find("li").last()[0]),this.caret.end(o)))}i=window.getSelection(),i.removeAllRanges(),r=document.createRange(),r.setStartBefore(e),r.collapse(!0),i.addRange(r)}},next:function(e){var i=t(e).next();return i.hasClass("redactor-script-tag, redactor-selection-marker")?i.next()[0]:i[0]},prev:function(e){var i=t(e).prev();return i.hasClass("redactor-script-tag, redactor-selection-marker")?i.prev()[0]:i[0]},offset:function(t){return this.offset.get(t)}}},clean:function(){return{onSet:function(e){e=this.clean.savePreCode(e),e=this.clean.saveFormTags(e),this.opts.script&&(e=e.replace(/<script(.*?[^>]?)>([\w\W]*?)<\/script>/gi,'<pre class="redactor-script-tag" $1>$2</pre>')),e=e.replace(/\$/g,"&#36;"),e=e.replace(/&amp;/g,"&"),e=e.replace(/<a href="(.*?[^>]?)®(.*?[^>]?)">/gi,'<a href="$1&reg$2">'),e=e.replace(/<span id="selection-marker-1"(.*?[^>]?)>​<\/span>/gi,"###marker1###"),e=e.replace(/<span id="selection-marker-2"(.*?[^>]?)>​<\/span>/gi,"###marker2###");var i=this,r=t("<div/>").html(t.parseHTML(e,document,!0)),o=this.opts.replaceTags;if(o){var s=Object.keys(this.opts.replaceTags);r.find(s.join(",")).each(function(t,e){i.utils.replaceToTag(e,o[e.tagName.toLowerCase()])})}r.find("span, a").attr("data-redactor-span",!0),r.find(this.opts.inlineTags.join(",")).each(function(){var e=t(this);e.attr("style")&&e.attr("data-redactor-style-cache",e.attr("style"))}),e=r.html();var n=["font","html","head","link","body","meta","applet"];return this.opts.script||n.push("script"),e=this.clean.stripTags(e,n),this.opts.removeComments&&(e=e.replace(/<!--[\s\S]*?-->/gi,"")),e=this.paragraphize.load(e),e=e.replace("###marker1###",'<span id="selection-marker-1" class="redactor-selection-marker">​</span>'),e=e.replace("###marker2###",'<span id="selection-marker-2" class="redactor-selection-marker">​</span>'),-1!==e.search(/^(||\s||<br\s?\/?>||&nbsp;)$/i)?this.opts.emptyHtml:e},onGet:function(t){return this.clean.onSync(t)},onSync:function(e){if(e=e.replace(/\u200B/g,""),e=e.replace(/&#x200b;/gi,""),-1!==e.search(/^<p>(||\s||<br\s?\/?>||&nbsp;)<\/p>$/i))return"";e=e.replace(/<span(.*?)id="redactor-image-box"(.*?[^>])>([\w\W]*?)<img(.*?)><\/span>/gi,"$3<img$4>"),e=e.replace(/<span(.*?)id="redactor-image-resizer"(.*?[^>])>(.*?)<\/span>/gi,""),e=e.replace(/<span(.*?)id="redactor-image-editter"(.*?[^>])>(.*?)<\/span>/gi,""),e=e.replace(/<img(.*?)style="(.*?)opacity: 0\.5;(.*?)"(.*?)>/gi,'<img$1style="$2$3"$4>');var i=t("<div/>").html(t.parseHTML(e,document,!0));i.find('*[style=""]').removeAttr("style"),i.find('*[class=""]').removeAttr("class"),i.find('*[rel=""]').removeAttr("rel"),i.find('*[data-image=""]').removeAttr("data-image"),i.find('*[alt=""]').removeAttr("alt"),i.find('*[title=""]').removeAttr("title"),i.find("*[data-redactor-style-cache]").removeAttr("data-redactor-style-cache"),i.find(".redactor-invisible-space, .redactor-unlink").each(function(){t(this).contents().unwrap()}),i.find("span, a").removeAttr("data-redactor-span data-redactor-style-cache").each(function(){0===this.attributes.length&&t(this).contents().unwrap()}),i.find("img").removeAttr("rel"),i.find(".redactor-selection-marker, #redactor-insert-marker").remove(),e=i.html(),this.opts.script&&(e=e.replace(/<pre class="redactor-script-tag"(.*?[^>]?)>([\w\W]*?)<\/pre>/gi,"<script$1>$2</script>")),e=this.clean.restoreFormTags(e),e=e.replace(new RegExp("<br\\s?/?></h","gi"),"</h"),e=e.replace(new RegExp("<br\\s?/?></li>","gi"),"</li>"),e=e.replace(new RegExp("</li><br\\s?/?>","gi"),"</li>"),e=e.replace(/<pre>/gi,"<pre>\n"),this.opts.preClass&&(e=e.replace(/<pre>/gi,'<pre class="'+this.opts.preClass+'">')),this.opts.linkNofollow&&(e=e.replace(/<a(.*?)rel="nofollow"(.*?[^>])>/gi,"<a$1$2>"),e=e.replace(/<a(.*?[^>])>/gi,'<a$1 rel="nofollow">'));var r={"™":"&trade;","©":"&copy;","…":"&hellip;","—":"&mdash;","‐":"&dash;"};return t.each(r,function(t,i){e=e.replace(new RegExp(t,"g"),i)}),e=e.replace(/&amp;/g,"&"),e=e.replace(/<p><\/p>/gi,""),e=e.replace(/\n{2,}/g,"\n"),this.opts.removeNewlines&&(e=e.replace(/\r?\n/g,"")),e},onPaste:function(e,i,r){if(r!==!0){e=e.replace(/<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2"),e=e.replace(/<b(.*?)id="docs-internal-guid(.*?)">([\w\W]*?)<\/b>/gi,"$3"),e=e.replace(/<span[^>]*(font-style: italic; font-weight: bold|font-weight: bold; font-style: italic)[^>]*>([\w\W]*?)<\/span>/gi,"<b><i>$2</i></b>"),e=e.replace(/<span[^>]*(font-style: italic; font-weight: 700|font-weight: 700; font-style: italic)[^>]*>([\w\W]*?)<\/span>/gi,"<b><i>$2</i></b>"),e=e.replace(/<span[^>]*font-style: italic[^>]*>([\w\W]*?)<\/span>/gi,"<i>$1</i>"),e=e.replace(/<span[^>]*font-weight: bold[^>]*>([\w\W]*?)<\/span>/gi,"<b>$1</b>"),e=e.replace(/<span[^>]*font-weight: 700[^>]*>([\w\W]*?)<\/span>/gi,"<b>$1</b>"),e=e.replace(/<o:p[^>]*>/gi,""),e=e.replace(/<\/o:p>/gi,"");var o=this.clean.isHtmlMsWord(e);o&&(e=this.clean.cleanMsWord(e))}return e=t.trim(e),i.pre?this.opts.preSpaces&&(e=e.replace(/\t/g,new Array(this.opts.preSpaces+1).join(" "))):(e=this.clean.replaceBrToNl(e),e=this.clean.removeTagsInsidePre(e)),r!==!0&&(e=this.clean.removeEmptyInlineTags(e),i.encode===!1&&(e=e.replace(/&/g,"&amp;"),e=this.clean.convertTags(e,i),e=this.clean.getPlainText(e),e=this.clean.reconvertTags(e,i))),i.text&&(e=this.clean.replaceNbspToSpaces(e),e=this.clean.getPlainText(e)),i.lists&&(e=e.replace("\n","<br>")),i.encode&&(e=this.clean.encodeHtml(e)),i.paragraphize&&(e=e.replace(/ \n/g," "),e=e.replace(/\n /g," "),e=this.paragraphize.load(e),e=e.replace(/<p><\/p>/g,"")),e},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||this.opts.enterKey===!1?(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),r.line===!0&&(r.paragraphize=!1),e===!0&&(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(e){var i=this.opts.inlineTags,r=t("<div/>").html(t.parseHTML(e,document,!0)),o=this,s=r.find("span"),n=r.find(i.join(","));return n.removeAttr("style"),n.each(function(){var e=t(this).html();0===this.attributes.length&&o.utils.isEmpty(e)&&t(this).replaceWith(function(){return t(this).contents()})}),s.each(function(){t(this).html();0===this.attributes.length&&t(this).replaceWith(function(){return t(this).contents()})}),e=r.html(),e=e.replace("<!--?php","<?php"),e=e.replace("<!--?","<?"),e=e.replace("?-->","?>"),r.remove(),e},cleanMsWord:function(e){e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/<o:p>[\s\S]*?<\/o:p>/gi,""),e=e.replace(/\n/g," "),e=e.replace(/<br\s?\/?>|<\/p>|<\/div>|<\/li>|<\/td>/gi,"\n\n");var i=t("<div/>").html(e),r=!1,o=1,s=[];return i.find("p[style]").each(function(){var e=t(this).attr("style").match(/mso\-list\:l([0-9]+)\slevel([0-9]+)/);if(e){var n=parseInt(e[1]),a=parseInt(e[2]),l=t(this).html().match(/^[\w]+\./)?"ol":"ul",c=t("<li/>").html(t(this).html());if(c.html(c.html().replace(/^([\w\.]+)</,"<")),c.find("span:first").remove(),1==a&&-1==t.inArray(n,s)){var d=t("<"+l+"/>").attr({"data-level":a,"data-list":n}).html(c);t(this).replaceWith(d),r=n,s.push(n)}else{if(a>o){for(var h=i.find('[data-level="'+o+'"][data-list="'+r+'"]'),u=h,p=o;a>p;p++)d=t("<"+l+"/>"),d.appendTo(u.find("li").last()),u=d;u.attr({"data-level":a,"data-list":n}).html(c)}else{var h=i.find('[data-level="'+a+'"][data-list="'+n+'"]').last();h.append(c)}o=a,r=n,t(this).remove()}}}),i.find("[data-level][data-list]").removeAttr("data-level data-list"),e=i.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(e,i){var r=t("<div>").html(e);r.find("iframe").remove();var o=r.find("a");if(o.removeAttr("style"),this.opts.pasteLinkTarget!==!1&&o.attr("target",this.opts.pasteLinkTarget),i.links&&this.opts.pasteLinks&&r.find("a").each(function(t,e){if(e.href){for(var i,r='##%a href="'+e.href+'"',o=0,s=e.attributes.length;s>o;o++)i=e.attributes.item(o),"href"!==i.name&&(r+=" "+i.name+'="'+i.value+'"');e.outerHTML=r+"%##"+e.innerHTML+"##%/a%##"}}),e=r.html(),i.images&&this.opts.pasteImages&&(e=e.replace(/<img(.*?)src="(.*?)"(.*?[^>])>/gi,'##%img$1src="$2"$3%##')),this.opts.pastePlainText)return e;var s,n=i.lists?["ul","ol","li"]:this.opts.pasteBlockTags;s=i.block||i.lists?i.inline?n.concat(this.opts.pasteInlineTags):n:i.inline?this.opts.pasteInlineTags:[];for(var a=s.length,l=0;a>l;l++)e=e.replace(new RegExp("</"+s[l]+">","gi"),"###/"+s[l]+"###"),"td"===s[l]||"th"===s[l]?e=e.replace(new RegExp("<"+s[l]+'(.*?[^>])((colspan|rowspan)="(.*?[^>])")?(.*?[^>])>',"gi"),"###"+s[l]+" $2###"):this.utils.isInlineTag(s[l])?(e=e.replace(new RegExp("<"+s[l]+'([^>]*)class="([^>]*)"[^>]*>',"gi"),"###"+s[l]+' class="$2"###'),e=e.replace(new RegExp("<"+s[l]+'([^>]*)data-redactor-style-cache="([^>]*)"[^>]*>',"gi"),"###"+s[l]+' cache="$2"###'),e=e.replace(new RegExp("<"+s[l]+"[^>]*>","gi"),"###"+s[l]+"###")):e=e.replace(new RegExp("<"+s[l]+"[^>]*>","gi"),"###"+s[l]+"###");return e},reconvertTags:function(t,e){if((e.links&&this.opts.pasteLinks||e.images&&this.opts.pasteImages)&&(t=t.replace(new RegExp("##%","gi"),"<"),t=t.replace(new RegExp("%##","gi"),">")),this.opts.pastePlainText)return t;var i,r=e.lists?["ul","ol","li"]:this.opts.pasteBlockTags;i=e.block||e.lists?e.inline?r.concat(this.opts.pasteInlineTags):r:e.inline?this.opts.pasteInlineTags:[];for(var o=i.length,s=0;o>s;s++)t=t.replace(new RegExp("###/"+i[s]+"###","gi"),"</"+i[s]+">");for(var s=0;o>s;s++)t=t.replace(new RegExp("###"+i[s]+"###","gi"),"<"+i[s]+">");for(var s=0;o>s;s++)if("td"===i[s]||"th"===i[s])t=t.replace(new RegExp("###"+i[s]+"s?(.*?[^#])###","gi"),"<"+i[s]+"$1>");else if(this.utils.isInlineTag(i[s])){var n="span"===i[s]?' data-redactor-span="true"':"";t=t.replace(new RegExp("###"+i[s]+' cache="(.*?[^#])"###',"gi"),"<"+i[s]+' style="$1"'+n+' data-redactor-style-cache="$1">'),t=t.replace(new RegExp("###"+i[s]+"s?(.*?[^#])###","gi"),"<"+i[s]+"$1>")}return t},cleanPre:function(e){e="undefined"==typeof e?t(this.selection.block()).closest("pre",this.core.editor()[0]):e,t(e).find("br").replaceWith(function(){return document.createTextNode("\n")}),t(e).find("p").replaceWith(function(){return t(this).contents()})},removeTagsInsidePre:function(e){var i=t("<div />").append(e);return i.find("pre").replaceWith(function(){var e=t(this).html();return e=e.replace(/<br\s?\/?>|<\/p>|<\/div>|<\/li>|<\/td>/gi,"\n"),e=e.replace(/(<([^>]+)>)/gi,""),t("<pre />").append(e)}),e=i.html(),i.remove(),e},getPlainText:function(e){e=e.replace(/<!--[\s\S]*?-->/gi,""),e=e.replace(/<style[\s\S]*?style>/gi,""),e=e.replace(/<p><\/p>/g,""),e=e.replace(/<\/div>|<\/li>|<\/td>/gi,"\n"),e=e.replace(/<\/p>/gi,"\n\n"),e=e.replace(/<\/H[1-6]>/gi,"\n\n");var i=document.createElement("div");return i.innerHTML=e,e=i.textContent||i.innerText,t.trim(e)},savePreCode:function(t){return t=this.clean.savePreFormatting(t),t=this.clean.saveCodeFormatting(t),t=this.clean.restoreSelectionMarkers(t)},savePreFormatting:function(e){var i=e.match(/<pre(.*?)>([\w\W]*?)<\/pre>/gi);return null===i?e:(t.each(i,t.proxy(function(t,i){var r,o,s,n=[],a=!1;i.match(/<pre(.*?)>(([\n\r\s]+)?)<code(.*?)>/i)?(n=i.match(/<pre(.*?)>(([\n\r\s]+)?)<code(.*?)>([\w\W]*?)<\/code>(([\n\r\s]+)?)<\/pre>/i),a=!0,r=n[5],o=n[1],s=n[4]):(n=i.match(/<pre(.*?)>([\w\W]*?)<\/pre>/i),r=n[2],o=n[1]),r=r.replace(/<br\s?\/?>/g,"\n"),r=r.replace(/&nbsp;/g," "),this.opts.preSpaces&&(r=r.replace(/\t/g,new Array(this.opts.preSpaces+1).join(" "))),r=this.clean.encodeEntities(r),r=r.replace(/\$/g,"&#36;"),e=a?e.replace(i,"<pre"+o+"><code"+s+">"+r+"</code></pre>"):e.replace(i,"<pre"+o+">"+r+"</pre>")},this)),e)},saveCodeFormatting:function(e){var i=e.match(/<code(.*?)>([\w\W]*?)<\/code>/gi);return null===i?e:(t.each(i,t.proxy(function(t,i){var r=i.match(/<code(.*?)>([\w\W]*?)<\/code>/i);r[2]=r[2].replace(/&nbsp;/g," "),r[2]=this.clean.encodeEntities(r[2]),r[2]=r[2].replace(/\$/g,"&#36;"),e=e.replace(i,"<code"+r[1]+">"+r[2]+"</code>")},this)),e)},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.replace(/<form(.*?)>([\w\W]*?)<\/form>/gi,'<section$1 rel="redactor-form-tag">$2</section>')},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.replace(/”/g,'"'),t=t.replace(/“/g,'"'),t=t.replace(/‘/g,"'"),t=t.replace(/’/g,"'"),t=this.clean.encodeEntities(t)},encodeEntities:function(t){return t=String(t).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"'),t=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},stripTags:function(t,e){if("undefined"==typeof e)return t.replace(/(<([^>]+)>)/gi,"");var i=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;return t.replace(i,function(t,i){return-1===e.indexOf(i.toLowerCase())?t:""})},removeMarkers:function(t){return t.replace(/<span(.*?[^>]?)class="redactor-selection-marker"(.*?[^>]?)>([\w\W]*?)<\/span>/gi,"")},removeSpaces:function(e){return e=t.trim(e),e=e.replace(/\n/g,""),e=e.replace(/[\t]*/g,""),e=e.replace(/\n\s*\n/g,"\n"),e=e.replace(/^[\s\n]*/g," "),e=e.replace(/[\s\n]*$/g," "),e=e.replace(/>\s{2,}</g,"> <"),e=e.replace(/\n\n/g,"\n"),e=e.replace(/\u200B/g,"")},removeSpacesHard:function(e){return e=t.trim(e),e=e.replace(/\n/g,""),e=e.replace(/[\t]*/g,""),e=e.replace(/\n\s*\n/g,"\n"),e=e.replace(/^[\s\n]*/g,""),e=e.replace(/[\s\n]*$/g,""),e=e.replace(/>\s{2,}</g,"><"),e=e.replace(/\n\n/g,"\n"),e=e.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(e){e=t.trim(e),e=e.replace(/^(<span id="selection-marker-1" class="redactor-selection-marker">​<\/span>)/,""),"textarea"===this.opts.type?e=this.clean.onSet(e):"div"===this.opts.type&&""===e&&(e=this.opts.emptyHtml),e=e.replace(/<p><span id="selection-marker-1" class="redactor-selection-marker">​<\/span><\/p>/,""),this.events.stopDetectChanges(),this.core.editor().html(e),this.observe.load(),this.events.startDetectChanges()},set:function(e,i){e=t.trim(e),i=i||{},i.start&&(this.start=i.start),"textarea"===this.opts.type?e=this.clean.onSet(e):"div"===this.opts.type&&""===e&&(e=this.opts.emptyHtml),this.core.editor().html(e),"textarea"===this.opts.type&&this.code.sync(),this.placeholder.enable()},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 e=this.core.editor().html(),i=this.code.cleaned(e);if(!this.code.isSync(i))return this.code.html=i,"textarea"!==this.opts.type?(this.core.callback("sync",e),void this.core.callback("change",e)):void("textarea"===this.opts.type&&setTimeout(t.proxy(function(){this.code.startSync(e)},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),this.start===!1&&this.core.callback("change",t),this.start=!1},isSync:function(t){var e=this.code.html!==!1?this.code.html:!1;return e!==!1&&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"undefined"==typeof this.$editor?t():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:!1},air:function(){return this.$air?this.$air:!1},object:function(){return t.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(e,i,r){var o="redactor",s=!1,n=t._data(this.core.element()[0],"events");if("undefined"!=typeof n&&"undefined"!=typeof n[e])for(var a=n[e].length,l=0;a>l;l++){var c=n[e][l].namespace;if(c==="callback."+o){var d=n[e][l].handler,h="undefined"==typeof r?[i]:[i,r];s="undefined"==typeof h?d.call(this,i):d.call(this,i,h)}}if(s)return s;if("undefined"==typeof this.opts.callbacks[e])return"undefined"==typeof r?i:r;var u=this.opts.callbacks[e];return t.isFunction(u)?"undefined"==typeof r?u.call(this,i):u.call(this,i,r):"undefined"==typeof r?i:r},destroy:function(){this.opts.destroyed=!0,this.core.callback("destroy"),this.placeholder.destroy(),this.progress.destroy(),t("#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"),t(document).off(".redactor-dropdown"),t(document).off(".redactor-air."+this.uuid),t(document).off("mousedown.redactor-blur."+this.uuid),t(document).off("mousedown.redactor."+this.uuid),t(document).off("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid),t(window).off(".redactor-toolbar."+this.uuid),t(window).off("touchmove.redactor."+this.uuid),t("body").off("scroll.redactor."+this.uuid),t(this.opts.toolbarFixedTarget).off("scroll.redactor."+this.uuid);var e=this;this.opts.plugins!==!1&&t.each(this.opts.plugins,function(i,r){t(window).off(".redactor-plugin-"+r),t(document).off(".redactor-plugin-"+r),t("body").off(".redactor-plugin-"+r),e.core.editor().off(".redactor-plugin-"+r)}),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 i=this.code.get();this.opts.toolbar&&this.$toolbar&&this.$toolbar.find("a").each(function(){var e=t(this);e.data("dropdown")&&(e.data("dropdown").remove(),e.data("dropdown",{}))}),"textarea"===this.opts.type&&(this.$box.after(this.$element),this.$box.remove(),this.$element.val(i).show()),this.opts.air&&this.$air.remove(),this.opts.toolbar&&this.$toolbar&&this.$toolbar.remove(),this.$modalBox&&this.$modalBox.remove(),this.$modalOverlay&&this.$modalOverlay.remove(),t(".redactor-link-tooltip").remove(),clearInterval(this.autosaveTimeout)}}},detect:function(){return{isWebkit:function(){return/webkit/.test(this.opts.userAgent)},isFirefox:function(){return this.opts.userAgent.indexOf("firefox")>-1},isIe:function(t){if(document.documentMode||/Edge/.test(navigator.userAgent))return"edge";var e;return e=RegExp("msie"+(isNaN(t)?"":"\\s"+t),"i").test(navigator.userAgent),e||(e=!!navigator.userAgent.match(/Trident.*rv[ :]*11\./)),e},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(e,i,r){r=this.dropdown.buildFormatting(e,r),t.each(r,t.proxy(function(t,r){var o=this.dropdown.buildItem(t,r);this.observe.addDropdown(o,t,r),i.attr("rel",e).append(o)},this))},buildFormatting:function(e,i){return"format"!==e||this.opts.formattingAdd===!1?i:(t.each(this.opts.formattingAdd,t.proxy(function(t,e){var r=this.utils.isBlockTag(e.args[0])?"block":"inline";i[t]={func:"block"===r?"block.format":"inline.format",args:e.args,title:e.title}},this)),i)},buildItem:function(e,i){var r=t("<li />");if("undefined"!=typeof i.classname&&r.addClass(i.classname),-1!==e.search(/^divider/i))return r.addClass("redactor-dropdown-divider"),r;var o=t('<a href="#" class="redactor-dropdown-'+e+'" role="button" />'),s=t("<span />").html(i.title);return o.append(s),o.on("mousedown",t.proxy(function(t){t.preventDefault(),this.dropdown.buildClick(t,e,i)},this)),r.append(o),r},buildClick:function(e,i,r){if(!t(e.target).hasClass("redactor-dropdown-link-inactive")){var o=this.dropdown.buildCommand(r);" undefined"!=typeof r.args?this.button.toggle(e,i,o.type,o.callback,r.args):this.button.toggle(e,i,o.type,o.callback)}},buildCommand:function(t){var e={};return e.type="func",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(e,i){return this.detect.isDesktop()&&this.core.editor().focus(),this.dropdown.hideAll(!1,i),this.dropdown.key=i,this.dropdown.button=this.button.get(this.dropdown.key),this.dropdown.button.hasClass("dropact")?void this.dropdown.hide():(this.dropdown.active=this.dropdown.button.data("dropdown").appendTo(document.body),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"),this.dropdown.getButtonPosition(),this.button.toolbar().hasClass("toolbar-fixed-box")&&this.detect.isDesktop()?this.dropdown.showIsFixedToolbar():this.dropdown.showIsUnFixedToolbar(),this.detect.isDesktop()&&!this.detect.isFirefox()&&(this.dropdown.active.on("mouseover.redactor-dropdown",t.proxy(this.utils.disableBodyScroll,this)),this.dropdown.active.on("mouseout.redactor-dropdown mousedown.redactor-dropdown",t.proxy(this.utils.enableBodyScroll,this))),void e.stopPropagation())},showIsFixedToolbar:function(){var e=this.dropdown.button.position().top+this.dropdown.button.innerHeight()+this.opts.toolbarFixedTopOffset,i="fixed";this.opts.toolbarFixedTarget!==document&&(e=this.dropdown.button.innerHeight()+this.$toolbar.offset().top+this.opts.toolbarFixedTopOffset,i="absolute"),this.dropdown.active.css({position:i,left:this.dropdown.position.left+"px",top:e+"px"}).show(),this.dropdown.active.redactorAnimation("slideDown",{duration:.2},t.proxy(function(){this.dropdown.enableCallback(),this.dropdown.enableEvents()},this))},showIsUnFixedToolbar:function(){this.dropdown.active.css({position:"absolute",left:this.dropdown.position.left+"px",top:this.dropdown.button.innerHeight()+this.dropdown.position.top+"px"}).show(),this.dropdown.active.redactorAnimation(this.opts.animation?"slideDown":"show",{duration:.2},t.proxy(function(){this.dropdown.enableCallback(),this.dropdown.enableEvents()},this))},enableEvents:function(){t(document).on("mousedown.redactor-dropdown",t.proxy(this.dropdown.hideAll,this)),this.core.editor().on("touchstart.redactor-dropdown",t.proxy(this.dropdown.hideAll,this)),t(document).on("keyup.redactor-dropdown",t.proxy(this.dropdown.closeHandler,this))},enableCallback:function(){this.core.callback("dropdownShown",{dropdown:this.dropdown.active,key:this.dropdown.key,button:this.dropdown.button})},getButtonPosition:function(){this.dropdown.position=this.dropdown.button.offset();var e=this.dropdown.active.width();this.dropdown.position.left+e>t(document).width()&&(this.dropdown.position.left=Math.max(0,this.dropdown.position.left-e+parseInt(this.dropdown.button.innerWidth())))},closeHandler:function(t){t.which===this.keyCode.ESC&&(this.dropdown.hideAll(t),this.core.editor().focus())},hideAll:function(e,i){if(this.detect.isDesktop()&&this.utils.enableBodyScroll(),e===!1||0===t(e.target).closest(".redactor-dropdown").length){var r="undefined"==typeof i?this.button.toolbar().find("a.dropact"):this.button.toolbar().find("a.dropact").not(".re-"+i),o="undefined"==typeof i?t(".redactor-dropdown-"+this.uuid):t(".redactor-dropdown-"+this.uuid).not(".redactor-dropdown-box-"+i);0!==o.length&&(t(document).off(".redactor-dropdown"),this.core.editor().off(".redactor-dropdown"),t.each(o,t.proxy(function(e,i){var r=t(i);this.core.callback("dropdownHide",r),r.hide(),r.off("mouseover mouseout").off(".redactor-dropdown")},this)),r.removeClass("redactor-act dropact"))}},hide:function(){this.dropdown.active!==!1&&(this.detect.isDesktop()&&this.utils.enableBodyScroll(),this.dropdown.active.redactorAnimation(this.opts.animation?"slideUp":"hide",{duration:.2},t.proxy(function(){t(document).off(".redactor-dropdown"),this.core.editor().off(".redactor-dropdown"),this.dropdown.hideOut()},this)))},hideOut:function(){this.core.callback("dropdownHide",this.dropdown.active),this.dropdown.button.removeClass("redactor-act dropact"),this.dropdown.active.off("mouseover mouseout").off(".redactor-dropdown"),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(e){e.preventDefault(),e.stopPropagation(),"IMG"===e.target.tagName&&t(e.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)):!0},click:function(t){var e=this.core.getEvent(),i="click"===e||"arrow"===e?!1:"click";this.core.addEvent(i),this.utils.disableSelectAll(),this.core.callback("click",t)},focus:function(t){if(!this.rtePaste&&(this.events.isCallback("focus")&&this.core.callback("focus",t),this.events.focused=!0,this.events.blured=!1,this.selection.current()===!1)){var e=this.selection.get(),i=this.selection.range(e);i.setStart(this.core.editor()[0],0),i.setEnd(this.core.editor()[0],0),this.selection.update(e,i)}},blur:function(e){this.start||this.rtePaste||0===t(e.target).closest("#"+this.core.id()+", .redactor-toolbar, .redactor-dropdown, #redactor-modal-box").length&&(!this.events.blured&&this.events.isCallback("blur")&&this.core.callback("blur",e),this.events.focused=!1,this.events.blured=!0)},touchImageEditing:function(){var e=-1;this.events.imageEditing=!1,t(window).on("touchmove.redactor."+this.uuid,t.proxy(function(){this.events.imageEditing=!0,-1!==e&&clearTimeout(e),e=setTimeout(t.proxy(function(){this.events.imageEditing=!1},this),500)},this))},init:function(){this.core.editor().on("dragover.redactor dragenter.redactor",t.proxy(this.events.dragover,this)),this.core.editor().on("dragleave.redactor",t.proxy(this.events.dragleave,this)),this.core.editor().on("drop.redactor",t.proxy(this.events.drop,this)),this.core.editor().on("click.redactor",t.proxy(this.events.click,this)),this.core.editor().on("paste.redactor",t.proxy(this.paste.init,this)),this.core.editor().on("keydown.redactor",t.proxy(this.keydown.init,this)),this.core.editor().on("keyup.redactor",t.proxy(this.keyup.init,this)),this.core.editor().on("focus.redactor",t.proxy(this.events.focus,this)),t(document).on("mousedown.redactor-blur."+this.uuid,t.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(i){i.forEach(t.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])&&(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(),this.autosave.is()&&(clearTimeout(this.autosaveTimeout),this.autosaveTimeout=setTimeout(t.proxy(this.autosave.send,this),300)))},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;i>r;r++)this.upload.directUpload(e[r],t)}},onDrop:function(t){this.core.callback("drop",t)},isCallback:function(e){return"undefined"!=typeof this.opts.callbacks[e]&&t.isFunction(this.opts.callbacks[e])},stopDetect:function(){this.events.stopDetectChanges()},startDetect:function(){this.events.startDetectChanges()}}},file:function(){return{is:function(){return!(!this.opts.fileUpload||!this.opts.fileUpload&&!this.opts.s3)},show:function(){this.modal.load("file",this.lang.get("file"),700),this.upload.init("#redactor-modal-file-upload",this.opts.fileUpload,this.file.insert),t("#redactor-filename").val(this.selection.get().toString()),this.modal.show()},insert:function(e,i,r){if("undefined"!=typeof e.error)return this.modal.close(),void this.core.callback("fileUploadError",e);this.file.release(r,i),this.buffer.set(),this.air.collapsed();var o=this.file.text(e),s=t("<a />").attr("href",e.url).text(o),n="undefined"==typeof e.id?"":e.id,a="undefined"==typeof e.s3?"file":"s3";s.attr("data-"+a,n),s=t(this.insert.node(s)),this.caret.after(s),this.storage.add({type:a,node:s[0],url:e.url,id:n}),null!==i&&this.core.callback("fileUpload",s,e)},release:function(t,e){e?(this.marker.remove(),this.insert.nodeToPoint(t,this.marker.get()),this.selection.restore()):this.modal.close()},text:function(e){var i=t("#redactor-filename").val();return"undefined"==typeof i||""===i?e.name:i}}},focus:function(){return{start:function(){if(this.core.editor().focus(),"inline"!==this.opts.type){var t=this.focus.first();t!==!1&&this.caret.start(t)}},end:function(){this.core.editor().focus();var t=this.opts.inline?this.core.editor():this.focus.last();if(0!==t.length){
-var e=this.focus.lastChild(t);if(this.detect.isWebkit()||e===!1){var i=this.selection.get(),r=this.selection.range(i);null!==r?(r.selectNodeContents(t[0]),r.collapse(!1),this.selection.update(i,r)):this.caret.end(t)}else this.caret.end(e)}},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:!1},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:!1},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(e,i,r){var o;if("undefined"!=typeof e.error)return this.modal.close(),this.events.dropImage=!1,void this.core.callback("imageUploadError",e,r);if(this.events.dropImage!==!1)return o=t(this.events.dropImage),this.core.callback("imageDelete",o[0].src,o),o.attr("src",e.url),this.events.dropImage=!1,void this.core.callback("imageUpload",o,e);this.placeholder.hide();var s=t("<"+this.opts.imageTag+">");o=t("<img>"),o.attr("src",e.url);var n="undefined"==typeof e.id?"":e.id,a="undefined"==typeof e.s3?"image":"s3";o.attr("data-"+a,n),s.append(o);var l=this.utils.isTag(this.selection.current(),"pre");if(i){this.air.collapsed(),this.marker.remove();var c=this.insert.nodeToPoint(r,this.marker.get()),d=t(c).next();this.selection.restore(),this.buffer.set(),"undefined"!=typeof d&&0!==d.length&&"IMG"===d[0].tagName?(this.core.callback("imageDelete",d[0].src,d),d.closest("figure, p",this.core.editor()[0]).replaceWith(s),this.caret.after(s)):(l?t(l).after(s):this.insert.node(s),this.caret.after(s))}else this.modal.close(),this.buffer.set(),this.air.collapsed(),l?t(l).after(s):this.insert.node(s),this.caret.after(s);this.events.dropImage=!1,this.storage.add({type:a,node:o[0],url:e.url,id:n});var h=o[0].nextSibling,u=s.next(),p=t(h).text().replace(/\u200B/g,""),f=u.text().replace(/\u200B/g,"");""===p&&t(h).remove(),1===u.length&&"FIGURE"===u[0].tagName&&""===f&&u.remove(),null!==i?this.core.callback("imageUpload",o,e):this.core.callback("imageInserted",o,e)},setEditable:function(e){if(e.on("dragstart",function(t){t.preventDefault()}),this.opts.imageResizable){var i=t.proxy(function(i){this.observe.image=e,this.image.resizer=this.image.loadEditableControls(e),t(document).on("mousedown.redactor-image-resize-hide."+this.uuid,t.proxy(this.image.hideResize,this)),this.image.resizer&&this.image.resizer.on("mousedown.redactor touchstart.redactor",t.proxy(function(t){this.image.setResizable(t,e)},this))},this);e.off("mousedown.redactor").on("mousedown.redactor",t.proxy(this.image.hideResize,this)),e.off("click.redactor touchstart.redactor").on("click.redactor touchstart.redactor",i)}else e.off("click.redactor touchstart.redactor").on("click.redactor touchstart.redactor",t.proxy(function(i){setTimeout(t.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,t.targetTouches&&(this.image.resizeHandle.x=t.targetTouches[0].pageX,this.image.resizeHandle.y=t.targetTouches[0].pageY),this.image.startResize()},startResize:function(){t(document).on("mousemove.redactor-image-resize touchmove.redactor-image-resize",t.proxy(this.image.moveResize,this)),t(document).on("mouseup.redactor-image-resize touchend.redactor-image-resize",t.proxy(this.image.stopResize,this))},moveResize:function(t){t.preventDefault(),t=t.originalEvent||t;var e=this.image.resizeHandle.h;e+=t.targetTouches?t.targetTouches[0].pageY-this.image.resizeHandle.y:t.pageY-this.image.resizeHandle.y;var i=Math.round(e*this.image.resizeHandle.ratio);if(!(50>e||100>i)){var e=Math.round(this.image.resizeHandle.el.width()/this.image.resizeHandle.ratio);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,t(document).off(".redactor-image-resize"),this.image.hideResize()},hideResize:function(e){if(!e||0===t(e.target).closest("#redactor-image-box",this.$editor[0]).length){if(e&&"IMG"==e.target.tagName){t(e.target)}var i=this.$editor.find("#redactor-image-box");0!==i.length&&(t("#redactor-image-editter").remove(),t("#redactor-image-resizer").remove(),i.find("img").css({marginTop:i[0].style.marginTop,marginBottom:i[0].style.marginBottom,marginLeft:i[0].style.marginLeft,marginRight:i[0].style.marginRight}),i.css("margin",""),i.find("img").css("opacity",""),i.replaceWith(function(){return t(this).contents()}),t(document).off("mousedown.redactor-image-resize-hide."+this.uuid),"undefined"!=typeof this.image.resizeHandle&&this.image.resizeHandle.el.attr("rel",this.image.resizeHandle.el.attr("style")))}},loadResizableControls:function(e,i){if(this.opts.imageResizable&&!this.detect.isMobile()){var r=t('<span id="redactor-image-resizer" data-redactor="verified"></span>');return this.detect.isDesktop()||r.css({width:"15px",height:"15px"}),r.attr("contenteditable",!1),i.append(r),i.append(e),r}return i.append(e),!1},loadEditableControls:function(e){if(0===t("#redactor-image-box").length){var i=t('<span id="redactor-image-box" data-redactor="verified">');if(i.css("float",e.css("float")).attr("contenteditable",!1),"auto"!=e[0].style.margin?(i.css({marginTop:e[0].style.marginTop,marginBottom:e[0].style.marginBottom,marginLeft:e[0].style.marginLeft,marginRight:e[0].style.marginRight}),e.css("margin","")):i.css({display:"block",margin:"auto"}),e.css("opacity",".5").after(i),this.opts.imageEditable){this.image.editter=t('<span id="redactor-image-editter" data-redactor="verified">'+this.lang.get("edit")+"</span>"),this.image.editter.attr("contenteditable",!1),this.image.editter.on("click",t.proxy(function(){this.image.showEdit(e)},this)),i.append(this.image.editter);var r=this.image.editter.innerWidth();this.image.editter.css("margin-left","-"+r/2+"px")}return this.image.loadResizableControls(e,i)}},showEdit:function(e){if(!this.events.imageEditing){this.observe.image=e;var i=e.closest("a",this.$editor[0]),r=e.closest("figure",this.$editor[0]),o=0!==r.length?r:e;if(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",t.proxy(this.image.remove,this)),this.image.buttonSave.on("click",t.proxy(this.image.update,this)),this.opts.imageCaption===!1)t("#redactor-image-caption").val("").hide().prev().hide();else{var s=e.closest(this.opts.imageTag,this.$editor[0]),n=s.find("figcaption");0!==n&&t("#redactor-image-caption").val(n.text()).show()}if(this.opts.imagePosition){var a=0!==r.length?"center"===o.css("text-align"):"block"==o.css("display")&&"none"==o.css("float"),l=a?"center":o.css("float");t("#redactor-image-align").val(l)}else t(".redactor-image-position-option").hide();t("#redactor-image-preview").html(t('<img src="'+e.attr("src")+'" style="max-width: 100%;">')),t("#redactor-image-title").val(e.attr("alt")),0!==i.length&&(t("#redactor-image-link").val(i.attr("href")),"_blank"===i.attr("target")&&t("#redactor-image-link-blank").prop("checked",!0)),t(".redactor-link-tooltip").remove(),this.modal.show(),this.detect.isDesktop()&&t("#redactor-image-title").focus()}},update:function(){var e=this.observe.image,i=e.closest("a",this.core.editor()[0]),r=t("#redactor-image-title").val().replace(/(<([^>]+)>)/gi,"");e.attr("alt",r).attr("title",r),this.image.setFloating(e);var o=t.trim(t("#redactor-image-link").val()).replace(/(<([^>]+)>)/gi,"");if(""!==o){var s="((xn--)?[a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,}",n=new RegExp("^(http|ftp|https)://"+s,"i"),a=new RegExp("^"+s,"i");-1===o.search(n)&&0===o.search(a)&&this.opts.linkProtocol&&(o=this.opts.linkProtocol+"://"+o);var l=!!t("#redactor-image-link-blank").prop("checked");if(0===i.length){var c=t('<a href="'+o+'" id="redactor-img-tmp">'+this.utils.getOuterHtml(e)+"</a>");l&&c.attr("target","_blank"),e=e.replaceWith(c),i=this.core.editor().find("#redactor-img-tmp"),i.removeAttr("id")}else i.attr("href",o),l?i.attr("target","_blank"):i.removeAttr("target")}else 0!==i.length&&i.replaceWith(this.utils.getOuterHtml(e));this.image.addCaption(e,i),this.modal.close(),this.buffer.set()},setFloating:function(e){var i=e.closest("figure",this.$editor[0]),r=0!==i.length?i:e,o=t("#redactor-image-align").val(),s="",n="",a="",l="";switch(o){case"left":s="left",a="0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin+" 0";break;case"right":s="right",a="0 0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin;break;case"center":0!==i.length?l="center":(n="block",a="auto")}r.css({"float":s,display:n,margin:a,"text-align":l}),r.attr("rel",e.attr("style"))},addCaption:function(e,i){var r=t("#redactor-image-caption").val(),o=0!==i.length?i:e,s=o.next();0!==s.length&&"FIGCAPTION"===s[0].tagName||(s=!1),""!==r?s===!1?(s=t("<figcaption />").text(r),o.after(s)):s.text(r):s!==!1&&s.remove()},remove:function(e,i,r){i="undefined"==typeof i?t(this.observe.image):i,"boolean"!=typeof e&&this.buffer.set(),this.events.stopDetectChanges();var o=i.closest("a",this.core.editor()[0]),s=i.closest(this.opts.imageTag,this.core.editor()[0]),n=i.parent(),a=this.core.callback("imageDelete",e,i[0]);if(a===!1)return e.preventDefault(),!1;0!==t("#redactor-image-box").length&&(n=t("#redactor-image-box").parent());var l,c;0!==s.length?(c=s.prev(),l=s.next(),s.remove()):0!==o.length?(n=o.parent(),o.remove()):i.remove(),t("#redactor-image-box").remove(),e!==!1&&(l&&0!==l.length?this.caret.start(l):c&&0!==c.length&&this.caret.end(c)),"boolean"!=typeof e&&this.modal.close(),this.utils.restoreScroll(),this.observe.image=!1,this.events.startDetectChanges(),this.placeholder.enable(),this.code.sync()}}},indent:function(){return{increase:function(){if(this.list.get()){var e=t(this.selection.current()).closest("li"),i=e.closest("ul, ol",this.core.editor()[0]),r=e.closest("li"),o=r.prev();if(0!==o.length&&"LI"===o[0].tagName)if(this.buffer.set(),this.utils.isCollapsed()){var s=i[0].tagName,n=t("<"+s+" />");this.selection.save();var a=o.find("ol").first();if(1===a.length)a.append(e);else{var s=i[0].tagName,n=t("<"+s+" />");n.append(e),o.append(n)}this.selection.restore()}else document.execCommand("indent"),this.selection.save(),this.indent.removeEmpty(),this.indent.normalize(),this.selection.restore()}},decrease:function(){if(this.list.get()){var e=t(this.selection.current()).closest("li");e.closest("ul, ol",this.core.editor()[0]);this.buffer.set(),document.execCommand("outdent");var i=t(this.selection.current()).closest("li",this.core.editor()[0]);if(this.utils.isCollapsed()&&this.indent.repositionItem(i),0===i.length){document.execCommand("formatblock",!1,"p"),i=t(this.selection.current());var r=i.next();0!==r.length&&"BR"===r[0].tagName&&r.remove()}this.selection.save(),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();if(0!==i.length&&"LI"!==i[0].tagName){this.selection.save();var r=t.parents("li",this.core.editor()[0]);r.after(t),this.selection.restore()}},normalize:function(){this.core.editor().find("li").each(t.proxy(function(e,i){var r=t(i);r.find(this.opts.inlineTags.join(",")).each(function(){t(this).removeAttr("style")});var o=r.parent();if(0!==o.length&&"LI"===o[0].tagName)return void o.after(r);var s=r.next();0===s.length||"UL"!==s[0].tagName&&"OL"!==s[0].tagName||r.append(s)},this))},removeEmpty:function(e){var i=this.core.editor().find("ul, ol"),r=this.core.editor().find("li");r.each(t.proxy(function(t,e){this.indent.removeItemEmpty(e)},this)),i.each(t.proxy(function(t,e){this.indent.removeItemEmpty(e)},this)),r.each(t.proxy(function(t,e){this.indent.removeItemEmpty(e)},this))},removeItemEmpty:function(e){var i=e.innerHTML.replace(/[\t\s\n]/g,"");i=i.replace(/<span><\/span>/g,""),""===i&&t(e).remove()}}},inline:function(){return{format:function(t,e,i,r){if(!this.utils.isCurrentOrParent(["PRE","CODE"])){var o=this.inline.getParams(e,i,r);t=this.inline.arrangeTag(t),this.placeholder.hide(),this.buffer.set(),this.utils.isCollapsed()?this.inline.formatCollapsed(t,o):this.inline.formatUncollapsed(t,o)}},formatCollapsed:function(e,i){var r,o=this.selection.inline();if(o){var s=o.tagName.toLowerCase();if(s===e)if(this.utils.isEmpty(o.innerHTML))this.caret.after(o),t(o).remove();else{var n=this.inline.insertBreakpoint(o,s);this.caret.after(n)}else if(0===t(o).closest(e).length)r=this.inline.insertInline(e),r=this.inline.setParams(r,i);else{var n=this.inline.insertBreakpoint($parent[0],s);this.caret.after(n)}}else r=this.inline.insertInline(e),r=this.inline.setParams(r,i)},formatUncollapsed:function(e,i){this.selection.save();var r=this.inline.getClearedNodes();this.inline.setNodesStriked(r,e,i),this.selection.restore(),document.execCommand("strikethrough"),this.selection.saveInstant();var o=this;this.core.editor().find("strike").each(function(){var r=o.utils.replaceToTag(this,e);o.inline.setParams(r[0],i);var s=r.find(e),n=r.parent(),a=n.parent();return 0!==a.length&&a[0].tagName.toLowerCase()===e&&a.html()==n[0].outerHTML?(r.replaceWith(function(){return t(this).contents()}),void a.replaceWith(function(){return t(this).contents()})):(0!==s.length&&o.inline.cleanInsideOrParent(s,i),n.html()==r[0].outerHTML&&o.inline.cleanInsideOrParent(n,i),void(o.detect.isFirefox()&&o.core.editor().find(e+":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 e=this.selection.nodes(),i=[],r=e.length,o=0,s=0;r>s;s++)if(t(e[s]).hasClass("redactor-selection-marker")){o=s+2;break}for(var s=0;r>s;s++)s>=o&&!this.utils.isBlockTag(e[s].tagName)&&i.push(e[s]);return i},isConvertableAttr:function(e,i,r){var o=t(e).attr(i);if(o)if("style"===i){r=t.trim(r).replace(/;$/,"");for(var s=r.split(";"),n=0,a=0;a<s.length;a++){var l=s[a].split(":"),c=t.trim(l[0]),d=t.trim(l[1]);if(-1!==c.search(/color/)){var h=t(e).css(c);!h||h!==d&&this.utils.rgb2hex(h)!==d||n++}else t(e).css(c)===d&&n++}if(n===s.length)return 1}else if(o===r)return 1;return 0},isConvertable:function(t,e,i,r){if(e===i){if(!r)return!0;var o=0;for(var s in r.data)o+=this.inline.isConvertableAttr(t,s,r.data[s]);if(o===Object.keys(r.data).length)return!0}return!1},setNodesStriked:function(e,i,r){for(var o=0;o<e.length;o++){var s=e[o].tagName?e[o].tagName.toLowerCase():void 0,n=e[o].parentNode,a=n&&n.tagName?n.tagName.toLowerCase():void 0,l=this.inline.isConvertable(n,a,i,r);if(l){var c=t(n).replaceWith(function(){return t("<strike>").append(t(this).contents())});c.attr("data-redactor-inline-converted")}var l=this.inline.isConvertable(e[o],s,i,r);if(l)var c=t(e[o]).replaceWith(function(){return t("<strike>").append(t(this).contents())})}},insertBreakpoint:function(e,i){var r=document.createElement("span");r.id="redactor-inline-breakpoint",r=this.insert.node(r);var o=this.utils.isEndOfElement(e),s=this.utils.getOuterHtml(e),n=o?"":"<"+i+">";s=s.replace(/<span id="redactor-inline-breakpoint"><\/span>/i,"</"+i+">"+n);var a=t(s);return t(e).replaceWith(a),""!==n&&this.utils.cloneAttributes(e,a.last()),a.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 o=i[r].split(":");o&&(e[o[0].trim()]=o[1].trim())}return e},getParams:function(t,e,i){var r=!1,o="toggle";return"object"==typeof t?(r=t,o=void 0!==e?e:o):void 0!==t&&void 0!==e&&(r={},r[t]=e,o=void 0!==i?i:o),r?{func:o,data:r}:!1},setParams:function(e,i){if(i)for(var r in i.data){var o=t(e);"style"===r?(e=this.inline[i.func+"Style"](i.data[r],e),o.attr("data-redactor-style-cache",o.attr("style"))):e="class"===r?this.inline[i.func+"Class"](i.data[r],e):"remove"===i.func?this.inline[i.func+"Attr"](r,e):this.inline[i.func+"Attr"](r,i.data[r],e),"style"===r&&"SPAN"===e.tagName&&o.attr("data-redactor-span",!0)}return e},eachInline:function(t,e){var i,r=void 0===t?this.selection.inlines():[t];if(r)for(var o=0;o<r.length;o++)i=e(r[o])[0];return i},replaceClass:function(e,i){return this.inline.eachInline(i,function(i){return t(i).removeAttr("class").addClass(e)})},toggleClass:function(e,i){return this.inline.eachInline(i,function(i){return t(i).toggleClass(e)})},addClass:function(e,i){return this.inline.eachInline(i,function(i){return t(i).addClass(e)})},removeClass:function(e,i){return this.inline.eachInline(i,function(i){return t(i).removeClass(e)})},removeAllClass:function(e){return this.inline.eachInline(e,function(e){return t(e).removeAttr("class")})},replaceAttr:function(e,i,r){return this.inline.eachInline(r,function(i){return t(i).removeAttr(e).attr(e.value)})},toggleAttr:function(e,i,r){return this.inline.eachInline(r,function(i){var r=t(i).attr(e);return r?t(i).removeAttr(e):t(i).attr(e.value)})},addAttr:function(e,i,r){return this.inline.eachInline(r,function(r){return t(r).attr(e,i)})},removeAttr:function(e,i){return this.inline.eachInline(i,function(i){var r=t(i);return r.removeAttr(e),"style"===e&&r.removeAttr("data-redactor-style-cache"),r})},removeAllAttr:function(e){return this.inline.eachInline(e,function(e){for(var i=t(e),r=e.attributes.length,o=0;r>o;o++)i.removeAttr(e.attributes[o].name);return i})},removeSpecificAttr:function(e,i,r){var o=t(e);if("style"===i){var s=r.split(":"),n=s[0].trim();o.css(n,""),this.utils.removeEmptyAttr(e,"style")&&o.removeAttr("data-redactor-style-cache")}else o.removeAttr(i)[0]},hasParentStyle:function(t){var e=t.parent();return 1===e.length&&e[0].tagName===t[0].tagName&&e.html()===t[0].outerHTML?e:!1},addParentStyle:function(e){var i=this.inline.hasParentStyle(e);if(i){var r=this.inline.getStyleParams(e.attr("style"));i.css(r),i.attr("data-redactor-style-cache",i.attr("style")),e.replaceWith(function(){return t(this).contents()})}else e.attr("data-redactor-style-cache",e.attr("style"));return e},replaceStyle:function(e,i){e=this.inline.getStyleParams(e);var r=this;return this.inline.eachInline(i,function(i){var o=t(i);o.removeAttr("style").css(e);var s=o.attr("style");return s&&o.attr("style",s.replace(/"/g,"'")),o=r.inline.addParentStyle(o)})},toggleStyle:function(e,i){e=this.inline.getStyleParams(e);var r=this;return this.inline.eachInline(i,function(i){var o=t(i);for(var s in e){var n=e[s],a=o.css(s);a=r.utils.isRgb(a)?r.utils.rgb2hex(a):a.replace(/"/g,""),n=r.utils.isRgb(n)?r.utils.rgb2hex(n):n.replace(/"/g,""),a===n?o.css(s,""):o.css(s,n)}var l=o.attr("style");return l&&o.attr("style",l.replace(/"/g,"'")),r.utils.removeEmptyAttr(i,"style")?o.removeAttr("data-redactor-style-cache"):o=r.inline.addParentStyle(o),o})},addStyle:function(e,i){e=this.inline.getStyleParams(e);var r=this;return this.inline.eachInline(i,function(i){var o=t(i);o.css(e);var s=o.attr("style");return s&&o.attr("style",s.replace(/"/g,"'")),o=r.inline.addParentStyle(o)})},removeStyle:function(e,i){e=this.inline.getStyleParams(e);var r=this;return this.inline.eachInline(i,function(i){var o=t(i);for(var s in e)o.css(s,"");return r.utils.removeEmptyAttr(i,"style")?o.removeAttr("data-redactor-style-cache"):o.attr("data-redactor-style-cache",o.attr("style")),o})},removeAllStyle:function(e){return this.inline.eachInline(e,function(e){return t(e).removeAttr("style").removeAttr("data-redactor-style-cache")})},removeStyleRule:function(e){var i=this.selection.parent(),r=this.selection.inlines();this.buffer.set(),i&&"SPAN"===i.tagName&&this.inline.removeStyleRuleAttr(t(i),e);for(var o=0;o<r.length;o++){var s=r[o],n=t(s);-1==t.inArray(s.tagName.toLowerCase(),this.opts.inlineTags)||n.hasClass("redactor-selection-marker")||this.inline.removeStyleRuleAttr(n,e)}},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 o=this.inline.getParams(e,i,r),s=this.selection.inlines(),n=[];if(s)for(var a=0;a<s.length;a++){var l=s[a];"*"!==t&&l.tagName.toLowerCase()!==t||n.push(this.inline.setParams(l,o))}return n},removeFormat:function(){this.selection.save();for(var e=this.inline.getClearedNodes(),i=0;i<e.length;i++)1===e[i].nodeType&&t(e[i]).replaceWith(function(){return t(this).contents()});this.selection.restore()}}},insert:function(){return{set:function(t){this.placeholder.hide(),this.code.set(t),this.focus.end(),this.placeholder.enable()},html:function(e,i){this.placeholder.hide(),this.core.editor().focus();var r=this.selection.block(),o=this.selection.inline();"undefined"==typeof i&&(i=this.clean.getCurrentType(e,!0),e=this.clean.onPaste(e,i,!0)),e=t.parseHTML(e);var s=t(e).last(),n=this.selection.get(),a=this.selection.range(n);if(a.deleteContents(),this.selection.update(n,a),i.lists){var l=t(e);if(0!==l.length&&("UL"===l[0].tagName||"OL"===l[0].tagName))return void this.insert.appendLists(r,l)}if(i.blocks&&r)if(this.utils.isSelectAll())this.core.editor().html(e),this.focus.end();else{var c=this.utils.breakBlockTag();if(c===!1)this.insert.placeHtml(e);else{var d=t(e).children().last();d.append(this.marker.get()),"start"===c.type?c.$block.before(e):c.$block.after(e),this.selection.restore(),this.core.editor().find("p").each(function(){""===t.trim(this.innerHTML)&&t(this).remove()})}}else{if(o){var h=t("<div/>").html(e);h.find(o.tagName.toLowerCase()).each(function(){t(this).contents().unwrap()}),e=h.html()}if(this.utils.isSelectAll()){var u=t(this.opts.emptyHtml);this.core.editor().html("").append(u),u.html(e),this.caret.end(u)}else this.insert.placeHtml(e)}this.utils.disableSelectAll(),this.linkify.format(),i.pre&&this.clean.cleanPre(),this.caret.end(s)},text:function(e){e=e.toString(),e=t.trim(e);var i=document.createElement("div");if(i.innerHTML=e,e=i.textContent||i.innerText,"undefined"!=typeof e){this.placeholder.hide(),this.core.editor().focus();var r=this.selection.blocks();if(e=e.replace(/\n/g," "),this.utils.isSelectAll()){var o=t(this.opts.emptyHtml);this.core.editor().html("").append(o),o.html(e),this.caret.end(o)}else{var s=this.selection.get(),n=document.createTextNode(e);if(s.getRangeAt&&s.rangeCount){var a=s.getRangeAt(0);a.deleteContents(),a.insertNode(n),a.setStartAfter(n),a.collapse(!0),this.selection.update(s,a)}r.length>1&&(t(n).wrap("<p>"),this.caret.after(n))}this.utils.disableSelectAll(),this.linkify.format(),this.clean.normalizeCurrentHeading()}},raw:function(t){this.placeholder.hide(),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 o,s,n=document.createDocumentFragment();o=r.firstChild;)s=n.appendChild(o);i.insertNode(n),s&&(i=i.cloneRange(),i.setStartAfter(s),i.collapse(!0),e.removeAllRanges(),e.addRange(i))},node:function(e,i){this.placeholder.hide(),"undefined"!=typeof this.start&&this.core.editor().focus(),e=e[0]||e;var r=this.selection.block(),o=this.utils.isBlockTag(e.tagName),s=!0;if(this.utils.isSelectAll())o?this.core.editor().html(e):this.core.editor().html(t("<p>").html(e)),this.code.sync();else if(o&&r){var n=this.utils.breakBlockTag();n===!1?this.insert.placeNode(e,i):("start"===n.type?n.$block.before(e):n.$block.after(e),this.core.editor().find("p:empty").remove())}else s=this.insert.placeNode(e,i);return this.utils.disableSelectAll(),s&&this.caret.end(e),e},appendLists:function(e,i){var r,o=t(e),s=this.utils.isEmpty(e.innerHTML);if(s||this.utils.isEndOfElement(e))r=o,i.find("li").each(function(){r.after(this),r=t(this)}),s&&o.remove();else if(this.utils.isStartOfElement(e))i.find("li").each(function(){o.before(this),r=t(this)});else{var n=this.selection.extractEndOfNode(e);o.after(t("<li>").append(n)),o.append(i),r=i}this.marker.remove(),r&&this.caret.end(r),this.linkify.format()},placeHtml:function(e){var i=document.createElement("span");i.id="redactor-insert-marker",i=this.insert.node(i),t(i).before(e),this.selection.restore(),this.caret.after(i),t(i).remove()},placeNode:function(t,e){var i=this.selection.get(),r=this.selection.range(i);return null==r?!1:(e!==!1&&r.deleteContents(),r.insertNode(t),r.collapse(!1),void this.selection.update(i,r))},nodeToPoint:function(e,i){if(this.placeholder.hide(),i=i[0]||i,this.utils.isEmpty())return i=this.utils.isBlock(i)?i:t("<p />").append(i),this.core.editor().html(i),i;var r,o=e.clientX,s=e.clientY;if(document.caretPositionFromPoint){var n=document.caretPositionFromPoint(o,s),a=document.getSelection();r=a.getRangeAt(0),r.setStart(n.offsetNode,n.offset),r.collapse(!0),r.insertNode(i)}else if(document.caretRangeFromPoint)r=document.caretRangeFromPoint(o,s),r.insertNode(i);else if("undefined"!=typeof document.body.createTextRange){r=document.body.createTextRange(),r.moveToPoint(o,s);var l=r.duplicate();l.moveToPoint(o,s),r.setEndPoint("EndToEnd",l),r.select()}return i},nodeToCaretPositionFromPoint:function(t,e){this.insert.nodeToPoint(t,e)},marker:function(){this.marker.insert()}}},keydown:function(){return{init:function(e){if(!this.rtePaste){var i=e.which,r=i>=37&&40>=i;this.keydown.ctrl=e.ctrlKey||e.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");var o=this.core.callback("keydown",e);if(o===!1)return e.preventDefault(),!1;if(this.shortcuts.init(e,i),this.keydown.checkEvents(r,i),this.keydown.setupBuffer(e,i),this.utils.isSelectAll()&&(i===this.keyCode.ENTER||i===this.keyCode.BACKSPACE||i===this.keyCode.DELETE))return e.preventDefault(),void this.code.set(this.opts.emptyHtml);if(this.keydown.addArrowsEvent(r),this.keydown.setupSelectAll(e,i),!this.opts.enterKey&&i===this.keyCode.ENTER){e.preventDefault();var s=this.selection.get(),n=this.selection.range(s);return void(n.collapsed||n.deleteContents())}if(this.opts.enterKey&&i===this.keyCode.DOWN&&this.keydown.onArrowDown(),this.opts.enterKey&&i===this.keyCode.UP&&this.keydown.onArrowUp(),("textarea"===this.opts.type||"div"===this.opts.type)&&this.keydown.current&&3===this.keydown.current.nodeType&&t(this.keydown.parent).hasClass("redactor-in")&&this.keydown.wrapToParagraph(),!this.keyup.lastShiftKey&&i===this.keyCode.SPACE&&(e.ctrlKey||e.shiftKey))return e.preventDefault(),this.keydown.onShiftSpace();if(i===this.keyCode.ENTER&&(e.ctrlKey||e.shiftKey))return e.preventDefault(),this.keydown.onShiftEnter(e);if(i===this.keyCode.ENTER&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey)return this.keydown.onEnter(e);if(i===this.keyCode.TAB||e.metaKey&&221===i||e.metaKey&&219===i)return this.keydown.onTab(e,i);if(this.detect.isFirefox()&&i===this.keyCode.BACKSPACE&&this.keydown.block&&"P"===this.keydown.block.tagName&&this.utils.isStartOfElement(this.keydown.block)){var a=t(this.keydown.block).prev();if(0!==a.length)return e.preventDefault(),a.append(this.marker.get()),a.append(t(this.keydown.block).html()),t(this.keydown.block).remove(),void this.selection.restore()}if(i===this.keyCode.BACKSPACE||i===this.keyCode.DELETE){if(this.observe.image&&"undefined"!=typeof this.observe.image&&0!==t("#redactor-image-box").length){e.preventDefault();var a=this.observe.image.closest("figure, p").prev();return this.image.remove(!1),this.observe.image=!1,void(a&&0!==a.length?this.caret.end(a):this.core.editor().focus())}this.keydown.onBackspaceAndDeleteBefore()}if(i===this.keyCode.DELETE){var l=t(this.keydown.block).next();if(this.utils.isEndOfElement(this.keydown.block)&&0!==l.length&&"FIGURE"===l[0].tagName)return l.remove(),!1;var c=this.keydown.block&&"LI"===this.keydown.block.tagName?this.keydown.block:!1;if(c){var d=t(this.keydown.block).parents("ul, ol").last(),h=d.next();if(this.utils.isRedactorParent(d)&&this.utils.isEndOfElement(d)&&0!==h.length&&("UL"===h[0].tagName||"OL"===h[0].tagName))return e.preventDefault(),d.append(h.contents()),h.remove(),!1}if(this.utils.isEndOfElement(this.keydown.block)&&0!==l.length&&"PRE"===l[0].tagName)return t(this.keydown.block).append(l.text()),l.remove(),!1}if(i===this.keyCode.DELETE&&0!==t("#redactor-image-box").length&&this.image.remove(),i===this.keyCode.BACKSPACE){if(this.detect.isFirefox()&&this.line.removeOnBackspace(e),this.list.combineAfterAndBefore(this.keydown.block))return void e.preventDefault();var u=this.selection.block();if(u&&"LI"===u.tagName&&this.utils.isCollapsed()&&this.utils.isStartOfElement())return this.indent.decrease(),void e.preventDefault();this.keydown.removeInvisibleSpace(),this.keydown.removeEmptyListInTable(e)}i!==this.keyCode.BACKSPACE&&i!==this.keyCode.DELETE||this.keydown.onBackspaceAndDeleteAfter(e)}},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(t.proxy(function(){this.code.syncFire=!1,this.keydown.removeEmptyLists();var t="";0!==this.opts.keepStyleAttr.length&&(t=","+this.opts.keepStyleAttr.join(","));var i=this.core.editor().find("*[style]");i.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(e){var i=this.core.callback("enter",e);if(i===!1)return e.preventDefault(),!1;if(this.keydown.blockquote&&this.keydown.exitFromBlockquote(e)===!0)return!1;if(this.keydown.pre)return this.keydown.insertNewLine(e);if(this.keydown.blockquote||this.keydown.figcaption)return this.keydown.insertBreakLine(e);if(this.keydown.figure)setTimeout(t.proxy(function(){this.keydown.replaceToParagraph("FIGURE")},this),1);else if(this.keydown.block){if(setTimeout(t.proxy(function(){this.keydown.replaceToParagraph("DIV")},this),1),"LI"===this.keydown.block.tagName){var r=this.selection.current(),o=t(r).closest("li",this.$editor[0]),s=o.parents("ul,ol",this.$editor[0]).last();if(0!==o.length&&this.utils.isEmpty(o.html())&&0===s.next().length&&this.utils.isEmpty(s.find("li").last().html())){s.find("li").last().remove();var n=t(this.opts.emptyHtml);return s.after(n),this.caret.start(n),!1}}}else if(!this.keydown.block)return this.keydown.insertParagraph(e);return this.detect.isFirefox()&&this.utils.isInline(this.keydown.parent)?void this.keydown.insertBreakLine(e):void setTimeout(t.proxy(function(){var e=this.selection.inline();if(e&&this.utils.isEmpty(e.innerHTML)){var i=this.selection.block();t(e).remove();var r=document.createRange();r.setStart(i,0);var o=document.createTextNode("​");r.insertNode(o),r.setStartAfter(o),r.collapse(!0);var s=window.getSelection();s.removeAllRanges(),s.addRange(r)}},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(e){var i=this.keyCode,r=[i.BACKSPACE,i.DELETE,i.ENTER,i.ESC,i.TAB,i.CTRL,i.META,i.ALT,i.SHIFT];return-1===t.inArray(e,r)},addArrowsEvent:function(t){return t?"click"===this.core.getEvent()||"arrow"===this.core.getEvent()?void this.core.addEvent(!1):void this.core.addEvent("arrow"):void 0},setupBuffer:function(t,e){return this.keydown.ctrl&&90===e&&!t.shiftKey&&!t.altKey&&this.opts.buffer.length?(t.preventDefault(),void this.buffer.undo()):this.keydown.ctrl&&90===e&&t.shiftKey&&!t.altKey&&0!==this.opts.rebuffer.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(e){if(this.utils.isEndOfElement(this.keydown.blockquote)){var i=this.clean.removeSpacesHard(t(this.keydown.blockquote).html());if(-1!==i.search(/(<br\s?\/?>){1}$/i)){e.preventDefault();var r=t(this.keydown.blockquote).children().last();r.filter("br").remove(),t(this.keydown.blockquote).children().last().filter("span").remove();var o=t(this.opts.emptyHtml);return t(this.keydown.blockquote).after(o),this.caret.start(o),!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(e){if(this.utils.isEndOfElement(e)){var i=this.core.editor().contents().last(),r="FIGCAPTION"===e.tagName?t(this.keydown.block).parent().next():t(this.keydown.block).next();if(0===r.length){if(0===i.length&&i[0]!==e)return void this.caret.start(i);var o=t(this.opts.emptyHtml);"FIGCAPTION"===e.tagName?t(e).parent().after(o):t(e).after(o),this.caret.start(o)}}},insertBeforeFirstElement:function(e){if(this.utils.isStartOfElement()&&!(this.core.editor().contents().length>1&&this.core.editor().contents().first()[0]!==e)){var i=t(this.opts.emptyHtml);t(e).before(i),this.caret.start(i)}},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&&this.opts.tabAsSpaces===!1)return!0;t.preventDefault(),this.buffer.set();var r,o=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("       "),this.insert.node(r)):this.opts.tabAsSpaces===!1||o?t.metaKey&&219===e?this.indent.decrease():t.metaKey&&221===e?this.indent.increase():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=document.createElement("br");if(this.insert.node(i),e===!0){var r=document.createElement("br");this.insert.node(r),this.caret.after(r)}else this.caret.after(i);return!1},wrapToParagraph:function(){var e=t(this.keydown.current),i=t("<p>").append(e.clone());e.replaceWith(i);var r=t(i).next();"undefined"!=typeof r[0]&&"BR"===r[0].tagName&&r.remove(),this.caret.end(i)},replaceToParagraph:function(e){var i=this.selection.block(),r=t(i).prev(),o=i.innerHTML.replace(/<br\s?\/?>/gi,"");if(i.tagName===e&&this.utils.isEmpty(o)&&!t(i).hasClass("redactor-in")){var s=document.createElement("p");return t(i).replaceWith(s),this.keydown.setCaretToParagraph(s),!1}if("P"===i.tagName)return t(i).removeAttr("class").removeAttr("style"),this.detect.isIe()&&this.utils.isEmpty(o)&&this.utils.isInline(this.keydown.parent)&&t(i).on("input",t.proxy(function(){var e=this.selection.parent();if(this.utils.isInline(e)){var r=t(e).html();t(i).html(r),this.caret.end(i)}t(i).off("keyup")},this)),!1;if(r.hasClass(this.opts.videoContainerClass)){r.removeAttr("class");var s=document.createElement("p");return r.replaceWith(s),this.keydown.setCaretToParagraph(s),!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 e=t(this.keydown.current);0===e.text().search(/^\u200B$/g)&&e.remove()},removeEmptyListInTable:function(e){var i=t(this.keydown.current),r=t(this.keydown.parent),o=i.closest("td",this.$editor[0]);if(0!==o.length&&i.closest("li",this.$editor[0])&&1===r.children("li").length){if(!this.utils.isEmpty(i.text()))return;e.preventDefault(),i.remove(),r.remove(),this.caret.start(o)}},removeEmptyLists:function(){var e=function(){var e=t.trim(this.innerHTML).replace(/\/t\/n/g,"");""===e&&t(this).remove()};this.core.editor().find("li").each(e),this.core.editor().find("ul, ol").each(e)},formatEmpty:function(e){var i=t.trim(this.core.editor().html());if(this.utils.isEmpty(i))return e.preventDefault(),"inline"===this.opts.type||"pre"===this.opts.type?(this.core.editor().html(this.marker.html()),this.selection.restore()):(this.core.editor().html(this.opts.emptyHtml),this.focus.start()),!1}}},keyup:function(){return{init:function(e){if(!this.rtePaste){var i=e.which;this.keyup.block=this.selection.block(),this.keyup.current=this.selection.current(),this.keyup.parent=this.selection.parent(),this.keyup.lastShiftKey=e.shiftKey;var r=this.core.callback("keyup",e);if(r===!1)return e.preventDefault(),!1;if(i===this.keyCode.ENTER&&this.keyup.block&&"FIGURE"===this.keyup.block.tagName){var o=t(this.keyup.block).prev();if(0!==o.length&&"FIGURE"===o[0].tagName){var s=this.utils.replaceToTag(o,"p");return void this.caret.start(s)}}if(i===this.keyCode.BACKSPACE||i===this.keyCode.DELETE){if(this.utils.isSelectAll())return this.focus.start(),void this.toolbar.setUnfixed();if(this.keyup.block&&this.keydown.block&&"FIGURE"===this.keyup.block.tagName&&this.utils.isStartOfElement(this.keydown.block)){e.preventDefault(),this.selection.save(),t(this.keyup.block).find("figcaption").remove(),t(this.keyup.block).find("img").first().remove(),this.utils.replaceToTag(this.keyup.block,"p");var n=this.marker.find();return t("html, body").animate({scrollTop:n.position().top+20},500),void this.selection.restore()}if(this.keyup.block&&"P"===this.keyup.block.tagName){var a=t(this.keyup.block).find("img").length,l=t(this.keyup.block).text().replace(/\u200B/g,"");""===l&&0!==a&&this.utils.replaceToTag(this.keyup.block,"figure")}this.keyup.block&&"FIGURE"===this.keyup.block.tagName&&0===t(this.keyup.block).find("img").length&&(this.selection.save(),this.utils.replaceToTag(this.keyup.block,"p"),this.selection.restore())}this.linkify.isKey(i)&&this.linkify.format()}}}},lang:function(){return{load:function(){this.opts.curLang=this.opts.langs[this.opts.lang]},get:function(t){return"undefined"!=typeof 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(e){if(this.utils.isCollapsed()){var i=t(this.selection.block());if(0!==i.length&&this.utils.isStartOfElement(i)){var r=i.prev();r&&0!==r.length&&"HR"===r[0].tagName&&(e.preventDefault(),r.remove())}}}}},link:function(){return{get:function(){return t(this.selection.inlines("a"))},is:function(){var e=this.selection.nodes(),i=t(this.selection.current()).closest("a",this.core.editor()[0]);return 0===i.length||e.length>1?!1:i},unlink:function(t){"undefined"!=typeof t&&t.preventDefault&&t.preventDefault(),this.buffer.set();var e=this.selection.inlines("a");if(0!==e.length){var i=this.link.replaceLinksToText(e);this.observe.closeAllTooltip(),this.core.callback("deletedLink",i)}},insert:function(e,i){var r=this.link.is();if(i!==!0&&(e=this.link.buildLinkFromObject(r,e),e===!1))return!1;if(this.buffer.set(),e=this.core.callback("beforeInsertingLink",e),r===!1){r=t("<a />"),r=this.link.update(r,e),r=t(this.insert.node(r));var o=r.parent();this.utils.isRedactorParent(o)===!1&&r.wrap("<p>"),o.hasClass("redactor-unlink")&&o.replaceWith(function(){return t(this).contents()}),this.caret.after(r),this.core.callback("insertedLink",r)}else r=this.link.update(r,e),this.caret.after(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(e){"undefined"!=typeof e&&e.preventDefault&&e.preventDefault(),this.observe.closeAllTooltip();var i=this.link.is();this.link.buildModal(i);var r=this.link.buildLinkFromElement(i);r.url=this.link.removeSelfHostFromUrl(r.url),this.opts.linkNewTab&&!i&&(r.target=!0),this.link.setModalValues(r),this.modal.show(),this.detect.isDesktop()&&t("#redactor-link-url").focus()},setModalValues:function(e){t("#redactor-link-blank").prop("checked",e.target),t("#redactor-link-url").val(e.url),t("#redactor-link-url-text").val(e.text)},buildModal:function(e){this.modal.load("link",this.lang.get(e===!1?"link-insert":"link-edit"),600);var i=this.modal.getActionButton();i.text(this.lang.get(e===!1?"insert":"save")).on("click",t.proxy(this.link.callback,this))},callback:function(){var t=this.link.buildLinkFromModal();return t===!1?!1:(this.modal.close(),void this.link.insert(t,!0))},cleanUrl:function(e){return"undefined"==typeof e?"":t.trim(e.replace(/[^\W\w\D\d+&\'@#\/%?=~_|!:,.;\(\)]/gi,""))},cleanText:function(e){return"undefined"==typeof e?"":t.trim(e.replace(/(<([^>]+)>)/gi,""))},getText:function(t){return""===t.text&&""!==t.url?this.link.truncateUrl(t.url.replace(/<|>/g,"")):t.text},isUrl:function(t){var e="((xn--)?[\\W\\w\\D\\d]+(-[\\W\\w\\D\\d]+)*\\.)+[\\W\\w]{2,}",i=new RegExp("^(http|ftp|https)://"+e,"i"),r=new RegExp("^"+e,"i"),o=new RegExp(".(html|php)$","i"),s=new RegExp("^/","i"),n=new RegExp("^tel:(.*?)","i");return-1===t.search(i)&&-1!==t.search(r)&&-1===t.search(o)&&"/"!==t.substring(0,1)&&(t="http://"+t),-1!==t.search(i)||-1!==t.search(o)||-1!==t.search(s)||-1!==t.search(n)?t:!1},isMailto:function(t){return-1!==t.search("@")&&/(http|ftp|https):\/\//i.test(t)===!1},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("#")&&(t.url=this.link.isUrl(t.url)),this.link.isEmpty(t)||t.url===!1?!1:t},buildLinkFromModal:function(){var e={};return e.url=this.link.cleanUrl(t("#redactor-link-url").val()),e.text=this.link.cleanText(t("#redactor-link-url-text").val()),e.text=this.link.getText(e),e.target=!!t("#redactor-link-blank").prop("checked"),this.link.parse(e)},buildLinkFromObject:function(t,e){return e.url=this.link.cleanUrl(e.url),e.text="undefined"==typeof e.text&&this.selection.is()?this.selection.text():this.link.cleanText(e.text),e.text=this.link.getText(e),e.target=t===!1?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 t!==!1&&(e.url=t.attr("href"),e.text=t.text(),e.target=this.link.buildTarget(t)),e},buildTarget:function(t){return"undefined"!=typeof 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(e){var i,r=t.each(e,function(e,r){var o=t(r),s=t('<span class="redactor-unlink" />').append(o.contents());return o.replaceWith(s),0===e&&(i=s),o});return 1===e.length&&this.selection.isCollapsed()&&this.caret.after(i),r}}},linkify:function(){return{isKey:function(t){return t===this.keyCode.ENTER||t===this.keyCode.SPACE},isLink:function(t){return t.nodeValue.match(this.opts.regexps.linkyoutube)||t.nodeValue.match(this.opts.regexps.linkvimeo)||t.nodeValue.match(this.opts.regexps.linkimage)||t.nodeValue.match(this.opts.regexps.url)},isFiltered:function(e,i){return 3===i.nodeType&&""!==t.trim(i.nodeValue)&&!t(i).parent().is("pre")&&this.linkify.isLink(i)},handler:function(e,i){var r=t(i),o=r.text(),s=o;s=s.match(this.opts.regexps.linkyoutube)||s.match(this.opts.regexps.linkvimeo)?this.linkify.convertVideoLinks(s):s.match(this.opts.regexps.linkimage)?this.linkify.convertImages(s):this.linkify.convertLinks(s),r.before(o.replace(o,s)).remove()},format:function(){if(this.opts.linkify&&!this.utils.isCurrentOrParent("pre")){this.core.editor().find(":not(iframe,img,a,pre,code,.redactor-unlink)").addBack().contents().filter(t.proxy(this.linkify.isFiltered,this)).each(t.proxy(this.linkify.handler,this));var e=this.core.editor().find(".redactor-linkify-object").each(t.proxy(function(e,i){var r=t(i);return r.removeClass("redactor-linkify-object"),""===r.attr("class")&&r.removeAttr("class"),"DIV"===i.tagName?this.linkify.breakBlockTag(r,"video"):"IMG"===i.tagName?this.linkify.breakBlockTag(r,"image"):"A"===i.tagName&&this.core.callback("insertedLink",r),r},this));setTimeout(t.proxy(function(){this.code.sync(),this.core.callback("linkify",e)},this),100)}},breakBlockTag:function(e,i){var r=this.utils.breakBlockTag();if(r!==!1){var o=e;"image"===i&&(o=t("<figure />").append(e)),"start"===r.type?r.$block.before(o):r.$block.after(o),"image"===i&&this.caret.after(o)}},convertVideoLinks:function(t){var e='<div class="'+this.opts.videoContainerClass+' redactor-linkify-object"><iframe class="redactor-linkify-object" width="500" height="281" src="',i='" frameborder="0" allowfullscreen></iframe></div>';return t.match(this.opts.regexps.linkyoutube)&&(t=t.replace(this.opts.regexps.linkyoutube,e+"//www.youtube.com/embed/$1"+i)),t.match(this.opts.regexps.linkvimeo)&&(t=t.replace(this.opts.regexps.linkvimeo,e+"//player.vimeo.com/video/$2"+i)),t},convertImages:function(t){var e=t.match(this.opts.regexps.linkimage);return e?t.replace(t,'<img src="'+e+'" class="redactor-linkify-object" />'):t},convertLinks:function(e){var i=e.match(this.opts.regexps.url);if(!i)return e;i=t.grep(i,function(e,r){return t.inArray(e,i)===r});for(var r=i.length,o=0;r>o;o++){var s=i[o],n=s,a=null!==s.match(/(https?|ftp):\/\//i)?"":"http://";n.length>this.opts.linkSize&&(n=n.substring(0,this.opts.linkSize)+"..."),-1===n.search("%")&&(n=decodeURIComponent(n));var l="\\b";-1!==t.inArray(s.slice(-1),["/","&","="])&&(l="");var c=new RegExp("("+s.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")+l+")","g"),d="";this.opts.pasteLinkTarget!==!1&&(d=' target="'+this.opts.pasteLinkTarget+'"'),e=e.replace(c,'<a href="'+a+t.trim(s)+'"'+d+' class="redactor-linkify-object">'+t.trim(n)+"</a>")}return e}}},list:function(){return{toggle:function(e){if(!this.utils.inBlocks(["table","td","th","tr"])){var i="orderedlist"===e||"ol"===e?"OL":"UL";e="OL"===i?"orderedlist":"unorderedlist";var r=t(this.selection.current()).parentsUntil(".redactor-in","ul, ol").first();if(this.placeholder.hide(),this.buffer.set(),0!==r.length&&r[0].tagName===i&&this.utils.isRedactorParent(r))return this.selection.save(),r.find("ul, ol").each(function(){var e=t(this).closest("li");t(this).find("li").each(function(){t(e).after(this)})}),r.find("ul, ol").remove(),r.find("li").each(function(){return t(this).replaceWith(function(){return t("<p />").append(t(this).contents())})}),r.replaceWith(function(){return t(this).contents()}),void this.selection.restore();this.selection.save(),0!==r.length&&r[0].tagName!==i?r.each(t.proxy(function(t,e){this.utils.replaceToTag(e,i)},this)):document.execCommand("insert"+e),this.selection.restore();var o=this.list.get();if(!o)return void(this.selection.block()||document.execCommand("formatblock",!1,"p"));o.find("span").replaceWith(function(){return t(this).contents()}),o.find(this.opts.inlineTags.join(",")).each(function(){t(this).removeAttr("style")});var s=o.parent();this.utils.isRedactorParent(s)&&"LI"!==s[0].tagName&&this.utils.isBlock(s)&&(this.selection.save(),s.replaceWith(s.contents()),this.selection.restore())}},get:function(){var e=this.selection.current(),i=t(e).closest("ul, ol",this.core.editor()[0]);return 0===i.length?!1:i},combineAfterAndBefore:function(e){var i=t(e).prev(),r=t(e).next(),o=e&&"P"===e.tagName&&("<br>"===e.innerHTML||""===e.innerHTML),s=1===i.closest("ol, ul",this.core.editor()[0]).length&&1===r.closest("ol, ul",this.core.editor()[0]).length;return o&&s?(i.children("li").last().append(this.marker.get()),i.append(r.contents()),this.selection.restore(),!0):!1}}},marker:function(){return{get:function(t){t="undefined"==typeof 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="undefined"==typeof 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&&e.collapsed===!1&&this.marker.insertNode(e,this.marker.get(2),!1)},remove:function(){this.core.editor().find(".redactor-selection-marker").each(this.marker.iterateRemove)},insertNode:function(e,i,r){var o=this.selection.parent();if(null!==e&&0!==t(o).closest(".redactor-in").length){e=e.cloneRange();try{e.collapse(r),e.insertNode(i)}catch(s){this.focus.start()}}},iterateRemove:function(e,i){var r=t(i),o=r.text().replace(/\u200B/g,"");return""===o?r.remove():r.replaceWith(function(){return t(this).contents()})}}},modal:function(){return{callbacks:{},templates:function(){this.opts.modal={"image-edit":String()+'<div class="redactor-modal-tab redactor-group" data-title="General"><div id="redactor-image-preview" class="redactor-modal-tab-side"></div><div class="redactor-modal-tab-area"><section><label>'+this.lang.get("title")+'</label><input type="text" id="redactor-image-title" /></section><section><label>'+this.lang.get("caption")+'</label><input type="text" id="redactor-image-caption" aria-label="'+this.lang.get("caption")+'" /></section><section><label>'+this.lang.get("link")+'</label><input type="text" id="redactor-image-link" aria-label="'+this.lang.get("link")+'" /></section><section><label class="redactor-image-position-option">'+this.lang.get("image-position")+'</label><select class="redactor-image-position-option" id="redactor-image-align" aria-label="'+this.lang.get("image-position")+'"><option value="none">'+this.lang.get("none")+'</option><option value="left">'+this.lang.get("left")+'</option><option value="center">'+this.lang.get("center")+'</option><option value="right">'+this.lang.get("right")+'</option></select></section><section><label class="checkbox"><input type="checkbox" id="redactor-image-link-blank" aria-label="'+this.lang.get("link-in-new-tab")+'"> '+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><button id="redactor-modal-button-delete" class="redactor-modal-button-offset">'+this.lang.get("delete")+"</button></section></div></div>",image:String()+'<div class="redactor-modal-tab" data-title="Upload"><section><div id="redactor-modal-image-droparea"></div></section></div>',file:String()+'<div class="redactor-modal-tab" data-title="Upload"><section><label>'+this.lang.get("filename")+' <span class="desc">('+this.lang.get("optional")+')</span></label><input type="text" id="redactor-filename" aria-label="'+this.lang.get("filename")+'" /><br><br></section><section><div id="redactor-modal-file-upload"></div></section></div>',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>"},t.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(t,e,i){"undefined"!=typeof this.$modalBox&&this.$modalBox.hasClass("open")||(this.modal.templateName=t,this.modal.width=i,this.modal.build(),this.modal.enableEvents(),this.modal.setTitle(e),this.modal.setDraggable(),this.modal.setContent(),"undefined"!=typeof this.modal.callbacks[t]&&this.modal.callbacks[t].call(this))},show:function(){this.detect.isDesktop()||document.activeElement.blur(),this.selection.save(),this.modal.buildTabber(),this.detect.isMobile()&&(this.modal.width="96%"),setTimeout(t.proxy(this.modal.buildWidth,this),0),t(window).on("resize.redactor-modal",t.proxy(this.modal.buildWidth,this)),this.$modalOverlay.redactorAnimation("fadeIn",{duration:.25}),this.$modalBox.addClass("open").show(),this.$modal.redactorAnimation("fadeIn",{timing:"cubic-bezier(0.175, 0.885, 0.320, 1.105)"},t.proxy(function(){this.utils.saveScroll(),this.utils.disableBodyScroll(),this.core.callback("modalOpened",this.modal.templateName,this.$modal),t(document).off("focusin.modal");var e=this.$modal.find("input[type=text],input[type=url],input[type=email]");e.on("keydown.redactor-modal",t.proxy(this.modal.setEnter,this))},this))},buildWidth:function(){var e=t(window).height(),i=t(window).width(),r="number"==typeof this.modal.width;!r&&this.modal.width.match(/%$/)?this.$modal.css({width:this.modal.width,"margin-bottom":"16px"}):parseInt(this.modal.width)>i?this.$modal.css({width:"96%","margin-bottom":"2%"}):(r&&(this.modal.width+="px"),this.$modal.css({width:this.modal.width,"margin-bottom":"16px"}));var o=this.$modal.outerHeight(),s=e/2-o/2+"px";this.detect.isMobile()?s="2%":o>e&&(s="16px"),this.$modal.css("margin-top",s)},buildTabber:function(){this.modal.tabs=this.$modal.find(".redactor-modal-tab"),this.modal.tabs.length<2||(this.modal.$tabsBox=t('<div id="redactor-modal-tabber" />'),t.each(this.modal.tabs,t.proxy(function(e,i){var r=t('<a href="#" rel="'+e+'" />').text(t(i).attr("data-title"));r.on("click",t.proxy(this.modal.showTab,this)),0===e&&r.addClass("active"),this.modal.$tabsBox.append(r)},this)),this.$modalBody.prepend(this.modal.$tabsBox))},showTab:function(e){e.preventDefault();var i=t(e.target),r=i.attr("rel");return this.modal.tabs.hide(),this.modal.tabs.eq(r).show(),t("#redactor-modal-tabber").find("a").removeClass("active"),i.addClass("active"),!1},setTitle:function(t){this.$modalHeader.html(t)},setContent:function(){this.$modalBody.html(this.modal.getTemplate(this.modal.templateName)),this.modal.getCancelButton().on("mousedown",t.proxy(this.modal.close,this))},setDraggable:function(){"undefined"!=typeof t.fn.draggable&&(this.$modal.draggable({handle:this.$modalHeader}),this.$modalHeader.css("cursor","move"))},setEnter:function(t){13===t.which&&(t.preventDefault(),this.modal.getActionButton().click())},build:function(){this.modal.buildOverlay(),this.$modalBox=t('<div id="redactor-modal-box"/>').hide(),this.$modal=t('<div id="redactor-modal" role="dialog" />'),this.$modalHeader=t('<div id="redactor-modal-header" />'),this.$modalClose=t('<button type="button" id="redactor-modal-close" aria-label="'+this.lang.get("close")+'" />').html("&times;"),this.$modalBody=t('<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=t('<div id="redactor-modal-overlay">').hide(),t("body").prepend(this.$modalOverlay)},enableEvents:function(){this.$modalClose.on("mousedown.redactor-modal",t.proxy(this.modal.close,this)),t(document).on("keyup.redactor-modal",t.proxy(this.modal.closeHandler,this)),this.core.editor().on("keyup.redactor-modal",t.proxy(this.modal.closeHandler,this)),this.$modalBox.on("click.redactor-modal",t.proxy(this.modal.close,this))},disableEvents:function(){this.$modalClose.off("mousedown.redactor-modal"),t(document).off("keyup.redactor-modal"),this.core.editor().off("keyup.redactor-modal"),this.$modalBox.off("click§.redactor-modal"),t(window).off("resize.redactor-modal")},closeHandler:function(t){t.which===this.keyCode.ESC&&this.modal.close(!1)},close:function(e){if(e){if("redactor-modal-button-cancel"!==t(e.target).attr("id")&&e.target!==this.$modalClose[0]&&e.target!==this.$modalBox[0])return;e.preventDefault()}this.$modalBox&&(this.selection.restore(),this.modal.disableEvents(),this.utils.enableBodyScroll(),this.utils.restoreScroll(),this.$modalOverlay.redactorAnimation("fadeOut",{duration:.4},t.proxy(function(){this.$modalOverlay.remove()},this)),this.$modal.redactorAnimation("fadeOut",{duration:.3,timing:"cubic-bezier(0.175, 0.885, 0.320, 1.175)"},t.proxy(function(){"undefined"!=typeof this.$modalBox&&(this.$modalBox.remove(),this.$modalBox=void 0),t(document.body).css("overflow",this.modal.bodyOveflow),this.core.callback("modalClosed",this.modal.templateName)},this)))}}},observe:function(){return{load:function(){"undefined"==typeof this.opts.destroyed&&(this.observe.links(),this.observe.images())},isCurrent:function(e,i){return"undefined"==typeof i&&(i=t(this.selection.current())),i.is(e)||i.parents(e).length>0},toolbar:function(){this.observe.buttons(),this.observe.dropdowns()},buttons:function(e,i){var r=this.selection.current(),o=this.selection.parent();return e!==!1?this.button.setInactiveAll():this.button.setInactiveAll(i),e===!1&&"html"!==i?void(-1!==t.inArray(i,this.opts.activeButtons)&&this.button.toggleActive(i)):void(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")),t.each(this.opts.activeButtonsStates,t.proxy(function(e,i){var s=t(o).closest(e,this.$editor[0]),n=t(r).closest(e,this.$editor[0]);(0===s.length||this.utils.isRedactorParent(s))&&this.utils.isRedactorParent(n)&&(0===s.length&&0===n.closest(e,this.$editor[0]).length||this.button.setActive(i))},this))))},dropdowns:function(){var e=t("<div />").html(this.selection.html()).find("a").length,i=t(this.selection.current()),r=this.utils.isRedactorParent(i);t.each(this.opts.observe.dropdowns,t.proxy(function(t,o){var s=o.observe,n=s.element,a=o.item,l="undefined"!=typeof s["in"]?s["in"]:!1,c="undefined"!=typeof s.out?s.out:!1;i.closest(n).length>0&&r||"a"===n&&0!==e?this.observe.setDropdownProperties(a,l,c):this.observe.setDropdownProperties(a,c,l)},this))},setDropdownProperties:function(t,e,i){i&&"undefined"!=typeof i.attr&&this.observe.setDropdownAttr(t,i.attr,!0),"undefined"!=typeof e.attr&&this.observe.setDropdownAttr(t,e.attr),"undefined"!=typeof e.title&&t.find("span").text(e.title)},setDropdownAttr:function(e,i,r){t.each(i,function(t,i){"class"===t?r?e.removeClass(i):e.addClass(i):r?e.removeAttr(t):e.attr(t,i)})},addDropdown:function(t,e,i){"undefined"!=typeof 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(t.proxy(function(e,i){var r=t(i);r.closest("a",this.$editor[0]).on("click",function(t){t.preventDefault()}),this.image.setEditable(r)},this)))},links:function(){this.opts.linkTooltip&&this.core.editor().find("a").each(t.proxy(function(e,i){var r=t(i);r.data("cached")!==!0&&(r.data("cached",!0),r.on("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,t.proxy(this.observe.showTooltip,this)))},this))},getTooltipPosition:function(t){return t.offset()},showTooltip:function(e){var i=t(e.target);if("IMG"!==i[0].tagName&&("A"!==i[0].tagName&&(i=i.closest("a",this.$editor[0])),"A"===i[0].tagName)){var r=i,o=this.observe.getTooltipPosition(r),s=t('<span class="redactor-link-tooltip"></span>'),n=r.attr("href");void 0===n&&(n=""),n.length>24&&(n=n.substring(0,24)+"...");var a=t('<a href="'+r.attr("href")+'" target="_blank" />').html(n).addClass("redactor-link-tooltip-action"),l=t('<a href="#" />').html(this.lang.get("edit")).on("click",t.proxy(this.link.show,this)).addClass("redactor-link-tooltip-action"),c=t('<a href="#" />').html(this.lang.get("unlink")).on("click",t.proxy(this.link.unlink,this)).addClass("redactor-link-tooltip-action");s.append(a).append(" | ").append(l).append(" | ").append(c);var d=parseInt(r.css("line-height"),10),h=Math.ceil((e.pageY-o.top)/d),u=o.top+h*d;s.css({top:u+"px",left:o.left+"px"}),t(".redactor-link-tooltip").remove(),t("body").append(s),this.core.editor().on("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,t.proxy(this.observe.closeTooltip,this)),t(document).on("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,t.proxy(this.observe.closeTooltip,this))}},closeAllTooltip:function(){t(".redactor-link-tooltip").remove()},closeTooltip:function(e){e=e.originalEvent||e;var i=e.target,r=t(i).closest("a",this.$editor[0]);0!==r.length&&"A"===r[0].tagName&&"A"!==i.tagName||"A"===i.tagName&&this.utils.isRedactorParent(i)||t(i).hasClass("redactor-link-tooltip-action")||(this.observe.closeAllTooltip(),this.core.editor().off("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,t.proxy(this.observe.closeTooltip,this)),t(document).off("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,t.proxy(this.observe.closeTooltip,this)))}}},offset:function(){return{get:function(e){var i=this.offset.clone(e);if(i===!1)return 0;var r=document.createElement("div");r.appendChild(i.cloneContents()),r.innerHTML=r.innerHTML.replace(/<img(.*?[^>])>$/gi,"i");var o=t.trim(t(r).text()).replace(/[\t\n\r\n]/g,"").replace(/\u200B/g,"");return o.length},clone:function(t){var e=this.selection.get(),i=this.selection.range(e);if(null===i&&"undefined"==typeof t)return!1;if(t="undefined"==typeof t?this.$editor:t,t===!1)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="undefined"==typeof e?t:e,this.focus.is()||this.focus.start();for(var i,r=this.selection.get(),o=this.selection.range(r),s=0,n=document.createTreeWalker(this.$editor[0],NodeFilter.SHOW_TEXT,null,null);null!==(i=n.nextNode());)if(s+=i.nodeValue.length,
-s>t&&(o.setStart(i,i.nodeValue.length+t-s),t=1/0),s>=e){o.setEnd(i,i.nodeValue.length+e-s);break}o.collapse(!1),this.selection.update(r,o)}}},paragraphize:function(){return{load:function(e){return this.opts.paragraphize===!1||"inline"===this.opts.type||"pre"===this.opts.type?e:""===e||"<p></p>"===e?this.opts.emptyHtml:(e+="\n",this.paragraphize.safes=[],this.paragraphize.z=0,e=e.replace(/(<br\s?\/?>){1,}\n?<\/blockquote>/gi,"</blockquote>"),e=e.replace(/<\/pre>/gi,"</pre>\n\n"),e=e.replace(/<p>\s<br><\/p>/gi,"<p></p>"),e=this.paragraphize.getSafes(e),e=e.replace("<br>","\n"),e=this.paragraphize.convert(e),e=this.paragraphize.clear(e),e=this.paragraphize.restoreSafes(e),e=e.replace(new RegExp("<br\\s?/?>\n?<("+this.opts.paragraphizeBlocks.join("|")+")(.*?[^>])>","gi"),"<p><br /></p>\n<$1$2>"),t.trim(e))},getSafes:function(e){var i=t("<div />").append(e);return i.find("blockquote p").replaceWith(function(){return t(this).append("<br />").contents()}),i.find(this.opts.paragraphizeBlocks.join(", ")).each(t.proxy(function(e,i){return this.paragraphize.z++,this.paragraphize.safes[this.paragraphize.z]=i.outerHTML,t(i).replaceWith("\n#####replace"+this.paragraphize.z+"#####\n\n")},this)),i.find("span.redactor-selection-marker").each(t.proxy(function(e,i){return this.paragraphize.z++,this.paragraphize.safes[this.paragraphize.z]=i.outerHTML,t(i).replaceWith("\n#####replace"+this.paragraphize.z+"#####\n\n")},this)),i.html()},restoreSafes:function(e){return t.each(this.paragraphize.safes,function(t,i){i="undefined"!=typeof i?i.replace(/\$/g,"&#36;"):i,e=e.replace("#####replace"+t+"#####",i)}),e},convert:function(e){e=e.replace(/\r\n/g,"xparagraphmarkerz"),e=e.replace(/\n/g,"xparagraphmarkerz"),e=e.replace(/\r/g,"xparagraphmarkerz");var i=/\s+/g;e=e.replace(i," "),e=t.trim(e);var r=/xparagraphmarkerzxparagraphmarkerz/gi;e=e.replace(r,"</p><p>");var o=/xparagraphmarkerz/gi;return e=e.replace(o,"<br>"),e="<p>"+e+"</p>",e=e.replace("<p></p>",""),e=e.replace("\r\n\r\n",""),e=e.replace(/<\/p><p>/g,"</p>\r\n\r\n<p>"),e=e.replace(new RegExp("<br\\s?/?></p>","g"),"</p>"),e=e.replace(new RegExp("<p><br\\s?/?>","g"),"<p>"),e=e.replace(new RegExp("<p><br\\s?/?>","g"),"<p>"),e=e.replace(new RegExp("<br\\s?/?></p>","g"),"</p>"),e=e.replace(/<p>&nbsp;<\/p>/gi,""),e=e.replace(/<p>\s?<br>&nbsp;<\/p>/gi,""),e=e.replace(/<p>\s?<br>/gi,"<p>")},clear:function(t){return t=t.replace(/<p>(.*?)#####replace(.*?)#####\s?<\/p>/gi,"<p>$1</p>#####replace$2#####"),t=t.replace(/(<br\s?\/?>){2,}<\/p>/gi,"</p>"),t=t.replace(new RegExp("</blockquote></p>","gi"),"</blockquote>"),t=t.replace(new RegExp("<p></blockquote>","gi"),"</blockquote>"),t=t.replace(new RegExp("<p><blockquote>","gi"),"<blockquote>"),t=t.replace(new RegExp("<blockquote></p>","gi"),"<blockquote>"),t=t.replace(new RegExp("<p><p ","gi"),"<p "),t=t.replace(new RegExp("<p><p>","gi"),"<p>"),t=t.replace(new RegExp("</p></p>","gi"),"</p>"),t=t.replace(new RegExp("<p>\\s?</p>","gi"),""),t=t.replace(new RegExp("\n</p>","gi"),"</p>"),t=t.replace(new RegExp("<p>   ?       ?\n?<p>","gi"),"<p>"),t=t.replace(new RegExp("<p>       *</p>","gi"),"")}}},paste:function(){return{init:function(e){this.rtePaste=!0;var i=!("pre"!==this.opts.type&&!this.utils.isCurrentOrParent("pre"));return this.detect.isDesktop()&&!this.paste.pre&&this.opts.clipboardImageUpload&&this.opts.imageUpload&&this.paste.detectClipboardUpload(e)?void(this.detect.isIe()&&setTimeout(t.proxy(this.paste.clipboardUpload,this),100)):(this.utils.saveScroll(),this.selection.save(),this.paste.createPasteBox(i),t(window).on("scroll.redactor-freeze",t.proxy(function(){t(window).scrollTop(this.saveBodyScroll)},this)),void setTimeout(t.proxy(function(){var e=this.paste.getPasteBoxCode(i);this.buffer.set(),this.selection.restore(),this.utils.restoreScroll();var r=this.clean.getCurrentType(e);e=this.clean.onPaste(e,r);var o=this.core.callback("paste",e);e="undefined"==typeof o?e:o,this.paste.insert(e,r),this.rtePaste=!1,i&&this.clean.cleanPre(),t(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(e){var i={position:"fixed",width:"1px",top:0,left:"-9999px"};this.$pasteBox=e?t("<textarea>").css(i):t("<div>").attr("contenteditable","true").css(i),this.paste.appendPasteBox(),this.$pasteBox.focus()},appendPasteBox:function(){if(this.detect.isIe())this.core.box().append(this.$pasteBox);else{var e=t(".modal-body:visible");e.length>0?e.append(this.$pasteBox):t("body").prepend(this.$pasteBox)}},detectClipboardUpload:function(e){e=e.originalEvent||e;var i=e.clipboardData;if(this.detect.isIe()||this.detect.isFirefox())return!1;var r=i.types;if(-1!==r.indexOf("public.tiff"))return e.preventDefault(),!1;if(i.items&&i.items.length){var o=i.items[0].getAsFile();if(null===o)return!1;var s=new FileReader;return s.readAsDataURL(o),s.onload=t.proxy(this.paste.insertFromClipboard,this),!0}},clipboardUpload:function(){var e=this.$editor.find("img");t.each(e,t.proxy(function(e,i){if(-1!==i.src.search(/^data\:image/i)){var r=window.FormData?new FormData:null;if(window.FormData){this.upload.direct=!0,this.upload.type="image",this.upload.url=this.opts.imageUpload,this.upload.callback=t.proxy(function(e){if(this.detect.isIe())t(i).wrap(t("<figure />"));else{var r=t(i).parent();this.utils.replaceToTag(r,"figure")}i.src=e.url,this.core.callback("imageUpload",t(i),e)},this);var o=this.utils.dataURItoBlob(i.src);r.append("clipboard",1),r.append(this.opts.imageUploadParam,o),this.progress.show(),this.upload.send(r,!1),this.code.sync(),this.rtePaste=!1}}},this))},insertFromClipboard:function(t){var e=window.FormData?new FormData:null;if(window.FormData){this.upload.direct=!0,this.upload.type="image",this.upload.url=this.opts.imageUpload,this.upload.callback=this.image.insert;var i=this.utils.dataURItoBlob(t.target.result);e.append("clipboard",1),e.append(this.opts.imageUploadParam,i),this.progress.show(),this.upload.send(e,t),this.rtePaste=!1}},insert:function(e,i){i.pre?this.insert.raw(e):i.text?this.insert.text(e):this.insert.html(e,i),this.detect.isFirefox()&&this.opts.clipboardImageUpload&&setTimeout(t.proxy(this.paste.clipboardUpload,this),100)}}},placeholder:function(){return{enable:function(){setTimeout(t.proxy(function(){return this.placeholder.isEditorEmpty()?this.placeholder.show():this.placeholder.hide()},this),5)},show:function(){this.core.editor().addClass("redactor-placeholder")},update:function(t){this.opts.placeholder=t,this.core.editor().attr("placeholder",t)},hide:function(){this.core.editor().removeClass("redactor-placeholder")},is:function(){return this.core.editor().hasClass("redactor-placeholder")},init:function(){this.placeholder.enabled()&&(this.utils.isEditorRelative()||this.utils.setEditorRelative(),this.placeholder.build(),this.placeholder.buildPosition(),this.placeholder.enable(),this.placeholder.enableEvents())},enabled:function(){return this.opts.placeholder?this.core.element().attr("placeholder",this.opts.placeholder):this.placeholder.isAttr()},enableEvents:function(){this.core.editor().on("keydown.redactor-placeholder."+this.uuid,t.proxy(this.placeholder.enable,this))},disableEvents:function(){this.core.editor().off(".redactor-placeholder."+this.uuid)},build:function(){this.core.editor().attr("placeholder",this.core.element().attr("placeholder"))},buildPosition:function(){var e=t("<style />");e.addClass("redactor-placeholder-style-tag"),e.html("#"+this.core.id()+".redactor-placeholder::after "+this.placeholder.getPosition()),t("head").append(e)},getPosition:function(){return"{ top: "+this.core.editor().css("padding-top")+"; left: "+this.core.editor().css("padding-left")+"; }"},isEditorEmpty:function(){var e=t.trim(this.core.editor().html()).replace(/[\t\n]/g,""),i=["","<p>​</p>","<p>​<br></p>",this.opts.emptyHtmlRendered];return-1!==t.inArray(e,i)},isAttr:function(){return"undefined"!=typeof this.core.element().attr("placeholder")&&""!==this.core.element().attr("placeholder")},destroy:function(){this.core.editor().removeAttr("placeholder"),this.placeholder.hide(),this.placeholder.disableEvents(),t(".redactor-placeholder-style-tag").remove()}}},progress:function(){return{$box:null,$bar:null,target:document.body,show:function(){this.progress.is()?this.progress.$box.show():(this.progress.build(),this.progress.$box.redactorAnimation("fadeIn"))},hide:function(){this.progress.is()&&this.progress.$box.redactorAnimation("fadeOut",{duration:.35},t.proxy(this.progress.destroy,this))},update:function(t){this.progress.show(),this.progress.$bar.css("width",t+"%")},is:function(){return null!==this.progress.$box},build:function(){this.progress.$bar=t("<span />"),this.progress.$box=t('<div id="redactor-progress" />'),this.progress.$box.append(this.progress.$bar),t(this.progress.target).append(this.progress.$box)},destroy:function(){this.progress.is()&&this.progress.$box.remove(),this.progress.$box=null,this.progress.$bar=null}}},selection:function(){return{get:function(){return window.getSelection?window.getSelection():document.selection&&"Control"!==document.selection.type?document.selection:null},range:function(t){return"undefined"==typeof t&&(t=this.selection.get()),t.getRangeAt&&t.rangeCount?t.getRangeAt(0):null},is:function(){return!this.selection.isCollapsed()},isRedactor:function(){var e=this.selection.range();if(null!==e){var i=e.startContainer.parentNode;if(t(i).hasClass("redactor-in")||0!==t(i).parents(".redactor-in").length)return!0}return!1},isCollapsed:function(){var t=this.selection.get();return null===t?!1:t.isCollapsed},update:function(t,e){null!==e&&(t.removeAllRanges(),t.addRange(e))},current:function(){var t=this.selection.get();return null===t?!1:t.anchorNode},parent:function(){var t=this.selection.current();return null===t?!1:t.parentNode},block:function(e){for(e=e||this.selection.current();e;){if(this.utils.isBlockTag(e.tagName))return t(e).hasClass("redactor-in")?!1:e;e=e.parentNode}return!1},inline:function(e){for(e=e||this.selection.current();e;){if(this.utils.isInlineTag(e.tagName))return t(e).hasClass("redactor-in")?!1:e;e=e.parentNode}return!1},element:function(e){for(e||(e=this.selection.current());e;){if(1===e.nodeType)return t(e).hasClass("redactor-in")?!1:e;e=e.parentNode}return!1},prev:function(){var t=this.selection.current();return null===t?!1:this.selection.current().previousSibling},next:function(){var t=this.selection.current();return null===t?!1:this.selection.current().nextSibling},blocks:function(e){var i=[],r=this.selection.nodes(e);t.each(r,t.proxy(function(t,e){this.utils.isBlock(e)&&i.push(e)},this));var o=this.selection.block();return 0===i.length&&o===!1?[]:0===i.length&&o!==!1?[o]:i},inlines:function(e){var i=[],r=this.selection.nodes(e);t.each(r,t.proxy(function(t,e){this.utils.isInline(e)&&i.push(e)},this));var o=this.selection.inline();return 0===i.length&&o===!1?[]:0===i.length&&o!==!1?[o]:i},nodes:function(e){var i="undefined"==typeof e?[]:t.isArray(e)?e:[e],r=this.selection.get(),o=this.selection.range(r),s=[],n=[];if(this.utils.isCollapsed())s=[this.selection.current()];else{var a=o.startContainer,l=o.endContainer;if(a===l)return[this.selection.parent()];for(;a&&a!==l;)s.push(a=this.selection.nextNode(a));for(a=o.startContainer;a&&a!==o.commonAncestorContainer;)s.unshift(a),a=a.parentNode}return t.each(s,function(e,r){if(r){var o=1!==r.nodeType?!1:r.tagName.toLowerCase();if(t(r).hasClass("redactor-script-tag")||t(r).hasClass("redactor-selection-marker"))return;if(o&&0!==i.length&&-1===t.inArray(o,i))return;n.push(r)}}),0===n.length?[]:n},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(),t!==!1&&(this.marker.remove(),this.savedSel=!1)},saveInstant:function(){var t=this.core.editor()[0],e=t.ownerDocument,i=e.defaultView,r=i.getSelection();if(r.getRangeAt&&r.rangeCount){var o=r.getRangeAt(0),s=o.cloneRange();s.selectNodeContents(t),s.setEnd(o.startContainer,o.startOffset);var n=s.toString().length;return this.saved={start:n,end:n+o.toString().length,node:o.startContainer},this.saved}},restoreInstant:function(t){if("undefined"!=typeof t||this.saved){this.saved="undefined"!=typeof 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=this.core.editor()[0],r=i.ownerDocument,o=r.defaultView,s=0,n=r.createRange();n.setStart(i,0),n.collapse(!0);for(var a,l=[i],c=!1,d=!1;!d&&(a=l.pop());)if(3==a.nodeType){var h=s+a.length;!c&&this.saved.start>=s&&this.saved.start<=h&&(n.setStart(a,this.saved.start-s),c=!0),c&&this.saved.end>=s&&this.saved.end<=h&&(n.setEnd(a,this.saved.end-s),d=!0),s=h}else for(var u=a.childNodes.length;u--;)l.push(a.childNodes[u]);var p=o.getSelection();p.removeAllRanges(),p.addRange(n)}else try{var n=document.createRange();n.setStart(e[0],0);var p=window.getSelection();p.removeAllRanges(),p.addRange(n)}catch(f){}}},node:function(e){t(e).prepend(this.marker.get(1)),t(e).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,o=0;r>o;++o)i.appendChild(e.getRangeAt(o).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(e,i){return this.opts.shortcuts===!1?(!e.ctrlKey&&!e.metaKey||66!==i&&73!==i||e.preventDefault(),!1):void t.each(this.opts.shortcuts,t.proxy(function(t,i){this.shortcuts.build(e,t,i)},this))},build:function(e,i,r){for(var o=t.proxy(function(){this.shortcuts.buildHandler(r)},this),s=i.split(","),n=s.length,a=0;n>a;a++)"string"==typeof s[a]&&this.shortcuts.handler(e,t.trim(s[a]),o)},buildHandler:function(t){var e;"-1"!==t.func.search(/\./)?(e=t.func.split("."),"undefined"!=typeof this[e[0]]&&this[e[0]][e[1]].apply(this,t.params)):this[t.func].apply(this,t.params)},handler:function(e,i,r){i=i.toLowerCase().split(" ");var o=this.shortcuts.hotkeysSpecialKeys[e.keyCode],s=String.fromCharCode(e.which).toLowerCase(),n="",a={};t.each(["alt","ctrl","meta","shift"],function(t,i){e[i+"Key"]&&o!==i&&(n+=i+"+")}),o&&(a[n+o]=!0),s&&(a[n+s]=!0,a[n+this.shortcuts.hotkeysShiftNums[s]]=!0,"shift+"===n&&(a[this.shortcuts.hotkeysShiftNums[s]]=!0));for(var l=i.length,c=0;l>c;c++)if(a[i[c]])return e.preventDefault(),r.apply(this,arguments)}}},storage:function(){return{data:[],add:function(t){t.status=!0,t.url=decodeURI(t.url),this.storage.data[t.url]=t},status:function(t,e){this.storage.data[decodeURI(t)].status=e},observe:function(){var e=this,i=this.core.editor().find("[data-image]");i.each(function(i,r){e.storage.add({type:"image",node:r,url:r.src,id:t(r).attr("data-image")})});var r=this.core.editor().find("[data-file]");r.each(function(i,r){e.storage.add({type:"file",node:r,url:r.href,id:t(r).attr("data-file")})});var o=this.core.editor().find("[data-s3]");o.each(function(i,r){var o="IMG"===r.tagName?r.src:r.href;e.storage.add({type:"s3",node:r,url:o,id:t(r).attr("data-s3")})})},changes:function(){for(var t in this.storage.data){var e=this.storage.data[t],i="IMG"===e.node.tagName?"src":"href",r=this.core.editor().find("[data-"+e.type+"]["+i+'="'+e.url+'"]');0===r.length?this.storage.status(e.url,!1):this.storage.status(e.url,!0)}return this.storage.data}}},toolbar:function(){return{build:function(){this.button.hideButtons(),this.button.hideButtonsOnMobile(),this.$toolbar=this.toolbar.createContainer(),this.toolbar.append(),this.button.$toolbar=this.$toolbar,this.button.setFormatting(),this.button.load(this.$toolbar),this.toolbar.setOverflow(),this.toolbar.setFixed()},createContainer:function(){return t("<ul>").addClass("redactor-toolbar").attr({id:"redactor-toolbar-"+this.uuid,role:"toolbar"})},append:function(){this.opts.toolbarExternal?(this.$toolbar.addClass("redactor-toolbar-external"),t(this.opts.toolbarExternal).html(this.$toolbar)):"textarea"===this.opts.type?this.$box.prepend(this.$toolbar):this.$element.before(this.$toolbar)},setOverflow:function(){this.opts.toolbarOverflow&&this.$toolbar.addClass("redactor-toolbar-overflow")},setFixed:function(){if(this.opts.toolbarFixed&&!this.opts.toolbarExternal){if(this.opts.toolbarFixedTarget!==document){var e=t(this.opts.toolbarFixedTarget);this.toolbarOffsetTop=0===e.length?0:this.core.box().offset().top-e.offset().top}var i=0!==this.core.box().closest(".modal-body").length?1e3:0;setTimeout(t.proxy(function(){var e=this;this.toolbar.observeScroll(!1),this.detect.isDesktop()?t(this.opts.toolbarFixedTarget).on("scroll.redactor."+this.uuid,function(){e.core.editor().height()<100||e.placeholder.isEditorEmpty()||e.toolbar.observeScroll()}):t(this.opts.toolbarFixedTarget).on("scroll.redactor."+this.uuid,function(){e.core.editor().height()<100||e.placeholder.isEditorEmpty()||(e.core.toolbar().hide(),clearTimeout(t.data(this,"scrollCheck")),t.data(this,"scrollCheck",setTimeout(function(){e.core.toolbar().show(),e.toolbar.observeScroll()},250)))})},this),i)}},setUnfixed:function(){this.toolbar.observeScrollDisable()},getBoxTop:function(){return this.opts.toolbarFixedTarget===document?this.core.box().offset().top:this.toolbar.toolbarOffsetTop},observeScroll:function(e){var i=0;e!==!1&&(i=this.opts.toolbarFixedTarget===document?20:0);var r=t(this.opts.toolbarFixedTarget).scrollTop(),o=this.toolbar.getBoxTop();r!==o&&(r+this.opts.toolbarFixedTopOffset+i>o?this.toolbar.observeScrollEnable(r,o):this.toolbar.observeScrollDisable())},observeScrollResize:function(){this.$toolbar.css({width:this.core.box().innerWidth(),left:this.core.box().offset().left})},observeScrollEnable:function(e,i){if("undefined"!=typeof this.fullscreen&&this.fullscreen.isOpened===!1)return void this.toolbar.observeScrollDisable();var r=i+this.core.box().outerHeight()-32,o=this.core.box().innerWidth(),s=this.detect.isDesktop()?"fixed":"absolute",n=this.detect.isDesktop()?this.opts.toolbarFixedTopOffset:t(this.opts.toolbarFixedTarget).scrollTop()-i+this.opts.toolbarFixedTopOffset,a=this.detect.isDesktop()?this.core.box().offset().left:0;this.opts.toolbarFixedTarget!==document&&(s="absolute",n=this.opts.toolbarFixedTopOffset+t(this.opts.toolbarFixedTarget).scrollTop()-i,a=0),this.$toolbar.addClass("toolbar-fixed-box"),this.$toolbar.css({position:s,width:o,top:n,left:a}),e>r&&t(".redactor-dropdown-"+this.uuid+":visible").hide(),this.toolbar.setDropdownsFixed(),this.$toolbar.css("visibility",r>e?"visible":"hidden"),t(window).on("resize.redactor-toolbar."+this.uuid,t.proxy(this.toolbar.observeScrollResize,this))},observeScrollDisable:function(){this.$toolbar.css({position:"relative",width:"auto",top:0,left:0,visibility:"visible"}),this.toolbar.unsetDropdownsFixed(),this.$toolbar.removeClass("toolbar-fixed-box"),t(window).off("resize.redactor-toolbar."+this.uuid)},setDropdownsFixed:function(){var t=this.opts.toolbarFixedTarget===document&&this.detect.isDesktop()?"fixed":"absolute";this.toolbar.setDropdownPosition(t)},unsetDropdownsFixed:function(){this.toolbar.setDropdownPosition("absolute")},setDropdownPosition:function(e){var i=this;t(".redactor-dropdown-"+this.uuid).each(function(){var r=t(this),o=i.button.get(r.attr("rel")),s="fixed"===e?i.opts.toolbarFixedTopOffset:o.offset().top;r.css({position:e,top:o.innerHeight()+s+"px"})})}}},upload:function(){return{init:function(e,i,r){this.upload.direct=!1,this.upload.callback=r,this.upload.url=i,this.upload.$el=t(e),this.upload.$droparea=t('<div id="redactor-droparea" />'),this.upload.$placeholdler=t('<div id="redactor-droparea-placeholder" />').text(this.lang.get("upload-label")),this.upload.$input=t('<input type="file" name="file" multiple />'),this.upload.$placeholdler.append(this.upload.$input),this.upload.$droparea.append(this.upload.$placeholdler),this.upload.$el.append(this.upload.$droparea),this.upload.$droparea.off("redactor.upload"),this.upload.$input.off("redactor.upload"),this.upload.$droparea.on("dragover.redactor.upload",t.proxy(this.upload.onDrag,this)),this.upload.$droparea.on("dragleave.redactor.upload",t.proxy(this.upload.onDragLeave,this)),this.upload.$input.on("change.redactor.upload",t.proxy(function(t){t=t.originalEvent||t;for(var e=this.upload.$input[0].files.length,i=0;e>i;i++)this.upload.traverseFile(this.upload.$input[0].files[i],t)},this)),this.upload.$droparea.on("drop.redactor.upload",t.proxy(function(t){t.preventDefault(),this.upload.$droparea.removeClass("drag-hover").addClass("drag-drop"),this.upload.onDrop(t)},this))},directUpload:function(t,e){this.upload.direct=!0,this.upload.traverseFile(t,e)},onDrop:function(t){t=t.originalEvent||t;var e=t.dataTransfer.files;if(this.opts.multipleImageUpload)for(var i=e.length,r=0;i>r;r++)this.upload.traverseFile(e[r],t);else this.upload.traverseFile(e[0],t)},traverseFile:function(t,e){if(this.opts.s3)return this.upload.setConfig(t),void this.uploads3.send(t,e);var i=window.FormData?new FormData:null;if(window.FormData){this.upload.setConfig(t);var r="image"===this.upload.type?this.opts.imageUploadParam:this.opts.fileUploadParam;i.append(r,t)}this.progress.show(),this.core.callback("uploadStart",e,i),this.upload.send(i,e)},setConfig:function(t){this.upload.getType(t),this.upload.direct&&(this.upload.url="image"===this.upload.type?this.opts.imageUpload:this.opts.fileUpload,this.upload.callback="image"===this.upload.type?this.image.insert:this.file.insert)},getType:function(t){this.upload.type=-1===this.opts.imageTypes.indexOf(t.type)?"file":"image",null===this.opts.imageUpload&&null!==this.opts.fileUpload&&(this.upload.type="file")},getHiddenFields:function(e,i){return e===!1||"object"!=typeof e?i:(t.each(e,t.proxy(function(e,r){null!==r&&0===r.toString().indexOf("#")&&(r=t(r).val()),i.append(e,r)},this)),i)},send:function(e,i){"image"===this.upload.type?(e=this.utils.appendFields(this.opts.imageUploadFields,e),e=this.utils.appendForms(this.opts.imageUploadForms,e),e=this.upload.getHiddenFields(this.upload.imageFields,e)):(e=this.utils.appendFields(this.opts.fileUploadFields,e),e=this.utils.appendForms(this.opts.fileUploadForms,e),e=this.upload.getHiddenFields(this.upload.fileFields,e));var r=new XMLHttpRequest;r.open("POST",this.upload.url),r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.onreadystatechange=t.proxy(function(){if(4===r.readyState){var t=r.responseText;t=t.replace(/^\[/,""),t=t.replace(/\]$/,"");var e;try{e="string"==typeof t?JSON.parse(t):t}catch(o){e={error:!0}}this.progress.hide(),this.upload.direct||this.upload.$droparea.removeClass("drag-drop"),this.upload.callback(e,this.upload.direct,i)}},this),this.core.callback("uploadBeforeSend",r),r.send(e)},onDrag:function(t){t.preventDefault(),this.upload.$droparea.addClass("drag-hover")},onDragLeave:function(t){t.preventDefault(),this.upload.$droparea.removeClass("drag-hover")},clearImageFields:function(){this.upload.imageFields={}},addImageFields:function(t,e){this.upload.imageFields[t]=e},removeImageFields:function(t){delete this.upload.imageFields[t]},clearFileFields:function(){this.upload.fileFields={}},addFileFields:function(t,e){this.upload.fileFields[t]=e},removeFileFields:function(t){delete this.upload.fileFields[t]}}},uploads3:function(){return{send:function(e,i){this.uploads3.executeOnSignedUrl(e,t.proxy(function(t){this.uploads3.sendToS3(e,t,i)},this))},executeOnSignedUrl:function(t,e){var i=new XMLHttpRequest,r=-1===this.opts.s3.search(/\?/)?"?":"&";i.open("GET",this.opts.s3+r+"name="+t.name+"&type="+t.type,!0),i.overrideMimeType&&i.overrideMimeType("text/plain; charset=x-user-defined");var o=this;i.onreadystatechange=function(t){4===this.readyState&&200===this.status&&(o.progress.show(),e(decodeURIComponent(this.responseText)))},i.send()},createCORSRequest:function(t,e){var i=new XMLHttpRequest;return"withCredentials"in i?i.open(t,e,!0):"undefined"!=typeof XDomainRequest?(i=new XDomainRequest,i.open(t,e)):i=null,i},sendToS3:function(i,r,o){var s=this.uploads3.createCORSRequest("PUT",r);s&&(s.onload=t.proxy(function(){var t;if(this.progress.hide(),200!==s.status)return t={error:!0},void this.upload.callback(t,this.upload.direct,s);var i=r.split("?");if(!i[0])return!1;if(this.upload.direct||this.upload.$droparea.removeClass("drag-drop"),t={url:i[0],id:i[0],s3:!0},"file"===this.upload.type){var o=i[0].split("/");t.name=o[o.length-1]}this.upload.callback(t,this.upload.direct,e)},this),s.onerror=function(){},s.upload.onprogress=function(t){},s.setRequestHeader("Content-Type",i.type),s.setRequestHeader("x-amz-acl","public-read"),s.send(o))}}},utils:function(){return{isEmpty:function(e){return e="undefined"==typeof e?this.core.editor().html():e,e=e.replace(/[\u200B-\u200D\uFEFF]/g,""),e=e.replace(/&nbsp;/gi,""),e=e.replace(/<\/?br\s?\/?>/g,""),e=e.replace(/\s/g,""),e=e.replace(/^<p>[^\W\w\D\d]*?<\/p>$/i,""),e=e.replace(/<iframe(.*?[^>])>$/i,"iframe"),e=e.replace(/<source(.*?[^>])>$/i,"source"),e=e.replace(/<[^\/>][^>]*><\/[^>]+>/gi,""),e=e.replace(/<[^\/>][^>]*><\/[^>]+>/gi,""),e=t.trim(e),""===e},isElement:function(t){try{return t instanceof HTMLElement}catch(e){return"object"==typeof t&&1===t.nodeType&&"object"==typeof t.style&&"object"==typeof t.ownerDocument}},strpos:function(t,e,i){var r=t.indexOf(e,i);return r>=0?r:!1},dataURItoBlob:function(t){var e;e=t.split(",")[0].indexOf("base64")>=0?atob(t.split(",")[1]):unescape(t.split(",")[1]);for(var i=t.split(",")[0].split(":")[1].split(";")[0],r=new Uint8Array(e.length),o=0;o<e.length;o++)r[o]=e.charCodeAt(o);return new Blob([r],{type:i})},getOuterHtml:function(e){return t("<div>").append(t(e).eq(0).clone()).html()},cloneAttributes:function(e,i){e=e[0]||e,i=t(i);for(var r=e.attributes,o=r.length;o--;){var s=r[o];i.attr(s.name,s.value)}return i},breakBlockTag:function(){var e=this.selection.block();if(!e)return!1;var i=this.utils.isEmpty(e.innerHTML),r=e.tagName.toLowerCase();if("pre"===r||"li"===r||"td"===r||"th"===r)return!1;if(!i&&this.utils.isStartOfElement(e))return{$block:t(e),$next:t(e).next(),type:"start"};if(!i&&this.utils.isEndOfElement(e))return{$block:t(e),$next:t(e).next(),type:"end"};var o=this.selection.extractEndOfNode(e),s=t("<"+r+" />").append(o);return s=this.utils.cloneAttributes(e,s),t(e).after(s),{$block:t(e),$next:s,type:"break"}},inBlocks:function(e){e=t.isArray(e)?e:[e];for(var i=this.selection.blocks(),r=i.length,o=!1,s=0;r>s;s++)if(i[s]!==!1){var n=i[s].tagName.toLowerCase();-1!==t.inArray(n,e)&&(o=!0)}return o},inInlines:function(e){e=t.isArray(e)?e:[e];for(var i=this.selection.inlines(),r=i.length,o=!1,s=0;r>s;s++){var n=i[s].tagName.toLowerCase();-1!==t.inArray(n,e)&&(o=!0)}return o},isTag:function(e,i){var r=t(e).closest(i,this.core.editor()[0]);return 1===r.length?r[0]:!1},isBlock:function(t){return null===t?!1:(t=t[0]||t,t&&this.utils.isBlockTag(t.tagName))},isBlockTag:function(t){return"undefined"==typeof t?!1:this.reIsBlock.test(t)},isInline:function(t){return t=t[0]||t,t&&this.utils.isInlineTag(t.tagName)},isInlineTag:function(t){return"undefined"==typeof t?!1:this.reIsInline.test(t)},isRedactorParent:function(e){return e?0===t(e).parents(".redactor-in").length||t(e).hasClass("redactor-in")?!1:e:!1},isCurrentOrParentHeader:function(){return this.utils.isCurrentOrParent(["H1","H2","H3","H4","H5","H6"])},isCurrentOrParent:function(e){var i=this.selection.parent(),r=this.selection.current();if(t.isArray(e)){var o=0;return t.each(e,t.proxy(function(t,e){this.utils.isCurrentOrParentOne(r,i,e)&&o++},this)),0!==o}return this.utils.isCurrentOrParentOne(r,i,e)},isCurrentOrParentOne:function(t,e,i){return i=i.toUpperCase(),e&&e.tagName===i?e:t&&t.tagName===i?t:!1},isEditorRelative:function(){var e=this.core.editor().css("position"),i=["absolute","fixed","relative"];return-1!==t.inArray(i,e)},setEditorRelative:function(){this.core.editor().addClass("redactor-relative")},getScrollTarget:function(){var e=t(this.opts.scrollTarget);return 0!==e.length?e:t(document)},freezeScroll:function(){this.freezeScrollTop=this.utils.getScrollTarget().scrollTop(),this.utils.getScrollTarget().scrollTop(this.freezeScrollTop)},unfreezeScroll:function(){"undefined"!=typeof this.freezeScrollTop&&this.utils.getScrollTarget().scrollTop(this.freezeScrollTop)},saveScroll:function(){this.tmpScrollTop=this.utils.getScrollTarget().scrollTop()},restoreScroll:function(){"undefined"!=typeof this.tmpScrollTop&&this.utils.getScrollTarget().scrollTop(this.tmpScrollTop)},isStartOfElement:function(t){return"undefined"!=typeof t||(t=this.selection.block())?0===this.offset.get(t):!1},isEndOfElement:function(e){if("undefined"==typeof e&&(e=this.selection.block(),!e))return!1;var i=t.trim(t(e).text()).replace(/[\t\n\r\n]/g,"").replace(/\u200B/g,""),r=this.offset.get(e);return r===i.length},removeEmptyAttr:function(e,i){var r=t(e);return"undefined"==typeof r.attr(i)?!0:""===r.attr(i)?(r.removeAttr(i),!0):!1},replaceToTag:function(e,i){var r;return t(e).replaceWith(function(){r=t("<"+i+" />").append(t(this).contents());for(var e=0;e<this.attributes.length;e++)r.attr(this.attributes[e].name,this.attributes[e].value);return r}),r},isSelectAll:function(){return this.selectAll},enableSelectAll:function(){this.selectAll=!0},disableSelectAll:function(){this.selectAll=!1},disableBodyScroll:function(){var e=t("html"),i=window.innerWidth;if(!i){var r=document.documentElement.getBoundingClientRect();i=r.right-Math.abs(r.left)}var o=document.body.clientWidth<i,s=this.utils.measureScrollbar();e.css("overflow","hidden"),o&&e.css("padding-right",s)},measureScrollbar:function(){var e=t("body"),i=document.createElement("div");i.className="redactor-scrollbar-measure",e.append(i);var r=i.offsetWidth-i.clientWidth;return e[0].removeChild(i),r},enableBodyScroll:function(){t("html").css({overflow:"","padding-right":""}),t("body").remove("redactor-scrollbar-measure")},appendFields:function(e,i){if(!e)return i;if("object"==typeof e)return t.each(e,function(e,r){null!==r&&0===r.toString().indexOf("#")&&(r=t(r).val()),i.append(e,r)}),i;var r=t(e);if(0===r.length)return i;return r.each(function(){i.append(t(this).attr("name"),t(this).val())}),i},appendForms:function(e,i){if(!e)return i;var r=t(e);if(0===r.length)return i;var o=r.serializeArray();return t.each(o,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),
-t&&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()}}}},t(window).on("load.tools.redactor",function(){t('[data-tools="redactor"]').redactor()}),i.prototype.init.prototype=i.prototype}(jQuery),function(t){function e(e,i,r,o){var s={duration:.5,iterate:1,delay:0,prefix:"redactor-",timing:"linear"};this.animation=i,this.slide="slideDown"===this.animation||"slideUp"===this.animation,this.$element=t(e),this.prefixes=["","-moz-","-o-animation-","-webkit-"],this.queue=[],"function"==typeof r?(o=r,this.opts=s):this.opts=t.extend(s,r),this.slide&&this.$element.height(this.$element.height()),this.init(o)}t.fn.redactorAnimation=function(t,i,r){return this.each(function(){new e(this,t,i,r)})},e.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(e){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 i=this.queue.length>1?null:e;this.complete("AnimationEnd",t.proxy(function(){this.$element.hasClass(this.opts.prefix+this.queue[0])&&(this.clean(),this.queue.shift(),this.queue.length&&this.animate(e))},this),i)},set:function(t,e,i,r){for(var o=this.prefixes.length;o--;)this.$element.css(this.prefixes[o]+"animation-duration",t),this.$element.css(this.prefixes[o]+"animation-delay",e),this.$element.css(this.prefixes[o]+"animation-iteration-count",i),this.$element.css(this.prefixes[o]+"animation-timing-function",r)},clean:function(){this.$element.removeClass("redactor-animated"),this.$element.removeClass(this.opts.prefix+this.queue[0]),this.set("","","","")},complete:function(e,i,r){this.$element.one(e.toLowerCase()+" webkit"+e+" o"+e+" MS"+e,t.proxy(function(){"function"==typeof i&&i(),"function"==typeof r&&r(this);var e=["fadeOut","slideUp","zoomOut","slideOutUp","slideOutRight","slideOutLeft"];-1!==t.inArray(this.animation,e)&&this.$element.css("display","none"),this.slide&&this.$element.css("height","")},this))}}}(jQuery);
\ No newline at end of file
+!function(t){"use strict";function e(t,i){return new e.prototype.init(t,i)}Function.prototype.bind||(Function.prototype.bind=function(t){var e=this;return function(){return e.apply(t)}});var i=0;t.fn.redactor=function(i){var r=[],o=Array.prototype.slice.call(arguments,1);return"string"==typeof i?this.each(function(){var e,s=t.data(this,"redactor");if("-1"!==i.search(/\./)?void 0!==s[(e=i.split("."))[0]]&&(e=s[e[0]][e[1]]):e=s[i],void 0!==s&&t.isFunction(e)){var n=e.apply(s,o);void 0!==n&&n!==s&&r.push(n)}else t.error('No such method "'+i+'" for Redactor')}):this.each(function(){t.data(this,"redactor",{}),t.data(this,"redactor",e(this,i))}),0===r.length?this:1===r.length?r[0]:r},t.Redactor=e,t.Redactor.VERSION="2.7",t.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"],t.Redactor.settings={},t.Redactor.opts={animation:!1,lang:"en",direction:"ltr",spellcheck:!0,overrideStyles:!0,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,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:[],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,buffer:[],rebuffer:[],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:t("").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}},e.fn=t.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(e,r){if(this.$element=t(e),this.uuid=i++,this.loadOptions(r),this.loadModules(),this.opts.clickToEdit&&!this.$element.hasClass("redactor-click-to-edit"))return this.loadToEdit(r);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(),t.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(e){this.$element.on("click.redactor-click-to-edit",t.proxy(function(){this.initToEdit(e)},this)),this.$element.addClass("redactor-click-to-edit")},initToEdit:function(e){t.extend(e.callbacks,{startToEdit:function(){this.insert.node(this.marker.get(),!1)},initToEdit:function(){this.selection.restore(),this.clickToCancelStorage=this.code.get(),t(this.opts.clickToCancel).off(".redactor-click-to-edit"),t(this.opts.clickToCancel).show().on("click.redactor-click-to-edit",t.proxy(function(i){i.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="",t(this.opts.clickToCancel).hide(),t(this.opts.clickToSave).hide(),this.$element.on("click.redactor-click-to-edit",t.proxy(function(){this.initToEdit(e)},this)),this.$element.addClass("redactor-click-to-edit")},this)),t(this.opts.clickToSave).off(".redactor-click-to-edit"),t(this.opts.clickToSave).show().on("click.redactor-click-to-edit",t.proxy(function(i){i.preventDefault(),this.core.destroy(),this.core.callback("save",this.code.get()),t(this.opts.clickToCancel).hide(),t(this.opts.clickToSave).hide(),this.$element.on("click.redactor-click-to-edit",t.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(e){var i={};void 0!==t.Redactor.settings.namespace?this.$element.hasClass(t.Redactor.settings.namespace)&&(i=t.Redactor.settings):i=t.Redactor.settings,this.opts=t.extend({},t.Redactor.opts,this.$element.data(),e),this.opts=t.extend(!0,this.opts,i)},getModuleMethods:function(t){return Object.getOwnPropertyNames(t).filter(function(e){return"function"==typeof t[e]})},loadModules:function(){for(var e=t.Redactor.modules.length,i=0;i<e;i++)this.bindModuleMethods(t.Redactor.modules[i])},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(){this.opts.air&&this.selection.get().collapseToStart()},collapsedEnd:function(){this.opts.air&&this.selection.get().collapseToEnd()},build:function(){this.detect.isMobile()||(this.button.hideButtons(),this.button.hideButtonsOnMobile(),0!==this.opts.buttons.length&&(this.$air=this.air.createContainer(),!1!==this.opts.airWidth&&this.$air.css("width",this.opts.airWidth),this.air.append(),this.button.$toolbar=this.$air,this.button.setFormatting(),this.button.load(this.$air),this.core.editor().on("mouseup.redactor",this,t.proxy(function(t){""!==this.selection.text()&&this.air.show(t)},this))))},append:function(){this.$air.appendTo("body")},createContainer:function(){return t("<ul>").addClass("redactor-air").attr({id:"redactor-air-"+this.uuid,role:"toolbar"}).hide()},show:function(e){this.selection.saveInstant(),t(".redactor-air").hide();var i=0,r=this.$air.innerWidth();t(window).width()<e.clientX+r&&(i=200),this.$air.css({left:e.clientX-i+"px",top:e.clientY+10+t(document).scrollTop()+"px"}).show(),this.air.enabled=!0,this.air.bindHide()},bindHide:function(){t(document).on("mousedown.redactor-air."+this.uuid,t.proxy(function(e){var i=t(e.target).closest(".redactor-dropdown").length;0===t(e.target).closest(this.$air).length&&0===i&&!1!==this.air.hide(e)&&this.marker.remove()},this)).on("keydown.redactor-air."+this.uuid,t.proxy(function(e){var i=e.which;if((this.utils.isRedactorParent(e.target)||t(e.target).hasClass("redactor-in"))&&0===t(e.target).closest("#redactor-modal").length){if(i===this.keyCode.ESC)this.selection.get().collapseToStart();else if(i===this.keyCode.BACKSPACE||i===this.keyCode.DELETE){var r=this.selection.get();this.selection.range(r).deleteContents()}else i===this.keyCode.ENTER&&this.selection.get().collapseToEnd();this.air.enabled?this.air.hide(e):this.selection.get().collapseToStart()}},this))},hide:function(e){if(e.ctrlKey||e.metaKey||e.shiftKey&&e.altKey)return!1;this.button.setInactiveAll(),this.$air.fadeOut(100),this.air.enabled=!1,t(document).off("mousedown.redactor-air."+this.uuid),t(document).off("keydown.redactor-air."+this.uuid)}}},autosave:function(){return{enabled:!1,html:!1,init:function(){this.opts.autosave&&(this.autosave.enabled=!0,this.autosave.name=this.opts.autosaveName?this.opts.autosaveName:this.$textarea.attr("name"))},is:function(){return this.autosave.enabled},send:function(){if(this.opts.autosave&&(this.autosave.source=this.code.get(),this.autosave.html!==this.autosave.source)){var e={};e.name=this.autosave.name,e[this.autosave.name]=this.autosave.source,e=this.autosave.getHiddenFields(e),t.ajax({url:this.opts.autosave,type:"post",data:e}).done(this.autosave.success)}},getHiddenFields:function(e){return!1===this.opts.autosaveFields||"object"!=typeof this.opts.autosaveFields?e:(t.each(this.opts.autosaveFields,t.proxy(function(i,r){null!==r&&0===r.toString().indexOf("#")&&(r=t(r).val()),e[i]=r},this)),e)},success:function(t){var e;try{e=JSON.parse(t)}catch(i){e=t}var i=void 0===e.error?"autosave":"autosaveError";this.core.callback(i,this.autosave.name,e),this.autosave.html=this.autosave.source},disable:function(){this.autosave.enabled=!1,clearInterval(this.autosaveTimeout)}}},block:function(){return{format:function(e,i,r,o){if(e="quote"===e?"blockquote":e,this.block.tags=["p","blockquote","pre","h1","h2","h3","h4","h5","h6","div","figure"],-1!==t.inArray(e,this.block.tags))return"p"===e&&void 0===i&&(i="class"),this.placeholder.hide(),this.buffer.set(),this.utils.isCollapsed()?this.block.formatCollapsed(e,i,r,o):this.block.formatUncollapsed(e,i,r,o)},formatCollapsed:function(e,i,r,o){this.selection.save();var s=this.selection.block(),n=s.tagName.toLowerCase();if(-1!==t.inArray(n,this.block.tags)){var a=!1;n===e&&void 0===i&&(e="p",a=!0),a&&(this.block.removeAllClass(),this.block.removeAllAttr());var l;if("blockquote"===n&&this.utils.isEndOfElement(s)){this.marker.remove(),(l=document.createElement("p")).innerHTML=this.opts.invisibleSpace,t(s).after(l),this.caret.start(l);var c=t(s).children().last();0!==c.length&&"BR"===c[0].tagName&&c.remove()}else l=this.utils.replaceToTag(s,e);if("object"==typeof i){o=r;for(var d in i)l=this.block.setAttr(l,d,i[d],o)}else l=this.block.setAttr(l,i,r,o);return"pre"===e&&1===l.length&&t(l).html(t.trim(t(l).html())),this.selection.restore(),this.block.removeInlineTags(l),l}this.selection.restore()},formatUncollapsed:function(e,i,r,o){this.selection.save();var s=[],n=this.selection.blocks();n[0]&&(t(n[0]).hasClass("redactor-in")||t(n[0]).hasClass("redactor-box"))&&(n=this.core.editor().find(this.opts.blockTags.join(", ")));for(var a=n.length,l=0;l<a;l++){var c=n[l].tagName.toLowerCase();if(-1!==t.inArray(c,this.block.tags)&&"figure"!==c){var d=this.utils.replaceToTag(n[l],e);if("object"==typeof i){o=r;for(var h in i)d=this.block.setAttr(d,h,i[h],o)}else d=this.block.setAttr(d,i,r,o);s.push(d),this.block.removeInlineTags(d)}}if(this.selection.restore(),"pre"===e&&0!==s.length){var u=s[0];t.each(s,function(e,i){0!==e&&(t(u).append("\n"+t.trim(i.html())),t(i).remove())}),(s=[]).push(u)}return s},removeInlineTags:function(e){e=e[0]||e;var i=this.opts.inlineTags,r=["PRE","H1","H2","H3","H4","H5","H6"];if(-1!==t.inArray(e.tagName,r)){if("PRE"!==e.tagName){var o=i.indexOf("a");i.splice(o,1)}t(e).find(i.join(",")).not(".redactor-selection-marker").contents().unwrap()}},setAttr:function(t,e,i,r){if(void 0===e)return t;var o=void 0===r?"replace":r;return t="class"===e?this.block[o+"Class"](i,t):"remove"===o?this.block[o+"Attr"](e,t):"removeAll"===o?this.block[o+"Attr"](e,t):this.block[o+"Attr"](e,i,t)},getBlocks:function(t){return void 0===t?this.selection.blocks():t},replaceClass:function(e,i){return t(this.block.getBlocks(i)).removeAttr("class").addClass(e)[0]},toggleClass:function(e,i){return t(this.block.getBlocks(i)).toggleClass(e)[0]},addClass:function(e,i){return t(this.block.getBlocks(i)).addClass(e)[0]},removeClass:function(e,i){return t(this.block.getBlocks(i)).removeClass(e)[0]},removeAllClass:function(e){return t(this.block.getBlocks(e)).removeAttr("class")[0]},replaceAttr:function(e,i,r){return r=this.block.removeAttr(e,r),t(r).attr(e,i)[0]},toggleAttr:function(e,i,r){r=this.block.getBlocks(r);var o=this,s=[];return t.each(r,function(r,n){t(n).attr(e)?s.push(o.block.removeAttr(e,n)):s.push(o.block.addAttr(e,i,n))}),s},addAttr:function(e,i,r){return t(this.block.getBlocks(r)).attr(e,i)[0]},removeAttr:function(e,i){return t(this.block.getBlocks(i)).removeAttr(e)[0]},removeAllAttr:function(e){e=this.block.getBlocks(e);var i=[];return t.each(e,function(e,r){void 0===r.attributes&&i.push(r);for(var o=t(r),s=r.attributes.length,n=0;n<s;n++)o.removeAttr(r.attributes[n].name);i.push(o[0])}),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.opts.buffer[this.opts.buffer.length-1],i=this.core.editor().html();(void 0===e||e[0]!==i)&&this.opts.buffer.push([i,t])},setRedo:function(){var t=this.selection.saveInstant();this.opts.rebuffer.push([this.core.editor().html(),t])},add:function(){this.opts.buffer.push([this.core.editor().html(),0])},undo:function(){if(0!==this.opts.buffer.length){var t=this.opts.buffer.pop();this.buffer.set("redo"),this.core.editor().html(t[0]),this.selection.restoreInstant(t[1]),this.observe.load()}},redo:function(){if(0!==this.opts.rebuffer.length){var t=this.opts.rebuffer.pop();this.buffer.set("undo"),this.core.editor().html(t[0]),this.selection.restoreInstant(t[1]),this.observe.load()}},clear:function(){this.opts.rebuffer=[]}}},build:function(){return{start:function(){"inline"===this.opts.type?this.opts.type="inline":"div"===this.opts.type?""===t.trim(this.$editor.html())&&this.$editor.html(this.opts.emptyHtml):"textarea"===this.opts.type&&this.build.startTextarea(),this.build.setIn(),this.build.setId(),this.build.enableEditor(),this.build.setOptions(),this.build.callEditor()},createContainerBox:function(){this.$box=t('<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},loadFromTextarea:function(){this.$editor=t("<div />"),this.$textarea=this.$element,this.$element.attr("name",this.build.getName()),this.$box.insertAfter(this.$element).append(this.$editor).append(this.$element),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>"),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.opts.air=!1,this.opts.linkify=!1),this.core.editor().attr("spellcheck",this.opts.spellcheck),this.opts.structure&&this.core.editor().addClass("redactor-structure"),"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.opts.toolbar||this.opts.air)&&(this.toolbarsButtons=this.button.init()),this.opts.air?this.air.build():this.opts.toolbar&&this.toolbar.build(),this.detect.isMobile()&&this.opts.toolbarMobile&&this.opts.air&&(this.opts.toolbar=!0,this.toolbar.build()),(this.opts.air||this.opts.toolbar)&&(this.core.editor().on("mouseup.redactor-observe."+this.uuid+" keyup.redactor-observe."+this.uuid+" focus.redactor-observe."+this.uuid+" touchstart.redactor-observe."+this.uuid,t.proxy(this.observe.toolbar,this)),this.core.element().on("blur.callback.redactor",t.proxy(function(){this.button.setInactiveAll()},this))),this.modal.templates(),this.build.plugins(),this.autosave.init(),this.code.html=this.code.cleaned(this.core.editor().html()),this.core.callback("init"),this.core.callback("initToEdit"),this.storage.observe(),this.start=!1},setHelpers:function(){this.opts.linkify&&this.linkify.format(),this.placeholder.init(),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&&t.each(this.opts.plugins,t.proxy(function(i,r){var o="undefined"!=typeof RedactorPlugins&&void 0!==RedactorPlugins[r]?RedactorPlugins:e.fn;if(t.isFunction(o[r])){this[r]=o[r]();for(var s=this.getModuleMethods(this[r]),n=s.length,a=0;a<n;a++)this[r][s[a]]=this[r][s[a]].bind(this);if(void 0!==this[r].langs){var l={};void 0!==this[r].langs[this.opts.lang]?l=this[r].langs[this.opts.lang]:void 0===this[r].langs[this.opts.lang]&&void 0!==this[r].langs.en&&(l=this[r].langs.en);var c=this;t.each(l,function(t,e){void 0===c.opts.curLang[t]&&(c.opts.curLang[t]=e)})}t.isFunction(this[r].init)&&this[r].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(){t.each(this.toolbarsButtons.format.dropdown,t.proxy(function(e,i){-1===t.inArray(e,this.opts.formatting)&&delete this.toolbarsButtons.format.dropdown[e]},this))},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(e){t.each(e,t.proxy(function(t,e){var i=this.opts.buttons.indexOf(e);-1!==i&&this.opts.buttons.splice(i,1)},this))},load:function(e){this.button.buttons=[],t.each(this.opts.buttons,t.proxy(function(i,r){!this.toolbarsButtons[r]||"file"===r&&!this.file.is()||"image"===r&&!this.image.is()||e.append(t("<li>").append(this.button.build(r,this.toolbarsButtons[r])))},this))},buildButtonTooltip:function(e,i){if(!this.opts.air&&!this.detect.isMobile()){var r=t("<span>");r.addClass("re-button-tooltip"),r.html(i),e.append(r),e.on("mouseover",function(){t(this).hasClass("redactor-button-disabled")||(r.show(),r.css("margin-left",-r.innerWidth()/2))}).on("mouseout",function(){r.hide()})}},build:function(e,i){if(!1!==this.opts.toolbar){var r=void 0!==i.label?i.label:i.title,o=t('<a href="javascript:void(null);" alt="'+r+'" rel="'+e+'" />');if(o.addClass("re-button re-"+e),o.attr({role:"button","aria-label":r,tabindex:"-1"}),void 0===i.icon||this.opts.buttonsTextLabeled)o.html(i.title);else{var s=t("<i>");s.addClass("re-icon-"+e),o.append(s),o.addClass("re-button-icon"),this.button.buildButtonTooltip(o,r)}if((i.func||i.command||i.dropdown)&&this.button.setEvent(o,e,i),i.dropdown){o.addClass("redactor-toolbar-link-dropdown").attr("aria-haspopup",!0);var n=t('<ul class="redactor-dropdown redactor-dropdown-'+this.uuid+" redactor-dropdown-box-"+e+'" style="display: none;">');o.data("dropdown",n),this.dropdown.build(e,n,i.dropdown)}return this.button.buttons.push(o),o}},getButtons:function(){return this.button.toolbar().find("a.re-button")},getButtonsKeys:function(){return this.button.buttons},setEvent:function(e,i,r){e.on("mousedown",t.proxy(function(t){if(t.preventDefault(),e.hasClass("redactor-button-disabled"))return!1;var o="func",s=r.func;return r.command?(o="command",s=r.command):r.dropdown&&(o="dropdown",s=!1),this.button.toggle(t,i,o,s),!1},this))},toggle:function(t,e,i,r,o){!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,o),"dropdown"!==i&&this.dropdown.hideAll(!1),this.opts.air&&"dropdown"!==i&&this.air.hide(t),!this.detect.isIe()&&this.detect.isDesktop()||this.utils.unfreezeScroll()},clickCallback:function(e,i,r,o){var s;if(o=void 0===o?r:o,t.isFunction(i))i.call(this,r);else if("-1"!==i.search(/\./)){if(s=i.split("."),void 0===this[s[0]])return;"object"==typeof o?this[s[0]][s[1]].apply(this,o):this[s[0]][s[1]].call(this,o)}else"object"==typeof o?this[i].apply(this,o):this[i].call(this,o);this.observe.buttons(e,r)},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(e,i){if(!0!==this.button.isAdded(e))return t();var r=this.button.build(e,{title:i});return this.button.toolbar().append(t("<li>").append(r)),r},addFirst:function(e,i){if(!0!==this.button.isAdded(e))return t();var r=this.button.build(e,{title:i});return this.button.toolbar().prepend(t("<li>").append(r)),r},addAfter:function(e,i,r){if(!0!==this.button.isAdded(i))return t();var o=this.button.build(i,{title:r}),s=this.button.get(e);return 0!==s.length?s.parent().after(t("<li>").append(o)):this.button.toolbar().append(t("<li>").append(o)),o},addBefore:function(e,i,r){if(!0!==this.button.isAdded(i))return t();var o=this.button.build(i,{title:r}),s=this.button.get(e);return 0!==s.length?s.parent().before(t("<li>").append(o)):this.button.toolbar().append(t("<li>").append(o)),o},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"),this.button.buildButtonTooltip(t,t.attr("alt")))},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){if(void 0!==e&&!1!==this.opts.toolbar){var r="dropdown"===i?"dropdown":"func",o=e.attr("rel");e.on("mousedown",t.proxy(function(t){if(e.hasClass("redactor-button-disabled"))return!1;this.button.toggle(t,o,r,i)},this))}},addDropdown:function(e,i){if(!1!==this.opts.toolbar){e.addClass("redactor-toolbar-link-dropdown").attr("aria-haspopup",!0);var r=e.attr("rel");this.button.addCallback(e,"dropdown");var o=t('<div class="redactor-dropdown redactor-dropdown-'+this.uuid+" redactor-dropdown-box-"+r+'" style="display: none;">');return e.data("dropdown",o),i&&this.dropdown.build(r,o,i),o}},setActive:function(t){this.button.get(t).addClass("redactor-act")},setInactive:function(t){this.button.get(t).removeClass("redactor-act")},setInactiveAll:function(t){var e=this.button.toolbar().find("a.re-button");void 0!==t&&(e=e.not(".re-"+t)),e.removeClass("redactor-act")},disable:function(t){this.button.get(t).addClass("redactor-button-disabled")},enable:function(t){this.button.get(t).removeClass("redactor-button-disabled")},disableAll:function(t){var e=this.button.toolbar().find("a.re-button");void 0!==t&&(e=e.not(".re-"+t)),e.addClass("redactor-button-disabled")},enableAll:function(){this.button.toolbar().find("a.re-button").removeClass("redactor-button-disabled")},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 o=this.selection.get(),s=this.selection.range(o);try{s.setStart(t,0),s.setEnd(e,i)}catch(t){}this.selection.update(o,s)},prepare:function(t){return this.detect.isFirefox()&&void 0!==this.start&&this.core.editor().focus(),t[0]||t},start:function(e){var i,r;if(e=this.caret.prepare(e)){if("BR"===e.tagName)return this.caret.before(e);var o=t(e).children().first(),s=this.utils.isInlineTag(e.tagName);""===e.innerHTML||s?this.caret.setStartEmptyOrInline(e,s):o&&0!==o.length&&this.utils.isInlineTag(o[0].tagName)&&""===o.text()?this.caret.setStartEmptyOrInline(o[0],!0):((i=window.getSelection()).removeAllRanges(),(r=document.createRange()).selectNodeContents(e),r.collapse(!0),i.addRange(r))}},setStartEmptyOrInline:function(e,i){var r=window.getSelection(),o=document.createRange(),s=document.createTextNode("​");o.setStart(e,0),o.insertNode(s),o.setStartAfter(s),o.collapse(!0),r.removeAllRanges(),r.addRange(o),i||this.core.editor().on("keydown.redactor-remove-textnode",function(){t(s).remove(),t(this).off("keydown.redactor-remove-textnode")})},end:function(e){var i,r;if(e=this.caret.prepare(e)){if("BR"!==e.tagName&&""===e.innerHTML)return this.caret.start(e);if("BR"===e.tagName){var o=document.createElement("span");return o.className="redactor-invisible-space",o.innerHTML="&#x200b;",t(e).after(o),(i=window.getSelection()).removeAllRanges(),(r=document.createRange()).setStartBefore(o),r.setEndBefore(o),i.addRange(r),void t(o).replaceWith(function(){return t(this).contents()})}if(e.lastChild&&1===e.lastChild.nodeType)return this.caret.after(e.lastChild);if((i=window.getSelection()).getRangeAt||i.rangeCount)try{(r=i.getRangeAt(0)).selectNodeContents(e),r.collapse(!1),i.removeAllRanges(),i.addRange(r)}catch(t){}}},after:function(e){var i,r;if(e=this.caret.prepare(e)){if("BR"===e.tagName)return this.caret.end(e);if(this.utils.isBlockTag(e.tagName)){var o=this.caret.next(e);void 0===o?this.caret.end(e):("TABLE"===o.tagName?o=t(o).find("th, td").first()[0]:"UL"!==o.tagName&&"OL"!==o.tagName||(o=t(o).find("li").first()[0]),this.caret.start(o))}else{var s=document.createTextNode("​");(i=window.getSelection()).removeAllRanges(),(r=document.createRange()).setStartAfter(e),r.insertNode(s),r.setStartAfter(s),r.collapse(!0),i.addRange(r)}}},before:function(e){var i,r;if(e=this.caret.prepare(e))if(this.utils.isBlockTag(e.tagName)){var o=this.caret.prev(e);void 0===o?this.caret.start(e):("TABLE"===o.tagName?o=t(o).find("th, td").last()[0]:"UL"!==o.tagName&&"OL"!==o.tagName||(o=t(o).find("li").last()[0]),this.caret.end(o))}else(i=window.getSelection()).removeAllRanges(),(r=document.createRange()).setStartBefore(e),r.collapse(!0),i.addRange(r)},next:function(e){var i=t(e).next();return i.hasClass("redactor-script-tag, redactor-selection-marker")?i.next()[0]:i[0]},prev:function(e){var i=t(e).prev();return i.hasClass("redactor-script-tag, redactor-selection-marker")?i.prev()[0]:i[0]},offset:function(t){return this.offset.get(t)}}},clean:function(){return{onSet:function(e){e=this.clean.savePreCode(e),e=this.clean.saveFormTags(e),this.opts.script&&(e=e.replace(/<script(.*?[^>]?)>([\w\W]*?)<\/script>/gi,'<pre class="redactor-script-tag" $1>$2</pre>')),e=(e=(e=(e=(e=e.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 i=this,r=t("<div/>").html(t.parseHTML(e,document,!0)),o=this.opts.replaceTags;if(o){var s=Object.keys(this.opts.replaceTags);r.find(s.join(",")).each(function(t,e){i.utils.replaceToTag(e,o[e.tagName.toLowerCase()])})}r.find("span, a").attr("data-redactor-span",!0),r.find(this.opts.inlineTags.join(",")).each(function(){var e=t(this);e.attr("style")&&e.attr("data-redactor-style-cache",e.attr("style"))}),e=r.html();var n=["font","html","head","link","body","meta","applet"];return this.opts.script||n.push("script"),e=this.clean.stripTags(e,n),this.opts.removeComments&&(e=e.replace(/<!--[\s\S]*?-->/gi,"")),e=this.paragraphize.load(e),e=e.replace("###marker1###",'<span id="selection-marker-1" class="redactor-selection-marker">​</span>'),e=e.replace("###marker2###",'<span id="selection-marker-2" class="redactor-selection-marker">​</span>'),-1!==e.search(/^(||\s||<br\s?\/?>||&nbsp;)$/i)?this.opts.emptyHtml:e},onGet:function(t){return this.clean.onSync(t)},onSync:function(e){if(e=e.replace(/\u200B/g,""),-1!==(e=e.replace(/&#x200b;/gi,"")).search(/^<p>(||\s||<br\s?\/?>||&nbsp;)<\/p>$/i))return"";e=e.replace(/<span(.*?)id="redactor-image-box"(.*?[^>])>([\w\W]*?)<img(.*?)><\/span>/gi,"$3<img$4>"),e=e.replace(/<span(.*?)id="redactor-image-resizer"(.*?[^>])>(.*?)<\/span>/gi,""),e=e.replace(/<span(.*?)id="redactor-image-editter"(.*?[^>])>(.*?)<\/span>/gi,""),e=e.replace(/<img(.*?)style="(.*?)opacity: 0\.5;(.*?)"(.*?)>/gi,'<img$1style="$2$3"$4>');var i=t("<div/>").html(t.parseHTML(e,document,!0));i.find('*[style=""]').removeAttr("style"),i.find('*[class=""]').removeAttr("class"),i.find('*[rel=""]').removeAttr("rel"),i.find('*[data-image=""]').removeAttr("data-image"),i.find('*[alt=""]').removeAttr("alt"),i.find('*[title=""]').removeAttr("title"),i.find("*[data-redactor-style-cache]").removeAttr("data-redactor-style-cache"),i.find(".redactor-invisible-space, .redactor-unlink").each(function(){t(this).contents().unwrap()}),i.find("span, a").removeAttr("data-redactor-span data-redactor-style-cache").each(function(){0===this.attributes.length&&t(this).contents().unwrap()}),i.find("img").removeAttr("rel"),i.find(".redactor-selection-marker, #redactor-insert-marker").remove(),e=i.html(),this.opts.script&&(e=e.replace(/<pre class="redactor-script-tag"(.*?[^>]?)>([\w\W]*?)<\/pre>/gi,"<script$1>$2<\/script>")),e=this.clean.restoreFormTags(e),e=e.replace(new RegExp("<br\\s?/?></h","gi"),"</h"),e=e.replace(new RegExp("<br\\s?/?></li>","gi"),"</li>"),e=e.replace(new RegExp("</li><br\\s?/?>","gi"),"</li>"),e=e.replace(/<pre>/gi,"<pre>\n"),this.opts.preClass&&(e=e.replace(/<pre>/gi,'<pre class="'+this.opts.preClass+'">')),this.opts.linkNofollow&&(e=e.replace(/<a(.*?)rel="nofollow"(.*?[^>])>/gi,"<a$1$2>"),e=e.replace(/<a(.*?[^>])>/gi,'<a$1 rel="nofollow">'));var r={"™":"&trade;","©":"&copy;","…":"&hellip;","—":"&mdash;","‐":"&dash;"};return t.each(r,function(t,i){e=e.replace(new RegExp(t,"g"),i)}),e=e.replace(/&amp;/g,"&"),e=e.replace(/\n{2,}/g,"\n"),this.opts.removeNewlines&&(e=e.replace(/\r?\n/g,"")),e},onPaste:function(e,i,r){return!0!==r&&(e=(e=(e=(e=(e=(e=(e=(e=(e=e.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(e)&&(e=this.clean.cleanMsWord(e))),e=t.trim(e),i.pre?this.opts.preSpaces&&(e=e.replace(/\t/g,new Array(this.opts.preSpaces+1).join(" "))):(e=this.clean.replaceBrToNl(e),e=this.clean.removeTagsInsidePre(e)),!0!==r&&(e=this.clean.removeEmptyInlineTags(e),!1===i.encode&&(e=e.replace(/&/g,"&amp;"),e=this.clean.convertTags(e,i),e=this.clean.getPlainText(e),e=this.clean.reconvertTags(e,i))),i.text&&(e=this.clean.replaceNbspToSpaces(e),e=this.clean.getPlainText(e)),i.lists&&(e=e.replace("\n","<br>")),i.encode&&(e=this.clean.encodeHtml(e)),i.paragraphize&&(e=(e=e.replace(/ \n/g," ")).replace(/\n /g," "),e=(e=this.paragraphize.load(e)).replace(/<p><\/p>/g,"")),e},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(e){var i=this.opts.inlineTags,r=t("<div/>").html(t.parseHTML(e,document,!0)),o=this,s=r.find("span"),n=r.find(i.join(","));return n.removeAttr("style"),n.each(function(){var e=t(this).html();0===this.attributes.length&&o.utils.isEmpty(e)&&t(this).replaceWith(function(){return t(this).contents()})}),s.each(function(){t(this).html();0===this.attributes.length&&t(this).replaceWith(function(){return t(this).contents()})}),e=r.html(),e=e.replace("\x3c!--?php","<?php"),e=e.replace("\x3c!--?","<?"),e=e.replace("?--\x3e","?>"),r.remove(),e},cleanMsWord:function(e){e=(e=(e=(e=e.replace(/<!--[\s\S]*?-->/g,"")).replace(/<o:p>[\s\S]*?<\/o:p>/gi,"")).replace(/\n/g," ")).replace(/<br\s?\/?>|<\/p>|<\/div>|<\/li>|<\/td>/gi,"\n\n");var i=t("<div/>").html(e),r=!1,o=1,s=[];return i.find("p[style]").each(function(){var e=t(this).attr("style").match(/mso\-list\:l([0-9]+)\slevel([0-9]+)/);if(e){var n=parseInt(e[1]),a=parseInt(e[2]),l=t(this).html().match(/^[\w]+\./)?"ol":"ul",c=t("<li/>").html(t(this).html());if(c.html(c.html().replace(/^([\w\.]+)</,"<")),c.find("span:first").remove(),1==a&&-1==t.inArray(n,s)){var d=t("<"+l+"/>").attr({"data-level":a,"data-list":n}).html(c);t(this).replaceWith(d),r=n,s.push(n)}else{if(a>o){for(var h=p=i.find('[data-level="'+o+'"][data-list="'+r+'"]'),u=o;u<a;u++)(d=t("<"+l+"/>")).appendTo(h.find("li").last()),h=d;h.attr({"data-level":a,"data-list":n}).html(c)}else{var p=i.find('[data-level="'+a+'"][data-list="'+n+'"]').last();p.append(c)}o=a,r=n,t(this).remove()}}}),i.find("[data-level][data-list]").removeAttr("data-level data-list"),e=i.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(e,i){var r=t("<div>").html(e);r.find("iframe").remove();var o=r.find("a");if(o.removeAttr("style"),!1!==this.opts.pasteLinkTarget&&o.attr("target",this.opts.pasteLinkTarget),i.links&&this.opts.pasteLinks&&r.find("a").each(function(t,e){if(e.href){for(var i,r='##%a href="'+e.href+'"',o=0,s=e.attributes.length;o<s;o++)"href"!==(i=e.attributes.item(o)).name&&(r+=" "+i.name+'="'+i.value+'"');e.outerHTML=r+"%##"+e.innerHTML+"##%/a%##"}}),e=r.html(),i.images&&this.opts.pasteImages&&(e=e.replace(/<img(.*?)src="(.*?)"(.*?[^>])>/gi,'##%img$1src="$2"$3%##')),this.opts.pastePlainText)return e;for(var s,n=i.lists?["ul","ol","li"]:this.opts.pasteBlockTags,a=(s=i.block||i.lists?i.inline?n.concat(this.opts.pasteInlineTags):n:i.inline?this.opts.pasteInlineTags:[]).length,l=0;l<a;l++)e=e.replace(new RegExp("</"+s[l]+">","gi"),"###/"+s[l]+"###"),e="td"===s[l]||"th"===s[l]?e.replace(new RegExp("<"+s[l]+'(.*?[^>])((colspan|rowspan)="(.*?[^>])")?(.*?[^>])>',"gi"),"###"+s[l]+" $2###"):this.utils.isInlineTag(s[l])?(e=(e=e.replace(new RegExp("<"+s[l]+'([^>]*)class="([^>]*)"[^>]*>',"gi"),"###"+s[l]+' class="$2"###')).replace(new RegExp("<"+s[l]+'([^>]*)data-redactor-style-cache="([^>]*)"[^>]*>',"gi"),"###"+s[l]+' cache="$2"###')).replace(new RegExp("<"+s[l]+"[^>]*>","gi"),"###"+s[l]+"###"):e.replace(new RegExp("<"+s[l]+"[^>]*>","gi"),"###"+s[l]+"###");return e},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,r=e.lists?["ul","ol","li"]:this.opts.pasteBlockTags,o=(i=e.block||e.lists?e.inline?r.concat(this.opts.pasteInlineTags):r:e.inline?this.opts.pasteInlineTags:[]).length,s=0;s<o;s++)t=t.replace(new RegExp("###/"+i[s]+"###","gi"),"</"+i[s]+">");for(s=0;s<o;s++)t=t.replace(new RegExp("###"+i[s]+"###","gi"),"<"+i[s]+">");for(s=0;s<o;s++)if("td"===i[s]||"th"===i[s])t=t.replace(new RegExp("###"+i[s]+"s?(.*?[^#])###","gi"),"<"+i[s]+"$1>");else if(this.utils.isInlineTag(i[s])){var n="span"===i[s]?' data-redactor-span="true"':"";t=(t=t.replace(new RegExp("###"+i[s]+' cache="(.*?[^#])"###',"gi"),"<"+i[s]+' style="$1"'+n+' data-redactor-style-cache="$1">')).replace(new RegExp("###"+i[s]+"s?(.*?[^#])###","gi"),"<"+i[s]+"$1>")}return t},cleanPre:function(e){e=void 0===e?t(this.selection.block()).closest("pre",this.core.editor()[0]):e,t(e).find("br").replaceWith(function(){return document.createTextNode("\n")}),t(e).find("p").replaceWith(function(){return t(this).contents()})},removeTagsInsidePre:function(e){var i=t("<div />").append(e);return i.find("pre").replaceWith(function(){var e=t(this).html();return e=e.replace(/<br\s?\/?>|<\/p>|<\/div>|<\/li>|<\/td>/gi,"\n"),e=e.replace(/(<([^>]+)>)/gi,""),t("<pre />").append(e)}),e=i.html(),i.remove(),e},getPlainText:function(e){e=(e=(e=(e=(e=(e=e.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 i=document.createElement("div");return i.innerHTML=e,e=i.textContent||i.innerText,t.trim(e)},savePreCode:function(t){return t=this.clean.savePreFormatting(t),t=this.clean.saveCodeFormatting(t),t=this.clean.restoreSelectionMarkers(t)},savePreFormatting:function(e){var i=e.match(/<pre(.*?)>([\w\W]*?)<\/pre>/gi);return null===i?e:(t.each(i,t.proxy(function(t,i){var r,o,s,n=[],a=!1;i.match(/<pre(.*?)>(([\n\r\s]+)?)<code(.*?)>/i)?(a=!0,r=(n=i.match(/<pre(.*?)>(([\n\r\s]+)?)<code(.*?)>([\w\W]*?)<\/code>(([\n\r\s]+)?)<\/pre>/i))[5],o=n[1],s=n[4]):(r=(n=i.match(/<pre(.*?)>([\w\W]*?)<\/pre>/i))[2],o=n[1]),r=(r=r.replace(/<br\s?\/?>/g,"\n")).replace(/&nbsp;/g," "),this.opts.preSpaces&&(r=r.replace(/\t/g,new Array(this.opts.preSpaces+1).join(" "))),r=(r=this.clean.encodeEntities(r)).replace(/\$/g,"&#36;"),e=a?e.replace(i,"<pre"+o+"><code"+s+">"+r+"</code></pre>"):e.replace(i,"<pre"+o+">"+r+"</pre>")},this)),e)},saveCodeFormatting:function(e){var i=e.match(/<code(.*?)>([\w\W]*?)<\/code>/gi);return null===i?e:(t.each(i,t.proxy(function(t,i){var r=i.match(/<code(.*?)>([\w\W]*?)<\/code>/i);r[2]=r[2].replace(/&nbsp;/g," "),r[2]=this.clean.encodeEntities(r[2]),r[2]=r[2].replace(/\$/g,"&#36;"),e=e.replace(i,"<code"+r[1]+">"+r[2]+"</code>")},this)),e)},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.replace(/<form(.*?)>([\w\W]*?)<\/form>/gi,'<section$1 rel="redactor-form-tag">$2</section>')},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.replace(/”/g,'"'),t=t.replace(/“/g,'"'),t=t.replace(/‘/g,"'"),t=t.replace(/’/g,"'"),t=this.clean.encodeEntities(t)},encodeEntities:function(t){return t=String(t).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"'),t=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},stripTags:function(t,e){if(void 0===e)return t.replace(/(<([^>]+)>)/gi,"");var i=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;return t.replace(i,function(t,i){return-1===e.indexOf(i.toLowerCase())?t:""})},removeMarkers:function(t){return t.replace(/<span(.*?[^>]?)class="redactor-selection-marker"(.*?[^>]?)>([\w\W]*?)<\/span>/gi,"")},removeSpaces:function(e){return e=t.trim(e),e=e.replace(/\n/g,""),e=e.replace(/[\t]*/g,""),e=e.replace(/\n\s*\n/g,"\n"),e=e.replace(/^[\s\n]*/g," "),e=e.replace(/[\s\n]*$/g," "),e=e.replace(/>\s{2,}</g,"> <"),e=e.replace(/\n\n/g,"\n"),e=e.replace(/\u200B/g,"")},removeSpacesHard:function(e){return e=t.trim(e),e=e.replace(/\n/g,""),e=e.replace(/[\t]*/g,""),e=e.replace(/\n\s*\n/g,"\n"),e=e.replace(/^[\s\n]*/g,""),e=e.replace(/[\s\n]*$/g,""),e=e.replace(/>\s{2,}</g,"><"),e=e.replace(/\n\n/g,"\n"),e=e.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(e){e=(e=t.trim(e)).replace(/^(<span id="selection-marker-1" class="redactor-selection-marker">​<\/span>)/,""),"textarea"===this.opts.type?e=this.clean.onSet(e):"div"===this.opts.type&&""===e&&(e=this.opts.emptyHtml),e=e.replace(/<p><span id="selection-marker-1" class="redactor-selection-marker">​<\/span><\/p>/,""),this.events.stopDetectChanges(),this.core.editor().html(e),this.observe.load(),this.events.startDetectChanges()},set:function(e,i){e=t.trim(e),(i=i||{}).start&&(this.start=i.start),"textarea"===this.opts.type?e=this.clean.onSet(e):"div"===this.opts.type&&""===e&&(e=this.opts.emptyHtml),this.core.editor().html(e),"textarea"===this.opts.type&&this.code.sync(),this.placeholder.enable()},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 e=this.core.editor().html(),i=this.code.cleaned(e);if(!this.code.isSync(i)){if(this.code.html=i,"textarea"!==this.opts.type)return this.core.callback("sync",e),void this.core.callback("change",e);"textarea"===this.opts.type&&setTimeout(t.proxy(function(){this.code.startSync(e)},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?t():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 t.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(e,i,r){var o=!1,s=t._data(this.core.element()[0],"events");if(void 0!==s&&void 0!==s[e])for(var n=s[e].length,a=0;a<n;a++)if("callback.redactor"===s[e][a].namespace){var l=s[e][a].handler,c=void 0===r?[i]:[i,r];o=void 0===c?l.call(this,i):l.call(this,i,c)}if(o)return o;if(void 0===this.opts.callbacks[e])return void 0===r?i:r;var d=this.opts.callbacks[e];return t.isFunction(d)?void 0===r?d.call(this,i):d.call(this,i,r):void 0===r?i:r},destroy:function(){this.opts.destroyed=!0,this.core.callback("destroy"),this.placeholder.destroy(),this.progress.destroy(),t("#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"),t(document).off(".redactor-dropdown"),t(document).off(".redactor-air."+this.uuid),t(document).off("mousedown.redactor-blur."+this.uuid),t(document).off("mousedown.redactor."+this.uuid),t(document).off("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid),t(window).off(".redactor-toolbar."+this.uuid),t(window).off("touchmove.redactor."+this.uuid),t("body").off("scroll.redactor."+this.uuid),t(this.opts.toolbarFixedTarget).off("scroll.redactor."+this.uuid);var e=this;!1!==this.opts.plugins&&t.each(this.opts.plugins,function(i,r){t(window).off(".redactor-plugin-"+r),t(document).off(".redactor-plugin-"+r),t("body").off(".redactor-plugin-"+r),e.core.editor().off(".redactor-plugin-"+r)}),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 i=this.code.get();this.opts.toolbar&&this.$toolbar&&this.$toolbar.find("a").each(function(){var e=t(this);e.data("dropdown")&&(e.data("dropdown").remove(),e.data("dropdown",{}))}),"textarea"===this.opts.type&&(this.$box.after(this.$element),this.$box.remove(),this.$element.val(i).show()),this.opts.air&&this.$air.remove(),this.opts.toolbar&&this.$toolbar&&this.$toolbar.remove(),this.$modalBox&&this.$modalBox.remove(),this.$modalOverlay&&this.$modalOverlay.remove(),t(".redactor-link-tooltip").remove(),clearInterval(this.autosaveTimeout)}}},detect:function(){return{isWebkit:function(){return/webkit/.test(this.opts.userAgent)},isFirefox:function(){return this.opts.userAgent.indexOf("firefox")>-1},isIe:function(t){if(document.documentMode||/Edge/.test(navigator.userAgent))return"edge";var e;return(e=RegExp("msie"+(isNaN(t)?"":"\\s"+t),"i").test(navigator.userAgent))||(e=!!navigator.userAgent.match(/Trident.*rv[ :]*11\./)),e},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(e,i,r){r=this.dropdown.buildFormatting(e,r),t.each(r,t.proxy(function(t,r){var o=this.dropdown.buildItem(t,r);this.observe.addDropdown(o,t,r),i.attr("rel",e).append(o)},this))},buildFormatting:function(e,i){return"format"!==e||!1===this.opts.formattingAdd?i:(t.each(this.opts.formattingAdd,t.proxy(function(t,e){var r=this.utils.isBlockTag(e.args[0])?"block":"inline";i[t]={func:"block"===r?"block.format":"inline.format",args:e.args,title:e.title}},this)),i)},buildItem:function(e,i){var r=t("<li />");if(void 0!==i.classname&&r.addClass(i.classname),-1!==e.search(/^divider/i))return r.addClass("redactor-dropdown-divider"),r;var o=t('<a href="#" class="redactor-dropdown-'+e+'" role="button" />'),s=t("<span />").html(i.title);return o.append(s),o.on("mousedown",t.proxy(function(t){t.preventDefault(),this.dropdown.buildClick(t,e,i)},this)),r.append(o),r},buildClick:function(e,i,r){if(!t(e.target).hasClass("redactor-dropdown-link-inactive")){var o=this.dropdown.buildCommand(r);void 0!==r.args?this.button.toggle(e,i,o.type,o.callback,r.args):this.button.toggle(e,i,o.type,o.callback)}},buildCommand:function(t){var e={};return e.type="func",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(e,i){this.detect.isDesktop()&&this.core.editor().focus(),this.dropdown.hideAll(!1,i),this.dropdown.key=i,this.dropdown.button=this.button.get(this.dropdown.key),this.dropdown.button.hasClass("dropact")?this.dropdown.hide():(this.dropdown.active=this.dropdown.button.data("dropdown").appendTo(document.body),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"),this.dropdown.getButtonPosition(),this.button.toolbar().hasClass("toolbar-fixed-box")&&this.detect.isDesktop()?this.dropdown.showIsFixedToolbar():this.dropdown.showIsUnFixedToolbar(),this.detect.isDesktop()&&!this.detect.isFirefox()&&(this.dropdown.active.on("mouseover.redactor-dropdown",t.proxy(this.utils.disableBodyScroll,this)),this.dropdown.active.on("mouseout.redactor-dropdown mousedown.redactor-dropdown",t.proxy(this.utils.enableBodyScroll,this))),e.stopPropagation())},showIsFixedToolbar:function(){var e=this.dropdown.button.position().top+this.dropdown.button.innerHeight()+this.opts.toolbarFixedTopOffset,i="fixed";this.opts.toolbarFixedTarget!==document&&(e=this.dropdown.button.innerHeight()+this.$toolbar.offset().top+this.opts.toolbarFixedTopOffset,i="absolute"),this.dropdown.active.css({position:i,left:this.dropdown.position.left+"px",top:e+"px"}).show(),this.dropdown.active.redactorAnimation("slideDown",{duration:.2},t.proxy(function(){this.dropdown.enableCallback(),this.dropdown.enableEvents()},this))},showIsUnFixedToolbar:function(){this.dropdown.active.css({position:"absolute",left:this.dropdown.position.left+"px",top:this.dropdown.button.innerHeight()+this.dropdown.position.top+"px"}).show(),this.dropdown.active.redactorAnimation(this.opts.animation?"slideDown":"show",{duration:.2},t.proxy(function(){this.dropdown.enableCallback(),this.dropdown.enableEvents()},this))},enableEvents:function(){t(document).on("mousedown.redactor-dropdown",t.proxy(this.dropdown.hideAll,this)),this.core.editor().on("touchstart.redactor-dropdown",t.proxy(this.dropdown.hideAll,this)),t(document).on("keyup.redactor-dropdown",t.proxy(this.dropdown.closeHandler,this))},enableCallback:function(){this.core.callback("dropdownShown",{dropdown:this.dropdown.active,key:this.dropdown.key,button:this.dropdown.button})},getButtonPosition:function(){this.dropdown.position=this.dropdown.button.offset();var e=this.dropdown.active.width();this.dropdown.position.left+e>t(document).width()&&(this.dropdown.position.left=Math.max(0,this.dropdown.position.left-e+parseInt(this.dropdown.button.innerWidth())))},closeHandler:function(t){t.which===this.keyCode.ESC&&(this.dropdown.hideAll(t),this.core.editor().focus())},hideAll:function(e,i){if(this.detect.isDesktop()&&this.utils.enableBodyScroll(),!1===e||0===t(e.target).closest(".redactor-dropdown").length){var r=void 0===i?this.button.toolbar().find("a.dropact"):this.button.toolbar().find("a.dropact").not(".re-"+i),o=void 0===i?t(".redactor-dropdown-"+this.uuid):t(".redactor-dropdown-"+this.uuid).not(".redactor-dropdown-box-"+i);0!==o.length&&(t(document).off(".redactor-dropdown"),this.core.editor().off(".redactor-dropdown"),t.each(o,t.proxy(function(e,i){var r=t(i);this.core.callback("dropdownHide",r),r.hide(),r.off("mouseover mouseout").off(".redactor-dropdown")},this)),r.removeClass("redactor-act dropact"))}},hide:function(){!1!==this.dropdown.active&&(this.detect.isDesktop()&&this.utils.enableBodyScroll(),this.dropdown.active.redactorAnimation(this.opts.animation?"slideUp":"hide",{duration:.2},t.proxy(function(){t(document).off(".redactor-dropdown"),this.core.editor().off(".redactor-dropdown"),this.dropdown.hideOut()},this)))},hideOut:function(){this.core.callback("dropdownHide",this.dropdown.active),this.dropdown.button.removeClass("redactor-act dropact"),this.dropdown.active.off("mouseover mouseout").off(".redactor-dropdown"),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(e){e.preventDefault(),e.stopPropagation(),"IMG"===e.target.tagName&&t(e.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){if(!this.rtePaste&&(this.events.isCallback("focus")&&this.core.callback("focus",t),this.events.focused=!0,this.events.blured=!1,!1===this.selection.current())){var e=this.selection.get(),i=this.selection.range(e);i.setStart(this.core.editor()[0],0),i.setEnd(this.core.editor()[0],0),this.selection.update(e,i)}},blur:function(e){this.start||this.rtePaste||0===t(e.target).closest("#"+this.core.id()+", .redactor-toolbar, .redactor-dropdown, #redactor-modal-box").length&&(!this.events.blured&&this.events.isCallback("blur")&&this.core.callback("blur",e),this.events.focused=!1,this.events.blured=!0)},touchImageEditing:function(){var e=-1;this.events.imageEditing=!1,t(window).on("touchmove.redactor."+this.uuid,t.proxy(function(){this.events.imageEditing=!0,-1!==e&&clearTimeout(e),e=setTimeout(t.proxy(function(){this.events.imageEditing=!1},this),500)},this))},init:function(){this.core.editor().on("dragover.redactor dragenter.redactor",t.proxy(this.events.dragover,this)),this.core.editor().on("dragleave.redactor",t.proxy(this.events.dragleave,this)),this.core.editor().on("drop.redactor",t.proxy(this.events.drop,this)),this.core.editor().on("click.redactor",t.proxy(this.events.click,this)),this.core.editor().on("paste.redactor",t.proxy(this.paste.init,this)),this.core.editor().on("keydown.redactor",t.proxy(this.keydown.init,this)),this.core.editor().on("keyup.redactor",t.proxy(this.keyup.init,this)),this.core.editor().on("focus.redactor",t.proxy(this.events.focus,this)),t(document).on("mousedown.redactor-blur."+this.uuid,t.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(i){i.forEach(t.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])&&(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(),this.autosave.is()&&(clearTimeout(this.autosaveTimeout),this.autosaveTimeout=setTimeout(t.proxy(this.autosave.send,this),300)))},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(e){return void 0!==this.opts.callbacks[e]&&t.isFunction(this.opts.callbacks[e])},stopDetect:function(){this.events.stopDetectChanges()},startDetect:function(){this.events.startDetectChanges()}}},file:function(){return{is:function(){return!(!this.opts.fileUpload||!this.opts.fileUpload&&!this.opts.s3)},show:function(){this.modal.load("file",this.lang.get("file"),700),this.upload.init("#redactor-modal-file-upload",this.opts.fileUpload,this.file.insert),t("#redactor-filename").val(this.selection.get().toString()),this.modal.show()},insert:function(e,i,r){if(void 0!==e.error)return this.modal.close(),void this.core.callback("fileUploadError",e);this.file.release(r,i),this.buffer.set(),this.air.collapsed();var o=this.file.text(e),s=t("<a />").attr("href",e.url).text(o),n=void 0===e.id?"":e.id,a=void 0===e.s3?"file":"s3";s.attr("data-"+a,n),s=t(this.insert.node(s)),this.caret.after(s),this.storage.add({type:a,node:s[0],url:e.url,id:n}),null!==i&&this.core.callback("fileUpload",s,e)},release:function(t,e){e?(this.marker.remove(),this.insert.nodeToPoint(t,this.marker.get()),this.selection.restore()):this.modal.close()},text:function(e){var i=t("#redactor-filename").val();return void 0===i||""===i?e.name:i}}},focus:function(){return{start:function(){if(this.core.editor().focus(),"inline"!==this.opts.type){var t=this.focus.first();!1!==t&&this.caret.start(t)}},end:function(){this.core.editor().focus();var t=this.opts.inline?this.core.editor():this.focus.last();if(0!==t.length){var e=this.focus.lastChild(t);if(this.detect.isWebkit()||!1===e){var i=this.selection.get(),r=this.selection.range(i);null!==r?(r.selectNodeContents(t[0]),r.collapse(!1),this.selection.update(i,r)):this.caret.end(t)}else this.caret.end(e)}},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(e,i,r){var o;if(void 0!==e.error)return this.modal.close(),this.events.dropImage=!1,void this.core.callback("imageUploadError",e,r);if(!1!==this.events.dropImage)return o=t(this.events.dropImage),this.core.callback("imageDelete",o[0].src,o),o.attr("src",e.url),this.events.dropImage=!1,void this.core.callback("imageUpload",o,e);this.placeholder.hide();var s=t("<"+this.opts.imageTag+">");(o=t("<img>")).attr("src",e.url);var n=void 0===e.id?"":e.id,a=void 0===e.s3?"image":"s3";o.attr("data-"+a,n),s.append(o);var l=this.utils.isTag(this.selection.current(),"pre");if(i){this.air.collapsed(),this.marker.remove();var c=this.insert.nodeToPoint(r,this.marker.get()),d=t(c).next();this.selection.restore(),this.buffer.set(),void 0!==d&&0!==d.length&&"IMG"===d[0].tagName?(this.core.callback("imageDelete",d[0].src,d),d.closest("figure, p",this.core.editor()[0]).replaceWith(s),this.caret.after(s)):(l?t(l).after(s):this.insert.node(s),this.caret.after(s))}else this.modal.close(),this.buffer.set(),this.air.collapsed(),l?t(l).after(s):this.insert.node(s),this.caret.after(s);this.events.dropImage=!1,this.storage.add({type:a,node:o[0],url:e.url,id:n});var h=o[0].nextSibling,u=s.next(),p=t(h).text().replace(/\u200B/g,""),f=u.text().replace(/\u200B/g,"");""===p&&t(h).remove(),1===u.length&&"FIGURE"===u[0].tagName&&""===f&&u.remove(),null!==i?this.core.callback("imageUpload",o,e):this.core.callback("imageInserted",o,e)},setEditable:function(e){if(e.on("dragstart",function(t){t.preventDefault()}),this.opts.imageResizable){var i=t.proxy(function(i){this.observe.image=e,this.image.resizer=this.image.loadEditableControls(e),t(document).on("mousedown.redactor-image-resize-hide."+this.uuid,t.proxy(this.image.hideResize,this)),this.image.resizer&&this.image.resizer.on("mousedown.redactor touchstart.redactor",t.proxy(function(t){this.image.setResizable(t,e)},this))},this);e.off("mousedown.redactor").on("mousedown.redactor",t.proxy(this.image.hideResize,this)),e.off("click.redactor touchstart.redactor").on("click.redactor touchstart.redactor",i)}else e.off("click.redactor touchstart.redactor").on("click.redactor touchstart.redactor",t.proxy(function(i){setTimeout(t.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(){t(document).on("mousemove.redactor-image-resize touchmove.redactor-image-resize",t.proxy(this.image.moveResize,this)),t(document).on("mouseup.redactor-image-resize touchend.redactor-image-resize",t.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.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,t(document).off(".redactor-image-resize"),this.image.hideResize()},hideResize:function(e){if(!e||0===t(e.target).closest("#redactor-image-box",this.$editor[0]).length){if(e&&"IMG"==e.target.tagName)t(e.target);var i=this.$editor.find("#redactor-image-box");0!==i.length&&(t("#redactor-image-editter").remove(),t("#redactor-image-resizer").remove(),i.find("img").css({marginTop:i[0].style.marginTop,marginBottom:i[0].style.marginBottom,marginLeft:i[0].style.marginLeft,marginRight:i[0].style.marginRight}),i.css("margin",""),i.find("img").css("opacity",""),i.replaceWith(function(){return t(this).contents()}),t(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(e,i){if(this.opts.imageResizable&&!this.detect.isMobile()){var r=t('<span id="redactor-image-resizer" data-redactor="verified"></span>');return this.detect.isDesktop()||r.css({width:"15px",height:"15px"}),r.attr("contenteditable",!1),i.append(r),i.append(e),r}return i.append(e),!1},loadEditableControls:function(e){if(0===t("#redactor-image-box").length){var i=t('<span id="redactor-image-box" data-redactor="verified">');if(i.css("float",e.css("float")).attr("contenteditable",!1),"auto"!=e[0].style.margin?(i.css({marginTop:e[0].style.marginTop,marginBottom:e[0].style.marginBottom,marginLeft:e[0].style.marginLeft,marginRight:e[0].style.marginRight}),e.css("margin","")):i.css({display:"block",margin:"auto"}),e.css("opacity",".5").after(i),this.opts.imageEditable){this.image.editter=t('<span id="redactor-image-editter" data-redactor="verified">'+this.lang.get("edit")+"</span>"),this.image.editter.attr("contenteditable",!1),this.image.editter.on("click",t.proxy(function(){this.image.showEdit(e)},this)),i.append(this.image.editter);var r=this.image.editter.innerWidth();this.image.editter.css("margin-left","-"+r/2+"px")}return this.image.loadResizableControls(e,i)}},showEdit:function(e){if(!this.events.imageEditing){this.observe.image=e;var i=e.closest("a",this.$editor[0]),r=e.closest("figure",this.$editor[0]),o=0!==r.length?r:e;if(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",t.proxy(this.image.remove,this)),this.image.buttonSave.on("click",t.proxy(this.image.update,this)),!1===this.opts.imageCaption)t("#redactor-image-caption").val("").hide().prev().hide();else{var s=e.closest(this.opts.imageTag,this.$editor[0]).find("figcaption");0!==s&&t("#redactor-image-caption").val(s.text()).show()}if(this.opts.imagePosition){var n=(0!==r.length?"center"===o.css("text-align"):"block"==o.css("display")&&"none"==o.css("float"))?"center":o.css("float");t("#redactor-image-align").val(n)}else t(".redactor-image-position-option").hide();t("#redactor-image-preview").html(t('<img src="'+e.attr("src")+'" style="max-width: 100%;">')),t("#redactor-image-title").val(e.attr("alt")),0!==i.length&&(t("#redactor-image-link").val(i.attr("href")),"_blank"===i.attr("target")&&t("#redactor-image-link-blank").prop("checked",!0)),t(".redactor-link-tooltip").remove(),this.modal.show(),this.detect.isDesktop()&&t("#redactor-image-title").focus()}},update:function(){var e=this.observe.image,i=e.closest("a",this.core.editor()[0]),r=t("#redactor-image-title").val().replace(/(<([^>]+)>)/gi,"");e.attr("alt",r).attr("title",r),this.image.setFloating(e);var o=t.trim(t("#redactor-image-link").val()).replace(/(<([^>]+)>)/gi,"");if(""!==o){var s="((xn--)?[a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,}",n=new RegExp("^(http|ftp|https)://"+s,"i"),a=new RegExp("^"+s,"i");-1===o.search(n)&&0===o.search(a)&&this.opts.linkProtocol&&(o=this.opts.linkProtocol+"://"+o);var l=!!t("#redactor-image-link-blank").prop("checked");if(0===i.length){var c=t('<a href="'+o+'" id="redactor-img-tmp">'+this.utils.getOuterHtml(e)+"</a>");l&&c.attr("target","_blank"),e=e.replaceWith(c),(i=this.core.editor().find("#redactor-img-tmp")).removeAttr("id")}else i.attr("href",o),l?i.attr("target","_blank"):i.removeAttr("target")}else 0!==i.length&&i.replaceWith(this.utils.getOuterHtml(e));this.image.addCaption(e,i),this.modal.close(),this.buffer.set()},setFloating:function(e){var i=e.closest("figure",this.$editor[0]),r=0!==i.length?i:e,o="",s="",n="",a="";switch(t("#redactor-image-align").val()){case"left":o="left",n="0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin+" 0";break;case"right":o="right",n="0 0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin;break;case"center":0!==i.length?a="center":(s="block",n="auto")}r.css({float:o,display:s,margin:n,"text-align":a}),r.attr("rel",e.attr("style"))},addCaption:function(e,i){var r=t("#redactor-image-caption").val(),o=0!==i.length?i:e,s=o.next();0!==s.length&&"FIGCAPTION"===s[0].tagName||(s=!1),""!==r?!1===s?(s=t("<figcaption />").text(r),o.after(s)):s.text(r):!1!==s&&s.remove()},remove:function(e,i,r){i=void 0===i?t(this.observe.image):i,"boolean"!=typeof e&&this.buffer.set(),this.events.stopDetectChanges();var o=i.closest("a",this.core.editor()[0]),s=i.closest(this.opts.imageTag,this.core.editor()[0]);i.parent();if(!1===this.core.callback("imageDelete",e,i[0]))return e&&e.preventDefault(),!1;0!==t("#redactor-image-box").length&&t("#redactor-image-box").parent();var n,a;0!==s.length?(a=s.prev(),n=s.next(),s.remove()):0!==o.length?(o.parent(),o.remove()):i.remove(),t("#redactor-image-box").remove(),!1!==e&&(n&&0!==n.length?this.caret.start(n):a&&0!==a.length&&this.caret.end(a)),"boolean"!=typeof e&&this.modal.close(),this.utils.restoreScroll(),this.observe.image=!1,this.events.startDetectChanges(),this.placeholder.enable(),this.code.sync()}}},indent:function(){return{increase:function(){if(this.list.get()){var e=t(this.selection.current()).closest("li"),i=e.closest("ul, ol",this.core.editor()[0]),r=e.closest("li").prev();if(0!==r.length&&"LI"===r[0].tagName)if(this.buffer.set(),this.utils.isCollapsed()){var o=i[0].tagName,s=t("<"+o+" />");this.selection.save();var n=r.find("ol").first();if(1===n.length)n.append(e);else{o=i[0].tagName;(s=t("<"+o+" />")).append(e),r.append(s)}this.selection.restore()}else document.execCommand("indent"),this.selection.save(),this.indent.removeEmpty(),this.indent.normalize(),this.selection.restore()}},decrease:function(){if(this.list.get()){t(this.selection.current()).closest("li").closest("ul, ol",this.core.editor()[0]);this.buffer.set(),document.execCommand("outdent");var e=t(this.selection.current()).closest("li",this.core.editor()[0]);if(this.utils.isCollapsed()&&this.indent.repositionItem(e),0===e.length){document.execCommand("formatblock",!1,"p");var i=(e=t(this.selection.current())).next();0!==i.length&&"BR"===i[0].tagName&&i.remove()}this.selection.save(),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(t.proxy(function(e,i){var r=t(i);r.find(this.opts.inlineTags.join(",")).each(function(){t(this).removeAttr("style")});var o=r.parent();if(0===o.length||"LI"!==o[0].tagName){var s=r.next();0===s.length||"UL"!==s[0].tagName&&"OL"!==s[0].tagName||r.append(s)}else o.after(r)},this))},removeEmpty:function(e){var i=this.core.editor().find("ul, ol"),r=this.core.editor().find("li");r.each(t.proxy(function(t,e){this.indent.removeItemEmpty(e)},this)),i.each(t.proxy(function(t,e){this.indent.removeItemEmpty(e)},this)),r.each(t.proxy(function(t,e){this.indent.removeItemEmpty(e)},this))},removeItemEmpty:function(e){var i=e.innerHTML.replace(/[\t\s\n]/g,"");""===(i=i.replace(/<span><\/span>/g,""))&&t(e).remove()}}},inline:function(){return{format:function(t,e,i,r){if(!this.utils.isCurrentOrParent(["PRE","CODE"])){var o=this.inline.getParams(e,i,r);t=this.inline.arrangeTag(t),this.placeholder.hide(),this.buffer.set(),this.utils.isCollapsed()?this.inline.formatCollapsed(t,o):this.inline.formatUncollapsed(t,o)}},formatCollapsed:function(e,i){var r,o=this.selection.inline();if(o){var s=o.tagName.toLowerCase();if(s===e)if(this.utils.isEmpty(o.innerHTML))this.caret.after(o),t(o).remove();else{n=this.inline.insertBreakpoint(o,s);this.caret.after(n)}else if(0===t(o).closest(e).length)r=this.inline.insertInline(e),r=this.inline.setParams(r,i);else{var n=this.inline.insertBreakpoint(o,s);this.caret.after(n)}}else r=this.inline.insertInline(e),r=this.inline.setParams(r,i)},formatUncollapsed:function(e,i){this.selection.save();var r=this.inline.getClearedNodes();this.inline.setNodesStriked(r,e,i),this.selection.restore(),document.execCommand("strikethrough"),this.selection.saveInstant();var o=this;this.core.editor().find("strike").each(function(){var r=o.utils.replaceToTag(this,e);o.inline.setParams(r[0],i);var s=r.find(e),n=r.parent(),a=n.parent();if(0!==a.length&&a[0].tagName.toLowerCase()===e&&a.html()==n[0].outerHTML)return r.replaceWith(function(){return t(this).contents()}),void a.replaceWith(function(){return t(this).contents()});0!==s.length&&o.inline.cleanInsideOrParent(s,i),n.html()==r[0].outerHTML&&o.inline.cleanInsideOrParent(n,i),o.detect.isFirefox()&&o.core.editor().find(e+":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 e=this.selection.nodes(),i=[],r=e.length,o=0,s=0;s<r;s++)if(t(e[s]).hasClass("redactor-selection-marker")){o=s+2;break}for(s=0;s<r;s++)s>=o&&!this.utils.isBlockTag(e[s].tagName)&&i.push(e[s]);return i},isConvertableAttr:function(e,i,r){var o=t(e).attr(i);if(o)if("style"===i){for(var s=(r=t.trim(r).replace(/;$/,"")).split(";"),n=0,a=0;a<s.length;a++){var l=s[a].split(":"),c=t.trim(l[0]),d=t.trim(l[1]);if(-1!==c.search(/color/)){var h=t(e).css(c);!h||h!==d&&this.utils.rgb2hex(h)!==d||n++}else t(e).css(c)===d&&n++}if(n===s.length)return 1}else if(o===r)return 1;return 0},isConvertable:function(t,e,i,r){if(e===i){if(!r)return!0;var o=0;for(var s in r.data)o+=this.inline.isConvertableAttr(t,s,r.data[s]);if(o===Object.keys(r.data).length)return!0}return!1},setNodesStriked:function(e,i,r){for(var o=0;o<e.length;o++){var s=e[o].tagName?e[o].tagName.toLowerCase():void 0,n=e[o].parentNode,a=n&&n.tagName?n.tagName.toLowerCase():void 0,l=this.inline.isConvertable(n,a,i,r);if(l&&t(n).replaceWith(function(){return t("<strike>").append(t(this).contents())}).attr("data-redactor-inline-converted"),l=this.inline.isConvertable(e[o],s,i,r))t(e[o]).replaceWith(function(){return t("<strike>").append(t(this).contents())})}},insertBreakpoint:function(e,i){var r=document.createElement("span");r.id="redactor-inline-breakpoint",r=this.insert.node(r);var o=this.utils.isEndOfElement(e),s=this.utils.getOuterHtml(e),n=o?"":"<"+i+">";s=s.replace(/<span id="redactor-inline-breakpoint"><\/span>/i,"</"+i+">"+n);var a=t(s);return t(e).replaceWith(a),""!==n&&this.utils.cloneAttributes(e,a.last()),a.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 o=i[r].split(":");o&&(e[o[0].trim()]=o[1].trim())}return e},getParams:function(t,e,i){var r=!1,o="toggle";return"object"==typeof t?(r=t,o=void 0!==e?e:o):void 0!==t&&void 0!==e&&((r={})[t]=e,o=void 0!==i?i:o),!!r&&{func:o,data:r}},setParams:function(e,i){if(i)for(var r in i.data){var o=t(e);"style"===r?(e=this.inline[i.func+"Style"](i.data[r],e),o.attr("data-redactor-style-cache",o.attr("style"))):e="class"===r?this.inline[i.func+"Class"](i.data[r],e):"remove"===i.func?this.inline[i.func+"Attr"](r,e):this.inline[i.func+"Attr"](r,i.data[r],e),"style"===r&&"SPAN"===e.tagName&&o.attr("data-redactor-span",!0)}return e},eachInline:function(t,e){var i,r=void 0===t?this.selection.inlines():[t];if(r)for(var o=0;o<r.length;o++)i=e(r[o])[0];return i},replaceClass:function(e,i){return this.inline.eachInline(i,function(i){return t(i).removeAttr("class").addClass(e)})},toggleClass:function(e,i){return this.inline.eachInline(i,function(i){return t(i).toggleClass(e)})},addClass:function(e,i){return this.inline.eachInline(i,function(i){return t(i).addClass(e)})},removeClass:function(e,i){return this.inline.eachInline(i,function(i){return t(i).removeClass(e)})},removeAllClass:function(e){return this.inline.eachInline(e,function(e){return t(e).removeAttr("class")})},replaceAttr:function(e,i,r){return this.inline.eachInline(r,function(i){return t(i).removeAttr(e).attr(e.value)})},toggleAttr:function(e,i,r){return this.inline.eachInline(r,function(i){return t(i).attr(e)?t(i).removeAttr(e):t(i).attr(e.value)})},addAttr:function(e,i,r){return this.inline.eachInline(r,function(r){return t(r).attr(e,i)})},removeAttr:function(e,i){return this.inline.eachInline(i,function(i){var r=t(i);return r.removeAttr(e),"style"===e&&r.removeAttr("data-redactor-style-cache"),r})},removeAllAttr:function(e){return this.inline.eachInline(e,function(e){for(var i=t(e),r=e.attributes.length,o=0;o<r;o++)i.removeAttr(e.attributes[o].name);return i})},removeSpecificAttr:function(e,i,r){var o=t(e);if("style"===i){var s=r.split(":")[0].trim();o.css(s,""),this.utils.removeEmptyAttr(e,"style")&&o.removeAttr("data-redactor-style-cache")}else o.removeAttr(i)[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(e){var i=this.inline.hasParentStyle(e);if(i){var r=this.inline.getStyleParams(e.attr("style"));i.css(r),i.attr("data-redactor-style-cache",i.attr("style")),e.replaceWith(function(){return t(this).contents()})}else e.attr("data-redactor-style-cache",e.attr("style"));return e},replaceStyle:function(e,i){e=this.inline.getStyleParams(e);var r=this;return this.inline.eachInline(i,function(i){var o=t(i);o.removeAttr("style").css(e);var s=o.attr("style");return s&&o.attr("style",s.replace(/"/g,"'")),o=r.inline.addParentStyle(o)})},toggleStyle:function(e,i){e=this.inline.getStyleParams(e);var r=this;return this.inline.eachInline(i,function(i){var o=t(i);for(var s in e){var n=e[s],a=o.css(s);(a=r.utils.isRgb(a)?r.utils.rgb2hex(a):a.replace(/"/g,""))===(n=r.utils.isRgb(n)?r.utils.rgb2hex(n):n.replace(/"/g,""))?o.css(s,""):o.css(s,n)}var l=o.attr("style");return l&&o.attr("style",l.replace(/"/g,"'")),r.utils.removeEmptyAttr(i,"style")?o.removeAttr("data-redactor-style-cache"):o=r.inline.addParentStyle(o),o})},addStyle:function(e,i){e=this.inline.getStyleParams(e);var r=this;return this.inline.eachInline(i,function(i){var o=t(i);o.css(e);var s=o.attr("style");return s&&o.attr("style",s.replace(/"/g,"'")),o=r.inline.addParentStyle(o)})},removeStyle:function(e,i){e=this.inline.getStyleParams(e);var r=this;return this.inline.eachInline(i,function(i){var o=t(i);for(var s in e)o.css(s,"");return r.utils.removeEmptyAttr(i,"style")?o.removeAttr("data-redactor-style-cache"):o.attr("data-redactor-style-cache",o.attr("style")),o})},removeAllStyle:function(e){return this.inline.eachInline(e,function(e){return t(e).removeAttr("style").removeAttr("data-redactor-style-cache")})},removeStyleRule:function(e){var i=this.selection.parent(),r=this.selection.inlines();this.buffer.set(),i&&"SPAN"===i.tagName&&this.inline.removeStyleRuleAttr(t(i),e);for(var o=0;o<r.length;o++){var s=r[o],n=t(s);-1==t.inArray(s.tagName.toLowerCase(),this.opts.inlineTags)||n.hasClass("redactor-selection-marker")||this.inline.removeStyleRuleAttr(n,e)}},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 o=this.inline.getParams(e,i,r),s=this.selection.inlines(),n=[];if(s)for(var a=0;a<s.length;a++){var l=s[a];"*"!==t&&l.tagName.toLowerCase()!==t||n.push(this.inline.setParams(l,o))}return n},removeFormat:function(){this.selection.save();for(var e=this.inline.getClearedNodes(),i=0;i<e.length;i++)1===e[i].nodeType&&t(e[i]).replaceWith(function(){return t(this).contents()});this.selection.restore()}}},insert:function(){return{set:function(t){this.placeholder.hide(),this.code.set(t),this.focus.end(),this.placeholder.enable()},html:function(e,i){this.placeholder.hide(),this.core.editor().focus();var r=this.selection.block(),o=this.selection.inline();void 0===i&&(i=this.clean.getCurrentType(e,!0),e=this.clean.onPaste(e,i,!0)),e=t.parseHTML(e);var s=t(e).last(),n=this.selection.get(),a=this.selection.range(n);if(a.deleteContents(),this.selection.update(n,a),i.lists){var l=t(e);if(0!==l.length&&("UL"===l[0].tagName||"OL"===l[0].tagName))return void this.insert.appendLists(r,l)}if(i.blocks&&r)if(this.utils.isSelectAll())this.core.editor().html(e),this.focus.end();else{var c=this.utils.breakBlockTag();!1===c?this.insert.placeHtml(e):(t(e).children().last().append(this.marker.get()),"start"===c.type?c.$block.before(e):c.$block.after(e),this.selection.restore(),this.core.editor().find("p").each(function(){""===t.trim(this.innerHTML)&&t(this).remove()}))}else{if(o){var d=t("<div/>").html(e);d.find(o.tagName.toLowerCase()).each(function(){t(this).contents().unwrap()}),e=d.html()}if(this.utils.isSelectAll()){var h=t(this.opts.emptyHtml);this.core.editor().html("").append(h),h.html(e),this.caret.end(h)}else this.insert.placeHtml(e)}this.utils.disableSelectAll(),i.pre&&this.clean.cleanPre(),this.caret.end(s),this.linkify.format()},text:function(e){e=e.toString(),e=t.trim(e);var i=document.createElement("div");if(i.innerHTML=e,void 0!==(e=i.textContent||i.innerText)){this.placeholder.hide(),this.core.editor().focus();var r=this.selection.blocks();if(e=e.replace(/\n/g," "),this.utils.isSelectAll()){var o=t(this.opts.emptyHtml);this.core.editor().html("").append(o),o.html(e),this.caret.end(o)}else{var s=this.selection.get(),n=document.createTextNode(e);if(s.getRangeAt&&s.rangeCount){var a=s.getRangeAt(0);a.deleteContents(),a.insertNode(n),a.setStartAfter(n),a.collapse(!0),this.selection.update(s,a)}r.length>1&&(t(n).wrap("<p>"),this.caret.after(n))}this.utils.disableSelectAll(),this.linkify.format(),this.clean.normalizeCurrentHeading()}},raw:function(t){this.placeholder.hide(),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 o,s,n=document.createDocumentFragment();o=r.firstChild;)s=n.appendChild(o);i.insertNode(n),s&&((i=i.cloneRange()).setStartAfter(s),i.collapse(!0),e.removeAllRanges(),e.addRange(i))},node:function(e,i){this.placeholder.hide(),void 0!==this.start&&this.core.editor().focus(),e=e[0]||e;var r=this.selection.block(),o=this.utils.isBlockTag(e.tagName),s=!0;if(this.utils.isSelectAll())o?this.core.editor().html(e):this.core.editor().html(t("<p>").html(e)),this.code.sync();else if(o&&r){var n=this.utils.breakBlockTag();!1===n?this.insert.placeNode(e,i):("start"===n.type?n.$block.before(e):n.$block.after(e),this.core.editor().find("p:empty").remove())}else s=this.insert.placeNode(e,i);return this.utils.disableSelectAll(),s&&this.caret.end(e),e},appendLists:function(e,i){var r,o=t(e),s=this.utils.isEmpty(e.innerHTML);if(s||this.utils.isEndOfElement(e))r=o,i.find("li").each(function(){r.after(this),r=t(this)}),s&&o.remove();else if(this.utils.isStartOfElement(e))i.find("li").each(function(){o.before(this),r=t(this)});else{var n=this.selection.extractEndOfNode(e);o.after(t("<li>").append(n)),o.append(i),r=i}this.marker.remove(),r&&this.caret.end(r),this.linkify.format()},placeHtml:function(e){var i=document.createElement("span");i.id="redactor-insert-marker",i=this.insert.node(i),t(i).before(e),this.selection.restore(),this.caret.after(i),t(i).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(e,i){if(this.placeholder.hide(),i=i[0]||i,this.utils.isEmpty())return i=this.utils.isBlock(i)?i:t("<p />").append(i),this.core.editor().html(i),i;var r,o=e.clientX,s=e.clientY;if(document.caretPositionFromPoint){var n=document.caretPositionFromPoint(o,s);(r=document.getSelection().getRangeAt(0)).setStart(n.offsetNode,n.offset),r.collapse(!0),r.insertNode(i)}else if(document.caretRangeFromPoint)(r=document.caretRangeFromPoint(o,s)).insertNode(i);else if(void 0!==document.body.createTextRange){(r=document.body.createTextRange()).moveToPoint(o,s);var a=r.duplicate();a.moveToPoint(o,s),r.setEndPoint("EndToEnd",a),r.select()}return i},nodeToCaretPositionFromPoint:function(t,e){this.insert.nodeToPoint(t,e)},marker:function(){this.marker.insert()}}},keydown:function(){return{init:function(e){if(!this.rtePaste){var i=e.which,r=i>=37&&i<=40;if(this.keydown.ctrl=e.ctrlKey||e.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",e))return e.preventDefault(),!1;if(this.shortcuts.init(e,i),this.keydown.checkEvents(r,i),this.keydown.setupBuffer(e,i),this.utils.isSelectAll()&&(i===this.keyCode.ENTER||i===this.keyCode.BACKSPACE||i===this.keyCode.DELETE))return e.preventDefault(),void this.code.set(this.opts.emptyHtml);if(this.keydown.addArrowsEvent(r),this.keydown.setupSelectAll(e,i),this.opts.enterKey||i!==this.keyCode.ENTER){if(this.opts.enterKey&&i===this.keyCode.DOWN&&this.keydown.onArrowDown(),this.opts.enterKey&&i===this.keyCode.UP&&this.keydown.onArrowUp(),("textarea"===this.opts.type||"div"===this.opts.type)&&this.keydown.current&&3===this.keydown.current.nodeType&&t(this.keydown.parent).hasClass("redactor-in")&&this.keydown.wrapToParagraph(),!this.keyup.lastShiftKey&&i===this.keyCode.SPACE&&(e.ctrlKey||e.shiftKey))return e.preventDefault(),this.keydown.onShiftSpace();if(i===this.keyCode.ENTER&&(e.ctrlKey||e.shiftKey))return e.preventDefault(),this.keydown.onShiftEnter(e);if(i===this.keyCode.ENTER&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey)return this.keydown.onEnter(e);if(i===this.keyCode.TAB||e.metaKey&&221===i||e.metaKey&&219===i)return this.keydown.onTab(e,i);if(this.detect.isFirefox()&&i===this.keyCode.BACKSPACE&&this.keydown.block&&"P"===this.keydown.block.tagName&&this.utils.isStartOfElement(this.keydown.block)&&0!==(o=t(this.keydown.block).prev()).length)return e.preventDefault(),o.append(this.marker.get()),o.append(t(this.keydown.block).html()),t(this.keydown.block).remove(),void this.selection.restore();if(i===this.keyCode.BACKSPACE||i===this.keyCode.DELETE){if(this.observe.image&&void 0!==this.observe.image&&0!==t("#redactor-image-box").length){e.preventDefault();var o=this.observe.image.closest("figure, p").prev();return this.image.remove(!1),this.observe.image=!1,void(o&&0!==o.length?this.caret.end(o):this.core.editor().focus())}this.keydown.onBackspaceAndDeleteBefore()}if(i===this.keyCode.DELETE){var s=t(this.keydown.block).next();if(this.utils.isEndOfElement(this.keydown.block)&&0!==s.length&&"FIGURE"===s[0].tagName)return s.remove(),!1;if(!(!this.keydown.block||"LI"!==this.keydown.block.tagName)&&this.keydown.block){var n=t(this.keydown.block).parents("ul, ol").last(),a=n.next();if(this.utils.isRedactorParent(n)&&this.utils.isEndOfElement(n)&&0!==a.length&&("UL"===a[0].tagName||"OL"===a[0].tagName))return e.preventDefault(),n.append(a.contents()),a.remove(),!1}if(this.utils.isEndOfElement(this.keydown.block)&&0!==s.length&&"PRE"===s[0].tagName)return t(this.keydown.block).append(s.text()),s.remove(),!1}if(i===this.keyCode.DELETE&&0!==t("#redactor-image-box").length&&this.image.remove(),i===this.keyCode.BACKSPACE){if(this.detect.isFirefox()&&this.line.removeOnBackspace(e),this.list.combineAfterAndBefore(this.keydown.block))return void e.preventDefault();var l=this.selection.block();if(l&&"LI"===l.tagName&&this.utils.isCollapsed()&&this.utils.isStartOfElement())return this.indent.decrease(),void e.preventDefault();this.keydown.removeInvisibleSpace(),this.keydown.removeEmptyListInTable(e)}i!==this.keyCode.BACKSPACE&&i!==this.keyCode.DELETE||this.keydown.onBackspaceAndDeleteAfter(e)}else{e.preventDefault();var c=this.selection.get(),d=this.selection.range(c);d.collapsed||d.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(t.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(e){if(!1===this.core.callback("enter",e))return e.preventDefault(),!1;if(this.keydown.blockquote&&!0===this.keydown.exitFromBlockquote(e))return!1;if(this.keydown.pre)return this.keydown.insertNewLine(e);if(this.keydown.blockquote||this.keydown.figcaption)return this.keydown.insertBreakLine(e);if(this.keydown.figure)setTimeout(t.proxy(function(){this.keydown.replaceToParagraph("FIGURE")},this),1);else if(this.keydown.block){if(setTimeout(t.proxy(function(){this.keydown.replaceToParagraph("DIV")},this),1),"LI"===this.keydown.block.tagName){var i=this.selection.current(),r=t(i).closest("li",this.$editor[0]),o=r.parents("ul,ol",this.$editor[0]).last();if(0!==r.length&&this.utils.isEmpty(r.html())&&0===o.next().length&&this.utils.isEmpty(o.find("li").last().html())){o.find("li").last().remove();var s=t(this.opts.emptyHtml);return o.after(s),this.caret.start(s),!1}}}else if(!this.keydown.block)return this.keydown.insertParagraph(e);this.detect.isFirefox()&&this.utils.isInline(this.keydown.parent)?this.keydown.insertBreakLine(e):setTimeout(t.proxy(function(){var e=this.selection.inline();if(e&&this.utils.isEmpty(e.innerHTML)){var i=this.selection.block();t(e).remove();var r=document.createRange();r.setStart(i,0);var o=document.createTextNode("​");r.insertNode(o),r.setStartAfter(o),r.collapse(!0);var s=window.getSelection();s.removeAllRanges(),s.addRange(r)}},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(e){var i=this.keyCode,r=[i.BACKSPACE,i.DELETE,i.ENTER,i.ESC,i.TAB,i.CTRL,i.META,i.ALT,i.SHIFT];return-1===t.inArray(e,r)},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.opts.buffer.length?(t.preventDefault(),void this.buffer.undo()):this.keydown.ctrl&&90===e&&t.shiftKey&&!t.altKey&&0!==this.opts.rebuffer.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(e){if(this.utils.isEndOfElement(this.keydown.blockquote)&&-1!==this.clean.removeSpacesHard(t(this.keydown.blockquote).html()).search(/(<br\s?\/?>){1}$/i)){e.preventDefault(),t(this.keydown.blockquote).children().last().filter("br").remove(),t(this.keydown.blockquote).children().last().filter("span").remove();var i=t(this.opts.emptyHtml);return t(this.keydown.blockquote).after(i),this.caret.start(i),!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(e){if(this.utils.isEndOfElement(e)){var i=this.core.editor().contents().last();if(0===("FIGCAPTION"===e.tagName?t(this.keydown.block).parent().next():t(this.keydown.block).next()).length)if(0!==i.length||i[0]===e){var r=t(this.opts.emptyHtml);"FIGCAPTION"===e.tagName?t(e).parent().after(r):t(e).after(r),this.caret.start(r)}else this.caret.start(i)}},insertBeforeFirstElement:function(e){if(this.utils.isStartOfElement()&&!(this.core.editor().contents().length>1&&this.core.editor().contents().first()[0]!==e)){var i=t(this.opts.emptyHtml);t(e).before(i),this.caret.start(i)}},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,o=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||o?t.metaKey&&219===e?this.indent.decrease():t.metaKey&&221===e?this.indent.increase():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=document.createElement("br");if(this.insert.node(i),!0===e){var r=document.createElement("br");this.insert.node(r),this.caret.after(r)}else this.caret.after(i);return!1},wrapToParagraph:function(){var e=t(this.keydown.current),i=t("<p>").append(e.clone());e.replaceWith(i);var r=t(i).next();void 0!==r[0]&&"BR"===r[0].tagName&&r.remove(),this.caret.end(i)},replaceToParagraph:function(e){var i=this.selection.block(),r=t(i).prev(),o=i.innerHTML.replace(/<br\s?\/?>/gi,"");if(i.tagName===e&&this.utils.isEmpty(o)&&!t(i).hasClass("redactor-in")){s=document.createElement("p");return t(i).replaceWith(s),this.keydown.setCaretToParagraph(s),!1}if("P"===i.tagName)return t(i).removeAttr("class").removeAttr("style"),this.detect.isIe()&&this.utils.isEmpty(o)&&this.utils.isInline(this.keydown.parent)&&t(i).on("input",t.proxy(function(){var e=this.selection.parent();if(this.utils.isInline(e)){var r=t(e).html();t(i).html(r),this.caret.end(i)}t(i).off("keyup")},this)),!1;if(r.hasClass(this.opts.videoContainerClass)){r.removeAttr("class");var s=document.createElement("p");return r.replaceWith(s),this.keydown.setCaretToParagraph(s),!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 e=t(this.keydown.current);0===e.text().search(/^\u200B$/g)&&e.remove()},removeEmptyListInTable:function(e){var i=t(this.keydown.current),r=t(this.keydown.parent),o=i.closest("td",this.$editor[0]);if(0!==o.length&&i.closest("li",this.$editor[0])&&1===r.children("li").length){if(!this.utils.isEmpty(i.text()))return;e.preventDefault(),i.remove(),r.remove(),this.caret.start(o)}},removeEmptyLists:function(){var e=function(){""===t.trim(this.innerHTML).replace(/\/t\/n/g,"")&&t(this).remove()};this.core.editor().find("li").each(e),this.core.editor().find("ul, ol").each(e)},formatEmpty:function(e){var i=t.trim(this.core.editor().html());if(this.utils.isEmpty(i))return e.preventDefault(),"inline"===this.opts.type||"pre"===this.opts.type?(this.core.editor().html(this.marker.html()),this.selection.restore()):(this.core.editor().html(this.opts.emptyHtml),this.focus.start()),!1}}},keyup:function(){return{init:function(e){if(!this.rtePaste){var i=e.which;if(this.keyup.block=this.selection.block(),this.keyup.current=this.selection.current(),this.keyup.parent=this.selection.parent(),this.keyup.lastShiftKey=e.shiftKey,!1===this.core.callback("keyup",e))return e.preventDefault(),!1;if(i===this.keyCode.ENTER&&this.keyup.block&&"FIGURE"===this.keyup.block.tagName){var r=t(this.keyup.block).prev();if(0!==r.length&&"FIGURE"===r[0].tagName){var o=this.utils.replaceToTag(r,"p");return void this.caret.start(o)}}if(i===this.keyCode.BACKSPACE||i===this.keyCode.DELETE){if(this.utils.isSelectAll())return this.focus.start(),void this.toolbar.setUnfixed();if(this.keyup.block&&this.keydown.block&&"FIGURE"===this.keyup.block.tagName&&this.utils.isStartOfElement(this.keydown.block)){e.preventDefault(),this.selection.save(),t(this.keyup.block).find("figcaption").remove(),t(this.keyup.block).find("img").first().remove(),this.utils.replaceToTag(this.keyup.block,"p");var s=this.marker.find();return t("html, body").animate({scrollTop:s.position().top+20},500),void this.selection.restore()}if(this.keyup.block&&"P"===this.keyup.block.tagName){var n=t(this.keyup.block).find("img").length;""===t(this.keyup.block).text().replace(/\u200B/g,"")&&0!==n&&this.utils.replaceToTag(this.keyup.block,"figure")}this.keyup.block&&"FIGURE"===this.keyup.block.tagName&&0===t(this.keyup.block).find("img").length&&(this.selection.save(),this.utils.replaceToTag(this.keyup.block,"p"),this.selection.restore())}this.linkify.isKey(i)&&this.linkify.format()}}}},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(e){if(this.utils.isCollapsed()){var i=t(this.selection.block());if(0!==i.length&&this.utils.isStartOfElement(i)){var r=i.prev();r&&0!==r.length&&"HR"===r[0].tagName&&(e.preventDefault(),r.remove())}}}}},link:function(){return{get:function(){return t(this.selection.inlines("a"))},is:function(){var e=this.selection.nodes(),i=t(this.selection.current()).closest("a",this.core.editor()[0]);return!(0===i.length||e.length>1)&&i},unlink:function(t){void 0!==t&&t.preventDefault&&t.preventDefault(),this.buffer.set();var e=this.selection.inlines("a");if(0!==e.length){var i=this.link.replaceLinksToText(e);this.observe.closeAllTooltip(),this.core.callback("deletedLink",i)}},insert:function(e,i){var r=this.link.is();if(!0!==i&&!1===(e=this.link.buildLinkFromObject(r,e)))return!1;if(this.buffer.set(),e=this.core.callback("beforeInsertingLink",e),!1===r){r=t("<a />"),r=this.link.update(r,e);var o=(r=t(this.insert.node(r))).parent();!1===this.utils.isRedactorParent(o)&&r.wrap("<p>"),o.hasClass("redactor-unlink")&&o.replaceWith(function(){return t(this).contents()}),this.caret.after(r),this.core.callback("insertedLink",r)}else r=this.link.update(r,e),this.caret.after(r);return 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(e){void 0!==e&&e.preventDefault&&e.preventDefault(),this.observe.closeAllTooltip();var i=this.link.is();this.link.buildModal(i);var r=this.link.buildLinkFromElement(i);r.url=this.link.removeSelfHostFromUrl(r.url),this.opts.linkNewTab&&!i&&(r.target=!0),this.link.setModalValues(r),this.modal.show(),this.detect.isDesktop()&&t("#redactor-link-url").focus()},setModalValues:function(e){t("#redactor-link-blank").prop("checked",e.target),t("#redactor-link-url").val(e.url),t("#redactor-link-url-text").val(e.text)},buildModal:function(e){this.modal.load("link",this.lang.get(!1===e?"link-insert":"link-edit"),600),this.modal.getActionButton().text(this.lang.get(!1===e?"insert":"save")).on("click",t.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(e){return void 0===e?"":t.trim(e.replace(/[^\W\w\D\d+&\'@#/%?=~_|!:,.;\(\)]/gi,""))},cleanText:function(e){return void 0===e?"":t.trim(e.replace(/(<([^>]+)>)/gi,""))},getText:function(t){return""===t.text&&""!==t.url?this.link.truncateUrl(t.url.replace(/<|>/g,"")):t.text},isUrl:function(t){var e="((xn--)?[\\W\\w\\D\\d]+(-[\\W\\w\\D\\d]+)*\\.)+[\\W\\w]{2,}",i=new RegExp("^(http|ftp|https)://"+e,"i"),r=new RegExp("^"+e,"i"),o=new RegExp(".(html|php)$","i"),s=new RegExp("^/","i"),n=new RegExp("^tel:(.*?)","i");return-1===t.search(i)&&-1!==t.search(r)&&-1===t.search(o)&&"/"!==t.substring(0,1)&&(t="http://"+t),(-1!==t.search(i)||-1!==t.search(o)||-1!==t.search(s)||-1!==t.search(n))&&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("#")&&(t.url=this.link.isUrl(t.url)),!this.link.isEmpty(t)&&!1!==t.url&&t},buildLinkFromModal:function(){var e={};return e.url=this.link.cleanUrl(t("#redactor-link-url").val()),e.text=this.link.cleanText(t("#redactor-link-url-text").val()),e.text=this.link.getText(e),e.target=!!t("#redactor-link-blank").prop("checked"),this.link.parse(e)},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(e){var i,r=t.each(e,function(e,r){var o=t(r),s=t('<span class="redactor-unlink" />').append(o.contents());return o.replaceWith(s),0===e&&(i=s),o});return 1===e.length&&this.selection.isCollapsed()&&this.caret.after(i),r}}},linkify:function(){return{isKey:function(t){return t===this.keyCode.ENTER||t===this.keyCode.SPACE},isLink:function(t){return t.nodeValue.match(this.opts.regexps.linkyoutube)||t.nodeValue.match(this.opts.regexps.linkvimeo)||t.nodeValue.match(this.opts.regexps.linkimage)||t.nodeValue.match(this.opts.regexps.url)},isFiltered:function(e,i){return 3===i.nodeType&&""!==t.trim(i.nodeValue)&&!t(i).parent().is("pre")&&this.linkify.isLink(i)},handler:function(e,i){var r=t(i),o=r.text(),s=o;s=s.match(this.opts.regexps.linkyoutube)||s.match(this.opts.regexps.linkvimeo)?this.linkify.convertVideoLinks(s):s.match(this.opts.regexps.linkimage)?this.linkify.convertImages(s):this.linkify.convertLinks(s),r.before(o.replace(o,s)).remove()},format:function(){if(this.opts.linkify&&!this.utils.isCurrentOrParent("pre")){this.core.editor().find(":not(iframe,img,a,pre,code,.redactor-unlink)").addBack().contents().filter(t.proxy(this.linkify.isFiltered,this)).each(t.proxy(this.linkify.handler,this));var e=this.core.editor().find(".redactor-linkify-object").each(t.proxy(function(e,i){var r=t(i);return r.removeClass("redactor-linkify-object"),""===r.attr("class")&&r.removeAttr("class"),"DIV"===i.tagName?this.linkify.breakBlockTag(r,"video"):"IMG"===i.tagName?this.linkify.breakBlockTag(r,"image"):"A"===i.tagName&&this.core.callback("insertedLink",r),r},this));setTimeout(t.proxy(function(){this.code.sync(),this.core.callback("linkify",e)},this),100)}},breakBlockTag:function(e,i){var r=this.utils.breakBlockTag();if(!1!==r){var o=e;"image"===i&&(o=t("<figure />").append(e)),"start"===r.type?r.$block.before(o):r.$block.after(o),"image"===i&&this.caret.after(o)}},convertVideoLinks:function(t){var e='<div class="'+this.opts.videoContainerClass+' redactor-linkify-object"><iframe class="redactor-linkify-object" width="500" height="281" src="',i='" frameborder="0" allowfullscreen></iframe></div>';return t.match(this.opts.regexps.linkyoutube)&&(t=t.replace(this.opts.regexps.linkyoutube,e+"//www.youtube.com/embed/$1"+i)),t.match(this.opts.regexps.linkvimeo)&&(t=t.replace(this.opts.regexps.linkvimeo,e+"//player.vimeo.com/video/$2"+i)),t},convertImages:function(t){var e=t.match(this.opts.regexps.linkimage);return e?t.replace(t,'<img src="'+e+'" class="redactor-linkify-object" />'):t},convertLinks:function(e){var i=e.match(this.opts.regexps.url);if(!i)return e;for(var r=(i=t.grep(i,function(e,r){return t.inArray(e,i)===r})).length,o=0;o<r;o++){var s=i[o],n=s,a=null!==s.match(/(https?|ftp):\/\//i)?"":"http://";n.length>this.opts.linkSize&&(n=n.substring(0,this.opts.linkSize)+"..."),-1===n.search("%")&&(n=decodeURIComponent(n));var l="\\b";-1!==t.inArray(s.slice(-1),["/","&","="])&&(l="");var c=new RegExp("("+s.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")+l+")","g"),d="";!1!==this.opts.pasteLinkTarget&&(d=' target="'+this.opts.pasteLinkTarget+'"'),e=e.replace(c,'<a href="'+a+t.trim(s)+'"'+d+' class="redactor-linkify-object">'+t.trim(n)+"</a>")}return e}}},list:function(){return{toggle:function(e){if(!this.utils.inBlocks(["table","td","th","tr"])){var i="orderedlist"===e||"ol"===e?"OL":"UL";e="OL"===i?"orderedlist":"unorderedlist";var r=t(this.selection.current()).parentsUntil(".redactor-in","ul, ol").first();if(this.placeholder.hide(),this.buffer.set(),0!==r.length&&r[0].tagName===i&&this.utils.isRedactorParent(r))return this.selection.save(),r.find("ul, ol").each(function(){var e=t(this).closest("li");t(this).find("li").each(function(){t(e).after(this)})}),r.find("ul, ol").remove(),r.find("li").each(function(){return t(this).replaceWith(function(){return t("<p />").append(t(this).contents())})}),r.replaceWith(function(){return t(this).contents()}),void this.selection.restore();this.selection.save(),0!==r.length&&r[0].tagName!==i?r.each(t.proxy(function(t,e){this.utils.replaceToTag(e,i)},this)):document.execCommand("insert"+e),this.selection.restore();var o=this.list.get();if(o){o.find("span").replaceWith(function(){return t(this).contents()}),o.find(this.opts.inlineTags.join(",")).each(function(){t(this).removeAttr("style")});var s=o.parent();this.utils.isRedactorParent(s)&&"LI"!==s[0].tagName&&this.utils.isBlock(s)&&(this.selection.save(),s.replaceWith(s.contents()),this.selection.restore())}else this.selection.block()||document.execCommand("formatblock",!1,"p")}},get:function(){var e=this.selection.current(),i=t(e).closest("ul, ol",this.core.editor()[0]);return 0!==i.length&&i},combineAfterAndBefore:function(e){var i=t(e).prev(),r=t(e).next(),o=e&&"P"===e.tagName&&("<br>"===e.innerHTML||""===e.innerHTML),s=1===i.closest("ol, ul",this.core.editor()[0]).length&&1===r.closest("ol, ul",this.core.editor()[0]).length;return!(!o||!s)&&(i.children("li").last().append(this.marker.get()),i.append(r.contents()),this.selection.restore(),!0)}}},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(e,i,r){var o=this.selection.parent();if(null!==e&&0!==t(o).closest(".redactor-in").length){e=e.cloneRange();try{e.collapse(r),e.insertNode(i)}catch(t){this.focus.start()}}},iterateRemove:function(e,i){var r=t(i);return""===r.text().replace(/\u200B/g,"")?r.remove():r.replaceWith(function(){return t(this).contents()})}}},modal:function(){return{callbacks:{},templates:function(){this.opts.modal={"image-edit":String()+'<div class="redactor-modal-tab redactor-group" data-title="General"><div id="redactor-image-preview" class="redactor-modal-tab-side"></div><div class="redactor-modal-tab-area"><section><label>'+this.lang.get("title")+'</label><input type="text" id="redactor-image-title" /></section><section><label>'+this.lang.get("caption")+'</label><input type="text" id="redactor-image-caption" aria-label="'+this.lang.get("caption")+'" /></section><section><label>'+this.lang.get("link")+'</label><input type="text" id="redactor-image-link" aria-label="'+this.lang.get("link")+'" /></section><section><label class="redactor-image-position-option">'+this.lang.get("image-position")+'</label><select class="redactor-image-position-option" id="redactor-image-align" aria-label="'+this.lang.get("image-position")+'"><option value="none">'+this.lang.get("none")+'</option><option value="left">'+this.lang.get("left")+'</option><option value="center">'+this.lang.get("center")+'</option><option value="right">'+this.lang.get("right")+'</option></select></section><section><label class="checkbox"><input type="checkbox" id="redactor-image-link-blank" aria-label="'+this.lang.get("link-in-new-tab")+'"> '+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><button id="redactor-modal-button-delete" class="redactor-modal-button-offset">'+this.lang.get("delete")+"</button></section></div></div>",image:String()+'<div class="redactor-modal-tab" data-title="Upload"><section><div id="redactor-modal-image-droparea"></div></section></div>',file:String()+'<div class="redactor-modal-tab" data-title="Upload"><section><label>'+this.lang.get("filename")+' <span class="desc">('+this.lang.get("optional")+')</span></label><input type="text" id="redactor-filename" aria-label="'+this.lang.get("filename")+'" /><br><br></section><section><div id="redactor-modal-file-upload"></div></section></div>',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>"},t.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(t,e,i){void 0!==this.$modalBox&&this.$modalBox.hasClass("open")||(this.modal.templateName=t,this.modal.width=i,this.modal.build(),this.modal.enableEvents(),this.modal.setTitle(e),this.modal.setDraggable(),this.modal.setContent(),void 0!==this.modal.callbacks[t]&&this.modal.callbacks[t].call(this))},show:function(){this.detect.isDesktop()||document.activeElement.blur(),this.selection.save(),this.modal.buildTabber(),this.detect.isMobile()&&(this.modal.width="96%"),setTimeout(t.proxy(this.modal.buildWidth,this),0),t(window).on("resize.redactor-modal",t.proxy(this.modal.buildWidth,this)),this.$modalOverlay.redactorAnimation("fadeIn",{duration:.25}),this.$modalBox.addClass("open").show(),this.$modal.redactorAnimation("fadeIn",{timing:"cubic-bezier(0.175, 0.885, 0.320, 1.105)"},t.proxy(function(){this.utils.saveScroll(),this.utils.disableBodyScroll(),this.core.callback("modalOpened",this.modal.templateName,this.$modal),t(document).off("focusin.modal"),this.$modal.find("input[type=text],input[type=url],input[type=email]").on("keydown.redactor-modal",t.proxy(this.modal.setEnter,this))},this))},buildWidth:function(){var e=t(window).height(),i=t(window).width(),r="number"==typeof this.modal.width;!r&&this.modal.width.match(/%$/)?this.$modal.css({width:this.modal.width,"margin-bottom":"16px"}):parseInt(this.modal.width)>i?this.$modal.css({width:"96%","margin-bottom":"2%"}):(r&&(this.modal.width+="px"),this.$modal.css({width:this.modal.width,"margin-bottom":"16px"}));var o=this.$modal.outerHeight(),s=e/2-o/2+"px";this.detect.isMobile()?s="2%":o>e&&(s="16px"),this.$modal.css("margin-top",s)},buildTabber:function(){this.modal.tabs=this.$modal.find(".redactor-modal-tab"),this.modal.tabs.length<2||(this.modal.$tabsBox=t('<div id="redactor-modal-tabber" />'),t.each(this.modal.tabs,t.proxy(function(e,i){var r=t('<a href="#" rel="'+e+'" />').text(t(i).attr("data-title"));r.on("click",t.proxy(this.modal.showTab,this)),0===e&&r.addClass("active"),this.modal.$tabsBox.append(r)},this)),this.$modalBody.prepend(this.modal.$tabsBox))},showTab:function(e){e.preventDefault();var i=t(e.target),r=i.attr("rel");return this.modal.tabs.hide(),this.modal.tabs.eq(r).show(),t("#redactor-modal-tabber").find("a").removeClass("active"),i.addClass("active"),!1},setTitle:function(t){this.$modalHeader.html(t)},setContent:function(){this.$modalBody.html(this.modal.getTemplate(this.modal.templateName)),this.modal.getCancelButton().on("mousedown",t.proxy(this.modal.close,this))},setDraggable:function(){void 0!==t.fn.draggable&&(this.$modal.draggable({handle:this.$modalHeader}),this.$modalHeader.css("cursor","move"))},setEnter:function(t){13===t.which&&(t.preventDefault(),this.modal.getActionButton().click())},build:function(){this.modal.buildOverlay(),this.$modalBox=t('<div id="redactor-modal-box"/>').hide(),this.$modal=t('<div id="redactor-modal" role="dialog" />'),this.$modalHeader=t('<div id="redactor-modal-header" />'),this.$modalClose=t('<button type="button" id="redactor-modal-close" aria-label="'+this.lang.get("close")+'" />').html("&times;"),this.$modalBody=t('<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=t('<div id="redactor-modal-overlay">').hide(),t("body").prepend(this.$modalOverlay)},enableEvents:function(){this.$modalClose.on("mousedown.redactor-modal",t.proxy(this.modal.close,this)),t(document).on("keyup.redactor-modal",t.proxy(this.modal.closeHandler,this)),this.core.editor().on("keyup.redactor-modal",t.proxy(this.modal.closeHandler,this)),this.$modalBox.on("click.redactor-modal",t.proxy(this.modal.close,this))},disableEvents:function(){this.$modalClose.off("mousedown.redactor-modal"),t(document).off("keyup.redactor-modal"),this.core.editor().off("keyup.redactor-modal"),this.$modalBox.off("click§.redactor-modal"),t(window).off("resize.redactor-modal")},closeHandler:function(t){t.which===this.keyCode.ESC&&this.modal.close(!1)},close:function(e){if(e){if("redactor-modal-button-cancel"!==t(e.target).attr("id")&&e.target!==this.$modalClose[0]&&e.target!==this.$modalBox[0])return;e.preventDefault()}this.$modalBox&&(this.selection.restore(),this.modal.disableEvents(),this.utils.enableBodyScroll(),this.utils.restoreScroll(),this.$modalOverlay.redactorAnimation("fadeOut",{duration:.4},t.proxy(function(){this.$modalOverlay.remove()},this)),this.$modal.redactorAnimation("fadeOut",{duration:.3,timing:"cubic-bezier(0.175, 0.885, 0.320, 1.175)"},t.proxy(function(){void 0!==this.$modalBox&&(this.$modalBox.remove(),this.$modalBox=void 0),t(document.body).css("overflow",this.modal.bodyOveflow),this.core.callback("modalClosed",this.modal.templateName)},this)))}}},observe:function(){return{load:function(){void 0===this.opts.destroyed&&(this.observe.links(),this.observe.images())},isCurrent:function(e,i){return void 0===i&&(i=t(this.selection.current())),i.is(e)||i.parents(e).length>0},toolbar:function(){this.observe.buttons(),this.observe.dropdowns()},buttons:function(e,i){var r=this.selection.current(),o=this.selection.parent();!1!==e?this.button.setInactiveAll():this.button.setInactiveAll(i),!1!==e||"html"===i?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")),t.each(this.opts.activeButtonsStates,t.proxy(function(e,i){var s=t(o).closest(e,this.$editor[0]),n=t(r).closest(e,this.$editor[0]);(0===s.length||this.utils.isRedactorParent(s))&&this.utils.isRedactorParent(n)&&(0===s.length&&0===n.closest(e,this.$editor[0]).length||this.button.setActive(i))},this))):-1!==t.inArray(i,this.opts.activeButtons)&&this.button.toggleActive(i)},dropdowns:function(){var e=t("<div />").html(this.selection.html()).find("a").length,i=t(this.selection.current()),r=this.utils.isRedactorParent(i);t.each(this.opts.observe.dropdowns,t.proxy(function(t,o){var s=o.observe,n=s.element,a=o.item,l=void 0!==s.in&&s.in,c=void 0!==s.out&&s.out;i.closest(n).length>0&&r||"a"===n&&0!==e?this.observe.setDropdownProperties(a,l,c):this.observe.setDropdownProperties(a,c,l)},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(e,i,r){t.each(i,function(t,i){"class"===t?r?e.removeClass(i):e.addClass(i):r?e.removeAttr(t):e.attr(t,i)})},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(t.proxy(function(e,i){var r=t(i);r.closest("a",this.$editor[0]).on("click",function(t){t.preventDefault()}),this.image.setEditable(r)},this)))},links:function(){this.opts.linkTooltip&&this.core.editor().find("a").each(t.proxy(function(e,i){var r=t(i);!0!==r.data("cached")&&(r.data("cached",!0),r.on("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,t.proxy(this.observe.showTooltip,this)))},this))},getTooltipPosition:function(t){return t.offset()},showTooltip:function(e){var i=t(e.target);if("IMG"!==i[0].tagName&&("A"!==i[0].tagName&&(i=i.closest("a",this.$editor[0])),"A"===i[0].tagName)){var r=i,o=this.observe.getTooltipPosition(r),s=t('<span class="redactor-link-tooltip"></span>'),n=r.attr("href");void 0===n&&(n=""),n.length>24&&(n=n.substring(0,24)+"...");var a=t('<a href="'+r.attr("href")+'" target="_blank" />').html(n).addClass("redactor-link-tooltip-action"),l=t('<a href="#" />').html(this.lang.get("edit")).on("click",t.proxy(this.link.show,this)).addClass("redactor-link-tooltip-action"),c=t('<a href="#" />').html(this.lang.get("unlink")).on("click",t.proxy(this.link.unlink,this)).addClass("redactor-link-tooltip-action");s.append(a).append(" | ").append(l).append(" | ").append(c);var d=parseInt(r.css("line-height"),10),h=Math.ceil((e.pageY-o.top)/d),u=o.top+h*d;s.css({top:u+"px",left:o.left+"px"}),t(".redactor-link-tooltip").remove(),t("body").append(s),this.core.editor().on("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,t.proxy(this.observe.closeTooltip,this)),t(document).on("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,t.proxy(this.observe.closeTooltip,this))}},closeAllTooltip:function(){t(".redactor-link-tooltip").remove()},closeTooltip:function(e){var i=(e=e.originalEvent||e).target,r=t(i).closest("a",this.$editor[0]);0!==r.length&&"A"===r[0].tagName&&"A"!==i.tagName||"A"===i.tagName&&this.utils.isRedactorParent(i)||t(i).hasClass("redactor-link-tooltip-action")||(this.observe.closeAllTooltip(),this.core.editor().off("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,t.proxy(this.observe.closeTooltip,this)),t(document).off("touchstart.redactor."+this.uuid+" click.redactor."+this.uuid,t.proxy(this.observe.closeTooltip,this)))}}},offset:function(){return{get:function(e){var i=this.offset.clone(e);if(!1===i)return 0;var r=document.createElement("div");return r.appendChild(i.cloneContents()),r.innerHTML=r.innerHTML.replace(/<img(.*?[^>])>$/gi,"i"),t.trim(t(r).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(),o=this.selection.range(r),s=0,n=document.createTreeWalker(this.$editor[0],NodeFilter.SHOW_TEXT,null,null);null!==(i=n.nextNode());)if((s+=i.nodeValue.length)>t&&(o.setStart(i,i.nodeValue.length+t-s),t=1/0),s>=e){o.setEnd(i,i.nodeValue.length+e-s);break}o.collapse(!1),this.selection.update(r,o)}}},paragraphize:function(){return{load:function(e){return!1===this.opts.paragraphize||"inline"===this.opts.type||"pre"===this.opts.type?e:""===e||"<p></p>"===e?this.opts.emptyHtml:(e+="\n",this.paragraphize.safes=[],this.paragraphize.z=0,e=e.replace(/(<br\s?\/?>){1,}\n?<\/blockquote>/gi,"</blockquote>"),e=e.replace(/<\/pre>/gi,"</pre>\n\n"),e=e.replace(/<p>\s<br><\/p>/gi,"<p></p>"),e=this.paragraphize.getSafes(e),e=e.replace("<br>","\n"),e=this.paragraphize.convert(e),e=this.paragraphize.clear(e),e=this.paragraphize.restoreSafes(e),e=e.replace(new RegExp("<br\\s?/?>\n?<("+this.opts.paragraphizeBlocks.join("|")+")(.*?[^>])>","gi"),"<p><br /></p>\n<$1$2>"),t.trim(e))},getSafes:function(e){var i=t("<div />").append(e);return i.find("blockquote p").replaceWith(function(){return t(this).append("<br />").contents()}),i.find(this.opts.paragraphizeBlocks.join(", ")).each(t.proxy(function(e,i){return this.paragraphize.z++,this.paragraphize.safes[this.paragraphize.z]=i.outerHTML,t(i).replaceWith("\n#####replace"+this.paragraphize.z+"#####\n\n")},this)),i.find("span.redactor-selection-marker").each(t.proxy(function(e,i){return this.paragraphize.z++,this.paragraphize.safes[this.paragraphize.z]=i.outerHTML,t(i).replaceWith("\n#####replace"+this.paragraphize.z+"#####\n\n")},this)),i.html()},restoreSafes:function(e){return t.each(this.paragraphize.safes,function(t,i){i=void 0!==i?i.replace(/\$/g,"&#36;"):i,e=e.replace("#####replace"+t+"#####",i)}),e},convert:function(e){var i=/\s+/g;e=(e=(e=(e=e.replace(/\r\n/g,"xparagraphmarkerz")).replace(/\n/g,"xparagraphmarkerz")).replace(/\r/g,"xparagraphmarkerz")).replace(i," ");var r=/xparagraphmarkerzxparagraphmarkerz/gi,o=/xparagraphmarkerz/gi;return e=(e=(e=t.trim(e)).replace(r,"</p><p>")).replace(o,"<br>"),e="<p>"+e+"</p>",e=e.replace("<p></p>",""),e=e.replace("\r\n\r\n",""),e=e.replace(/<\/p><p>/g,"</p>\r\n\r\n<p>"),e=e.replace(new RegExp("<br\\s?/?></p>","g"),"</p>"),e=e.replace(new RegExp("<p><br\\s?/?>","g"),"<p>"),e=e.replace(new RegExp("<p><br\\s?/?>","g"),"<p>"),e=e.replace(new RegExp("<br\\s?/?></p>","g"),"</p>"),e=e.replace(/<p>&nbsp;<\/p>/gi,""),e=e.replace(/<p>\s?<br>&nbsp;<\/p>/gi,""),e=e.replace(/<p>\s?<br>/gi,"<p>")},clear:function(t){return t=t.replace(/<p>(.*?)#####replace(.*?)#####\s?<\/p>/gi,"<p>$1</p>#####replace$2#####"),t=t.replace(/(<br\s?\/?>){2,}<\/p>/gi,"</p>"),t=t.replace(new RegExp("</blockquote></p>","gi"),"</blockquote>"),t=t.replace(new RegExp("<p></blockquote>","gi"),"</blockquote>"),t=t.replace(new RegExp("<p><blockquote>","gi"),"<blockquote>"),t=t.replace(new RegExp("<blockquote></p>","gi"),"<blockquote>"),t=t.replace(new RegExp("<p><p ","gi"),"<p "),t=t.replace(new RegExp("<p><p>","gi"),"<p>"),t=t.replace(new RegExp("</p></p>","gi"),"</p>"),t=t.replace(new RegExp("<p>\\s?</p>","gi"),""),t=t.replace(new RegExp("\n</p>","gi"),"</p>"),t=t.replace(new RegExp("<p>\t?\t?\n?<p>","gi"),"<p>"),t=t.replace(new RegExp("<p>\t*</p>","gi"),"")}}},paste:function(){return{init:function(e){this.rtePaste=!0;var i=!("pre"!==this.opts.type&&!this.utils.isCurrentOrParent("pre"));this.detect.isDesktop()&&!this.paste.pre&&this.opts.clipboardImageUpload&&this.opts.imageUpload&&this.paste.detectClipboardUpload(e)?this.detect.isIe()&&setTimeout(t.proxy(this.paste.clipboardUpload,this),100):(this.utils.saveScroll(),this.selection.save(),this.paste.createPasteBox(i),t(window).on("scroll.redactor-freeze",t.proxy(function(){t(window).scrollTop(this.saveBodyScroll)},this)),setTimeout(t.proxy(function(){var e=this.paste.getPasteBoxCode(i);this.buffer.set(),this.selection.restore(),this.utils.restoreScroll();var r=this.clean.getCurrentType(e);e=this.clean.onPaste(e,r);var o=this.core.callback("paste",e);e=void 0===o?e:o,this.paste.insert(e,r),this.rtePaste=!1,i&&this.clean.cleanPre(),t(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(e){var i={position:"fixed",width:"1px",top:0,left:"-9999px"};this.$pasteBox=e?t("<textarea>").css(i):t("<div>").attr("contenteditable","true").css(i),this.paste.appendPasteBox(),this.$pasteBox.focus()},appendPasteBox:function(){if(this.detect.isIe())this.core.box().append(this.$pasteBox);else{var e=t(".modal-body:visible");e.length>0?e.append(this.$pasteBox):t("body").prepend(this.$pasteBox)}},detectClipboardUpload:function(e){var i=(e=e.originalEvent||e).clipboardData;if(this.detect.isIe()||this.detect.isFirefox())return!1;if(-1!==i.types.indexOf("public.tiff"))return e.preventDefault(),!1;if(i.items&&i.items.length){var r=i.items[0].getAsFile();if(null===r)return!1;var o=new FileReader;return o.readAsDataURL(r),o.onload=t.proxy(this.paste.insertFromClipboard,this),!0}},clipboardUpload:function(){var e=this.$editor.find("img");t.each(e,t.proxy(function(e,i){if(-1!==i.src.search(/^data\:image/i)){var r=window.FormData?new FormData:null;if(window.FormData){this.upload.direct=!0,this.upload.type="image",this.upload.url=this.opts.imageUpload,this.upload.callback=t.proxy(function(e){if(this.detect.isIe())t(i).wrap(t("<figure />"));else{var r=t(i).parent();this.utils.replaceToTag(r,"figure")}i.src=e.url,this.core.callback("imageUpload",t(i),e)},this);var o=this.utils.dataURItoBlob(i.src);r.append("clipboard",1),r.append(this.opts.imageUploadParam,o),this.progress.show(),this.upload.send(r,!1),this.code.sync(),this.rtePaste=!1}}},this))},insertFromClipboard:function(t){var e=window.FormData?new FormData:null;if(window.FormData){this.upload.direct=!0,this.upload.type="image",this.upload.url=this.opts.imageUpload,this.upload.callback=this.image.insert;var i=this.utils.dataURItoBlob(t.target.result);e.append("clipboard",1),e.append(this.opts.imageUploadParam,i),this.progress.show(),this.upload.send(e,t),this.rtePaste=!1}},insert:function(e,i){i.pre?this.insert.raw(e):i.text?this.insert.text(e):this.insert.html(e,i),this.detect.isFirefox()&&this.opts.clipboardImageUpload&&setTimeout(t.proxy(this.paste.clipboardUpload,this),100)}}},placeholder:function(){return{enable:function(){setTimeout(t.proxy(function(){return this.placeholder.isEditorEmpty()?this.placeholder.show():this.placeholder.hide()},this),5)},show:function(){this.core.editor().addClass("redactor-placeholder")},update:function(t){this.opts.placeholder=t,this.core.editor().attr("placeholder",t)},hide:function(){this.core.editor().removeClass("redactor-placeholder")},is:function(){return this.core.editor().hasClass("redactor-placeholder")},init:function(){this.placeholder.enabled()&&(this.utils.isEditorRelative()||this.utils.setEditorRelative(),this.placeholder.build(),this.placeholder.buildPosition(),this.placeholder.enable(),this.placeholder.enableEvents())},enabled:function(){return this.opts.placeholder?this.core.element().attr("placeholder",this.opts.placeholder):this.placeholder.isAttr()},enableEvents:function(){this.core.editor().on("keydown.redactor-placeholder."+this.uuid,t.proxy(this.placeholder.enable,this))},disableEvents:function(){this.core.editor().off(".redactor-placeholder."+this.uuid)},build:function(){this.core.editor().attr("placeholder",this.core.element().attr("placeholder"))},buildPosition:function(){var e=t("<style />");e.addClass("redactor-placeholder-style-tag"),e.html("#"+this.core.id()+".redactor-placeholder::after "+this.placeholder.getPosition()),t("head").append(e)},getPosition:function(){return"{ top: "+this.core.editor().css("padding-top")+"; left: "+this.core.editor().css("padding-left")+"; }"},isEditorEmpty:function(){var e=t.trim(this.core.editor().html()).replace(/[\t\n]/g,""),i=["","<p>​</p>","<p>​<br></p>",this.opts.emptyHtmlRendered];return-1!==t.inArray(e,i)},isAttr:function(){return void 0!==this.core.element().attr("placeholder")&&""!==this.core.element().attr("placeholder")},destroy:function(){this.core.editor().removeAttr("placeholder"),this.placeholder.hide(),this.placeholder.disableEvents(),t(".redactor-placeholder-style-tag").remove()}}},progress:function(){return{$box:null,$bar:null,target:document.body,show:function(){this.progress.is()?this.progress.$box.show():(this.progress.build(),this.progress.$box.redactorAnimation("fadeIn"))},hide:function(){this.progress.is()&&this.progress.$box.redactorAnimation("fadeOut",{duration:.35},t.proxy(this.progress.destroy,this))},update:function(t){this.progress.show(),this.progress.$bar.css("width",t+"%")},is:function(){return null!==this.progress.$box},build:function(){this.progress.$bar=t("<span />"),this.progress.$box=t('<div id="redactor-progress" />'),this.progress.$box.append(this.progress.$bar),t(this.progress.target).append(this.progress.$box)},destroy:function(){this.progress.is()&&this.progress.$box.remove(),this.progress.$box=null,this.progress.$bar=null}}},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 e=this.selection.range();if(null!==e){var i=e.startContainer.parentNode;if(t(i).hasClass("redactor-in")||0!==t(i).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(e){for(e=e||this.selection.current();e;){if(this.utils.isBlockTag(e.tagName))return!t(e).hasClass("redactor-in")&&e;e=e.parentNode}return!1},inline:function(e){for(e=e||this.selection.current();e;){if(this.utils.isInlineTag(e.tagName))return!t(e).hasClass("redactor-in")&&e;e=e.parentNode}return!1},element:function(e){for(e||(e=this.selection.current());e;){if(1===e.nodeType)return!t(e).hasClass("redactor-in")&&e;e=e.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(e){var i=[],r=this.selection.nodes(e);t.each(r,t.proxy(function(t,e){this.utils.isBlock(e)&&i.push(e)},this));var o=this.selection.block();return 0===i.length&&!1===o?[]:0===i.length&&!1!==o?[o]:i},inlines:function(e){var i=[],r=this.selection.nodes(e);t.each(r,t.proxy(function(t,e){this.utils.isInline(e)&&i.push(e)},this));var o=this.selection.inline();return 0===i.length&&!1===o?[]:0===i.length&&!1!==o?[o]:i},nodes:function(e){var i=void 0===e?[]:t.isArray(e)?e:[e],r=this.selection.get(),o=this.selection.range(r),s=[],n=[];if(this.utils.isCollapsed())s=[this.selection.current()];else{var a=o.startContainer,l=o.endContainer;if(a===l)return[this.selection.parent()];for(;a&&a!==l;)s.push(a=this.selection.nextNode(a));for(a=o.startContainer;a&&a!==o.commonAncestorContainer;)s.unshift(a),a=a.parentNode}return t.each(s,function(e,r){if(r){var o=1===r.nodeType&&r.tagName.toLowerCase();if(t(r).hasClass("redactor-script-tag")||t(r).hasClass("redactor-selection-marker"))return;if(o&&0!==i.length&&-1===t.inArray(o,i))return;n.push(r)}}),0===n.length?[]:n},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 o=r.toString().length;return this.saved={start:o,end:o+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=this.core.editor()[0],r=i.ownerDocument,o=r.defaultView,s=0,n=r.createRange();n.setStart(i,0),n.collapse(!0);for(var a,l=[i],c=!1,d=!1;!d&&(a=l.pop());)if(3==a.nodeType){var h=s+a.length;!c&&this.saved.start>=s&&this.saved.start<=h&&(n.setStart(a,this.saved.start-s),c=!0),c&&this.saved.end>=s&&this.saved.end<=h&&(n.setEnd(a,this.saved.end-s),d=!0),s=h}else for(var u=a.childNodes.length;u--;)l.push(a.childNodes[u]);var p=o.getSelection();p.removeAllRanges(),p.addRange(n)}else try{(n=document.createRange()).setStart(e[0],0),(p=window.getSelection()).removeAllRanges(),p.addRange(n)}catch(t){}}},node:function(e){t(e).prepend(this.marker.get(1)),t(e).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,o=0;o<r;++o)i.appendChild(e.getRangeAt(o).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(e,i){if(!1===this.opts.shortcuts)return!e.ctrlKey&&!e.metaKey||66!==i&&73!==i||e.preventDefault(),!1;t.each(this.opts.shortcuts,t.proxy(function(t,i){this.shortcuts.build(e,t,i)},this))},build:function(e,i,r){for(var o=t.proxy(function(){this.shortcuts.buildHandler(r)},this),s=i.split(","),n=s.length,a=0;a<n;a++)"string"==typeof s[a]&&this.shortcuts.handler(e,t.trim(s[a]),o)},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(e,i,r){i=i.toLowerCase().split(" ");var o=this.shortcuts.hotkeysSpecialKeys[e.keyCode],s=String.fromCharCode(e.which).toLowerCase(),n="",a={};t.each(["alt","ctrl","meta","shift"],function(t,i){e[i+"Key"]&&o!==i&&(n+=i+"+")}),o&&(a[n+o]=!0),s&&(a[n+s]=!0,a[n+this.shortcuts.hotkeysShiftNums[s]]=!0,"shift+"===n&&(a[this.shortcuts.hotkeysShiftNums[s]]=!0));for(var l=i.length,c=0;c<l;c++)if(a[i[c]])return e.preventDefault(),r.apply(this,arguments)}}},storage:function(){return{data:[],add:function(t){t.status=!0,t.url=decodeURI(t.url),this.storage.data[t.url]=t},status:function(t,e){this.storage.data[decodeURI(t)].status=e},observe:function(){var e=this;this.core.editor().find("[data-image]").each(function(i,r){e.storage.add({type:"image",node:r,url:r.src,id:t(r).attr("data-image")})}),this.core.editor().find("[data-file]").each(function(i,r){e.storage.add({type:"file",node:r,url:r.href,id:t(r).attr("data-file")})}),this.core.editor().find("[data-s3]").each(function(i,r){var o="IMG"===r.tagName?r.src:r.href;e.storage.add({type:"s3",node:r,url:o,id:t(r).attr("data-s3")})})},changes:function(){for(var t in this.storage.data){var e=this.storage.data[t],i="IMG"===e.node.tagName?"src":"href";0===this.core.editor().find("[data-"+e.type+"]["+i+'="'+e.url+'"]').length?this.storage.status(e.url,!1):this.storage.status(e.url,!0)}return this.storage.data}}},toolbar:function(){return{build:function(){this.button.hideButtons(),this.button.hideButtonsOnMobile(),this.$toolbar=this.toolbar.createContainer(),this.toolbar.append(),this.button.$toolbar=this.$toolbar,this.button.setFormatting(),this.button.load(this.$toolbar),this.toolbar.setOverflow(),this.toolbar.setFixed()},createContainer:function(){return t("<ul>").addClass("redactor-toolbar").attr({id:"redactor-toolbar-"+this.uuid,role:"toolbar"})},append:function(){this.opts.toolbarExternal?(this.$toolbar.addClass("redactor-toolbar-external"),t(this.opts.toolbarExternal).html(this.$toolbar)):"textarea"===this.opts.type?this.$box.prepend(this.$toolbar):this.$element.before(this.$toolbar)},setOverflow:function(){this.opts.toolbarOverflow&&this.$toolbar.addClass("redactor-toolbar-overflow")},setFixed:function(){if(this.opts.toolbarFixed&&!this.opts.toolbarExternal){if(this.opts.toolbarFixedTarget!==document){var e=t(this.opts.toolbarFixedTarget);this.toolbar.toolbarOffsetTop=0===e.length?0:this.core.box().offset().top-e.offset().top}var i=0!==this.core.box().closest(".modal-body").length?1e3:0;setTimeout(t.proxy(function(){var e=this;this.toolbar.observeScroll(!1),this.detect.isDesktop()?t(this.opts.toolbarFixedTarget).on("scroll.redactor."+this.uuid,function(){e.core.editor().height()<100||e.placeholder.isEditorEmpty()||e.toolbar.observeScroll()}):t(this.opts.toolbarFixedTarget).on("scroll.redactor."+this.uuid,function(){e.core.editor().height()<100||e.placeholder.isEditorEmpty()||(e.core.toolbar().hide(),clearTimeout(t.data(this,"scrollCheck")),t.data(this,"scrollCheck",setTimeout(function(){e.core.toolbar().show(),e.toolbar.observeScroll()},250)))})},this),i)}},setUnfixed:function(){this.toolbar.observeScrollDisable()},getBoxTop:function(){return this.opts.toolbarFixedTarget===document?this.core.box().offset().top:this.toolbar.toolbarOffsetTop},observeScroll:function(e){var i=0;!1!==e&&(i=this.opts.toolbarFixedTarget===document?20:0);var r=t(this.opts.toolbarFixedTarget).scrollTop(),o=this.toolbar.getBoxTop();r!==o&&(r+this.opts.toolbarFixedTopOffset+i>o?this.toolbar.observeScrollEnable(r,o):this.toolbar.observeScrollDisable())},observeScrollResize:function(){this.$toolbar.css({width:this.core.box().innerWidth(),left:this.core.box().offset().left})},observeScrollEnable:function(e,i){if(void 0===this.fullscreen||!1!==this.fullscreen.isOpened){var r=i+this.core.box().outerHeight()-32,o=this.core.box().innerWidth(),s=this.detect.isDesktop()?"fixed":"absolute",n=this.detect.isDesktop()?this.opts.toolbarFixedTopOffset:t(this.opts.toolbarFixedTarget).scrollTop()-i+this.opts.toolbarFixedTopOffset,a=this.detect.isDesktop()?this.core.box().offset().left:0;this.opts.toolbarFixedTarget!==document&&(s="absolute",n=this.opts.toolbarFixedTopOffset+t(this.opts.toolbarFixedTarget).scrollTop()-i,a=0),this.$toolbar.addClass("toolbar-fixed-box"),this.$toolbar.css({position:s,width:o,top:n,left:a}),e>r&&t(".redactor-dropdown-"+this.uuid+":visible").hide(),this.toolbar.setDropdownsFixed(),this.$toolbar.css("visibility",e<r?"visible":"hidden"),t(window).on("resize.redactor-toolbar."+this.uuid,t.proxy(this.toolbar.observeScrollResize,this))}else this.toolbar.observeScrollDisable()},observeScrollDisable:function(){this.$toolbar.css({position:"relative",width:"auto",top:0,left:0,visibility:"visible"}),this.toolbar.unsetDropdownsFixed(),this.$toolbar.removeClass("toolbar-fixed-box"),t(window).off("resize.redactor-toolbar."+this.uuid)},setDropdownsFixed:function(){var t=this.opts.toolbarFixedTarget===document&&this.detect.isDesktop()?"fixed":"absolute";this.toolbar.setDropdownPosition(t)},unsetDropdownsFixed:function(){this.toolbar.setDropdownPosition("absolute")},setDropdownPosition:function(e){var i=this;t(".redactor-dropdown-"+this.uuid).each(function(){var r=t(this),o=i.button.get(r.attr("rel")),s="fixed"===e?i.opts.toolbarFixedTopOffset:o.offset().top;r.css({position:e,top:o.innerHeight()+s+"px"})})}}},upload:function(){return{init:function(e,i,r){this.upload.direct=!1,this.upload.callback=r,this.upload.url=i,this.upload.$el=t(e),this.upload.$droparea=t('<div id="redactor-droparea" />'),this.upload.$placeholdler=t('<div id="redactor-droparea-placeholder" />').text(this.lang.get("upload-label")),this.upload.$input=t('<input type="file" name="file" multiple />'),this.upload.$placeholdler.append(this.upload.$input),this.upload.$droparea.append(this.upload.$placeholdler),this.upload.$el.append(this.upload.$droparea),this.upload.$droparea.off("redactor.upload"),this.upload.$input.off("redactor.upload"),this.upload.$droparea.on("dragover.redactor.upload",t.proxy(this.upload.onDrag,this)),this.upload.$droparea.on("dragleave.redactor.upload",t.proxy(this.upload.onDragLeave,this)),this.upload.$input.on("change.redactor.upload",t.proxy(function(t){t=t.originalEvent||t;for(var e=this.upload.$input[0].files.length,i=0;i<e;i++){var r=e-1-i;this.upload.traverseFile(this.upload.$input[0].files[r],t)}},this)),this.upload.$droparea.on("drop.redactor.upload",t.proxy(function(t){t.preventDefault(),this.upload.$droparea.removeClass("drag-hover").addClass("drag-drop"),this.upload.onDrop(t)},this))},directUpload:function(t,e){this.upload.direct=!0,this.upload.traverseFile(t,e)},onDrop:function(t){var e=(t=t.originalEvent||t).dataTransfer.files;if(this.opts.multipleImageUpload)for(var i=e.length,r=0;r<i;r++)this.upload.traverseFile(e[r],t);else this.upload.traverseFile(e[0],t)},traverseFile:function(t,e){if(this.opts.s3)return this.upload.setConfig(t),void this.uploads3.send(t,e);var i=window.FormData?new FormData:null;if(window.FormData){this.upload.setConfig(t);var r="image"===this.upload.type?this.opts.imageUploadParam:this.opts.fileUploadParam;i.append(r,t)}this.progress.show(),!1!==this.core.callback("uploadStart",e,i)&&this.upload.send(i,e)},setConfig:function(t){this.upload.getType(t),this.upload.direct&&(this.upload.url="image"===this.upload.type?this.opts.imageUpload:this.opts.fileUpload,this.upload.callback="image"===this.upload.type?this.image.insert:this.file.insert)},getType:function(t){this.upload.type=-1===this.opts.imageTypes.indexOf(t.type)?"file":"image",null===this.opts.imageUpload&&null!==this.opts.fileUpload&&(this.upload.type="file")},getHiddenFields:function(e,i){return!1===e||"object"!=typeof e?i:(t.each(e,t.proxy(function(e,r){null!==r&&0===r.toString().indexOf("#")&&(r=t(r).val()),i.append(e,r)},this)),i)},send:function(e,i){"image"===this.upload.type?(e=this.utils.appendFields(this.opts.imageUploadFields,e),e=this.utils.appendForms(this.opts.imageUploadForms,e),e=this.upload.getHiddenFields(this.upload.imageFields,e)):(e=this.utils.appendFields(this.opts.fileUploadFields,e),e=this.utils.appendForms(this.opts.fileUploadForms,e),e=this.upload.getHiddenFields(this.upload.fileFields,e));var r=new XMLHttpRequest;r.open("POST",this.upload.url),r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.onreadystatechange=t.proxy(function(){if(4===r.readyState){var t=r.responseText;t=(t=t.replace(/^\[/,"")).replace(/\]$/,"");var e;try{e="string"==typeof t?JSON.parse(t):t}catch(t){e={error:!0}}this.progress.hide(),this.upload.direct||this.upload.$droparea.removeClass("drag-drop"),this.upload.callback(e,this.upload.direct,i)}},this),!1!==this.core.callback("uploadBeforeSend",r)&&r.send(e)},onDrag:function(t){t.preventDefault(),this.upload.$droparea.addClass("drag-hover")},onDragLeave:function(t){t.preventDefault(),this.upload.$droparea.removeClass("drag-hover")},clearImageFields:function(){this.upload.imageFields={}},addImageFields:function(t,e){this.upload.imageFields[t]=e},removeImageFields:function(t){delete this.upload.imageFields[t]},clearFileFields:function(){this.upload.fileFields={}},addFileFields:function(t,e){this.upload.fileFields[t]=e},removeFileFields:function(t){delete this.upload.fileFields[t]}}},uploads3:function(){return{send:function(e,i){this.uploads3.executeOnSignedUrl(e,t.proxy(function(t){this.uploads3.sendToS3(e,t,i)},this))},executeOnSignedUrl:function(t,e){var i=new XMLHttpRequest,r=-1===this.opts.s3.search(/\?/)?"?":"&";i.open("GET",this.opts.s3+r+"name="+t.name+"&type="+t.type,!0),i.overrideMimeType&&i.overrideMimeType("text/plain; charset=x-user-defined");var o=this;i.onreadystatechange=function(t){4===this.readyState&&200===this.status&&(o.progress.show(),e(decodeURIComponent(this.responseText)))},i.send()},createCORSRequest:function(t,e){var i=new XMLHttpRequest;return"withCredentials"in i?i.open(t,e,!0):"undefined"!=typeof XDomainRequest?(i=new XDomainRequest).open(t,e):i=null,i},sendToS3:function(e,i,r){var o=this.uploads3.createCORSRequest("PUT",i);o&&(o.onload=t.proxy(function(){var t;if(this.progress.hide(),200!==o.status)return t={error:!0},void this.upload.callback(t,this.upload.direct,o);var e=i.split("?");if(!e[0])return!1;if(this.upload.direct||this.upload.$droparea.removeClass("drag-drop"),t={url:e[0],id:e[0],s3:!0},"file"===this.upload.type){var s=e[0].split("/");t.name=s[s.length-1]}this.upload.callback(t,this.upload.direct,r)},this),o.onerror=function(){},o.upload.onprogress=function(t){},o.setRequestHeader("Content-Type",e.type),o.setRequestHeader("x-amz-acl","public-read"),o.send(e))}}},utils:function(){return{isEmpty:function(e){return e=void 0===e?this.core.editor().html():e,e=e.replace(/[\u200B-\u200D\uFEFF]/g,""),e=e.replace(/&nbsp;/gi,""),e=e.replace(/<\/?br\s?\/?>/g,""),e=e.replace(/\s/g,""),e=e.replace(/^<p>[^\W\w\D\d]*?<\/p>$/i,""),e=e.replace(/<iframe(.*?[^>])>$/i,"iframe"),e=e.replace(/<source(.*?[^>])>$/i,"source"),e=e.replace(/<[^\/>][^>]*><\/[^>]+>/gi,""),e=e.replace(/<[^\/>][^>]*><\/[^>]+>/gi,""),""===(e=t.trim(e))},isElement:function(t){try{return t instanceof HTMLElement}catch(e){return"object"==typeof t&&1===t.nodeType&&"object"==typeof t.style&&"object"==typeof t.ownerDocument}},strpos:function(t,e,i){var r=t.indexOf(e,i);return r>=0&&r},dataURItoBlob:function(t){var e;e=t.split(",")[0].indexOf("base64")>=0?atob(t.split(",")[1]):unescape(t.split(",")[1]);for(var i=t.split(",")[0].split(":")[1].split(";")[0],r=new Uint8Array(e.length),o=0;o<e.length;o++)r[o]=e.charCodeAt(o);return new Blob([r],{type:i})},getOuterHtml:function(e){return t("<div>").append(t(e).eq(0).clone()).html()},cloneAttributes:function(e,i){e=e[0]||e,i=t(i);for(var r=e.attributes,o=r.length;o--;){var s=r[o];i.attr(s.name,s.value)}return i},breakBlockTag:function(){var e=this.selection.block();if(!e)return!1;var i=this.utils.isEmpty(e.innerHTML),r=e.tagName.toLowerCase();if("pre"===r||"li"===r||"td"===r||"th"===r)return!1;if(!i&&this.utils.isStartOfElement(e))return{$block:t(e),$next:t(e).next(),type:"start"};if(!i&&this.utils.isEndOfElement(e))return{$block:t(e),$next:t(e).next(),type:"end"};var o=this.selection.extractEndOfNode(e),s=t("<"+r+" />").append(o);return s=this.utils.cloneAttributes(e,s),t(e).after(s),{$block:t(e),$next:s,type:"break"}},inBlocks:function(e){e=t.isArray(e)?e:[e];for(var i=this.selection.blocks(),r=i.length,o=!1,s=0;s<r;s++)if(!1!==i[s]){var n=i[s].tagName.toLowerCase();-1!==t.inArray(n,e)&&(o=!0)}return o},inInlines:function(e){e=t.isArray(e)?e:[e];for(var i=this.selection.inlines(),r=i.length,o=!1,s=0;s<r;s++){var n=i[s].tagName.toLowerCase();-1!==t.inArray(n,e)&&(o=!0)}return o},isTag:function(e,i){var r=t(e).closest(i,this.core.editor()[0]);return 1===r.length&&r[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(e){return!!e&&(0!==t(e).parents(".redactor-in").length&&!t(e).hasClass("redactor-in")&&e)},isCurrentOrParentHeader:function(){return this.utils.isCurrentOrParent(["H1","H2","H3","H4","H5","H6"])},isCurrentOrParent:function(e){var i=this.selection.parent(),r=this.selection.current();if(t.isArray(e)){var o=0;return t.each(e,t.proxy(function(t,e){this.utils.isCurrentOrParentOne(r,i,e)&&o++},this)),0!==o}return this.utils.isCurrentOrParentOne(r,i,e)},isCurrentOrParentOne:function(t,e,i){return i=i.toUpperCase(),e&&e.tagName===i?e:!(!t||t.tagName!==i)&&t},isEditorRelative:function(){var e=this.core.editor().css("position"),i=["absolute","fixed","relative"];return-1!==t.inArray(i,e)},setEditorRelative:function(){this.core.editor().addClass("redactor-relative")},getScrollTarget:function(){var e=t(this.opts.scrollTarget);return 0!==e.length?e:t(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(e){if(void 0===e&&!(e=this.selection.block()))return!1;var i=t.trim(t(e).text()).replace(/[\t\n\r\n]/g,"").replace(/\u200B/g,"");return this.offset.get(e)===i.length},removeEmptyAttr:function(e,i){var r=t(e);return void 0===r.attr(i)||""===r.attr(i)&&(r.removeAttr(i),!0)},replaceToTag:function(e,i){var r;return t(e).replaceWith(function(){r=t("<"+i+" />").append(t(this).contents());for(var e=0;e<this.attributes.length;e++)r.attr(this.attributes[e].name,this.attributes[e].value);return r}),r},isSelectAll:function(){return this.selectAll},enableSelectAll:function(){this.selectAll=!0},disableSelectAll:function(){this.selectAll=!1},disableBodyScroll:function(){var e=t("html"),i=window.innerWidth;if(!i){var r=document.documentElement.getBoundingClientRect();i=r.right-Math.abs(r.left)}var o=document.body.clientWidth<i,s=this.utils.measureScrollbar();e.css("overflow","hidden"),o&&e.css("padding-right",s)},measureScrollbar:function(){var e=t("body"),i=document.createElement("div");i.className="redactor-scrollbar-measure",e.append(i);var r=i.offsetWidth-i.clientWidth;return e[0].removeChild(i),r},enableBodyScroll:function(){t("html").css({overflow:"","padding-right":""}),t("body").remove("redactor-scrollbar-measure")},appendFields:function(e,i){if(!e)return i;if("object"==typeof e)return t.each(e,function(e,r){null!==r&&0===r.toString().indexOf("#")&&(r=t(r).val()),i.append(e,r)}),i;var r=t(e);if(0===r.length)return i;return r.each(function(){i.append(t(this).attr("name"),t(this).val())}),i},appendForms:function(e,i){if(!e)return i;var r=t(e);if(0===r.length)return i;var o=r.serializeArray();return t.each(o,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),t&&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()}}}},t(window).on("load.tools.redactor",function(){t('[data-tools="redactor"]').redactor()}),e.prototype.init.prototype=e.prototype}(jQuery),function(t){function e(e,i,r,o){var s={duration:.5,iterate:1,delay:0,prefix:"redactor-",timing:"linear"};this.animation=i,this.slide="slideDown"===this.animation||"slideUp"===this.animation,this.$element=t(e),this.prefixes=["","-moz-","-o-animation-","-webkit-"],this.queue=[],"function"==typeof r?(o=r,this.opts=s):this.opts=t.extend(s,r),this.slide&&this.$element.height(this.$element.height()),this.init(o)}t.fn.redactorAnimation=function(t,i,r){return this.each(function(){new e(this,t,i,r)})},e.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(e){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 i=this.queue.length>1?null:e;this.complete("AnimationEnd",t.proxy(function(){this.$element.hasClass(this.opts.prefix+this.queue[0])&&(this.clean(),this.queue.shift(),this.queue.length&&this.animate(e))},this),i)},set:function(t,e,i,r){for(var o=this.prefixes.length;o--;)this.$element.css(this.prefixes[o]+"animation-duration",t),this.$element.css(this.prefixes[o]+"animation-delay",e),this.$element.css(this.prefixes[o]+"animation-iteration-count",i),this.$element.css(this.prefixes[o]+"animation-timing-function",r)},clean:function(){this.$element.removeClass("redactor-animated"),this.$element.removeClass(this.opts.prefix+this.queue[0]),this.set("","","","")},complete:function(e,i,r){this.$element.one(e.toLowerCase()+" webkit"+e+" o"+e+" MS"+e,t.proxy(function(){"function"==typeof i&&i(),"function"==typeof r&&r(this);var e=["fadeOut","slideUp","zoomOut","slideOutUp","slideOutRight","slideOutLeft"];-1!==t.inArray(this.animation,e)&&this.$element.css("display","none"),this.slide&&this.$element.css("height","")},this))}}}(jQuery);
\ No newline at end of file