CVE-2023-4704 (published 2023-09-01T10:15Z)

External Control of System or Configuration Setting in GitHub repository instantsoft/icms2 prior to 2.16.1-git.

CVSS v3 base score: 4.9, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:N/A:N)

Weakness information:
cwe_id: CWE-610
cwe_name: Externally Controlled Reference to a Resource in Another Sphere
description: The product uses an externally controlled name or reference that resolves to a resource that is outside of the intended control sphere.
extended_description: 
            
         
         

Fix information:
repo_url: https://github.com/instantsoft/icms2
commit_details: repo_url: https://github.com/instantsoft/icms2
author: fuzegit
author_date: 2023-08-11 23:26:57+03:00
msg: Forbid contact with myself
repository: repo_url: https://github.com/instantsoft/icms2
repo_name: instantsoft/icms2
description: Self-hosted Site Management System
repo_language: PHP
owner: instantsoft
file_changes: filename: write.php
change_type: ModificationType.MODIFY
diff: @@ -12,6 +12,11 @@ class actionMessagesWrite extends cmsAction {
             return cmsCore::error404();
         }
 
+        // Самому себе нельзя
+        if ($this->cms_user->id == $contact_id) {
+            return cmsCore::error404();
+        }
+
         $contact_exists_id = $this->model->isContactExists($this->cms_user->id, $contact_id);
 
         if (!$contact_exists_id) {

programming_language: PHP
filename: frontend.php
change_type: ModificationType.MODIFY
diff: @@ -99,7 +99,16 @@ class messages extends cmsFrontend {
     public function sendMessage($content) {
 
         // Создаем контакты получателям
-        foreach ($this->recipients as $contact_id) {
+        foreach ($this->recipients as $key => $contact_id) {
+
+            // Контакт сам с собой невозможен
+            if ($contact_id == $this->sender_id) {
+
+                unset($this->recipients[$key]);
+
+                continue;
+            }
+
             if (!$this->model->isContactExists($contact_id, $this->sender_id)) {
                 $this->model->addContact($contact_id, $this->sender_id);
             }

programming_language: PHP
filename: redactor.js
change_type: ModificationType.MODIFY
diff: @@ -765,6 +765,8 @@
 		setEditor: function(html, strip)
 		{
 
+            html = this.sanitizeHTML(html);
+
 			if (strip !== false)
 			{
 				html = this.cleanSavePreCode(html);
@@ -778,9 +780,7 @@
 			}
 
 			html = html.replace(/&amp;#36;/g, '$');
-
-			html = this.cleanEmpty(html);
-			html = this.sanitizeHTML(html);
+            html = this.cleanEmpty(html);
 
 			this.$editor.html(html);
 
@@ -791,6 +791,9 @@
 		},
         sanitizeHTML:  function(htmlStr)
 		{
+            if(htmlStr.length === 0){
+                return htmlStr;
+            }
             function stringToHTML () {
                 let parser = new DOMParser();
                 let doc = parser.parseFromString(htmlStr, 'text/html');
@@ -849,6 +852,7 @@
 		},
 		setFullpageOnInit: function(html)
 		{
+            html = this.sanitizeHTML(html);
 			this.fullpageDoctype = html.match(/^<\!doctype[^>]*>/i);
 			if (this.fullpageDoctype && this.fullpageDoctype.length == 1)
 			{
@@ -858,7 +862,6 @@
 			html = this.cleanSavePreCode(html, true);
 			html = this.cleanConverters(html);
 			html = this.cleanEmpty(html);
-            html = this.sanitizeHTML(html);
 
 			this.$editor.html(html);
 
@@ -7835,4 +7838,4 @@
 		}
 	};
 
-})(jQuery);
+})(jQuery);
\ No newline at end of file

programming_language: JavaScript
filename: redactor.min.js
change_type: ModificationType.MODIFY
diff: @@ -1 +1 @@
-!function($){var uuid=0;"use strict";var 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.-]*/ig,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=[],s=Array.prototype.slice.call(arguments,1);return("string"==typeof t?this.each(function(){var o=$.data(this,"redactor");if(!(void 0!==o&&$.isFunction(o[t])))return $.error('No such method "'+t+'" for Redactor');var r=o[t].apply(o,s);void 0!==r&&r!==o&&e.push(r)}):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>&#x200b;</p>",invisibleSpace:"&#x200b;",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 s=$.extend(!0,{},$.Redactor.opts);if(this.opts=$.extend({},s,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=RegExp("^<(/?"+this.opts.ownLine.join("|/?")+"|"+this.opts.contOwnLine.join("|")+")[ >]"),this.cleanlineAfter=RegExp("^<(br|/?"+this.opts.ownLine.join("|/?")+"|/"+this.opts.contOwnLine.join("|/")+")[ >]"),this.cleannewLevel=RegExp("^</?("+this.opts.newLevel.join("|")+")[ >]"),this.rTestBlock=RegExp("^("+this.opts.blockLevelElements.join("|")+")$","i"),!1===this.opts.linebreaks){if(!1!==this.opts.allowedTags){var o=["strong","em","del"],r=["b","i","strike"];for(i in"-1"===$.inArray("p",this.opts.allowedTags)&&this.opts.allowedTags.push("p"),o)"-1"!=$.inArray(o[i],this.opts.allowedTags)&&this.opts.allowedTags.push(r[i])}if(!1!==this.opts.deniedTags){var a=$.inArray("p",this.opts.deniedTags);"-1"!==a&&this.opts.deniedTags.splice(a,a)}}(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:"&bull; "+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,s){var o=this.opts[t+"Callback"];return $.isFunction(o)?!1===e?o.call(this,s):o.call(this,e,s):s},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,s){t=(t=t.toString()).replace(/\$/g,"&#36;"),this.opts.fullpage?this.setCodeIframe(t):this.setEditor(t,e),""==t&&(s=!1),!1!==s&&this.placeholderRemoveFromEditor()},setEditor:function(t,e){!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(/&amp;#36;/g,"$"),t=this.cleanEmpty(t),t=this.sanitizeHTML(t),this.$editor.html(t),this.setNonEditable(),this.setSpansVerified(),this.sync()},sanitizeHTML:function(t){function e(){return new DOMParser().parseFromString(t,"text/html").body}function s(t){let e=t.children;for(let r of e)o(r),s(r)}function o(t){let e=t.attributes;for(let{name:s,value:o}of e)r(s,o)&&t.removeAttribute(s)}function r(t,e){let s=e.replace(/\s+/g,"").toLowerCase();if(["src","href","xlink:href"].includes(t)&&(s.includes("javascript:")||s.includes("data:text/html"))||t.startsWith("on"))return!0}let a=e();return s(a),a.innerHTML},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){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),t=this.sanitizeHTML(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,s=RegExp("<"+this.tagName,"gi"),o=t.replace(s,"<"+e);s=RegExp("</"+this.tagName,"gi"),o=o.replace(s,"</"+e),$(this).replaceWith(o)})},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,s="";if(this.cleanUnverified(),s=this.opts.fullpage?this.getCodeIframe():this.$editor.html(),s=this.syncClean(s),s=this.cleanRemoveEmptyTags(s),this.cleanRemoveSpaces(this.$source.val(),!1)==this.cleanRemoveSpaces(s,!1))return!1;if(s=s.replace(/<\/li><(ul|ol)>([\w\W]*?)<\/(ul|ol)>/gi,"<$1>$2</$1></li>"),"<br>"===$.trim(s)&&(s=""),this.opts.xhtml){var o=["br","hr","img","link","input","meta"];$.each(o,function(t,e){s=s.replace(RegExp("<"+e+"(.*?[^/$]?)>","gi"),"<"+e+"$1 />")})}if(s=this.callback("syncBefore",!1,s),this.$source.val(s),this.setFullpageDoctype(),this.callback("syncAfter",!1,s),!1===this.start){if(void 0!==t)switch(t.which){case 37:case 38:case 39:case 40:break;default:this.callback("change",!1,s)}else this.callback("change",!1,s)}},syncClean:function(t){return this.opts.fullpage||(t=this.cleanStripTags(t)),t=$.trim(t),("<p></p>"==(t=(t=(t=(t=(t=this.placeholderRemoveFromCode(t)).replace(/&#x200b;/gi,"")).replace(/&#8203;/gi,"")).replace(/<\/a>&nbsp;/gi,"</a> ")).replace(/\u200B/g,""))||"<p> </p>"==t||"<p>&nbsp;</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("<!--?php","<?php")).replace("?-->","?>")).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,"&trade;")).replace(/\u00a9/gi,"&copy;")).replace(/\u2026/gi,"&hellip;")).replace(/\u2014/gi,"&mdash;")).replace(/\u2010/gi,"&dash;"),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,s){t.addClass("redactor_"+s)})},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||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;if(this.browser("webkit")&&-1===navigator.userAgent.indexOf("Chrome")&&this.browser("version").split(".")[0]<536&&(e=!0),e||this.browser("opera")||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 s=this.extractContent();setTimeout($.proxy(function(){var t=this.extractContent();this.$editor.append(s),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 s=e.clipboardData.items[0].getAsFile();if(null!==s){this.bufferSet(),this.clipboardFilePaste=!0;var o=new FileReader;return o.onload=$.proxy(this.pasteClipboardUpload,this),o.readAsDataURL(s),!0}}return!1},buildEventKeydown:function(t){if(this.rtePaste)return!1;var e=t.which,s=t.ctrlKey||t.metaKey,o=this.getParent(),r=this.getCurrent(),a=this.getBlock(),n=!1;if(this.callback("keydown",t),this.browser("mozilla")&&"modify"in window.getSelection()&&s&&(37===t.keyCode||39===t.keyCode)){var l=this.getSelection(),c=t.metaKey?"line":"word";37!==t.keyCode||(l.modify("extend","left",c),t.shiftKey||l.collapseToStart()),39!==t.keyCode||(l.modify("extend","right",c),t.shiftKey||l.collapseToEnd()),t.preventDefault()}if(this.imageResizeHide(!1),(o&&"CODE"===$(o).get(0).tagName||r&&"CODE"===$(r).get(0).tagName)&&(n=!0,e===this.keyCode.DOWN&&this.insertAfterLastElement(a)),e===this.keyCode.DOWN&&(o&&"BLOCKQUOTE"===$(o)[0].tagName&&this.insertAfterLastElement(o),r&&"BLOCKQUOTE"===$(r)[0].tagName&&this.insertAfterLastElement(r),o&&"P"===$(o)[0].tagName&&"BLOCKQUOTE"==$(o).parent()[0].tagName&&this.insertAfterLastElement(o,$(o).parent()[0]),r&&"P"===$(r)[0].tagName&&o&&"BLOCKQUOTE"==$(o)[0].tagName&&this.insertAfterLastElement(r,o)),this.shortcuts(t,e),!s||90!==e||t.shiftKey||t.altKey){if(s&&90===e&&t.shiftKey&&!t.altKey){t.preventDefault(),0!=this.opts.rebuffer.length?this.bufferRedo():this.document.execCommand("redo",!1,!1);return}}else{t.preventDefault(),this.opts.buffer.length?this.bufferUndo():this.document.execCommand("undo",!1,!1);return}if(32==e&&this.bufferSet(),s&&65===e?(this.bufferSet(),this.selectall=!0):e==this.keyCode.LEFT_WIN||s||(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 h=this.getRange();if(h&&!1===h.collapsed&&(sel=this.getSelection()).rangeCount&&h.deleteContents(),this.browser("msie")&&1==o.nodeType&&("TD"==o.tagName||"TH"==o.tagName))return t.preventDefault(),this.bufferSet(),this.insertNode(document.createElement("br")),this.callback("enter",t),!1;if(a&&("BLOCKQUOTE"==a.tagName||"BLOCKQUOTE"==$(a).parent()[0].tagName)){if(this.isEndOfElement()){if(1==this.dblEnter){if("BLOCKQUOTE"==a.tagName?(p="br",d=a):(p="p",d=$(a).parent()[0]),t.preventDefault(),this.insertingAfterLastElement(d),this.dblEnter=0,"p"==p)$(a).parent().find("p").last().remove();else{var d,p,u=$.trim($(a).html());$(a).html(u.replace(/<br\s?\/?>$/i,""))}return}this.dblEnter++}else this.dblEnter++}if(!0===n)return this.buildEventKeydownPre(t,r);if(!this.opts.linebreaks){if(a&&"LI"==a.tagName){var f=this.getBlock();if(!1!==f||"LI"===f.tagName){var m=$.trim($(a).text()),g=$.trim($(f).text());if(""==m&&""==g&&0==$(f).next("li").length&&0==$(f).parents("li").length){this.bufferSet();var b=$(f).closest("ol, ul");$(f).remove();var v=$("<p>"+this.opts.invisibleSpace+"</p>");return b.after(v),this.selectionStart(v),this.sync(),this.callback("enter",t),!1}}}if(a&&this.opts.rBlockTest.test(a.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===a){this.bufferSet();var v=$("<p>"+this.opts.invisibleSpace+"</p>");return this.insertNode(v[0]),this.selectionStart(v),this.callback("enter",t),!1}}if(this.opts.linebreaks){if(!(a&&this.opts.rBlockTest.test(a.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"==a.tagName||"FIGCAPTION"==a.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,n,e);e===this.keyCode.BACKSPACE&&this.buildEventKeydownBackspace(t,r,o)},buildEventKeydownPre:function(t,e){t.preventDefault(),this.bufferSet();var s=$(e).parent().text();return this.insertNode(document.createTextNode("\n")),-1==s.search(/\s$/)&&this.insertNode(document.createTextNode("\n")),this.sync(),this.callback("enter",t),!1},buildEventKeydownTab:function(t,e,s){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("\xa0"))),this.sync()):t.shiftKey?this.indentingOutdent():this.indentingIndent():(this.bufferSet(),this.insertNode(document.createTextNode("	")),this.sync()),!1)},buildEventKeydownBackspace:function(t,e,s){if(s&&e&&"TD"==s.parentNode.tagName&&"UL"==s.tagName&&"LI"==e.tagName&&1==$(s).children("li").length){var o;if(""==$(e).text().replace(/[\u200B-\u200D\uFEFF]/g,"")){var o=s.parentNode;return $(s).remove(),this.selectionStart(o),this.sync(),!1}}void 0!==e.tagName&&/^(H[1-6])$/i.test(e.tagName)&&(o=!1===this.opts.linebreaks?$("<p>"+this.opts.invisibleSpace+"</p>"):$("<br>"+this.opts.invisibleSpace),$(e).replaceWith(o),this.selectionStart(o),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,s=this.getParent(),o=this.getCurrent();if(!this.opts.linebreaks&&3==o.nodeType&&(!1==s||"BODY"==s.tagName)){var r=$("<p>").append($(o).clone());$(o).replaceWith(r);var a=$(r).next();void 0!==a[0]&&"BR"==a[0].tagName&&a.remove(),this.selectionEnd(r)}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,s){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:"'"},r={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"};e=e.toLowerCase().split(" ");var a=o[t.keyCode],n=String.fromCharCode(t.which).toLowerCase(),l="",c={};$.each(["alt","ctrl","meta","shift"],function(e,s){t[s+"Key"]&&a!==s&&(l+=s+"+")}),a&&(c[l+a]=!0),n&&(c[l+n]=!0,c[l+r[n]]=!0,"shift+"===l&&(c[r[n]]=!0));for(var h=0,d=e.length;h<d;h++)if(c[e[h]])return t.preventDefault(),s.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 s=this.getRange();s.selectNodeContents(e),s.collapse(t||!1);var o=this.getSelection();o.removeAllRanges(),o.addRange(s)},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,""),s=t.replace(/\n/g,"");s=this.cleanRemoveSpaces(s,!1),this.modified=this.cleanRemoveSpaces(e,!1)!==s}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 s=this.$source.val();""!==s&&this.opts.tidyHtml&&this.$source.val(this.cleanHtml(s)),this.modified=s,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),s=e.get(0).selectionStart;return e.val(e.val().substring(0,s)+"	"+e.val().substring(e.get(0).selectionEnd)),e.get(0).selectionStart=e.get(0).selectionEnd=s+1,!1}},autosave:function(){var t=!1;this.autosaveInterval=setInterval($.proxy(function(){var e=this.get();if(t!==e){var s=this.$source.attr("name");$.ajax({url:this.opts.autosave,type:"post",data:"name="+s+"&"+s+"="+escape(encodeURIComponent(e)),success:$.proxy(function(s){var o=$.parseJSON(s);void 0===o.error?this.callback("autosave",!1,o):this.callback("autosaveError",!1,o),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 s=this.opts.buttons.indexOf(e);this.opts.buttons.splice(s,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 s=this.opts.toolbar[e];if(!1===this.opts.fileUpload&&"file"===e)return!0;this.$toolbar.append($("<li>").append(this.buttonBuild(e,s)))}},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=$(this.opts.toolbarFixedTarget).scrollTop(),e=0,s=0,o=0;if(o=(e=this.opts.toolbarFixedTarget===document?this.$box.offset().top:1)+this.$box.height()+40,t>e){var r="100%";this.opts.toolbarFixedBox&&(s=this.$box.offset().left,r=this.$box.innerWidth(),this.$toolbar.addClass("toolbar_fixed_box")),this.toolbarFixed=!0,this.opts.toolbarFixedTarget===document?this.$toolbar.css({position:"fixed",width:r,zIndex:10005,top:this.opts.toolbarFixedTopOffset+"px",left:s}):this.$toolbar.css({position:"absolute",width:r,zIndex:10005,top:this.opts.toolbarFixedTopOffset+t+"px",left:0}),t<o?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 s=$(this.getElement(this.getSelection().focusNode)),o=s.offset();o.height=s.height(),this.airShow(o,!0)}},this))},airShow:function(t,e){if(this.opts.air){if(this.selectionSave(),$(".redactor_air").hide(),e)s=t.left,o=t.top+t.height+14,this.opts.iframe&&(o+=this.$box.position().top-$(this.document).scrollTop(),s+=this.$box.position().left);else{var s,o,r=this.$air.innerWidth();s=t.clientX,$(this.document).width()<s+r&&(s-=r),o=t.clientY+14,this.opts.iframe?(o+=this.$box.position().top,s+=this.$box.position().left):o+=$(this.document).scrollTop()}this.$air.css({left:s+"px",top:o+"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,s){var o;s.className||(s.className=""),"separator"===s.name?o=$('<a class="redactor_separator_drop">'):(o=$('<a href="#" class="'+s.className+" redactor_dropdown_"+e+'">'+s.title+"</a>")).on("click",$.proxy(function(t){this.opts.air&&this.selectionRestore(),t.preventDefault&&t.preventDefault(),this.browser("msie")&&(t.returnValue=!1),s.callback&&s.callback.call(this,e,o,s,t),s.exec&&this.execCommand(s.exec,e),s.func&&this[s.func](e),this.buttonActiveObserver(),this.opts.air&&this.$air.fadeOut(100)},this)),t.append(o)},this))},dropdownShow:function(t,e){if(!this.opts.visual)return t.preventDefault(),!1;var s=this.buttonGet(e),o=s.data("dropdown").appendTo(document.body);if(s.hasClass("dropact"))this.dropdownHideAll();else{this.dropdownHideAll(),this.callback("dropdownShow",{dropdown:o,key:e,button:s}),this.buttonActive(e),s.addClass("dropact");var r=s.offset(),a=o.width();r.left+a>$(document).width()&&(r.left-=a);var n=r.left+"px",l=s.innerHeight(),c="absolute",h=l+this.opts.toolbarFixedTopOffset+"px";this.opts.toolbarFixed&&this.toolbarFixed?c="fixed":h=r.top+l+"px",o.css({position:c,left:n,top:h}).show(),this.callback("dropdownShown",{dropdown:o,key:e,button:s})}var d=$.proxy(function(t){this.dropdownHide(t,o)},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,s){var o=$('<a href="javascript:;" title="'+e.title+'" tabindex="-1" class="re-icon re-'+t+'"></a>');if(void 0!==s&&o.addClass("redactor-btn-image"),o.on("click",$.proxy(function(s){if(s.preventDefault&&s.preventDefault(),this.browser("msie")&&(s.returnValue=!1),o.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,o,e,s),this.airBindMousemoveHide()):e.dropdown&&this.dropdownShow(s,t),this.buttonActiveObserver(!1,t)},this)),e.dropdown){var r=$('<div class="redactor_dropdown redactor_dropdown_box_'+t+'" style="display: none;">');o.data("dropdown",r),this.dropdownBuild(r,e.dropdown)}return o},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 s=this.buttonGet(t);s.removeClass("redactor-btn-image"),s.addClass("fa-redactor-btn"),s.html('<i class="fa '+e+'"></i>')},buttonAdd:function(t,e,s,o){if(this.opts.toolbar){var r=this.buttonBuild(t,{title:e,callback:s,dropdown:o},!0);return this.$toolbar.append($("<li>").append(r)),r}},buttonAddFirst:function(t,e,s,o){if(this.opts.toolbar){var r=this.buttonBuild(t,{title:e,callback:s,dropdown:o},!0);this.$toolbar.prepend($("<li>").append(r))}},buttonAddAfter:function(t,e,s,o,r){if(this.opts.toolbar){var a=this.buttonBuild(e,{title:s,callback:o,dropdown:r},!0),n=this.buttonGet(t);return 0!==n.length?n.parent().after($("<li>").append(a)):this.$toolbar.append($("<li>").append(a)),a}},buttonAddBefore:function(t,e,s,o,r){if(this.opts.toolbar){var a=this.buttonBuild(e,{title:s,callback:o,dropdown:r},!0),n=this.buttonGet(t);return 0!==n.length?n.parent().before($("<li>").append(a)):this.$toolbar.append($("<li>").append(a)),a}},buttonRemove:function(t){this.buttonGet(t).remove()},buttonActiveObserver:function(t,e){var s=this.getParent();if(this.buttonInactiveAll(e),!1===t&&"html"!==e){-1!=$.inArray(e,this.opts.activeButtons)&&this.buttonActiveToggle(e);return}s&&"A"===s.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!=$(s).closest(t,this.$editor.get()[0]).length&&this.buttonActive(e)},this));var o=$(s).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);if(o.length){var r=o.css("text-align");""==r&&(r="left"),this.buttonActive("align"+r)}},execPasteFrag:function(t){var e=this.getSelection();if(e.getRangeAt&&e.rangeCount){var s=this.getRange();s.deleteContents();var o=this.document.createElement("div");o.innerHTML=t;for(var r,a,n=this.document.createDocumentFragment();r=o.firstChild;)a=n.appendChild(r);n.firstChild,s.insertNode(n),a&&((s=s.cloneRange()).setStartAfter(a),s.collapse(!0)),e.removeAllRanges(),e.addRange(s)}},exec:function(t,e,s){"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!==s&&this.sync(),this.callback("execCommand",t,e)},execCommand:function(t,e,s){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 o=this.getParent();("SUP"===o.tagName||"SUB"===o.tagName)&&this.inlineRemoveFormatReplace(o)}if("inserthtml"===t){this.insertHtml(e,s),this.callback("execCommand",t,e);return}return(!this.currentOrParentIs("CODE")||!!this.opts.formattingPre)&&("insertunorderedlist"===t||"insertorderedlist"===t?this.execLists(t,e):"unlink"===t?this.execUnlink(t,e):void(this.exec(t,e,s),"inserthorizontalrule"===t&&this.$editor.find("hr").removeAttr("id")))},execUnlink:function(t,e){this.bufferSet();var s=this.currentOrParentIs("A");if(s){$(s).replaceWith($(s).text()),this.sync(),this.callback("execCommand",t,e);return}},execLists:function(t,e){this.bufferSet();var s=this.getParent(),o=$(s).closest("ol, ul");this.isParentRedactor(o)||0==o.length||(o=!1);var r=!1;if(o&&o.length){r=!0;var a=o[0].tagName;("insertunorderedlist"===t&&"OL"===a||"insertorderedlist"===t&&"UL"===a)&&(r=!1)}if(this.selectionSave(),r){var n=this.getNodes(),l=this.getBlocks(n);void 0!==n[0]&&n.length>1&&3==n[0].nodeType&&l.unshift(this.getBlock());var c="",h="";$.each(l,$.proxy(function(t,e){if("LI"==e.tagName){var s=$(e),o=s.clone();(o.find("ul","ol").remove(),!1===this.opts.linebreaks)?c+=this.outerHtml($("<p>").append(o.contents())):c+=o.html().replace(/<br\s?\/?>$/i,"")+"<br>",0==t?(s.addClass("redactor-replaced").empty(),h=this.outerHtml(s)):s.remove()}},this)),html=this.$editor.html().replace(h,"</"+a+">"+c+"<"+a+">"),this.$editor.html(html),this.$editor.find(a+":empty").remove()}else{var d=$(this.getParent()).closest("td");if(this.browser("msie")&&!this.isIe11()&&this.opts.linebreaks){var p=this.selectionWrap("div"),u=$(p).html(),f=$("<ul>");"insertorderedlist"==t&&(f=$("<ol>"));var m=$("<li>");""==$.trim(u)?(m.append(u+'<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),f.append(m),this.$editor.find("#selection-marker-1").replaceWith(f)):(m.append(u),f.append(m),$(p).replaceWith(f))}else this.document.execCommand(t);var s=this.getParent(),o=$(s).closest("ol, ul");if(!1===this.opts.linebreaks&&""==$.trim(o.text())&&(o.children("li").find("br").remove(),o.children("li").append('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>")),0!=d.length&&o.wrapAll("<td>"),o.length){var g=o.parent();this.isParentRedactor(g)&&"LI"!=g[0].tagName&&this.nodeTestBlocks(g[0])&&g.replaceWith(g.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 s=$(this.getParent()).closest("ol, ul")[0].tagName,o=this.getBlocks();$.each(o,function(t,e){if("LI"==e.tagName){var o=$(e).prev();if(0!=o.length&&"LI"==o[0].tagName){var r=o.children("ul, ol");0==r.length?o.append($("<"+s+">").append(e)):r.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 s=!1;if("TD"!==e.tagName){s=-1!==$.inArray(e.tagName,this.opts.alignmentTags)?$(e):$(e).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);var o=this.normalize(s.css("margin-left"))+this.opts.indentValue;s.css("margin-left",o+"px")}},this))}this.selectionRestore()}else{this.selectionSave();var e=this.getBlock();if(e&&"LI"==e.tagName){var o=this.getBlocks(),l=0;this.insideOutdent(e,l,o)}else{var n=this.getBlocks();$.each(n,$.proxy(function(t,e){var s=!1;s=-1!==$.inArray(e.tagName,this.opts.alignmentTags)?$(e):$(e).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);var o=this.normalize(s.css("margin-left"))-this.opts.indentValue;o<=0?!0===this.opts.linebreaks&&void 0!==s.data("tagblock")?s.replaceWith(s.html()+"<br>"):(s.css("margin-left",""),this.removeEmptyAttr(s,"style")):s.css("margin-left",o+"px")},this))}this.selectionRestore()}this.sync()},insideOutdent:function(t,e,s){if(t&&"LI"==t.tagName){var o=$(t).parent().parent();0!=o.length&&"LI"==o[0].tagName?o.after(t):void 0!==s[e]?(t=s[e],e++,this.insideOutdent(t,e,s)):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;this.selectionSave();var s=this.getBlock();if(!s&&this.opts.linebreaks){this.exec("formatblock","div");var o=this.getBlock(),s=$('<div data-tagblock="">').html($(o).html());$(o).replaceWith(s),$(s).css("text-align",t),this.removeEmptyAttr(s,"style"),""==t&&void 0!==$(s).data("tagblock")&&$(s).replaceWith($(s).html())}else{var r=this.getBlocks();$.each(r,$.proxy(function(e,s){var o=!1;(o=-1!==$.inArray(s.tagName,this.opts.alignmentTags)?$(s):$(s).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]))&&(o.css("text-align",t),this.removeEmptyAttr(o,"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,"<!-- template double $1 -->")).replace(/\{(.*?)\}/gi,"<!-- template $1 -->")),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){var e=[],s=t.match(/<(code|style|script|title)(.*?)>([\w\W]*?)<\/(code|style|script|title)>/gi);if(null===s&&(s=[]),this.opts.phpTags){var o=t.match(/<\?php([\w\W]*?)\?>/gi);o&&(s=$.merge(s,o))}s&&$.each(s,function(s,o){t=t.replace(o,"buffer_"+s),e.push(o)})}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,s){t=t.replace("buffer_"+e,s)}),t},cleanRemoveEmptyTags:function(t){t=t.replace(/[\u200B-\u200D\uFEFF]/g,"");for(var e=["<b>\\s*</b>","<b>&nbsp;</b>","<em>\\s*</em>"],s=["<code></code>","<blockquote>\\s*</blockquote>","<dd></dd>","<dt></dt>","<ul></ul>","<ol></ol>","<li></li>","<table></table>","<tr></tr>","<span>\\s*<span>","<span>&nbsp;<span>","<p>\\s*</p>","<p></p>","<p>&nbsp;</p>","<p>\\s*<br>\\s*</p>","<div>\\s*</div>","<div>\\s*<br>\\s*</div>"],o=(s=this.opts.removeEmptyTags?s.concat(e):e).length,r=0;r<o;++r)t=t.replace(RegExp(s[r],"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=[],s=t.match(/<(table|div|code|object)(.*?)>([\w\W]*?)<\/(table|div|code|object)>/gi);s||(s=[]);var o=t.match(/<!--([\w\W]*?)-->/gi);if(o&&(s=$.merge(s,o)),this.opts.phpTags){var r=t.match(/<section(.*?)rel="redactor-php-tag">([\w\W]*?)<\/section>/gi);r&&(s=$.merge(s,r))}function a(e,s,o){return t.replace(RegExp(e,s),o)}s&&$.each(s,function(s,o){e[s]=o,t=t.replace(o,"{replace"+s+"}\n")}),t=(t=t.replace(/<br \/>\s*<br \/>/gi,"\n\n")).replace(/<br><br>/gi,"\n\n");var n="(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=a("(<"+n+"[^>]*>)","gi","\n$1"),t=a("(</"+n+">)","gi","$1\n\n"),t=a("\r\n","g","\n"),t=a("\r","g","\n");var l=(t=a("/\n\n+/","g","\n\n")).split(RegExp("\ns*\n","g"),-1);for(var c in t="",l)l.hasOwnProperty(c)&&(-1==l[c].search("{replace")?(l[c]=l[c].replace(/<p>\n\t?<\/p>/gi,""),l[c]=l[c].replace(/<p><\/p>/gi,""),""!=l[c]&&(t+="<p>"+l[c].replace(/^\n+|\n+$/g,"")+"</p>")):t+=l[c]);return t=a("<p><p>","gi","<p>"),t=a("</p></p>","gi","</p>"),t=a("<p>s?</p>","gi",""),t=a("<p>([^<]+)</(div|address|form)>","gi","<p>$1</p></$2>"),t=a("<p>(</?"+n+"[^>]*>)</p>","gi","$1"),t=a("<p>(<li.+?)</p>","gi","$1"),t=a("<p>s?(</?"+n+"[^>]*>)","gi","$1"),t=a("(</?"+n+"[^>]*>)s?</p>","gi","$1"),t=a("(</?"+n+"[^>]*>)s?<br />","gi","$1"),t=a("<br />(s*</?(?:p|li|div|dl|dd|dt|th|code|td|ul|ol)[^>]*>)","gi","$1"),t=a("\n</p>","gi","</p>"),t=a("<li><p>","gi","<li>"),t=a("</p></li>","gi","</li>"),t=a("</li><p>","gi","</li>"),t=a("<p>	?\n?<p>","gi","<p>"),t=a("</dt><p>","gi","</dt>"),t=a("</dd><p>","gi","</dd>"),t=a("<br></p></blockquote>","gi","</blockquote>"),t=a("<p>	*</p>","gi",""),$.each(e,function(e,s){t=t.replace("{replace"+e+"}",s)}),$.trim(t)},cleanConvertInlineTags:function(t,e){var s="strong";"b"===this.opts.boldTag&&(s="b");var o="em";return"i"===this.opts.italicTag&&(o="i"),t=(t=t.replace(/<span style="font-style: italic;">([\w\W]*?)<\/span>/gi,"<"+o+">$1</"+o+">")).replace(/<span style="font-weight: bold;">([\w\W]*?)<\/span>/gi,"<"+s+">$1</"+s+">"),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 s=!0===e?this.opts.allowedTags:this.opts.deniedTags,o=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;return t=t.replace(o,function(t,o){return!0===e?$.inArray(o.toLowerCase(),s)>"-1"?t:"":$.inArray(o.toLowerCase(),s)>"-1"?"":t}),t=this.cleanConvertInlineTags(t)},cleanSavePreCode:function(t,e){var s=t.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/gi);return null!==s&&$.each(s,$.proxy(function(s,o){var r=o.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/i);r[3]=r[3].replace(/&nbsp;/g," "),!1!==e&&(r[3]=this.cleanEncodeEntities(r[3])),r[3]=r[3].replace(/\$/g,"&#36;"),t=t.replace(o,"<"+r[1]+r[2]+">"+r[3]+"</"+r[1]+">")},this)),t},cleanEncodeEntities:function(t){return(t=String(t).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"')).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},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,s=0,o=t.length,r=0,a=null,n=null,l="",c="",h="";for(this.cleanlevel=0;s<o;s++){if(r=s,-1==t.substr(s).indexOf("<")){c+=t.substr(s);break}for(;r<o&&"<"!=t.charAt(r);)r++;for(s!=r&&((h=t.substr(s,r-s)).match(/^\s{2,}$/g)||("\n"==c.charAt(c.length-1)?c+=this.cleanGetTabs():"\n"==h.charAt(0)&&(c+="\n"+this.cleanGetTabs(),h=h.replace(/^\s+/,"")),c+=h),h.match(/\n/)&&(c+="\n"+this.cleanGetTabs())),a=r;r<o&&">"!=t.charAt(r);)r++;if(l=t.substr(a,r-a),s=r,"!--"==l.substr(1,3)){if(!l.match(/--$/)){for(;"-->"!=t.substr(r,3);)r++;r+=2,l=t.substr(a,r-a),s=r}"\n"!=c.charAt(c.length-1)&&(c+="\n"),c+=this.cleanGetTabs(),c+=l+">\n"}else"!"==l[1]?c=this.placeTag(l+">",c):"?"==l[1]?c+=l+">\n":(e=l.match(/^<(script|style|pre|code)/i))?(e[1]=e[1].toLowerCase(),l=this.cleanTag(l),c=this.placeTag(l,c),(n=String(t.substr(s+1)).toLowerCase().indexOf("</"+e[1]))&&(h=t.substr(s+1,n),s+=n,c+=h)):(l=this.cleanTag(l),c=this.placeTag(l,c))}return this.cleanFinish(c)},cleanGetTabs:function(){for(var t="",e=0;e<this.cleanlevel;e++)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,s="";t=(t=(t=t.replace(/\n/g," ")).replace(/\s{2,}/g," ")).replace(/^\s+|\s+$/g," ");var o="";for(t.match(/\/$/)&&(o="/",t=t.replace(/\/+$/,""));e=/\s*([^= ]+)(?:=((['"']).*?\3|[^ ]+))?/.exec(t);)e[2]?s+=e[1].toLowerCase()+"="+e[2]:e[1]&&(s+=e[1].toLowerCase()),s+=" ",t=t.substr(e[0].length);return s.replace(/\s*$/,"")+o+">"},placeTag:function(t,e){var s=t.match(this.cleannewLevel);return(t.match(this.cleanlineBefore)||s)&&(e=e.replace(/\s*$/,""),e+="\n"),s&&"/"==t.charAt(1)&&this.cleanlevel--,"\n"==e.charAt(e.length-1)&&(e+=this.cleanGetTabs()),s&&"/"!=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 s=(e=e.replace(/<br\s?\/?>/i,"")).replace(/<p>\s?<\/p>/gi,"");if(""===e||""===s){t.preventDefault();var o=$(this.opts.emptyHtml).get(0);this.$editor.html(o),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,s){if("LI"!==s.tagName){var o=$(s).parent();if("p"===t){if("P"===s.tagName&&0!=o.length&&"BLOCKQUOTE"===o[0].tagName||"BLOCKQUOTE"===s.tagName){this.formatQuote();return}if(this.opts.linebreaks){if(!s||0!=s.tagName.search(/H[1-6]/))return;$(s).replaceWith(s.innerHTML+"<br>")}else this.formatBlock(t,s)}else this.formatBlock(t,s)}},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 s="";if("code"!==t?s=$(e).contents():(s=$(e).html(),""===$.trim(s)&&(s='<span id="selection-marker-1"></span>')),"CODE"===e.tagName&&(t="p"),!0===this.opts.linebreaks&&"p"===t)$(e).replaceWith($("<div>").append(s).html()+"<br>");else{var o=this.getParent(),r=$("<"+t+">").append(s);$(e).replaceWith(r),o&&"TD"==o.tagName&&$(r).wrapAll("<td>")}},formatChangeTag:function(t,e,s){!1!==s&&this.selectionSave();var o=$("<"+e+"/>");return $(t).replaceWith(function(){return o.append($(this).contents())}),!1!==s&&this.selectionRestore(),o},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,s=t.length;if(t){var o="",r="",a=!1,n=!0;if($.each(t,function(t,e){"P"!==e.tagName&&(n=!1)}),$.each(t,$.proxy(function(l,c){if("BLOCKQUOTE"===c.tagName)this.formatBlock("p",c,!1);else if("P"===c.tagName){if("BLOCKQUOTE"==(e=$(c).parent())[0].tagName){var h=$(e).children("p").length;1==h?$(e).replaceWith(c):h==s?(a="blockquote",o+=this.outerHtml(c)):(a="html",o+=this.outerHtml(c),0==l?($(c).addClass("redactor-replaced").empty(),r=this.outerHtml(c)):$(c).remove())}else!1===n||1==t.length?this.formatBlock("blockquote",c,!1):(a="paragraphs",o+=this.outerHtml(c))}else"LI"!==c.tagName&&this.formatBlock("blockquote",c,!1)},this)),a){if("paragraphs"==a)$(t[0]).replaceWith("<blockquote>"+o+"</blockquote>"),$(t).remove();else if("blockquote"==a)$(e).replaceWith(o);else if("html"==a){var l=this.$editor.html().replace(r,"</blockquote>"+o+"<blockquote>");this.$editor.html(l),this.$editor.find("blockquote").each(function(){""==$.trim($(this).html())&&$(this).remove()})}}}this.selectionRestore()}else{var c=this.getBlock();if("BLOCKQUOTE"===c.tagName){this.selectionSave();var l=$.trim($(c).html()),h=$.trim(this.getSelectionHtml());if((l=l.replace(/<span(.*?)id="selection-marker(.*?)<\/span>/gi,""))==h)$(c).replaceWith($(c).html()+"<br>");else{this.inlineFormat("tmp");var d=this.$editor.find("tmp");d.empty();var p=this.$editor.html().replace("<tmp></tmp>",'</blockquote><span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"+h+"<blockquote>");this.$editor.html(p),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 u=this.selectionWrap("blockquote"),l=$(u).html(),f=["ul","ol","table","tr","tbody","thead","tfoot","dl"];$.each(f,function(t,e){l=(l=l.replace(RegExp("<"+e+"(.*?)>","gi"),"")).replace(RegExp("</"+e+">","gi"),"")});var m=this.opts.blockLevelElements;$.each(m,function(t,e){l=(l=l.replace(RegExp("<"+e+"(.*?)>","gi"),"")).replace(RegExp("</"+e+">","gi"),"<br>")}),$(u).html(l),this.selectionElement(u);var g=$(u).next();0!=g.length&&"BR"===g[0].tagName&&g.remove()}}this.sync()},blockRemoveAttr:function(t,e){$(this.getBlocks()).removeAttr(t),this.sync()},blockSetAttr:function(t,e){$(this.getBlocks()).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){$(this.getBlocks()).css(t,e),this.sync()},blockRemoveClass:function(t){var e=this.getBlocks();$(e).removeClass(t),this.removeEmptyAttr(e,"class"),this.sync()},blockSetClass:function(t){$(this.getBlocks()).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){$(this.getCurrent()).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(),s=this.getElement(),o=this.getNodes();(e.collapsed||e.startContainer===e.endContainer&&s)&&(o=$(s)),$(o).removeAttr(t),this.inlineUnwrapSpan(),this.selectionRestore(),this.sync()},inlineSetAttr:function(t,e){this.inlineMethods("attr",t,e)},inlineMethods:function(t,e,s){this.bufferSet(),this.selectionSave();var o=this.getRange(),r=this.getElement();if((o.collapsed||o.startContainer===o.endContainer)&&r&&!this.nodeTestBlocks(r))$(r)[t](e,s);else{var a,n=s;switch(e){case"font-size":a="fontSize",n=4;break;case"font-family":a="fontName";break;case"color":a="foreColor";break;case"background-color":a="backColor"}this.document.execCommand(a,!1,n);var l=this.$editor.find("font");$.each(l,$.proxy(function(o,r){this.inlineSetMethods(t,r,e,s)},this))}this.selectionRestore(),this.sync()},inlineSetMethods:function(t,e,s,o){var r,a=$(e).parent(),n=this.getSelectionText(),l=$(a).text();return n==l&&a&&"INLINE"===a[0].tagName&&0!=a[0].attributes.length?(r=a,$(e).replaceWith($(e).html())):(r=$("<inline>").append($(e).contents()),$(e).replaceWith(r)),$(r)[t](s,o),r},inlineEachNodes:function(t){var e,s=this.getRange(),o=this.getElement(),r=this.getNodes();(s.collapsed||s.startContainer===s.endContainer&&o)&&(r=$(o),e=!0),$.each(r,$.proxy(function(s,o){if(!e&&"INLINE"!==o.tagName){var r=this.getSelectionText(),a=$(o).parent().text();if(r!=a||"INLINE"!==o.parentNode.tagName||$(o.parentNode).hasClass("redactor_editor"))return;o=o.parentNode}t.call(this,o)},this))},inlineUnwrapSpan:function(){var t=this.$editor.find("inline");$.each(t,$.proxy(function(t,e){var s=$(e);void 0===s.attr("class")&&void 0===s.attr("style")&&s.contents().unwrap()},this))},inlineFormat:function(t){this.selectionSave(),this.document.execCommand("fontSize",!1,4);var e,s=this.$editor.find("font");$.each(s,function(s,o){var r=$("<"+t+"/>").append($(o).contents());$(o).replaceWith(r),e=r}),this.selectionRestore(),this.sync()},inlineRemoveFormat:function(t){this.selectionSave();var e=t.toUpperCase(),s=this.getNodes(),o=$(this.getParent()).parent();$.each(s,function(t,s){s.tagName===e&&this.inlineRemoveFormatReplace(s)}),o&&o[0].tagName===e&&this.inlineRemoveFormatReplace(o),this.selectionRestore(),this.sync()},inlineRemoveFormatReplace:function(t){$(t).replaceWith($(t).contents())},insertHtml:function(t,e){var s=this.getCurrent(),o=s.parentNode;this.focusWithSaveScroll(),this.bufferSet();var r=$("<div>").append($.parseHTML(t));t=r.html(),t=this.cleanRemoveEmptyTags(t),r=$("<div>").append($.parseHTML(t));var a=this.getBlock();if(1==r.contents().length){var n=r.contents()[0].tagName;("P"!=n&&n==a.tagName||"CODE"==n)&&(r=$("<div>").append(t))}this.opts.linebreaks&&(t=t.replace(/<p(.*?)>([\w\W]*?)<\/p>/gi,"$2<br>")),this.opts.linebreaks||1!=r.contents().length||3!=r.contents()[0].nodeType||!(this.getRangeSelectedNodes().length>2)&&s&&("BODY"!=s.tagName||o)&&"HTML"!=o.tagName||(t="<p>"+t+"</p>"),t=this.setSpansVerifiedHtml(t),r.contents().length>1&&a||r.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 s=this.getSelection();if(s.getRangeAt&&s.rangeCount){var o=s.getRangeAt(0);o.deleteContents();var r=document.createElement("div");r.innerHTML=t;for(var a,n,l=document.createDocumentFragment();a=r.firstChild;)n=l.appendChild(a);o.insertNode(l),n&&((o=o.cloneRange()).setStartAfter(n),o.collapse(!0),s.removeAllRanges(),s.addRange(o))}!1!==e&&this.sync()},insertBeforeCursor:function(t){t=this.setSpansVerifiedHtml(t);var e=$(t),s=document.createElement("span");s.innerHTML="​";var o=this.getRange();o.insertNode(s),o.insertNode(e[0]),o.collapse(!1);var r=this.getSelection();r.removeAllRanges(),r.addRange(o),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",s=t.outerHTML,o=RegExp("<"+t.tagName,"i"),r=s.replace(o,"<"+e);o=RegExp("</"+t.tagName,"i"),r=r.replace(o,"</"+e),t=$(r)[0]}var a=this.getSelection();return a.getRangeAt&&a.rangeCount&&((range=a.getRangeAt(0)).deleteContents(),range.insertNode(t),range.setEndAfter(t),range.setStartAfter(t),a.removeAllRanges(),a.addRange(range)),t},insertNodeToCaretPositionFromPoint:function(t,e){var s,o=t.clientX,r=t.clientY;if(this.document.caretPositionFromPoint){var a=this.document.caretPositionFromPoint(o,r);(s=this.getRange()).setStart(a.offsetNode,a.offset),s.collapse(!0),s.insertNode(e)}else if(this.document.caretRangeFromPoint)(s=this.document.caretRangeFromPoint(o,r)).insertNode(e);else if(void 0!==document.body.createTextRange){(s=this.document.body.createTextRange()).moveToPoint(o,r);var n=s.duplicate();n.moveToPoint(o,r),s.setEndPoint("EndToEnd",n),s.select()}},insertAfterLastElement:function(t,e){if(void 0!==e&&(t=e),this.isEndOfElement()){if(this.opts.linebreaks){var s=$("<div>").append($.trim(this.$editor.html())).contents(),o=s.last()[0];if("SPAN"==o.tagName&&""==o.innerHTML&&(o=s.prev()[0]),this.outerHtml(o)!=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{var 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(!0==t&&(e="<br><br>"),this.browser("mozilla")){var s=$("<span>").html(this.opts.invisibleSpace);this.$editor.find("#selection-marker-1").before(e).before(s).before(this.opts.invisibleSpace),this.setCaretAfter(s[0]),s.remove(),this.selectionRemoveMarkers()}else{var o=this.getParent();if(o&&"A"===o.tagName){var r=this.getCaretOffset(o),a=$.trim($(o).text()).replace(/\n\r\n/g,"").length;if(r==a){this.selectionRemoveMarkers();var n=$('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>",this.document)[0];return $(o).after(n),$(n).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){if(t=this.callback("pasteBefore",!1,t),this.browser("msie")){var e=$.trim(t);0==e.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 s=!1;if(this.currentOrParentIs("TD")){s=!0;var o=this.opts.blockLevelElements;o.push("tr"),o.push("table"),$.each(o,function(e,s){t=(t=t.replace(RegExp("<"+s+"(.*?)>","gi"),"")).replace(RegExp("</"+s+">","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(/(&nbsp;){2,}/gi,"&nbsp;")).replace(/&nbsp;/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>&nbsp;<\/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*|&nbsp;|<br>)<\/[^>]+>/gi,"<br>")):t=t.replace(/<[^\/>][^>]*>(\s*|\t*|\n*|&nbsp;|<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>&nbsp;</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===s&&(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 r=t.match(/<img src="data:image(.*?)"(.*?)>/gi);if(null!==r)for(var a in this.pasteClipboardMozilla=r,r){var n=r[a].replace("<img",'<img data-mozilla-paste-image="'+a+'" ');t=t.replace(r[a],n)}}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===s&&(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,s){null!=s&&0===s.toString().indexOf("#")&&(s=$(s).val()),t[e]=s},this)),t},pasteClipboardUploadMozilla:function(){var t=this.$editor.find("img[data-mozilla-paste-image]");$.each(t,$.proxy(function(t,e){var s=$(e),o=e.src.split(","),r={contentType:o[0].split(";")[0].split(":")[1],data:o[1]};r=this.pasteClipboardAppendFields(r),$.post(this.opts.clipboardUploadUrl,r,$.proxy(function(t){var e="string"==typeof t?$.parseJSON(t):t;s.attr("src",e.image.url),s.removeAttr("data-mozilla-paste-image"),this.sync(),this.callback("imageUpload",s,e)},this))},this))},pasteClipboardUpload:function(t){var e=t.target.result,s=e.split(","),o={contentType:s[0].split(";")[0].split(":")[1],data:s[1]};this.opts.clipboardUpload?(o=this.pasteClipboardAppendFields(o),$.post(this.opts.clipboardUploadUrl,o,$.proxy(function(t){var e="string"==typeof t?$.parseJSON(t):t,s='<img src="'+e.image.url+'" id="clipboard-image-marker" />';this.execCommand("inserthtml",s,!1);var o=$(this.$editor.find("img#clipboard-image-marker"));o.length?o.removeAttr("id"):o=!1,this.sync(),o&&this.callback("imageUpload",o,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(){if(0===this.opts.buffer.length){this.focusWithSaveScroll();return}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)},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 s=$(e).parent();s.hasClass("royalSlider")||s.hasClass("fotorama")||this.imageResize(e)},this)),this.$editor.find(".fotorama, .royalSlider").on("click",$.proxy(this.editGallery,this))},linkObserver:function(t){var e=$(t.target),s=$(t.target).parent();if(!(s.hasClass("royalSlider")||s.hasClass("fotorama"))&&0!=e.length&&"A"===e[0].tagName){var o=e.offset();if(this.opts.iframe){var r=this.$frame.offset();o.top=r.top+(o.top-$(this.document).scrollTop()),o.left+=r.left}var a=$('<span class="redactor-link-tooltip"></span>'),n=e.attr("href");void 0===n&&(n=""),n.length>24&&(n=n.substring(0,24)+"...");var l=$('<a href="'+e.attr("href")+'" target="_blank">'+n+"</a>").on("click",$.proxy(function(t){this.linkObserverTooltipClose(!1)},this)),c=$('<a href="#">'+this.opts.curLang.edit+"</a>").on("click",$.proxy(function(t){t.preventDefault(),this.linkShow(),this.linkObserverTooltipClose(!1)},this)),h=$('<a href="#">'+this.opts.curLang.unlink+"</a>").on("click",$.proxy(function(t){t.preventDefault(),this.execCommand("unlink"),this.linkObserverTooltipClose(!1)},this));a.append(l),a.append(" | "),a.append(c),a.append(" | "),a.append(h),a.css({top:o.top+20+"px",left:o.left+"px"}),$(".redactor-link-tooltip").remove(),$("body").append(a)}},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,s,o){null==s&&(s=t),null==o&&(o=e);var r=this.getSelection();if(r){if("P"==t.tagName&&""==t.innerHTML&&(t.innerHTML=this.opts.invisibleSpace),"BR"==t.tagName&&!1===this.opts.linebreaks){var a=$(this.opts.emptyHtml)[0];$(t).replaceWith(a),s=t=a}var n=this.getRange();n.setStart(t,e),n.setEnd(s,o);try{r.removeAllRanges()}catch(l){}r.addRange(n)}},selectionWrap:function(t){t=t.toLowerCase();var e=this.getBlock();if(e){var s=this.formatChangeTag(e,t);return this.sync(),s}var o=this.getSelection().getRangeAt(0),s=document.createElement(t);return s.appendChild(o.extractContents()),o.insertNode(s),this.selectionElement(s),s},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=0,s=this.getRange(),o=s.cloneRange();return o.selectNodeContents(t),o.setEnd(s.endContainer,s.endOffset),e=$.trim(o.toString()).length},getCaretOffsetRange:function(){return new Range(this.getSelection().getRangeAt(0))},setCaret:function(t,e,s){void 0===s&&(s=e),t=t[0]||t;var o=this.getRange();o.selectNodeContents(t);var r,a=this.getTextNodesIn(t),n=!1,l=0;if(1==a.length&&e)o.setStart(a[0],e),o.setEnd(a[0],s);else for(var c,h=0;c=a[h++];){if(r=l+c.length,!n&&e>=l&&(e<r||e==r&&h<a.length)&&(o.setStart(c,e-l),n=!0),n&&s<=r){o.setEnd(c,s-l);break}l=r}var d=this.getSelection();d.removeAllRanges(),d.addRange(o)},setCaretAfter:function(t){this.$editor.focus(),t=t[0]||t;var e=this.document.createRange(),s=1,o=-1;e.setStart(t,s),e.setEnd(t,o+2);var r=this.window.getSelection(),a=this.document.createRange(),n=this.document.createTextNode("​");$(t).after(n),a.setStartAfter(n),r.removeAllRanges(),r.addRange(a),$(n).remove()},getTextNodesIn:function(t){var e=[];if(3==t.nodeType)e.push(t);else for(var s=t.childNodes,o=0,r=s.length;o<r;++o)e.push.apply(e,this.getTextNodesIn(s[o]));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)){if($(t).hasClass("redactor_editor"))return!1;return t}t=t.parentNode}return!1},getBlocks:function(t){var e=[];if(void 0===t){var s=this.getRange();if(s&&!0===s.collapsed)return[this.getBlock()];var t=this.getNodes(s)}return $.each(t,$.proxy(function(t,s){if(!1===this.opts.iframe&&0==$(s).parents("div.redactor_editor").length)return!1;this.nodeTestBlocks(s)&&e.push(s)},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||!1==t)var t=this.getRange();if(t&&!0===t.collapsed){if(!(void 0===e&&this.tagTestBlock(e)))return[this.getCurrent()];var s=this.getBlock();return s.tagName==e?[s]:[]}var o=[],r=[],a=this.document.getSelection();if(a.isCollapsed||(o=this.getRangeSelectedNodes(a.getRangeAt(0))),$.each(o,$.proxy(function(t,s){if(!1===this.opts.iframe&&0==$(s).parents("div.redactor_editor").length)return!1;void 0===e?""!=$.trim(s.textContent)&&r.push(s):s.tagName==e&&r.push(s)},this)),0==r.length){if(void 0===e&&this.tagTestBlock(e)){var s=this.getBlock();return s.tagName==e?r.push(s):[]}r.push(this.getCurrent())}var n=r[r.length-1];return this.nodeTestBlocks(n)&&(r=r.slice(0,-1)),r},getElement:function(t){for(t||(t=this.getCurrent());t;){if(1==t.nodeType){if($(t).hasClass("redactor_editor"))return!1;return t}t=t.parentNode}return!1},getRangeSelectedNodes:function(t){var e=(t=t||this.getRange()).startContainer,s=t.endContainer;if(e==s)return[e];for(var o=[];e&&e!=s;)o.push(e=this.nextNode(e));for(e=t.startContainer;e&&e!=t.commonAncestorContainer;)o.unshift(e),e=e.parentNode;return o},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 s=this.document.createElement("div"),o=e.rangeCount,r=0;r<o;++r)s.appendChild(e.getRangeAt(r).cloneContents());t=s.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 s=$('<span id="selection-marker-1" class="redactor-selection-marker">'+this.opts.invisibleSpace+"</span>",this.document)[0],o=$('<span id="selection-marker-2" class="redactor-selection-marker">'+this.opts.invisibleSpace+"</span>",this.document)[0];!0===t.collapsed?this.selectionSetMarker(t,s,!0):(this.selectionSetMarker(t,s,!0),this.selectionSetMarker(t,o,!1)),this.savedSel=this.$editor.html(),this.selectionRestore(!1,!1)}},selectionSetMarker:function(t,e,s){var o=t.cloneRange();try{o.collapse(s),o.insertNode(e),o.detach()}catch(r){var a=this.opts.emptyHtml;this.opts.linebreaks&&(a="<br>"),this.$editor.prepend(a),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 s=this.$editor.find("span#selection-marker-1"),o=this.$editor.find("span#selection-marker-2");this.browser("mozilla")?this.$editor.focus():this.isFocused()||this.focusWithSaveScroll(),0!=s.length&&0!=o.length?this.selectionSet(s[0],0,o[0],0):0!=s.length&&this.selectionSet(s[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,s,o,r=$("#redactor_table_rows").val(),a=$("#redactor_table_columns").val(),n=$("<div></div>"),l=Math.floor(99999*Math.random()),c=$('<table id="table'+l+'"><tbody></tbody></table>');for(t=0;t<r;t++){for(s=0,e=$("<tr></tr>");s<a;s++)o=$("<td>"+this.opts.invisibleSpace+"</td>"),0===t&&0===s&&o.append('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),$(e).append(o);c.append(e)}n.append(c);var h=n.html();!1===this.opts.linebreaks&&this.browser("mozilla")&&(h+="<p>"+this.opts.invisibleSpace+"</p>"),this.modalClose(),this.selectionRestore();var d=this.getBlock()||this.getCurrent();if(d&&"BODY"!=d.tagName){if("LI"==d.tagName)var d=$(d).closest("ul, ol");$(d).after(h)}else this.insertHtmlAdvanced(h,!1);this.selectionRestore();var p=this.$editor.find("#table"+l);this.buttonActiveObserver(),p.find("span#selection-marker-1, inline#selection-marker-1").remove(),p.removeAttr("id"),this.sync()},tableDeleteTable:function(){var t=$(this.getParent()).closest("table");if(!this.isParentRedactor(t)||0==t.length)return!1;this.bufferSet(),t.remove(),this.sync()},tableDeleteRow:function(){var t=this.getParent(),e=$(t).closest("table");if(!this.isParentRedactor(e)||0==e.length)return!1;this.bufferSet();var s=$(t).closest("tr"),o=s.prev().length?s.prev():s.next();if(o.length){var r=o.children("td").first();r.length&&r.prepend('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>")}s.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)||0==e.length)return!1;this.bufferSet();var s=$(t).closest("td");s.is("td")||(s=s.closest("td"));var o=s.get(0).cellIndex;e.find("tr").each($.proxy(function(t,e){var s=o-1<0?o+1:o-1;0===t&&$(e).find("td").eq(s).prepend('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),$(e).find("td").eq(o).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)||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>")).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)||0==e.length)return!1;this.bufferSet();var s=$(this.getParent()).closest("tr"),o=s.clone();o.find("td").html(this.opts.invisibleSpace),"after"===t?s.after(o):s.before(o),this.sync()},tableAddColumn:function(t){var e=$(this.getParent()).closest("table");if(!this.isParentRedactor(e)||0==e.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)),e.find("tr").each($.proxy(function(e,o){var r=$(o).find("td").eq(s),a=r.clone();a.html(this.opts.invisibleSpace),"after"===t?r.after(a):r.before(a)},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();t=this.cleanStripTags(t);var e='<iframe width="500" height="281" src="',s='" frameborder="0" allowfullscreen></iframe>';t.match(reUrlYoutube)?t=t.replace(reUrlYoutube,e+"//www.youtube.com/embed/$1"+s):t.match(reUrlVimeo)?t=t.replace(reUrlVimeo,e+"//player.vimeo.com/video/$2"+s):t.match(reUrlFacebook)?t=t.replace(reUrlFacebook,e+"https://www.facebook.com/video/embed?video_id=$1"+s):t.match(reUrlRutube)&&(t=t.replace(reUrlRutube,e+"//rutube.ru/play/embed/$1"+s)),this.selectionRestore();var o=this.getBlock()||this.getCurrent();o?$(o).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 s=$("#redactor-predefined-links");s.html(""),$.each(e,function(e,o){t.predefinedLinksStorage[e]=o,s.append($("<option>").val(e).html(o.name))}),s.on("change",function(){var e=$(this).val(),s="",o="";0!=e&&(s=t.predefinedLinksStorage[e].name,o=t.predefinedLinksStorage[e].url),$("#redactor_link_url").val(o),1!=$("#redactor_link_url_text").data("is_selected_text")&&$("#redactor_link_url_text").val(s)}),s.show()}})}this.insert_link_node=!1;var e=this.getSelection(),s="",o="",r="",a=this.getParent(),n=$(a).parent().get(0);n&&"A"===n.tagName&&(a=n),a&&"A"===a.tagName?(s=a.href,o=$(a).text(),r=a.target,this.insert_link_node=a):o=e.toString(),$("#redactor_link_url_text").val(o),o.length>0&&$("#redactor_link_url_text").data("is_selected_text",1);var l=self.location.href.replace(/\/$/i,"");if(s=(s=(s=s.replace(l,"")).replace(/^\/#/,"#")).replace("mailto:",""),!1===this.opts.linkProtocol){var c=RegExp("^(http|ftp|https)://"+self.location.host,"i");s=s.replace(c,"")}$("#redactor_link_url").val(s),"_blank"===r&&$("#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="",s=$("#redactor_link_url").val(),o=$("#redactor_link_url_text").val();if(-1!=s.search("@")&&!1===/(http|ftp|https):\/\//i.test(s))s="mailto:"+s;else if(0!=s.search("#")){$("#redactor_link_blank").prop("checked")&&(t=' target="_blank"',e="_blank");var r="((xn--)?[a-z0-9]+(-[a-z0-9]+)*.)+[a-z]{2,}",a=RegExp("^(http|ftp|https)://"+r,"i"),n=RegExp("^"+r,"i");-1==s.search(a)&&0==s.search(n)&&this.opts.linkProtocol&&(s=this.opts.linkProtocol+s)}o=o.replace(/<|>/g,"");var l="&nbsp;";this.browser("mozilla")&&(l="&nbsp;"),this.linkInsert('<a href="'+s+'"'+t+">"+o+"</a>"+l,$.trim(o),s,e)}},linkInsert:function(t,e,s,o){if(this.selectionRestore(),""!==e){if(this.insert_link_node)this.bufferSet(),$(this.insert_link_node).text(e).attr("href",s),""!==o?$(this.insert_link_node).attr("target",o):$(this.insert_link_node).removeAttr("target");else{var r=$(t).addClass("redactor-added-link");this.exec("inserthtml",this.outerHtml(r),!1);var s=this.$editor.find("a.redactor-added-link");s.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 s='<a href="'+t.filelink+'" id="filelink-marker">'+e+"</a>";this.browser("webkit")&&this.window.chrome&&(s+="&nbsp;"),this.execCommand("inserthtml",s,!1);var o=$(this.$editor.find("a#filelink-marker"));0!=o.length?o.removeAttr("id"):o=!1,this.sync(),this.callback("fileUpload",o,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);return}var e={},s=0;$.each(t,$.proxy(function(t,o){void 0!==o.folder&&(s++,e[o.folder]=s)},this)),$("#redactor_image_box .empty_list").show();var o=!1;if($.each(t,$.proxy(function(t,s){var r="";void 0!==s.title&&(r=s.title);var a=0;$.isEmptyObject(e)||void 0===s.folder||(a=e[s.folder],!1!==o||(o=".redactorfolder"+a));var n=$('<img src="'+s.thumb+'" class="redactorfolder redactorfolder'+a+'" rel="'+s.image+'" title="'+r+'" />');$("#redactor_image_box").append(n),$(n).on("click",$.proxy(this.imageThumbClick,this)),$("#redactor_image_box .empty_list").hide()},this)),!$.isEmptyObject(e)){$(".redactorfolder").hide(),$(o).show();var r=function(t){$(".redactorfolder").hide(),$(".redactorfolder"+$(t.target).val()).show()},a=$('<select id="redactor_image_box_select">');$.each(e,function(t,e){a.append($('<option value="'+e+'">'+t+"</option>"))}),$("#redactor_image_box").before(a),a.change(r)}},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,s=e.parent().parent(),o=$.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"===$(s).get(0).tagName&&($("#redactor_file_link").val($(s).attr("href")),"_blank"==$(s).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,o)},imageRemove:function(t){var e=$(t).parent().parent(),s=$(t).parent(),o=!1;e.length&&"A"===e[0].tagName?(o=!0,$(e).remove()):s.length&&"A"===s[0].tagName?(o=!0,$(s).remove()):$(t).remove(),s.length&&"P"===s[0].tagName&&(this.focusWithSaveScroll(),!1===o&&this.selectionStart(s)),this.callback("imageDelete",t),this.modalClose(),this.sync()},imageSave:function(t){this.imageResizeHide(!1);var e=$(t),s=e.parent();e.attr("alt",$("#redactor_file_alt").val());var o=$("#redactor_form_image_align").val(),r="";"left"===o?(r="0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin+" 0",e.css({float:"left",margin:r})):"right"===o?(r="0 0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin,e.css({float:"right",margin:r})):"center"===o?e.css({float:"",display:"block",margin:"auto"}):e.css({float:"",display:"",margin:""});var a=$.trim($("#redactor_file_link").val());if(""!==a){var n=!1;if($("#redactor_link_blank").prop("checked")&&(n=!0),"A"!==s.get(0).tagName){var l=$('<a href="'+a+'">'+this.outerHtml(t)+"</a>");n&&l.attr("target","_blank"),e.replaceWith(l)}else s.attr("href",a),n?s.attr("target","_blank"):s.removeAttr("target")}else"A"===s.get(0).tagName&&s.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 s,o,r=e.width()/e.height(),a=20,n=this.imageResizeControls(e),l=!1;!1!==n&&(n.on("mousedown",function(t){l=!0,t.preventDefault(),r=e.width()/e.height(),s=Math.round(t.pageX-e.eq(0).offset().left),o=Math.round(t.pageY-e.eq(0).offset().top)}),$(this.document.body).on("mousemove",$.proxy(function(t){if(l){t.pageX,e.eq(0).offset().left;var n=Math.round(t.pageY-e.eq(0).offset().top)-o,c=Math.round((parseInt(e.height(),10)+n)*r);c>a&&(e.width(c),c<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"})),s=Math.round(t.pageX-e.eq(0).offset().left),o=Math.round(t.pageY-e.eq(0).offset().top),this.sync()}},this)).on("mouseup",function(){l=!1})),this.$editor.on("keydown.redactor-image-delete",$.proxy(function(t){var s=t.which;(this.keyCode.BACKSPACE==s||this.keyCode.DELETE==s)&&(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)return e.append(t),!1;var s=$('<span id="redactor-image-resizer" data-redactor="verified"></span>');return s.css({position:"absolute",zIndex:2,lineHeight:1,cursor:"nw-resize",bottom:"-4px",right:"-5px",border:"1px solid #fff",backgroundColor:"#000",width:"8px",height:"8px"}),s.attr("contenteditable",!1),e.append(s),e.append(t),s},imageThumbClick:function(t){var e='<img id="image-marker" src="'+$(t.target).attr("rel")+'" alt="'+$(t.target).attr("title")+'" />',s=this.getParent();this.opts.paragraphy&&0==$(s).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 s="";if(!0!==e){s='<img id="image-marker" src="'+t.image.url+'" />';var o=this.getParent();this.opts.paragraphy&&0==$(o).closest("li").length&&(s="<p>"+s+"</p>")}else s=t;this.execCommand("inserthtml",s,!1);var r=$(this.$editor.find("img#image-marker"));r.length?r.removeAttr("id"):r=!1,this.sync(),!0!==e&&this.callback("imageUpload",r,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,s,o){return this.modalSetOverlay(),this.$redactorModalWidth=s,this.$redactorModal=$("#redactor_modal"),this.$redactorModal.length||(this.$redactorModal=$('<div id="redactor_modal" style="display: none;" />'),this.$redactorModal.append($('<div id="redactor_modal_close">&times;</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 o&&o(),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(s,o){s++,$(o).on("click",function(o){if(o.preventDefault(),t.find("a").removeClass("redactor_tabs_act"),$(this).addClass("redactor_tabs_act"),$(".redactor_tab").hide(),$("#redactor_tab"+s).show(),$("#redactor_tab_selected").val(s),!1===e.isMobile()){var r=e.$redactorModal.outerHeight();e.$redactorModal.css("margin-top","-"+(r+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,s=t.target.files,o=0;e=s[o];o++)this.s3uploadFile(e)},s3uploadFile:function(t){this.s3executeOnSignedUrl(t,$.proxy(function(e){this.s3uploadToS3(t,e)},this))},s3executeOnSignedUrl:function(t,e){var s=new XMLHttpRequest,o="?";"-1"!=this.opts.s3.search(/\?/)&&(o="&"),s.open("GET",this.opts.s3+o+"name="+t.name+"&type="+t.type,!0),s.overrideMimeType&&s.overrideMimeType("text/plain; charset=x-user-defined");var r=this;s.onreadystatechange=function(t){4==this.readyState&&200==this.status?(r.showProgressBar(),e(decodeURIComponent(this.responseText))):4==this.readyState&&this.status},s.send()},s3createCORSRequest:function(t,e){var s=new XMLHttpRequest;return"withCredentials"in s?s.open(t,e,!0):"undefined"!=typeof XDomainRequest?(s=new XDomainRequest).open(t,e):s=null,s},s3uploadToS3:function(t,e){var s=this.s3createCORSRequest("PUT",e);s&&(s.onload=$.proxy(function(){if(200==s.status){this.hideProgressBar();var t=e.split("?");if(!t[0])return!1;this.selectionRestore();var o="";o='<img id="image-marker" src="'+t[0]+'" />',this.opts.paragraphy&&(o="<p>"+o+"</p>"),this.execCommand("inserthtml",o,!1);var r=$(this.$editor.find("img#image-marker"));r.length?r.removeAttr("id"):r=!1,this.sync(),this.callback("imageUpload",r,!1),this.modalClose(),this.observeImages()}},this),s.onerror=function(){},s.upload.onprogress=function(t){},s.setRequestHeader("Content-Type",t.type),s.setRequestHeader("x-amz-acl","public-read"),s.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 s=$("#"+t);s.length&&"INPUT"===s[0].tagName?(this.uploadOptions.input=s,this.el=$(s[0].form)):this.el=s,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 s="redactorUploadForm"+this.id,o="redactorUploadFile"+this.id;this.form=$('<form  action="'+this.uploadOptions.url+'" method="POST" target="'+e+'" name="'+s+'" id="'+s+'" 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 s=$("<input/>",{type:"hidden",name:t,value:e});$(this.form).append(s)},this));var r=this.uploadOptions.input,a=$(r).clone();$(r).attr("id",o).before(a).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 s=t.body.innerHTML.match(/\{(.|\n)*\}/)[0];s=(s=s.replace(/^\[/,"")).replace(/\]$/,"");var o=$.parseJSON(s);void 0===o.error?this.uploadOptions.success(o):(console.log(o),this.uploadOptions.error(this,o),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,s,o,r){if(!s){var a=$.ajaxSettings.xhr();a.upload&&a.upload.addEventListener("progress",$.proxy(this.uploadProgress,this),!1),$.ajaxSetup({xhr:function(){return a}})}this.callback("drop",o);var n=new FormData;!1!==r?n.append(r,e):n.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()),n.append(t,e)},this)),$.ajax({url:t,dataType:"html",async:!1,data:n,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(),s){var r=$("<img>");r.attr("src",e.image.url).attr("id","drag-image-marker"),this.insertNodeToCaretPositionFromPoint(o,r[0]);var a=$(this.$editor.find("img#drag-image-marker"));a.length?a.removeAttr("id"):a=!1,this.sync(),this.observeImages(),a&&this.callback("imageUpload",a,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 s=t.loaded?parseInt(t.loaded/t.total*100,10):t;this.dropareabox.text("Loading "+s+"% "+(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(/&#x200b;|<br>|<br\/>|&nbsp;/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!=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(),s=/(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)||0>e.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return"version"==t?s[2]:"webkit"==t?"chrome"==s[1]||"webkit"==s[1]:"rv"==s[1]?"msie"==t:"opr"==s[1]?"webkit"==t:t==s[1]},oldIE:function(){return!!(this.browser("msie")&&9>parseInt(this.browser("version"),10))},getFragmentHtml:function(t){var e=t.cloneNode(!0),s=this.document.createElement("div");return s.appendChild(e),s.innerHTML},extractContent:function(){for(var t,e=this.$editor[0],s=this.document.createDocumentFragment();t=e.firstChild;)s.appendChild(t);return s},isParentRedactor:function(t){return!!t&&(this.opts.iframe?t:!(0==$(t).parents("div.redactor_editor").length||$(t).hasClass("redactor_editor"))&&t)},currentOrParentIs:function(t){var e=this.getParent(),s=this.getCurrent();return e&&e.tagName===t?e:!!s&&s.tagName===t&&s},isEndOfElement:function(){var t=this.getBlock(),e=this.getCaretOffset(t),s=$.trim($(t).text()).replace(/\n\r\n/g,"").length;return e==s},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 s=null;-1!==(s=t.indexOf(e));)t.splice(s,1);return t}},Redactor.prototype.init.prototype=Redactor.prototype,$.Redactor.fn.formatLinkify=function(t,e,s,o,r){for(var a=/(((https?|ftps?):\/\/)|www[.][^\s])(.+?\..+?)([.),]?)(\s|\.\s+|\)|$)/gi,n=/(https?|ftp):\/\//i,l=/(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/gi,c=(this.$editor?this.$editor.get(0):this).childNodes,h=c.length;h--;){var d=c[h];if(3===d.nodeType){var p=d.nodeValue;if(o&&p){var u='<iframe width="500" height="281" src="',f='" frameborder="0" allowfullscreen></iframe>';p.match(reUrlYoutube)?(p=p.replace(reUrlYoutube,u+"//www.youtube.com/embed/$1"+f),$(d).after(p).remove()):p.match(reUrlVimeo)&&(p=p.replace(reUrlVimeo,u+"//player.vimeo.com/video/$2"+f),$(d).after(p).remove())}if(s&&p&&p.match(l)&&(p=p.replace(l,'<img src="$1">'),$(d).after(p).remove()),e&&p&&p.match(a)){var m=p.match(a);for(var h in m){var g=m[h],b=g,v="";null!==g.match(/\s$/)&&(v=" ");var _=t;null!==g.match(n)&&(_=""),b.length>r&&(b=b.substring(0,r)+"...");var y=(b=b.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")).replace("$","$$$");p=p.replace(g,'<a href="'+_+$.trim(g)+'">'+$.trim(y)+"</a>"+v)}$(d).after(p).remove()}}else 1!==d.nodeType||/^(a|button|textarea)$/i.test(d.tagName)||$.Redactor.fn.formatLinkify.call(d,t,e,s,o,r)}}}(jQuery);
\ No newline at end of file
+!function($){var uuid=0;"use strict";var 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.-]*/ig,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=[],s=Array.prototype.slice.call(arguments,1);return("string"==typeof t?this.each(function(){var o=$.data(this,"redactor");if(!(void 0!==o&&$.isFunction(o[t])))return $.error('No such method "'+t+'" for Redactor');var r=o[t].apply(o,s);void 0!==r&&r!==o&&e.push(r)}):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>&#x200b;</p>",invisibleSpace:"&#x200b;",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 s=$.extend(!0,{},$.Redactor.opts);if(this.opts=$.extend({},s,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=RegExp("^<(/?"+this.opts.ownLine.join("|/?")+"|"+this.opts.contOwnLine.join("|")+")[ >]"),this.cleanlineAfter=RegExp("^<(br|/?"+this.opts.ownLine.join("|/?")+"|/"+this.opts.contOwnLine.join("|/")+")[ >]"),this.cleannewLevel=RegExp("^</?("+this.opts.newLevel.join("|")+")[ >]"),this.rTestBlock=RegExp("^("+this.opts.blockLevelElements.join("|")+")$","i"),!1===this.opts.linebreaks){if(!1!==this.opts.allowedTags){var o=["strong","em","del"],r=["b","i","strike"];for(i in"-1"===$.inArray("p",this.opts.allowedTags)&&this.opts.allowedTags.push("p"),o)"-1"!=$.inArray(o[i],this.opts.allowedTags)&&this.opts.allowedTags.push(r[i])}if(!1!==this.opts.deniedTags){var a=$.inArray("p",this.opts.deniedTags);"-1"!==a&&this.opts.deniedTags.splice(a,a)}}(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:"&bull; "+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,s){var o=this.opts[t+"Callback"];return $.isFunction(o)?!1===e?o.call(this,s):o.call(this,e,s):s},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,s){t=(t=t.toString()).replace(/\$/g,"&#36;"),this.opts.fullpage?this.setCodeIframe(t):this.setEditor(t,e),""==t&&(s=!1),!1!==s&&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(/&amp;#36;/g,"$"),t=this.cleanEmpty(t),this.$editor.html(t),this.setNonEditable(),this.setSpansVerified(),this.sync()},sanitizeHTML:function(t){if(0===t.length)return t;function e(){return new DOMParser().parseFromString(t,"text/html").body}function s(t){let e=t.children;for(let r of e)o(r),s(r)}function o(t){let e=t.attributes;for(let{name:s,value:o}of e)r(s,o)&&t.removeAttribute(s)}function r(t,e){let s=e.replace(/\s+/g,"").toLowerCase();if(["src","href","xlink:href"].includes(t)&&(s.includes("javascript:")||s.includes("data:text/html"))||t.startsWith("on"))return!0}let a=e();return s(a),a.innerHTML},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,s=RegExp("<"+this.tagName,"gi"),o=t.replace(s,"<"+e);s=RegExp("</"+this.tagName,"gi"),o=o.replace(s,"</"+e),$(this).replaceWith(o)})},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,s="";if(this.cleanUnverified(),s=this.opts.fullpage?this.getCodeIframe():this.$editor.html(),s=this.syncClean(s),s=this.cleanRemoveEmptyTags(s),this.cleanRemoveSpaces(this.$source.val(),!1)==this.cleanRemoveSpaces(s,!1))return!1;if(s=s.replace(/<\/li><(ul|ol)>([\w\W]*?)<\/(ul|ol)>/gi,"<$1>$2</$1></li>"),"<br>"===$.trim(s)&&(s=""),this.opts.xhtml){var o=["br","hr","img","link","input","meta"];$.each(o,function(t,e){s=s.replace(RegExp("<"+e+"(.*?[^/$]?)>","gi"),"<"+e+"$1 />")})}if(s=this.callback("syncBefore",!1,s),this.$source.val(s),this.setFullpageDoctype(),this.callback("syncAfter",!1,s),!1===this.start){if(void 0!==t)switch(t.which){case 37:case 38:case 39:case 40:break;default:this.callback("change",!1,s)}else this.callback("change",!1,s)}},syncClean:function(t){return this.opts.fullpage||(t=this.cleanStripTags(t)),t=$.trim(t),("<p></p>"==(t=(t=(t=(t=(t=this.placeholderRemoveFromCode(t)).replace(/&#x200b;/gi,"")).replace(/&#8203;/gi,"")).replace(/<\/a>&nbsp;/gi,"</a> ")).replace(/\u200B/g,""))||"<p> </p>"==t||"<p>&nbsp;</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("<!--?php","<?php")).replace("?-->","?>")).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,"&trade;")).replace(/\u00a9/gi,"&copy;")).replace(/\u2026/gi,"&hellip;")).replace(/\u2014/gi,"&mdash;")).replace(/\u2010/gi,"&dash;"),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,s){t.addClass("redactor_"+s)})},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||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;if(this.browser("webkit")&&-1===navigator.userAgent.indexOf("Chrome")&&this.browser("version").split(".")[0]<536&&(e=!0),e||this.browser("opera")||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 s=this.extractContent();setTimeout($.proxy(function(){var t=this.extractContent();this.$editor.append(s),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 s=e.clipboardData.items[0].getAsFile();if(null!==s){this.bufferSet(),this.clipboardFilePaste=!0;var o=new FileReader;return o.onload=$.proxy(this.pasteClipboardUpload,this),o.readAsDataURL(s),!0}}return!1},buildEventKeydown:function(t){if(this.rtePaste)return!1;var e=t.which,s=t.ctrlKey||t.metaKey,o=this.getParent(),r=this.getCurrent(),a=this.getBlock(),n=!1;if(this.callback("keydown",t),this.browser("mozilla")&&"modify"in window.getSelection()&&s&&(37===t.keyCode||39===t.keyCode)){var l=this.getSelection(),c=t.metaKey?"line":"word";37!==t.keyCode||(l.modify("extend","left",c),t.shiftKey||l.collapseToStart()),39!==t.keyCode||(l.modify("extend","right",c),t.shiftKey||l.collapseToEnd()),t.preventDefault()}if(this.imageResizeHide(!1),(o&&"CODE"===$(o).get(0).tagName||r&&"CODE"===$(r).get(0).tagName)&&(n=!0,e===this.keyCode.DOWN&&this.insertAfterLastElement(a)),e===this.keyCode.DOWN&&(o&&"BLOCKQUOTE"===$(o)[0].tagName&&this.insertAfterLastElement(o),r&&"BLOCKQUOTE"===$(r)[0].tagName&&this.insertAfterLastElement(r),o&&"P"===$(o)[0].tagName&&"BLOCKQUOTE"==$(o).parent()[0].tagName&&this.insertAfterLastElement(o,$(o).parent()[0]),r&&"P"===$(r)[0].tagName&&o&&"BLOCKQUOTE"==$(o)[0].tagName&&this.insertAfterLastElement(r,o)),this.shortcuts(t,e),!s||90!==e||t.shiftKey||t.altKey){if(s&&90===e&&t.shiftKey&&!t.altKey){t.preventDefault(),0!=this.opts.rebuffer.length?this.bufferRedo():this.document.execCommand("redo",!1,!1);return}}else{t.preventDefault(),this.opts.buffer.length?this.bufferUndo():this.document.execCommand("undo",!1,!1);return}if(32==e&&this.bufferSet(),s&&65===e?(this.bufferSet(),this.selectall=!0):e==this.keyCode.LEFT_WIN||s||(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 h=this.getRange();if(h&&!1===h.collapsed&&(sel=this.getSelection()).rangeCount&&h.deleteContents(),this.browser("msie")&&1==o.nodeType&&("TD"==o.tagName||"TH"==o.tagName))return t.preventDefault(),this.bufferSet(),this.insertNode(document.createElement("br")),this.callback("enter",t),!1;if(a&&("BLOCKQUOTE"==a.tagName||"BLOCKQUOTE"==$(a).parent()[0].tagName)){if(this.isEndOfElement()){if(1==this.dblEnter){if("BLOCKQUOTE"==a.tagName?(p="br",d=a):(p="p",d=$(a).parent()[0]),t.preventDefault(),this.insertingAfterLastElement(d),this.dblEnter=0,"p"==p)$(a).parent().find("p").last().remove();else{var d,p,u=$.trim($(a).html());$(a).html(u.replace(/<br\s?\/?>$/i,""))}return}this.dblEnter++}else this.dblEnter++}if(!0===n)return this.buildEventKeydownPre(t,r);if(!this.opts.linebreaks){if(a&&"LI"==a.tagName){var f=this.getBlock();if(!1!==f||"LI"===f.tagName){var m=$.trim($(a).text()),g=$.trim($(f).text());if(""==m&&""==g&&0==$(f).next("li").length&&0==$(f).parents("li").length){this.bufferSet();var b=$(f).closest("ol, ul");$(f).remove();var v=$("<p>"+this.opts.invisibleSpace+"</p>");return b.after(v),this.selectionStart(v),this.sync(),this.callback("enter",t),!1}}}if(a&&this.opts.rBlockTest.test(a.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===a){this.bufferSet();var v=$("<p>"+this.opts.invisibleSpace+"</p>");return this.insertNode(v[0]),this.selectionStart(v),this.callback("enter",t),!1}}if(this.opts.linebreaks){if(!(a&&this.opts.rBlockTest.test(a.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"==a.tagName||"FIGCAPTION"==a.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,n,e);e===this.keyCode.BACKSPACE&&this.buildEventKeydownBackspace(t,r,o)},buildEventKeydownPre:function(t,e){t.preventDefault(),this.bufferSet();var s=$(e).parent().text();return this.insertNode(document.createTextNode("\n")),-1==s.search(/\s$/)&&this.insertNode(document.createTextNode("\n")),this.sync(),this.callback("enter",t),!1},buildEventKeydownTab:function(t,e,s){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("\xa0"))),this.sync()):t.shiftKey?this.indentingOutdent():this.indentingIndent():(this.bufferSet(),this.insertNode(document.createTextNode("	")),this.sync()),!1)},buildEventKeydownBackspace:function(t,e,s){if(s&&e&&"TD"==s.parentNode.tagName&&"UL"==s.tagName&&"LI"==e.tagName&&1==$(s).children("li").length){var o;if(""==$(e).text().replace(/[\u200B-\u200D\uFEFF]/g,"")){var o=s.parentNode;return $(s).remove(),this.selectionStart(o),this.sync(),!1}}void 0!==e.tagName&&/^(H[1-6])$/i.test(e.tagName)&&(o=!1===this.opts.linebreaks?$("<p>"+this.opts.invisibleSpace+"</p>"):$("<br>"+this.opts.invisibleSpace),$(e).replaceWith(o),this.selectionStart(o),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,s=this.getParent(),o=this.getCurrent();if(!this.opts.linebreaks&&3==o.nodeType&&(!1==s||"BODY"==s.tagName)){var r=$("<p>").append($(o).clone());$(o).replaceWith(r);var a=$(r).next();void 0!==a[0]&&"BR"==a[0].tagName&&a.remove(),this.selectionEnd(r)}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,s){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:"'"},r={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"};e=e.toLowerCase().split(" ");var a=o[t.keyCode],n=String.fromCharCode(t.which).toLowerCase(),l="",c={};$.each(["alt","ctrl","meta","shift"],function(e,s){t[s+"Key"]&&a!==s&&(l+=s+"+")}),a&&(c[l+a]=!0),n&&(c[l+n]=!0,c[l+r[n]]=!0,"shift+"===l&&(c[r[n]]=!0));for(var h=0,d=e.length;h<d;h++)if(c[e[h]])return t.preventDefault(),s.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 s=this.getRange();s.selectNodeContents(e),s.collapse(t||!1);var o=this.getSelection();o.removeAllRanges(),o.addRange(s)},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,""),s=t.replace(/\n/g,"");s=this.cleanRemoveSpaces(s,!1),this.modified=this.cleanRemoveSpaces(e,!1)!==s}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 s=this.$source.val();""!==s&&this.opts.tidyHtml&&this.$source.val(this.cleanHtml(s)),this.modified=s,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),s=e.get(0).selectionStart;return e.val(e.val().substring(0,s)+"	"+e.val().substring(e.get(0).selectionEnd)),e.get(0).selectionStart=e.get(0).selectionEnd=s+1,!1}},autosave:function(){var t=!1;this.autosaveInterval=setInterval($.proxy(function(){var e=this.get();if(t!==e){var s=this.$source.attr("name");$.ajax({url:this.opts.autosave,type:"post",data:"name="+s+"&"+s+"="+escape(encodeURIComponent(e)),success:$.proxy(function(s){var o=$.parseJSON(s);void 0===o.error?this.callback("autosave",!1,o):this.callback("autosaveError",!1,o),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 s=this.opts.buttons.indexOf(e);this.opts.buttons.splice(s,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 s=this.opts.toolbar[e];if(!1===this.opts.fileUpload&&"file"===e)return!0;this.$toolbar.append($("<li>").append(this.buttonBuild(e,s)))}},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=$(this.opts.toolbarFixedTarget).scrollTop(),e=0,s=0,o=0;if(o=(e=this.opts.toolbarFixedTarget===document?this.$box.offset().top:1)+this.$box.height()+40,t>e){var r="100%";this.opts.toolbarFixedBox&&(s=this.$box.offset().left,r=this.$box.innerWidth(),this.$toolbar.addClass("toolbar_fixed_box")),this.toolbarFixed=!0,this.opts.toolbarFixedTarget===document?this.$toolbar.css({position:"fixed",width:r,zIndex:10005,top:this.opts.toolbarFixedTopOffset+"px",left:s}):this.$toolbar.css({position:"absolute",width:r,zIndex:10005,top:this.opts.toolbarFixedTopOffset+t+"px",left:0}),t<o?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 s=$(this.getElement(this.getSelection().focusNode)),o=s.offset();o.height=s.height(),this.airShow(o,!0)}},this))},airShow:function(t,e){if(this.opts.air){if(this.selectionSave(),$(".redactor_air").hide(),e)s=t.left,o=t.top+t.height+14,this.opts.iframe&&(o+=this.$box.position().top-$(this.document).scrollTop(),s+=this.$box.position().left);else{var s,o,r=this.$air.innerWidth();s=t.clientX,$(this.document).width()<s+r&&(s-=r),o=t.clientY+14,this.opts.iframe?(o+=this.$box.position().top,s+=this.$box.position().left):o+=$(this.document).scrollTop()}this.$air.css({left:s+"px",top:o+"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,s){var o;s.className||(s.className=""),"separator"===s.name?o=$('<a class="redactor_separator_drop">'):(o=$('<a href="#" class="'+s.className+" redactor_dropdown_"+e+'">'+s.title+"</a>")).on("click",$.proxy(function(t){this.opts.air&&this.selectionRestore(),t.preventDefault&&t.preventDefault(),this.browser("msie")&&(t.returnValue=!1),s.callback&&s.callback.call(this,e,o,s,t),s.exec&&this.execCommand(s.exec,e),s.func&&this[s.func](e),this.buttonActiveObserver(),this.opts.air&&this.$air.fadeOut(100)},this)),t.append(o)},this))},dropdownShow:function(t,e){if(!this.opts.visual)return t.preventDefault(),!1;var s=this.buttonGet(e),o=s.data("dropdown").appendTo(document.body);if(s.hasClass("dropact"))this.dropdownHideAll();else{this.dropdownHideAll(),this.callback("dropdownShow",{dropdown:o,key:e,button:s}),this.buttonActive(e),s.addClass("dropact");var r=s.offset(),a=o.width();r.left+a>$(document).width()&&(r.left-=a);var n=r.left+"px",l=s.innerHeight(),c="absolute",h=l+this.opts.toolbarFixedTopOffset+"px";this.opts.toolbarFixed&&this.toolbarFixed?c="fixed":h=r.top+l+"px",o.css({position:c,left:n,top:h}).show(),this.callback("dropdownShown",{dropdown:o,key:e,button:s})}var d=$.proxy(function(t){this.dropdownHide(t,o)},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,s){var o=$('<a href="javascript:;" title="'+e.title+'" tabindex="-1" class="re-icon re-'+t+'"></a>');if(void 0!==s&&o.addClass("redactor-btn-image"),o.on("click",$.proxy(function(s){if(s.preventDefault&&s.preventDefault(),this.browser("msie")&&(s.returnValue=!1),o.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,o,e,s),this.airBindMousemoveHide()):e.dropdown&&this.dropdownShow(s,t),this.buttonActiveObserver(!1,t)},this)),e.dropdown){var r=$('<div class="redactor_dropdown redactor_dropdown_box_'+t+'" style="display: none;">');o.data("dropdown",r),this.dropdownBuild(r,e.dropdown)}return o},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 s=this.buttonGet(t);s.removeClass("redactor-btn-image"),s.addClass("fa-redactor-btn"),s.html('<i class="fa '+e+'"></i>')},buttonAdd:function(t,e,s,o){if(this.opts.toolbar){var r=this.buttonBuild(t,{title:e,callback:s,dropdown:o},!0);return this.$toolbar.append($("<li>").append(r)),r}},buttonAddFirst:function(t,e,s,o){if(this.opts.toolbar){var r=this.buttonBuild(t,{title:e,callback:s,dropdown:o},!0);this.$toolbar.prepend($("<li>").append(r))}},buttonAddAfter:function(t,e,s,o,r){if(this.opts.toolbar){var a=this.buttonBuild(e,{title:s,callback:o,dropdown:r},!0),n=this.buttonGet(t);return 0!==n.length?n.parent().after($("<li>").append(a)):this.$toolbar.append($("<li>").append(a)),a}},buttonAddBefore:function(t,e,s,o,r){if(this.opts.toolbar){var a=this.buttonBuild(e,{title:s,callback:o,dropdown:r},!0),n=this.buttonGet(t);return 0!==n.length?n.parent().before($("<li>").append(a)):this.$toolbar.append($("<li>").append(a)),a}},buttonRemove:function(t){this.buttonGet(t).remove()},buttonActiveObserver:function(t,e){var s=this.getParent();if(this.buttonInactiveAll(e),!1===t&&"html"!==e){-1!=$.inArray(e,this.opts.activeButtons)&&this.buttonActiveToggle(e);return}s&&"A"===s.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!=$(s).closest(t,this.$editor.get()[0]).length&&this.buttonActive(e)},this));var o=$(s).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);if(o.length){var r=o.css("text-align");""==r&&(r="left"),this.buttonActive("align"+r)}},execPasteFrag:function(t){var e=this.getSelection();if(e.getRangeAt&&e.rangeCount){var s=this.getRange();s.deleteContents();var o=this.document.createElement("div");o.innerHTML=t;for(var r,a,n=this.document.createDocumentFragment();r=o.firstChild;)a=n.appendChild(r);n.firstChild,s.insertNode(n),a&&((s=s.cloneRange()).setStartAfter(a),s.collapse(!0)),e.removeAllRanges(),e.addRange(s)}},exec:function(t,e,s){"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!==s&&this.sync(),this.callback("execCommand",t,e)},execCommand:function(t,e,s){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 o=this.getParent();("SUP"===o.tagName||"SUB"===o.tagName)&&this.inlineRemoveFormatReplace(o)}if("inserthtml"===t){this.insertHtml(e,s),this.callback("execCommand",t,e);return}return(!this.currentOrParentIs("CODE")||!!this.opts.formattingPre)&&("insertunorderedlist"===t||"insertorderedlist"===t?this.execLists(t,e):"unlink"===t?this.execUnlink(t,e):void(this.exec(t,e,s),"inserthorizontalrule"===t&&this.$editor.find("hr").removeAttr("id")))},execUnlink:function(t,e){this.bufferSet();var s=this.currentOrParentIs("A");if(s){$(s).replaceWith($(s).text()),this.sync(),this.callback("execCommand",t,e);return}},execLists:function(t,e){this.bufferSet();var s=this.getParent(),o=$(s).closest("ol, ul");this.isParentRedactor(o)||0==o.length||(o=!1);var r=!1;if(o&&o.length){r=!0;var a=o[0].tagName;("insertunorderedlist"===t&&"OL"===a||"insertorderedlist"===t&&"UL"===a)&&(r=!1)}if(this.selectionSave(),r){var n=this.getNodes(),l=this.getBlocks(n);void 0!==n[0]&&n.length>1&&3==n[0].nodeType&&l.unshift(this.getBlock());var c="",h="";$.each(l,$.proxy(function(t,e){if("LI"==e.tagName){var s=$(e),o=s.clone();(o.find("ul","ol").remove(),!1===this.opts.linebreaks)?c+=this.outerHtml($("<p>").append(o.contents())):c+=o.html().replace(/<br\s?\/?>$/i,"")+"<br>",0==t?(s.addClass("redactor-replaced").empty(),h=this.outerHtml(s)):s.remove()}},this)),html=this.$editor.html().replace(h,"</"+a+">"+c+"<"+a+">"),this.$editor.html(html),this.$editor.find(a+":empty").remove()}else{var d=$(this.getParent()).closest("td");if(this.browser("msie")&&!this.isIe11()&&this.opts.linebreaks){var p=this.selectionWrap("div"),u=$(p).html(),f=$("<ul>");"insertorderedlist"==t&&(f=$("<ol>"));var m=$("<li>");""==$.trim(u)?(m.append(u+'<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),f.append(m),this.$editor.find("#selection-marker-1").replaceWith(f)):(m.append(u),f.append(m),$(p).replaceWith(f))}else this.document.execCommand(t);var s=this.getParent(),o=$(s).closest("ol, ul");if(!1===this.opts.linebreaks&&""==$.trim(o.text())&&(o.children("li").find("br").remove(),o.children("li").append('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>")),0!=d.length&&o.wrapAll("<td>"),o.length){var g=o.parent();this.isParentRedactor(g)&&"LI"!=g[0].tagName&&this.nodeTestBlocks(g[0])&&g.replaceWith(g.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 s=$(this.getParent()).closest("ol, ul")[0].tagName,o=this.getBlocks();$.each(o,function(t,e){if("LI"==e.tagName){var o=$(e).prev();if(0!=o.length&&"LI"==o[0].tagName){var r=o.children("ul, ol");0==r.length?o.append($("<"+s+">").append(e)):r.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 s=!1;if("TD"!==e.tagName){s=-1!==$.inArray(e.tagName,this.opts.alignmentTags)?$(e):$(e).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);var o=this.normalize(s.css("margin-left"))+this.opts.indentValue;s.css("margin-left",o+"px")}},this))}this.selectionRestore()}else{this.selectionSave();var e=this.getBlock();if(e&&"LI"==e.tagName){var o=this.getBlocks(),l=0;this.insideOutdent(e,l,o)}else{var n=this.getBlocks();$.each(n,$.proxy(function(t,e){var s=!1;s=-1!==$.inArray(e.tagName,this.opts.alignmentTags)?$(e):$(e).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);var o=this.normalize(s.css("margin-left"))-this.opts.indentValue;o<=0?!0===this.opts.linebreaks&&void 0!==s.data("tagblock")?s.replaceWith(s.html()+"<br>"):(s.css("margin-left",""),this.removeEmptyAttr(s,"style")):s.css("margin-left",o+"px")},this))}this.selectionRestore()}this.sync()},insideOutdent:function(t,e,s){if(t&&"LI"==t.tagName){var o=$(t).parent().parent();0!=o.length&&"LI"==o[0].tagName?o.after(t):void 0!==s[e]?(t=s[e],e++,this.insideOutdent(t,e,s)):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;this.selectionSave();var s=this.getBlock();if(!s&&this.opts.linebreaks){this.exec("formatblock","div");var o=this.getBlock(),s=$('<div data-tagblock="">').html($(o).html());$(o).replaceWith(s),$(s).css("text-align",t),this.removeEmptyAttr(s,"style"),""==t&&void 0!==$(s).data("tagblock")&&$(s).replaceWith($(s).html())}else{var r=this.getBlocks();$.each(r,$.proxy(function(e,s){var o=!1;(o=-1!==$.inArray(s.tagName,this.opts.alignmentTags)?$(s):$(s).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]))&&(o.css("text-align",t),this.removeEmptyAttr(o,"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,"<!-- template double $1 -->")).replace(/\{(.*?)\}/gi,"<!-- template $1 -->")),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){var e=[],s=t.match(/<(code|style|script|title)(.*?)>([\w\W]*?)<\/(code|style|script|title)>/gi);if(null===s&&(s=[]),this.opts.phpTags){var o=t.match(/<\?php([\w\W]*?)\?>/gi);o&&(s=$.merge(s,o))}s&&$.each(s,function(s,o){t=t.replace(o,"buffer_"+s),e.push(o)})}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,s){t=t.replace("buffer_"+e,s)}),t},cleanRemoveEmptyTags:function(t){t=t.replace(/[\u200B-\u200D\uFEFF]/g,"");for(var e=["<b>\\s*</b>","<b>&nbsp;</b>","<em>\\s*</em>"],s=["<code></code>","<blockquote>\\s*</blockquote>","<dd></dd>","<dt></dt>","<ul></ul>","<ol></ol>","<li></li>","<table></table>","<tr></tr>","<span>\\s*<span>","<span>&nbsp;<span>","<p>\\s*</p>","<p></p>","<p>&nbsp;</p>","<p>\\s*<br>\\s*</p>","<div>\\s*</div>","<div>\\s*<br>\\s*</div>"],o=(s=this.opts.removeEmptyTags?s.concat(e):e).length,r=0;r<o;++r)t=t.replace(RegExp(s[r],"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=[],s=t.match(/<(table|div|code|object)(.*?)>([\w\W]*?)<\/(table|div|code|object)>/gi);s||(s=[]);var o=t.match(/<!--([\w\W]*?)-->/gi);if(o&&(s=$.merge(s,o)),this.opts.phpTags){var r=t.match(/<section(.*?)rel="redactor-php-tag">([\w\W]*?)<\/section>/gi);r&&(s=$.merge(s,r))}function a(e,s,o){return t.replace(RegExp(e,s),o)}s&&$.each(s,function(s,o){e[s]=o,t=t.replace(o,"{replace"+s+"}\n")}),t=(t=t.replace(/<br \/>\s*<br \/>/gi,"\n\n")).replace(/<br><br>/gi,"\n\n");var n="(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=a("(<"+n+"[^>]*>)","gi","\n$1"),t=a("(</"+n+">)","gi","$1\n\n"),t=a("\r\n","g","\n"),t=a("\r","g","\n");var l=(t=a("/\n\n+/","g","\n\n")).split(RegExp("\ns*\n","g"),-1);for(var c in t="",l)l.hasOwnProperty(c)&&(-1==l[c].search("{replace")?(l[c]=l[c].replace(/<p>\n\t?<\/p>/gi,""),l[c]=l[c].replace(/<p><\/p>/gi,""),""!=l[c]&&(t+="<p>"+l[c].replace(/^\n+|\n+$/g,"")+"</p>")):t+=l[c]);return t=a("<p><p>","gi","<p>"),t=a("</p></p>","gi","</p>"),t=a("<p>s?</p>","gi",""),t=a("<p>([^<]+)</(div|address|form)>","gi","<p>$1</p></$2>"),t=a("<p>(</?"+n+"[^>]*>)</p>","gi","$1"),t=a("<p>(<li.+?)</p>","gi","$1"),t=a("<p>s?(</?"+n+"[^>]*>)","gi","$1"),t=a("(</?"+n+"[^>]*>)s?</p>","gi","$1"),t=a("(</?"+n+"[^>]*>)s?<br />","gi","$1"),t=a("<br />(s*</?(?:p|li|div|dl|dd|dt|th|code|td|ul|ol)[^>]*>)","gi","$1"),t=a("\n</p>","gi","</p>"),t=a("<li><p>","gi","<li>"),t=a("</p></li>","gi","</li>"),t=a("</li><p>","gi","</li>"),t=a("<p>	?\n?<p>","gi","<p>"),t=a("</dt><p>","gi","</dt>"),t=a("</dd><p>","gi","</dd>"),t=a("<br></p></blockquote>","gi","</blockquote>"),t=a("<p>	*</p>","gi",""),$.each(e,function(e,s){t=t.replace("{replace"+e+"}",s)}),$.trim(t)},cleanConvertInlineTags:function(t,e){var s="strong";"b"===this.opts.boldTag&&(s="b");var o="em";return"i"===this.opts.italicTag&&(o="i"),t=(t=t.replace(/<span style="font-style: italic;">([\w\W]*?)<\/span>/gi,"<"+o+">$1</"+o+">")).replace(/<span style="font-weight: bold;">([\w\W]*?)<\/span>/gi,"<"+s+">$1</"+s+">"),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 s=!0===e?this.opts.allowedTags:this.opts.deniedTags,o=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;return t=t.replace(o,function(t,o){return!0===e?$.inArray(o.toLowerCase(),s)>"-1"?t:"":$.inArray(o.toLowerCase(),s)>"-1"?"":t}),t=this.cleanConvertInlineTags(t)},cleanSavePreCode:function(t,e){var s=t.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/gi);return null!==s&&$.each(s,$.proxy(function(s,o){var r=o.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/i);r[3]=r[3].replace(/&nbsp;/g," "),!1!==e&&(r[3]=this.cleanEncodeEntities(r[3])),r[3]=r[3].replace(/\$/g,"&#36;"),t=t.replace(o,"<"+r[1]+r[2]+">"+r[3]+"</"+r[1]+">")},this)),t},cleanEncodeEntities:function(t){return(t=String(t).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"')).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},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,s=0,o=t.length,r=0,a=null,n=null,l="",c="",h="";for(this.cleanlevel=0;s<o;s++){if(r=s,-1==t.substr(s).indexOf("<")){c+=t.substr(s);break}for(;r<o&&"<"!=t.charAt(r);)r++;for(s!=r&&((h=t.substr(s,r-s)).match(/^\s{2,}$/g)||("\n"==c.charAt(c.length-1)?c+=this.cleanGetTabs():"\n"==h.charAt(0)&&(c+="\n"+this.cleanGetTabs(),h=h.replace(/^\s+/,"")),c+=h),h.match(/\n/)&&(c+="\n"+this.cleanGetTabs())),a=r;r<o&&">"!=t.charAt(r);)r++;if(l=t.substr(a,r-a),s=r,"!--"==l.substr(1,3)){if(!l.match(/--$/)){for(;"-->"!=t.substr(r,3);)r++;r+=2,l=t.substr(a,r-a),s=r}"\n"!=c.charAt(c.length-1)&&(c+="\n"),c+=this.cleanGetTabs(),c+=l+">\n"}else"!"==l[1]?c=this.placeTag(l+">",c):"?"==l[1]?c+=l+">\n":(e=l.match(/^<(script|style|pre|code)/i))?(e[1]=e[1].toLowerCase(),l=this.cleanTag(l),c=this.placeTag(l,c),(n=String(t.substr(s+1)).toLowerCase().indexOf("</"+e[1]))&&(h=t.substr(s+1,n),s+=n,c+=h)):(l=this.cleanTag(l),c=this.placeTag(l,c))}return this.cleanFinish(c)},cleanGetTabs:function(){for(var t="",e=0;e<this.cleanlevel;e++)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,s="";t=(t=(t=t.replace(/\n/g," ")).replace(/\s{2,}/g," ")).replace(/^\s+|\s+$/g," ");var o="";for(t.match(/\/$/)&&(o="/",t=t.replace(/\/+$/,""));e=/\s*([^= ]+)(?:=((['"']).*?\3|[^ ]+))?/.exec(t);)e[2]?s+=e[1].toLowerCase()+"="+e[2]:e[1]&&(s+=e[1].toLowerCase()),s+=" ",t=t.substr(e[0].length);return s.replace(/\s*$/,"")+o+">"},placeTag:function(t,e){var s=t.match(this.cleannewLevel);return(t.match(this.cleanlineBefore)||s)&&(e=e.replace(/\s*$/,""),e+="\n"),s&&"/"==t.charAt(1)&&this.cleanlevel--,"\n"==e.charAt(e.length-1)&&(e+=this.cleanGetTabs()),s&&"/"!=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 s=(e=e.replace(/<br\s?\/?>/i,"")).replace(/<p>\s?<\/p>/gi,"");if(""===e||""===s){t.preventDefault();var o=$(this.opts.emptyHtml).get(0);this.$editor.html(o),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,s){if("LI"!==s.tagName){var o=$(s).parent();if("p"===t){if("P"===s.tagName&&0!=o.length&&"BLOCKQUOTE"===o[0].tagName||"BLOCKQUOTE"===s.tagName){this.formatQuote();return}if(this.opts.linebreaks){if(!s||0!=s.tagName.search(/H[1-6]/))return;$(s).replaceWith(s.innerHTML+"<br>")}else this.formatBlock(t,s)}else this.formatBlock(t,s)}},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 s="";if("code"!==t?s=$(e).contents():(s=$(e).html(),""===$.trim(s)&&(s='<span id="selection-marker-1"></span>')),"CODE"===e.tagName&&(t="p"),!0===this.opts.linebreaks&&"p"===t)$(e).replaceWith($("<div>").append(s).html()+"<br>");else{var o=this.getParent(),r=$("<"+t+">").append(s);$(e).replaceWith(r),o&&"TD"==o.tagName&&$(r).wrapAll("<td>")}},formatChangeTag:function(t,e,s){!1!==s&&this.selectionSave();var o=$("<"+e+"/>");return $(t).replaceWith(function(){return o.append($(this).contents())}),!1!==s&&this.selectionRestore(),o},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,s=t.length;if(t){var o="",r="",a=!1,n=!0;if($.each(t,function(t,e){"P"!==e.tagName&&(n=!1)}),$.each(t,$.proxy(function(l,c){if("BLOCKQUOTE"===c.tagName)this.formatBlock("p",c,!1);else if("P"===c.tagName){if("BLOCKQUOTE"==(e=$(c).parent())[0].tagName){var h=$(e).children("p").length;1==h?$(e).replaceWith(c):h==s?(a="blockquote",o+=this.outerHtml(c)):(a="html",o+=this.outerHtml(c),0==l?($(c).addClass("redactor-replaced").empty(),r=this.outerHtml(c)):$(c).remove())}else!1===n||1==t.length?this.formatBlock("blockquote",c,!1):(a="paragraphs",o+=this.outerHtml(c))}else"LI"!==c.tagName&&this.formatBlock("blockquote",c,!1)},this)),a){if("paragraphs"==a)$(t[0]).replaceWith("<blockquote>"+o+"</blockquote>"),$(t).remove();else if("blockquote"==a)$(e).replaceWith(o);else if("html"==a){var l=this.$editor.html().replace(r,"</blockquote>"+o+"<blockquote>");this.$editor.html(l),this.$editor.find("blockquote").each(function(){""==$.trim($(this).html())&&$(this).remove()})}}}this.selectionRestore()}else{var c=this.getBlock();if("BLOCKQUOTE"===c.tagName){this.selectionSave();var l=$.trim($(c).html()),h=$.trim(this.getSelectionHtml());if((l=l.replace(/<span(.*?)id="selection-marker(.*?)<\/span>/gi,""))==h)$(c).replaceWith($(c).html()+"<br>");else{this.inlineFormat("tmp");var d=this.$editor.find("tmp");d.empty();var p=this.$editor.html().replace("<tmp></tmp>",'</blockquote><span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"+h+"<blockquote>");this.$editor.html(p),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 u=this.selectionWrap("blockquote"),l=$(u).html(),f=["ul","ol","table","tr","tbody","thead","tfoot","dl"];$.each(f,function(t,e){l=(l=l.replace(RegExp("<"+e+"(.*?)>","gi"),"")).replace(RegExp("</"+e+">","gi"),"")});var m=this.opts.blockLevelElements;$.each(m,function(t,e){l=(l=l.replace(RegExp("<"+e+"(.*?)>","gi"),"")).replace(RegExp("</"+e+">","gi"),"<br>")}),$(u).html(l),this.selectionElement(u);var g=$(u).next();0!=g.length&&"BR"===g[0].tagName&&g.remove()}}this.sync()},blockRemoveAttr:function(t,e){$(this.getBlocks()).removeAttr(t),this.sync()},blockSetAttr:function(t,e){$(this.getBlocks()).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){$(this.getBlocks()).css(t,e),this.sync()},blockRemoveClass:function(t){var e=this.getBlocks();$(e).removeClass(t),this.removeEmptyAttr(e,"class"),this.sync()},blockSetClass:function(t){$(this.getBlocks()).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){$(this.getCurrent()).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(),s=this.getElement(),o=this.getNodes();(e.collapsed||e.startContainer===e.endContainer&&s)&&(o=$(s)),$(o).removeAttr(t),this.inlineUnwrapSpan(),this.selectionRestore(),this.sync()},inlineSetAttr:function(t,e){this.inlineMethods("attr",t,e)},inlineMethods:function(t,e,s){this.bufferSet(),this.selectionSave();var o=this.getRange(),r=this.getElement();if((o.collapsed||o.startContainer===o.endContainer)&&r&&!this.nodeTestBlocks(r))$(r)[t](e,s);else{var a,n=s;switch(e){case"font-size":a="fontSize",n=4;break;case"font-family":a="fontName";break;case"color":a="foreColor";break;case"background-color":a="backColor"}this.document.execCommand(a,!1,n);var l=this.$editor.find("font");$.each(l,$.proxy(function(o,r){this.inlineSetMethods(t,r,e,s)},this))}this.selectionRestore(),this.sync()},inlineSetMethods:function(t,e,s,o){var r,a=$(e).parent(),n=this.getSelectionText(),l=$(a).text();return n==l&&a&&"INLINE"===a[0].tagName&&0!=a[0].attributes.length?(r=a,$(e).replaceWith($(e).html())):(r=$("<inline>").append($(e).contents()),$(e).replaceWith(r)),$(r)[t](s,o),r},inlineEachNodes:function(t){var e,s=this.getRange(),o=this.getElement(),r=this.getNodes();(s.collapsed||s.startContainer===s.endContainer&&o)&&(r=$(o),e=!0),$.each(r,$.proxy(function(s,o){if(!e&&"INLINE"!==o.tagName){var r=this.getSelectionText(),a=$(o).parent().text();if(r!=a||"INLINE"!==o.parentNode.tagName||$(o.parentNode).hasClass("redactor_editor"))return;o=o.parentNode}t.call(this,o)},this))},inlineUnwrapSpan:function(){var t=this.$editor.find("inline");$.each(t,$.proxy(function(t,e){var s=$(e);void 0===s.attr("class")&&void 0===s.attr("style")&&s.contents().unwrap()},this))},inlineFormat:function(t){this.selectionSave(),this.document.execCommand("fontSize",!1,4);var e,s=this.$editor.find("font");$.each(s,function(s,o){var r=$("<"+t+"/>").append($(o).contents());$(o).replaceWith(r),e=r}),this.selectionRestore(),this.sync()},inlineRemoveFormat:function(t){this.selectionSave();var e=t.toUpperCase(),s=this.getNodes(),o=$(this.getParent()).parent();$.each(s,function(t,s){s.tagName===e&&this.inlineRemoveFormatReplace(s)}),o&&o[0].tagName===e&&this.inlineRemoveFormatReplace(o),this.selectionRestore(),this.sync()},inlineRemoveFormatReplace:function(t){$(t).replaceWith($(t).contents())},insertHtml:function(t,e){var s=this.getCurrent(),o=s.parentNode;this.focusWithSaveScroll(),this.bufferSet();var r=$("<div>").append($.parseHTML(t));t=r.html(),t=this.cleanRemoveEmptyTags(t),r=$("<div>").append($.parseHTML(t));var a=this.getBlock();if(1==r.contents().length){var n=r.contents()[0].tagName;("P"!=n&&n==a.tagName||"CODE"==n)&&(r=$("<div>").append(t))}this.opts.linebreaks&&(t=t.replace(/<p(.*?)>([\w\W]*?)<\/p>/gi,"$2<br>")),this.opts.linebreaks||1!=r.contents().length||3!=r.contents()[0].nodeType||!(this.getRangeSelectedNodes().length>2)&&s&&("BODY"!=s.tagName||o)&&"HTML"!=o.tagName||(t="<p>"+t+"</p>"),t=this.setSpansVerifiedHtml(t),r.contents().length>1&&a||r.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 s=this.getSelection();if(s.getRangeAt&&s.rangeCount){var o=s.getRangeAt(0);o.deleteContents();var r=document.createElement("div");r.innerHTML=t;for(var a,n,l=document.createDocumentFragment();a=r.firstChild;)n=l.appendChild(a);o.insertNode(l),n&&((o=o.cloneRange()).setStartAfter(n),o.collapse(!0),s.removeAllRanges(),s.addRange(o))}!1!==e&&this.sync()},insertBeforeCursor:function(t){t=this.setSpansVerifiedHtml(t);var e=$(t),s=document.createElement("span");s.innerHTML="​";var o=this.getRange();o.insertNode(s),o.insertNode(e[0]),o.collapse(!1);var r=this.getSelection();r.removeAllRanges(),r.addRange(o),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",s=t.outerHTML,o=RegExp("<"+t.tagName,"i"),r=s.replace(o,"<"+e);o=RegExp("</"+t.tagName,"i"),r=r.replace(o,"</"+e),t=$(r)[0]}var a=this.getSelection();return a.getRangeAt&&a.rangeCount&&((range=a.getRangeAt(0)).deleteContents(),range.insertNode(t),range.setEndAfter(t),range.setStartAfter(t),a.removeAllRanges(),a.addRange(range)),t},insertNodeToCaretPositionFromPoint:function(t,e){var s,o=t.clientX,r=t.clientY;if(this.document.caretPositionFromPoint){var a=this.document.caretPositionFromPoint(o,r);(s=this.getRange()).setStart(a.offsetNode,a.offset),s.collapse(!0),s.insertNode(e)}else if(this.document.caretRangeFromPoint)(s=this.document.caretRangeFromPoint(o,r)).insertNode(e);else if(void 0!==document.body.createTextRange){(s=this.document.body.createTextRange()).moveToPoint(o,r);var n=s.duplicate();n.moveToPoint(o,r),s.setEndPoint("EndToEnd",n),s.select()}},insertAfterLastElement:function(t,e){if(void 0!==e&&(t=e),this.isEndOfElement()){if(this.opts.linebreaks){var s=$("<div>").append($.trim(this.$editor.html())).contents(),o=s.last()[0];if("SPAN"==o.tagName&&""==o.innerHTML&&(o=s.prev()[0]),this.outerHtml(o)!=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{var 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(!0==t&&(e="<br><br>"),this.browser("mozilla")){var s=$("<span>").html(this.opts.invisibleSpace);this.$editor.find("#selection-marker-1").before(e).before(s).before(this.opts.invisibleSpace),this.setCaretAfter(s[0]),s.remove(),this.selectionRemoveMarkers()}else{var o=this.getParent();if(o&&"A"===o.tagName){var r=this.getCaretOffset(o),a=$.trim($(o).text()).replace(/\n\r\n/g,"").length;if(r==a){this.selectionRemoveMarkers();var n=$('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>",this.document)[0];return $(o).after(n),$(n).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){if(t=this.callback("pasteBefore",!1,t),this.browser("msie")){var e=$.trim(t);0==e.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 s=!1;if(this.currentOrParentIs("TD")){s=!0;var o=this.opts.blockLevelElements;o.push("tr"),o.push("table"),$.each(o,function(e,s){t=(t=t.replace(RegExp("<"+s+"(.*?)>","gi"),"")).replace(RegExp("</"+s+">","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(/(&nbsp;){2,}/gi,"&nbsp;")).replace(/&nbsp;/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>&nbsp;<\/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*|&nbsp;|<br>)<\/[^>]+>/gi,"<br>")):t=t.replace(/<[^\/>][^>]*>(\s*|\t*|\n*|&nbsp;|<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>&nbsp;</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===s&&(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 r=t.match(/<img src="data:image(.*?)"(.*?)>/gi);if(null!==r)for(var a in this.pasteClipboardMozilla=r,r){var n=r[a].replace("<img",'<img data-mozilla-paste-image="'+a+'" ');t=t.replace(r[a],n)}}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===s&&(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,s){null!=s&&0===s.toString().indexOf("#")&&(s=$(s).val()),t[e]=s},this)),t},pasteClipboardUploadMozilla:function(){var t=this.$editor.find("img[data-mozilla-paste-image]");$.each(t,$.proxy(function(t,e){var s=$(e),o=e.src.split(","),r={contentType:o[0].split(";")[0].split(":")[1],data:o[1]};r=this.pasteClipboardAppendFields(r),$.post(this.opts.clipboardUploadUrl,r,$.proxy(function(t){var e="string"==typeof t?$.parseJSON(t):t;s.attr("src",e.image.url),s.removeAttr("data-mozilla-paste-image"),this.sync(),this.callback("imageUpload",s,e)},this))},this))},pasteClipboardUpload:function(t){var e=t.target.result,s=e.split(","),o={contentType:s[0].split(";")[0].split(":")[1],data:s[1]};this.opts.clipboardUpload?(o=this.pasteClipboardAppendFields(o),$.post(this.opts.clipboardUploadUrl,o,$.proxy(function(t){var e="string"==typeof t?$.parseJSON(t):t,s='<img src="'+e.image.url+'" id="clipboard-image-marker" />';this.execCommand("inserthtml",s,!1);var o=$(this.$editor.find("img#clipboard-image-marker"));o.length?o.removeAttr("id"):o=!1,this.sync(),o&&this.callback("imageUpload",o,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(){if(0===this.opts.buffer.length){this.focusWithSaveScroll();return}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)},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 s=$(e).parent();s.hasClass("royalSlider")||s.hasClass("fotorama")||this.imageResize(e)},this)),this.$editor.find(".fotorama, .royalSlider").on("click",$.proxy(this.editGallery,this))},linkObserver:function(t){var e=$(t.target),s=$(t.target).parent();if(!(s.hasClass("royalSlider")||s.hasClass("fotorama"))&&0!=e.length&&"A"===e[0].tagName){var o=e.offset();if(this.opts.iframe){var r=this.$frame.offset();o.top=r.top+(o.top-$(this.document).scrollTop()),o.left+=r.left}var a=$('<span class="redactor-link-tooltip"></span>'),n=e.attr("href");void 0===n&&(n=""),n.length>24&&(n=n.substring(0,24)+"...");var l=$('<a href="'+e.attr("href")+'" target="_blank">'+n+"</a>").on("click",$.proxy(function(t){this.linkObserverTooltipClose(!1)},this)),c=$('<a href="#">'+this.opts.curLang.edit+"</a>").on("click",$.proxy(function(t){t.preventDefault(),this.linkShow(),this.linkObserverTooltipClose(!1)},this)),h=$('<a href="#">'+this.opts.curLang.unlink+"</a>").on("click",$.proxy(function(t){t.preventDefault(),this.execCommand("unlink"),this.linkObserverTooltipClose(!1)},this));a.append(l),a.append(" | "),a.append(c),a.append(" | "),a.append(h),a.css({top:o.top+20+"px",left:o.left+"px"}),$(".redactor-link-tooltip").remove(),$("body").append(a)}},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,s,o){null==s&&(s=t),null==o&&(o=e);var r=this.getSelection();if(r){if("P"==t.tagName&&""==t.innerHTML&&(t.innerHTML=this.opts.invisibleSpace),"BR"==t.tagName&&!1===this.opts.linebreaks){var a=$(this.opts.emptyHtml)[0];$(t).replaceWith(a),s=t=a}var n=this.getRange();n.setStart(t,e),n.setEnd(s,o);try{r.removeAllRanges()}catch(l){}r.addRange(n)}},selectionWrap:function(t){t=t.toLowerCase();var e=this.getBlock();if(e){var s=this.formatChangeTag(e,t);return this.sync(),s}var o=this.getSelection().getRangeAt(0),s=document.createElement(t);return s.appendChild(o.extractContents()),o.insertNode(s),this.selectionElement(s),s},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=0,s=this.getRange(),o=s.cloneRange();return o.selectNodeContents(t),o.setEnd(s.endContainer,s.endOffset),e=$.trim(o.toString()).length},getCaretOffsetRange:function(){return new Range(this.getSelection().getRangeAt(0))},setCaret:function(t,e,s){void 0===s&&(s=e),t=t[0]||t;var o=this.getRange();o.selectNodeContents(t);var r,a=this.getTextNodesIn(t),n=!1,l=0;if(1==a.length&&e)o.setStart(a[0],e),o.setEnd(a[0],s);else for(var c,h=0;c=a[h++];){if(r=l+c.length,!n&&e>=l&&(e<r||e==r&&h<a.length)&&(o.setStart(c,e-l),n=!0),n&&s<=r){o.setEnd(c,s-l);break}l=r}var d=this.getSelection();d.removeAllRanges(),d.addRange(o)},setCaretAfter:function(t){this.$editor.focus(),t=t[0]||t;var e=this.document.createRange(),s=1,o=-1;e.setStart(t,s),e.setEnd(t,o+2);var r=this.window.getSelection(),a=this.document.createRange(),n=this.document.createTextNode("​");$(t).after(n),a.setStartAfter(n),r.removeAllRanges(),r.addRange(a),$(n).remove()},getTextNodesIn:function(t){var e=[];if(3==t.nodeType)e.push(t);else for(var s=t.childNodes,o=0,r=s.length;o<r;++o)e.push.apply(e,this.getTextNodesIn(s[o]));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)){if($(t).hasClass("redactor_editor"))return!1;return t}t=t.parentNode}return!1},getBlocks:function(t){var e=[];if(void 0===t){var s=this.getRange();if(s&&!0===s.collapsed)return[this.getBlock()];var t=this.getNodes(s)}return $.each(t,$.proxy(function(t,s){if(!1===this.opts.iframe&&0==$(s).parents("div.redactor_editor").length)return!1;this.nodeTestBlocks(s)&&e.push(s)},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||!1==t)var t=this.getRange();if(t&&!0===t.collapsed){if(!(void 0===e&&this.tagTestBlock(e)))return[this.getCurrent()];var s=this.getBlock();return s.tagName==e?[s]:[]}var o=[],r=[],a=this.document.getSelection();if(a.isCollapsed||(o=this.getRangeSelectedNodes(a.getRangeAt(0))),$.each(o,$.proxy(function(t,s){if(!1===this.opts.iframe&&0==$(s).parents("div.redactor_editor").length)return!1;void 0===e?""!=$.trim(s.textContent)&&r.push(s):s.tagName==e&&r.push(s)},this)),0==r.length){if(void 0===e&&this.tagTestBlock(e)){var s=this.getBlock();return s.tagName==e?r.push(s):[]}r.push(this.getCurrent())}var n=r[r.length-1];return this.nodeTestBlocks(n)&&(r=r.slice(0,-1)),r},getElement:function(t){for(t||(t=this.getCurrent());t;){if(1==t.nodeType){if($(t).hasClass("redactor_editor"))return!1;return t}t=t.parentNode}return!1},getRangeSelectedNodes:function(t){var e=(t=t||this.getRange()).startContainer,s=t.endContainer;if(e==s)return[e];for(var o=[];e&&e!=s;)o.push(e=this.nextNode(e));for(e=t.startContainer;e&&e!=t.commonAncestorContainer;)o.unshift(e),e=e.parentNode;return o},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 s=this.document.createElement("div"),o=e.rangeCount,r=0;r<o;++r)s.appendChild(e.getRangeAt(r).cloneContents());t=s.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 s=$('<span id="selection-marker-1" class="redactor-selection-marker">'+this.opts.invisibleSpace+"</span>",this.document)[0],o=$('<span id="selection-marker-2" class="redactor-selection-marker">'+this.opts.invisibleSpace+"</span>",this.document)[0];!0===t.collapsed?this.selectionSetMarker(t,s,!0):(this.selectionSetMarker(t,s,!0),this.selectionSetMarker(t,o,!1)),this.savedSel=this.$editor.html(),this.selectionRestore(!1,!1)}},selectionSetMarker:function(t,e,s){var o=t.cloneRange();try{o.collapse(s),o.insertNode(e),o.detach()}catch(r){var a=this.opts.emptyHtml;this.opts.linebreaks&&(a="<br>"),this.$editor.prepend(a),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 s=this.$editor.find("span#selection-marker-1"),o=this.$editor.find("span#selection-marker-2");this.browser("mozilla")?this.$editor.focus():this.isFocused()||this.focusWithSaveScroll(),0!=s.length&&0!=o.length?this.selectionSet(s[0],0,o[0],0):0!=s.length&&this.selectionSet(s[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,s,o,r=$("#redactor_table_rows").val(),a=$("#redactor_table_columns").val(),n=$("<div></div>"),l=Math.floor(99999*Math.random()),c=$('<table id="table'+l+'"><tbody></tbody></table>');for(t=0;t<r;t++){for(s=0,e=$("<tr></tr>");s<a;s++)o=$("<td>"+this.opts.invisibleSpace+"</td>"),0===t&&0===s&&o.append('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),$(e).append(o);c.append(e)}n.append(c);var h=n.html();!1===this.opts.linebreaks&&this.browser("mozilla")&&(h+="<p>"+this.opts.invisibleSpace+"</p>"),this.modalClose(),this.selectionRestore();var d=this.getBlock()||this.getCurrent();if(d&&"BODY"!=d.tagName){if("LI"==d.tagName)var d=$(d).closest("ul, ol");$(d).after(h)}else this.insertHtmlAdvanced(h,!1);this.selectionRestore();var p=this.$editor.find("#table"+l);this.buttonActiveObserver(),p.find("span#selection-marker-1, inline#selection-marker-1").remove(),p.removeAttr("id"),this.sync()},tableDeleteTable:function(){var t=$(this.getParent()).closest("table");if(!this.isParentRedactor(t)||0==t.length)return!1;this.bufferSet(),t.remove(),this.sync()},tableDeleteRow:function(){var t=this.getParent(),e=$(t).closest("table");if(!this.isParentRedactor(e)||0==e.length)return!1;this.bufferSet();var s=$(t).closest("tr"),o=s.prev().length?s.prev():s.next();if(o.length){var r=o.children("td").first();r.length&&r.prepend('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>")}s.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)||0==e.length)return!1;this.bufferSet();var s=$(t).closest("td");s.is("td")||(s=s.closest("td"));var o=s.get(0).cellIndex;e.find("tr").each($.proxy(function(t,e){var s=o-1<0?o+1:o-1;0===t&&$(e).find("td").eq(s).prepend('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),$(e).find("td").eq(o).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)||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>")).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)||0==e.length)return!1;this.bufferSet();var s=$(this.getParent()).closest("tr"),o=s.clone();o.find("td").html(this.opts.invisibleSpace),"after"===t?s.after(o):s.before(o),this.sync()},tableAddColumn:function(t){var e=$(this.getParent()).closest("table");if(!this.isParentRedactor(e)||0==e.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)),e.find("tr").each($.proxy(function(e,o){var r=$(o).find("td").eq(s),a=r.clone();a.html(this.opts.invisibleSpace),"after"===t?r.after(a):r.before(a)},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();t=this.cleanStripTags(t);var e='<iframe width="500" height="281" src="',s='" frameborder="0" allowfullscreen></iframe>';t.match(reUrlYoutube)?t=t.replace(reUrlYoutube,e+"//www.youtube.com/embed/$1"+s):t.match(reUrlVimeo)?t=t.replace(reUrlVimeo,e+"//player.vimeo.com/video/$2"+s):t.match(reUrlFacebook)?t=t.replace(reUrlFacebook,e+"https://www.facebook.com/video/embed?video_id=$1"+s):t.match(reUrlRutube)&&(t=t.replace(reUrlRutube,e+"//rutube.ru/play/embed/$1"+s)),this.selectionRestore();var o=this.getBlock()||this.getCurrent();o?$(o).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 s=$("#redactor-predefined-links");s.html(""),$.each(e,function(e,o){t.predefinedLinksStorage[e]=o,s.append($("<option>").val(e).html(o.name))}),s.on("change",function(){var e=$(this).val(),s="",o="";0!=e&&(s=t.predefinedLinksStorage[e].name,o=t.predefinedLinksStorage[e].url),$("#redactor_link_url").val(o),1!=$("#redactor_link_url_text").data("is_selected_text")&&$("#redactor_link_url_text").val(s)}),s.show()}})}this.insert_link_node=!1;var e=this.getSelection(),s="",o="",r="",a=this.getParent(),n=$(a).parent().get(0);n&&"A"===n.tagName&&(a=n),a&&"A"===a.tagName?(s=a.href,o=$(a).text(),r=a.target,this.insert_link_node=a):o=e.toString(),$("#redactor_link_url_text").val(o),o.length>0&&$("#redactor_link_url_text").data("is_selected_text",1);var l=self.location.href.replace(/\/$/i,"");if(s=(s=(s=s.replace(l,"")).replace(/^\/#/,"#")).replace("mailto:",""),!1===this.opts.linkProtocol){var c=RegExp("^(http|ftp|https)://"+self.location.host,"i");s=s.replace(c,"")}$("#redactor_link_url").val(s),"_blank"===r&&$("#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="",s=$("#redactor_link_url").val(),o=$("#redactor_link_url_text").val();if(-1!=s.search("@")&&!1===/(http|ftp|https):\/\//i.test(s))s="mailto:"+s;else if(0!=s.search("#")){$("#redactor_link_blank").prop("checked")&&(t=' target="_blank"',e="_blank");var r="((xn--)?[a-z0-9]+(-[a-z0-9]+)*.)+[a-z]{2,}",a=RegExp("^(http|ftp|https)://"+r,"i"),n=RegExp("^"+r,"i");-1==s.search(a)&&0==s.search(n)&&this.opts.linkProtocol&&(s=this.opts.linkProtocol+s)}o=o.replace(/<|>/g,"");var l="&nbsp;";this.browser("mozilla")&&(l="&nbsp;"),this.linkInsert('<a href="'+s+'"'+t+">"+o+"</a>"+l,$.trim(o),s,e)}},linkInsert:function(t,e,s,o){if(this.selectionRestore(),""!==e){if(this.insert_link_node)this.bufferSet(),$(this.insert_link_node).text(e).attr("href",s),""!==o?$(this.insert_link_node).attr("target",o):$(this.insert_link_node).removeAttr("target");else{var r=$(t).addClass("redactor-added-link");this.exec("inserthtml",this.outerHtml(r),!1);var s=this.$editor.find("a.redactor-added-link");s.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 s='<a href="'+t.filelink+'" id="filelink-marker">'+e+"</a>";this.browser("webkit")&&this.window.chrome&&(s+="&nbsp;"),this.execCommand("inserthtml",s,!1);var o=$(this.$editor.find("a#filelink-marker"));0!=o.length?o.removeAttr("id"):o=!1,this.sync(),this.callback("fileUpload",o,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);return}var e={},s=0;$.each(t,$.proxy(function(t,o){void 0!==o.folder&&(s++,e[o.folder]=s)},this)),$("#redactor_image_box .empty_list").show();var o=!1;if($.each(t,$.proxy(function(t,s){var r="";void 0!==s.title&&(r=s.title);var a=0;$.isEmptyObject(e)||void 0===s.folder||(a=e[s.folder],!1!==o||(o=".redactorfolder"+a));var n=$('<img src="'+s.thumb+'" class="redactorfolder redactorfolder'+a+'" rel="'+s.image+'" title="'+r+'" />');$("#redactor_image_box").append(n),$(n).on("click",$.proxy(this.imageThumbClick,this)),$("#redactor_image_box .empty_list").hide()},this)),!$.isEmptyObject(e)){$(".redactorfolder").hide(),$(o).show();var r=function(t){$(".redactorfolder").hide(),$(".redactorfolder"+$(t.target).val()).show()},a=$('<select id="redactor_image_box_select">');$.each(e,function(t,e){a.append($('<option value="'+e+'">'+t+"</option>"))}),$("#redactor_image_box").before(a),a.change(r)}},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,s=e.parent().parent(),o=$.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"===$(s).get(0).tagName&&($("#redactor_file_link").val($(s).attr("href")),"_blank"==$(s).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,o)},imageRemove:function(t){var e=$(t).parent().parent(),s=$(t).parent(),o=!1;e.length&&"A"===e[0].tagName?(o=!0,$(e).remove()):s.length&&"A"===s[0].tagName?(o=!0,$(s).remove()):$(t).remove(),s.length&&"P"===s[0].tagName&&(this.focusWithSaveScroll(),!1===o&&this.selectionStart(s)),this.callback("imageDelete",t),this.modalClose(),this.sync()},imageSave:function(t){this.imageResizeHide(!1);var e=$(t),s=e.parent();e.attr("alt",$("#redactor_file_alt").val());var o=$("#redactor_form_image_align").val(),r="";"left"===o?(r="0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin+" 0",e.css({float:"left",margin:r})):"right"===o?(r="0 0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin,e.css({float:"right",margin:r})):"center"===o?e.css({float:"",display:"block",margin:"auto"}):e.css({float:"",display:"",margin:""});var a=$.trim($("#redactor_file_link").val());if(""!==a){var n=!1;if($("#redactor_link_blank").prop("checked")&&(n=!0),"A"!==s.get(0).tagName){var l=$('<a href="'+a+'">'+this.outerHtml(t)+"</a>");n&&l.attr("target","_blank"),e.replaceWith(l)}else s.attr("href",a),n?s.attr("target","_blank"):s.removeAttr("target")}else"A"===s.get(0).tagName&&s.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 s,o,r=e.width()/e.height(),a=20,n=this.imageResizeControls(e),l=!1;!1!==n&&(n.on("mousedown",function(t){l=!0,t.preventDefault(),r=e.width()/e.height(),s=Math.round(t.pageX-e.eq(0).offset().left),o=Math.round(t.pageY-e.eq(0).offset().top)}),$(this.document.body).on("mousemove",$.proxy(function(t){if(l){t.pageX,e.eq(0).offset().left;var n=Math.round(t.pageY-e.eq(0).offset().top)-o,c=Math.round((parseInt(e.height(),10)+n)*r);c>a&&(e.width(c),c<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"})),s=Math.round(t.pageX-e.eq(0).offset().left),o=Math.round(t.pageY-e.eq(0).offset().top),this.sync()}},this)).on("mouseup",function(){l=!1})),this.$editor.on("keydown.redactor-image-delete",$.proxy(function(t){var s=t.which;(this.keyCode.BACKSPACE==s||this.keyCode.DELETE==s)&&(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)return e.append(t),!1;var s=$('<span id="redactor-image-resizer" data-redactor="verified"></span>');return s.css({position:"absolute",zIndex:2,lineHeight:1,cursor:"nw-resize",bottom:"-4px",right:"-5px",border:"1px solid #fff",backgroundColor:"#000",width:"8px",height:"8px"}),s.attr("contenteditable",!1),e.append(s),e.append(t),s},imageThumbClick:function(t){var e='<img id="image-marker" src="'+$(t.target).attr("rel")+'" alt="'+$(t.target).attr("title")+'" />',s=this.getParent();this.opts.paragraphy&&0==$(s).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 s="";if(!0!==e){s='<img id="image-marker" src="'+t.image.url+'" />';var o=this.getParent();this.opts.paragraphy&&0==$(o).closest("li").length&&(s="<p>"+s+"</p>")}else s=t;this.execCommand("inserthtml",s,!1);var r=$(this.$editor.find("img#image-marker"));r.length?r.removeAttr("id"):r=!1,this.sync(),!0!==e&&this.callback("imageUpload",r,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,s,o){return this.modalSetOverlay(),this.$redactorModalWidth=s,this.$redactorModal=$("#redactor_modal"),this.$redactorModal.length||(this.$redactorModal=$('<div id="redactor_modal" style="display: none;" />'),this.$redactorModal.append($('<div id="redactor_modal_close">&times;</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 o&&o(),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(s,o){s++,$(o).on("click",function(o){if(o.preventDefault(),t.find("a").removeClass("redactor_tabs_act"),$(this).addClass("redactor_tabs_act"),$(".redactor_tab").hide(),$("#redactor_tab"+s).show(),$("#redactor_tab_selected").val(s),!1===e.isMobile()){var r=e.$redactorModal.outerHeight();e.$redactorModal.css("margin-top","-"+(r+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,s=t.target.files,o=0;e=s[o];o++)this.s3uploadFile(e)},s3uploadFile:function(t){this.s3executeOnSignedUrl(t,$.proxy(function(e){this.s3uploadToS3(t,e)},this))},s3executeOnSignedUrl:function(t,e){var s=new XMLHttpRequest,o="?";"-1"!=this.opts.s3.search(/\?/)&&(o="&"),s.open("GET",this.opts.s3+o+"name="+t.name+"&type="+t.type,!0),s.overrideMimeType&&s.overrideMimeType("text/plain; charset=x-user-defined");var r=this;s.onreadystatechange=function(t){4==this.readyState&&200==this.status?(r.showProgressBar(),e(decodeURIComponent(this.responseText))):4==this.readyState&&this.status},s.send()},s3createCORSRequest:function(t,e){var s=new XMLHttpRequest;return"withCredentials"in s?s.open(t,e,!0):"undefined"!=typeof XDomainRequest?(s=new XDomainRequest).open(t,e):s=null,s},s3uploadToS3:function(t,e){var s=this.s3createCORSRequest("PUT",e);s&&(s.onload=$.proxy(function(){if(200==s.status){this.hideProgressBar();var t=e.split("?");if(!t[0])return!1;this.selectionRestore();var o="";o='<img id="image-marker" src="'+t[0]+'" />',this.opts.paragraphy&&(o="<p>"+o+"</p>"),this.execCommand("inserthtml",o,!1);var r=$(this.$editor.find("img#image-marker"));r.length?r.removeAttr("id"):r=!1,this.sync(),this.callback("imageUpload",r,!1),this.modalClose(),this.observeImages()}},this),s.onerror=function(){},s.upload.onprogress=function(t){},s.setRequestHeader("Content-Type",t.type),s.setRequestHeader("x-amz-acl","public-read"),s.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 s=$("#"+t);s.length&&"INPUT"===s[0].tagName?(this.uploadOptions.input=s,this.el=$(s[0].form)):this.el=s,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 s="redactorUploadForm"+this.id,o="redactorUploadFile"+this.id;this.form=$('<form  action="'+this.uploadOptions.url+'" method="POST" target="'+e+'" name="'+s+'" id="'+s+'" 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 s=$("<input/>",{type:"hidden",name:t,value:e});$(this.form).append(s)},this));var r=this.uploadOptions.input,a=$(r).clone();$(r).attr("id",o).before(a).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 s=t.body.innerHTML.match(/\{(.|\n)*\}/)[0];s=(s=s.replace(/^\[/,"")).replace(/\]$/,"");var o=$.parseJSON(s);void 0===o.error?this.uploadOptions.success(o):(console.log(o),this.uploadOptions.error(this,o),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,s,o,r){if(!s){var a=$.ajaxSettings.xhr();a.upload&&a.upload.addEventListener("progress",$.proxy(this.uploadProgress,this),!1),$.ajaxSetup({xhr:function(){return a}})}this.callback("drop",o);var n=new FormData;!1!==r?n.append(r,e):n.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()),n.append(t,e)},this)),$.ajax({url:t,dataType:"html",async:!1,data:n,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(),s){var r=$("<img>");r.attr("src",e.image.url).attr("id","drag-image-marker"),this.insertNodeToCaretPositionFromPoint(o,r[0]);var a=$(this.$editor.find("img#drag-image-marker"));a.length?a.removeAttr("id"):a=!1,this.sync(),this.observeImages(),a&&this.callback("imageUpload",a,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 s=t.loaded?parseInt(t.loaded/t.total*100,10):t;this.dropareabox.text("Loading "+s+"% "+(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(/&#x200b;|<br>|<br\/>|&nbsp;/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!=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(),s=/(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)||0>e.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return"version"==t?s[2]:"webkit"==t?"chrome"==s[1]||"webkit"==s[1]:"rv"==s[1]?"msie"==t:"opr"==s[1]?"webkit"==t:t==s[1]},oldIE:function(){return!!(this.browser("msie")&&9>parseInt(this.browser("version"),10))},getFragmentHtml:function(t){var e=t.cloneNode(!0),s=this.document.createElement("div");return s.appendChild(e),s.innerHTML},extractContent:function(){for(var t,e=this.$editor[0],s=this.document.createDocumentFragment();t=e.firstChild;)s.appendChild(t);return s},isParentRedactor:function(t){return!!t&&(this.opts.iframe?t:!(0==$(t).parents("div.redactor_editor").length||$(t).hasClass("redactor_editor"))&&t)},currentOrParentIs:function(t){var e=this.getParent(),s=this.getCurrent();return e&&e.tagName===t?e:!!s&&s.tagName===t&&s},isEndOfElement:function(){var t=this.getBlock(),e=this.getCaretOffset(t),s=$.trim($(t).text()).replace(/\n\r\n/g,"").length;return e==s},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 s=null;-1!==(s=t.indexOf(e));)t.splice(s,1);return t}},Redactor.prototype.init.prototype=Redactor.prototype,$.Redactor.fn.formatLinkify=function(t,e,s,o,r){for(var a=/(((https?|ftps?):\/\/)|www[.][^\s])(.+?\..+?)([.),]?)(\s|\.\s+|\)|$)/gi,n=/(https?|ftp):\/\//i,l=/(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/gi,c=(this.$editor?this.$editor.get(0):this).childNodes,h=c.length;h--;){var d=c[h];if(3===d.nodeType){var p=d.nodeValue;if(o&&p){var u='<iframe width="500" height="281" src="',f='" frameborder="0" allowfullscreen></iframe>';p.match(reUrlYoutube)?(p=p.replace(reUrlYoutube,u+"//www.youtube.com/embed/$1"+f),$(d).after(p).remove()):p.match(reUrlVimeo)&&(p=p.replace(reUrlVimeo,u+"//player.vimeo.com/video/$2"+f),$(d).after(p).remove())}if(s&&p&&p.match(l)&&(p=p.replace(l,'<img src="$1">'),$(d).after(p).remove()),e&&p&&p.match(a)){var m=p.match(a);for(var h in m){var g=m[h],b=g,v="";null!==g.match(/\s$/)&&(v=" ");var _=t;null!==g.match(n)&&(_=""),b.length>r&&(b=b.substring(0,r)+"...");var y=(b=b.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")).replace("$","$$$");p=p.replace(g,'<a href="'+_+$.trim(g)+'">'+$.trim(y)+"</a>"+v)}$(d).after(p).remove()}}else 1!==d.nodeType||/^(a|button|textarea)$/i.test(d.tagName)||$.Redactor.fn.formatLinkify.call(d,t,e,s,o,r)}}}(jQuery);
\ No newline at end of file

programming_language: JavaScript