(function($){var uuid=0,Range=function(t){return this[0]=t.startOffset,this[1]=t.endOffset,this.range=t,this};Range.prototype.equals=function(){return this[0]===this[1]};var reUrlYoutube=/https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/gi,reUrlVimeo=/https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/,reUrlFacebook=/^(?:(?:https|http)?:\/\/)?(?:www\.)?(?:facebook\.com(?:\/[^\/]+\/videos\/|\/video\.php\?v=))([0-9]+)(?:.+)?$/,reUrlRutube=/^(?:(?:https|http)?:\/\/)?(?:www\.)?(?:rutube\.ru\/video\/)([a-z0-9]+)(?:.+)?$/;function Redactor(t,e){return new Redactor.prototype.init(t,e)}$.fn.redactor=function(t){var e=[],i=Array.prototype.slice.call(arguments,1);return"string"==typeof t?this.each((function(){var s=$.data(this,"redactor");if(void 0===s||!$.isFunction(s[t]))return $.error('No such method "'+t+'" for Redactor');var o=s[t].apply(s,i);void 0!==o&&o!==s&&e.push(o)})):this.each((function(){$.data(this,"redactor")||$.data(this,"redactor",Redactor(this,t))})),0===e.length?this:1===e.length?e[0]:e},$.Redactor=Redactor,$.Redactor.VERSION="9.2.6",$.Redactor.opts={rangy:!1,iframe:!1,fullpage:!1,css:!1,lang:"en",direction:"ltr",placeholder:!1,typewriter:!1,wym:!1,mobile:!0,cleanup:!0,tidyHtml:!0,pastePlainText:!1,removeEmptyTags:!0,cleanSpaces:!0,cleanFontTag:!0,templateVars:!1,xhtml:!1,visual:!0,focus:!1,tabindex:!1,autoresize:!0,minHeight:!1,maxHeight:!1,shortcuts:{"ctrl+m, meta+m":"this.execCommand('removeFormat', false)","ctrl+b, meta+b":"this.execCommand('bold', false)","ctrl+i, meta+i":"this.execCommand('italic', false)","ctrl+h, meta+h":"this.execCommand('superscript', false)","ctrl+l, meta+l":"this.execCommand('subscript', false)","ctrl+k, meta+k":"this.linkShow()","ctrl+shift+7":"this.execCommand('insertorderedlist', false)","ctrl+shift+8":"this.execCommand('insertunorderedlist', false)"},shortcutsAdd:!1,autosave:!1,autosaveInterval:60,plugins:!1,linkProtocol:"http://",linkNofollow:!1,linkSize:50,predefinedLinks:!1,imageFloatMargin:"10px",imageGetJson:!1,dragUpload:!0,imageTabLink:!0,imageUpload:!1,imageUploadParam:"file",imageResizable:!0,fileUpload:!1,fileUploadParam:"file",clipboardUpload:!0,clipboardUploadUrl:!1,smilesUrl:"",dnbImageTypes:["image/png","image/jpeg","image/gif"],s3:!1,uploadFields:!1,observeImages:!0,observeLinks:!0,modalOverlay:!0,tabSpaces:!1,tabFocus:!0,air:!1,airButtons:["formatting","bold","italic","deleted","unorderedlist","orderedlist","outdent","indent"],toolbar:!0,toolbarFixed:!1,toolbarFixedTarget:document,toolbarFixedTopOffset:0,toolbarFixedBox:!1,toolbarExternal:!1,toolbarOverflow:!1,buttonSource:!0,buttons:["html","undo","redo","formatting","bold","italic","deleted","unorderedlist","orderedlist","outdent","indent","image","video","file","table","link","alignment","|","horizontalrule"],buttonsHideOnMobile:[],activeButtons:["deleted","italic","bold","underline","unorderedlist","orderedlist","alignleft","aligncenter","alignright","justify","table"],activeButtonsStates:{b:"bold",strong:"bold",i:"italic",em:"italic",del:"deleted",strike:"deleted",ul:"unorderedlist",ol:"orderedlist",u:"underline",tr:"table",td:"table",table:"table"},formattingTags:["p","blockquote","code","h2","h3","h4","h5","h6"],linebreaks:!1,paragraphy:!0,convertDivs:!0,convertLinks:!0,convertImageLinks:!1,convertVideoLinks:!1,formattingPre:!1,phpTags:!1,allowedTags:!1,deniedTags:["html","head","link","body","meta","script","style","applet"],boldTag:"strong",italicTag:"em",indentValue:20,buffer:[],rebuffer:[],textareamode:!1,emptyHtml:"<p>​</p>",invisibleSpace:"​",rBlockTest:/^(P|H[1-6]|LI|ADDRESS|SECTION|HEADER|FOOTER|ASIDE|ARTICLE)$/i,alignmentTags:["P","H1","H2","H3","H4","H5","H6","DD","DL","DT","DIV","TD","BLOCKQUOTE","OUTPUT","FIGCAPTION","ADDRESS","SECTION","HEADER","FOOTER","ASIDE","ARTICLE"],ownLine:["area","body","head","hr","i?frame","link","meta","noscript","style","script","table","tbody","thead","tfoot"],contOwnLine:["li","dt","dt","h[1-6]","option","script"],newLevel:["blockquote","div","dl","fieldset","form","frameset","map","ol","p","code","select","td","th","tr","ul"],blockLevelElements:["P","H1","H2","H3","H4","H5","H6","DD","DL","DT","DIV","LI","BLOCKQUOTE","OUTPUT","FIGCAPTION","CODE","ADDRESS","SECTION","HEADER","FOOTER","ASIDE","ARTICLE","TD"],langs:{en:{html:"HTML",video:"Insert Video",image:"Insert Image",table:"Table",link:"Link",link_insert:"Insert link",link_edit:"Edit link",unlink:"Unlink",formatting:"Formatting",paragraph:"Normal text",quote:"Quote",code:"Code",header1:"Header 1",header2:"Header 2",header3:"Header 3",header4:"Header 4",header5:"Header 5",bold:"Bold",italic:"Italic",fontcolor:"Font Color",backcolor:"Back Color",unorderedlist:"Unordered List",orderedlist:"Ordered List",outdent:"Outdent",indent:"Indent",cancel:"Cancel",insert:"Insert",save:"Save",_delete:"Delete",insert_table:"Insert Table",insert_row_above:"Add Row Above",insert_row_below:"Add Row Below",insert_column_left:"Add Column Left",insert_column_right:"Add Column Right",delete_column:"Delete Column",delete_row:"Delete Row",delete_table:"Delete Table",rows:"Rows",columns:"Columns",add_head:"Add Head",delete_head:"Delete Head",title:"Title",image_position:"Position",none:"None",left:"Left",right:"Right",center:"Center",image_web_link:"Image Web Link",text:"Text",mailto:"Email",web:"URL",video_html_code:"Video Embed Code",file:"Insert File",upload:"Upload",download:"Download",choose:"Choose",empty_img_list:"You have no images",or_choose:"Or choose",drop_file_here:"Drop file here",align_left:"Align text to the left",align_center:"Center text",align_right:"Align text to the right",align_justify:"Justify text",horizontalrule:"Insert Horizontal Rule",fullscreen:"Full screen",fontsize:"Font size",fontfamily:"Font",remove_font:"Clear Font",image_save_toserver:"Save to the server?",deleted:"Deleted",anchor:"Anchor",link_new_tab:"Open link in new tab",underline:"Underline",alignment:"Alignment",filename:"Name (optional)",edit:"Edit",spoiler:"Spoiler",spoiler_name:"Spoiler name",spoiler_text:"Spoiler text",smiles:"Smiles",undo:"Undo",redo:"Redo",formalize:"Formalize"}}},Redactor.fn=$.Redactor.prototype={keyCode:{BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,ESC:27,TAB:9,CTRL:17,META:91,LEFT:37,LEFT_WIN:91},init:function(t,e){this.rtePaste=!1,this.$element=this.$source=$(t),this.uuid=uuid++;var i=$.extend(!0,{},$.Redactor.opts);if(this.opts=$.extend({},i,this.$element.data(),e),this.start=!0,this.dropdowns=[],this.sourceHeight=this.$source.css("height"),this.sourceWidth=this.$source.css("width"),this.opts.fullpage&&(this.opts.iframe=!0),this.opts.linebreaks&&(this.opts.paragraphy=!1),this.opts.paragraphy&&(this.opts.linebreaks=!1),this.opts.toolbarFixedBox&&(this.opts.toolbarFixed=!0),this.document=document,this.window=window,this.savedSel=!1,this.cleanlineBefore=new RegExp("^<(/?"+this.opts.ownLine.join("|/?")+"|"+this.opts.contOwnLine.join("|")+")[ >]"),this.cleanlineAfter=new RegExp("^<(br|/?"+this.opts.ownLine.join("|/?")+"|/"+this.opts.contOwnLine.join("|/")+")[ >]"),this.cleannewLevel=new RegExp("^</?("+this.opts.newLevel.join("|")+")[ >]"),this.rTestBlock=new RegExp("^("+this.opts.blockLevelElements.join("|")+")$","i"),!1===this.opts.linebreaks){if(!1!==this.opts.allowedTags){var s=["strong","em","del"],o=["b","i","strike"];"-1"===$.inArray("p",this.opts.allowedTags)&&this.opts.allowedTags.push("p");for(let t in s)"-1"!=$.inArray(s[t],this.opts.allowedTags)&&this.opts.allowedTags.push(o[t])}if(!1!==this.opts.deniedTags){var r=$.inArray("p",this.opts.deniedTags);"-1"!==r&&this.opts.deniedTags.splice(r,r)}}(this.browser("msie")||this.browser("opera"))&&(this.opts.buttons=this.removeFromArrayByValue(this.opts.buttons,"horizontalrule")),this.opts.curLang=this.opts.langs[this.opts.lang],$.extend(this.opts.shortcuts,this.opts.shortcutsAdd),this.placeholderInit(),this.buildStart()},toolbarInit:function(t){return{html:{title:t.html,func:"toggle"},undo:{title:t.undo,func:"bufferUndo"},redo:{title:t.redo,func:"bufferRedo"},formatting:{title:t.formatting,func:"show",dropdown:{p:{title:t.paragraph,func:"formatBlocks"},blockquote:{title:t.quote,func:"formatQuote",className:"redactor_format_blockquote"},code:{title:t.code,func:"formatBlocks",className:"redactor_format_code"},h1:{title:t.header1,func:"formatBlocks",className:"redactor_format_h1"},h2:{title:t.header2,func:"formatBlocks",className:"redactor_format_h2"},h3:{title:t.header3,func:"formatBlocks",className:"redactor_format_h3"},h4:{title:t.header4,func:"formatBlocks",className:"redactor_format_h4"},h5:{title:t.header5,func:"formatBlocks",className:"redactor_format_h5"}}},bold:{title:t.bold,exec:"bold"},italic:{title:t.italic,exec:"italic"},deleted:{title:t.deleted,exec:"strikethrough"},underline:{title:t.underline,exec:"underline"},unorderedlist:{title:"• "+t.unorderedlist,exec:"insertunorderedlist"},orderedlist:{title:"1. "+t.orderedlist,exec:"insertorderedlist"},outdent:{title:"< "+t.outdent,func:"indentingOutdent"},indent:{title:"> "+t.indent,func:"indentingIndent"},image:{title:t.image,func:"imageShow"},video:{title:t.video,func:"videoShow"},file:{title:t.file,func:"fileShow"},table:{title:t.table,func:"show",dropdown:{insert_table:{title:t.insert_table,func:"tableShow"},separator_drop1:{name:"separator"},insert_row_above:{title:t.insert_row_above,func:"tableAddRowAbove"},insert_row_below:{title:t.insert_row_below,func:"tableAddRowBelow"},insert_column_left:{title:t.insert_column_left,func:"tableAddColumnLeft"},insert_column_right:{title:t.insert_column_right,func:"tableAddColumnRight"},separator_drop2:{name:"separator"},add_head:{title:t.add_head,func:"tableAddHead"},delete_head:{title:t.delete_head,func:"tableDeleteHead"},separator_drop3:{name:"separator"},delete_column:{title:t.delete_column,func:"tableDeleteColumn"},delete_row:{title:t.delete_row,func:"tableDeleteRow"},delete_table:{title:t.delete_table,func:"tableDeleteTable"}}},link:{title:t.link,func:"show",dropdown:{link:{title:t.link_insert,func:"linkShow"},unlink:{title:t.unlink,exec:"unlink"}}},alignment:{title:t.alignment,func:"show",dropdown:{alignleft:{title:t.align_left,func:"alignmentLeft"},aligncenter:{title:t.align_center,func:"alignmentCenter"},alignright:{title:t.align_right,func:"alignmentRight"},justify:{title:t.align_justify,func:"alignmentJustify"}}},alignleft:{title:t.align_left,func:"alignmentLeft"},aligncenter:{title:t.align_center,func:"alignmentCenter"},alignright:{title:t.align_right,func:"alignmentRight"},alignjustify:{title:t.align_justify,func:"alignmentJustify"},horizontalrule:{exec:"inserthorizontalrule",title:t.horizontalrule}}},callback:function(t,e,i){var s=this.opts[t+"Callback"];return $.isFunction(s)?!1===e?s.call(this,i):s.call(this,e,i):i},destroy:function(){clearInterval(this.autosaveInterval),$(window).off(".redactor"),this.$source.off("redactor-textarea"),this.$element.off(".redactor").removeData("redactor");var t=this.get();if(this.opts.textareamode)this.$box.after(this.$source),this.$box.remove(),this.$source.val(t).show();else{var e=this.$editor;this.opts.iframe&&(e=this.$element),this.$box.after(e),this.$box.remove(),e.removeClass("redactor_editor").removeClass("redactor_editor_wym").removeAttr("contenteditable").html(t).show()}this.opts.toolbarExternal&&$(this.opts.toolbarExternal).html(""),this.opts.air&&$("#redactor_air_"+this.uuid).remove()},getObject:function(){return $.extend({},this)},getEditor:function(){return this.$editor},getBox:function(){return this.$box},getIframe:function(){return!!this.opts.iframe&&this.$frame},getToolbar:function(){return!!this.$toolbar&&this.$toolbar},get:function(){return this.$source.val()},getCodeIframe:function(){this.$editor.removeAttr("contenteditable").removeAttr("dir");var t=this.outerHtml(this.$frame.contents().children());return this.$editor.attr({contenteditable:!0,dir:this.opts.direction}),t},set:function(t,e,i){t=(t=t.toString()).replace(/\$/g,"$"),this.opts.fullpage?this.setCodeIframe(t):this.setEditor(t,e),""==t&&(i=!1),!1!==i&&this.placeholderRemoveFromEditor()},setEditor:function(t,e){t=this.sanitizeHTML(t),!1!==e&&(t=this.cleanSavePreCode(t),t=this.cleanStripTags(t),t=this.cleanConvertProtected(t),t=this.cleanConvertInlineTags(t,!0),t=!1===this.opts.linebreaks?this.cleanConverters(t):t.replace(/<p(.*?)>([\w\W]*?)<\/p>/gi,"$2<br>")),t=t.replace(/&#36;/g,"$"),t=this.cleanEmpty(t),this.$editor.html(t),this.setNonEditable(),this.setSpansVerified(),this.sync()},sanitizeHTML:function(t){return HtmlSanitizer.SanitizeHtml(t)},setCodeIframe:function(t){var e=this.iframePage();this.$frame[0].src="about:blank",t=this.cleanConvertProtected(t),t=this.cleanConvertInlineTags(t),t=this.cleanRemoveSpaces(t),e.open(),e.write(t),e.close(),this.opts.fullpage&&(this.$editor=this.$frame.contents().find("body").attr({contenteditable:!0,dir:this.opts.direction})),this.setNonEditable(),this.setSpansVerified(),this.sync()},setFullpageOnInit:function(t){t=this.sanitizeHTML(t),this.fullpageDoctype=t.match(/^<\!doctype[^>]*>/i),this.fullpageDoctype&&1==this.fullpageDoctype.length&&(t=t.replace(/^<\!doctype[^>]*>/i,"")),t=this.cleanSavePreCode(t,!0),t=this.cleanConverters(t),t=this.cleanEmpty(t),this.$editor.html(t),this.setNonEditable(),this.setSpansVerified(),this.sync()},setFullpageDoctype:function(){if(this.fullpageDoctype&&1==this.fullpageDoctype.length){var t=this.fullpageDoctype[0]+"\n"+this.$source.val();this.$source.val(t)}},setSpansVerified:function(){var t=this.$editor.find("span"),e="inline";$.each(t,(function(){var t=this.outerHTML,i=new RegExp("<"+this.tagName,"gi"),s=t.replace(i,"<"+e);i=new RegExp("</"+this.tagName,"gi"),s=s.replace(i,"</"+e),$(this).replaceWith(s)}))},setSpansVerifiedHtml:function(t){return(t=t.replace(/<span(.*?)>/,"<inline$1>")).replace(/<\/span>/,"</inline>")},setNonEditable:function(){this.$editor.find(".noneditable").attr("contenteditable",!1)},sync:function(t){var e="";if(this.cleanUnverified(),e=this.opts.fullpage?this.getCodeIframe():this.$editor.html(),e=this.syncClean(e),e=this.cleanRemoveEmptyTags(e),this.cleanRemoveSpaces(this.$source.val(),!1)==this.cleanRemoveSpaces(e,!1))return!1;if(e=e.replace(/<\/li><(ul|ol)>([\w\W]*?)<\/(ul|ol)>/gi,"<$1>$2</$1></li>"),"<br>"===$.trim(e)&&(e=""),this.opts.xhtml){$.each(["br","hr","img","link","input","meta"],(function(t,i){e=e.replace(new RegExp("<"+i+"(.*?[^/$]?)>","gi"),"<"+i+"$1 />")}))}if(e=this.callback("syncBefore",!1,e),this.$source.val(e),this.setFullpageDoctype(),this.callback("syncAfter",!1,e),!1===this.start)if(void 0!==t)switch(t.which){case 37:case 38:case 39:case 40:break;default:this.callback("change",!1,e)}else this.callback("change",!1,e)},syncClean:function(t){return this.opts.fullpage||(t=this.cleanStripTags(t)),t=this.sanitizeHTML(t),t=$.trim(t),"<p></p>"!==(t=(t=(t=(t=(t=this.placeholderRemoveFromCode(t)).replace(/​/gi,"")).replace(/​/gi,"")).replace(/<\/a> /gi,"</a> ")).replace(/\u200B/g,""))&&"<p> </p>"!==t&&"<p> </p>"!==t||(t=""),this.opts.linkNofollow&&(t=(t=t.replace(/<a(.*?)rel="nofollow"(.*?)>/gi,"<a$1$2>")).replace(/<a(.*?)>/gi,'<a$1 rel="nofollow">')),t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace("\x3c!--?php","<?php")).replace("?--\x3e","?>")).replace(/<(.*?)class="noeditable"(.*?) contenteditable="false"(.*?)>/gi,'<$1class="noeditable"$2$3>')).replace(/ data-tagblock=""/gi,"")).replace(/<br\s?\/?>\n?<\/(P|H[1-6]|LI|ADDRESS|SECTION|HEADER|FOOTER|ASIDE|ARTICLE)>/gi,"</$1>")).replace(/<span(.*?)id="redactor-image-box"(.*?)>([\w\W]*?)<img(.*?)><\/span>/gi,"$3<img$4>")).replace(/<span(.*?)id="redactor-image-resizer"(.*?)>(.*?)<\/span>/gi,"")).replace(/<span(.*?)id="redactor-image-editter"(.*?)>(.*?)<\/span>/gi,"")).replace(/<(ul|ol)>\s*\t*\n*<\/(ul|ol)>/gi,""),this.opts.cleanFontTag&&(t=t.replace(/<font(.*?)>([\w\W]*?)<\/font>/gi,"$2")),t=(t=(t=(t=(t=t.replace(/<span(.*?)>([\w\W]*?)<\/span>/gi,"$2")).replace(/<inline>([\w\W]*?)<\/inline>/gi,"$1")).replace(/<inline>/gi,"<span>")).replace(/<inline /gi,"<span ")).replace(/<\/inline>/gi,"</span>"),this.opts.removeEmptyTags&&(t=t.replace(/<span>([\w\W]*?)<\/span>/gi,"$1")),t=(t=(t=(t=(t=(t=(t=(t=t.replace(/<span(.*?)class="redactor_placeholder"(.*?)>([\w\W]*?)<\/span>/gi,"")).replace(/<img(.*?)contenteditable="false"(.*?)>/gi,"<img$1$2>")).replace(/&/gi,"&")).replace(/\u2122/gi,"™")).replace(/\u00a9/gi,"©")).replace(/\u2026/gi,"…")).replace(/\u2014/gi,"—")).replace(/\u2010/gi,"‐"),t=this.cleanReConvertProtected(t)},buildStart:function(){this.content="",this.$box=$('<div class="redactor_box" />'),"TEXTAREA"===this.$source[0].tagName&&(this.opts.textareamode=!0),!1===this.opts.mobile&&this.isMobile()?this.buildMobile():(this.buildContent(),this.opts.iframe?(this.opts.autoresize=!1,this.iframeStart()):this.opts.textareamode?this.buildFromTextarea():this.buildFromElement(),this.opts.iframe||(this.buildOptions(),this.buildAfter()))},buildMobile:function(){this.opts.textareamode||(this.$editor=this.$source,this.$editor.hide(),this.$source=this.buildCodearea(this.$editor),this.$source.val(this.content)),this.$box.insertAfter(this.$source).append(this.$source)},buildContent:function(){this.opts.textareamode?this.content=$.trim(this.$source.val()):this.content=$.trim(this.$source.html())},buildFromTextarea:function(){this.$editor=$("<div />"),this.$box.insertAfter(this.$source).append(this.$editor).append(this.$source),this.buildAddClasses(this.$editor),this.buildEnable()},buildFromElement:function(){this.$editor=this.$source,this.$source=this.buildCodearea(this.$editor),this.$box.insertAfter(this.$editor).append(this.$editor).append(this.$source),this.buildEnable()},buildCodearea:function(t){return $("<textarea />").attr("name",t.attr("id")).css("height",this.sourceHeight)},buildAddClasses:function(t){$.each(this.$source.get(0).className.split(/\s+/),(function(e,i){t.addClass("redactor_"+i)}))},buildEnable:function(){this.$editor.addClass("redactor_editor").attr({contenteditable:!0,dir:this.opts.direction}),this.$source.attr("dir",this.opts.direction).hide(),this.set(this.content,!0,!1)},buildOptions:function(){var t=this.$editor;this.opts.iframe&&(t=this.$frame),this.opts.tabindex&&t.attr("tabindex",this.opts.tabindex),this.opts.minHeight?t.css("min-height",this.opts.minHeight+"px"):this.browser("mozilla")&&this.opts.linebreaks&&this.$editor.css("min-height","45px"),this.browser("mozilla")&&this.opts.linebreaks&&this.$editor.css("padding-bottom","10px"),this.opts.maxHeight&&(this.opts.autoresize=!1,this.sourceHeight=this.opts.maxHeight),this.opts.wym&&this.$editor.addClass("redactor_editor_wym"),this.opts.typewriter&&this.$editor.addClass("redactor-editor-typewriter"),this.opts.autoresize||t.css("height",this.sourceHeight)},buildAfter:function(){if(this.start=!1,this.opts.toolbar&&(this.opts.toolbar=this.toolbarInit(this.opts.curLang),this.toolbarBuild()),this.modalTemplatesInit(),this.buildPlugins(),this.buildBindKeyboard(),this.opts.autosave&&this.autosave(),setTimeout($.proxy(this.observeStart,this),4),this.browser("mozilla"))try{this.document.execCommand("enableObjectResizing",!1,!1),this.document.execCommand("enableInlineTableEditing",!1,!1)}catch(t){}this.opts.focus&&setTimeout($.proxy(this.focus,this),100),this.opts.visual||setTimeout($.proxy((function(){this.opts.visual=!0,this.toggle(!1)}),this),200),this.callback("init")},buildBindKeyboard:function(){var t;this.dblEnter=0,!this.opts.dragUpload||!1===this.opts.imageUpload&&!1===this.opts.s3||this.$editor.on("drop.redactor",$.proxy(this.buildEventDrop,this)),this.$editor.on("click.redactor",$.proxy((function(){this.selectall=!1}),this)),this.$editor.on("input.redactor",$.proxy(this.sync,this)),this.$editor.on("paste.redactor",$.proxy(this.buildEventPaste,this)),this.$editor.on("keydown.redactor",$.proxy(this.buildEventKeydown,this)),this.$editor.on("keyup.redactor",$.proxy(this.buildEventKeyup,this)),$.isFunction(this.opts.textareaKeydownCallback)&&this.$source.on("keydown.redactor-textarea",$.proxy(this.opts.textareaKeydownCallback,this)),$.isFunction(this.opts.focusCallback)&&this.$editor.on("focus.redactor",$.proxy(this.opts.focusCallback,this)),$(document).mousedown((function(e){t=$(e.target)})),this.$editor.on("blur.redactor",$.proxy((function(e){$(t).hasClass("redactor_toolbar")||0!==$(t).parents(".redactor_toolbar").length||(this.selectall=!1,$.isFunction(this.opts.blurCallback)&&this.callback("blur",e))}),this))},buildEventDrop:function(t){if(t=t.originalEvent||t,void 0===window.FormData||!t.dataTransfer)return!0;if(0===t.dataTransfer.files.length)return!0;t.preventDefault();var e=t.dataTransfer.files[0];if(!1!==this.opts.dnbImageTypes&&-1===this.opts.dnbImageTypes.indexOf(e.type))return!0;this.bufferSet(),this.showProgressBar(),!1===this.opts.s3?this.dragUploadAjax(this.opts.imageUpload,e,!0,t,this.opts.imageUploadParam):this.s3uploadFile(e)},buildEventPaste:function(t){var e=!1;this.browser("webkit")&&-1===navigator.userAgent.indexOf("Chrome")&&(this.browser("version").split(".")[0]<536&&(e=!0));if(e)return!0;if(this.browser("opera"))return!0;if(this.opts.clipboardUpload&&this.buildEventClipboardUpload(t))return!0;if(this.opts.cleanup){this.rtePaste=!0,this.selectionSave(),this.selectall||(!0===this.opts.autoresize&&!0!==this.fullscreen?(this.$editor.height(this.$editor.height()),this.saveScroll=this.document.body.scrollTop):this.saveScroll=this.$editor.scrollTop());var i=this.extractContent();setTimeout($.proxy((function(){var t=this.extractContent();this.$editor.append(i),this.selectionRestore();var e=this.getFragmentHtml(t);this.pasteClean(e),!0===this.opts.autoresize&&!0!==this.fullscreen&&this.$editor.css("height","auto")}),this),1)}},buildEventClipboardUpload:function(t){var e=t.originalEvent||t;if(this.clipboardFilePaste=!1,void 0===e.clipboardData)return!1;if(e.clipboardData.items){var i=e.clipboardData.items[0].getAsFile();if(null!==i){this.bufferSet(),this.clipboardFilePaste=!0;var s=new FileReader;return s.onload=$.proxy(this.pasteClipboardUpload,this),s.readAsDataURL(i),!0}}return!1},buildEventKeydown:function(t){if(this.rtePaste)return!1;var e=t.which,i=t.ctrlKey||t.metaKey,s=this.getParent(),o=this.getCurrent(),r=this.getBlock(),a=!1;if(this.callback("keydown",t),this.browser("mozilla")&&"modify"in window.getSelection()&&i&&(37===t.keyCode||39===t.keyCode)){var n=this.getSelection(),l=t.metaKey?"line":"word";37===t.keyCode&&(n.modify("extend","left",l),t.shiftKey||n.collapseToStart()),39===t.keyCode&&(n.modify("extend","right",l),t.shiftKey||n.collapseToEnd()),t.preventDefault()}if(this.imageResizeHide(!1),(s&&"CODE"===$(s).get(0).tagName||o&&"CODE"===$(o).get(0).tagName)&&(a=!0,e===this.keyCode.DOWN&&this.insertAfterLastElement(r)),e===this.keyCode.DOWN&&(s&&"BLOCKQUOTE"===$(s)[0].tagName&&this.insertAfterLastElement(s),o&&"BLOCKQUOTE"===$(o)[0].tagName&&this.insertAfterLastElement(o),s&&"P"===$(s)[0].tagName&&"BLOCKQUOTE"===$(s).parent()[0].tagName&&this.insertAfterLastElement(s,$(s).parent()[0]),o&&"P"===$(o)[0].tagName&&s&&"BLOCKQUOTE"===$(s)[0].tagName&&this.insertAfterLastElement(o,s)),this.shortcuts(t,e),i&&90===e&&!t.shiftKey&&!t.altKey)return t.preventDefault(),void(this.opts.buffer.length?this.bufferUndo():this.document.execCommand("undo",!1,!1));if(i&&90===e&&t.shiftKey&&!t.altKey)return t.preventDefault(),void(0!==this.opts.rebuffer.length?this.bufferRedo():this.document.execCommand("redo",!1,!1));if(32===e&&this.bufferSet(),i&&65===e?(this.bufferSet(),this.selectall=!0):e===this.keyCode.LEFT_WIN||i||(this.selectall=!1),e!==this.keyCode.ENTER||t.shiftKey||t.ctrlKey||t.metaKey)e===this.keyCode.ENTER&&(t.ctrlKey||t.shiftKey)&&(this.bufferSet(),t.preventDefault(),this.insertLineBreak());else{var c=this.getRange();if(c&&!1===c.collapsed&&(sel=this.getSelection(),sel.rangeCount&&c.deleteContents()),this.browser("msie")&&1==s.nodeType&&("TD"===s.tagName||"TH"===s.tagName))return t.preventDefault(),this.bufferSet(),this.insertNode(document.createElement("br")),this.callback("enter",t),!1;if(r&&("BLOCKQUOTE"===r.tagName||"BLOCKQUOTE"===$(r).parent()[0].tagName))if(this.isEndOfElement()){if(1==this.dblEnter){var d,h;if("BLOCKQUOTE"===r.tagName?(h="br",d=r):(h="p",d=$(r).parent()[0]),t.preventDefault(),this.insertingAfterLastElement(d),this.dblEnter=0,"p"===h)$(r).parent().find("p").last().remove();else{var p=$.trim($(r).html());$(r).html(p.replace(/<br\s?\/?>$/i,""))}return}this.dblEnter++}else this.dblEnter++;if(!0===a)return this.buildEventKeydownPre(t,o);if(!this.opts.linebreaks){if(r&&"LI"===r.tagName){var u=this.getBlock();if(!1!==u||"LI"===u.tagName){var f=$.trim($(r).text()),m=$.trim($(u).text());if(""==f&&""==m&&0===$(u).next("li").length&&0===$(u).parents("li").length){this.bufferSet();var g=$(u).closest("ol, ul");$(u).remove();var b=$("<p>"+this.opts.invisibleSpace+"</p>");return g.after(b),this.selectionStart(b),this.sync(),this.callback("enter",t),!1}}}if(r&&this.opts.rBlockTest.test(r.tagName))this.bufferSet(),setTimeout($.proxy((function(){var t=this.getBlock();if("DIV"===t.tagName&&!$(t).hasClass("redactor_editor")){var e=$("<p>"+this.opts.invisibleSpace+"</p>");$(t).replaceWith(e),this.selectionStart(e)}}),this),1);else if(!1===r){this.bufferSet();b=$("<p>"+this.opts.invisibleSpace+"</p>");return this.insertNode(b[0]),this.selectionStart(b),this.callback("enter",t),!1}}if(this.opts.linebreaks){if(!r||!this.opts.rBlockTest.test(r.tagName))return this.buildEventKeydownInsertLineBreak(t);this.bufferSet(),setTimeout($.proxy((function(){var t=this.getBlock();"DIV"!==t.tagName&&"P"!==t.tagName||$(t).hasClass("redactor_editor")||this.replaceLineBreak(t)}),this),1)}if("BLOCKQUOTE"===r.tagName||"FIGCAPTION"===r.tagName)return this.buildEventKeydownInsertLineBreak(t);this.callback("enter",t)}if((e===this.keyCode.TAB||t.metaKey&&219===e)&&this.opts.shortcuts)return this.buildEventKeydownTab(t,a,e);e===this.keyCode.BACKSPACE&&this.buildEventKeydownBackspace(t,o,s)},buildEventKeydownPre:function(t,e){t.preventDefault(),this.bufferSet();var i=$(e).parent().text();return this.insertNode(document.createTextNode("\n")),-1===i.search(/\s$/)&&this.insertNode(document.createTextNode("\n")),this.sync(),this.callback("enter",t),!1},buildEventKeydownTab:function(t,e,i){return!this.opts.tabFocus||(!(!this.isEmpty(this.get())||!1!==this.opts.tabSpaces)||(t.preventDefault(),!0!==e||t.shiftKey?!1!==this.opts.tabSpaces?(this.bufferSet(),this.insertNode(document.createTextNode(Array(this.opts.tabSpaces+1).join(" "))),this.sync(),!1):(t.shiftKey?this.indentingOutdent():this.indentingIndent(),!1):(this.bufferSet(),this.insertNode(document.createTextNode("\t")),this.sync(),!1)))},buildEventKeydownBackspace:function(t,e,i){if(i&&e&&"TD"===i.parentNode.tagName&&"UL"===i.tagName&&"LI"===e.tagName&&1===$(i).children("li").length&&""==$(e).text().replace(/[\u200B-\u200D\uFEFF]/g,"")){var s=i.parentNode;return $(i).remove(),this.selectionStart(s),this.sync(),!1}void 0!==e.tagName&&/^(H[1-6])$/i.test(e.tagName)&&(s=!1===this.opts.linebreaks?$("<p>"+this.opts.invisibleSpace+"</p>"):$("<br>"+this.opts.invisibleSpace),$(e).replaceWith(s),this.selectionStart(s),this.sync());void 0!==e.nodeValue&&null!==e.nodeValue&&e.remove&&3===e.nodeType&&null==e.nodeValue.match(/[^\u200B]/g)&&($(e).prev().remove(),this.sync())},buildEventKeydownInsertLineBreak:function(t){this.bufferSet(),t.preventDefault(),this.insertLineBreak(),this.callback("enter",t)},buildEventKeyup:function(t){if(this.rtePaste)return!1;var e=t.which,i=this.getParent(),s=this.getCurrent();if(!this.opts.linebreaks&&3==s.nodeType&&(0==i||"BODY"===i.tagName)){var o=$("<p>").append($(s).clone());$(s).replaceWith(o);var r=$(o).next();void 0!==r[0]&&"BR"===r[0].tagName&&r.remove(),this.selectionEnd(o)}if((this.opts.convertLinks||this.opts.convertImageLinks||this.opts.convertVideoLinks)&&e===this.keyCode.ENTER&&this.buildEventKeyupConverters(),e===this.keyCode.DELETE||e===this.keyCode.BACKSPACE)return this.formatEmpty(t);this.callback("keyup",t),this.sync(t)},buildEventKeyupConverters:function(){this.formatLinkify(this.opts.linkProtocol,this.opts.convertLinks,this.opts.convertImageLinks,this.opts.convertVideoLinks,this.opts.linkSize),setTimeout($.proxy((function(){this.opts.convertImageLinks&&this.observeImages(),this.opts.observeLinks&&this.observeLinks()}),this),5)},buildPlugins:function(){this.opts.plugins&&$.each(this.opts.plugins,$.proxy((function(t,e){RedactorPlugins[e]&&($.extend(this,RedactorPlugins[e]),$.isFunction(RedactorPlugins[e].init)&&this.init())}),this))},iframeStart:function(){this.iframeCreate(),this.opts.textareamode?this.iframeAppend(this.$source):(this.$sourceOld=this.$source.hide(),this.$source=this.buildCodearea(this.$sourceOld),this.iframeAppend(this.$sourceOld))},iframeAppend:function(t){this.$source.attr("dir",this.opts.direction).hide(),this.$box.insertAfter(t).append(this.$frame).append(this.$source)},iframeCreate:function(){this.$frame=$('<iframe style="width: 100%;" frameborder="0" />').one("load",$.proxy((function(){if(this.opts.fullpage){this.iframePage(),""===this.content&&(this.content=this.opts.invisibleSpace),this.$frame.contents()[0].write(this.content),this.$frame.contents()[0].close();var t=setInterval($.proxy((function(){this.$frame.contents().find("body").html()&&(clearInterval(t),this.iframeLoad())}),this),0)}else this.iframeLoad()}),this))},iframeDoc:function(){return this.$frame[0].contentWindow.document},iframePage:function(){var t=this.iframeDoc();return t.documentElement&&t.removeChild(t.documentElement),t},iframeAddCss:function(t){t=t||this.opts.css,this.isString(t)&&this.$frame.contents().find("head").append('<link rel="stylesheet" href="'+t+'" />'),$.isArray(t)&&$.each(t,$.proxy((function(t,e){this.iframeAddCss(e)}),this))},iframeLoad:function(){this.$editor=this.$frame.contents().find("body").attr({contenteditable:!0,dir:this.opts.direction}),this.$editor[0]&&(this.document=this.$editor[0].ownerDocument,this.window=this.document.defaultView||window),this.iframeAddCss(),this.opts.fullpage?this.setFullpageOnInit(this.$source.val()):this.set(this.content,!0,!1),this.buildOptions(),this.buildAfter()},placeholderInit:function(){!1!==this.opts.placeholder?(this.placeholderText=this.opts.placeholder,this.opts.placeholder=!0):void 0===this.$element.attr("placeholder")||""==this.$element.attr("placeholder")?this.opts.placeholder=!1:(this.placeholderText=this.$element.attr("placeholder"),this.opts.placeholder=!0)},placeholderStart:function(t){return!1!==this.opts.placeholder&&(this.isEmpty(t)?(this.opts.focus=!1,this.placeholderOnFocus(),this.placeholderOnBlur(),this.placeholderGet()):(this.placeholderOnBlur(),!1))},placeholderOnFocus:function(){this.$editor.on("focus.redactor_placeholder",$.proxy(this.placeholderFocus,this))},placeholderOnBlur:function(){this.$editor.on("blur.redactor_placeholder",$.proxy(this.placeholderBlur,this))},placeholderGet:function(){var t=$('<span class="redactor_placeholder">').data("redactor","verified").attr("contenteditable",!1).text(this.placeholderText);return!1===this.opts.linebreaks?$("<p>").append(t):t},placeholderBlur:function(){var t=this.get();this.isEmpty(t)&&(this.placeholderOnFocus(),this.$editor.html(this.placeholderGet()))},placeholderFocus:function(){this.$editor.find("span.redactor_placeholder").remove();var t="";!1===this.opts.linebreaks&&(t=this.opts.emptyHtml),this.$editor.off("focus.redactor_placeholder"),this.$editor.html(t),!1===this.opts.linebreaks?this.selectionStart(this.$editor.children()[0]):this.focus(),this.sync()},placeholderRemoveFromEditor:function(){this.$editor.find("span.redactor_placeholder").remove(),this.$editor.off("focus.redactor_placeholder")},placeholderRemoveFromCode:function(t){return t.replace(/<span class="redactor_placeholder"(.*?)>(.*?)<\/span>/i,"")},shortcuts:function(e,key){if(!this.opts.shortcuts)return!e.ctrlKey&&!e.metaKey||66!==key&&73!==key||e.preventDefault(),!1;$.each(this.opts.shortcuts,$.proxy((function(str,command){var keys=str.split(",");for(var i in keys)"string"==typeof keys[i]&&this.shortcutsHandler(e,$.trim(keys[i]),$.proxy((function(){eval(command)}),this))}),this))},shortcutsHandler:function(t,e,i){var s={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"};e=e.toLowerCase().split(" ");var o={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:"'"}[t.keyCode],r=String.fromCharCode(t.which).toLowerCase(),a="",n={};$.each(["alt","ctrl","meta","shift"],(function(e,i){t[i+"Key"]&&o!==i&&(a+=i+"+")})),o&&(n[a+o]=!0),r&&(n[a+r]=!0,n[a+s[r]]=!0,"shift+"===a&&(n[s[r]]=!0));for(var l=0,c=e.length;l<c;l++)if(n[e[l]])return t.preventDefault(),i.apply(this,arguments)},focus:function(){this.browser("opera")?this.$editor.focus():this.window.setTimeout($.proxy(this.focusSet,this,!0),1)},focusWithSaveScroll:function(){if(this.browser("msie"))var t=this.document.documentElement.scrollTop;this.$editor.focus(),this.browser("msie")&&(this.document.documentElement.scrollTop=t)},focusEnd:function(){if(this.browser("mozilla"))if(!1===this.opts.linebreaks){var t=this.$editor.children().last();this.$editor.focus(),this.selectionEnd(t)}else this.focusSet();else this.focusSet()},focusSet:function(t,e){this.$editor.focus(),void 0===e&&(e=this.$editor[0]);var i=this.getRange();i.selectNodeContents(e),i.collapse(t||!1);var s=this.getSelection();s.removeAllRanges(),s.addRange(i)},toggle:function(t){this.opts.visual?this.toggleCode(t):this.toggleVisual()},toggleVisual:function(){var t=this.$source.hide().val();if(void 0!==this.modified){var e=this.modified.replace(/\n/g,""),i=t.replace(/\n/g,"");i=this.cleanRemoveSpaces(i,!1),this.modified=this.cleanRemoveSpaces(e,!1)!==i}this.modified&&(this.opts.fullpage&&""===t?this.setFullpageOnInit(t):(this.set(t),this.opts.fullpage&&this.buildBindKeyboard()),this.callback("change",!1,t)),this.opts.iframe?this.$frame.show():this.$editor.show(),this.opts.fullpage&&this.$editor.attr("contenteditable",!0),this.$source.off("keydown.redactor-textarea-indenting"),this.$editor.focus(),this.selectionRestore(),this.observeStart(),this.buttonActiveVisual(),this.buttonInactive("html"),this.opts.visual=!0},toggleCode:function(t){!1!==t&&this.selectionSave();var e=null;this.opts.iframe?(e=this.$frame.height(),this.opts.fullpage&&this.$editor.removeAttr("contenteditable"),this.$frame.hide()):(e=this.$editor.innerHeight(),this.$editor.hide());var i=this.$source.val();""!==i&&this.opts.tidyHtml&&this.$source.val(this.cleanHtml(i)),this.modified=i,this.$source.height(e).show().focus(),this.$source.on("keydown.redactor-textarea-indenting",this.textareaIndenting),this.buttonInactiveVisual(),this.buttonActive("html"),this.opts.visual=!1},textareaIndenting:function(t){if(9===t.keyCode){var e=$(this),i=e.get(0).selectionStart;return e.val(e.val().substring(0,i)+"\t"+e.val().substring(e.get(0).selectionEnd)),e.get(0).selectionStart=e.get(0).selectionEnd=i+1,!1}},autosave:function(){var t=!1;this.autosaveInterval=setInterval($.proxy((function(){var e=this.get();if(t!==e){var i=this.$source.attr("name");$.ajax({url:this.opts.autosave,type:"post",data:"name="+i+"&"+i+"="+escape(encodeURIComponent(e)),success:$.proxy((function(i){var s=$.parseJSON(i);void 0===s.error?this.callback("autosave",!1,s):this.callback("autosaveError",!1,s),t=e}),this)})}}),this),1e3*this.opts.autosaveInterval)},toolbarBuild:function(){if(this.isMobile()&&this.opts.buttonsHideOnMobile.length>0&&$.each(this.opts.buttonsHideOnMobile,$.proxy((function(t,e){var i=this.opts.buttons.indexOf(e);this.opts.buttons.splice(i,1)}),this)),this.opts.air)this.opts.buttons=this.opts.airButtons;else if(!this.opts.buttonSource){var t=this.opts.buttons.indexOf("html");this.opts.buttons.splice(t,1)}if(this.opts.toolbar&&$.each(this.opts.toolbar.formatting.dropdown,$.proxy((function(t,e){"-1"==$.inArray(t,this.opts.formattingTags)&&delete this.opts.toolbar.formatting.dropdown[t]}),this)),0===this.opts.buttons.length)return!1;this.airEnable(),this.$toolbar=$("<ul>").addClass("redactor_toolbar").attr("id","redactor_toolbar_"+this.uuid),this.opts.typewriter&&this.$toolbar.addClass("redactor-toolbar-typewriter"),this.opts.toolbarOverflow&&this.isMobile()&&this.$toolbar.addClass("redactor-toolbar-overflow"),this.opts.air?(this.$air=$('<div class="redactor_air">').attr("id","redactor_air_"+this.uuid).hide(),this.$air.append(this.$toolbar),$("body").append(this.$air)):this.opts.toolbarExternal?(this.$toolbar.addClass("redactor-toolbar-external"),$(this.opts.toolbarExternal).html(this.$toolbar)):this.$box.prepend(this.$toolbar),$.each(this.opts.buttons,$.proxy((function(t,e){if(this.opts.toolbar[e]){var i=this.opts.toolbar[e];if(!1===this.opts.fileUpload&&"file"===e)return!0;this.$toolbar.append($("<li>").append(this.buttonBuild(e,i)))}}),this)),this.$toolbar.find("a").attr("tabindex","-1"),this.opts.toolbarFixed&&(this.toolbarObserveScroll(),$(this.opts.toolbarFixedTarget).on("scroll.redactor",$.proxy(this.toolbarObserveScroll,this))),this.opts.activeButtons&&this.$editor.on("mouseup.redactor keyup.redactor",$.proxy(this.buttonActiveObserver,this))},toolbarObserveScroll:function(){var t,e=$(this.opts.toolbarFixedTarget).scrollTop(),i=0,s=0;if(t=(i=this.opts.toolbarFixedTarget===document?this.$box.offset().top:1)+this.$box.height()+40,e>i){var o="100%";this.opts.toolbarFixedBox&&(s=this.$box.offset().left,o=this.$box.innerWidth(),this.$toolbar.addClass("toolbar_fixed_box")),this.toolbarFixed=!0,this.opts.toolbarFixedTarget===document?this.$toolbar.css({position:"fixed",width:o,zIndex:10005,top:this.opts.toolbarFixedTopOffset+"px",left:s}):this.$toolbar.css({position:"absolute",width:o,zIndex:10005,top:this.opts.toolbarFixedTopOffset+e+"px",left:0}),e<t?this.$toolbar.css("visibility","visible"):this.$toolbar.css("visibility","hidden")}else this.toolbarFixed=!1,this.$toolbar.css({position:"relative",width:"auto",top:0,left:s}),this.opts.toolbarFixedBox&&this.$toolbar.removeClass("toolbar_fixed_box")},airEnable:function(){this.opts.air&&this.$editor.on("mouseup.redactor keyup.redactor",this,$.proxy((function(t){var e=this.getSelectionText();if("mouseup"===t.type&&""!=e&&this.airShow(t),"keyup"===t.type&&t.shiftKey&&""!=e){var i=$(this.getElement(this.getSelection().focusNode)),s=i.offset();s.height=i.height(),this.airShow(s,!0)}}),this))},airShow:function(t,e){if(this.opts.air){var i,s;if(this.selectionSave(),$(".redactor_air").hide(),e)i=t.left,s=t.top+t.height+14,this.opts.iframe&&(s+=this.$box.position().top-$(this.document).scrollTop(),i+=this.$box.position().left);else{var o=this.$air.innerWidth();i=t.clientX,$(this.document).width()<i+o&&(i-=o),s=t.clientY+14,this.opts.iframe?(s+=this.$box.position().top,i+=this.$box.position().left):s+=$(this.document).scrollTop()}this.$air.css({left:i+"px",top:s+"px"}).show(),this.airBindHide()}},airBindHide:function(){if(this.opts.air){var t=$.proxy((function(t){$(t).on("mousedown.redactor",$.proxy((function(e){0===$(e.target).closest(this.$toolbar).length&&(this.$air.fadeOut(100),this.selectionRemove(),$(t).off(e))}),this)).on("keydown.redactor",$.proxy((function(e){e.which===this.keyCode.ESC&&this.getSelection().collapseToStart(),this.$air.fadeOut(100),$(t).off(e)}),this))}),this);t(document),this.opts.iframe&&t(this.document)}},airBindMousemoveHide:function(){if(this.opts.air){var t=$.proxy((function(t){$(t).on("mousemove.redactor",$.proxy((function(e){0===$(e.target).closest(this.$toolbar).length&&(this.$air.fadeOut(100),$(t).off(e))}),this))}),this);t(document),this.opts.iframe&&t(this.document)}},dropdownBuild:function(t,e){$.each(e,$.proxy((function(e,i){var s;i.className||(i.className=""),"separator"===i.name?s=$('<a class="redactor_separator_drop">'):(s=$('<a href="#" class="'+i.className+" redactor_dropdown_"+e+'">'+i.title+"</a>")).on("click",$.proxy((function(t){this.opts.air&&this.selectionRestore(),t.preventDefault&&t.preventDefault(),this.browser("msie")&&(t.returnValue=!1),i.callback&&i.callback.call(this,e,s,i,t),i.exec&&this.execCommand(i.exec,e),i.func&&this[i.func](e),this.buttonActiveObserver(),this.opts.air&&this.$air.fadeOut(100)}),this)),t.append(s)}),this))},dropdownShow:function(t,e){if(!this.opts.visual)return t.preventDefault(),!1;var i=this.buttonGet(e),s=i.data("dropdown").appendTo(document.body);if(i.hasClass("dropact"))this.dropdownHideAll();else{this.dropdownHideAll(),this.callback("dropdownShow",{dropdown:s,key:e,button:i}),this.buttonActive(e),i.addClass("dropact");var o=i.offset(),r=s.width();o.left+r>$(document).width()&&(o.left-=r);var a=o.left+"px",n=i.innerHeight(),l="absolute",c=n+this.opts.toolbarFixedTopOffset+"px";this.opts.toolbarFixed&&this.toolbarFixed?l="fixed":c=o.top+n+"px",s.css({position:l,left:a,top:c}).show(),this.callback("dropdownShown",{dropdown:s,key:e,button:i})}var d=$.proxy((function(t){this.dropdownHide(t,s)}),this);$(document).one("click",d),this.$editor.one("click",d),this.$editor.one("touchstart",d),t.stopPropagation(),this.focusWithSaveScroll()},dropdownHideAll:function(){this.$toolbar.find("a.dropact").removeClass("redactor_act").removeClass("dropact"),$(".redactor_dropdown").hide(),this.callback("dropdownHide")},dropdownHide:function(t,e){$(t.target).hasClass("dropact")||(e.removeClass("dropact"),this.dropdownHideAll())},buttonBuild:function(t,e,i){var s=$('<a href="#" title="'+e.title+'" tabindex="-1" class="re-icon re-'+t+'"></a>');if(void 0!==i&&s.addClass("redactor-btn-image"),s.on("click",$.proxy((function(i){if(i.preventDefault&&i.preventDefault(),this.browser("msie")&&(i.returnValue=!1),s.hasClass("redactor_button_disabled"))return!1;!1!==this.isFocused()||e.exec||this.focusWithSaveScroll(),e.exec?(this.focusWithSaveScroll(),this.execCommand(e.exec,t),this.airBindMousemoveHide()):e.func&&"show"!==e.func?(this[e.func](t),this.airBindMousemoveHide()):e.callback?(e.callback.call(this,t,s,e,i),this.airBindMousemoveHide()):e.dropdown&&this.dropdownShow(i,t),this.buttonActiveObserver(!1,t)}),this)),e.dropdown){var o=$('<div class="redactor_dropdown redactor_dropdown_box_'+t+'" style="display: none;">');s.data("dropdown",o),this.dropdownBuild(o,e.dropdown)}return s},buttonGet:function(t){return!!this.opts.toolbar&&$(this.$toolbar.find("a.re-"+t))},buttonTagToActiveState:function(t,e){this.opts.activeButtons.push(t),this.opts.activeButtonsStates[e]=t},buttonActiveToggle:function(t){this.buttonGet(t).hasClass("redactor_act")?this.buttonInactive(t):this.buttonActive(t)},buttonActive:function(t){this.buttonGet(t).addClass("redactor_act")},buttonInactive:function(t){this.buttonGet(t).removeClass("redactor_act")},buttonInactiveAll:function(t){this.$toolbar.find("a.re-icon").not(".re-"+t).removeClass("redactor_act")},buttonActiveVisual:function(){this.$toolbar.find("a.re-icon").not("a.re-html").removeClass("redactor_button_disabled")},buttonInactiveVisual:function(){this.$toolbar.find("a.re-icon").not("a.re-html").addClass("redactor_button_disabled")},buttonChangeIcon:function(t,e){this.buttonGet(t).addClass("re-"+e)},buttonRemoveIcon:function(t,e){this.buttonGet(t).removeClass("re-"+e)},buttonAwesome:function(t,e){var i=this.buttonGet(t);i.removeClass("redactor-btn-image"),i.addClass("fa-redactor-btn"),i.html('<i class="fa '+e+'"></i>')},buttonAdd:function(t,e,i,s){if(this.opts.toolbar){var o=this.buttonBuild(t,{title:e,callback:i,dropdown:s},!0);return this.$toolbar.append($("<li>").append(o)),o}},buttonAddFirst:function(t,e,i,s){if(this.opts.toolbar){var o=this.buttonBuild(t,{title:e,callback:i,dropdown:s},!0);this.$toolbar.prepend($("<li>").append(o))}},buttonAddAfter:function(t,e,i,s,o){if(this.opts.toolbar){var r=this.buttonBuild(e,{title:i,callback:s,dropdown:o},!0),a=this.buttonGet(t);return 0!==a.length?a.parent().after($("<li>").append(r)):this.$toolbar.append($("<li>").append(r)),r}},buttonAddBefore:function(t,e,i,s,o){if(this.opts.toolbar){var r=this.buttonBuild(e,{title:i,callback:s,dropdown:o},!0),a=this.buttonGet(t);return 0!==a.length?a.parent().before($("<li>").append(r)):this.$toolbar.append($("<li>").append(r)),r}},buttonRemove:function(t){this.buttonGet(t).remove()},buttonActiveObserver:function(t,e){var i=this.getParent();if(this.buttonInactiveAll(e),!1!==t||"html"===e){i&&"A"===i.tagName?this.$toolbar.find("a.redactor_dropdown_link").text(this.opts.curLang.link_edit):this.$toolbar.find("a.redactor_dropdown_link").text(this.opts.curLang.link_insert),$.each(this.opts.activeButtonsStates,$.proxy((function(t,e){0!=$(i).closest(t,this.$editor.get()[0]).length&&this.buttonActive(e)}),this));var s=$(i).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);if(s.length){var o=s.css("text-align");""==o&&(o="left"),this.buttonActive("align"+o)}}else-1!=$.inArray(e,this.opts.activeButtons)&&this.buttonActiveToggle(e)},execPasteFrag:function(t){var e=this.getSelection();if(e.getRangeAt&&e.rangeCount){var i=this.getRange();i.deleteContents();var s=this.document.createElement("div");s.innerHTML=t;for(var o,r,a=this.document.createDocumentFragment();o=s.firstChild;)r=a.appendChild(o);a.firstChild;i.insertNode(a),r&&((i=i.cloneRange()).setStartAfter(r),i.collapse(!0)),e.removeAllRanges(),e.addRange(i)}},exec:function(t,e,i){"formatblock"===t&&this.browser("msie")&&(e="<"+e+">"),"inserthtml"===t&&this.browser("msie")?this.isIe11()?this.execPasteFrag(e):(this.focusWithSaveScroll(),this.document.selection.createRange().pasteHTML(e)):this.document.execCommand(t,!1,e),!1!==i&&this.sync(),this.callback("execCommand",t,e)},execCommand:function(t,e,i){if(!this.opts.visual)return this.$source.focus(),!1;if("bold"!==t&&"italic"!==t&&"underline"!==t&&"strikethrough"!==t||this.bufferSet(),"superscript"===t||"subscript"===t){var s=this.getParent();"SUP"!==s.tagName&&"SUB"!==s.tagName||this.inlineRemoveFormatReplace(s)}return"inserthtml"===t?(this.insertHtml(e,i),void this.callback("execCommand",t,e)):!(this.currentOrParentIs("CODE")&&!this.opts.formattingPre)&&("insertunorderedlist"===t||"insertorderedlist"===t?this.execLists(t,e):"unlink"===t?this.execUnlink(t,e):(this.exec(t,e,i),void("inserthorizontalrule"===t&&this.$editor.find("hr").removeAttr("id"))))},execUnlink:function(t,e){this.bufferSet();var i=this.currentOrParentIs("A");if(i)return $(i).replaceWith($(i).text()),this.sync(),void this.callback("execCommand",t,e)},execLists:function(t,e){this.bufferSet();var i=this.getParent(),s=$(i).closest("ol, ul");this.isParentRedactor(s)||0==s.length||(s=!1);var o=!1;if(s&&s.length){o=!0;var r=s[0].tagName;("insertunorderedlist"===t&&"OL"===r||"insertorderedlist"===t&&"UL"===r)&&(o=!1)}if(this.selectionSave(),o){var a=this.getNodes(),n=this.getBlocks(a);void 0!==a[0]&&a.length>1&&3==a[0].nodeType&&n.unshift(this.getBlock());var l="",c="";$.each(n,$.proxy((function(t,e){if("LI"==e.tagName){var i=$(e),s=i.clone();if(s.find("ul","ol").remove(),!1===this.opts.linebreaks)l+=this.outerHtml($("<p>").append(s.contents()));else{var o=s.html().replace(/<br\s?\/?>$/i,"");l+=o+"<br>"}0==t?(i.addClass("redactor-replaced").empty(),c=this.outerHtml(i)):i.remove()}}),this)),html=this.$editor.html().replace(c,"</"+r+">"+l+"<"+r+">"),this.$editor.html(html),this.$editor.find(r+":empty").remove()}else{var d=$(this.getParent()).closest("td");if(this.browser("msie")&&!this.isIe11()&&this.opts.linebreaks){var h=this.selectionWrap("div"),p=$(h).html(),u=$("<ul>");"insertorderedlist"==t&&(u=$("<ol>"));var f=$("<li>");""==$.trim(p)?(f.append(p+'<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),u.append(f),this.$editor.find("#selection-marker-1").replaceWith(u)):(f.append(p),u.append(f),$(h).replaceWith(u))}else this.document.execCommand(t);i=this.getParent(),s=$(i).closest("ol, ul");if(!1===this.opts.linebreaks)""==$.trim(s.text())&&(s.children("li").find("br").remove(),s.children("li").append('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"));if(0!=d.length&&s.wrapAll("<td>"),s.length){var m=s.parent();this.isParentRedactor(m)&&"LI"!=m[0].tagName&&this.nodeTestBlocks(m[0])&&m.replaceWith(m.contents())}this.browser("mozilla")&&this.$editor.focus()}this.selectionRestore(),this.$editor.find("#selection-marker-1").removeAttr("id"),this.sync(),this.callback("execCommand",t,e)},indentingIndent:function(){this.indentingStart("indent")},indentingOutdent:function(){this.indentingStart("outdent")},indentingStart:function(t){if(this.bufferSet(),"indent"===t){var e=this.getBlock();if(this.selectionSave(),e&&"LI"==e.tagName){var i=this.getParent(),s=$(i).closest("ol, ul")[0].tagName,o=this.getBlocks();$.each(o,(function(t,e){if("LI"==e.tagName){var i=$(e).prev();if(0!=i.length&&"LI"==i[0].tagName){var o=i.children("ul, ol");0==o.length?i.append($("<"+s+">").append(e)):o.append(e)}}}))}else if(!1===e&&!0===this.opts.linebreaks){this.exec("formatBlock","blockquote");var r=this.getBlock();e=$('<div data-tagblock="">').html($(r).html());$(r).replaceWith(e);var a=this.normalize($(e).css("margin-left"))+this.opts.indentValue;$(e).css("margin-left",a+"px")}else{var n=this.getBlocks();$.each(n,$.proxy((function(t,e){var i=!1;if("TD"!==e.tagName){i=-1!==$.inArray(e.tagName,this.opts.alignmentTags)?$(e):$(e).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);var s=this.normalize(i.css("margin-left"))+this.opts.indentValue;i.css("margin-left",s+"px")}}),this))}this.selectionRestore()}else{if(this.selectionSave(),(e=this.getBlock())&&"LI"==e.tagName){o=this.getBlocks();this.insideOutdent(e,0,o)}else{n=this.getBlocks();$.each(n,$.proxy((function(t,e){var i=!1;i=-1!==$.inArray(e.tagName,this.opts.alignmentTags)?$(e):$(e).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);var s=this.normalize(i.css("margin-left"))-this.opts.indentValue;s<=0?!0===this.opts.linebreaks&&void 0!==i.data("tagblock")?i.replaceWith(i.html()+"<br>"):(i.css("margin-left",""),this.removeEmptyAttr(i,"style")):i.css("margin-left",s+"px")}),this))}this.selectionRestore()}this.sync()},insideOutdent:function(t,e,i){if(t&&"LI"==t.tagName){var s=$(t).parent().parent();0!=s.length&&"LI"==s[0].tagName?s.after(t):void 0!==i[e]?(t=i[e],e++,this.insideOutdent(t,e,i)):this.execCommand("insertunorderedlist")}},alignmentLeft:function(){this.alignmentSet("","JustifyLeft")},alignmentRight:function(){this.alignmentSet("right","JustifyRight")},alignmentCenter:function(){this.alignmentSet("center","JustifyCenter")},alignmentJustify:function(){this.alignmentSet("justify","JustifyFull")},alignmentSet:function(t,e){if(this.bufferSet(),this.oldIE())return this.document.execCommand(e,!1,!1),!0;if(this.selectionSave(),!(s=this.getBlock())&&this.opts.linebreaks){this.exec("formatblock","div");var i=this.getBlock(),s=$('<div data-tagblock="">').html($(i).html());$(i).replaceWith(s),$(s).css("text-align",t),this.removeEmptyAttr(s,"style"),""==t&&void 0!==$(s).data("tagblock")&&$(s).replaceWith($(s).html())}else{var o=this.getBlocks();$.each(o,$.proxy((function(e,i){var s=!1;(s=-1!==$.inArray(i.tagName,this.opts.alignmentTags)?$(i):$(i).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]))&&(s.css("text-align",t),this.removeEmptyAttr(s,"style"))}),this))}this.selectionRestore(),this.sync()},cleanEmpty:function(t){var e=this.placeholderStart(t);return!1!==e?e:(!1===this.opts.linebreaks&&(""===t?t=this.opts.emptyHtml:-1!==t.search(/^<hr\s?\/?>$/gi)&&(t="<hr>"+this.opts.emptyHtml)),t)},cleanConverters:function(t){return this.opts.convertDivs&&!this.opts.gallery&&(t=t.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"<p$1>$2</p>")),this.opts.paragraphy&&(t=this.cleanParagraphy(t)),t},cleanConvertProtected:function(t){return this.opts.templateVars&&(t=(t=t.replace(/\{\{(.*?)\}\}/gi,"\x3c!-- template double $1 --\x3e")).replace(/\{(.*?)\}/gi,"\x3c!-- template $1 --\x3e")),t=(t=(t=t.replace(/<script(.*?)>([\w\W]*?)<\/script>/gi,'<title type="text/javascript" style="display: none;" class="redactor-script-tag"$1>$2</title>')).replace(/<style(.*?)>([\w\W]*?)<\/style>/gi,'<section$1 style="display: none;" rel="redactor-style-tag">$2</section>')).replace(/<form(.*?)>([\w\W]*?)<\/form>/gi,'<section$1 rel="redactor-form-tag">$2</section>'),t=this.opts.phpTags?t.replace(/<\?php([\w\W]*?)\?>/gi,'<section style="display: none;" rel="redactor-php-tag">$1</section>'):t.replace(/<\?php([\w\W]*?)\?>/gi,"")},cleanReConvertProtected:function(t){return this.opts.templateVars&&(t=(t=t.replace(/<!-- template double (.*?) -->/gi,"{{$1}}")).replace(/<!-- template (.*?) -->/gi,"{$1}")),t=(t=(t=t.replace(/<title type="text\/javascript" style="display: none;" class="redactor-script-tag"(.*?)>([\w\W]*?)<\/title>/gi,'<script$1 type="text/javascript">$2<\/script>')).replace(/<section(.*?) style="display: none;" rel="redactor-style-tag">([\w\W]*?)<\/section>/gi,"<style$1>$2</style>")).replace(/<section(.*?)rel="redactor-form-tag"(.*?)>([\w\W]*?)<\/section>/gi,"<form$1$2>$3</form>"),this.opts.phpTags&&(t=t.replace(/<section style="display: none;" rel="redactor-php-tag">([\w\W]*?)<\/section>/gi,"<?php\r\n$1\r\n?>")),t},cleanRemoveSpaces:function(t,e){if(!1!==e){e=[];var i=t.match(/<(code|style|script|title)(.*?)>([\w\W]*?)<\/(code|style|script|title)>/gi);if(null===i&&(i=[]),this.opts.phpTags){var s=t.match(/<\?php([\w\W]*?)\?>/gi);s&&(i=$.merge(i,s))}i&&$.each(i,(function(i,s){t=t.replace(s,"buffer_"+i),e.push(s)}))}return t=(t=(t=(t=(t=(t=t.replace(/\n/g," ")).replace(/[\t]*/g,"")).replace(/\n\s*\n/g,"\n")).replace(/^[\s\n]*/g," ")).replace(/[\s\n]*$/g," ")).replace(/>\s{2,}</g,"> <"),t=(t=this.cleanReplacer(t,e)).replace(/\n\n/g,"\n")},cleanReplacer:function(t,e){return!1===e||$.each(e,(function(e,i){t=t.replace("buffer_"+e,i)})),t},cleanRemoveEmptyTags:function(t){t=t.replace(/[\u200B-\u200D\uFEFF]/g,"");for(var e=["<b>\\s*</b>","<b> </b>","<em>\\s*</em>"],i=["<code></code>","<blockquote>\\s*</blockquote>","<dd></dd>","<dt></dt>","<ul></ul>","<ol></ol>","<li></li>","<table></table>","<tr></tr>","<span>\\s*<span>","<span> <span>","<p>\\s*</p>","<p></p>","<p> </p>","<p>\\s*<br>\\s*</p>","<div>\\s*</div>","<div>\\s*<br>\\s*</div>"],s=(i=this.opts.removeEmptyTags?i.concat(e):e).length,o=0;o<s;++o)t=t.replace(new RegExp(i[o],"gi"),"");return t},cleanParagraphy:function(t){if(t=$.trim(t),!0===this.opts.linebreaks)return t;if(""===t||"<p></p>"===t)return this.opts.emptyHtml;if(t+="\n",!1===this.opts.removeEmptyTags)return t;var e=[],i=t.match(/<(table|div|code|object)(.*?)>([\w\W]*?)<\/(table|div|code|object)>/gi);i||(i=[]);var s=t.match(/<!--([\w\W]*?)-->/gi);if(s&&(i=$.merge(i,s)),this.opts.phpTags){var o=t.match(/<section(.*?)rel="redactor-php-tag">([\w\W]*?)<\/section>/gi);o&&(i=$.merge(i,o))}function r(e,i,s){return t.replace(new RegExp(e,i),s)}i&&$.each(i,(function(i,s){e[i]=s,t=t.replace(s,"{replace"+i+"}\n")})),t=(t=t.replace(/<br \/>\s*<br \/>/gi,"\n\n")).replace(/<br><br>/gi,"\n\n");var a="(comment|html|body|head|title|meta|style|script|link|iframe|table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|code|select|option|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)";t=r("(<"+a+"[^>]*>)","gi","\n$1"),t=r("(</"+a+">)","gi","$1\n\n"),t=r("\r\n","g","\n"),t=r("\r","g","\n");var n=(t=r("/\n\n+/","g","\n\n")).split(new RegExp("\ns*\n","g"),-1);for(var l in t="",n)n.hasOwnProperty(l)&&(-1==n[l].search("{replace")?(n[l]=n[l].replace(/<p>\n\t?<\/p>/gi,""),n[l]=n[l].replace(/<p><\/p>/gi,""),""!=n[l]&&(t+="<p>"+n[l].replace(/^\n+|\n+$/g,"")+"</p>")):t+=n[l]);return t=r("<p><p>","gi","<p>"),t=r("</p></p>","gi","</p>"),t=r("<p>s?</p>","gi",""),t=r("<p>([^<]+)</(div|address|form)>","gi","<p>$1</p></$2>"),t=r("<p>(</?"+a+"[^>]*>)</p>","gi","$1"),t=r("<p>(<li.+?)</p>","gi","$1"),t=r("<p>s?(</?"+a+"[^>]*>)","gi","$1"),t=r("(</?"+a+"[^>]*>)s?</p>","gi","$1"),t=r("(</?"+a+"[^>]*>)s?<br />","gi","$1"),t=r("<br />(s*</?(?:p|li|div|dl|dd|dt|th|code|td|ul|ol)[^>]*>)","gi","$1"),t=r("\n</p>","gi","</p>"),t=r("<li><p>","gi","<li>"),t=r("</p></li>","gi","</li>"),t=r("</li><p>","gi","</li>"),t=r("<p>\t?\n?<p>","gi","<p>"),t=r("</dt><p>","gi","</dt>"),t=r("</dd><p>","gi","</dd>"),t=r("<br></p></blockquote>","gi","</blockquote>"),t=r("<p>\t*</p>","gi",""),$.each(e,(function(e,i){t=t.replace("{replace"+e+"}",i)})),$.trim(t)},cleanConvertInlineTags:function(t,e){var i="strong";"b"===this.opts.boldTag&&(i="b");var s="em";return"i"===this.opts.italicTag&&(s="i"),t=(t=t.replace(/<span style="font-style: italic;">([\w\W]*?)<\/span>/gi,"<"+s+">$1</"+s+">")).replace(/<span style="font-weight: bold;">([\w\W]*?)<\/span>/gi,"<"+i+">$1</"+i+">"),t="strong"===this.opts.boldTag?t.replace(/<b>([\w\W]*?)<\/b>/gi,"<strong>$1</strong>"):t.replace(/<strong>([\w\W]*?)<\/strong>/gi,"<b>$1</b>"),t=(t="em"===this.opts.italicTag?t.replace(/<i>([\w\W]*?)<\/i>/gi,"<em>$1</em>"):t.replace(/<em>([\w\W]*?)<\/em>/gi,"<i>$1</i>")).replace(/<span style="text-decoration: underline;">([\w\W]*?)<\/span>/gi,"<u>$1</u>"),t=!0!==e?t.replace(/<strike>([\w\W]*?)<\/strike>/gi,"<del>$1</del>"):t.replace(/<del>([\w\W]*?)<\/del>/gi,"<strike>$1</strike>")},cleanStripTags:function(t){if(""==t||void 0===t)return t;var e=!1;!1!==this.opts.allowedTags&&(e=!0);var i=!0===e?this.opts.allowedTags:this.opts.deniedTags;return t=t.replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,(function(t,s){return!0===e?$.inArray(s.toLowerCase(),i)>"-1"?t:"":$.inArray(s.toLowerCase(),i)>"-1"?"":t})),t=this.cleanConvertInlineTags(t)},cleanSavePreCode:function(t,e){var i=t.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/gi);return null!==i&&$.each(i,$.proxy((function(i,s){var o=s.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/i);o[3]=o[3].replace(/ /g," "),!1!==e&&(o[3]=this.cleanEncodeEntities(o[3])),o[3]=o[3].replace(/\$/g,"$"),t=t.replace(s,"<"+o[1]+o[2]+">"+o[3]+"</"+o[1]+">")}),this)),t},cleanEncodeEntities:function(t){return(t=String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"')).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},cleanUnverified:function(){var t=this.$editor.find("li, img, a, b, strong, sub, sup, i, em, u, small, strike, del, span, cite");t.filter('[style*="background-color: transparent;"][style*="line-height"]').css("background-color","").css("line-height",""),t.filter('[style*="background-color: transparent;"]').css("background-color",""),t.css("line-height",""),$.each(t,$.proxy((function(t,e){this.removeEmptyAttr(e,"style")}),this));var e=this.$editor.find("b, strong, i, em, u, strike, del");e.css("font-size",""),$.each(e,$.proxy((function(t,e){this.removeEmptyAttr(e,"style")}),this)),this.$editor.find('div[style="text-align: -webkit-auto;"]').contents().unwrap(),this.$editor.find("ul, ol, li").removeAttr("style")},cleanHtml:function(t){var e=0,i=t.length,s=0,o=null,r=null,a="",n="",l="";for(this.cleanlevel=0;e<i;e++){if(s=e,-1==t.substr(e).indexOf("<"))return n+=t.substr(e),this.cleanFinish(n);for(;s<i&&"<"!=t.charAt(s);)s++;for(e!=s&&((l=t.substr(e,s-e)).match(/^\s{2,}$/g)||("\n"==n.charAt(n.length-1)?n+=this.cleanGetTabs():"\n"==l.charAt(0)&&(n+="\n"+this.cleanGetTabs(),l=l.replace(/^\s+/,"")),n+=l),l.match(/\n/)&&(n+="\n"+this.cleanGetTabs())),o=s;s<i&&">"!=t.charAt(s);)s++;var c;if(e=s,"!--"==(a=t.substr(o,s-o)).substr(1,3)){if(!a.match(/--$/)){for(;"--\x3e"!=t.substr(s,3);)s++;s+=2,a=t.substr(o,s-o),e=s}"\n"!=n.charAt(n.length-1)&&(n+="\n"),n+=this.cleanGetTabs(),n+=a+">\n"}else"!"==a[1]?n=this.placeTag(a+">",n):"?"==a[1]?n+=a+">\n":(c=a.match(/^<(script|style|pre|code)/i))?(c[1]=c[1].toLowerCase(),a=this.cleanTag(a),n=this.placeTag(a,n),(r=String(t.substr(e+1)).toLowerCase().indexOf("</"+c[1]))&&(l=t.substr(e+1,r),e+=r,n+=l)):(a=this.cleanTag(a),n=this.placeTag(a,n))}return this.cleanFinish(n)},cleanGetTabs:function(){for(var t="",e=0;e<this.cleanlevel;e++)t+="\t";return t},cleanFinish:function(t){return t=(t=(t=(t=t.replace(/\n\s*\n/g,"\n")).replace(/^[\s\n]*/,"")).replace(/[\s\n]*$/,"")).replace(/<script(.*?)>\n<\/script>/gi,"<script$1><\/script>"),this.cleanlevel=0,t},cleanTag:function(t){var e,i="",s="";for((t=(t=(t=t.replace(/\n/g," ")).replace(/\s{2,}/g," ")).replace(/^\s+|\s+$/g," ")).match(/\/$/)&&(s="/",t=t.replace(/\/+$/,""));e=/\s*([^= ]+)(?:=((['"']).*?\3|[^ ]+))?/.exec(t);)e[2]?i+=e[1].toLowerCase()+"="+e[2]:e[1]&&(i+=e[1].toLowerCase()),i+=" ",t=t.substr(e[0].length);return i.replace(/\s*$/,"")+s+">"},placeTag:function(t,e){var i=t.match(this.cleannewLevel);return(t.match(this.cleanlineBefore)||i)&&(e=e.replace(/\s*$/,""),e+="\n"),i&&"/"==t.charAt(1)&&this.cleanlevel--,"\n"==e.charAt(e.length-1)&&(e+=this.cleanGetTabs()),i&&"/"!=t.charAt(1)&&this.cleanlevel++,e+=t,(t.match(this.cleanlineAfter)||t.match(this.cleannewLevel))&&(e=e.replace(/ *$/,""),e+="\n"),e},formatEmpty:function(t){var e=$.trim(this.$editor.html());if(this.opts.linebreaks)""==e&&(t.preventDefault(),this.$editor.html(""),this.focus());else{var i=(e=e.replace(/<br\s?\/?>/i,"")).replace(/<p>\s?<\/p>/gi,"");if(""===e||""===i){t.preventDefault();var s=$(this.opts.emptyHtml).get(0);this.$editor.html(s),this.focus()}}this.sync()},formatBlocks:function(t){this.browser("mozilla")&&this.isFocused()&&this.$editor.focus(),this.bufferSet();var e=this.getBlocks();this.selectionSave(),$.each(e,$.proxy((function(e,i){if("LI"!==i.tagName){var s=$(i).parent();if("p"===t){if("P"===i.tagName&&0!=s.length&&"BLOCKQUOTE"===s[0].tagName||"BLOCKQUOTE"===i.tagName)return void this.formatQuote();if(this.opts.linebreaks){if(!i||0!=i.tagName.search(/H[1-6]/))return;$(i).replaceWith(i.innerHTML+"<br>")}else this.formatBlock(t,i)}else this.formatBlock(t,i)}}),this)),this.selectionRestore(),this.sync()},formatBlock:function(t,e){if(!1===e&&(e=this.getBlock()),!1===e&&!0===this.opts.linebreaks)return this.execCommand("formatblock",t),!0;var i="";if("code"!==t?i=$(e).contents():(i=$(e).html(),""===$.trim(i)&&(i='<span id="selection-marker-1"></span>')),"CODE"===e.tagName&&(t="p"),!0===this.opts.linebreaks&&"p"===t)$(e).replaceWith($("<div>").append(i).html()+"<br>");else{var s=this.getParent(),o=$("<"+t+">").append(i);$(e).replaceWith(o),s&&"TD"==s.tagName&&$(o).wrapAll("<td>")}},formatChangeTag:function(t,e,i){!1!==i&&this.selectionSave();var s=$("<"+e+"/>");return $(t).replaceWith((function(){return s.append($(this).contents())})),!1!==i&&this.selectionRestore(),s},formatQuote:function(){if(this.browser("mozilla")&&this.isFocused()&&this.$editor.focus(),this.bufferSet(),!1===this.opts.linebreaks){this.selectionSave();var t=this.getBlocks(),e=!1,i=t.length;if(t){var s="",o="",r=!1,a=!0;if($.each(t,(function(t,e){"P"!==e.tagName&&(a=!1)})),$.each(t,$.proxy((function(n,l){if("BLOCKQUOTE"===l.tagName)this.formatBlock("p",l,!1);else if("P"===l.tagName)if("BLOCKQUOTE"==(e=$(l).parent())[0].tagName){var c=$(e).children("p").length;1==c?$(e).replaceWith(l):c==i?(r="blockquote",s+=this.outerHtml(l)):(r="html",s+=this.outerHtml(l),0==n?($(l).addClass("redactor-replaced").empty(),o=this.outerHtml(l)):$(l).remove())}else!1===a||1==t.length?this.formatBlock("blockquote",l,!1):(r="paragraphs",s+=this.outerHtml(l));else"LI"!==l.tagName&&this.formatBlock("blockquote",l,!1)}),this)),r)if("paragraphs"==r)$(t[0]).replaceWith("<blockquote>"+s+"</blockquote>"),$(t).remove();else if("blockquote"==r)$(e).replaceWith(s);else if("html"==r){var n=this.$editor.html().replace(o,"</blockquote>"+s+"<blockquote>");this.$editor.html(n),this.$editor.find("blockquote").each((function(){""==$.trim($(this).html())&&$(this).remove()}))}}this.selectionRestore()}else{var l=this.getBlock();if("BLOCKQUOTE"===l.tagName){this.selectionSave();n=$.trim($(l).html());var c=$.trim(this.getSelectionHtml());if((n=n.replace(/<span(.*?)id="selection-marker(.*?)<\/span>/gi,""))==c)$(l).replaceWith($(l).html()+"<br>");else{this.inlineFormat("tmp");var d=this.$editor.find("tmp");d.empty();var h=this.$editor.html().replace("<tmp></tmp>",'</blockquote><span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"+c+"<blockquote>");this.$editor.html(h),d.remove(),this.$editor.find("blockquote").each((function(){""==$.trim($(this).html())&&$(this).remove()}))}this.selectionRestore(),this.$editor.find("span#selection-marker-1").attr("id",!1)}else{var p=this.selectionWrap("blockquote");n=$(p).html();$.each(["ul","ol","table","tr","tbody","thead","tfoot","dl"],(function(t,e){n=(n=n.replace(new RegExp("<"+e+"(.*?)>","gi"),"")).replace(new RegExp("</"+e+">","gi"),"")}));var u=this.opts.blockLevelElements;$.each(u,(function(t,e){n=(n=n.replace(new RegExp("<"+e+"(.*?)>","gi"),"")).replace(new RegExp("</"+e+">","gi"),"<br>")})),$(p).html(n),this.selectionElement(p);var f=$(p).next();0!=f.length&&"BR"===f[0].tagName&&f.remove()}}this.sync()},blockRemoveAttr:function(t,e){var i=this.getBlocks();$(i).removeAttr(t),this.sync()},blockSetAttr:function(t,e){var i=this.getBlocks();$(i).attr(t,e),this.sync()},blockRemoveStyle:function(t){var e=this.getBlocks();$(e).css(t,""),this.removeEmptyAttr(e,"style"),this.sync()},blockSetStyle:function(t,e){var i=this.getBlocks();$(i).css(t,e),this.sync()},blockRemoveClass:function(t){var e=this.getBlocks();$(e).removeClass(t),this.removeEmptyAttr(e,"class"),this.sync()},blockSetClass:function(t){var e=this.getBlocks();$(e).addClass(t),this.sync()},inlineRemoveClass:function(t){this.selectionSave(),this.inlineEachNodes((function(e){$(e).removeClass(t),this.removeEmptyAttr(e,"class")})),this.selectionRestore(),this.sync()},inlineSetClass:function(t){var e=this.getCurrent();$(e).hasClass(t)||this.inlineMethods("addClass",t)},inlineRemoveStyle:function(t){this.selectionSave(),this.inlineEachNodes((function(e){$(e).css(t,""),this.removeEmptyAttr(e,"style")})),this.selectionRestore(),this.sync()},inlineSetStyle:function(t,e){this.inlineMethods("css",t,e)},inlineRemoveAttr:function(t){this.selectionSave();var e=this.getRange(),i=this.getElement(),s=this.getNodes();(e.collapsed||e.startContainer===e.endContainer&&i)&&(s=$(i)),$(s).removeAttr(t),this.inlineUnwrapSpan(),this.selectionRestore(),this.sync()},inlineSetAttr:function(t,e){this.inlineMethods("attr",t,e)},inlineMethods:function(t,e,i){this.bufferSet(),this.selectionSave();var s=this.getRange(),o=this.getElement();if(!s.collapsed&&s.startContainer!==s.endContainer||!o||this.nodeTestBlocks(o)){var r,a=i;switch(e){case"font-size":r="fontSize",a=4;break;case"font-family":r="fontName";break;case"color":r="foreColor";break;case"background-color":r="backColor"}this.document.execCommand(r,!1,a);var n=this.$editor.find("font");$.each(n,$.proxy((function(s,o){this.inlineSetMethods(t,o,e,i)}),this))}else $(o)[t](e,i);this.selectionRestore(),this.sync()},inlineSetMethods:function(t,e,i,s){var o,r=$(e).parent();return this.getSelectionText()==$(r).text()&&r&&"INLINE"===r[0].tagName&&0!=r[0].attributes.length?(o=r,$(e).replaceWith($(e).html())):(o=$("<inline>").append($(e).contents()),$(e).replaceWith(o)),$(o)[t](i,s),o},inlineEachNodes:function(t){var e,i=this.getRange(),s=this.getElement(),o=this.getNodes();(i.collapsed||i.startContainer===i.endContainer&&s)&&(o=$(s),e=!0),$.each(o,$.proxy((function(i,s){if(!e&&"INLINE"!==s.tagName){if(!(this.getSelectionText()==$(s).parent().text())||"INLINE"!==s.parentNode.tagName||$(s.parentNode).hasClass("redactor_editor"))return;s=s.parentNode}t.call(this,s)}),this))},inlineUnwrapSpan:function(){var t=this.$editor.find("inline");$.each(t,$.proxy((function(t,e){var i=$(e);void 0===i.attr("class")&&void 0===i.attr("style")&&i.contents().unwrap()}),this))},inlineFormat:function(t){this.selectionSave(),this.document.execCommand("fontSize",!1,4);var e=this.$editor.find("font");$.each(e,(function(e,i){var s=$("<"+t+"/>").append($(i).contents());$(i).replaceWith(s),s})),this.selectionRestore(),this.sync()},inlineRemoveFormat:function(t){this.selectionSave();var e=t.toUpperCase(),i=this.getNodes(),s=$(this.getParent()).parent();$.each(i,(function(t,i){i.tagName===e&&this.inlineRemoveFormatReplace(i)})),s&&s[0].tagName===e&&this.inlineRemoveFormatReplace(s),this.selectionRestore(),this.sync()},inlineRemoveFormatReplace:function(t){$(t).replaceWith($(t).contents())},insertHtml:function(t,e){var i=this.getCurrent(),s=i.parentNode;this.focusWithSaveScroll(),this.bufferSet();var o=$("<div>").append($.parseHTML(t));t=o.html(),t=this.cleanRemoveEmptyTags(t),o=$("<div>").append($.parseHTML(t));var r=this.getBlock();if(1==o.contents().length){var a=o.contents()[0].tagName;("P"!=a&&a==r.tagName||"CODE"==a)&&(o=$("<div>").append(t))}this.opts.linebreaks&&(t=t.replace(/<p(.*?)>([\w\W]*?)<\/p>/gi,"$2<br>")),!this.opts.linebreaks&&1==o.contents().length&&3==o.contents()[0].nodeType&&(this.getRangeSelectedNodes().length>2||!i||"BODY"==i.tagName&&!s||"HTML"==s.tagName)&&(t="<p>"+t+"</p>"),t=this.setSpansVerifiedHtml(t),o.contents().length>1&&r||o.contents().is("p, :header, ul, ol, li, div, table, td, blockquote, code, address, section, header, footer, aside, article")?this.browser("msie")?this.isIe11()?this.execPasteFrag(t):this.document.selection.createRange().pasteHTML(t):this.document.execCommand("inserthtml",!1,t):this.insertHtmlAdvanced(t,!1),this.selectall&&this.window.setTimeout($.proxy((function(){this.opts.linebreaks?this.focusEnd():this.selectionEnd(this.$editor.contents().last())}),this),1),this.observeStart(),this.setNonEditable(),!1!==e&&this.sync()},insertHtmlAdvanced:function(t,e){t=this.setSpansVerifiedHtml(t);var i=this.getSelection();if(i.getRangeAt&&i.rangeCount){var s=i.getRangeAt(0);s.deleteContents();var o=document.createElement("div");o.innerHTML=t;for(var r,a,n=document.createDocumentFragment();r=o.firstChild;)a=n.appendChild(r);s.insertNode(n),a&&((s=s.cloneRange()).setStartAfter(a),s.collapse(!0),i.removeAllRanges(),i.addRange(s))}!1!==e&&this.sync()},insertBeforeCursor:function(t){t=this.setSpansVerifiedHtml(t);var e=$(t),i=document.createElement("span");i.innerHTML="";var s=this.getRange();s.insertNode(i),s.insertNode(e[0]),s.collapse(!1);var o=this.getSelection();o.removeAllRanges(),o.addRange(s),this.sync()},insertText:function(t){var e=$($.parseHTML(t));e.length&&(t=e.text()),this.focusWithSaveScroll(),this.browser("msie")?this.isIe11()?this.execPasteFrag(t):this.document.selection.createRange().pasteHTML(t):this.document.execCommand("inserthtml",!1,t),this.sync()},insertNode:function(t){if("SPAN"==(t=t[0]||t).tagName){var e="inline",i=t.outerHTML,s=new RegExp("<"+t.tagName,"i"),o=i.replace(s,"<"+e);s=new RegExp("</"+t.tagName,"i"),o=o.replace(s,"</"+e),t=$(o)[0]}var r=this.getSelection();return r.getRangeAt&&r.rangeCount&&(range=r.getRangeAt(0),range.deleteContents(),range.insertNode(t),range.setEndAfter(t),range.setStartAfter(t),r.removeAllRanges(),r.addRange(range)),t},insertNodeToCaretPositionFromPoint:function(t,e){var i,s=t.clientX,o=t.clientY;if(this.document.caretPositionFromPoint){var r=this.document.caretPositionFromPoint(s,o);(i=this.getRange()).setStart(r.offsetNode,r.offset),i.collapse(!0),i.insertNode(e)}else if(this.document.caretRangeFromPoint)(i=this.document.caretRangeFromPoint(s,o)).insertNode(e);else if(void 0!==document.body.createTextRange){(i=this.document.body.createTextRange()).moveToPoint(s,o);var a=i.duplicate();a.moveToPoint(s,o),i.setEndPoint("EndToEnd",a),i.select()}},insertAfterLastElement:function(t,e){if(void 0!==e&&(t=e),this.isEndOfElement()){if(this.opts.linebreaks){var i=$("<div>").append($.trim(this.$editor.html())).contents(),s=i.last()[0];if("SPAN"==s.tagName&&""==s.innerHTML&&(s=i.prev()[0]),this.outerHtml(s)!=this.outerHtml(t))return!1}else if(this.$editor.contents().last()[0]!==t)return!1;this.insertingAfterLastElement(t)}},insertingAfterLastElement:function(t){if(this.bufferSet(),!1===this.opts.linebreaks){var e=$(this.opts.emptyHtml);$(t).after(e),this.selectionStart(e)}else{e=$('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>",this.document)[0];$(t).after(e),$(e).after(this.opts.invisibleSpace),this.selectionRestore(),this.$editor.find("span#selection-marker-1").removeAttr("id")}},insertLineBreak:function(t){this.selectionSave();var e="<br>";if(1==t&&(e="<br><br>"),this.browser("mozilla")){var i=$("<span>").html(this.opts.invisibleSpace);this.$editor.find("#selection-marker-1").before(e).before(i).before(this.opts.invisibleSpace),this.setCaretAfter(i[0]),i.remove(),this.selectionRemoveMarkers()}else{var s=this.getParent();if(s&&"A"===s.tagName)if(this.getCaretOffset(s)==$.trim($(s).text()).replace(/\n\r\n/g,"").length){this.selectionRemoveMarkers();var o=$('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>",this.document)[0];return $(s).after(o),$(o).before(e+(this.browser("webkit")?this.opts.invisibleSpace:"")),this.selectionRestore(),!0}this.$editor.find("#selection-marker-1").before(e+(this.browser("webkit")?this.opts.invisibleSpace:"")),this.selectionRestore()}},insertDoubleLineBreak:function(){this.insertLineBreak(!0)},replaceLineBreak:function(t){var e=$("<br>"+this.opts.invisibleSpace);$(t).replaceWith(e),this.selectionStart(e)},pasteClean:function(t){(t=this.callback("pasteBefore",!1,t),this.browser("msie"))&&(0==(e=$.trim(t)).search(/^<a(.*?)>(.*?)<\/a>$/i)&&(t=t.replace(/^<a(.*?)>(.*?)<\/a>$/i,"$2")));if(t=t.replace(/on([a-z]+)=|javascript\:/gi,""),this.opts.pastePlainText){var e=this.document.createElement("div");return t=t.replace(/<br>|<\/H[1-6]>|<\/p>|<\/div>/gi,"\n"),e.innerHTML=t,t=e.textContent||e.innerText,t=(t=$.trim(t)).replace("\n","<br>"),t=this.cleanParagraphy(t),this.pasteInsert(t),!1}var i=!1;if(this.currentOrParentIs("TD")){i=!0;var s=this.opts.blockLevelElements;s.push("tr"),s.push("table"),$.each(s,(function(e,i){t=(t=t.replace(new RegExp("<"+i+"(.*?)>","gi"),"")).replace(new RegExp("</"+i+">","gi"),"<br>")}))}if(this.currentOrParentIs("CODE"))return t=this.pastePre(t),this.pasteInsert(t),!0;if(t=(t=(t=(t=(t=(t=(t=t.replace(/<img(.*?)v:shapes=(.*?)>/gi,"")).replace(/<p(.*?)class="MsoListParagraphCxSpFirst"([\w\W]*?)<\/p>/gi,"<ul><li$2</li>")).replace(/<p(.*?)class="MsoListParagraphCxSpMiddle"([\w\W]*?)<\/p>/gi,"<li$2</li>")).replace(/<p(.*?)class="MsoListParagraphCxSpLast"([\w\W]*?)<\/p>/gi,"<li$2</li></ul>")).replace(/<p(.*?)class="MsoListParagraph"([\w\W]*?)<\/p>/gi,"<ul><li$2</li></ul>")).replace(/·/g,"")).replace(/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi,""),!0===this.opts.cleanSpaces&&(t=(t=t.replace(/( ){2,}/gi," ")).replace(/ /gi," ")),t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2")).replace(/<b(.*?)id="docs-internal-guid(.*?)">([\w\W]*?)<\/b>/gi,"$3")).replace(/<span[^>]*(font-style: italic; font-weight: bold|font-weight: bold; font-style: italic)[^>]*>/gi,'<span style="font-weight: bold;"><span style="font-style: italic;">')).replace(/<span[^>]*font-style: italic[^>]*>/gi,'<span style="font-style: italic;">')).replace(/<span[^>]*font-weight: bold[^>]*>/gi,'<span style="font-weight: bold;">')).replace(/<span[^>]*text-decoration: underline[^>]*>/gi,'<span style="text-decoration: underline;">')).replace(/<td>\u200b*<\/td>/gi,"[td]")).replace(/<td> <\/td>/gi,"[td]")).replace(/<td><br><\/td>/gi,"[td]")).replace(/<td(.*?)colspan="(.*?)"(.*?)>([\w\W]*?)<\/td>/gi,'[td colspan="$2"]$4[/td]')).replace(/<td(.*?)rowspan="(.*?)"(.*?)>([\w\W]*?)<\/td>/gi,'[td rowspan="$2"]$4[/td]')).replace(/<a(.*?)href="(.*?)"(.*?)>([\w\W]*?)<\/a>/gi,'[a href="$2"]$4[/a]')).replace(/<iframe(.*?)>([\w\W]*?)<\/iframe>/gi,"[iframe$1]$2[/iframe]")).replace(/<video(.*?)>([\w\W]*?)<\/video>/gi,"[video$1]$2[/video]")).replace(/<audio(.*?)>([\w\W]*?)<\/audio>/gi,"[audio$1]$2[/audio]")).replace(/<embed(.*?)>([\w\W]*?)<\/embed>/gi,"[embed$1]$2[/embed]")).replace(/<object(.*?)>([\w\W]*?)<\/object>/gi,"[object$1]$2[/object]")).replace(/<param(.*?)>/gi,"[param$1]")).replace(/<img(.*?)>/gi,"[img$1]")).replace(/ class="(.*?)"/gi,"")).replace(/<(\w+)([\w\W]*?)>/gi,"<$1>"),this.opts.linebreaks?(t=(t=t.replace(/<strong><\/strong>/gi,"")).replace(/<u><\/u>/gi,""),this.opts.cleanFontTag&&(t=t.replace(/<font(.*?)>([\w\W]*?)<\/font>/gi,"$2")),t=t.replace(/<[^\/>][^>]*>(\s*|\t*|\n*| |<br>)<\/[^>]+>/gi,"<br>")):t=t.replace(/<[^\/>][^>]*>(\s*|\t*|\n*| |<br>)<\/[^>]+>/gi,""),t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/<div>\s*?\t*?\n*?(<ul>|<ol>|<p>)/gi,"$1")).replace(/\[td colspan="(.*?)"\]([\w\W]*?)\[\/td\]/gi,'<td colspan="$1">$2</td>')).replace(/\[td rowspan="(.*?)"\]([\w\W]*?)\[\/td\]/gi,'<td rowspan="$1">$2</td>')).replace(/\[td\]/gi,"<td> </td>")).replace(/\[a href="(.*?)"\]([\w\W]*?)\[\/a\]/gi,'<a href="$1">$2</a>')).replace(/\[iframe(.*?)\]([\w\W]*?)\[\/iframe\]/gi,"<iframe$1>$2</iframe>")).replace(/\[video(.*?)\]([\w\W]*?)\[\/video\]/gi,"<video$1>$2</video>")).replace(/\[audio(.*?)\]([\w\W]*?)\[\/audio\]/gi,"<audio$1>$2</audio>")).replace(/\[embed(.*?)\]([\w\W]*?)\[\/embed\]/gi,"<embed$1>$2</embed>")).replace(/\[object(.*?)\]([\w\W]*?)\[\/object\]/gi,"<object$1>$2</object>")).replace(/\[param(.*?)\]/gi,"<param$1>")).replace(/\[img(.*?)\]/gi,"<img$1>"),t=this.opts.convertDivs?(t=(t=(t=t.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"<p>$2</p>")).replace(/<\/div><p>/gi,"<p>")).replace(/<\/p><\/div>/gi,"</p>")).replace(/<p><\/p>/gi,"<br />"):t.replace(/<div><\/div>/gi,"<br />"),t=this.cleanStripTags(t),this.currentOrParentIs("LI")?t=t.replace(/<p>([\w\W]*?)<\/p>/gi,"$1<br>"):!1===i&&(t=this.cleanParagraphy(t)),t=(t=(t=(t=(t=(t=(t=(t=t.replace(/<span(.*?)>([\w\W]*?)<\/span>/gi,"$2")).replace(/<img>/gi,"")).replace(/<[^\/>][^>][^img|param|source|td][^<]*>(\s*|\t*|\n*| |<br>)<\/[^>]+>/gi,"")).replace(/\n{3,}/gi,"\n")).replace(/<p><p>/gi,"<p>")).replace(/<\/p><\/p>/gi,"</p>")).replace(/<li>(\s*|\t*|\n*)<p>/gi,"<li>")).replace(/<\/p>(\s*|\t*|\n*)<\/li>/gi,"</li>"),!0===this.opts.linebreaks&&(t=t.replace(/<p(.*?)>([\w\W]*?)<\/p>/gi,"$2<br>")),t=(t=(t=t.replace(/<[^\/>][^>][^img|param|source|td][^<]*>(\s*|\t*|\n*| |<br>)<\/[^>]+>/gi,"")).replace(/<img src="webkit-fake-url\:\/\/(.*?)"(.*?)>/gi,"")).replace(/<td(.*?)>(\s*|\t*|\n*)<p>([\w\W]*?)<\/p>(\s*|\t*|\n*)<\/td>/gi,"<td$1>$3</td>"),this.opts.convertDivs&&(t=(t=t.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"$2")).replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"$2")),this.pasteClipboardMozilla=!1,this.browser("mozilla")){if(this.opts.clipboardUpload){var o=t.match(/<img src="data:image(.*?)"(.*?)>/gi);if(null!==o)for(var r in this.pasteClipboardMozilla=o,o){var a=o[r].replace("<img",'<img data-mozilla-paste-image="'+r+'" ');t=t.replace(o[r],a)}}for(;/<br>$/gi.test(t);)t=t.replace(/<br>$/gi,"")}if(t=t.replace(/<p>•([\w\W]*?)<\/p>/gi,"<li>$1</li>"),this.browser("msie"))for(;/<font>([\w\W]*?)<\/font>/gi.test(t);)t=t.replace(/<font>([\w\W]*?)<\/font>/gi,"$1");!1===i&&(t=(t=(t=(t=t.replace(/<td(.*?)>([\w\W]*?)<p(.*?)>([\w\W]*?)<\/td>/gi,"<td$1>$2$4</td>")).replace(/<td(.*?)>([\w\W]*?)<\/p>([\w\W]*?)<\/td>/gi,"<td$1>$2$3</td>")).replace(/<td(.*?)>([\w\W]*?)<p(.*?)>([\w\W]*?)<\/td>/gi,"<td$1>$2$4</td>")).replace(/<td(.*?)>([\w\W]*?)<\/p>([\w\W]*?)<\/td>/gi,"<td$1>$2$3</td>")),t=(t=t.replace(/\n/g," ")).replace(/<p>\n?<li>/gi,"<li>"),this.pasteInsert(t)},pastePre:function(t){t=t.replace(/<br>|<\/H[1-6]>|<\/p>|<\/div>/gi,"\n");var e=this.document.createElement("div");return e.innerHTML=t,this.cleanEncodeEntities(e.textContent||e.innerText)},pasteInsert:function(t){t=this.callback("pasteAfter",!1,t),this.selectall?(this.$editor.html(t),this.selectionRemove(),this.focusEnd(),this.sync()):this.insertHtml(t),this.selectall=!1,setTimeout($.proxy((function(){this.rtePaste=!1,this.browser("mozilla")&&this.$editor.find("p:empty").remove(),!1!==this.pasteClipboardMozilla&&this.pasteClipboardUploadMozilla()}),this),100),this.opts.autoresize&&!0!==this.fullscreen?$(this.document.body).scrollTop(this.saveScroll):this.$editor.scrollTop(this.saveScroll)},pasteClipboardAppendFields:function(t){return!1!==this.opts.uploadFields&&"object"==typeof this.opts.uploadFields&&$.each(this.opts.uploadFields,$.proxy((function(e,i){null!=i&&0===i.toString().indexOf("#")&&(i=$(i).val()),t[e]=i}),this)),t},pasteClipboardUploadMozilla:function(){var t=this.$editor.find("img[data-mozilla-paste-image]");$.each(t,$.proxy((function(t,e){var i=$(e),s=e.src.split(","),o={contentType:s[0].split(";")[0].split(":")[1],data:s[1]};o=this.pasteClipboardAppendFields(o),$.post(this.opts.clipboardUploadUrl,o,$.proxy((function(t){var e="string"==typeof t?$.parseJSON(t):t;i.attr("src",e.image.url),i.removeAttr("data-mozilla-paste-image"),this.sync(),this.callback("imageUpload",i,e)}),this))}),this))},pasteClipboardUpload:function(t){var e=t.target.result,i=e.split(","),s={contentType:i[0].split(";")[0].split(":")[1],data:i[1]};this.opts.clipboardUpload?(s=this.pasteClipboardAppendFields(s),$.post(this.opts.clipboardUploadUrl,s,$.proxy((function(t){var e="string"==typeof t?$.parseJSON(t):t,i='<img src="'+e.image.url+'" id="clipboard-image-marker" />';this.execCommand("inserthtml",i,!1);var s=$(this.$editor.find("img#clipboard-image-marker"));s.length?s.removeAttr("id"):s=!1,this.sync(),s&&this.callback("imageUpload",s,e)}),this))):this.insertHtml('<img src="'+e+'" />')},bufferSet:function(t){!1!==t&&this.selectionSave(),this.opts.buffer.push(this.$editor.html()),!1!==t&&this.selectionRemoveMarkers("buffer")},bufferUndo:function(){0!==this.opts.buffer.length?(this.selectionSave(),this.opts.rebuffer.push(this.$editor.html()),this.selectionRestore(!1,!0),this.$editor.html(this.opts.buffer.pop()),this.selectionRestore(),setTimeout($.proxy(this.observeStart,this),100)):this.focusWithSaveScroll()},bufferRedo:function(){if(0===this.opts.rebuffer.length)return this.focusWithSaveScroll(),!1;this.selectionSave(),this.opts.buffer.push(this.$editor.html()),this.selectionRestore(!1,!0),this.$editor.html(this.opts.rebuffer.pop()),this.selectionRestore(!0),setTimeout($.proxy(this.observeStart,this),4)},observeStart:function(){this.observeImages(),this.opts.observeLinks&&this.observeLinks()},observeLinks:function(){this.$editor.find("a").on("click",$.proxy(this.linkObserver,this)),this.$editor.on("click.redactor",$.proxy((function(t){this.linkObserverTooltipClose(t)}),this)),$(document).on("click.redactor",$.proxy((function(t){this.linkObserverTooltipClose(t)}),this))},observeImages:function(){if(!1===this.opts.observeImages)return!1;this.$editor.find("img").each($.proxy((function(t,e){this.browser("msie")&&$(e).attr("unselectable","on");var i=$(e).parent();i.hasClass("royalSlider")||i.hasClass("fotorama")||this.imageResize(e)}),this)),this.$editor.find(".fotorama, .royalSlider").on("click",$.proxy(this.editGallery,this))},linkObserver:function(t){var e=$(t.target),i=$(t.target).parent();if(!i.hasClass("royalSlider")&&!i.hasClass("fotorama")&&0!=e.length&&"A"===e[0].tagName){var s=e.offset();if(this.opts.iframe){var o=this.$frame.offset();s.top=o.top+(s.top-$(this.document).scrollTop()),s.left+=o.left}var r=$('<span class="redactor-link-tooltip"></span>'),a=e.attr("href");void 0===a&&(a=""),a.length>24&&(a=a.substring(0,24)+"...");var n=$('<a href="'+e.attr("href")+'" target="_blank">'+a+"</a>").on("click",$.proxy((function(t){this.linkObserverTooltipClose(!1)}),this)),l=$('<a href="#">'+this.opts.curLang.edit+"</a>").on("click",$.proxy((function(t){t.preventDefault(),this.linkShow(),this.linkObserverTooltipClose(!1)}),this)),c=$('<a href="#">'+this.opts.curLang.unlink+"</a>").on("click",$.proxy((function(t){t.preventDefault(),this.execCommand("unlink"),this.linkObserverTooltipClose(!1)}),this));r.append(n),r.append(" | "),r.append(l),r.append(" | "),r.append(c),r.css({top:s.top+20+"px",left:s.left+"px"}),$(".redactor-link-tooltip").remove(),$("body").append(r)}},linkObserverTooltipClose:function(t){if(!1!==t&&"A"==t.target.tagName)return!1;$(".redactor-link-tooltip").remove()},getSelection:function(){return this.opts.rangy?this.opts.iframe?rangy.getSelection(this.$frame[0]):rangy.getSelection():this.document.getSelection()},getRange:function(){if(this.opts.rangy)return this.opts.iframe?rangy.createRange(this.iframeDoc()):rangy.createRange();if(this.document.getSelection){var t=this.getSelection();if(t.getRangeAt&&t.rangeCount)return t.getRangeAt(0)}return this.document.createRange()},selectionElement:function(t){this.setCaret(t)},selectionStart:function(t){this.selectionSet(t[0]||t,0,null,0)},selectionEnd:function(t){this.selectionSet(t[0]||t,1,null,1)},selectionSet:function(t,e,i,s){null==i&&(i=t),null==s&&(s=e);var o=this.getSelection();if(o){if("P"==t.tagName&&""==t.innerHTML&&(t.innerHTML=this.opts.invisibleSpace),"BR"==t.tagName&&!1===this.opts.linebreaks){var r=$(this.opts.emptyHtml)[0];$(t).replaceWith(r),i=t=r}var a=this.getRange();a.setStart(t,e),a.setEnd(i,s);try{o.removeAllRanges()}catch(t){}o.addRange(a)}},selectionWrap:function(t){t=t.toLowerCase();var e=this.getBlock();if(e){var i=this.formatChangeTag(e,t);return this.sync(),i}var s=this.getSelection().getRangeAt(0);return(i=document.createElement(t)).appendChild(s.extractContents()),s.insertNode(i),this.selectionElement(i),i},selectionAll:function(){var t=this.getRange();t.selectNodeContents(this.$editor[0]);var e=this.getSelection();e.removeAllRanges(),e.addRange(t)},selectionRemove:function(){this.getSelection().removeAllRanges()},getCaretOffset:function(t){var e=this.getRange(),i=e.cloneRange();return i.selectNodeContents(t),i.setEnd(e.endContainer,e.endOffset),$.trim(i.toString()).length},getCaretOffsetRange:function(){return new Range(this.getSelection().getRangeAt(0))},setCaret:function(t,e,i){void 0===i&&(i=e),t=t[0]||t;var s=this.getRange();s.selectNodeContents(t);var o,r=this.getTextNodesIn(t),a=!1,n=0;if(1==r.length&&e)s.setStart(r[0],e),s.setEnd(r[0],i);else for(var l,c=0;l=r[c++];){if(o=n+l.length,!a&&e>=n&&(e<o||e==o&&c<r.length)&&(s.setStart(l,e-n),a=!0),a&&i<=o){s.setEnd(l,i-n);break}n=o}var d=this.getSelection();d.removeAllRanges(),d.addRange(s)},setCaretAfter:function(t){this.$editor.focus(),t=t[0]||t;var e=this.document.createRange();e.setStart(t,1),e.setEnd(t,1);var i=this.window.getSelection(),s=this.document.createRange(),o=this.document.createTextNode("");$(t).after(o),s.setStartAfter(o),i.removeAllRanges(),i.addRange(s),$(o).remove()},getTextNodesIn:function(t){var e=[];if(3==t.nodeType)e.push(t);else for(var i=t.childNodes,s=0,o=i.length;s<o;++s)e.push.apply(e,this.getTextNodesIn(i[s]));return e},getCurrent:function(){var t=!1,e=this.getSelection();return e&&e.rangeCount>0&&(t=e.getRangeAt(0).startContainer),this.isParentRedactor(t)},getParent:function(t){return!!(t=t||this.getCurrent())&&this.isParentRedactor($(t).parent()[0])},getBlock:function(t){for(void 0===t&&(t=this.getCurrent());t;){if(this.nodeTestBlocks(t))return!$(t).hasClass("redactor_editor")&&t;t=t.parentNode}return!1},getBlocks:function(t){var e=[];if(void 0===t){var i=this.getRange();if(i&&!0===i.collapsed)return[this.getBlock()];t=this.getNodes(i)}return $.each(t,$.proxy((function(t,i){if(!1===this.opts.iframe&&0==$(i).parents("div.redactor_editor").length)return!1;this.nodeTestBlocks(i)&&e.push(i)}),this)),0===e.length&&(e=[this.getBlock()]),e},isInlineNode:function(t){return 1==t.nodeType&&!this.rTestBlock.test(t.nodeName)},nodeTestBlocks:function(t){return 1==t.nodeType&&this.rTestBlock.test(t.nodeName)},tagTestBlock:function(t){return this.rTestBlock.test(t)},getNodes:function(t,e){if(void 0===t||0==t)t=this.getRange();if(t&&!0===t.collapsed)return void 0===e&&this.tagTestBlock(e)?(r=this.getBlock()).tagName==e?[r]:[]:[this.getCurrent()];var i=[],s=[],o=this.document.getSelection();if(o.isCollapsed||(i=this.getRangeSelectedNodes(o.getRangeAt(0))),$.each(i,$.proxy((function(t,i){if(!1===this.opts.iframe&&0==$(i).parents("div.redactor_editor").length)return!1;void 0===e?""!=$.trim(i.textContent)&&s.push(i):i.tagName==e&&s.push(i)}),this)),0==s.length){var r;if(void 0===e&&this.tagTestBlock(e))return(r=this.getBlock()).tagName==e?s.push(r):[];s.push(this.getCurrent())}var a=s[s.length-1];return this.nodeTestBlocks(a)&&(s=s.slice(0,-1)),s},getElement:function(t){for(t||(t=this.getCurrent());t;){if(1==t.nodeType)return!$(t).hasClass("redactor_editor")&&t;t=t.parentNode}return!1},getRangeSelectedNodes:function(t){var e=(t=t||this.getRange()).startContainer,i=t.endContainer;if(e==i)return[e];for(var s=[];e&&e!=i;)s.push(e=this.nextNode(e));for(e=t.startContainer;e&&e!=t.commonAncestorContainer;)s.unshift(e),e=e.parentNode;return s},nextNode:function(t){if(t.hasChildNodes())return t.firstChild;for(;t&&!t.nextSibling;)t=t.parentNode;return t?t.nextSibling:null},getSelectionText:function(){return this.getSelection().toString()},getSelectionHtml:function(){var t="",e=this.getSelection();if(e.rangeCount){for(var i=this.document.createElement("div"),s=e.rangeCount,o=0;o<s;++o)i.appendChild(e.getRangeAt(o).cloneContents());t=i.innerHTML}return this.syncClean(t)},selectionSave:function(){this.isFocused()||this.focusWithSaveScroll(),this.opts.rangy?this.savedSel=rangy.saveSelection():this.selectionCreateMarker(this.getRange())},selectionCreateMarker:function(t,e){if(t){var i=$('<span id="selection-marker-1" class="redactor-selection-marker">'+this.opts.invisibleSpace+"</span>",this.document)[0],s=$('<span id="selection-marker-2" class="redactor-selection-marker">'+this.opts.invisibleSpace+"</span>",this.document)[0];!0===t.collapsed?this.selectionSetMarker(t,i,!0):(this.selectionSetMarker(t,i,!0),this.selectionSetMarker(t,s,!1)),this.savedSel=this.$editor.html(),this.selectionRestore(!1,!1)}},selectionSetMarker:function(t,e,i){var s=t.cloneRange();try{s.collapse(i),s.insertNode(e),s.detach()}catch(t){var o=this.opts.emptyHtml;this.opts.linebreaks&&(o="<br>"),this.$editor.prepend(o),this.focus()}},selectionRestore:function(t,e){if(this.opts.rangy)rangy.restoreSelection(this.savedSel);else{!0===t&&this.savedSel&&this.$editor.html(this.savedSel);var i=this.$editor.find("span#selection-marker-1"),s=this.$editor.find("span#selection-marker-2");this.browser("mozilla")?this.$editor.focus():this.isFocused()||this.focusWithSaveScroll(),0!=i.length&&0!=s.length?this.selectionSet(i[0],0,s[0],0):0!=i.length&&this.selectionSet(i[0],0,null,0),!1!==e&&(this.selectionRemoveMarkers(),this.savedSel=!1)}},selectionRemoveMarkers:function(t){this.opts.rangy?rangy.removeMarkers(this.savedSel):$.each(this.$editor.find("span.redactor-selection-marker"),(function(){""==$.trim($(this).html().replace(/[^\u0000-\u1C7F]/g,""))?$(this).remove():$(this).removeAttr("class").removeAttr("id")}))},tableShow:function(){this.selectionSave(),this.modalInit(this.opts.curLang.table,this.opts.modal_table,300,$.proxy((function(){$("#redactor_insert_table_btn").on("click",$.proxy(this.tableInsert,this)),setTimeout((function(){$("#redactor_table_rows").focus()}),200)}),this))},tableInsert:function(){this.bufferSet(!1);var t,e,i,s,o=$("#redactor_table_rows").val(),r=$("#redactor_table_columns").val(),a=$("<div></div>"),n=Math.floor(99999*Math.random()),l=$('<table id="table'+n+'"><tbody></tbody></table>');for(t=0;t<o;t++){for(e=$("<tr></tr>"),i=0;i<r;i++)s=$("<td>"+this.opts.invisibleSpace+"</td>"),0===t&&0===i&&s.append('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),$(e).append(s);l.append(e)}a.append(l);var c=a.html();if(!1===this.opts.linebreaks&&this.browser("mozilla")&&(c+="<p>"+this.opts.invisibleSpace+"</p>"),this.modalClose(),this.selectionRestore(),(d=this.getBlock()||this.getCurrent())&&"BODY"!=d.tagName){if("LI"==d.tagName)var d=$(d).closest("ul, ol");$(d).after(c)}else this.insertHtmlAdvanced(c,!1);this.selectionRestore();var h=this.$editor.find("#table"+n);this.buttonActiveObserver(),h.find("span#selection-marker-1, inline#selection-marker-1").remove(),h.removeAttr("id"),this.sync()},tableDeleteTable:function(){var t=$(this.getParent()).closest("table");return!!this.isParentRedactor(t)&&(0!=t.length&&(this.bufferSet(),t.remove(),void this.sync()))},tableDeleteRow:function(){var t=this.getParent(),e=$(t).closest("table");if(!this.isParentRedactor(e))return!1;if(0==e.length)return!1;this.bufferSet();var i=$(t).closest("tr"),s=i.prev().length?i.prev():i.next();if(s.length){var o=s.children("td").first();o.length&&o.prepend('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>")}i.remove(),this.selectionRestore(),e.find("span#selection-marker-1").remove(),this.sync()},tableDeleteColumn:function(){var t=this.getParent(),e=$(t).closest("table");if(!this.isParentRedactor(e))return!1;if(0==e.length)return!1;this.bufferSet();var i=$(t).closest("td");i.is("td")||(i=i.closest("td"));var s=i.get(0).cellIndex;e.find("tr").each($.proxy((function(t,e){var i=s-1<0?s+1:s-1;0===t&&$(e).find("td").eq(i).prepend('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),$(e).find("td").eq(s).remove()}),this)),this.selectionRestore(),e.find("span#selection-marker-1").remove(),this.sync()},tableAddHead:function(){var t=$(this.getParent()).closest("table");if(!this.isParentRedactor(t))return!1;if(0==t.length)return!1;if(this.bufferSet(),0!==t.find("thead").length)this.tableDeleteHead();else{var e=t.find("tr").first().clone();e.find("td").replaceWith("<th></th>").html(this.opts.invisibleSpace),$thead=$("<thead></thead>"),$thead.append(e),t.prepend($thead),this.sync()}},tableDeleteHead:function(){var t=$(this.getParent()).closest("table");if(!this.isParentRedactor(t))return!1;var e=t.find("thead");if(0==e.length)return!1;this.bufferSet(),e.remove(),this.sync()},tableAddRowAbove:function(){this.tableAddRow("before")},tableAddRowBelow:function(){this.tableAddRow("after")},tableAddColumnLeft:function(){this.tableAddColumn("before")},tableAddColumnRight:function(){this.tableAddColumn("after")},tableAddRow:function(t){var e=$(this.getParent()).closest("table");if(!this.isParentRedactor(e))return!1;if(0==e.length)return!1;this.bufferSet();var i=$(this.getParent()).closest("tr"),s=i.clone();s.find("td").html(this.opts.invisibleSpace),"after"===t?i.after(s):i.before(s),this.sync()},tableAddColumn:function(t){var e=this.getParent(),i=$(e).closest("table");if(!this.isParentRedactor(i))return!1;if(0==i.length)return!1;this.bufferSet();var s=0,o=this.getCurrent(),r=$(o).closest("tr"),a=$(o).closest("td");r.find("td").each($.proxy((function(t,e){$(e)[0]===a[0]&&(s=t)}),this)),i.find("tr").each($.proxy((function(e,i){var o=$(i).find("td").eq(s),r=o.clone();r.html(this.opts.invisibleSpace),"after"===t?o.after(r):o.before(r)}),this)),this.sync()},videoShow:function(){this.selectionSave(),this.modalInit(this.opts.curLang.video,this.opts.modal_video,600,$.proxy((function(){$("#redactor_insert_video_btn").on("click",$.proxy(this.videoInsert,this)),setTimeout((function(){$("#redactor_insert_video_area").focus()}),200)}),this))},videoInsert:function(){var t=$("#redactor_insert_video_area").val(),e='<iframe width="500" height="281" src="',i='" frameborder="0" allowfullscreen></iframe>';(t=this.cleanStripTags(t)).match(reUrlYoutube)?t=t.replace(reUrlYoutube,e+"//www.youtube.com/embed/$1"+i):t.match(reUrlVimeo)?t=t.replace(reUrlVimeo,e+"//player.vimeo.com/video/$2"+i):t.match(reUrlFacebook)?t=t.replace(reUrlFacebook,e+"https://www.facebook.com/video/embed?video_id=$1"+i):t.match(reUrlRutube)&&(t=t.replace(reUrlRutube,e+"//rutube.ru/play/embed/$1"+i)),this.selectionRestore();var s=this.getBlock()||this.getCurrent();t=this.sanitizeHTML(t),s?$(s).after(t):this.insertHtmlAdvanced(t,!1),this.sync(),this.modalClose()},linkShow:function(){this.selectionSave();var t=$.proxy((function(){if(!1!==this.opts.predefinedLinks){this.predefinedLinksStorage={};var t=this;$.getJSON(this.opts.predefinedLinks,(function(e){if(0!==Object.keys(e).length){var i=$("#redactor-predefined-links");i.html(""),$.each(e,(function(e,s){t.predefinedLinksStorage[e]=s,i.append($("<option>").val(e).html(s.name))})),i.on("change",(function(){var e=$(this).val(),i="",s="";0!=e&&(i=t.predefinedLinksStorage[e].name,s=t.predefinedLinksStorage[e].url),$("#redactor_link_url").val(s),1!=$("#redactor_link_url_text").data("is_selected_text")&&$("#redactor_link_url_text").val(i)})),i.show()}}))}this.insert_link_node=!1;var e=this.getSelection(),i="",s="",o="",r=this.getParent(),a=$(r).parent().get(0);a&&"A"===a.tagName&&(r=a),r&&"A"===r.tagName?(i=r.href,s=$(r).text(),o=r.target,this.insert_link_node=r):s=e.toString(),$("#redactor_link_url_text").val(s),s.length>0&&$("#redactor_link_url_text").data("is_selected_text",1);var n=self.location.href.replace(/\/$/i,"");if(i=(i=(i=i.replace(n,"")).replace(/^\/#/,"#")).replace("mailto:",""),!1===this.opts.linkProtocol){var l=new RegExp("^(http|ftp|https)://"+self.location.host,"i");i=i.replace(l,"")}$("#redactor_link_url").val(i),"_blank"===o&&$("#redactor_link_blank").prop("checked",!0),this.linkInsertPressed=!1,$("#redactor_insert_link_btn").on("click",$.proxy(this.linkProcess,this)),setTimeout((function(){$("#redactor_link_url").focus()}),200)}),this);this.modalInit(this.opts.curLang.link,this.opts.modal_link,460,t)},linkProcess:function(){if(!this.linkInsertPressed){this.linkInsertPressed=!0;var t="",e="",i=$("#redactor_link_url").val(),s=$("#redactor_link_url_text").val();if(-1!=i.search("@")&&!1===/(http|ftp|https):\/\//i.test(i))i="mailto:"+i;else if(0!=i.search("#")){$("#redactor_link_blank").prop("checked")&&(t=' target="_blank"',e="_blank");var o="((xn--)?[a-z0-9]+(-[a-z0-9]+)*.)+[a-z]{2,}",r=new RegExp("^(http|ftp|https)://"+o,"i"),a=new RegExp("^"+o,"i");-1==i.search(r)&&0==i.search(a)&&this.opts.linkProtocol&&(i=this.opts.linkProtocol+i)}s=s.replace(/<|>/g,"");var n=" ";this.browser("mozilla")&&(n=" "),this.linkInsert('<a href="'+i+'"'+t+">"+s+"</a>"+n,$.trim(s),i,e)}},linkInsert:function(t,e,i,s){if(this.selectionRestore(),""!==e){if(this.insert_link_node)this.bufferSet(),$(this.insert_link_node).text(e).attr("href",i),""!==s?$(this.insert_link_node).attr("target",s):$(this.insert_link_node).removeAttr("target");else{var o=$(t).addClass("redactor-added-link");this.exec("inserthtml",this.outerHtml(o),!1),(i=this.$editor.find("a.redactor-added-link")).removeAttr("style").removeClass("redactor-added-link").each((function(){""==this.className&&$(this).removeAttr("class")}))}this.sync()}setTimeout($.proxy((function(){this.opts.observeLinks&&this.observeLinks()}),this),5),this.modalClose()},fileShow:function(){this.selectionSave();var t=$.proxy((function(){var t=this.getSelection(),e="";e=this.oldIE()?t.text:t.toString(),$("#redactor_filename").val(e),this.isMobile()||this.isIPad()||this.draguploadInit("#redactor_file",{url:this.opts.fileUpload,uploadFields:this.opts.uploadFields,success:$.proxy(this.fileCallback,this),error:$.proxy((function(t,e){this.callback("fileUploadError",e)}),this),uploadParam:this.opts.fileUploadParam}),this.uploadInit("redactor_file",{auto:!0,url:this.opts.fileUpload,success:$.proxy(this.fileCallback,this),error:$.proxy((function(t,e){this.callback("fileUploadError",e)}),this)})}),this);this.modalInit(this.opts.curLang.file,this.opts.modal_file,500,t)},fileCallback:function(t){if(this.selectionRestore(),!1!==t){var e=$("#redactor_filename").val();""===e&&(e=t.filename);var i='<a href="'+t.filelink+'" id="filelink-marker">'+e+"</a>";this.browser("webkit")&&this.window.chrome&&(i+=" "),this.execCommand("inserthtml",i,!1);var s=$(this.$editor.find("a#filelink-marker"));0!=s.length?s.removeAttr("id"):s=!1,this.sync(),this.callback("fileUpload",s,t)}this.modalClose()},imageShow:function(){this.selectionSave();var t=$.proxy((function(){this.opts.imageGetJson?$.getJSON(this.opts.imageGetJson,$.proxy((function(t){if(t.error)alert(t.message);else{var e={},i=0;$.each(t,$.proxy((function(t,s){void 0!==s.folder&&(i++,e[s.folder]=i)}),this)),$("#redactor_image_box .empty_list").show();var s=!1;if($.each(t,$.proxy((function(t,i){var o="";void 0!==i.title&&(o=i.title);var r=0;$.isEmptyObject(e)||void 0===i.folder||(r=e[i.folder],!1===s&&(s=".redactorfolder"+r));var a=$('<img src="'+i.thumb+'" class="redactorfolder redactorfolder'+r+'" rel="'+i.image+'" title="'+o+'" />');$("#redactor_image_box").append(a),$(a).on("click",$.proxy(this.imageThumbClick,this)),$("#redactor_image_box .empty_list").hide()}),this)),!$.isEmptyObject(e)){$(".redactorfolder").hide(),$(s).show();var o=$('<select id="redactor_image_box_select">');$.each(e,(function(t,e){o.append($('<option value="'+e+'">'+t+"</option>"))})),$("#redactor_image_box").before(o),o.change((function(t){$(".redactorfolder").hide(),$(".redactorfolder"+$(t.target).val()).show()}))}}}),this)):$("#redactor-tab-control-2").remove(),this.opts.imageUpload||this.opts.s3?(this.isMobile()||this.isIPad()||!1!==this.opts.s3||$("#redactor_file").length&&this.draguploadInit("#redactor_file",{url:this.opts.imageUpload,uploadFields:this.opts.uploadFields,success:$.proxy(this.imageCallback,this),error:$.proxy((function(t,e){this.callback("imageUploadError",e)}),this),uploadParam:this.opts.imageUploadParam}),!1===this.opts.s3?this.uploadInit("redactor_file",{auto:!0,url:this.opts.imageUpload,success:$.proxy(this.imageCallback,this),error:$.proxy((function(t,e){this.callback("imageUploadError",e)}),this)}):$("#redactor_file").on("change.redactor",$.proxy(this.s3handleFileSelect,this))):($(".redactor_tab").hide(),this.opts.imageGetJson?($("#redactor-tab-control-1").remove(),$("#redactor-tab-control-2").addClass("redactor_tabs_act"),$("#redactor_tab2").show()):($("#redactor_tabs").remove(),$("#redactor_tab3").show())),this.opts.imageTabLink||!this.opts.imageUpload&&!this.opts.imageGetJson||$("#redactor-tab-control-3").hide(),$("#redactor_upload_btn").on("click",$.proxy(this.imageCallbackLink,this)),this.opts.imageUpload||this.opts.imageGetJson||setTimeout((function(){$("#redactor_file_link").focus()}),200)}),this);this.modalInit(this.opts.curLang.image,this.opts.modal_image,610,t)},imageEdit:function(t){var e=t,i=e.parent().parent(),s=$.proxy((function(){$("#redactor_file_alt").val(e.attr("alt")),$("#redactor_image_edit_src").attr("href",e.attr("src")),"block"==e.css("display")&&"none"==e.css("float")?$("#redactor_form_image_align").val("center"):$("#redactor_form_image_align").val(e.css("float")),"A"===$(i).get(0).tagName&&($("#redactor_file_link").val($(i).attr("href")),"_blank"==$(i).attr("target")&&$("#redactor_link_blank").prop("checked",!0)),$("#redactor_image_delete_btn").on("click",$.proxy((function(){this.imageRemove(e)}),this)),$("#redactorSaveBtn").on("click",$.proxy((function(){this.imageSave(e)}),this))}),this);this.modalInit(this.opts.curLang.edit,this.opts.modal_image_edit,380,s)},imageRemove:function(t){var e=$(t).parent().parent(),i=$(t).parent(),s=!1;e.length&&"A"===e[0].tagName?(s=!0,$(e).remove()):i.length&&"A"===i[0].tagName?(s=!0,$(i).remove()):$(t).remove(),i.length&&"P"===i[0].tagName&&(this.focusWithSaveScroll(),!1===s&&this.selectionStart(i)),this.callback("imageDelete",t),this.modalClose(),this.sync()},imageSave:function(t){this.imageResizeHide(!1);var e=$(t),i=e.parent();e.attr("alt",$("#redactor_file_alt").val());var s=$("#redactor_form_image_align").val(),o="";"left"===s?(o="0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin+" 0",e.css({float:"left",margin:o})):"right"===s?(o="0 0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin,e.css({float:"right",margin:o})):"center"===s?e.css({float:"",display:"block",margin:"auto"}):e.css({float:"",display:"",margin:""});var r=$.trim($("#redactor_file_link").val());if(""!==r){var a=!1;if($("#redactor_link_blank").prop("checked")&&(a=!0),"A"!==i.get(0).tagName){var n=$('<a href="'+r+'">'+this.outerHtml(t)+"</a>");a&&n.attr("target","_blank"),e.replaceWith(n)}else i.attr("href",r),a?i.attr("target","_blank"):i.removeAttr("target")}else"A"===i.get(0).tagName&&i.replaceWith(this.outerHtml(t));this.modalClose(),this.observeImages(),this.sync()},imageResizeHide:function(t){if(!1!==t&&0!=$(t.target).parent().length&&"redactor-image-box"===$(t.target).parent()[0].id)return!1;var e=this.$editor.find("#redactor-image-box");if(0==e.length)return!1;this.$editor.find("#redactor-image-editter, #redactor-image-resizer").remove(),e.find("img").css({marginTop:e[0].style.marginTop,marginBottom:e[0].style.marginBottom,marginLeft:e[0].style.marginLeft,marginRight:e[0].style.marginRight}),e.css("margin",""),e.find("img").css("opacity",""),e.replaceWith((function(){return $(this).contents()})),$(document).off("click.redactor-image-resize-hide"),this.$editor.off("click.redactor-image-resize-hide"),this.$editor.off("keydown.redactor-image-delete"),this.sync()},imageResize:function(t){var e=$(t);e.on("mousedown",$.proxy((function(){this.imageResizeHide(!1)}),this)),e.on("dragstart",$.proxy((function(){this.$editor.on("drop.redactor-image-inside-drop",$.proxy((function(){setTimeout($.proxy((function(){this.observeImages(),this.$editor.off("drop.redactor-image-inside-drop"),this.sync()}),this),1)}),this))}),this)),e.on("click",$.proxy((function(t){if(0!=this.$editor.find("#redactor-image-box").length)return!1;var i,s=e.width()/e.height(),o=this.imageResizeControls(e),r=!1;!1!==o&&(o.on("mousedown",(function(t){r=!0,t.preventDefault(),s=e.width()/e.height(),Math.round(t.pageX-e.eq(0).offset().left),i=Math.round(t.pageY-e.eq(0).offset().top)})),$(this.document.body).on("mousemove",$.proxy((function(t){if(r){Math.round(t.pageX-e.eq(0).offset().left);var o=Math.round(t.pageY-e.eq(0).offset().top)-i,a=e.height(),n=parseInt(a,10)+o,l=Math.round(n*s);l>20&&(e.width(l),l<100?this.imageEditter.css({marginTop:"-7px",marginLeft:"-13px",fontSize:"9px",padding:"3px 5px"}):this.imageEditter.css({marginTop:"-11px",marginLeft:"-18px",fontSize:"11px",padding:"7px 10px"})),Math.round(t.pageX-e.eq(0).offset().left),i=Math.round(t.pageY-e.eq(0).offset().top),this.sync()}}),this)).on("mouseup",(function(){r=!1}))),this.$editor.on("keydown.redactor-image-delete",$.proxy((function(t){var i=t.which;this.keyCode.BACKSPACE!=i&&this.keyCode.DELETE!=i||(this.bufferSet(!1),this.imageResizeHide(!1),this.imageRemove(e))}),this)),$(document).on("click.redactor-image-resize-hide",$.proxy(this.imageResizeHide,this)),this.$editor.on("click.redactor-image-resize-hide",$.proxy(this.imageResizeHide,this))}),this))},imageResizeControls:function(t){var e=$('<span id="redactor-image-box" data-redactor="verified">');if(e.css({position:"relative",display:"inline-block",lineHeight:0,outline:"1px dashed rgba(0, 0, 0, .6)",float:t.css("float")}),e.attr("contenteditable",!1),"auto"!=t[0].style.margin?(e.css({marginTop:t[0].style.marginTop,marginBottom:t[0].style.marginBottom,marginLeft:t[0].style.marginLeft,marginRight:t[0].style.marginRight}),t.css("margin","")):e.css({display:"block",margin:"auto"}),t.css("opacity",.5).after(e),this.imageEditter=$('<span id="redactor-image-editter" data-redactor="verified">'+this.opts.curLang.edit+"</span>"),this.imageEditter.css({position:"absolute",zIndex:5,top:"50%",left:"50%",marginTop:"-11px",marginLeft:"-18px",lineHeight:1,backgroundColor:"#000",color:"#fff",fontSize:"11px",padding:"7px 10px",cursor:"pointer"}),this.imageEditter.attr("contenteditable",!1),this.imageEditter.on("click",$.proxy((function(){this.imageEdit(t)}),this)),e.append(this.imageEditter),this.opts.imageResizable){var i=$('<span id="redactor-image-resizer" data-redactor="verified"></span>');return i.css({position:"absolute",zIndex:2,lineHeight:1,cursor:"nw-resize",bottom:"-4px",right:"-5px",border:"1px solid #fff",backgroundColor:"#000",width:"8px",height:"8px"}),i.attr("contenteditable",!1),e.append(i),e.append(t),i}return e.append(t),!1},imageThumbClick:function(t){var e='<img id="image-marker" src="'+$(t.target).attr("rel")+'" alt="'+$(t.target).attr("title")+'" />',i=this.getParent();this.opts.paragraphy&&0==$(i).closest("li").length&&(e="<p>"+e+"</p>"),this.imageInsert(e,!0)},imageCallbackLink:function(){var t=$("#redactor_file_link").val();if(""!==t){var e='<img id="image-marker" src="'+t+'" />';!1===this.opts.linebreaks&&(e="<p>"+e+"</p>"),this.imageInsert(e,!0)}else this.modalClose()},imageCallback:function(t){this.imageInsert(t)},imageInsert:function(t,e){if(this.selectionRestore(),!1!==t){var i="";if(!0!==e){i='<img id="image-marker" src="'+t.image.url+'" />';var s=this.getParent();this.opts.paragraphy&&0==$(s).closest("li").length&&(i="<p>"+i+"</p>")}else i=t;this.execCommand("inserthtml",i,!1);var o=$(this.$editor.find("img#image-marker"));o.length?o.removeAttr("id"):o=!1,this.sync(),!0!==e&&this.callback("imageUpload",o,t)}this.modalClose(),this.observeImages()},buildProgressBar:function(){0==$("#redactor-progress").length&&(this.$progressBar=$('<div id="redactor-progress"><span></span></div>'),$(document.body).append(this.$progressBar))},showProgressBar:function(){this.buildProgressBar(),$("#redactor-progress").fadeIn()},hideProgressBar:function(){$("#redactor-progress").fadeOut(1500)},modalTemplatesInit:function(){$.extend(this.opts,{modal_file:String()+'<section id="redactor-modal-file-insert"><form id="redactorUploadFileForm" method="post" action="" enctype="multipart/form-data"><label>'+this.opts.curLang.filename+'</label><input type="text" id="redactor_filename" class="redactor_input" /><div style="margin-top: 7px;"><input type="file" id="redactor_file" name="'+this.opts.fileUploadParam+'" /></div></form></section>',modal_image_edit:String()+'<section id="redactor-modal-image-edit"><label>'+this.opts.curLang.title+'</label><input type="text" id="redactor_file_alt" class="redactor_input" /><label>'+this.opts.curLang.link+'</label><input type="text" id="redactor_file_link" class="redactor_input" /><label><input type="checkbox" id="redactor_link_blank"> '+this.opts.curLang.link_new_tab+"</label><label>"+this.opts.curLang.image_position+'</label><select id="redactor_form_image_align"><option value="none">'+this.opts.curLang.none+'</option><option value="left">'+this.opts.curLang.left+'</option><option value="center">'+this.opts.curLang.center+'</option><option value="right">'+this.opts.curLang.right+'</option></select></section><footer><button id="redactor_image_delete_btn" class="redactor_modal_btn redactor_modal_delete_btn">'+this.opts.curLang._delete+'</button><button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button><button id="redactorSaveBtn" class="redactor_modal_btn redactor_modal_action_btn">'+this.opts.curLang.save+"</button></footer>",modal_image:String()+'<section id="redactor-modal-image-insert"><div id="redactor_tabs"><a href="#" id="redactor-tab-control-1" class="redactor_tabs_act">'+this.opts.curLang.upload+'</a><a href="#" id="redactor-tab-control-2">'+this.opts.curLang.choose+'</a><a href="#" id="redactor-tab-control-3">'+this.opts.curLang.link+'</a></div><form id="redactorInsertImageForm" method="post" action="" enctype="multipart/form-data"><div id="redactor_tab1" class="redactor_tab"><input type="file" id="redactor_file" name="'+this.opts.imageUploadParam+'" /></div><div id="redactor_tab2" class="redactor_tab" style="display: none;"><div id="redactor_image_box"><span class="empty_list">'+this.opts.curLang.empty_img_list+'</span></div></div></form><div id="redactor_tab3" class="redactor_tab" style="display: none;"><label>'+this.opts.curLang.image_web_link+'</label><input type="text" name="redactor_file_link" id="redactor_file_link" class="redactor_input" /><br><br></div></section><footer><button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button><button class="redactor_modal_btn redactor_modal_action_btn" id="redactor_upload_btn">'+this.opts.curLang.insert+"</button></footer>",modal_link:String()+'<section id="redactor-modal-link-insert"><select id="redactor-predefined-links" style="width: 99.5%; display: none;"></select><label>URL</label><input type="text" class="redactor_input" id="redactor_link_url" /><label>'+this.opts.curLang.text+'</label><input type="text" class="redactor_input" id="redactor_link_url_text" /><label><input type="checkbox" id="redactor_link_blank"> '+this.opts.curLang.link_new_tab+'</label></section><footer><button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button><button id="redactor_insert_link_btn" class="redactor_modal_btn redactor_modal_action_btn">'+this.opts.curLang.insert+"</button></footer>",modal_table:String()+'<section id="redactor-modal-table-insert"><label>'+this.opts.curLang.rows+'</label><input type="text" size="5" value="2" id="redactor_table_rows" /><label>'+this.opts.curLang.columns+'</label><input type="text" size="5" value="3" id="redactor_table_columns" /></section><footer><button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button><button id="redactor_insert_table_btn" class="redactor_modal_btn redactor_modal_action_btn">'+this.opts.curLang.insert+"</button></footer>",modal_video:String()+'<section id="redactor-modal-video-insert"><form id="redactorInsertVideoForm"><label>'+this.opts.curLang.video_html_code+'</label><textarea id="redactor_insert_video_area" style="width: 99%; height: 160px;"></textarea></form></section><footer><button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button><button id="redactor_insert_video_btn" class="redactor_modal_btn redactor_modal_action_btn">'+this.opts.curLang.insert+"</button></footer>"})},modalInit:function(t,e,i,s){return this.modalSetOverlay(),this.$redactorModalWidth=i,this.$redactorModal=$("#redactor_modal"),this.$redactorModal.length||(this.$redactorModal=$('<div id="redactor_modal" style="display: none;" />'),this.$redactorModal.append($('<div id="redactor_modal_close">×</div>')),this.$redactorModal.append($('<header id="redactor_modal_header" />')),this.$redactorModal.append($('<div id="redactor_modal_inner" />')),this.$redactorModal.appendTo(document.body)),$("#redactor_modal_close").on("click",$.proxy(this.modalClose,this)),$(document).on("keyup",$.proxy(this.modalCloseHandler,this)),this.$editor.on("keyup",$.proxy(this.modalCloseHandler,this)),this.modalSetContent(e),this.modalSetTitle(t),this.modalSetDraggable(),this.modalLoadTabs(),this.modalOnCloseButton(),this.modalSetButtonsWidth(),this.saveModalScroll=this.document.body.scrollTop,!1===this.opts.autoresize&&(this.saveModalScroll=this.$editor.scrollTop()),!1===this.isMobile()?this.modalShowOnDesktop():this.modalShowOnMobile(),"function"==typeof s&&s(),setTimeout($.proxy((function(){this.callback("modalOpened",this.$redactorModal)}),this),11),$(document).off("focusin.modal"),this.$redactorModal.find("input[type=text]").on("keypress",$.proxy((function(t){13===t.which&&(this.$redactorModal.find(".redactor_modal_action_btn").trigger("click"),t.preventDefault())}),this)),this.$redactorModal},modalShowOnDesktop:function(){this.$redactorModal.css({position:"fixed",top:"-2000px",left:"50%",width:this.$redactorModalWidth+"px",marginLeft:"-"+this.$redactorModalWidth/2+"px"}).show(),this.modalSaveBodyOveflow=$(document.body).css("overflow"),$(document.body).css("overflow","hidden"),setTimeout($.proxy((function(){var t=this.$redactorModal.outerHeight();this.$redactorModal.css({top:"50%",height:"auto",minHeight:"auto",marginTop:"-"+(t+10)/2+"px"})}),this),15)},modalShowOnMobile:function(){this.$redactorModal.css({position:"fixed",width:"100%",height:"100%",top:"0",left:"0",margin:"0",minHeight:"300px"}).show()},modalSetContent:function(t){this.modalcontent=!1,0==t.indexOf("#")?(this.modalcontent=$(t),$("#redactor_modal_inner").empty().append(this.modalcontent.html()),this.modalcontent.html("")):$("#redactor_modal_inner").empty().append(t)},modalSetTitle:function(t){this.$redactorModal.find("#redactor_modal_header").html(t)},modalSetButtonsWidth:function(){},modalOnCloseButton:function(){this.$redactorModal.find(".redactor_btn_modal_close").on("click",$.proxy(this.modalClose,this))},modalSetOverlay:function(){this.opts.modalOverlay&&(this.$redactorModalOverlay=$("#redactor_modal_overlay"),this.$redactorModalOverlay.length||(this.$redactorModalOverlay=$('<div id="redactor_modal_overlay" style="display: none;"></div>'),$("body").prepend(this.$redactorModalOverlay)),this.$redactorModalOverlay.show().on("click",$.proxy(this.modalClose,this)))},modalSetDraggable:function(){void 0!==$.fn.draggable&&(this.$redactorModal.draggable({handle:"#redactor_modal_header"}),this.$redactorModal.find("#redactor_modal_header").css("cursor","move"))},modalLoadTabs:function(){var t=$("#redactor_tabs");if(!t.length)return!1;var e=this;t.find("a").each((function(i,s){i++,$(s).on("click",(function(s){if(s.preventDefault(),t.find("a").removeClass("redactor_tabs_act"),$(this).addClass("redactor_tabs_act"),$(".redactor_tab").hide(),$("#redactor_tab"+i).show(),$("#redactor_tab_selected").val(i),!1===e.isMobile()){var o=e.$redactorModal.outerHeight();e.$redactorModal.css("margin-top","-"+(o+10)/2+"px")}}))}))},modalCloseHandler:function(t){if(t.keyCode===this.keyCode.ESC)return this.modalClose(),!1},modalClose:function(){return $("#redactor_modal_close").off("click",this.modalClose),$("#redactor_modal").fadeOut("fast",$.proxy((function(){var t=$("#redactor_modal_inner");!1!==this.modalcontent&&(this.modalcontent.html(t.html()),this.modalcontent=!1),t.html(""),this.opts.modalOverlay&&$("#redactor_modal_overlay").hide().off("click",this.modalClose),$(document).off("keyup",this.modalCloseHandler),this.$editor.off("keyup",this.modalCloseHandler),this.selectionRestore(),this.opts.autoresize&&this.saveModalScroll?$(this.document.body).scrollTop(this.saveModalScroll):!1===this.opts.autoresize&&this.saveModalScroll&&this.$editor.scrollTop(this.saveModalScroll),this.callback("modalClosed")}),this)),!1===this.isMobile()&&$(document.body).css("overflow",this.modalSaveBodyOveflow?this.modalSaveBodyOveflow:"visible"),!1},modalSetTab:function(t){$(".redactor_tab").hide(),$("#redactor_tabs").find("a").removeClass("redactor_tabs_act").eq(t-1).addClass("redactor_tabs_act"),$("#redactor_tab"+t).show()},s3handleFileSelect:function(t){for(var e,i=t.target.files,s=0;e=i[s];s++)this.s3uploadFile(e)},s3uploadFile:function(t){this.s3executeOnSignedUrl(t,$.proxy((function(e){this.s3uploadToS3(t,e)}),this))},s3executeOnSignedUrl:function(t,e){var i=new XMLHttpRequest,s="?";"-1"!=this.opts.s3.search(/\?/)&&(s="&"),i.open("GET",this.opts.s3+s+"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.showProgressBar(),e(decodeURIComponent(this.responseText))):4==this.readyState&&this.status},i.send()},s3createCORSRequest: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},s3uploadToS3:function(t,e){var i=this.s3createCORSRequest("PUT",e);i&&(i.onload=$.proxy((function(){if(200==i.status){this.hideProgressBar();var t=e.split("?");if(!t[0])return!1;this.selectionRestore();var s="";s='<img id="image-marker" src="'+t[0]+'" />',this.opts.paragraphy&&(s="<p>"+s+"</p>"),this.execCommand("inserthtml",s,!1);var o=$(this.$editor.find("img#image-marker"));o.length?o.removeAttr("id"):o=!1,this.sync(),this.callback("imageUpload",o,!1),this.modalClose(),this.observeImages()}}),this),i.onerror=function(){},i.upload.onprogress=function(t){},i.setRequestHeader("Content-Type",t.type),i.setRequestHeader("x-amz-acl","public-read"),i.send(t))},uploadInit:function(t,e){this.uploadOptions={url:!1,success:!1,error:!1,start:!1,trigger:!1,auto:!1,input:!1},$.extend(this.uploadOptions,e);var i=$("#"+t);i.length&&"INPUT"===i[0].tagName?(this.uploadOptions.input=i,this.el=$(i[0].form)):this.el=i,this.element_action=this.el.attr("action"),this.uploadOptions.auto?$(this.uploadOptions.input).change($.proxy((function(t){this.el.submit((function(t){return!1})),this.uploadSubmit(t)}),this)):this.uploadOptions.trigger&&$("#"+this.uploadOptions.trigger).on("click",$.proxy(this.uploadSubmit,this))},uploadSubmit:function(t){this.showProgressBar(),this.uploadForm(this.element,this.uploadFrame())},uploadFrame:function(){this.id="f"+Math.floor(99999*Math.random());var t=this.document.createElement("div"),e='<iframe style="display:none" id="'+this.id+'" name="'+this.id+'"></iframe>';return t.innerHTML=e,$(t).appendTo("body"),this.uploadOptions.start&&this.uploadOptions.start(),$("#"+this.id).one("load",$.proxy(this.uploadLoaded,this)),this.id},uploadForm:function(t,e){if(this.uploadOptions.input){var i="redactorUploadForm"+this.id,s="redactorUploadFile"+this.id;this.form=$('<form action="'+this.uploadOptions.url+'" method="POST" target="'+e+'" name="'+i+'" id="'+i+'" enctype="multipart/form-data" />'),!1!==this.opts.uploadFields&&"object"==typeof this.opts.uploadFields&&$.each(this.opts.uploadFields,$.proxy((function(t,e){null!=e&&0===e.toString().indexOf("#")&&(e=$(e).val());var i=$("<input/>",{type:"hidden",name:t,value:e});$(this.form).append(i)}),this));var o=this.uploadOptions.input,r=$(o).clone();$(o).attr("id",s).before(r).appendTo(this.form),$(this.form).css("position","absolute").css("top","-2000px").css("left","-2000px").appendTo("body"),this.form.submit()}else t.attr("target",e).attr("method","POST").attr("enctype","multipart/form-data").attr("action",this.uploadOptions.url),this.element.submit()},uploadLoaded:function(){var t,e=$("#"+this.id)[0];if(t=e.contentDocument?e.contentDocument:e.contentWindow?e.contentWindow.document:window.frames[this.id].document,this.uploadOptions.success)if(this.hideProgressBar(),void 0!==t){var i=t.body.innerHTML.match(/\{(.|\n)*\}/)[0];i=(i=i.replace(/^\[/,"")).replace(/\]$/,"");var s=$.parseJSON(i);void 0===s.error?this.uploadOptions.success(s):(console.log(s),this.uploadOptions.error(this,s),this.modalClose())}else this.modalClose(),alert("Upload failed!");this.el.attr("action",this.element_action),this.el.attr("target","")},draguploadInit:function(t,e){if(this.draguploadOptions=$.extend({url:!1,success:!1,error:!1,preview:!1,uploadFields:!1,text:this.opts.curLang.drop_file_here,atext:this.opts.curLang.or_choose,uploadParam:!1},e),void 0===window.FormData)return!1;this.droparea=$('<div class="redactor_droparea"></div>'),this.dropareabox=$('<div class="redactor_dropareabox">'+this.draguploadOptions.text+"</div>"),this.dropalternative=$('<div class="redactor_dropalternative">'+this.draguploadOptions.atext+"</div>"),this.droparea.append(this.dropareabox),$(t).before(this.droparea),$(t).before(this.dropalternative),this.dropareabox.on("dragover",$.proxy((function(){return this.draguploadOndrag()}),this)),this.dropareabox.on("dragleave",$.proxy((function(){return this.draguploadOndragleave()}),this)),this.dropareabox.get(0).ondrop=$.proxy((function(t){for(var e in t.preventDefault(),this.dropareabox.removeClass("hover").addClass("drop"),this.showProgressBar(),t.dataTransfer.files)t.dataTransfer.files.hasOwnProperty(e)&&this.dragUploadAjax(this.draguploadOptions.url,t.dataTransfer.files[e],!1,t,this.draguploadOptions.uploadParam)}),this)},dragUploadAjax:function(t,e,i,s,o){if(!i){var r=$.ajaxSettings.xhr();r.upload&&r.upload.addEventListener("progress",$.proxy(this.uploadProgress,this),!1),$.ajaxSetup({xhr:function(){return r}})}this.callback("drop",s);var a=new FormData;!1!==o?a.append(o,e):a.append("file",e),!1!==this.opts.uploadFields&&"object"==typeof this.opts.uploadFields&&$.each(this.opts.uploadFields,$.proxy((function(t,e){null!=e&&0===e.toString().indexOf("#")&&(e=$(e).val()),a.append(t,e)}),this)),$.ajax({url:t,dataType:"html",async:!1,data:a,cache:!1,contentType:!1,processData:!1,type:"POST",success:$.proxy((function(t){var e="string"==typeof(t=(t=t.replace(/^\[/,"")).replace(/\]$/,""))?$.parseJSON(t):t;if(this.hideProgressBar(),i){var o=$("<img>");o.attr("src",e.image.url).attr("id","drag-image-marker"),this.insertNodeToCaretPositionFromPoint(s,o[0]);var r=$(this.$editor.find("img#drag-image-marker"));r.length?r.removeAttr("id"):r=!1,this.sync(),this.observeImages(),r&&this.callback("imageUpload",r,e),void 0!==e.error&&this.callback("imageUploadError",e)}else void 0===e.error?this.draguploadOptions.success(e):(this.draguploadOptions.error(this,e),this.draguploadOptions.success(!1))}),this)})},draguploadOndrag:function(){return this.dropareabox.addClass("hover"),!1},draguploadOndragleave:function(){return this.dropareabox.removeClass("hover"),!1},uploadProgress:function(t,e){var i=t.loaded?parseInt(t.loaded/t.total*100,10):t;this.dropareabox.text("Loading "+i+"% "+(e||""))},isMobile:function(){return/(iPhone|iPod|BlackBerry|Android)/.test(navigator.userAgent)},isIPad:function(){return/iPad/.test(navigator.userAgent)},normalize:function(t){return void 0===t?0:parseInt(t.replace("px",""),10)},outerHtml:function(t){return $("<div>").append($(t).eq(0).clone()).html()},stripHtml:function(t){var e=document.createElement("DIV");return e.innerHTML=t,e.textContent||e.innerText||""},isString:function(t){return"[object String]"==Object.prototype.toString.call(t)},isEmpty:function(t){return""==(t=(t=(t=t.replace(/​|<br>|<br\/>| /gi,"")).replace(/\s/g,"")).replace(/^<p>[^\W\w\D\d]*?<\/p>$/i,""))},getInternetExplorerVersion:function(){var t=!1;if("Microsoft Internet Explorer"==navigator.appName){var e=navigator.userAgent;null!=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(e)&&(t=parseFloat(RegExp.$1))}return t},isIe11:function(){return!!navigator.userAgent.match(/Trident\/7\./)},browser:function(t){var e=navigator.userAgent.toLowerCase(),i=/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return"version"==t?i[2]:"webkit"==t?"chrome"==i[1]||"webkit"==i[1]:"rv"==i[1]?"msie"==t:"opr"==i[1]?"webkit"==t:t==i[1]},oldIE:function(){return!!(this.browser("msie")&&parseInt(this.browser("version"),10)<9)},getFragmentHtml:function(t){var e=t.cloneNode(!0),i=this.document.createElement("div");return i.appendChild(e),i.innerHTML},extractContent:function(){for(var t,e=this.$editor[0],i=this.document.createDocumentFragment();t=e.firstChild;)i.appendChild(t);return i},isParentRedactor:function(t){return!!t&&((this.opts.iframe||0!=$(t).parents("div.redactor_editor").length&&!$(t).hasClass("redactor_editor"))&&t)},currentOrParentIs:function(t){var e=this.getParent(),i=this.getCurrent();return e&&e.tagName===t?e:!(!i||i.tagName!==t)&&i},isEndOfElement:function(){var t=this.getBlock();return this.getCaretOffset(t)==$.trim($(t).text()).replace(/\n\r\n/g,"").length},isFocused:function(){var t,e=this.getSelection();return e&&e.rangeCount&&e.rangeCount>0&&(t=e.getRangeAt(0).startContainer),!!t&&(this.opts.iframe?!this.getCaretOffsetRange().equals()||!this.$editor.is(t):0!=$(t).closest("div.redactor_editor").length)},removeEmptyAttr:function(t,e){""==$(t).attr(e)&&$(t).removeAttr(e)},removeFromArrayByValue:function(t,e){for(var i=null;-1!==(i=t.indexOf(e));)t.splice(i,1);return t}},Redactor.prototype.init.prototype=Redactor.prototype,$.Redactor.fn.formatLinkify=function(t,e,i,s,o){for(var r=/(((https?|ftps?):\/\/)|www[.][^\s])(.+?\..+?)([.),]?)(\s|\.\s+|\)|$)/gi,a=/(https?|ftp):\/\//i,n=/(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/gi,l=(this.$editor?this.$editor.get(0):this).childNodes,c=l.length;c--;){var d=l[c];if(3===d.nodeType){var h=d.nodeValue;if(s&&h){var p='<iframe width="500" height="281" src="',u='" frameborder="0" allowfullscreen></iframe>';h.match(reUrlYoutube)?(h=h.replace(reUrlYoutube,p+"//www.youtube.com/embed/$1"+u),$(d).after(h).remove()):h.match(reUrlVimeo)&&(h=h.replace(reUrlVimeo,p+"//player.vimeo.com/video/$2"+u),$(d).after(h).remove())}if(i&&h&&h.match(n)&&(h=h.replace(n,'<img src="$1">'),$(d).after(h).remove()),e&&h&&h.match(r)){var f=h.match(r);for(var c in f){var m=f[c],g=m,b="";null!==m.match(/\s$/)&&(b=" ");var v=t;null!==m.match(a)&&(v=""),g.length>o&&(g=g.substring(0,o)+"...");var y=(g=g.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")).replace("$","$$$");h=h.replace(m,'<a href="'+v+$.trim(m)+'">'+$.trim(y)+"</a>"+b)}$(d).after(h).remove()}}else 1!==d.nodeType||/^(a|button|textarea)$/i.test(d.tagName)||$.Redactor.fn.formatLinkify.call(d,t,e,i,s,o)}}})(jQuery);