!function(){Array.prototype.every||(Array.prototype.every=function(t,e){if(void 0===this||null===this||"function"!=typeof t)throw new TypeError;for(var i=Object(this),r=i.length>>>0,o=void 0===e||null===e,s=0;r>s;s++)if(s in i)if(o){if(!t(i[s],s,i))return!1}else if(!t.call(e,i[s],s,i))return!1;return!0}),Array.prototype.filter||(Array.prototype.filter=function(t,e){if(void 0===this||null===this||"function"!=typeof t)throw new TypeError;for(var i=Object(this),r=i.length>>>0,o=void 0===e||null===e,s=[],a=0;r>a;a++)if(a in i){var n=i[a];o?t(i[a],a,i)&&s.push(n):t.call(e,i[a],a,i)&&s.push(n)}return s}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){if(void 0===this||null===this||"function"!=typeof t)throw new TypeError;for(var i=Object(this),r=i.length>>>0,o=void 0===e||null===e,s=0;r>s;s++)s in i&&(o?t(i[s],s,i):t.call(e,i[s],s,i))}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t,e){if(void 0===this||null===this)throw new TypeError;var i=Object(this),r=i.length>>>0,o=void 0!==e&&null!==e;if(0===r)return-1;var s=0;if(o&&(s=Number(e),s!==s?s=0:0!==s&&1/0!==s&&s!==-1/0&&(s=(s>0||-1)*Math.floor(Math.abs(s)))),s>=r)return-1;for(var a=s>=0?s:Math.max(r-Math.abs(s),0);r>a;a++)if(a in i&&i[a]===t)return a;return-1}),Array.isArray=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(t,e){if(void 0===this||null===this)throw new TypeError;var i=Object(this),r=i.length>>>0,o=void 0!==e&&null!==e;if(0===r)return-1;var s=r;o&&(s=Number(e),s!==s?s=0:0!==s&&1/0!==s&&s!==-1/0&&(s=(s>0||-1)*Math.floor(Math.abs(s))));for(var a=s>=0?Math.min(s,r-1):r-Math.abs(s);a>=0;a--)if(a in i&&i[a]===t)return a;return-1}),Array.prototype.map||(Array.prototype.map=function(t,e){if(void 0===this||null===this||"function"!=typeof t)throw new TypeError;for(var i=Object(this),r=i.length>>>0,o=void 0===e||null===e,s=new Array(r),a=0;r>a;a++)a in i&&(s[a]=o?t(i[a],a,i):t.call(e,i[a],a,i));return s}),Array.prototype.reduce||(Array.prototype.reduce=function(t,e){if(void 0===this||null===this||"function"!=typeof t)throw new TypeError;var i=Object(this),r=i.length>>>0,o=void 0!==e&&null!==e;if(0==r&&!o)throw new TypeError;var s,a=0;if(o)s=e;else for(;;){if(a in i){s=i[a++];break}if(++a>=r)throw new TypeError}for(;r>a;)a in i&&(s=t(s,i[a],a,i)),a++;return s}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(t,e){if(void 0===this||null===this||"function"!=typeof t)throw new TypeError;var i=Object(this),r=i.length>>>0,o=void 0!==e&&null!==e;if(0==r&&!o)throw new TypeError;var s,a=r-1;if(o)s=e;else for(;;){if(a in this){s=i[a--];break}if(--a<0)throw new TypeError}for(;a--;)a in i&&(s=callbackfn(s,i[a],a,i));return s}),Array.prototype.some||(Array.prototype.some=function(t,e){if(void 0===this||null===this||"function"!=typeof t)throw new TypeError;for(var i=Object(this),r=i.length>>>0,o=void 0===e||null===e,s=0;r>s;s++)if(s in i)if(o){if(t(i[s],s,i))return!0}else if(t.call(e,i[s],s,i))return!0;return!1}),Date.now||(Date.now=function(){return+new Date}),Date.prototype.toISOString||(Date.prototype.toISOString=function(){var t=function(e,i){return i=i||2,e+="",e.length===i?e:t("0"+e,i)};return function(){var e=this.getUTCFullYear();e=(0>e?"-":e>9999?"+":"")+("00000"+Math.abs(e)).slice(e>=0&&9999>=e?-4:-6);var i=[e,t(this.getUTCMonth()+1),t(this.getUTCDate())].join("-"),r=[t(this.getUTCHours()),t(this.getUTCMinutes()),t(this.getUTCSeconds())].join(":")+"."+t(this.getUTCMilliseconds(),3);return[i,r].join("T")+"Z"}}()),Date.prototype.toJSON||(Date.prototype.toJSON=function(){var t=Object(this),e=t.toISOString;if("function"!=typeof e)throw new TypeError;return e.call(t)}),Function.prototype.bind||(Function.prototype.bind=function(t){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var e=Array.prototype.slice,i=e.call(arguments,1),r=this,o=function(){},s=function(){if(o.prototype&&this instanceof o){var s=r.apply(new o,i.concat(e.call(arguments)));return Object(s)===s?s:r}return r.apply(t,i.concat(e.call(arguments)))};return o.prototype=r.prototype,s.prototype=new o,s}),function(){"use strict";var t=function(t){if(t!==Object(t))throw new TypeError("Object.getPrototypeOf called on non-object")};Object.getPrototypeOf||(Object.getPrototypeOf="object"==typeof"test".__proto__?function(e){return t(e),e.__proto__}:function(e){return t(e),e.constructor.prototype})}(),Object.keys||(Object.keys=function(){var t=Object.prototype.hasOwnProperty,e=!{toString:null}.propertyIsEnumerable("toString"),i=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],r=i.length;return function(o){if("object"!=typeof o&&"function"!=typeof o||null===o)throw new TypeError("Object.keys called on non-object");var s=[];for(var a in o)t.call(o,a)&&s.push(a);if(e)for(var n=0;r>n;n++)t.call(o,i[n])&&s.push(i[n]);return s}}()),String.prototype.trim||(String.prototype.trim=function(){var t=/^\s+/,e=/\s+$/;return function(){return this.replace(t,"").replace(e,"")}}()),function(){var t=!1,e=/xyz/.test(function(){})?/\b_super\b/:/.*/;this.Class=function(){},Class.extend=function(i){function r(){!t&&this.init&&this.init.apply(this,arguments)}var o=this.prototype;t=!0;var s=new this;t=!1;for(var a in i)s[a]="function"==typeof i[a]&&"function"==typeof o[a]&&e.test(i[a])?function(t,e){return function(){var i=this._super;this._super=o[t];var r=e.apply(this,arguments);return this._super=i,r}}(a,i[a]):i[a];return r.prototype=s,r.prototype.constructor=r,r.extend=arguments.callee,r}}(),function(t){t.fn.hoverIntent=function(e,i){var r={sensitivity:7,interval:100,timeout:0};r=t.extend(r,i?{over:e,out:i}:e);var o,s,a,n,l=function(t){o=t.pageX,s=t.pageY},c=function(e,i){return i.hoverIntent_t=clearTimeout(i.hoverIntent_t),Math.abs(a-o)+Math.abs(n-s)<r.sensitivity?(t(i).unbind("mousemove",l),i.hoverIntent_s=1,r.over.apply(i,[e])):(a=o,n=s,i.hoverIntent_t=setTimeout(function(){c(e,i)},r.interval),void 0)},d=function(t,e){return e.hoverIntent_t=clearTimeout(e.hoverIntent_t),e.hoverIntent_s=0,r.out.apply(e,[t])},h=function(e){var i=jQuery.extend({},e),o=this;o.hoverIntent_t&&(o.hoverIntent_t=clearTimeout(o.hoverIntent_t)),"mouseenter"==e.type?(a=i.pageX,n=i.pageY,t(o).bind("mousemove",l),1!=o.hoverIntent_s&&(o.hoverIntent_t=setTimeout(function(){c(i,o)},r.interval))):(t(o).unbind("mousemove",l),1==o.hoverIntent_s&&(o.hoverIntent_t=setTimeout(function(){d(i,o)},r.timeout)))};return this.bind("mouseenter",h).bind("mouseleave",h)}}(jQuery),function($){function Redactor(t,e){return new Redactor.prototype.init(t,e)}var uuid=0,Range=function(t){return this[0]=t.startOffset,this[1]=t.endOffset,this.range=t,this};Range.prototype.equals=function(){return this[0]===this[1]};var reUrlYoutube=/https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/gi,reUrlVimeo=/https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;$.fn.redactor=function(t){var e=[],i=Array.prototype.slice.call(arguments,1);return this.each("string"==typeof t?function(){var r=$.data(this,"redactor");if("undefined"==typeof r||!$.isFunction(r[t]))return $.error('No such method "'+t+'" for Redactor');var o=r[t].apply(r,i);void 0!==o&&o!==r&&e.push(o)}: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.5",$.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,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","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","pre","h1","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","pre","select","td","th","tr","ul"],blockLevelElements:["P","H1","H2","H3","H4","H5","H6","DD","DL","DT","DIV","LI","BLOCKQUOTE","OUTPUT","FIGCAPTION","PRE","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",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",deleted:"Deleted",anchor:"Anchor",link_new_tab:"Open link in new tab",underline:"Underline",alignment:"Alignment",filename:"Name (optional)",edit:"Edit"}}},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 r=$.extend(!0,{},$.Redactor.opts);if(this.opts=$.extend({},r,this.$element.data(),e),this.start=!0,this.dropdowns=[],this.sourceHeight=this.$source.css("height"),this.sourceWidth=this.$source.css("width"),this.opts.fullpage&&(this.opts.iframe=!0),this.opts.linebreaks&&(this.opts.paragraphy=!1),this.opts.paragraphy&&(this.opts.linebreaks=!1),this.opts.toolbarFixedBox&&(this.opts.toolbarFixed=!0),this.document=document,this.window=window,this.savedSel=!1,this.cleanlineBefore=new RegExp("^<(/?"+this.opts.ownLine.join("|/?")+"|"+this.opts.contOwnLine.join("|")+")[ >]"),this.cleanlineAfter=new RegExp("^<(br|/?"+this.opts.ownLine.join("|/?")+"|/"+this.opts.contOwnLine.join("|/")+")[ >]"),this.cleannewLevel=new RegExp("^</?("+this.opts.newLevel.join("|")+")[ >]"),this.rTestBlock=new RegExp("^("+this.opts.blockLevelElements.join("|")+")$","i"),this.opts.linebreaks===!1){if(this.opts.allowedTags!==!1){var o=["strong","em","del"],s=["b","i","strike"];"-1"===$.inArray("p",this.opts.allowedTags)&&this.opts.allowedTags.push("p");for(i in o)"-1"!=$.inArray(o[i],this.opts.allowedTags)&&this.opts.allowedTags.push(s[i])}if(this.opts.deniedTags!==!1){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"},formatting:{title:t.formatting,func:"show",dropdown:{p:{title:t.paragraph,func:"formatBlocks"},blockquote:{title:t.quote,func:"formatQuote",className:"redactor_format_blockquote"},pre:{title:t.code,func:"formatBlocks",className:"redactor_format_pre"},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,i){var r=this.opts[t+"Callback"];return $.isFunction(r)?e===!1?r.call(this,i):r.call(this,e,i):i},destroy:function(){clearInterval(this.autosaveInterval),$(window).off(".redactor"),this.$source.off("redactor-textarea"),this.$element.off(".redactor").removeData("redactor");var t=this.get();if(this.opts.textareamode)this.$box.after(this.$source),this.$box.remove(),this.$source.val(t).show();else{var e=this.$editor;this.opts.iframe&&(e=this.$element),this.$box.after(e),this.$box.remove(),e.removeClass("redactor_editor").removeClass("redactor_editor_wym").removeAttr("contenteditable").html(t).show()}this.opts.toolbarExternal&&$(this.opts.toolbarExternal).html(""),this.opts.air&&$("#redactor_air_"+this.uuid).remove()},getObject:function(){return $.extend({},this)},getEditor:function(){return this.$editor},getBox:function(){return this.$box},getIframe:function(){return this.opts.iframe?this.$frame:!1},getToolbar:function(){return this.$toolbar?this.$toolbar:!1},get:function(){return this.$source.val()},getCodeIframe:function(){this.$editor.removeAttr("contenteditable").removeAttr("dir");var t=this.outerHtml(this.$frame.contents().children());return this.$editor.attr({contenteditable:!0,dir:this.opts.direction}),t},set:function(t,e,i){t=t.toString(),t=t.replace(/\$/g,"&#36;"),this.opts.fullpage?this.setCodeIframe(t):this.setEditor(t,e),""==t&&(i=!1),i!==!1&&this.placeholderRemoveFromEditor()},setEditor:function(t,e){e!==!1&&(t=this.cleanSavePreCode(t),t=this.cleanStripTags(t),t=this.cleanConvertProtected(t),t=this.cleanConvertInlineTags(t,!0),t=this.opts.linebreaks===!1?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()},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),this.$editor.html(t),this.setNonEditable(),this.setSpansVerified(),this.sync()},setFullpageDoctype:function(){if(this.fullpageDoctype&&1==this.fullpageDoctype.length){var t=this.fullpageDoctype[0]+"\n"+this.$source.val();this.$source.val(t)}},setSpansVerified:function(){var t=this.$editor.find("span"),e="inline";$.each(t,function(){var t=this.outerHTML,i=new RegExp("<"+this.tagName,"gi"),r=t.replace(i,"<"+e);i=new RegExp("</"+this.tagName,"gi"),r=r.replace(i,"</"+e),$(this).replaceWith(r)})},setSpansVerifiedHtml:function(t){return t=t.replace(/<span(.*?)>/,"<inline$1>"),t.replace(/<\/span>/,"</inline>")},setNonEditable:function(){this.$editor.find(".noneditable").attr("contenteditable",!1)},sync:function(t){var e="";this.cleanUnverified(),e=this.opts.fullpage?this.getCodeIframe():this.$editor.html(),e=this.syncClean(e),e=this.cleanRemoveEmptyTags(e);var i=this.cleanRemoveSpaces(this.$source.val(),!1),r=this.cleanRemoveSpaces(e,!1);if(i==r)return!1;if(e=e.replace(/<\/li><(ul|ol)>([\w\W]*?)<\/(ul|ol)>/gi,"<$1>$2</$1></li>"),"<br>"===$.trim(e)&&(e=""),this.opts.xhtml){var o=["br","hr","img","link","input","meta"];$.each(o,function(t,i){e=e.replace(new RegExp("<"+i+"(.*?[^/$]?)>","gi"),"<"+i+"$1 />")})}if(e=this.callback("syncBefore",!1,e),this.$source.val(e),this.setFullpageDoctype(),this.callback("syncAfter",!1,e),this.start===!1)if("undefined"!=typeof t)switch(t.which){case 37:break;case 38:break;case 39:break;case 40:break;default:this.callback("change",!1,e)}else this.callback("change",!1,e)},syncClean:function(t){return this.opts.fullpage||(t=this.cleanStripTags(t)),t=$.trim(t),t=this.placeholderRemoveFromCode(t),t=t.replace(/&#x200b;/gi,""),t=t.replace(/&#8203;/gi,""),t=t.replace(/<\/a>&nbsp;/gi,"</a> "),t=t.replace(/\u200B/g,""),("<p></p>"==t||"<p> </p>"==t||"<p>&nbsp;</p>"==t)&&(t=""),this.opts.linkNofollow&&(t=t.replace(/<a(.*?)rel="nofollow"(.*?)>/gi,"<a$1$2>"),t=t.replace(/<a(.*?)>/gi,'<a$1 rel="nofollow">')),t=t.replace("<!--?php","<?php"),t=t.replace("?-->","?>"),t=t.replace(/<(.*?)class="noeditable"(.*?) contenteditable="false"(.*?)>/gi,'<$1class="noeditable"$2$3>'),t=t.replace(/ data-tagblock=""/gi,""),t=t.replace(/<br\s?\/?>\n?<\/(P|H[1-6]|LI|ADDRESS|SECTION|HEADER|FOOTER|ASIDE|ARTICLE)>/gi,"</$1>"),t=t.replace(/<span(.*?)id="redactor-image-box"(.*?)>([\w\W]*?)<img(.*?)><\/span>/gi,"$3<img$4>"),t=t.replace(/<span(.*?)id="redactor-image-resizer"(.*?)>(.*?)<\/span>/gi,""),t=t.replace(/<span(.*?)id="redactor-image-editter"(.*?)>(.*?)<\/span>/gi,""),t=t.replace(/<(ul|ol)>\s*\t*\n*<\/(ul|ol)>/gi,""),this.opts.cleanFontTag&&(t=t.replace(/<font(.*?)>([\w\W]*?)<\/font>/gi,"$2")),t=t.replace(/<span(.*?)>([\w\W]*?)<\/span>/gi,"$2"),t=t.replace(/<inline>([\w\W]*?)<\/inline>/gi,"$1"),t=t.replace(/<inline>/gi,"<span>"),t=t.replace(/<inline /gi,"<span "),t=t.replace(/<\/inline>/gi,"</span>"),this.opts.removeEmptyTags&&(t=t.replace(/<span>([\w\W]*?)<\/span>/gi,"$1")),t=t.replace(/<span(.*?)class="redactor_placeholder"(.*?)>([\w\W]*?)<\/span>/gi,""),t=t.replace(/<img(.*?)contenteditable="false"(.*?)>/gi,"<img$1$2>"),t=t.replace(/&/gi,"&"),t=t.replace(/\u2122/gi,"&trade;"),t=t.replace(/\u00a9/gi,"&copy;"),t=t.replace(/\u2026/gi,"&hellip;"),t=t.replace(/\u2014/gi,"&mdash;"),t=t.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),this.opts.mobile===!1&&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.content=$.trim(this.opts.textareamode?this.$source.val():this.$source.html())},buildFromTextarea:function(){this.$editor=$("<div />"),this.$box.insertAfter(this.$source).append(this.$editor).append(this.$source),this.buildAddClasses(this.$editor),this.buildEnable()},buildFromElement:function(){this.$editor=this.$source,this.$source=this.buildCodearea(this.$editor),this.$box.insertAfter(this.$editor).append(this.$editor).append(this.$source),this.buildEnable()},buildCodearea:function(t){return $("<textarea />").attr("name",t.attr("id")).css("height",this.sourceHeight)},buildAddClasses:function(t){$.each(this.$source.get(0).className.split(/\s+/),function(e,i){t.addClass("redactor_"+i)})},buildEnable:function(){this.$editor.addClass("redactor_editor").attr({contenteditable:!0,dir:this.opts.direction}),this.$source.attr("dir",this.opts.direction).hide(),this.set(this.content,!0,!1)},buildOptions:function(){var t=this.$editor;this.opts.iframe&&(t=this.$frame),this.opts.tabindex&&t.attr("tabindex",this.opts.tabindex),this.opts.minHeight?t.css("min-height",this.opts.minHeight+"px"):this.browser("mozilla")&&this.opts.linebreaks&&this.$editor.css("min-height","45px"),this.browser("mozilla")&&this.opts.linebreaks&&this.$editor.css("padding-bottom","10px"),this.opts.maxHeight&&(this.opts.autoresize=!1,this.sourceHeight=this.opts.maxHeight),this.opts.wym&&this.$editor.addClass("redactor_editor_wym"),this.opts.typewriter&&this.$editor.addClass("redactor-editor-typewriter"),this.opts.autoresize||t.css("height",this.sourceHeight)},buildAfter:function(){if(this.start=!1,this.opts.toolbar&&(this.opts.toolbar=this.toolbarInit(this.opts.curLang),this.toolbarBuild()),this.modalTemplatesInit(),this.buildPlugins(),this.buildBindKeyboard(),this.opts.autosave&&this.autosave(),setTimeout($.proxy(this.observeStart,this),4),this.browser("mozilla"))try{this.document.execCommand("enableObjectResizing",!1,!1),this.document.execCommand("enableInlineTableEditing",!1,!1)}catch(t){}this.opts.focus&&setTimeout($.proxy(this.focus,this),100),this.opts.visual||setTimeout($.proxy(function(){this.opts.visual=!0,this.toggle(!1)},this),200),this.callback("init")},buildBindKeyboard:function(){this.dblEnter=0,!this.opts.dragUpload||this.opts.imageUpload===!1&&this.opts.s3===!1||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));var t;$(document).mousedown(function(e){t=$(e.target)}),this.$editor.on("blur.redactor",$.proxy(function(e){$(t).hasClass("redactor_toolbar")||0!=$(t).parents(".redactor_toolbar").size()||(this.selectall=!1,$.isFunction(this.opts.blurCallback)&&this.callback("blur",e))},this))},buildEventDrop:function(t){if(t=t.originalEvent||t,void 0===window.FormData||!t.dataTransfer)return!0;var e=t.dataTransfer.files.length;if(0==e)return!0;t.preventDefault();var i=t.dataTransfer.files[0];return this.opts.dnbImageTypes!==!1&&-1==this.opts.dnbImageTypes.indexOf(i.type)?!0:(this.bufferSet(),this.showProgressBar(),void(this.opts.s3===!1?this.dragUploadAjax(this.opts.imageUpload,i,!0,t,this.opts.imageUploadParam):this.s3uploadFile(i)))},buildEventPaste:function(t){var e=!1;if(this.browser("webkit")&&-1===navigator.userAgent.indexOf("Chrome")){var i=this.browser("version").split(".");i[0]<536&&(e=!0)}if(e)return!0;if(this.browser("opera"))return!0;if(this.opts.clipboardUpload&&this.buildEventClipboardUpload(t))return!0;if(this.opts.cleanup){this.rtePaste=!0,this.selectionSave(),this.selectall||(this.opts.autoresize===!0&&this.fullscreen!==!0?(this.$editor.height(this.$editor.height()),this.saveScroll=this.document.body.scrollTop):this.saveScroll=this.$editor.scrollTop());var r=this.extractContent();setTimeout($.proxy(function(){var t=this.extractContent();this.$editor.append(r),this.selectionRestore();var e=this.getFragmentHtml(t);this.pasteClean(e),this.opts.autoresize===!0&&this.fullscreen!==!0&&this.$editor.css("height","auto")},this),1)}},buildEventClipboardUpload:function(t){var e=t.originalEvent||t;if(this.clipboardFilePaste=!1,"undefined"==typeof e.clipboardData)return!1;if(e.clipboardData.items){var i=e.clipboardData.items[0].getAsFile();if(null!==i){this.bufferSet(),this.clipboardFilePaste=!0;var r=new FileReader;return r.onload=$.proxy(this.pasteClipboardUpload,this),r.readAsDataURL(i),!0}}return!1},buildEventKeydown:function(t){if(this.rtePaste)return!1;var e=t.which,i=t.ctrlKey||t.metaKey,r=this.getParent(),o=this.getCurrent(),s=this.getBlock(),a=!1;if(this.callback("keydown",t),this.browser("mozilla")&&"modify"in window.getSelection()&&i&&(37===t.keyCode||39===t.keyCode)){var n=this.getSelection(),l=t.metaKey?"line":"word";37===t.keyCode&&(n.modify("extend","left",l),t.shiftKey||n.collapseToStart()),39===t.keyCode&&(n.modify("extend","right",l),t.shiftKey||n.collapseToEnd()),t.preventDefault()}if(this.imageResizeHide(!1),(r&&"PRE"===$(r).get(0).tagName||o&&"PRE"===$(o).get(0).tagName)&&(a=!0,e===this.keyCode.DOWN&&this.insertAfterLastElement(s)),e===this.keyCode.DOWN&&(r&&"BLOCKQUOTE"===$(r)[0].tagName&&this.insertAfterLastElement(r),o&&"BLOCKQUOTE"===$(o)[0].tagName&&this.insertAfterLastElement(o),r&&"P"===$(r)[0].tagName&&"BLOCKQUOTE"==$(r).parent()[0].tagName&&this.insertAfterLastElement(r,$(r).parent()[0]),o&&"P"===$(o)[0].tagName&&r&&"BLOCKQUOTE"==$(r)[0].tagName&&this.insertAfterLastElement(o,r)),this.shortcuts(t,e),i&&90===e&&!t.shiftKey&&!t.altKey)return t.preventDefault(),void(this.opts.buffer.length?this.bufferUndo():this.document.execCommand("undo",!1,!1));if(i&&90===e&&t.shiftKey&&!t.altKey)return t.preventDefault(),void(0!=this.opts.rebuffer.length?this.bufferRedo():this.document.execCommand("redo",!1,!1));if(32==e&&this.bufferSet(),i&&65===e?(this.bufferSet(),this.selectall=!0):e==this.keyCode.LEFT_WIN||i||(this.selectall=!1),e!=this.keyCode.ENTER||t.shiftKey||t.ctrlKey||t.metaKey)e===this.keyCode.ENTER&&(t.ctrlKey||t.shiftKey)&&(this.bufferSet(),t.preventDefault(),this.insertLineBreak());else{var c=this.getRange();if(c&&c.collapsed===!1&&(sel=this.getSelection(),sel.rangeCount&&c.deleteContents()),this.browser("msie")&&1==r.nodeType&&("TD"==r.tagName||"TH"==r.tagName))return t.preventDefault(),this.bufferSet(),this.insertNode(document.createElement("br")),this.callback("enter",t),!1;if(s&&("BLOCKQUOTE"==s.tagName||"BLOCKQUOTE"==$(s).parent()[0].tagName))if(this.isEndOfElement()){if(1==this.dblEnter){var d,h;if("BLOCKQUOTE"==s.tagName?(h="br",d=s):(h="p",d=$(s).parent()[0]),t.preventDefault(),this.insertingAfterLastElement(d),this.dblEnter=0,"p"==h)$(s).parent().find("p").last().remove();else{var p=$.trim($(s).html());$(s).html(p.replace(/<br\s?\/?>$/i,""))}return}this.dblEnter++}else this.dblEnter++;if(a===!0)return this.buildEventKeydownPre(t,o);if(!this.opts.linebreaks){if(s&&"LI"==s.tagName){var u=this.getBlock();if(u!==!1||"LI"===u.tagName){var f=$.trim($(s).text()),m=$.trim($(u).text());if(""==f&&""==m&&0==$(u).next("li").size()&&0==$(u).parents("li").size()){this.bufferSet();var g=$(u).closest("ol, ul");$(u).remove();var b=$("<p>"+this.opts.invisibleSpace+"</p>");return g.after(b),this.selectionStart(b),this.sync(),this.callback("enter",t),!1}}}if(s&&this.opts.rBlockTest.test(s.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(s===!1){this.bufferSet();var b=$("<p>"+this.opts.invisibleSpace+"</p>");return this.insertNode(b[0]),this.selectionStart(b),this.callback("enter",t),!1}}if(this.opts.linebreaks){if(!s||!this.opts.rBlockTest.test(s.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"==s.tagName||"FIGCAPTION"==s.tagName)return this.buildEventKeydownInsertLineBreak(t);this.callback("enter",t)}return(e===this.keyCode.TAB||t.metaKey&&219===e)&&this.opts.shortcuts?this.buildEventKeydownTab(t,a,e):void(e===this.keyCode.BACKSPACE&&this.buildEventKeydownBackspace(t,o,r))},buildEventKeydownPre:function(t,e){t.preventDefault(),this.bufferSet();var i=$(e).parent().text();return this.insertNode(document.createTextNode("\n")),-1==i.search(/\s$/)&&this.insertNode(document.createTextNode("\n")),this.sync(),this.callback("enter",t),!1
},buildEventKeydownTab:function(t,e){return this.opts.tabFocus?this.isEmpty(this.get())&&this.opts.tabSpaces===!1?!0:(t.preventDefault(),e!==!0||t.shiftKey?this.opts.tabSpaces!==!1?(this.bufferSet(),this.insertNode(document.createTextNode(Array(this.opts.tabSpaces+1).join(" "))),this.sync(),!1):(t.shiftKey?this.indentingOutdent():this.indentingIndent(),!1):(this.bufferSet(),this.insertNode(document.createTextNode("	")),this.sync(),!1)):!0},buildEventKeydownBackspace:function(t,e,i){if(i&&e&&"TD"==i.parentNode.tagName&&"UL"==i.tagName&&"LI"==e.tagName&&1==$(i).children("li").size()){var r=$(e).text().replace(/[\u200B-\u200D\uFEFF]/g,"");if(""==r){var o=i.parentNode;return $(i).remove(),this.selectionStart(o),this.sync(),!1}}if("undefined"!=typeof e.tagName&&/^(H[1-6])$/i.test(e.tagName)){var o;o=$(this.opts.linebreaks===!1?"<p>"+this.opts.invisibleSpace+"</p>":"<br>"+this.opts.invisibleSpace),$(e).replaceWith(o),this.selectionStart(o),this.sync()}"undefined"!=typeof e.nodeValue&&null!==e.nodeValue&&e.remove&&3===e.nodeType&&null==e.nodeValue.match(/[^\u200B]/g)&&($(e).prev().remove(),this.sync())},buildEventKeydownInsertLineBreak:function(t){this.bufferSet(),t.preventDefault(),this.insertLineBreak(),this.callback("enter",t)},buildEventKeyup:function(t){if(this.rtePaste)return!1;var e=t.which,i=this.getParent(),r=this.getCurrent();if(!this.opts.linebreaks&&3==r.nodeType&&(0==i||"BODY"==i.tagName)){var o=$("<p>").append($(r).clone());$(r).replaceWith(o);var s=$(o).next();"undefined"!=typeof s[0]&&"BR"==s[0].tagName&&s.remove(),this.selectionEnd(o)}return(this.opts.convertLinks||this.opts.convertImageLinks||this.opts.convertVideoLinks)&&e===this.keyCode.ENTER&&this.buildEventKeyupConverters(),e===this.keyCode.DELETE||e===this.keyCode.BACKSPACE?this.formatEmpty(t):(this.callback("keyup",t),void 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(){this.opts.placeholder!==!1?(this.placeholderText=this.opts.placeholder,this.opts.placeholder=!0):"undefined"==typeof 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 this.opts.placeholder===!1?!1: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 this.opts.linebreaks===!1?$("<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="";this.opts.linebreaks===!1&&(t=this.opts.emptyHtml),this.$editor.off("focus.redactor_placeholder"),this.$editor.html(t),this.opts.linebreaks===!1?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){return this.opts.shortcuts?void $.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)):(!e.ctrlKey&&!e.metaKey||66!==key&&73!==key||e.preventDefault(),!1)},shortcutsHandler:function(t,e,i){var r={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:"'"},o={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"};e=e.toLowerCase().split(" ");var s=r[t.keyCode],a=String.fromCharCode(t.which).toLowerCase(),n="",l={};$.each(["alt","ctrl","meta","shift"],function(e,i){t[i+"Key"]&&s!==i&&(n+=i+"+")}),s&&(l[n+s]=!0),a&&(l[n+a]=!0,l[n+o[a]]=!0,"shift+"===n&&(l[o[a]]=!0));for(var c=0,d=e.length;d>c;c++)if(l[e[c]])return t.preventDefault(),i.apply(this,arguments)},focus:function(){this.browser("opera")?this.$editor.focus():this.window.setTimeout($.proxy(this.focusSet,this,!0),1)},focusWithSaveScroll:function(){if(this.browser("msie"))var t=this.document.documentElement.scrollTop;this.$editor.focus(),this.browser("msie")&&(this.document.documentElement.scrollTop=t)},focusEnd:function(){if(this.browser("mozilla"))if(this.opts.linebreaks===!1){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(),"undefined"==typeof e&&(e=this.$editor[0]);var i=this.getRange();i.selectNodeContents(e),i.collapse(t||!1);var r=this.getSelection();r.removeAllRanges(),r.addRange(i)},toggle:function(t){this.opts.visual?this.toggleCode(t):this.toggleVisual()},toggleVisual:function(){var t=this.$source.hide().val();if("undefined"!=typeof this.modified){var e=this.modified.replace(/\n/g,""),i=t.replace(/\n/g,"");i=this.cleanRemoveSpaces(i,!1),this.modified=this.cleanRemoveSpaces(e,!1)!==i}this.modified&&(this.opts.fullpage&&""===t?this.setFullpageOnInit(t):(this.set(t),this.opts.fullpage&&this.buildBindKeyboard()),this.callback("change",!1,t)),this.opts.iframe?this.$frame.show():this.$editor.show(),this.opts.fullpage&&this.$editor.attr("contenteditable",!0),this.$source.off("keydown.redactor-textarea-indenting"),this.$editor.focus(),this.selectionRestore(),this.observeStart(),this.buttonActiveVisual(),this.buttonInactive("html"),this.opts.visual=!0},toggleCode:function(t){t!==!1&&this.selectionSave();var e=null;this.opts.iframe?(e=this.$frame.height(),this.opts.fullpage&&this.$editor.removeAttr("contenteditable"),this.$frame.hide()):(e=this.$editor.innerHeight(),this.$editor.hide());var i=this.$source.val();""!==i&&this.opts.tidyHtml&&this.$source.val(this.cleanHtml(i)),this.modified=i,this.$source.height(e).show().focus(),this.$source.on("keydown.redactor-textarea-indenting",this.textareaIndenting),this.buttonInactiveVisual(),this.buttonActive("html"),this.opts.visual=!1},textareaIndenting:function(t){if(9===t.keyCode){var e=$(this),i=e.get(0).selectionStart;return e.val(e.val().substring(0,i)+"	"+e.val().substring(e.get(0).selectionEnd)),e.get(0).selectionStart=e.get(0).selectionEnd=i+1,!1}},autosave:function(){var t=!1;this.autosaveInterval=setInterval($.proxy(function(){var e=this.get();if(t!==e){var i=this.$source.attr("name");$.ajax({url:this.opts.autosave,type:"post",data:"name="+i+"&"+i+"="+escape(encodeURIComponent(e)),success:$.proxy(function(i){var r=$.parseJSON(i);"undefined"==typeof r.error?this.callback("autosave",!1,r):this.callback("autosaveError",!1,r),t=e},this)})}},this),1e3*this.opts.autosaveInterval)},toolbarBuild:function(){if(this.isMobile()&&this.opts.buttonsHideOnMobile.length>0&&$.each(this.opts.buttonsHideOnMobile,$.proxy(function(t,e){var i=this.opts.buttons.indexOf(e);this.opts.buttons.splice(i,1)},this)),this.opts.air)this.opts.buttons=this.opts.airButtons;else if(!this.opts.buttonSource){var t=this.opts.buttons.indexOf("html");this.opts.buttons.splice(t,1)}return this.opts.toolbar&&$.each(this.opts.toolbar.formatting.dropdown,$.proxy(function(t){"-1"==$.inArray(t,this.opts.formattingTags)&&delete this.opts.toolbar.formatting.dropdown[t]},this)),0===this.opts.buttons.length?!1:(this.airEnable(),this.$toolbar=$("<ul>").addClass("redactor_toolbar").attr("id","redactor_toolbar_"+this.uuid),this.opts.typewriter&&this.$toolbar.addClass("redactor-toolbar-typewriter"),this.opts.toolbarOverflow&&this.isMobile()&&this.$toolbar.addClass("redactor-toolbar-overflow"),this.opts.air?(this.$air=$('<div class="redactor_air">').attr("id","redactor_air_"+this.uuid).hide(),this.$air.append(this.$toolbar),$("body").append(this.$air)):this.opts.toolbarExternal?(this.$toolbar.addClass("redactor-toolbar-external"),$(this.opts.toolbarExternal).html(this.$toolbar)):this.$box.prepend(this.$toolbar),$.each(this.opts.buttons,$.proxy(function(t,e){if(this.opts.toolbar[e]){var i=this.opts.toolbar[e];if(this.opts.fileUpload===!1&&"file"===e)return!0;this.$toolbar.append($("<li>").append(this.buttonBuild(e,i)))}},this)),this.$toolbar.find("a").attr("tabindex","-1"),this.opts.toolbarFixed&&(this.toolbarObserveScroll(),$(this.opts.toolbarFixedTarget).on("scroll.redactor",$.proxy(this.toolbarObserveScroll,this))),void(this.opts.activeButtons&&this.$editor.on("mouseup.redactor keyup.redactor",$.proxy(this.buttonActiveObserver,this))))},toolbarObserveScroll:function(){var t=$(this.opts.toolbarFixedTarget).scrollTop(),e=0,i=0,r=0;if(e=this.opts.toolbarFixedTarget===document?this.$box.offset().top:1,r=e+this.$box.height()+40,t>e){var o="100%";this.opts.toolbarFixedBox&&(i=this.$box.offset().left,o=this.$box.innerWidth(),this.$toolbar.addClass("toolbar_fixed_box")),this.toolbarFixed=!0,this.$toolbar.css(this.opts.toolbarFixedTarget===document?{position:"fixed",width:o,zIndex:10005,top:this.opts.toolbarFixedTopOffset+"px",left:i}:{position:"absolute",width:o,zIndex:10005,top:this.opts.toolbarFixedTopOffset+t+"px",left:0}),r>t?this.$toolbar.css("visibility","visible"):this.$toolbar.css("visibility","hidden")}else this.toolbarFixed=!1,this.$toolbar.css({position:"relative",width:"auto",top:0,left:i}),this.opts.toolbarFixedBox&&this.$toolbar.removeClass("toolbar_fixed_box")},airEnable:function(){this.opts.air&&this.$editor.on("mouseup.redactor keyup.redactor",this,$.proxy(function(t){var e=this.getSelectionText();if("mouseup"===t.type&&""!=e&&this.airShow(t),"keyup"===t.type&&t.shiftKey&&""!=e){var i=$(this.getElement(this.getSelection().focusNode)),r=i.offset();r.height=i.height(),this.airShow(r,!0)}},this))},airShow:function(t,e){if(this.opts.air){this.selectionSave();var i,r;if($(".redactor_air").hide(),e)i=t.left,r=t.top+t.height+14,this.opts.iframe&&(r+=this.$box.position().top-$(this.document).scrollTop(),i+=this.$box.position().left);else{var o=this.$air.innerWidth();i=t.clientX,$(this.document).width()<i+o&&(i-=o),r=t.clientY+14,this.opts.iframe?(r+=this.$box.position().top,i+=this.$box.position().left):r+=$(this.document).scrollTop()}this.$air.css({left:i+"px",top:r+"px"}).show(),this.airBindHide()}},airBindHide:function(){if(this.opts.air){var t=$.proxy(function(t){$(t).on("mousedown.redactor",$.proxy(function(e){0===$(e.target).closest(this.$toolbar).length&&(this.$air.fadeOut(100),this.selectionRemove(),$(t).off(e))},this)).on("keydown.redactor",$.proxy(function(e){e.which===this.keyCode.ESC&&this.getSelection().collapseToStart(),this.$air.fadeOut(100),$(t).off(e)},this))},this);t(document),this.opts.iframe&&t(this.document)}},airBindMousemoveHide:function(){if(this.opts.air){var t=$.proxy(function(t){$(t).on("mousemove.redactor",$.proxy(function(e){0===$(e.target).closest(this.$toolbar).length&&(this.$air.fadeOut(100),$(t).off(e))},this))},this);t(document),this.opts.iframe&&t(this.document)}},dropdownBuild:function(t,e){$.each(e,$.proxy(function(e,i){i.className||(i.className="");var r;"separator"===i.name?r=$('<a class="redactor_separator_drop">'):(r=$('<a href="#" class="'+i.className+" redactor_dropdown_"+e+'">'+i.title+"</a>"),r.on("click",$.proxy(function(t){this.opts.air&&this.selectionRestore(),t.preventDefault&&t.preventDefault(),this.browser("msie")&&(t.returnValue=!1),i.callback&&i.callback.call(this,e,r,i,t),i.exec&&this.execCommand(i.exec,e),i.func&&this[i.func](e),this.buttonActiveObserver(),this.opts.air&&this.$air.fadeOut(100)},this))),t.append(r)},this))},dropdownShow:function(t,e){if(!this.opts.visual)return t.preventDefault(),!1;var i=this.buttonGet(e),r=i.data("dropdown").appendTo(document.body);if(i.hasClass("dropact"))this.dropdownHideAll();else{this.dropdownHideAll(),this.callback("dropdownShow",{dropdown:r,key:e,button:i}),this.buttonActive(e),i.addClass("dropact");var o=i.offset(),s=r.width();o.left+s>$(document).width()&&(o.left-=s);var a=o.left+"px",n=i.innerHeight(),l="absolute",c=n+this.opts.toolbarFixedTopOffset+"px";this.opts.toolbarFixed&&this.toolbarFixed?l="fixed":c=o.top+n+"px",r.css({position:l,left:a,top:c}).show(),this.callback("dropdownShown",{dropdown:r,key:e,button:i})}var d=$.proxy(function(t){this.dropdownHide(t,r)},this);$(document).one("click",d),this.$editor.one("click",d),this.$editor.one("touchstart",d),t.stopPropagation(),this.focusWithSaveScroll()},dropdownHideAll:function(){this.$toolbar.find("a.dropact").removeClass("redactor_act").removeClass("dropact"),$(".redactor_dropdown").hide(),this.callback("dropdownHide")},dropdownHide:function(t,e){$(t.target).hasClass("dropact")||(e.removeClass("dropact"),this.dropdownHideAll())},buttonBuild:function(t,e,i){var r=$('<a href="javascript:;" title="'+e.title+'" tabindex="-1" class="re-icon re-'+t+'"></a>');if("undefined"!=typeof i&&r.addClass("redactor-btn-image"),r.on("click",$.proxy(function(i){return i.preventDefault&&i.preventDefault(),this.browser("msie")&&(i.returnValue=!1),r.hasClass("redactor_button_disabled")?!1:(this.isFocused()!==!1||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,r,e,i),this.airBindMousemoveHide()):e.dropdown&&this.dropdownShow(i,t),void this.buttonActiveObserver(!1,t))},this)),e.dropdown){var o=$('<div class="redactor_dropdown redactor_dropdown_box_'+t+'" style="display: none;">');r.data("dropdown",o),this.dropdownBuild(o,e.dropdown)}return r},buttonGet:function(t){return this.opts.toolbar?$(this.$toolbar.find("a.re-"+t)):!1},buttonTagToActiveState:function(t,e){this.opts.activeButtons.push(t),this.opts.activeButtonsStates[e]=t},buttonActiveToggle:function(t){var e=this.buttonGet(t);e.hasClass("redactor_act")?this.buttonInactive(t):this.buttonActive(t)},buttonActive:function(t){var e=this.buttonGet(t);e.addClass("redactor_act")},buttonInactive:function(t){var e=this.buttonGet(t);e.removeClass("redactor_act")},buttonInactiveAll:function(t){this.$toolbar.find("a.re-icon").not(".re-"+t).removeClass("redactor_act")},buttonActiveVisual:function(){this.$toolbar.find("a.re-icon").not("a.re-html").removeClass("redactor_button_disabled")},buttonInactiveVisual:function(){this.$toolbar.find("a.re-icon").not("a.re-html").addClass("redactor_button_disabled")},buttonChangeIcon:function(t,e){this.buttonGet(t).addClass("re-"+e)},buttonRemoveIcon:function(t,e){this.buttonGet(t).removeClass("re-"+e)},buttonAwesome:function(t,e){var i=this.buttonGet(t);i.removeClass("redactor-btn-image"),i.addClass("fa-redactor-btn"),i.html('<i class="fa '+e+'"></i>')},buttonAdd:function(t,e,i,r){if(this.opts.toolbar){var o=this.buttonBuild(t,{title:e,callback:i,dropdown:r},!0);return this.$toolbar.append($("<li>").append(o)),o}},buttonAddFirst:function(t,e,i,r){if(this.opts.toolbar){var o=this.buttonBuild(t,{title:e,callback:i,dropdown:r},!0);this.$toolbar.prepend($("<li>").append(o))}},buttonAddAfter:function(t,e,i,r,o){if(this.opts.toolbar){var s=this.buttonBuild(e,{title:i,callback:r,dropdown:o},!0),a=this.buttonGet(t);return 0!==a.size()?a.parent().after($("<li>").append(s)):this.$toolbar.append($("<li>").append(s)),s}},buttonAddBefore:function(t,e,i,r,o){if(this.opts.toolbar){var s=this.buttonBuild(e,{title:i,callback:r,dropdown:o},!0),a=this.buttonGet(t);return 0!==a.size()?a.parent().before($("<li>").append(s)):this.$toolbar.append($("<li>").append(s)),s}},buttonRemove:function(t){var e=this.buttonGet(t);e.remove()},buttonActiveObserver:function(t,e){var i=this.getParent();if(this.buttonInactiveAll(e),t===!1&&"html"!==e)return void(-1!=$.inArray(e,this.opts.activeButtons)&&this.buttonActiveToggle(e));this.$toolbar.find("a.redactor_dropdown_link").text(i&&"A"===i.tagName?this.opts.curLang.link_edit:this.opts.curLang.link_insert),$.each(this.opts.activeButtonsStates,$.proxy(function(t,e){0!=$(i).closest(t,this.$editor.get()[0]).length&&this.buttonActive(e)},this));var r=$(i).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);if(r.length){var o=r.css("text-align");""==o&&(o="left"),this.buttonActive("align"+o)}},execPasteFrag:function(t){var e=this.getSelection();if(e.getRangeAt&&e.rangeCount){var i=this.getRange();i.deleteContents();var r=this.document.createElement("div");r.innerHTML=t;for(var o,s,a=this.document.createDocumentFragment();o=r.firstChild;)s=a.appendChild(o);{a.firstChild}i.insertNode(a),s&&(i=i.cloneRange(),i.setStartAfter(s),i.collapse(!0)),e.removeAllRanges(),e.addRange(i)}},exec:function(t,e,i){"formatblock"===t&&this.browser("msie")&&(e="<"+e+">"),"inserthtml"===t&&this.browser("msie")?this.isIe11()?this.execPasteFrag(e):(this.focusWithSaveScroll(),this.document.selection.createRange().pasteHTML(e)):this.document.execCommand(t,!1,e),i!==!1&&this.sync(),this.callback("execCommand",t,e)},execCommand:function(t,e,i){if(!this.opts.visual)return this.$source.focus(),!1;if(("bold"===t||"italic"===t||"underline"===t||"strikethrough"===t)&&this.bufferSet(),"superscript"===t||"subscript"===t){var r=this.getParent();("SUP"===r.tagName||"SUB"===r.tagName)&&this.inlineRemoveFormatReplace(r)}return"inserthtml"===t?(this.insertHtml(e,i),void this.callback("execCommand",t,e)):this.currentOrParentIs("PRE")&&!this.opts.formattingPre?!1:"insertunorderedlist"===t||"insertorderedlist"===t?this.execLists(t,e):"unlink"===t?this.execUnlink(t,e):(this.exec(t,e,i),void("inserthorizontalrule"===t&&this.$editor.find("hr").removeAttr("id")))},execUnlink:function(t,e){this.bufferSet();var i=this.currentOrParentIs("A");return i?($(i).replaceWith($(i).text()),this.sync(),void this.callback("execCommand",t,e)):void 0},execLists:function(t,e){this.bufferSet();var i=this.getParent(),r=$(i).closest("ol, ul");this.isParentRedactor(r)||0==r.size()||(r=!1);var o=!1;if(r&&r.length){o=!0;var s=r[0].tagName;("insertunorderedlist"===t&&"OL"===s||"insertorderedlist"===t&&"UL"===s)&&(o=!1)}if(this.selectionSave(),o){var a=this.getNodes(),n=this.getBlocks(a);"undefined"!=typeof a[0]&&a.length>1&&3==a[0].nodeType&&n.unshift(this.getBlock());var l="",c="";$.each(n,$.proxy(function(t,e){if("LI"==e.tagName){var i=$(e),r=i.clone();if(r.find("ul","ol").remove(),this.opts.linebreaks===!1)l+=this.outerHtml($("<p>").append(r.contents()));else{var o=r.html().replace(/<br\s?\/?>$/i,"");l+=o+"<br>"}0==t?(i.addClass("redactor-replaced").empty(),c=this.outerHtml(i)):i.remove()}},this)),html=this.$editor.html().replace(c,"</"+s+">"+l+"<"+s+">"),this.$editor.html(html),this.$editor.find(s+":empty").remove()}else{var d=$(this.getParent()).closest("td");if(this.browser("msie")&&!this.isIe11()&&this.opts.linebreaks){var h=this.selectionWrap("div"),p=$(h).html(),u=$("<ul>");"insertorderedlist"==t&&(u=$("<ol>"));var f=$("<li>");""==$.trim(p)?(f.append(p+'<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),u.append(f),this.$editor.find("#selection-marker-1").replaceWith(u)):(f.append(p),u.append(f),$(h).replaceWith(u))}else this.document.execCommand(t);var i=this.getParent(),r=$(i).closest("ol, ul");if(this.opts.linebreaks===!1){var m=$.trim(r.text());""==m&&(r.children("li").find("br").remove(),r.children("li").append('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"))}if(0!=d.size()&&r.wrapAll("<td>"),r.length){var g=r.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 i=this.getParent(),r=$(i).closest("ol, ul"),o=r[0].tagName,s=this.getBlocks();$.each(s,function(t,e){if("LI"==e.tagName){var i=$(e).prev();if(0!=i.size()&&"LI"==i[0].tagName){var r=i.children("ul, ol");0==r.size()?i.append($("<"+o+">").append(e)):r.append(e)}}})}else if(e===!1&&this.opts.linebreaks===!0){this.exec("formatBlock","blockquote");var a=this.getBlock(),e=$('<div data-tagblock="">').html($(a).html());$(a).replaceWith(e);var n=this.normalize($(e).css("margin-left"))+this.opts.indentValue;$(e).css("margin-left",n+"px")}else{var l=this.getBlocks();$.each(l,$.proxy(function(t,e){var i=!1;if("TD"!==e.tagName){i=-1!==$.inArray(e.tagName,this.opts.alignmentTags)?$(e):$(e).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);var r=this.normalize(i.css("margin-left"))+this.opts.indentValue;i.css("margin-left",r+"px")}},this))}this.selectionRestore()}else{this.selectionSave();var e=this.getBlock();if(e&&"LI"==e.tagName){var s=this.getBlocks(),c=0;this.insideOutdent(e,c,s)}else{var l=this.getBlocks();$.each(l,$.proxy(function(t,e){var i=!1;i=-1!==$.inArray(e.tagName,this.opts.alignmentTags)?$(e):$(e).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);var r=this.normalize(i.css("margin-left"))-this.opts.indentValue;0>=r?this.opts.linebreaks===!0&&"undefined"!=typeof i.data("tagblock")?i.replaceWith(i.html()+"<br>"):(i.css("margin-left",""),this.removeEmptyAttr(i,"style")):i.css("margin-left",r+"px")},this))}this.selectionRestore()}this.sync()},insideOutdent:function(t,e,i){if(t&&"LI"==t.tagName){var r=$(t).parent().parent();0!=r.size()&&"LI"==r[0].tagName?r.after(t):"undefined"!=typeof i[e]?(t=i[e],e++,this.insideOutdent(t,e,i)):this.execCommand("insertunorderedlist")}},alignmentLeft:function(){this.alignmentSet("","JustifyLeft")},alignmentRight:function(){this.alignmentSet("right","JustifyRight")},alignmentCenter:function(){this.alignmentSet("center","JustifyCenter")},alignmentJustify:function(){this.alignmentSet("justify","JustifyFull")},alignmentSet:function(t,e){if(this.bufferSet(),this.oldIE())return this.document.execCommand(e,!1,!1),!0;this.selectionSave();var i=this.getBlock();if(!i&&this.opts.linebreaks){this.exec("formatblock","div");var r=this.getBlock(),i=$('<div data-tagblock="">').html($(r).html());$(r).replaceWith(i),$(i).css("text-align",t),this.removeEmptyAttr(i,"style"),""==t&&"undefined"!=typeof $(i).data("tagblock")&&$(i).replaceWith($(i).html())}else{var o=this.getBlocks();$.each(o,$.proxy(function(e,i){var r=!1;r=-1!==$.inArray(i.tagName,this.opts.alignmentTags)?$(i):$(i).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]),r&&(r.css("text-align",t),this.removeEmptyAttr(r,"style"))},this))}this.selectionRestore(),this.sync()},cleanEmpty:function(t){var e=this.placeholderStart(t);return e!==!1?e:(this.opts.linebreaks===!1&&(""===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.replace(/\{\{(.*?)\}\}/gi,"<!-- template double $1 -->"),t=t.replace(/\{(.*?)\}/gi,"<!-- template $1 -->")),t=t.replace(/<script(.*?)>([\w\W]*?)<\/script>/gi,'<title type="text/javascript" style="display: none;" class="redactor-script-tag"$1>$2</title>'),t=t.replace(/<style(.*?)>([\w\W]*?)<\/style>/gi,'<section$1 style="display: none;" rel="redactor-style-tag">$2</section>'),t=t.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.replace(/<!-- template double (.*?) -->/gi,"{{$1}}"),t=t.replace(/<!-- template (.*?) -->/gi,"{$1}")),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>'),t=t.replace(/<section(.*?) style="display: none;" rel="redactor-style-tag">([\w\W]*?)<\/section>/gi,"<style$1>$2</style>"),t=t.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(e!==!1){var e=[],i=t.match(/<(pre|style|script|title)(.*?)>([\w\W]*?)<\/(pre|style|script|title)>/gi);if(null===i&&(i=[]),this.opts.phpTags){var r=t.match(/<\?php([\w\W]*?)\?>/gi);r&&(i=$.merge(i,r))}i&&$.each(i,function(i,r){t=t.replace(r,"buffer_"+i),e.push(r)})}return t=t.replace(/\n/g," "),t=t.replace(/[\t]*/g,""),t=t.replace(/\n\s*\n/g,"\n"),t=t.replace(/^[\s\n]*/g," "),t=t.replace(/[\s\n]*$/g," "),t=t.replace(/>\s{2,}</g,"> <"),t=this.cleanReplacer(t,e),t=t.replace(/\n\n/g,"\n")},cleanReplacer:function(t,e){return e===!1?t:($.each(e,function(e,i){t=t.replace("buffer_"+e,i)}),t)},cleanRemoveEmptyTags:function(t){t=t.replace(/[\u200B-\u200D\uFEFF]/g,"");var e=["<b>\\s*</b>","<b>&nbsp;</b>","<em>\\s*</em>"],i=["<pre></pre>","<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>"];i=this.opts.removeEmptyTags?i.concat(e):e;for(var r=i.length,o=0;r>o;++o)t=t.replace(new RegExp(i[o],"gi"),"");return t},cleanParagraphy:function(t){function e(e,i,r){return t.replace(new RegExp(e,i),r)}if(t=$.trim(t),this.opts.linebreaks===!0)return t;if(""===t||"<p></p>"===t)return this.opts.emptyHtml;if(t+="\n",this.opts.removeEmptyTags===!1)return t;var i=[],r=t.match(/<(table|div|pre|object)(.*?)>([\w\W]*?)<\/(table|div|pre|object)>/gi);r||(r=[]);var o=t.match(/<!--([\w\W]*?)-->/gi);if(o&&(r=$.merge(r,o)),this.opts.phpTags){var s=t.match(/<section(.*?)rel="redactor-php-tag">([\w\W]*?)<\/section>/gi);s&&(r=$.merge(r,s))}r&&$.each(r,function(e,r){i[e]=r,t=t.replace(r,"{replace"+e+"}\n")}),t=t.replace(/<br \/>\s*<br \/>/gi,"\n\n"),t=t.replace(/<br><br>/gi,"\n\n");var a="(comment|html|body|head|title|meta|style|script|link|iframe|table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|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=e("(<"+a+"[^>]*>)","gi","\n$1"),t=e("(</"+a+">)","gi","$1\n\n"),t=e("\r\n","g","\n"),t=e("\r","g","\n"),t=e("/\n\n+/","g","\n\n");var n=t.split(new RegExp("\ns*\n","g"),-1);t="";for(var l in n)n.hasOwnProperty(l)&&(-1==n[l].search("{replace")?(n[l]=n[l].replace(/<p>\n\t?<\/p>/gi,""),n[l]=n[l].replace(/<p><\/p>/gi,""),""!=n[l]&&(t+="<p>"+n[l].replace(/^\n+|\n+$/g,"")+"</p>")):t+=n[l]);return t=e("<p><p>","gi","<p>"),t=e("</p></p>","gi","</p>"),t=e("<p>s?</p>","gi",""),t=e("<p>([^<]+)</(div|address|form)>","gi","<p>$1</p></$2>"),t=e("<p>(</?"+a+"[^>]*>)</p>","gi","$1"),t=e("<p>(<li.+?)</p>","gi","$1"),t=e("<p>s?(</?"+a+"[^>]*>)","gi","$1"),t=e("(</?"+a+"[^>]*>)s?</p>","gi","$1"),t=e("(</?"+a+"[^>]*>)s?<br />","gi","$1"),t=e("<br />(s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)","gi","$1"),t=e("\n</p>","gi","</p>"),t=e("<li><p>","gi","<li>"),t=e("</p></li>","gi","</li>"),t=e("</li><p>","gi","</li>"),t=e("<p>	?\n?<p>","gi","<p>"),t=e("</dt><p>","gi","</dt>"),t=e("</dd><p>","gi","</dd>"),t=e("<br></p></blockquote>","gi","</blockquote>"),t=e("<p>	*</p>","gi",""),$.each(i,function(e,i){t=t.replace("{replace"+e+"}",i)}),$.trim(t)},cleanConvertInlineTags:function(t,e){var i="strong";"b"===this.opts.boldTag&&(i="b");var r="em";return"i"===this.opts.italicTag&&(r="i"),t=t.replace(/<span style="font-style: italic;">([\w\W]*?)<\/span>/gi,"<"+r+">$1</"+r+">"),t=t.replace(/<span style="font-weight: bold;">([\w\W]*?)<\/span>/gi,"<"+i+">$1</"+i+">"),t="strong"===this.opts.boldTag?t.replace(/<b>([\w\W]*?)<\/b>/gi,"<strong>$1</strong>"):t.replace(/<strong>([\w\W]*?)<\/strong>/gi,"<b>$1</b>"),t="em"===this.opts.italicTag?t.replace(/<i>([\w\W]*?)<\/i>/gi,"<em>$1</em>"):t.replace(/<em>([\w\W]*?)<\/em>/gi,"<i>$1</i>"),t=t.replace(/<span style="text-decoration: underline;">([\w\W]*?)<\/span>/gi,"<u>$1</u>"),t=e!==!0?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||"undefined"==typeof t)return t;var e=!1;this.opts.allowedTags!==!1&&(e=!0);var i=e===!0?this.opts.allowedTags:this.opts.deniedTags,r=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;return t=t.replace(r,function(t,r){return e===!0?$.inArray(r.toLowerCase(),i)>"-1"?t:"":$.inArray(r.toLowerCase(),i)>"-1"?"":t}),t=this.cleanConvertInlineTags(t)},cleanSavePreCode:function(t,e){var i=t.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/gi);return null!==i&&$.each(i,$.proxy(function(i,r){var o=r.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/i);
o[3]=o[3].replace(/&nbsp;/g," "),e!==!1&&(o[3]=this.cleanEncodeEntities(o[3])),o[3]=o[3].replace(/\$/g,"&#36;"),t=t.replace(r,"<"+o[1]+o[2]+">"+o[3]+"</"+o[1]+">")},this)),t},cleanEncodeEntities:function(t){return t=String(t).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"'),t.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=0,i=t.length,r=0,o=null,s=null,a="",n="",l="";for(this.cleanlevel=0;i>e;e++){if(r=e,-1==t.substr(e).indexOf("<"))return n+=t.substr(e),this.cleanFinish(n);for(;i>r&&"<"!=t.charAt(r);)r++;for(e!=r&&(l=t.substr(e,r-e),l.match(/^\s{2,}$/g)||("\n"==n.charAt(n.length-1)?n+=this.cleanGetTabs():"\n"==l.charAt(0)&&(n+="\n"+this.cleanGetTabs(),l=l.replace(/^\s+/,"")),n+=l),l.match(/\n/)&&(n+="\n"+this.cleanGetTabs())),o=r;i>r&&">"!=t.charAt(r);)r++;a=t.substr(o,r-o),e=r;var c;if("!--"==a.substr(1,3)){if(!a.match(/--$/)){for(;"-->"!=t.substr(r,3);)r++;r+=2,a=t.substr(o,r-o),e=r}"\n"!=n.charAt(n.length-1)&&(n+="\n"),n+=this.cleanGetTabs(),n+=a+">\n"}else"!"==a[1]?n=this.placeTag(a+">",n):"?"==a[1]?n+=a+">\n":(c=a.match(/^<(script|style|pre)/i))?(c[1]=c[1].toLowerCase(),a=this.cleanTag(a),n=this.placeTag(a,n),s=String(t.substr(e+1)).toLowerCase().indexOf("</"+c[1]),s&&(l=t.substr(e+1,s),e+=s,n+=l)):(a=this.cleanTag(a),n=this.placeTag(a,n))}return this.cleanFinish(n)},cleanGetTabs:function(){for(var t="",e=0;e<this.cleanlevel;e++)t+="	";return t},cleanFinish:function(t){return t=t.replace(/\n\s*\n/g,"\n"),t=t.replace(/^[\s\n]*/,""),t=t.replace(/[\s\n]*$/,""),t=t.replace(/<script(.*?)>\n<\/script>/gi,"<script$1></script>"),this.cleanlevel=0,t},cleanTag:function(t){var e="";t=t.replace(/\n/g," "),t=t.replace(/\s{2,}/g," "),t=t.replace(/^\s+|\s+$/g," ");var i="";t.match(/\/$/)&&(i="/",t=t.replace(/\/+$/,""));for(var r;r=/\s*([^= ]+)(?:=((['"']).*?\3|[^ ]+))?/.exec(t);)r[2]?e+=r[1].toLowerCase()+"="+r[2]:r[1]&&(e+=r[1].toLowerCase()),e+=" ",t=t.substr(r[0].length);return e.replace(/\s*$/,"")+i+">"},placeTag:function(t,e){var i=t.match(this.cleannewLevel);return(t.match(this.cleanlineBefore)||i)&&(e=e.replace(/\s*$/,""),e+="\n"),i&&"/"==t.charAt(1)&&this.cleanlevel--,"\n"==e.charAt(e.length-1)&&(e+=this.cleanGetTabs()),i&&"/"!=t.charAt(1)&&this.cleanlevel++,e+=t,(t.match(this.cleanlineAfter)||t.match(this.cleannewLevel))&&(e=e.replace(/ *$/,""),e+="\n"),e},formatEmpty:function(t){var e=$.trim(this.$editor.html());if(this.opts.linebreaks)""==e&&(t.preventDefault(),this.$editor.html(""),this.focus());else{e=e.replace(/<br\s?\/?>/i,"");var i=e.replace(/<p>\s?<\/p>/gi,"");if(""===e||""===i){t.preventDefault();var r=$(this.opts.emptyHtml).get(0);this.$editor.html(r),this.focus()}}this.sync()},formatBlocks:function(t){this.browser("mozilla")&&this.isFocused()&&this.$editor.focus(),this.bufferSet();var e=this.getBlocks();this.selectionSave(),$.each(e,$.proxy(function(e,i){if("LI"!==i.tagName){var r=$(i).parent();if("p"===t){if("P"===i.tagName&&0!=r.size()&&"BLOCKQUOTE"===r[0].tagName||"BLOCKQUOTE"===i.tagName)return void this.formatQuote();if(this.opts.linebreaks){if(!i||0!=i.tagName.search(/H[1-6]/))return;$(i).replaceWith(i.innerHTML+"<br>")}else this.formatBlock(t,i)}else this.formatBlock(t,i)}},this)),this.selectionRestore(),this.sync()},formatBlock:function(t,e){if(e===!1&&(e=this.getBlock()),e===!1&&this.opts.linebreaks===!0)return this.execCommand("formatblock",t),!0;var i="";if("pre"!==t?i=$(e).contents():(i=$(e).html(),""===$.trim(i)&&(i='<span id="selection-marker-1"></span>')),"PRE"===e.tagName&&(t="p"),this.opts.linebreaks===!0&&"p"===t)$(e).replaceWith($("<div>").append(i).html()+"<br>");else{var r=this.getParent(),o=$("<"+t+">").append(i);$(e).replaceWith(o),r&&"TD"==r.tagName&&$(o).wrapAll("<td>")}},formatChangeTag:function(t,e,i){i!==!1&&this.selectionSave();var r=$("<"+e+"/>");return $(t).replaceWith(function(){return r.append($(this).contents())}),i!==!1&&this.selectionRestore(),r},formatQuote:function(){if(this.browser("mozilla")&&this.isFocused()&&this.$editor.focus(),this.bufferSet(),this.opts.linebreaks===!1){this.selectionSave();var t=this.getBlocks(),e=!1,i=t.length;if(t){var r="",o="",s=!1,a=!0;if($.each(t,function(t,e){"P"!==e.tagName&&(a=!1)}),$.each(t,$.proxy(function(n,l){if("BLOCKQUOTE"===l.tagName)this.formatBlock("p",l,!1);else if("P"===l.tagName)if(e=$(l).parent(),"BLOCKQUOTE"==e[0].tagName){var c=$(e).children("p").size();1==c?$(e).replaceWith(l):c==i?(s="blockquote",r+=this.outerHtml(l)):(s="html",r+=this.outerHtml(l),0==n?($(l).addClass("redactor-replaced").empty(),o=this.outerHtml(l)):$(l).remove())}else a===!1||1==t.length?this.formatBlock("blockquote",l,!1):(s="paragraphs",r+=this.outerHtml(l));else"LI"!==l.tagName&&this.formatBlock("blockquote",l,!1)},this)),s)if("paragraphs"==s)$(t[0]).replaceWith("<blockquote>"+r+"</blockquote>"),$(t).remove();else if("blockquote"==s)$(e).replaceWith(r);else if("html"==s){var n=this.$editor.html().replace(o,"</blockquote>"+r+"<blockquote>");this.$editor.html(n),this.$editor.find("blockquote").each(function(){""==$.trim($(this).html())&&$(this).remove()})}}this.selectionRestore()}else{var l=this.getBlock();if("BLOCKQUOTE"===l.tagName){this.selectionSave();var n=$.trim($(l).html()),c=$.trim(this.getSelectionHtml());if(n=n.replace(/<span(.*?)id="selection-marker(.*?)<\/span>/gi,""),n==c)$(l).replaceWith($(l).html()+"<br>");else{this.inlineFormat("tmp");var d=this.$editor.find("tmp");d.empty();var h=this.$editor.html().replace("<tmp></tmp>",'</blockquote><span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"+c+"<blockquote>");this.$editor.html(h),d.remove(),this.$editor.find("blockquote").each(function(){""==$.trim($(this).html())&&$(this).remove()})}this.selectionRestore(),this.$editor.find("span#selection-marker-1").attr("id",!1)}else{var p=this.selectionWrap("blockquote"),n=$(p).html(),u=["ul","ol","table","tr","tbody","thead","tfoot","dl"];$.each(u,function(t,e){n=n.replace(new RegExp("<"+e+"(.*?)>","gi"),""),n=n.replace(new RegExp("</"+e+">","gi"),"")});var f=this.opts.blockLevelElements;$.each(f,function(t,e){n=n.replace(new RegExp("<"+e+"(.*?)>","gi"),""),n=n.replace(new RegExp("</"+e+">","gi"),"<br>")}),$(p).html(n),this.selectionElement(p);var m=$(p).next();0!=m.size()&&"BR"===m[0].tagName&&m.remove()}}this.sync()},blockRemoveAttr:function(t){var e=this.getBlocks();$(e).removeAttr(t),this.sync()},blockSetAttr:function(t,e){var i=this.getBlocks();$(i).attr(t,e),this.sync()},blockRemoveStyle:function(t){var e=this.getBlocks();$(e).css(t,""),this.removeEmptyAttr(e,"style"),this.sync()},blockSetStyle:function(t,e){var i=this.getBlocks();$(i).css(t,e),this.sync()},blockRemoveClass:function(t){var e=this.getBlocks();$(e).removeClass(t),this.removeEmptyAttr(e,"class"),this.sync()},blockSetClass:function(t){var e=this.getBlocks();$(e).addClass(t),this.sync()},inlineRemoveClass:function(t){this.selectionSave(),this.inlineEachNodes(function(e){$(e).removeClass(t),this.removeEmptyAttr(e,"class")}),this.selectionRestore(),this.sync()},inlineSetClass:function(t){var e=this.getCurrent();$(e).hasClass(t)||this.inlineMethods("addClass",t)},inlineRemoveStyle:function(t){this.selectionSave(),this.inlineEachNodes(function(e){$(e).css(t,""),this.removeEmptyAttr(e,"style")}),this.selectionRestore(),this.sync()},inlineSetStyle:function(t,e){this.inlineMethods("css",t,e)},inlineRemoveAttr:function(t){this.selectionSave();var e=this.getRange(),i=this.getElement(),r=this.getNodes();(e.collapsed||e.startContainer===e.endContainer&&i)&&(r=$(i)),$(r).removeAttr(t),this.inlineUnwrapSpan(),this.selectionRestore(),this.sync()},inlineSetAttr:function(t,e){this.inlineMethods("attr",t,e)},inlineMethods:function(t,e,i){this.bufferSet(),this.selectionSave();var r=this.getRange(),o=this.getElement();if(!r.collapsed&&r.startContainer!==r.endContainer||!o||this.nodeTestBlocks(o)){var s,a=i;switch(e){case"font-size":s="fontSize",a=4;break;case"font-family":s="fontName";break;case"color":s="foreColor";break;case"background-color":s="backColor"}this.document.execCommand(s,!1,a);var n=this.$editor.find("font");$.each(n,$.proxy(function(r,o){this.inlineSetMethods(t,o,e,i)},this))}else $(o)[t](e,i);this.selectionRestore(),this.sync()},inlineSetMethods:function(t,e,i,r){var o,s=$(e).parent(),a=this.getSelectionText(),n=$(s).text(),l=a==n;return l&&s&&"INLINE"===s[0].tagName&&0!=s[0].attributes.length?(o=s,$(e).replaceWith($(e).html())):(o=$("<inline>").append($(e).contents()),$(e).replaceWith(o)),$(o)[t](i,r),o},inlineEachNodes:function(t){var e,i=this.getRange(),r=this.getElement(),o=this.getNodes();(i.collapsed||i.startContainer===i.endContainer&&r)&&(o=$(r),e=!0),$.each(o,$.proxy(function(i,r){if(!e&&"INLINE"!==r.tagName){var o=this.getSelectionText(),s=$(r).parent().text(),a=o==s;if(!a||"INLINE"!==r.parentNode.tagName||$(r.parentNode).hasClass("redactor_editor"))return;r=r.parentNode}t.call(this,r)},this))},inlineUnwrapSpan:function(){var t=this.$editor.find("inline");$.each(t,$.proxy(function(t,e){var i=$(e);void 0===i.attr("class")&&void 0===i.attr("style")&&i.contents().unwrap()},this))},inlineFormat:function(t){this.selectionSave(),this.document.execCommand("fontSize",!1,4);var e,i=this.$editor.find("font");$.each(i,function(i,r){var o=$("<"+t+"/>").append($(r).contents());$(r).replaceWith(o),e=o}),this.selectionRestore(),this.sync()},inlineRemoveFormat:function(t){this.selectionSave();var e=t.toUpperCase(),i=this.getNodes(),r=$(this.getParent()).parent();$.each(i,function(t,i){i.tagName===e&&this.inlineRemoveFormatReplace(i)}),r&&r[0].tagName===e&&this.inlineRemoveFormatReplace(r),this.selectionRestore(),this.sync()},inlineRemoveFormatReplace:function(t){$(t).replaceWith($(t).contents())},insertHtml:function(t,e){var i=this.getCurrent(),r=i.parentNode;this.focusWithSaveScroll(),this.bufferSet();var o=$("<div>").append($.parseHTML(t));t=o.html(),t=this.cleanRemoveEmptyTags(t),o=$("<div>").append($.parseHTML(t));var s=this.getBlock();if(1==o.contents().length){var a=o.contents()[0].tagName;("P"!=a&&a==s.tagName||"PRE"==a)&&(o=$("<div>").append(t))}this.opts.linebreaks&&(t=t.replace(/<p(.*?)>([\w\W]*?)<\/p>/gi,"$2<br>")),!this.opts.linebreaks&&1==o.contents().length&&3==o.contents()[0].nodeType&&(this.getRangeSelectedNodes().length>2||!i||"BODY"==i.tagName&&!r||"HTML"==r.tagName)&&(t="<p>"+t+"</p>"),t=this.setSpansVerifiedHtml(t),o.contents().length>1&&s||o.contents().is("p, :header, ul, ol, li, div, table, td, blockquote, pre, 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(),e!==!1&&this.sync()},insertHtmlAdvanced:function(t,e){t=this.setSpansVerifiedHtml(t);var i=this.getSelection();if(i.getRangeAt&&i.rangeCount){var r=i.getRangeAt(0);r.deleteContents();var o=this.document.createElement("div");o.innerHTML=t;for(var s,a,n=this.document.createDocumentFragment();s=o.firstChild;)a=n.appendChild(s);r.insertNode(n),a&&(r=r.cloneRange(),r.setStartAfter(a),r.collapse(!0),i.removeAllRanges(),i.addRange(r))}e!==!1&&this.sync()},insertBeforeCursor:function(t){t=this.setSpansVerifiedHtml(t);var e=$(t),i=document.createElement("span");i.innerHTML="​";var r=this.getRange();r.insertNode(i),r.insertNode(e[0]),r.collapse(!1);var o=this.getSelection();o.removeAllRanges(),o.addRange(r),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(t=t[0]||t,"SPAN"==t.tagName){var e="inline",i=t.outerHTML,r=new RegExp("<"+t.tagName,"i"),o=i.replace(r,"<"+e);r=new RegExp("</"+t.tagName,"i"),o=o.replace(r,"</"+e),t=$(o)[0]}var s=this.getSelection();return s.getRangeAt&&s.rangeCount&&(range=s.getRangeAt(0),range.deleteContents(),range.insertNode(t),range.setEndAfter(t),range.setStartAfter(t),s.removeAllRanges(),s.addRange(range)),t},insertNodeToCaretPositionFromPoint:function(t,e){var i,r=t.clientX,o=t.clientY;if(this.document.caretPositionFromPoint){var s=this.document.caretPositionFromPoint(r,o);i=this.getRange(),i.setStart(s.offsetNode,s.offset),i.collapse(!0),i.insertNode(e)}else if(this.document.caretRangeFromPoint)i=this.document.caretRangeFromPoint(r,o),i.insertNode(e);else if("undefined"!=typeof document.body.createTextRange){i=this.document.body.createTextRange(),i.moveToPoint(r,o);var a=i.duplicate();a.moveToPoint(r,o),i.setEndPoint("EndToEnd",a),i.select()}},insertAfterLastElement:function(t,e){if("undefined"!=typeof e&&(t=e),this.isEndOfElement()){if(this.opts.linebreaks){var i=$("<div>").append($.trim(this.$editor.html())).contents(),r=i.last()[0];if("SPAN"==r.tagName&&""==r.innerHTML&&(r=i.prev()[0]),this.outerHtml(r)!=this.outerHtml(t))return!1}else if(this.$editor.contents().last()[0]!==t)return!1;this.insertingAfterLastElement(t)}},insertingAfterLastElement:function(t){if(this.bufferSet(),this.opts.linebreaks===!1){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(1==t&&(e="<br><br>"),this.browser("mozilla")){var i=$("<span>").html(this.opts.invisibleSpace);this.$editor.find("#selection-marker-1").before(e).before(i).before(this.opts.invisibleSpace),this.setCaretAfter(i[0]),i.remove(),this.selectionRemoveMarkers()}else{var r=this.getParent();if(r&&"A"===r.tagName){var o=this.getCaretOffset(r),s=$.trim($(r).text()).replace(/\n\r\n/g,""),a=s.length;if(o==a){this.selectionRemoveMarkers();var n=$('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>",this.document)[0];return $(r).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(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=$.trim(t),t=t.replace("\n","<br>"),t=this.cleanParagraphy(t),this.pasteInsert(t),!1}var i=!1;if(this.currentOrParentIs("TD")){i=!0;var r=this.opts.blockLevelElements;r.push("tr"),r.push("table"),$.each(r,function(e,i){t=t.replace(new RegExp("<"+i+"(.*?)>","gi"),""),t=t.replace(new RegExp("</"+i+">","gi"),"<br>")})}if(this.currentOrParentIs("PRE"))return t=this.pastePre(t),this.pasteInsert(t),!0;if(t=t.replace(/<img(.*?)v:shapes=(.*?)>/gi,""),t=t.replace(/<p(.*?)class="MsoListParagraphCxSpFirst"([\w\W]*?)<\/p>/gi,"<ul><li$2</li>"),t=t.replace(/<p(.*?)class="MsoListParagraphCxSpMiddle"([\w\W]*?)<\/p>/gi,"<li$2</li>"),t=t.replace(/<p(.*?)class="MsoListParagraphCxSpLast"([\w\W]*?)<\/p>/gi,"<li$2</li></ul>"),t=t.replace(/<p(.*?)class="MsoListParagraph"([\w\W]*?)<\/p>/gi,"<ul><li$2</li></ul>"),t=t.replace(/Â·/g,""),t=t.replace(/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi,""),this.opts.cleanSpaces===!0&&(t=t.replace(/(&nbsp;){2,}/gi,"&nbsp;"),t=t.replace(/&nbsp;/gi," ")),t=t.replace(/<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2"),t=t.replace(/<b(.*?)id="docs-internal-guid(.*?)">([\w\W]*?)<\/b>/gi,"$3"),t=t.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;">'),t=t.replace(/<span[^>]*font-style: italic[^>]*>/gi,'<span style="font-style: italic;">'),t=t.replace(/<span[^>]*font-weight: bold[^>]*>/gi,'<span style="font-weight: bold;">'),t=t.replace(/<span[^>]*text-decoration: underline[^>]*>/gi,'<span style="text-decoration: underline;">'),t=t.replace(/<td>\u200b*<\/td>/gi,"[td]"),t=t.replace(/<td>&nbsp;<\/td>/gi,"[td]"),t=t.replace(/<td><br><\/td>/gi,"[td]"),t=t.replace(/<td(.*?)colspan="(.*?)"(.*?)>([\w\W]*?)<\/td>/gi,'[td colspan="$2"]$4[/td]'),t=t.replace(/<td(.*?)rowspan="(.*?)"(.*?)>([\w\W]*?)<\/td>/gi,'[td rowspan="$2"]$4[/td]'),t=t.replace(/<a(.*?)href="(.*?)"(.*?)>([\w\W]*?)<\/a>/gi,'[a href="$2"]$4[/a]'),t=t.replace(/<iframe(.*?)>([\w\W]*?)<\/iframe>/gi,"[iframe$1]$2[/iframe]"),t=t.replace(/<video(.*?)>([\w\W]*?)<\/video>/gi,"[video$1]$2[/video]"),t=t.replace(/<audio(.*?)>([\w\W]*?)<\/audio>/gi,"[audio$1]$2[/audio]"),t=t.replace(/<embed(.*?)>([\w\W]*?)<\/embed>/gi,"[embed$1]$2[/embed]"),t=t.replace(/<object(.*?)>([\w\W]*?)<\/object>/gi,"[object$1]$2[/object]"),t=t.replace(/<param(.*?)>/gi,"[param$1]"),t=t.replace(/<img(.*?)>/gi,"[img$1]"),t=t.replace(/ class="(.*?)"/gi,""),t=t.replace(/<(\w+)([\w\W]*?)>/gi,"<$1>"),this.opts.linebreaks?(t=t.replace(/<strong><\/strong>/gi,""),t=t.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.replace(/<div>\s*?\t*?\n*?(<ul>|<ol>|<p>)/gi,"$1"),t=t.replace(/\[td colspan="(.*?)"\]([\w\W]*?)\[\/td\]/gi,'<td colspan="$1">$2</td>'),t=t.replace(/\[td rowspan="(.*?)"\]([\w\W]*?)\[\/td\]/gi,'<td rowspan="$1">$2</td>'),t=t.replace(/\[td\]/gi,"<td>&nbsp;</td>"),t=t.replace(/\[a href="(.*?)"\]([\w\W]*?)\[\/a\]/gi,'<a href="$1">$2</a>'),t=t.replace(/\[iframe(.*?)\]([\w\W]*?)\[\/iframe\]/gi,"<iframe$1>$2</iframe>"),t=t.replace(/\[video(.*?)\]([\w\W]*?)\[\/video\]/gi,"<video$1>$2</video>"),t=t.replace(/\[audio(.*?)\]([\w\W]*?)\[\/audio\]/gi,"<audio$1>$2</audio>"),t=t.replace(/\[embed(.*?)\]([\w\W]*?)\[\/embed\]/gi,"<embed$1>$2</embed>"),t=t.replace(/\[object(.*?)\]([\w\W]*?)\[\/object\]/gi,"<object$1>$2</object>"),t=t.replace(/\[param(.*?)\]/gi,"<param$1>"),t=t.replace(/\[img(.*?)\]/gi,"<img$1>"),this.opts.convertDivs?(t=t.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"<p>$2</p>"),t=t.replace(/<\/div><p>/gi,"<p>"),t=t.replace(/<\/p><\/div>/gi,"</p>"),t=t.replace(/<p><\/p>/gi,"<br />")):t=t.replace(/<div><\/div>/gi,"<br />"),t=this.cleanStripTags(t),this.currentOrParentIs("LI")?t=t.replace(/<p>([\w\W]*?)<\/p>/gi,"$1<br>"):i===!1&&(t=this.cleanParagraphy(t)),t=t.replace(/<span(.*?)>([\w\W]*?)<\/span>/gi,"$2"),t=t.replace(/<img>/gi,""),t=t.replace(/<[^\/>][^>][^img|param|source|td][^<]*>(\s*|\t*|\n*| |<br>)<\/[^>]+>/gi,""),t=t.replace(/\n{3,}/gi,"\n"),t=t.replace(/<p><p>/gi,"<p>"),t=t.replace(/<\/p><\/p>/gi,"</p>"),t=t.replace(/<li>(\s*|\t*|\n*)<p>/gi,"<li>"),t=t.replace(/<\/p>(\s*|\t*|\n*)<\/li>/gi,"</li>"),this.opts.linebreaks===!0&&(t=t.replace(/<p(.*?)>([\w\W]*?)<\/p>/gi,"$2<br>")),t=t.replace(/<[^\/>][^>][^img|param|source|td][^<]*>(\s*|\t*|\n*| |<br>)<\/[^>]+>/gi,""),t=t.replace(/<img src="webkit-fake-url\:\/\/(.*?)"(.*?)>/gi,""),t=t.replace(/<td(.*?)>(\s*|\t*|\n*)<p>([\w\W]*?)<\/p>(\s*|\t*|\n*)<\/td>/gi,"<td$1>$3</td>"),this.opts.convertDivs&&(t=t.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"$2"),t=t.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"$2")),this.pasteClipboardMozilla=!1,this.browser("mozilla")){if(this.opts.clipboardUpload){var o=t.match(/<img src="data:image(.*?)"(.*?)>/gi);if(null!==o){this.pasteClipboardMozilla=o;for(k in o){var s=o[k].replace("<img",'<img data-mozilla-paste-image="'+k+'" ');t=t.replace(o[k],s)}}}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");i===!1&&(t=t.replace(/<td(.*?)>([\w\W]*?)<p(.*?)>([\w\W]*?)<\/td>/gi,"<td$1>$2$4</td>"),t=t.replace(/<td(.*?)>([\w\W]*?)<\/p>([\w\W]*?)<\/td>/gi,"<td$1>$2$3</td>"),t=t.replace(/<td(.*?)>([\w\W]*?)<p(.*?)>([\w\W]*?)<\/td>/gi,"<td$1>$2$4</td>"),t=t.replace(/<td(.*?)>([\w\W]*?)<\/p>([\w\W]*?)<\/td>/gi,"<td$1>$2$3</td>")),t=t.replace(/\n/g," "),t=t.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(),this.pasteClipboardMozilla!==!1&&this.pasteClipboardUploadMozilla()},this),100),this.opts.autoresize&&this.fullscreen!==!0?$(this.document.body).scrollTop(this.saveScroll):this.$editor.scrollTop(this.saveScroll)},pasteClipboardAppendFields:function(t){return this.opts.uploadFields!==!1&&"object"==typeof this.opts.uploadFields&&$.each(this.opts.uploadFields,$.proxy(function(e,i){null!=i&&0===i.toString().indexOf("#")&&(i=$(i).val()),t[e]=i},this)),t},pasteClipboardUploadMozilla:function(){var t=this.$editor.find("img[data-mozilla-paste-image]");$.each(t,$.proxy(function(t,e){var i=$(e),r=e.src.split(","),o={contentType:r[0].split(";")[0].split(":")[1],data:r[1]};o=this.pasteClipboardAppendFields(o),$.post(this.opts.clipboardUploadUrl,o,$.proxy(function(t){var e="string"==typeof t?$.parseJSON(t):t;i.attr("src",e.filelink),i.removeAttr("data-mozilla-paste-image"),this.sync(),this.callback("imageUpload",i,e)},this))},this))},pasteClipboardUpload:function(t){var e=t.target.result,i=e.split(","),r={contentType:i[0].split(";")[0].split(":")[1],data:i[1]};this.opts.clipboardUpload?(r=this.pasteClipboardAppendFields(r),$.post(this.opts.clipboardUploadUrl,r,$.proxy(function(t){var e="string"==typeof t?$.parseJSON(t):t,i='<img src="'+e.filelink+'" id="clipboard-image-marker" />';this.execCommand("inserthtml",i,!1);var r=$(this.$editor.find("img#clipboard-image-marker"));r.length?r.removeAttr("id"):r=!1,this.sync(),r&&this.callback("imageUpload",r,e)},this))):this.insertHtml('<img src="'+e+'" />')},bufferSet:function(t){t!==!1&&this.selectionSave(),this.opts.buffer.push(this.$editor.html()),t!==!1&&this.selectionRemoveMarkers("buffer")},bufferUndo:function(){return 0===this.opts.buffer.length?void this.focusWithSaveScroll():(this.selectionSave(),this.opts.rebuffer.push(this.$editor.html()),this.selectionRestore(!1,!0),this.$editor.html(this.opts.buffer.pop()),this.selectionRestore(),void setTimeout($.proxy(this.observeStart,this),100))},bufferRedo:function(){return 0===this.opts.rebuffer.length?(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),void 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(){return this.opts.observeImages===!1?!1:(this.$editor.find("img").each($.proxy(function(t,e){this.browser("msie")&&$(e).attr("unselectable","on");var i=$(e).parent();i.hasClass("royalSlider")||i.hasClass("fotorama")||this.imageResize(e)},this)),void this.$editor.find(".fotorama, .royalSlider").on("click",$.proxy(this.editGallery,this)))},linkObserver:function(t){var e=$(t.target),i=$(t.target).parent();if(!i.hasClass("royalSlider")&&!i.hasClass("fotorama")&&0!=e.size()&&"A"===e[0].tagName){var r=e.offset();if(this.opts.iframe){var o=this.$frame.offset();r.top=o.top+(r.top-$(this.document).scrollTop()),r.left+=o.left}var s=$('<span class="redactor-link-tooltip"></span>'),a=e.attr("href");void 0===a&&(a=""),a.length>24&&(a=a.substring(0,24)+"...");var n=$('<a href="'+e.attr("href")+'" target="_blank">'+a+"</a>").on("click",$.proxy(function(){this.linkObserverTooltipClose(!1)},this)),l=$('<a href="#">'+this.opts.curLang.edit+"</a>").on("click",$.proxy(function(t){t.preventDefault(),this.linkShow(),this.linkObserverTooltipClose(!1)},this)),c=$('<a href="#">'+this.opts.curLang.unlink+"</a>").on("click",$.proxy(function(t){t.preventDefault(),this.execCommand("unlink"),this.linkObserverTooltipClose(!1)},this));s.append(n),s.append(" | "),s.append(l),s.append(" | "),s.append(c),s.css({top:r.top+20+"px",left:r.left+"px"}),$(".redactor-link-tooltip").remove(),$("body").append(s)}},linkObserverTooltipClose:function(t){return t!==!1&&"A"==t.target.tagName?!1:void $(".redactor-link-tooltip").remove()},getSelection:function(){return this.opts.rangy?this.opts.iframe?rangy.getSelection(this.$frame[0]):rangy.getSelection():this.document.getSelection()},getRange:function(){if(this.opts.rangy)return this.opts.iframe?rangy.createRange(this.iframeDoc()):rangy.createRange();if(this.document.getSelection){var t=this.getSelection();if(t.getRangeAt&&t.rangeCount)return t.getRangeAt(0)}return this.document.createRange()},selectionElement:function(t){this.setCaret(t)},selectionStart:function(t){this.selectionSet(t[0]||t,0,null,0)},selectionEnd:function(t){this.selectionSet(t[0]||t,1,null,1)},selectionSet:function(t,e,i,r){null==i&&(i=t),null==r&&(r=e);var o=this.getSelection();if(o){if("P"==t.tagName&&""==t.innerHTML&&(t.innerHTML=this.opts.invisibleSpace),"BR"==t.tagName&&this.opts.linebreaks===!1){var s=$(this.opts.emptyHtml)[0];$(t).replaceWith(s),t=s,i=t}var a=this.getRange();a.setStart(t,e),a.setEnd(i,r);try{o.removeAllRanges()}catch(n){}o.addRange(a)}},selectionWrap:function(t){t=t.toLowerCase();var e=this.getBlock();if(e){var i=this.formatChangeTag(e,t);return this.sync(),i}var r=this.getSelection(),o=r.getRangeAt(0),i=document.createElement(t);return i.appendChild(o.extractContents()),o.insertNode(i),this.selectionElement(i),i},selectionAll:function(){var t=this.getRange();t.selectNodeContents(this.$editor[0]);var e=this.getSelection();e.removeAllRanges(),e.addRange(t)},selectionRemove:function(){this.getSelection().removeAllRanges()},getCaretOffset:function(t){var e=0,i=this.getRange(),r=i.cloneRange();return r.selectNodeContents(t),r.setEnd(i.endContainer,i.endOffset),e=$.trim(r.toString()).length},getCaretOffsetRange:function(){return new Range(this.getSelection().getRangeAt(0))},setCaret:function(t,e,i){"undefined"==typeof i&&(i=e),t=t[0]||t;var r=this.getRange();r.selectNodeContents(t);var o,s=this.getTextNodesIn(t),a=!1,n=0;if(1==s.length&&e)r.setStart(s[0],e),r.setEnd(s[0],i);else for(var l,c=0;l=s[c++];){if(o=n+l.length,!a&&e>=n&&(o>e||e==o&&c<s.length)&&(r.setStart(l,e-n),a=!0),a&&o>=i){r.setEnd(l,i-n);break}n=o}var d=this.getSelection();d.removeAllRanges(),d.addRange(r)},setCaretAfter:function(t){this.$editor.focus(),t=t[0]||t;var e=this.document.createRange(),i=1,r=-1;e.setStart(t,i),e.setEnd(t,r+2);var o=this.window.getSelection(),s=this.document.createRange(),a=this.document.createTextNode("​");$(t).after(a),s.setStartAfter(a),o.removeAllRanges(),o.addRange(s),$(a).remove()},getTextNodesIn:function(t){var e=[];if(3==t.nodeType)e.push(t);else for(var i=t.childNodes,r=0,o=i.length;o>r;++r)e.push.apply(e,this.getTextNodesIn(i[r]));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(),t?this.isParentRedactor($(t).parent()[0]):!1},getBlock:function(t){for("undefined"==typeof t&&(t=this.getCurrent());t;){if(this.nodeTestBlocks(t))return $(t).hasClass("redactor_editor")?!1:t;t=t.parentNode}return!1},getBlocks:function(t){var e=[];if("undefined"==typeof t){var i=this.getRange();if(i&&i.collapsed===!0)return[this.getBlock()];var t=this.getNodes(i)}return $.each(t,$.proxy(function(t,i){return this.opts.iframe===!1&&0==$(i).parents("div.redactor_editor").size()?!1:void(this.nodeTestBlocks(i)&&e.push(i))},this)),0===e.length&&(e=[this.getBlock()]),e},isInlineNode:function(t){return 1!=t.nodeType?!1:!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("undefined"==typeof t||0==t)var t=this.getRange();if(t&&t.collapsed===!0){if("undefined"==typeof e&&this.tagTestBlock(e)){var i=this.getBlock();return i.tagName==e?[i]:[]}return[this.getCurrent()]}var r=[],o=[],s=this.document.getSelection();if(s.isCollapsed||(r=this.getRangeSelectedNodes(s.getRangeAt(0))),$.each(r,$.proxy(function(t,i){return this.opts.iframe===!1&&0==$(i).parents("div.redactor_editor").size()?!1:void("undefined"==typeof e?""!=$.trim(i.textContent)&&o.push(i):i.tagName==e&&o.push(i))},this)),0==o.length){if("undefined"==typeof e&&this.tagTestBlock(e)){var i=this.getBlock();return i.tagName==e?o.push(i):[]}o.push(this.getCurrent())}var a=o[o.length-1];return this.nodeTestBlocks(a)&&(o=o.slice(0,-1)),o},getElement:function(t){for(t||(t=this.getCurrent());t;){if(1==t.nodeType)return $(t).hasClass("redactor_editor")?!1:t;t=t.parentNode}return!1},getRangeSelectedNodes:function(t){t=t||this.getRange();var e=t.startContainer,i=t.endContainer;if(e==i)return[e];for(var r=[];e&&e!=i;)r.push(e=this.nextNode(e));for(e=t.startContainer;e&&e!=t.commonAncestorContainer;)r.unshift(e),e=e.parentNode;return r},nextNode:function(t){if(t.hasChildNodes())return t.firstChild;for(;t&&!t.nextSibling;)t=t.parentNode;return t?t.nextSibling:null},getSelectionText:function(){return this.getSelection().toString()},getSelectionHtml:function(){var t="",e=this.getSelection();if(e.rangeCount){for(var i=this.document.createElement("div"),r=e.rangeCount,o=0;r>o;++o)i.appendChild(e.getRangeAt(o).cloneContents());t=i.innerHTML}return this.syncClean(t)},selectionSave:function(){this.isFocused()||this.focusWithSaveScroll(),this.opts.rangy?this.savedSel=rangy.saveSelection():this.selectionCreateMarker(this.getRange())},selectionCreateMarker:function(t){if(t){var e=$('<span id="selection-marker-1" class="redactor-selection-marker">'+this.opts.invisibleSpace+"</span>",this.document)[0],i=$('<span id="selection-marker-2" class="redactor-selection-marker">'+this.opts.invisibleSpace+"</span>",this.document)[0];t.collapsed===!0?this.selectionSetMarker(t,e,!0):(this.selectionSetMarker(t,e,!0),this.selectionSetMarker(t,i,!1)),this.savedSel=this.$editor.html(),this.selectionRestore(!1,!1)}},selectionSetMarker:function(t,e,i){var r=t.cloneRange();try{r.collapse(i),r.insertNode(e),r.detach()}catch(o){var s=this.opts.emptyHtml;this.opts.linebreaks&&(s="<br>"),this.$editor.prepend(s),this.focus()
}},selectionRestore:function(t,e){if(this.opts.rangy)rangy.restoreSelection(this.savedSel);else{t===!0&&this.savedSel&&this.$editor.html(this.savedSel);var i=this.$editor.find("span#selection-marker-1"),r=this.$editor.find("span#selection-marker-2");this.browser("mozilla")?this.$editor.focus():this.isFocused()||this.focusWithSaveScroll(),0!=i.length&&0!=r.length?this.selectionSet(i[0],0,r[0],0):0!=i.length&&this.selectionSet(i[0],0,null,0),e!==!1&&(this.selectionRemoveMarkers(),this.savedSel=!1)}},selectionRemoveMarkers:function(){this.opts.rangy?rangy.removeMarkers(this.savedSel):$.each(this.$editor.find("span.redactor-selection-marker"),function(){var t=$.trim($(this).html().replace(/[^\u0000-\u1C7F]/g,""));""==t?$(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").click($.proxy(this.tableInsert,this)),setTimeout(function(){$("#redactor_table_rows").focus()},200)},this))},tableInsert:function(){this.bufferSet(!1);var t,e,i,r,o=$("#redactor_table_rows").val(),s=$("#redactor_table_columns").val(),a=$("<div></div>"),n=Math.floor(99999*Math.random()),l=$('<table id="table'+n+'"><tbody></tbody></table>');for(t=0;o>t;t++){for(e=$("<tr></tr>"),i=0;s>i;i++)r=$("<td>"+this.opts.invisibleSpace+"</td>"),0===t&&0===i&&r.append('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),$(e).append(r);l.append(e)}a.append(l);var c=a.html();this.opts.linebreaks===!1&&this.browser("mozilla")&&(c+="<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(c)}else this.insertHtmlAdvanced(c,!1);this.selectionRestore();var h=this.$editor.find("#table"+n);this.buttonActiveObserver(),h.find("span#selection-marker-1, inline#selection-marker-1").remove(),h.removeAttr("id"),this.sync()},tableDeleteTable:function(){var t=$(this.getParent()).closest("table");return this.isParentRedactor(t)?0==t.size()?!1:(this.bufferSet(),t.remove(),void this.sync()):!1},tableDeleteRow:function(){var t=this.getParent(),e=$(t).closest("table");if(!this.isParentRedactor(e))return!1;if(0==e.size())return!1;this.bufferSet();var i=$(t).closest("tr"),r=i.prev().length?i.prev():i.next();if(r.length){var o=r.children("td").first();o.length&&o.prepend('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>")}i.remove(),this.selectionRestore(),e.find("span#selection-marker-1").remove(),this.sync()},tableDeleteColumn:function(){var t=this.getParent(),e=$(t).closest("table");if(!this.isParentRedactor(e))return!1;if(0==e.size())return!1;this.bufferSet();var i=$(t).closest("td");i.is("td")||(i=i.closest("td"));var r=i.get(0).cellIndex;e.find("tr").each($.proxy(function(t,e){var i=0>r-1?r+1:r-1;0===t&&$(e).find("td").eq(i).prepend('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),$(e).find("td").eq(r).remove()},this)),this.selectionRestore(),e.find("span#selection-marker-1").remove(),this.sync()},tableAddHead:function(){var t=$(this.getParent()).closest("table");if(!this.isParentRedactor(t))return!1;if(0==t.size())return!1;if(this.bufferSet(),0!==t.find("thead").size())this.tableDeleteHead();else{var e=t.find("tr").first().clone();e.find("td").html(this.opts.invisibleSpace),$thead=$("<thead></thead>"),$thead.append(e),t.prepend($thead),this.sync()}},tableDeleteHead:function(){var t=$(this.getParent()).closest("table");if(!this.isParentRedactor(t))return!1;var e=t.find("thead");return 0==e.size()?!1:(this.bufferSet(),e.remove(),void this.sync())},tableAddRowAbove:function(){this.tableAddRow("before")},tableAddRowBelow:function(){this.tableAddRow("after")},tableAddColumnLeft:function(){this.tableAddColumn("before")},tableAddColumnRight:function(){this.tableAddColumn("after")},tableAddRow:function(t){var e=$(this.getParent()).closest("table");if(!this.isParentRedactor(e))return!1;if(0==e.size())return!1;this.bufferSet();var i=$(this.getParent()).closest("tr"),r=i.clone();r.find("td").html(this.opts.invisibleSpace),"after"===t?i.after(r):i.before(r),this.sync()},tableAddColumn:function(t){var e=this.getParent(),i=$(e).closest("table");if(!this.isParentRedactor(i))return!1;if(0==i.size())return!1;this.bufferSet();var r=0,o=this.getCurrent(),s=$(o).closest("tr"),a=$(o).closest("td");s.find("td").each($.proxy(function(t,e){$(e)[0]===a[0]&&(r=t)},this)),i.find("tr").each($.proxy(function(e,i){var o=$(i).find("td").eq(r),s=o.clone();s.html(this.opts.invisibleSpace),"after"===t?o.after(s):o.before(s)},this)),this.sync()},videoShow:function(){this.selectionSave(),this.modalInit(this.opts.curLang.video,this.opts.modal_video,600,$.proxy(function(){$("#redactor_insert_video_btn").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="',i='" frameborder="0" allowfullscreen></iframe>';t.match(reUrlYoutube)?t=t.replace(reUrlYoutube,e+"//www.youtube.com/embed/$1"+i):t.match(reUrlVimeo)&&(t=t.replace(reUrlVimeo,e+"//player.vimeo.com/video/$2"+i)),this.selectionRestore();var r=this.getBlock()||this.getCurrent();r?$(r).after(t):this.insertHtmlAdvanced(t,!1),this.sync(),this.modalClose()},linkShow:function(){this.selectionSave();var t=$.proxy(function(){if(this.opts.predefinedLinks!==!1){this.predefinedLinksStorage={};var t=this;$.getJSON(this.opts.predefinedLinks,function(e){var i=$("#redactor-predefined-links");i.html(""),$.each(e,function(e,r){t.predefinedLinksStorage[e]=r,i.append($("<option>").val(e).html(r.name))}),i.on("change",function(){var e=$(this).val(),i="",r="";0!=e&&(i=t.predefinedLinksStorage[e].name,r=t.predefinedLinksStorage[e].url),$("#redactor_link_url").val(r),$("#redactor_link_url_text").val(i)}),i.show()})}this.insert_link_node=!1;var e=this.getSelection(),i="",r="",o="",s=this.getParent(),a=$(s).parent().get(0);a&&"A"===a.tagName&&(s=a),s&&"A"===s.tagName?(i=s.href,r=$(s).text(),o=s.target,this.insert_link_node=s):r=e.toString(),$("#redactor_link_url_text").val(r);var n=self.location.href.replace(/\/$/i,"");if(i=i.replace(n,""),i=i.replace(/^\/#/,"#"),i=i.replace("mailto:",""),this.opts.linkProtocol===!1){var l=new RegExp("^(http|ftp|https)://"+self.location.host,"i");i=i.replace(l,"")}$("#redactor_link_url").val(i),"_blank"===o&&$("#redactor_link_blank").prop("checked",!0),this.linkInsertPressed=!1,$("#redactor_insert_link_btn").on("click",$.proxy(this.linkProcess,this)),setTimeout(function(){$("#redactor_link_url").focus()},200)},this);this.modalInit(this.opts.curLang.link,this.opts.modal_link,460,t)},linkProcess:function(){if(!this.linkInsertPressed){this.linkInsertPressed=!0;var t="",e="",i=$("#redactor_link_url").val(),r=$("#redactor_link_url_text").val();if(-1!=i.search("@")&&/(http|ftp|https):\/\//i.test(i)===!1)i="mailto:"+i;else if(0!=i.search("#")){$("#redactor_link_blank").prop("checked")&&(t=' target="_blank"',e="_blank");var o="((xn--)?[a-z0-9]+(-[a-z0-9]+)*.)+[a-z]{2,}",s=new RegExp("^(http|ftp|https)://"+o,"i"),a=new RegExp("^"+o,"i");-1==i.search(s)&&0==i.search(a)&&this.opts.linkProtocol&&(i=this.opts.linkProtocol+i)}r=r.replace(/<|>/g,"");var n="&nbsp;";this.browser("mozilla")&&(n="&nbsp;"),this.linkInsert('<a href="'+i+'"'+t+">"+r+"</a>"+n,$.trim(r),i,e)}},linkInsert:function(t,e,i,r){if(this.selectionRestore(),""!==e){if(this.insert_link_node)this.bufferSet(),$(this.insert_link_node).text(e).attr("href",i),""!==r?$(this.insert_link_node).attr("target",r):$(this.insert_link_node).removeAttr("target");else{var o=$(t).addClass("redactor-added-link");this.exec("inserthtml",this.outerHtml(o),!1);var i=this.$editor.find("a.redactor-added-link");i.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(),t!==!1){var e=$("#redactor_filename").val();""===e&&(e=t.filename);var i='<a href="'+t.filelink+'" id="filelink-marker">'+e+"</a>";this.browser("webkit")&&this.window.chrome&&(i+="&nbsp;"),this.execCommand("inserthtml",i,!1);var r=$(this.$editor.find("a#filelink-marker"));0!=r.size()?r.removeAttr("id"):r=!1,this.sync(),this.callback("fileUpload",r,t)}this.modalClose()},imageShow:function(){this.selectionSave();var t=$.proxy(function(){this.opts.imageGetJson?$.getJSON(this.opts.imageGetJson,$.proxy(function(t){var e={},i=0;$.each(t,$.proxy(function(t,r){"undefined"!=typeof r.folder&&(i++,e[r.folder]=i)},this));var r=!1;if($.each(t,$.proxy(function(t,i){var o="";"undefined"!=typeof i.title&&(o=i.title);var s=0;$.isEmptyObject(e)||"undefined"==typeof i.folder||(s=e[i.folder],r===!1&&(r=".redactorfolder"+s));var a=$('<img src="'+i.thumb+'" class="redactorfolder redactorfolder'+s+'" rel="'+i.image+'" title="'+o+'" />');$("#redactor_image_box").append(a),$(a).click($.proxy(this.imageThumbClick,this))},this)),!$.isEmptyObject(e)){$(".redactorfolder").hide(),$(r).show();var o=function(t){$(".redactorfolder").hide(),$(".redactorfolder"+$(t.target).val()).show()},s=$('<select id="redactor_image_box_select">');$.each(e,function(t,e){s.append($('<option value="'+e+'">'+t+"</option>"))}),$("#redactor_image_box").before(s),s.change(o)}},this)):$("#redactor-tab-control-2").remove(),this.opts.imageUpload||this.opts.s3?(this.isMobile()||this.isIPad()||this.opts.s3!==!1||$("#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}),this.opts.s3===!1?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").click($.proxy(this.imageCallbackLink,this)),this.opts.imageUpload||this.opts.imageGetJson||setTimeout(function(){$("#redactor_file_link").focus()},200)},this);this.modalInit(this.opts.curLang.image,this.opts.modal_image,610,t)},imageEdit:function(t){var e=t,i=e.parent().parent(),r=$.proxy(function(){$("#redactor_file_alt").val(e.attr("alt")),$("#redactor_image_edit_src").attr("href",e.attr("src")),$("#redactor_form_image_align").val("block"==e.css("display")&&"none"==e.css("float")?"center":e.css("float")),"A"===$(i).get(0).tagName&&($("#redactor_file_link").val($(i).attr("href")),"_blank"==$(i).attr("target")&&$("#redactor_link_blank").prop("checked",!0)),$("#redactor_image_delete_btn").click($.proxy(function(){this.imageRemove(e)},this)),$("#redactorSaveBtn").click($.proxy(function(){this.imageSave(e)},this))},this);this.modalInit(this.opts.curLang.edit,this.opts.modal_image_edit,380,r)},imageRemove:function(t){var e=$(t).parent().parent(),i=$(t).parent(),r=!1;e.length&&"A"===e[0].tagName?(r=!0,$(e).remove()):i.length&&"A"===i[0].tagName?(r=!0,$(i).remove()):$(t).remove(),i.length&&"P"===i[0].tagName&&(this.focusWithSaveScroll(),r===!1&&this.selectionStart(i)),this.callback("imageDelete",t),this.modalClose(),this.sync()},imageSave:function(t){this.imageResizeHide(!1);var e=$(t),i=e.parent();e.attr("alt",$("#redactor_file_alt").val());var r=$("#redactor_form_image_align").val(),o="";"left"===r?(o="0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin+" 0",e.css({"float":"left",margin:o})):"right"===r?(o="0 0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin,e.css({"float":"right",margin:o})):e.css("center"===r?{"float":"",display:"block",margin:"auto"}:{"float":"",display:"",margin:""});var s=$.trim($("#redactor_file_link").val());if(""!==s){var a=!1;if($("#redactor_link_blank").prop("checked")&&(a=!0),"A"!==i.get(0).tagName){var n=$('<a href="'+s+'">'+this.outerHtml(t)+"</a>");a&&n.attr("target","_blank"),e.replaceWith(n)}else i.attr("href",s),a?i.attr("target","_blank"):i.removeAttr("target")}else"A"===i.get(0).tagName&&i.replaceWith(this.outerHtml(t));this.modalClose(),this.observeImages(),this.sync()},imageResizeHide:function(t){if(t!==!1&&0!=$(t.target).parent().size()&&"redactor-image-box"===$(t.target).parent()[0].id)return!1;var e=this.$editor.find("#redactor-image-box");return 0==e.size()?!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"),void 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(){if(0!=this.$editor.find("#redactor-image-box").size())return!1;var t,i,r=e.width()/e.height(),o=20,s=this.imageResizeControls(e),a=!1;s!==!1&&(s.on("mousedown",function(o){a=!0,o.preventDefault(),r=e.width()/e.height(),t=Math.round(o.pageX-e.eq(0).offset().left),i=Math.round(o.pageY-e.eq(0).offset().top)}),$(this.document.body).on("mousemove",$.proxy(function(s){if(a){var n=(Math.round(s.pageX-e.eq(0).offset().left)-t,Math.round(s.pageY-e.eq(0).offset().top)-i),l=e.height(),c=parseInt(l,10)+n,d=Math.round(c*r);d>o&&(e.width(d),this.imageEditter.css(100>d?{marginTop:"-7px",marginLeft:"-13px",fontSize:"9px",padding:"3px 5px"}:{marginTop:"-11px",marginLeft:"-18px",fontSize:"11px",padding:"7px 10px"})),t=Math.round(s.pageX-e.eq(0).offset().left),i=Math.round(s.pageY-e.eq(0).offset().top),this.sync()}},this)).on("mouseup",function(){a=!1})),this.$editor.on("keydown.redactor-image-delete",$.proxy(function(t){var i=t.which;(this.keyCode.BACKSPACE==i||this.keyCode.DELETE==i)&&(this.bufferSet(!1),this.imageResizeHide(!1),this.imageRemove(e))},this)),$(document).on("click.redactor-image-resize-hide",$.proxy(this.imageResizeHide,this)),this.$editor.on("click.redactor-image-resize-hide",$.proxy(this.imageResizeHide,this))},this))},imageResizeControls:function(t){var e=$('<span id="redactor-image-box" data-redactor="verified">');if(e.css({position:"relative",display:"inline-block",lineHeight:0,outline:"1px dashed rgba(0, 0, 0, .6)","float":t.css("float")}),e.attr("contenteditable",!1),"auto"!=t[0].style.margin?(e.css({marginTop:t[0].style.marginTop,marginBottom:t[0].style.marginBottom,marginLeft:t[0].style.marginLeft,marginRight:t[0].style.marginRight}),t.css("margin","")):e.css({display:"block",margin:"auto"}),t.css("opacity",.5).after(e),this.imageEditter=$('<span id="redactor-image-editter" data-redactor="verified">'+this.opts.curLang.edit+"</span>"),this.imageEditter.css({position:"absolute",zIndex:5,top:"50%",left:"50%",marginTop:"-11px",marginLeft:"-18px",lineHeight:1,backgroundColor:"#000",color:"#fff",fontSize:"11px",padding:"7px 10px",cursor:"pointer"}),this.imageEditter.attr("contenteditable",!1),this.imageEditter.on("click",$.proxy(function(){this.imageEdit(t)},this)),e.append(this.imageEditter),this.opts.imageResizable){var i=$('<span id="redactor-image-resizer" data-redactor="verified"></span>');return i.css({position:"absolute",zIndex:2,lineHeight:1,cursor:"nw-resize",bottom:"-4px",right:"-5px",border:"1px solid #fff",backgroundColor:"#000",width:"8px",height:"8px"}),i.attr("contenteditable",!1),e.append(i),e.append(t),i}return e.append(t),!1},imageThumbClick:function(t){var e='<img id="image-marker" src="'+$(t.target).attr("rel")+'" alt="'+$(t.target).attr("title")+'" />',i=this.getParent();this.opts.paragraphy&&0==$(i).closest("li").size()&&(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+'" />';this.opts.linebreaks===!1&&(e="<p>"+e+"</p>"),this.imageInsert(e,!0)}else this.modalClose()},imageCallback:function(t){this.imageInsert(t)},imageInsert:function(t,e){if(this.selectionRestore(),t!==!1){var i="";if(e!==!0){i='<img id="image-marker" src="'+t.filelink+'" />';var r=this.getParent();this.opts.paragraphy&&0==$(r).closest("li").size()&&(i="<p>"+i+"</p>")}else i=t;this.execCommand("inserthtml",i,!1);var o=$(this.$editor.find("img#image-marker"));o.length?o.removeAttr("id"):o=!1,this.sync(),e!==!0&&this.callback("imageUpload",o,t)}this.modalClose(),this.observeImages()},buildProgressBar:function(){0==$("#redactor-progress").size()&&(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"></div></div></form><div id="redactor_tab3" class="redactor_tab" style="display: none;"><label>'+this.opts.curLang.image_web_link+'</label><input type="text" name="redactor_file_link" id="redactor_file_link" class="redactor_input"  /><br><br></div></section><footer><button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button><button class="redactor_modal_btn redactor_modal_action_btn" id="redactor_upload_btn">'+this.opts.curLang.insert+"</button></footer>",modal_link:String()+'<section id="redactor-modal-link-insert"><select id="redactor-predefined-links" style="width: 99.5%; display: none;"></select><label>URL</label><input type="text" class="redactor_input" id="redactor_link_url" /><label>'+this.opts.curLang.text+'</label><input type="text" class="redactor_input" id="redactor_link_url_text" /><label><input type="checkbox" id="redactor_link_blank"> '+this.opts.curLang.link_new_tab+'</label></section><footer><button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button><button id="redactor_insert_link_btn" class="redactor_modal_btn redactor_modal_action_btn">'+this.opts.curLang.insert+"</button></footer>",modal_table:String()+'<section id="redactor-modal-table-insert"><label>'+this.opts.curLang.rows+'</label><input type="text" size="5" value="2" id="redactor_table_rows" /><label>'+this.opts.curLang.columns+'</label><input type="text" size="5" value="3" id="redactor_table_columns" /></section><footer><button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button><button id="redactor_insert_table_btn" class="redactor_modal_btn redactor_modal_action_btn">'+this.opts.curLang.insert+"</button></footer>",modal_video:String()+'<section id="redactor-modal-video-insert"><form id="redactorInsertVideoForm"><label>'+this.opts.curLang.video_html_code+'</label><textarea id="redactor_insert_video_area" style="width: 99%; height: 160px;"></textarea></form></section><footer><button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button><button id="redactor_insert_video_btn" class="redactor_modal_btn redactor_modal_action_btn">'+this.opts.curLang.insert+"</button></footer>"})},modalInit:function(t,e,i,r){return this.modalSetOverlay(),this.$redactorModalWidth=i,this.$redactorModal=$("#redactor_modal"),this.$redactorModal.length||(this.$redactorModal=$('<div id="redactor_modal" style="display: none;" />'),this.$redactorModal.append($('<div id="redactor_modal_close">&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).keyup($.proxy(this.modalCloseHandler,this)),this.$editor.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,this.opts.autoresize===!1&&(this.saveModalScroll=this.$editor.scrollTop()),this.isMobile()===!1?this.modalShowOnDesktop():this.modalShowOnMobile(),"function"==typeof r&&r(),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").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(){var t=this.$redactorModal.find("footer button").not(".redactor_modal_btn_hidden"),e=t.size();e>0&&$(t).css("width",this.$redactorModalWidth/e+"px")},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(){"undefined"!=typeof $.fn.draggable&&(this.$redactorModal.draggable({handle:"#redactor_modal_header"}),this.$redactorModal.find("#redactor_modal_header").css("cursor","move"))},modalLoadTabs:function(){var t=$("#redactor_tabs");if(!t.length)return!1;var e=this;t.find("a").each(function(i,r){i++,$(r).on("click",function(r){if(r.preventDefault(),t.find("a").removeClass("redactor_tabs_act"),$(this).addClass("redactor_tabs_act"),$(".redactor_tab").hide(),$("#redactor_tab"+i).show(),$("#redactor_tab_selected").val(i),e.isMobile()===!1){var o=e.$redactorModal.outerHeight();e.$redactorModal.css("margin-top","-"+(o+10)/2+"px")}})})},modalCloseHandler:function(t){return t.keyCode===this.keyCode.ESC?(this.modalClose(),!1):void 0},modalClose:function(){return $("#redactor_modal_close").off("click",this.modalClose),$("#redactor_modal").fadeOut("fast",$.proxy(function(){var t=$("#redactor_modal_inner");this.modalcontent!==!1&&(this.modalcontent.html(t.html()),this.modalcontent=!1),t.html(""),this.opts.modalOverlay&&$("#redactor_modal_overlay").hide().off("click",this.modalClose),$(document).unbind("keyup",this.hdlModalClose),this.$editor.unbind("keyup",this.hdlModalClose),this.selectionRestore(),this.opts.autoresize&&this.saveModalScroll?$(this.document.body).scrollTop(this.saveModalScroll):this.opts.autoresize===!1&&this.saveModalScroll&&this.$editor.scrollTop(this.saveModalScroll),this.callback("modalClosed")},this)),this.isMobile()===!1&&$(document.body).css("overflow",this.modalSaveBodyOveflow?this.modalSaveBodyOveflow:"visible"),!1},modalSetTab:function(t){$(".redactor_tab").hide(),$("#redactor_tabs").find("a").removeClass("redactor_tabs_act").eq(t-1).addClass("redactor_tabs_act"),$("#redactor_tab"+t).show()},s3handleFileSelect:function(t){for(var e,i=t.target.files,r=0;e=i[r];r++)this.s3uploadFile(e)},s3uploadFile:function(t){this.s3executeOnSignedUrl(t,$.proxy(function(e){this.s3uploadToS3(t,e)},this))},s3executeOnSignedUrl:function(t,e){var i=new XMLHttpRequest,r="?";"-1"!=this.opts.s3.search(/\?/)&&(r="&"),i.open("GET",this.opts.s3+r+"name="+t.name+"&type="+t.type,!0),i.overrideMimeType&&i.overrideMimeType("text/plain; charset=x-user-defined");var o=this;i.onreadystatechange=function(){4==this.readyState&&200==this.status?(o.showProgressBar(),e(decodeURIComponent(this.responseText))):4==this.readyState&&200!=this.status},i.send()},s3createCORSRequest:function(t,e){var i=new XMLHttpRequest;return"withCredentials"in i?i.open(t,e,!0):"undefined"!=typeof XDomainRequest?(i=new XDomainRequest,i.open(t,e)):i=null,i},s3uploadToS3:function(t,e){var i=this.s3createCORSRequest("PUT",e);i&&(i.onload=$.proxy(function(){if(200==i.status){this.hideProgressBar();var t=e.split("?");if(!t[0])return!1;this.selectionRestore();var r="";r='<img id="image-marker" src="'+t[0]+'" />',this.opts.paragraphy&&(r="<p>"+r+"</p>"),this.execCommand("inserthtml",r,!1);var o=$(this.$editor.find("img#image-marker"));o.length?o.removeAttr("id"):o=!1,this.sync(),this.callback("imageUpload",o,!1),this.modalClose(),this.observeImages()}},this),i.onerror=function(){},i.upload.onprogress=function(){},i.setRequestHeader("Content-Type",t.type),i.setRequestHeader("x-amz-acl","public-read"),i.send(t))},uploadInit:function(t,e){this.uploadOptions={url:!1,success:!1,error:!1,start:!1,trigger:!1,auto:!1,input:!1},$.extend(this.uploadOptions,e);var i=$("#"+t);i.length&&"INPUT"===i[0].tagName?(this.uploadOptions.input=i,this.el=$(i[0].form)):this.el=i,this.element_action=this.el.attr("action"),this.uploadOptions.auto?$(this.uploadOptions.input).change($.proxy(function(t){this.el.submit(function(){return!1}),this.uploadSubmit(t)},this)):this.uploadOptions.trigger&&$("#"+this.uploadOptions.trigger).click($.proxy(this.uploadSubmit,this))},uploadSubmit:function(){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).load($.proxy(this.uploadLoaded,this)),this.id},uploadForm:function(t,e){if(this.uploadOptions.input){var i="redactorUploadForm"+this.id,r="redactorUploadFile"+this.id;this.form=$('<form  action="'+this.uploadOptions.url+'" method="POST" target="'+e+'" name="'+i+'" id="'+i+'" enctype="multipart/form-data" />'),this.opts.uploadFields!==!1&&"object"==typeof this.opts.uploadFields&&$.each(this.opts.uploadFields,$.proxy(function(t,e){null!=e&&0===e.toString().indexOf("#")&&(e=$(e).val());var i=$("<input/>",{type:"hidden",name:t,value:e});$(this.form).append(i)},this));var o=this.uploadOptions.input,s=$(o).clone();$(o).attr("id",r).before(s).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(),"undefined"!=typeof t){var i=t.body.innerHTML,r=i.match(/\{(.|\n)*\}/)[0];r=r.replace(/^\[/,""),r=r.replace(/\]$/,"");var o=$.parseJSON(r);"undefined"==typeof o.error?this.uploadOptions.success(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){return 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?!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)),void(this.dropareabox.get(0).ondrop=$.proxy(function(t){t.preventDefault(),this.dropareabox.removeClass("hover").addClass("drop"),this.showProgressBar(),this.dragUploadAjax(this.draguploadOptions.url,t.dataTransfer.files[0],!1,t,this.draguploadOptions.uploadParam)},this)))},dragUploadAjax:function(t,e,i,r,o){if(!i){var s=$.ajaxSettings.xhr();s.upload&&s.upload.addEventListener("progress",$.proxy(this.uploadProgress,this),!1),$.ajaxSetup({xhr:function(){return s}})}this.callback("drop",r);var a=new FormData;o!==!1?a.append(o,e):a.append("file",e),this.opts.uploadFields!==!1&&"object"==typeof this.opts.uploadFields&&$.each(this.opts.uploadFields,$.proxy(function(t,e){null!=e&&0===e.toString().indexOf("#")&&(e=$(e).val()),a.append(t,e)},this)),$.ajax({url:t,dataType:"html",data:a,cache:!1,contentType:!1,processData:!1,type:"POST",success:$.proxy(function(t){t=t.replace(/^\[/,""),t=t.replace(/\]$/,"");var e="string"==typeof t?$.parseJSON(t):t;if(this.hideProgressBar(),i){var o=$("<img>");o.attr("src",e.filelink).attr("id","drag-image-marker"),this.insertNodeToCaretPositionFromPoint(r,o[0]);var s=$(this.$editor.find("img#drag-image-marker"));s.length?s.removeAttr("id"):s=!1,this.sync(),this.observeImages(),s&&this.callback("imageUpload",s,e),"undefined"!=typeof e.error&&this.callback("imageUploadError",e)}else"undefined"==typeof e.error?this.draguploadOptions.success(e):(this.draguploadOptions.error(this,e),this.draguploadOptions.success(!1))},this)})},draguploadOndrag:function(){return this.dropareabox.addClass("hover"),!1},draguploadOndragleave:function(){return this.dropareabox.removeClass("hover"),!1},uploadProgress:function(t,e){var i=t.loaded?parseInt(t.loaded/t.total*100,10):t;this.dropareabox.text("Loading "+i+"% "+(e||""))},isMobile:function(){return/(iPhone|iPod|BlackBerry|Android)/.test(navigator.userAgent)},isIPad:function(){return/iPad/.test(navigator.userAgent)},normalize:function(t){return"undefined"==typeof 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.replace(/&#x200b;|<br>|<br\/>|&nbsp;/gi,""),t=t.replace(/\s/g,""),t=t.replace(/^<p>[^\W\w\D\d]*?<\/p>$/i,""),""==t},getInternetExplorerVersion:function(){var t=!1;if("Microsoft Internet Explorer"==navigator.appName){var e=navigator.userAgent,i=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");null!=i.exec(e)&&(t=parseFloat(RegExp.$1))}return t},isIe11:function(){return!!navigator.userAgent.match(/Trident\/7\./)},browser:function(t){var e=navigator.userAgent.toLowerCase(),i=/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return"version"==t?i[2]:"webkit"==t?"chrome"==i[1]||"webkit"==i[1]:"rv"==i[1]?"msie"==t:"opr"==i[1]?"webkit"==t:t==i[1]},oldIE:function(){return this.browser("msie")&&parseInt(this.browser("version"),10)<9?!0:!1},getFragmentHtml:function(t){var e=t.cloneNode(!0),i=this.document.createElement("div");return i.appendChild(e),i.innerHTML},extractContent:function(){for(var t,e=this.$editor[0],i=this.document.createDocumentFragment();t=e.firstChild;)i.appendChild(t);return i},isParentRedactor:function(t){return t?this.opts.iframe?t:0==$(t).parents("div.redactor_editor").length||$(t).hasClass("redactor_editor")?!1:t:!1},currentOrParentIs:function(t){var e=this.getParent(),i=this.getCurrent();return e&&e.tagName===t?e:i&&i.tagName===t?i:!1},isEndOfElement:function(){var t=this.getBlock(),e=this.getCaretOffset(t),i=$.trim($(t).text()).replace(/\n\r\n/g,""),r=i.length;return e==r?!0:!1},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:0!=$(t).closest("div.redactor_editor").length:!1},removeEmptyAttr:function(t,e){""==$(t).attr(e)&&$(t).removeAttr(e)},removeFromArrayByValue:function(t,e){for(var i=null;-1!==(i=t.indexOf(e));)t.splice(i,1);return t}},Redactor.prototype.init.prototype=Redactor.prototype,$.Redactor.fn.formatLinkify=function(t,e,i,r,o){for(var s=/(((https?|ftps?):\/\/)|www[.][^\s])(.+?\..+?)([.),]?)(\s|\.\s+|\)|$)/gi,a=/(https?|ftp):\/\//i,n=/(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/gi,l=(this.$editor?this.$editor.get(0):this).childNodes,c=l.length;c--;){var d=l[c];if(3===d.nodeType){var h=d.nodeValue;if(r&&h){var p='<iframe width="500" height="281" src="',u='" frameborder="0" allowfullscreen></iframe>';h.match(reUrlYoutube)?(h=h.replace(reUrlYoutube,p+"//www.youtube.com/embed/$1"+u),$(d).after(h).remove()):h.match(reUrlVimeo)&&(h=h.replace(reUrlVimeo,p+"//player.vimeo.com/video/$2"+u),$(d).after(h).remove())}if(i&&h&&h.match(n)&&(h=h.replace(n,'<img src="$1">'),$(d).after(h).remove()),e&&h&&h.match(s)){var f=h.match(s);for(var c in f){var m=f[c],g=m,b="";null!==m.match(/\s$/)&&(b=" ");var v=t;null!==m.match(a)&&(v=""),g.length>o&&(g=g.substring(0,o)+"..."),g=g.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");var y=g.replace("$","$$$");h=h.replace(m,'<a href="'+v+$.trim(m)+'">'+$.trim(y)+"</a>"+b)}$(d).after(h).remove()}}else 1!==d.nodeType||/^(a|button|textarea)$/i.test(d.tagName)||$.Redactor.fn.formatLinkify.call(d,t,e,i,r,o)}}}(jQuery)}();