PHP Classes

File: themes/default/js/redactor.js

Recommend this page to a friend!
  Classes of Aby Dahana   Dwitri PHP Social Network Platform   themes/default/js/redactor.js   Download  
File: themes/default/js/redactor.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Dwitri PHP Social Network Platform
Create a community site like a social network
Author: By
Last change:
Date: 2 years ago
Size: 114,044 bytes
 

Contents

Class file image Download
if(function(t){function e(t,i){return new e.prototype.init(t,i)}var s=0,o=function(t){return this[0]=t.startOffset,this[1]=t.endOffset,this.range=t,this};o.prototype.equals=function(){return this[0]===this[1]},t.fn.redactor=function(i){var s=[],o=Array.prototype.slice.call(arguments,1);return"string"==typeof i?this.each(function(){var e=t.data(this,"redactor");if("undefined"==typeof e||!t.isFunction(e[i]))return t.error('No such method "'+i+'" for Redactor');var r=e[i].apply(e,o);void 0!==r&&r!==e&&s.push(r)}):this.each(function(){t.data(this,"redactor")||t.data(this,"redactor",e(this,i))}),0===s.length?this:1===s.length?s[0]:s},t.Redactor=e,t.Redactor.VERSION="9.1.7",t.Redactor.opts={rangy:!1,iframe:!1,fullpage:!1,css:!1,lang:"en",direction:"ltr",placeholder:!1,wym:!1,mobile:!0,cleanup:!0,tidyHtml:!0,pastePlainText:!1,removeEmptyTags:!0,templateVars:!1,xhtml:!1,visual:!0,focus:!1,tabindex:!1,autoresize:!0,minHeight:!1,maxHeight:!1,shortcuts:!0,autosave:!1,autosaveInterval:60,plugins:!1,linkAnchor:!0,linkEmail:!0,linkProtocol:"http://",linkNofollow:!1,linkSize:50,imageFloatMargin:"10px",imageGetJson:!1,imageUpload:!1,imageUploadParam:"file",fileUpload:!1,fileUploadParam:"file",clipboardUpload:!0,clipboardUploadUrl:!1,dragUpload:!0,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,buttonSource:!0,buttonSeparator:'<li class="redactor_separator"></li>',buttonsCustom:{},buttonsAdd:[],buttons:["html","|","formatting","|","bold","italic","deleted","|","unorderedlist","orderedlist","outdent","indent","|","image","video","file","table","link","|","alignment","|","horizontalrule"],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"},activeButtonsAdd:!1,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",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"}}},e.fn=t.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(e,o){this.rtePaste=!1,this.$element=this.$source=t(e),this.uuid=s++;var r=t.extend(!0,{},t.Redactor.opts);if(this.opts=t.extend({},r,this.$element.data(),o),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 a=["strong","em","del"],n=["b","i","strike"];"-1"===t.inArray("p",this.opts.allowedTags)&&this.opts.allowedTags.push("p");for(i in a)"-1"!=t.inArray(a[i],this.opts.allowedTags)&&this.opts.allowedTags.push(n[i])}if(this.opts.deniedTags!==!1){var l=t.inArray("p",this.opts.deniedTags);"-1"!==l&&this.opts.deniedTags.splice(l,l)}}(this.browser("msie")||this.browser("opera"))&&(this.opts.buttons=this.removeFromArrayByValue(this.opts.buttons,"horizontalrule")),this.opts.curLang=this.opts.langs[this.opts.lang],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"}}},fontcolor:{title:t.fontcolor,func:"show"},backcolor:{title:t.backcolor,func:"show"},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"},justify:{title:t.align_justify,func:"alignmentJustify"},horizontalrule:{exec:"inserthorizontalrule",title:t.horizontalrule}}},callback:function(e,i,s){var o=this.opts[e+"Callback"];return t.isFunction(o)?i===!1?o.call(this,s):o.call(this,i,s):s},destroy:function(){clearInterval(this.autosaveInterval),t(window).off(".redactor"),this.$source.off("redactor-textarea"),this.$element.off(".redactor").removeData("redactor");var e=this.get();if(this.opts.textareamode)this.$box.after(this.$source),this.$box.remove(),this.$source.val(e).show();else{var i=this.$editor;this.opts.iframe&&(i=this.$element),this.$box.after(i),this.$box.remove(),i.removeClass("redactor_editor").removeClass("redactor_editor_wym").removeAttr("contenteditable").html(e).show()}this.opts.air&&t("#redactor_air_"+this.uuid).remove()},getObject:function(){return t.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(),this.opts.fullpage?this.setCodeIframe(t):this.setEditor(t,e),i!==!1&&this.placeholderRemove()},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=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){t=this.cleanSavePreCode(t,!0),t=this.cleanConverters(t),t=this.cleanEmpty(t),this.$editor.html(t),this.setNonEditable(),this.setSpansVerified(),this.sync()},setSpansVerified:function(){var e=this.$editor.find("span"),i="inline";t.each(e,function(){var e=this.outerHTML,s=new RegExp("<"+this.tagName,"i"),o=e.replace(s,"<"+i);s=new RegExp("</"+this.tagName,"i"),o=o.replace(s,"</"+i),t(this).replaceWith(o)})},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(){var e="";if(this.cleanUnverified(),e=this.opts.fullpage?this.getCodeIframe():this.$editor.html(),e=this.syncClean(e),e=this.cleanRemoveEmptyTags(e),e=e.replace(/<\/li><(ul|ol)>([\w\W]*?)<\/(ul|ol)>/gi,"<$1>$2</$1></li>"),"<br>"===t.trim(e)&&(e=""),this.opts.xhtml){var i=["br","hr","img","link","input","meta"];t.each(i,function(t,i){e=e.replace(new RegExp("<"+i+"(.*?[^/$]?)>","gi"),"<"+i+"$1 />")})}e=this.callback("syncBefore",!1,e),this.$source.val(e),this.callback("syncAfter",!1,e),this.start===!1&&this.callback("change",!1,e)},syncClean:function(e){return this.opts.fullpage||(e=this.cleanStripTags(e)),e=t.trim(e),e=this.placeholderRemoveFromCode(e),e=e.replace(/&#x200b;/gi,""),e=e.replace(/&#8203;/gi,""),e=e.replace(/&nbsp;/gi," "),this.opts.linkNofollow&&(e=e.replace(/<a(.*?)rel="nofollow"(.*?)>/gi,"<a$1$2>"),e=e.replace(/<a(.*?)>/gi,'<a$1 rel="nofollow">')),e=e.replace("<!--?php","<?php"),e=e.replace("?-->","?>"),e=e.replace(/<(.*?)class="noeditable"(.*?) contenteditable="false"(.*?)>/gi,'<$1class="noeditable"$2$3>'),e=e.replace(/ data-tagblock=""/gi,""),e=e.replace(/<br\s?\/?>\n?<\/(P|H[1-6]|LI|ADDRESS|SECTION|HEADER|FOOTER|ASIDE|ARTICLE)>/gi,"</$1>"),e=e.replace(/<span(.*?)id="redactor-image-box"(.*?)>([\w\W]*?)<img(.*?)><\/span>/i,"$3<img$4>"),e=e.replace(/<span(.*?)id="redactor-image-resizer"(.*?)>(.*?)<\/span>/i,""),e=e.replace(/<span(.*?)id="redactor-image-editter"(.*?)>(.*?)<\/span>/i,""),e=e.replace(/<font(.*?)>([\w\W]*?)<\/font>/gi,"$2"),e=e.replace(/<span(.*?)>([\w\W]*?)<\/span>/gi,"$2"),e=e.replace(/<inline(.*?)>([\w\W]*?)<\/inline>/gi,"<span$1>$2</span>"),e=e.replace(/<span(.*?)class="redactor_placeholder"(.*?)>([\w\W]*?)<\/span>/gi,""),e=e.replace(/&amp;/gi,"&"),e=this.cleanReConvertProtected(e)},buildStart:function(){this.content="",this.$box=t('<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.opts.textareamode?this.content=t.trim(this.$source.val()):this.content=t.trim(this.$source.html())},buildFromTextarea:function(){this.$editor=t("<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(e){return t("<textarea />").attr("name",e.attr("id")).css("height",this.sourceHeight)},buildAddClasses:function(e){t.each(this.$source.get(0).className.split(/\s+/),function(t,i){e.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.opts.maxHeight&&t.css("max-height",this.opts.maxHeight+"px"),this.opts.wym&&this.$editor.addClass("redactor_editor_wym"),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(t.proxy(this.observeStart,this),4),this.browser("mozilla"))try{this.document.execCommand("enableObjectResizing",!1,!1),this.document.execCommand("enableInlineTableEditing",!1,!1)}catch(e){}this.opts.focus&&setTimeout(t.proxy(this.focus,this),100),this.opts.visual||setTimeout(t.proxy(function(){this.opts.visual=!0,this.toggle(!1)},this),200),this.callback("init")},buildBindKeyboard:function(){this.opts.dragUpload&&this.opts.imageUpload!==!1&&this.$editor.on("drop.redactor",t.proxy(this.buildEventDrop,this)),this.$editor.on("paste.redactor",t.proxy(this.buildEventPaste,this)),this.$editor.on("keydown.redactor",t.proxy(this.buildEventKeydown,this)),this.$editor.on("keyup.redactor",t.proxy(this.buildEventKeyup,this)),t.isFunction(this.opts.textareaKeydownCallback)&&this.$source.on("keydown.redactor-textarea",t.proxy(this.opts.textareaKeydownCallback,this)),t.isFunction(this.opts.focusCallback)&&this.$editor.on("focus.redactor",t.proxy(this.opts.focusCallback,this));var e;t(document).mousedown(function(i){e=t(i.target)}),this.$editor.on("blur.redactor",t.proxy(function(i){t(e).hasClass("redactor_toolbar")||0!=t(e).parents(".redactor_toolbar").size()||(this.selectall=!1,t.isFunction(this.opts.blurCallback)&&this.callback("blur",i))},this))},buildEventDrop:function(e){if(e=e.originalEvent||e,void 0===window.FormData||!e.dataTransfer)return!0;var i=e.dataTransfer.files.length;if(0==i)return!0;e.preventDefault();var s=e.dataTransfer.files[0];if(this.opts.dnbImageTypes!==!1&&-1==this.opts.dnbImageTypes.indexOf(s.type))return!0;this.bufferSet();var o=t('<div id="redactor-progress-drag" class="redactor-progress redactor-progress-striped"><div id="redactor-progress-bar" class="redactor-progress-bar" style="width: 100%;"></div></div>');t(document.body).append(o),this.opts.s3===!1?this.dragUploadAjax(this.opts.imageUpload,s,!0,o,e,this.opts.imageUploadParam):this.s3uploadFile(s)},buildEventPaste:function(e){var i=!1;if(this.browser("webkit")&&-1===navigator.userAgent.indexOf("Chrome")){var s=this.browser("version").split(".");s[0]<536&&(i=!0)}if(i)return!0;if(this.browser("opera"))return!0;if(this.opts.clipboardUpload&&this.buildEventClipboardUpload(e))return!0;if(this.opts.cleanup){this.rtePaste=!0,this.selectionSave(),this.selectall||(this.opts.autoresize===!0?(this.$editor.height(this.$editor.height()),this.saveScroll=this.document.body.scrollTop):this.saveScroll=this.$editor.scrollTop());var o=this.extractContent();setTimeout(t.proxy(function(){var t=this.extractContent();this.$editor.append(o),this.selectionRestore();var e=this.getFragmentHtml(t);this.pasteClean(e),this.opts.autoresize===!0&&this.$editor.css("height","auto")},this),1)}},buildEventClipboardUpload:function(e){var i=e.originalEvent||e;if(this.clipboardFilePaste=!1,"undefined"==typeof i.clipboardData)return!1;if(i.clipboardData.items){var s=i.clipboardData.items[0].getAsFile();if(null!==s){this.bufferSet(),this.clipboardFilePaste=!0;var o=new FileReader;return o.onload=t.proxy(this.pasteClipboardUpload,this),o.readAsDataURL(s),!0}}return!1},buildEventKeydown:function(e){if(this.rtePaste)return!1;var i=e.which,s=e.ctrlKey||e.metaKey,o=this.getParent(),r=this.getCurrent(),a=this.getBlock(),n=!1;if(this.callback("keydown",e),this.imageResizeHide(!1),(o&&"PRE"===t(o).get(0).tagName||r&&"PRE"===t(r).get(0).tagName)&&(n=!0,i===this.keyCode.DOWN&&this.insertAfterLastElement(a)),i===this.keyCode.DOWN&&(o&&"BLOCKQUOTE"===t(o)[0].tagName&&this.insertAfterLastElement(o),r&&"BLOCKQUOTE"===t(r)[0].tagName&&this.insertAfterLastElement(r),o&&"P"===t(o)[0].tagName&&"BLOCKQUOTE"==t(o).parent()[0].tagName&&this.insertAfterLastElement(o,t(o).parent()[0]),r&&"P"===t(r)[0].tagName&&o&&"BLOCKQUOTE"==t(o)[0].tagName&&this.insertAfterLastElement(r,o)),s&&!e.shiftKey&&this.shortcuts(e,i),s&&90===i&&!e.shiftKey&&!e.altKey)return e.preventDefault(),void(this.opts.buffer.length?this.bufferUndo():this.document.execCommand("undo",!1,!1));if(s&&90===i&&e.shiftKey&&!e.altKey)return e.preventDefault(),void(0!=this.opts.rebuffer.length?this.bufferRedo():this.document.execCommand("redo",!1,!1));if(s&&65===i?this.selectall=!0:i==this.keyCode.LEFT_WIN||s||(this.selectall=!1),i!=this.keyCode.ENTER||e.shiftKey||e.ctrlKey||e.metaKey)i===this.keyCode.ENTER&&(e.ctrlKey||e.shiftKey)&&(this.bufferSet(),e.preventDefault(),this.insertLineBreak());else{if(this.browser("msie")&&1==o.nodeType&&("TD"==o.tagName||"TH"==o.tagName))return e.preventDefault(),this.bufferSet(),this.insertNode(document.createElement("br")),this.callback("enter",e),!1;if(n===!0)return this.buildEventKeydownPre(e,r);if(!this.opts.linebreaks)if(a&&this.opts.rBlockTest.test(a.tagName))this.bufferSet(),setTimeout(t.proxy(function(){var e=this.getBlock();if("DIV"===e.tagName&&!t(e).hasClass("redactor_editor")){var i=t("<p>"+this.opts.invisibleSpace+"</p>");t(e).replaceWith(i),this.selectionStart(i)}},this),1);else if(a===!1){this.bufferSet();var l=t("<p>"+this.opts.invisibleSpace+"</p>");return this.insertNode(l[0]),this.selectionStart(l),this.callback("enter",e),!1}if(this.opts.linebreaks){if(!a||!this.opts.rBlockTest.test(a.tagName))return this.buildEventKeydownInsertLineBreak(e);this.bufferSet(),setTimeout(t.proxy(function(){var e=this.getBlock();"DIV"!==e.tagName&&"P"!==e.tagName||t(e).hasClass("redactor_editor")||this.replaceLineBreak(e)},this),1)}if("BLOCKQUOTE"==a.tagName||"FIGCAPTION"==a.tagName)return this.buildEventKeydownInsertLineBreak(e);this.callback("enter",e)}return i===this.keyCode.TAB&&this.opts.shortcuts?this.buildEventKeydownTab(e,n):void(i===this.keyCode.BACKSPACE&&this.buildEventKeydownBackspace(r))},buildEventKeydownPre:function(e,i){e.preventDefault(),this.bufferSet();var s=t(i).parent().text();return this.insertNode(document.createTextNode("\n")),-1==s.search(/\s$/)&&this.insertNode(document.createTextNode("\n")),this.sync(),this.callback("enter",e),!1},buildEventKeydownTab:function(t,e){return this.opts.tabFocus?this.isEmpty(this.get())?!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(e){if("undefined"!=typeof e.tagName&&/^(H[1-6])$/i.test(e.tagName)){var i;i=t(this.opts.linebreaks===!1?"<p>"+this.opts.invisibleSpace+"</p>":"<br>"+this.opts.invisibleSpace),t(e).replaceWith(i),this.selectionStart(i)}"undefined"!=typeof e.nodeValue&&null!==e.nodeValue&&e.remove&&3===e.nodeType&&null==e.nodeValue.match(/[^\/\u200B]/g)&&e.remove()},buildEventKeydownInsertLineBreak:function(t){this.bufferSet(),t.preventDefault(),this.insertLineBreak(),this.callback("enter",t)},buildEventKeyup:function(e){if(this.rtePaste)return!1;var i=e.which,s=this.getParent(),o=this.getCurrent();if(!this.opts.linebreaks&&3==o.nodeType&&(0==s||"BODY"==s.tagName)){var r=t("<p>").append(t(o).clone());t(o).replaceWith(r);var a=t(r).next();"undefined"!=typeof a[0]&&"BR"==a[0].tagName&&a.remove(),this.selectionEnd(r)}return(this.opts.convertLinks||this.opts.convertImageLinks||this.opts.convertVideoLinks)&&i===this.keyCode.ENTER&&this.buildEventKeyupConverters(),i===this.keyCode.DELETE||i===this.keyCode.BACKSPACE?this.formatEmpty(e):(this.callback("keyup",e),void this.sync())},buildEventKeyupConverters:function(){this.formatLinkify(this.opts.linkProtocol,this.opts.convertLinks,this.opts.convertImageLinks,this.opts.convertVideoLinks,this.opts.linkSize),setTimeout(t.proxy(function(){this.opts.convertImageLinks&&this.observeImages(),this.opts.observeLinks&&this.observeLinks()},this),5)},buildPlugins:function(){this.opts.plugins&&t.each(this.opts.plugins,t.proxy(function(e,i){RedactorPlugins[i]&&(t.extend(this,RedactorPlugins[i]),t.isFunction(RedactorPlugins[i].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=t('<iframe style="width: 100%;" frameborder="0" />').one("load",t.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 e=setInterval(t.proxy(function(){this.$frame.contents().find("body").html()&&(clearInterval(e),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(e){e=e||this.opts.css,this.isString(e)&&this.$frame.contents().find("head").append('<link rel="stylesheet" href="'+e+'" />'),t.isArray(e)&&t.each(e,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.$editor.html()):this.set(this.content,!0,!1),this.buildOptions(),this.buildAfter()},placeholderStart:function(e){return this.isEmpty(e)&&(this.$element.attr("placeholder")&&(this.opts.placeholder=this.$element.attr("placeholder")),""===this.opts.placeholder&&(this.opts.placeholder=!1),this.opts.placeholder!==!1)?(this.opts.focus=!1,this.$editor.one("focus.redactor_placeholder",t.proxy(this.placeholderFocus,this)),t('<span class="redactor_placeholder" data-redactor="verified">').attr("contenteditable",!1).text(this.opts.placeholder)):!1},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()},placeholderRemove:function(){this.opts.placeholder=!1,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(t,e){this.opts.shortcuts&&(t.altKey?48===e?this.shortcutsLoadFormat(t,"p"):49===e?this.shortcutsLoadFormat(t,"h1"):50===e?this.shortcutsLoadFormat(t,"h2"):51===e?this.shortcutsLoadFormat(t,"h3"):52===e?this.shortcutsLoadFormat(t,"h4"):53===e?this.shortcutsLoadFormat(t,"h5"):54===e&&this.shortcutsLoadFormat(t,"h6"):77===e?this.shortcutsLoad(t,"removeFormat"):66===e?this.shortcutsLoad(t,"bold"):73===e?this.shortcutsLoad(t,"italic"):74===e?this.shortcutsLoad(t,"insertunorderedlist"):75===e?this.shortcutsLoad(t,"insertorderedlist"):72===e?this.shortcutsLoad(t,"superscript"):76===e&&this.shortcutsLoad(t,"subscript"))},shortcutsLoad:function(t,e){t.preventDefault(),this.execCommand(e,!1)},shortcutsLoadFormat:function(t,e){t.preventDefault(),this.formatBlocks(e)},focus:function(){this.browser("opera")?this.$editor.focus():this.window.setTimeout(t.proxy(this.focusSet,this,!0),1)},focusEnd:function(){this.focusSet()},focusSet:function(t){this.$editor.focus();var e=this.getRange();e.selectNodeContents(this.$editor[0]),e.collapse(t||!1);var i=this.getSelection();i.removeAllRanges(),i.addRange(e)},toggle:function(t){this.opts.visual?this.toggleCode(t):this.toggleVisual()},toggleVisual:function(){var t=this.$source.hide().val();"undefined"!=typeof this.modified&&(this.modified=this.cleanRemoveSpaces(this.modified,!1)!==this.cleanRemoveSpaces(t,!1)),this.modified&&(this.opts.fullpage&&""===t?this.setFullpageOnInit(t):(this.set(t),this.opts.fullpage&&this.buildBindKeyboard())),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(e){if(9===e.keyCode){var i=t(this),s=i.get(0).selectionStart;return i.val(i.val().substring(0,s)+" "+i.val().substring(i.get(0).selectionEnd)),i.get(0).selectionStart=i.get(0).selectionEnd=s+1,!1}},autosave:function(){var e=!1;this.autosaveInterval=setInterval(t.proxy(function(){var i=this.get();e!==i&&t.ajax({url:this.opts.autosave,type:"post",data:this.$source.attr("name")+"="+escape(encodeURIComponent(i)),success:t.proxy(function(t){this.callback("autosave",!1,t),e=i},this)})},this),1e3*this.opts.autosaveInterval)},toolbarBuild:function(){if(this.opts.air)this.opts.buttons=this.opts.airButtons;else if(!this.opts.buttonSource){var e=this.opts.buttons.indexOf("html"),i=this.opts.buttons[e+1];this.opts.buttons.splice(e,1),"|"===i&&this.opts.buttons.splice(e,1)}if(t.extend(this.opts.toolbar,this.opts.buttonsCustom),t.each(this.opts.buttonsAdd,t.proxy(function(t,e){this.opts.buttons.push(e)},this)),this.opts.toolbar&&t.each(this.opts.toolbar.formatting.dropdown,t.proxy(function(e,i){"-1"==t.inArray(e,this.opts.formattingTags)&&delete this.opts.toolbar.formatting.dropdown[e]},this)),0===this.opts.buttons.length)return!1;if(this.airEnable(),this.$toolbar=t("<ul>").addClass("redactor_toolbar").attr("id","redactor_toolbar_"+this.uuid),this.opts.air?(this.$air=t('<div class="redactor_air">').attr("id","redactor_air_"+this.uuid).hide(),this.$air.append(this.$toolbar),t("body").append(this.$air)):this.opts.toolbarExternal?t(this.opts.toolbarExternal).html(this.$toolbar):this.$box.prepend(this.$toolbar),t.each(this.opts.buttons,t.proxy(function(e,i){if("|"===i)this.$toolbar.append(t(this.opts.buttonSeparator));else if(this.opts.toolbar[i]){var s=this.opts.toolbar[i];if(this.opts.fileUpload===!1&&"file"===i)return!0;this.$toolbar.append(t("<li>").append(this.buttonBuild(i,s)))}},this)),this.$toolbar.find("a").attr("tabindex","-1"),this.opts.toolbarFixed&&(this.toolbarObserveScroll(),t(this.opts.toolbarFixedTarget).on("scroll.redactor",t.proxy(this.toolbarObserveScroll,this))),this.opts.activeButtons){var s=t.proxy(this.buttonActiveObserver,this);this.$editor.on("mouseup.redactor keyup.redactor",s)}},toolbarObserveScroll:function(){var e=t(this.opts.toolbarFixedTarget).scrollTop(),i=this.$box.offset().top,s=0,o=i+this.$box.height()+40;if(e>i){var r="100%";this.opts.toolbarFixedBox&&(s=this.$box.offset().left,r=this.$box.innerWidth(),this.$toolbar.addClass("toolbar_fixed_box")),this.toolbarFixed=!0,this.$toolbar.css({position:"fixed",width:r,zIndex:1005,top:this.opts.toolbarFixedTopOffset+"px",left:s}),o>e?this.$toolbar.css("visibility","visible"):this.$toolbar.css("visibility","hidden")}else this.toolbarFixed=!1,this.$toolbar.css({position:"relative",width:"auto",top:0,left:s}),this.opts.toolbarFixedBox&&this.$toolbar.removeClass("toolbar_fixed_box")},airEnable:function(){this.opts.air&&this.$editor.on("mouseup.redactor keyup.redactor",this,t.proxy(function(e){var i=this.getSelectionText();if("mouseup"===e.type&&""!=i&&this.airShow(e),"keyup"===e.type&&e.shiftKey&&""!=i){var s=t(this.getElement(this.getSelection().focusNode)),o=s.offset(); o.height=s.height(),this.airShow(o,!0)}},this))},airShow:function(e,i){if(this.opts.air){var s,o;if(t(".redactor_air").hide(),i)s=e.left,o=e.top+e.height+14,this.opts.iframe&&(o+=this.$box.position().top-t(this.document).scrollTop(),s+=this.$box.position().left);else{var r=this.$air.innerWidth();s=e.clientX,t(this.document).width()<s+r&&(s-=r),o=e.clientY+14,this.opts.iframe?(o+=this.$box.position().top,s+=this.$box.position().left):o+=t(this.document).scrollTop()}this.$air.css({left:s+"px",top:o+"px"}).show(),this.airBindHide()}},airBindHide:function(){if(this.opts.air){var e=t.proxy(function(e){t(e).on("mousedown.redactor",t.proxy(function(i){0===t(i.target).closest(this.$toolbar).length&&(this.$air.fadeOut(100),this.selectionRemove(),t(e).off(i))},this)).on("keydown.redactor",t.proxy(function(i){i.which===this.keyCode.ESC&&this.getSelection().collapseToStart(),this.$air.fadeOut(100),t(e).off(i)},this))},this);e(document),this.opts.iframe&&e(this.document)}},airBindMousemoveHide:function(){if(this.opts.air){var e=t.proxy(function(e){t(e).on("mousemove.redactor",t.proxy(function(i){0===t(i.target).closest(this.$toolbar).length&&(this.$air.fadeOut(100),t(e).off(i))},this))},this);e(document),this.opts.iframe&&e(this.document)}},dropdownBuild:function(e,i){t.each(i,t.proxy(function(i,s){s.className||(s.className="");var o;"separator"===s.name?o=t('<a class="redactor_separator_drop">'):(o=t('<a href="#" class="'+s.className+" redactor_dropdown_"+i+'">'+s.title+"</a>"),o.on("click",t.proxy(function(t){t.preventDefault&&t.preventDefault(),this.browser("msie")&&(t.returnValue=!1),s.callback&&s.callback.call(this,i,o,s,t),s.exec&&this.execCommand(s.exec,i),s.func&&this[s.func](i),this.buttonActiveObserver(),this.opts.air&&this.$air.fadeOut(100)},this))),e.append(o)},this))},dropdownShow:function(e,i){if(!this.opts.visual)return e.preventDefault(),!1;var s=this.$toolbar.find(".redactor_dropdown_box_"+i),o=this.buttonGet(i);if(o.hasClass("dropact"))this.dropdownHideAll();else{this.dropdownHideAll(),this.buttonActive(i),o.addClass("dropact");var r=o.position();this.toolbarFixed&&(r=o.offset());var a=s.width();r.left+a>t(document).width()&&(r.left-=a);var n=r.left+"px",l=29,c="absolute",d=l+"px";this.opts.toolbarFixed&&this.toolbarFixed?c="fixed":this.opts.air||(d=r.top+l+"px"),s.css({position:c,left:n,top:d}).show()}var h=t.proxy(function(t){this.dropdownHide(t,s)},this);t(document).one("click",h),this.$editor.one("click",h),e.stopPropagation()},dropdownHideAll:function(){this.$toolbar.find("a.dropact").removeClass("redactor_act").removeClass("dropact"),t(".redactor_dropdown").hide()},dropdownHide:function(e,i){t(e.target).hasClass("dropact")||(i.removeClass("dropact"),this.dropdownHideAll())},buttonBuild:function(e,i){var s=t('<a href="javascript:;" title="'+i.title+'" tabindex="-1" class="redactor_btn redactor_btn_'+e+'"></a>');if(s.on("click",t.proxy(function(t){return t.preventDefault&&t.preventDefault(),this.browser("msie")&&(t.returnValue=!1),s.hasClass("redactor_button_disabled")?!1:(this.isFocused()!==!1||i.exec||this.$editor.focus(),i.exec?(this.$editor.focus(),this.execCommand(i.exec,e),this.airBindMousemoveHide()):i.func&&"show"!==i.func?(this[i.func](e),this.airBindMousemoveHide()):i.callback?(i.callback.call(this,e,s,i,t),this.airBindMousemoveHide()):i.dropdown&&this.dropdownShow(t,e),void this.buttonActiveObserver(!1,e))},this)),i.dropdown){var o=t('<div class="redactor_dropdown redactor_dropdown_box_'+e+'" style="display: none;">');o.appendTo(this.$toolbar),this.dropdownBuild(o,i.dropdown)}return s},buttonGet:function(e){return this.opts.toolbar?t(this.$toolbar.find("a.redactor_btn_"+e)):!1},buttonActiveToggle:function(t){var e=this.buttonGet(t);e.hasClass("redactor_act")?e.removeClass("redactor_act"):e.addClass("redactor_act")},buttonActive:function(t){this.buttonGet(t).addClass("redactor_act")},buttonInactive:function(t){this.buttonGet(t).removeClass("redactor_act")},buttonInactiveAll:function(e){t.each(this.opts.toolbar,t.proxy(function(t){t!=e&&this.buttonInactive(t)},this))},buttonActiveVisual:function(){this.$toolbar.find("a.redactor_btn").not("a.redactor_btn_html").removeClass("redactor_button_disabled")},buttonInactiveVisual:function(){this.$toolbar.find("a.redactor_btn").not("a.redactor_btn_html").addClass("redactor_button_disabled")},buttonChangeIcon:function(t,e){this.buttonGet(t).addClass("redactor_btn_"+e)},buttonRemoveIcon:function(t,e){this.buttonGet(t).removeClass("redactor_btn_"+e)},buttonAddSeparator:function(){this.$toolbar.append(t(this.opts.buttonSeparator))},buttonAddSeparatorAfter:function(e){this.buttonGet(e).parent().after(t(this.opts.buttonSeparator))},buttonAddSeparatorBefore:function(e){this.buttonGet(e).parent().before(t(this.opts.buttonSeparator))},buttonRemoveSeparatorAfter:function(t){this.buttonGet(t).parent().next().remove()},buttonRemoveSeparatorBefore:function(t){this.buttonGet(t).parent().prev().remove()},buttonSetRight:function(t){this.opts.toolbar&&this.buttonGet(t).parent().addClass("redactor_btn_right")},buttonSetLeft:function(t){this.opts.toolbar&&this.buttonGet(t).parent().removeClass("redactor_btn_right")},buttonAdd:function(e,i,s,o){if(this.opts.toolbar){var r=this.buttonBuild(e,{title:i,callback:s,dropdown:o});this.$toolbar.append(t("<li>").append(r))}},buttonAddFirst:function(e,i,s,o){if(this.opts.toolbar){var r=this.buttonBuild(e,{title:i,callback:s,dropdown:o});this.$toolbar.prepend(t("<li>").append(r))}},buttonAddAfter:function(e,i,s,o,r){if(this.opts.toolbar){var a=this.buttonBuild(i,{title:s,callback:o,dropdown:r}),n=this.buttonGet(e);0!==n.size()?n.parent().after(t("<li>").append(a)):this.$toolbar.append(t("<li>").append(a))}},buttonAddBefore:function(e,i,s,o,r){if(this.opts.toolbar){var a=this.buttonBuild(i,{title:s,callback:o,dropdown:r}),n=this.buttonGet(e);0!==n.size()?n.parent().before(t("<li>").append(a)):this.$toolbar.append(t("<li>").append(a))}},buttonRemove:function(t,e){var i=this.buttonGet(t);e&&i.parent().next().remove(),i.parent().removeClass("redactor_btn_right"),i.remove()},buttonActiveObserver:function(e,i){var s=this.getParent();if(this.buttonInactiveAll(i),e===!1&&"html"!==i)return void(-1!=t.inArray(i,this.opts.activeButtons)&&this.buttonActiveToggle(i));s&&"A"===s.tagName?this.$toolbar.find("a.redactor_dropdown_link").text(this.opts.curLang.link_edit):this.$toolbar.find("a.redactor_dropdown_link").text(this.opts.curLang.link_insert),this.opts.activeButtonsAdd&&(t.each(this.opts.activeButtonsAdd,t.proxy(function(t,e){this.opts.activeButtons.push(e)},this)),t.extend(this.opts.activeButtonsStates,this.opts.activeButtonsAdd)),t.each(this.opts.activeButtonsStates,t.proxy(function(e,i){0!=t(s).closest(e,this.$editor.get()[0]).length&&this.buttonActive(i)},this));var o=t(s).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);if(o.length){var r=o.css("text-align");switch(r){case"right":this.buttonActive("alignright");break;case"center":this.buttonActive("aligncenter");break;case"justify":this.buttonActive("justify");break;default:this.buttonActive("alignleft")}}},exec:function(t,e,i){"formatblock"===t&&this.browser("msie")&&(e="<"+e+">"),"inserthtml"===t&&this.browser("msie")?(this.$editor.focus(),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){return this.opts.visual?"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"))):(this.$source.focus(),!1)},execUnlink:function(e,i){this.bufferSet();var s=this.currentOrParentIs("A");return s?(t(s).replaceWith(t(s).text()),this.sync(),void this.callback("execCommand",e,i)):void 0},execLists:function(e,i){this.bufferSet();var s=this.getParent(),o=t(s).closest("ol, ul"),r=!1;if(o.length){r=!0;var a=o[0].tagName;("insertunorderedlist"===e&&"OL"===a||"insertorderedlist"===e&&"UL"===a)&&(r=!1)}if(this.selectionSave(),r){var n=this.getNodes(),l=this.getBlocks(n);"undefined"!=typeof n[0]&&n.length>1&&3==n[0].nodeType&&l.unshift(this.getBlock());var c="",d="";t.each(l,t.proxy(function(e,i){if("LI"==i.tagName){var s=t(i),o=s.clone();o.find("ul","ol").remove(),c+=this.opts.linebreaks===!1?this.outerHtml(t("<p>").append(o.contents())):o.html()+"<br>",0==e?(s.addClass("redactor-replaced").empty(),d=this.outerHtml(s)):s.remove()}},this)),html=this.$editor.html().replace(d,"</"+a+">"+c+"<"+a+">"),this.$editor.html(html),this.$editor.find(a+":empty").remove()}else{var h=this.getParent();this.document.execCommand(e);var s=this.getParent(),o=t(s).closest("ol, ul");if(h&&"TD"==h.tagName&&o.wrapAll("<td>"),o.length){(this.browser("msie")||this.browser("mozilla"))&&"LI"!==s.tagName&&t(s).replaceWith(t(s).html());var p=o.parent();this.isParentRedactor(p)&&this.nodeTestBlocks(p[0])&&p.replaceWith(p.contents())}this.browser("mozilla")&&this.$editor.focus()}this.selectionRestore(),this.sync(),this.callback("execCommand",e,i)},indentingIndent:function(){this.indentingStart("indent")},indentingOutdent:function(){this.indentingStart("outdent")},indentingStart:function(e){if(this.bufferSet(),"indent"===e){var i=this.getBlock();if(this.selectionSave(),i&&"LI"==i.tagName){var s=this.getParent(),o=t(s).closest("ol, ul"),r=o[0].tagName,a=this.getBlocks();t.each(a,function(e,i){if("LI"==i.tagName){var s=t(i).prev();if(0!=s.size()&&"LI"==s[0].tagName){var o=s.children("ul, ol");0==o.size()?s.append(t("<"+r+">").append(i)):o.append(i)}}})}else if(i===!1&&this.opts.linebreaks===!0){this.exec("formatBlock","blockquote");var n=this.getBlock(),i=t('<div data-tagblock="">').html(t(n).html());t(n).replaceWith(i);var l=this.normalize(t(i).css("margin-left"))+this.opts.indentValue;t(i).css("margin-left",l+"px")}else{var c=this.getBlocks();t.each(c,t.proxy(function(e,i){var s=!1;if("TD"!==i.tagName){s=-1!==t.inArray(i.tagName,this.opts.alignmentTags)?t(i):t(i).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);var o=this.normalize(s.css("margin-left"))+this.opts.indentValue;s.css("margin-left",o+"px")}},this))}this.selectionRestore()}else{this.selectionSave();var i=this.getBlock();if(i&&"LI"==i.tagName){var a=this.getBlocks(),d=0;this.insideOutdent(i,d,a)}else{var c=this.getBlocks();t.each(c,t.proxy(function(e,i){var s=!1;s=-1!==t.inArray(i.tagName,this.opts.alignmentTags)?t(i):t(i).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);var o=this.normalize(s.css("margin-left"))-this.opts.indentValue;0>=o?this.opts.linebreaks===!0&&"undefined"!=typeof s.data("tagblock")?s.replaceWith(s.html()):(s.css("margin-left",""),this.removeEmptyAttr(s,"style")):s.css("margin-left",o+"px")},this))}this.selectionRestore()}this.sync()},insideOutdent:function(e,i,s){if(e&&"LI"==e.tagName){var o=t(e).parent().parent();0!=o.size()&&"LI"==o[0].tagName?o.after(e):"undefined"!=typeof s[i]?(e=s[i],i++,this.insideOutdent(e,i,s)):this.execCommand("insertunorderedlist")}},alignmentLeft:function(){this.alignmentSet("","JustifyLeft")},alignmentRight:function(){this.alignmentSet("right","JustifyRight")},alignmentCenter:function(){this.alignmentSet("center","JustifyCenter")},alignmentJustify:function(){this.alignmentSet("justify","JustifyFull")},alignmentSet:function(e,i){if(this.bufferSet(),this.oldIE())return this.document.execCommand(i,!1,!1),!0;this.selectionSave();var s=this.getBlock();if(!s&&this.opts.linebreaks){this.exec("formatBlock","blockquote");var o=this.getBlock(),s=t('<div data-tagblock="">').html(t(o).html());t(o).replaceWith(s),t(s).css("text-align",e),this.removeEmptyAttr(s,"style"),""==e&&"undefined"!=typeof t(s).data("tagblock")&&t(s).replaceWith(t(s).html())}else{var r=this.getBlocks();t.each(r,t.proxy(function(i,s){var o=!1;o=-1!==t.inArray(s.tagName,this.opts.alignmentTags)?t(s):t(s).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]),o&&(o.css("text-align",e),this.removeEmptyAttr(o,"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&&(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(e,i){if(i!==!1){var i=[],s=e.match(/<(pre|style|script|title)(.*?)>([\w\W]*?)<\/(pre|style|script|title)>/gi);if(null===s&&(s=[]),this.opts.phpTags){var o=e.match(/<\?php([\w\W]*?)\?>/gi);o&&(s=t.merge(s,o))}s&&t.each(s,function(t,s){e=e.replace(s,"buffer_"+t),i.push(s)})}return e=e.replace(/\n/g," "),e=e.replace(/[\t]*/g,""),e=e.replace(/\n\s*\n/g,"\n"),e=e.replace(/^[\s\n]*/g," "),e=e.replace(/[\s\n]*$/g," "),e=e.replace(/>\s{2,}</g,"> <"),e=this.cleanReplacer(e,i),e=e.replace(/\n\n/g,"\n")},cleanReplacer:function(e,i){return i===!1?e:(t.each(i,function(t,i){e=e.replace("buffer_"+t,i)}),e)},cleanRemoveEmptyTags:function(t){t=t.replace(/<span>([\w\W]*?)<\/span>/gi,"$1"),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 s=i.length,o=0;s>o;++o)t=t.replace(new RegExp(i[o],"gi"),"");return t},cleanParagraphy:function(e){function i(t,i,s){return e.replace(new RegExp(t,i),s)}if(e=t.trim(e),this.opts.linebreaks===!0)return e;if(""===e||"<p></p>"===e)return this.opts.emptyHtml;e+="\n";var s=[],o=e.match(/<(table|div|pre|object)(.*?)>([\w\W]*?)<\/(table|div|pre|object)>/gi);o||(o=[]);var r=e.match(/<!--([\w\W]*?)-->/gi);if(r&&(o=t.merge(o,r)),this.opts.phpTags){var a=e.match(/<section(.*?)rel="redactor-php-tag">([\w\W]*?)<\/section>/gi);a&&(o=t.merge(o,a))}o&&t.each(o,function(t,i){s[t]=i,e=e.replace(i,"{replace"+t+"}\n")}),e=e.replace(/<br \/>\s*<br \/>/gi,"\n\n");var n="(comment|html|body|head|title|meta|style|script|link|iframe|table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|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)";e=i("(<"+n+"[^>]*>)","gi","\n$1"),e=i("(</"+n+">)","gi","$1\n\n"),e=i("\r\n","g","\n"),e=i("\r","g","\n"),e=i("/\n\n+/","g","\n\n");var l=e.split(new RegExp("\ns*\n","g"),-1);e="";for(var c in l)l.hasOwnProperty(c)&&(e+=-1==l[c].search("{replace")?"<p>"+l[c].replace(/^\n+|\n+$/g,"")+"</p>":l[c]);return e=i("<p>s*</p>","gi",""),e=i("<p>([^<]+)</(div|address|form)>","gi","<p>$1</p></$2>"),e=i("<p>s*(</?"+n+"[^>]*>)s*</p>","gi","$1"),e=i("<p>(<li.+?)</p>","gi","$1"),e=i("<p>s*(</?"+n+"[^>]*>)","gi","$1"),e=i("(</?"+n+"[^>]*>)s*</p>","gi","$1"),e=i("(</?"+n+"[^>]*>)s*<br />","gi","$1"),e=i("<br />(s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)","gi","$1"),e=i("\n</p>","gi","</p>"),e=i("<li><p>","gi","<li>"),e=i("</p></li>","gi","</li>"),e=i("</li><p>","gi","</li>"),e=i("<p> ?\n?<p>","gi","<p>"),e=i("</dt><p>","gi","</dt>"),e=i("</dd><p>","gi","</dd>"),e=i("<br></p></blockquote>","gi","</blockquote>"),e=i("<p> *</p>","gi",""),t.each(s,function(t,i){e=e.replace("{replace"+t+"}",i)}),t.trim(e)},cleanConvertInlineTags:function(t,e){var i="strong";"b"===this.opts.boldTag&&(i="b");var s="em";return"i"===this.opts.italicTag&&(s="i"),t=t.replace(/<span style="font-style: italic;">([\w\W]*?)<\/span>/gi,"<"+s+">$1</"+s+">"),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=e!==!0?t.replace(/<strike>([\w\W]*?)<\/strike>/gi,"<del>$1</del>"):t.replace(/<del>([\w\W]*?)<\/del>/gi,"<strike>$1</strike>")},cleanStripTags:function(e){if(""==e||"undefined"==typeof e)return e;var i=!1;this.opts.allowedTags!==!1&&(i=!0);var s=i===!0?this.opts.allowedTags:this.opts.deniedTags,o=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;return e=e.replace(o,function(e,o){return i===!0?t.inArray(o.toLowerCase(),s)>"-1"?e:"":t.inArray(o.toLowerCase(),s)>"-1"?"":e}),e=this.cleanConvertInlineTags(e)},cleanSavePreCode:function(e,i){var s=e.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/gi);return null!==s&&t.each(s,t.proxy(function(t,s){var o=s.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/i);o[3]=o[3].replace(/&nbsp;/g," "),i!==!1&&(o[3]=this.cleanEncodeEntities(o[3])),e=e.replace(s,"<"+o[1]+o[2]+">"+o[3]+"</"+o[1]+">")},this)),e},cleanEncodeEntities:function(t){return t=String(t).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"'),String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},cleanUnverified:function(){var e=this.$editor.find("li, img, a, b, strong, sub, sup, i, em, u, small, strike, del, span, cite");e.filter('[style*="background-color: transparent;"][style*="line-height"]').css("background-color","").css("line-height",""),e.filter('[style*="background-color: transparent;"]').css("background-color",""),e.css("line-height",""),t.each(e,t.proxy(function(t,e){this.removeEmptyAttr(e,"style")},this)),this.$editor.find('div[style="text-align: -webkit-auto;"]').contents().unwrap()},cleanHtml:function(t){var e=0,i=t.length,s=0,o=null,r=null,a="",n="",l="";for(this.cleanlevel=0;i>e;e++){if(s=e,-1==t.substr(e).indexOf("<"))return n+=t.substr(e),this.cleanFinish(n);for(;i>s&&"<"!=t.charAt(s);)s++;for(e!=s&&(l=t.substr(e,s-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=s;i>s&&">"!=t.charAt(s);)s++;a=t.substr(o,s-o),e=s;var c;if("!--"==a.substr(1,3)){if(!a.match(/--$/)){for(;"-->"!=t.substr(s,3);)s++;s+=2,a=t.substr(o,s-o),e=s}"\n"!=n.charAt(n.length-1)&&(n+="\n"),n+=this.cleanGetTabs(),n+=a+">\n"}else"!"==a[1]?n=this.placeTag(a+">",n):"?"==a[1]?n+=a+">\n":(c=a.match(/^<(script|style|pre)/i))?(c[1]=c[1].toLowerCase(),a=this.cleanTag(a),n=this.placeTag(a,n),r=String(t.substr(e+1)).toLowerCase().indexOf("</"+c[1]),r&&(l=t.substr(e+1,r),e+=r,n+=l)):(a=this.cleanTag(a),n=this.placeTag(a,n))}return this.cleanFinish(n)},cleanGetTabs:function(){for(var t="",e=0;e<this.cleanlevel;e++)t+=" ";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 s;s=/\s*([^= ]+)(?:=((['"']).*?\3|[^ ]+))?/.exec(t);)s[2]?e+=s[1].toLowerCase()+"="+s[2]:s[1]&&(e+=s[1].toLowerCase()),e+=" ",t=t.substr(s[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(e){var i=t.trim(this.$editor.html());if(this.opts.linebreaks)""==i&&(e.preventDefault(),this.$editor.html(""),this.focus());else{i=i.replace(/<br\s?\/?>/i,"");var s=i.replace(/<p>\s?<\/p>/gi,"");if(""===i||""===s){e.preventDefault();var o=t(this.opts.emptyHtml).get(0);this.$editor.html(o),this.focus()}}this.sync()},formatBlocks:function(e){this.bufferSet();var i=this.getBlocks();this.selectionSave(),t.each(i,t.proxy(function(i,s){if("LI"!==s.tagName){var o=t(s).parent();if("p"===e){if("P"===s.tagName&&0!=o.size()&&"BLOCKQUOTE"===o[0].tagName||"BLOCKQUOTE"===s.tagName)return void this.formatQuote();if(this.opts.linebreaks)return}else this.formatBlock(e,s)}},this)),this.selectionRestore(),this.sync()},formatBlock:function(e,i){if(i===!1&&(i=this.getBlock()),i===!1)return this.opts.linebreaks===!0&&this.execCommand("formatblock",e),!0;var s="";if("pre"!==e?s=t(i).contents():(s=t(i).html(),""===t.trim(s)&&(s='<span id="selection-marker-1"></span>')),"PRE"===i.tagName&&(e="p"),this.opts.linebreaks===!0&&"p"===e)t(i).replaceWith(t("<div>").append(s).html()+"<br>");else{var o=t("<"+e+">").append(s);t(i).replaceWith(o)}},formatChangeTag:function(e,i,s){s!==!1&&this.selectionSave();var o=t("<"+i+"/>");return t(e).replaceWith(function(){return o.append(t(this).contents())}),s!==!1&&this.selectionRestore(),o},formatQuote:function(){if(this.bufferSet(),this.opts.linebreaks===!1){this.selectionSave();var e=this.getBlocks(),i=!1,s=e.length;if(e){var o="",r="",a=!1,n=!0;if(t.each(e,function(t,e){"P"!==e.tagName&&(n=!1)}),t.each(e,t.proxy(function(l,c){if("BLOCKQUOTE"===c.tagName)this.formatBlock("p",c,!1);else if("P"===c.tagName)if(i=t(c).parent(),"BLOCKQUOTE"==i[0].tagName){var d=t(i).children("p").size();1==d?t(i).replaceWith(c):d==s?(a="blockquote",o+=this.outerHtml(c)):(a="html",o+=this.outerHtml(c),0==l?(t(c).addClass("redactor-replaced").empty(),r=this.outerHtml(c)):t(c).remove())}else n===!1||1==e.length?this.formatBlock("blockquote",c,!1):(a="paragraphs",o+=this.outerHtml(c));else"LI"!==c.tagName&&this.formatBlock("blockquote",c,!1)},this)),a)if("paragraphs"==a)t(e[0]).replaceWith("<blockquote>"+o+"</blockquote>"),t(e).remove();else if("blockquote"==a)t(i).replaceWith(o);else if("html"==a){var l=this.$editor.html().replace(r,"</blockquote>"+o+"<blockquote>");this.$editor.html(l),this.$editor.find("blockquote").each(function(){""==t.trim(t(this).html())&&t(this).remove()})}}this.selectionRestore()}else{var c=this.getBlock();if("BLOCKQUOTE"===c.tagName){this.selectionSave();var l=t.trim(t(c).html()),d=t.trim(this.getSelectionHtml());if(l=l.replace(/<span(.*?)id="selection-marker(.*?)<\/span>/gi,""),l==d)t(c).replaceWith(t(c).html()+"<br>");else{this.inlineFormat("tmp");var h=this.$editor.find("tmp");h.empty();var p=this.$editor.html().replace("<tmp></tmp>",'</blockquote><span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"+d+"<blockquote>");this.$editor.html(p),h.remove(),this.$editor.find("blockquote").each(function(){""==t.trim(t(this).html())&&t(this).remove()})}this.selectionRestore(),this.$editor.find("span#selection-marker-1").attr("id",!1)}else{var u=this.selectionWrap("blockquote"),l=t(u).html(),f=["ul","ol","table","tr","tbody","thead","tfoot","dl"];t.each(f,function(t,e){l=l.replace(new RegExp("<"+e+"(.*?)>","gi"),""),l=l.replace(new RegExp("</"+e+">","gi"),"")});var m=this.opts.blockLevelElements;m.push("td"),t.each(m,function(t,e){l=l.replace(new RegExp("<"+e+"(.*?)>","gi"),""),l=l.replace(new RegExp("</"+e+">","gi"),"<br>")}),t(u).html(l),this.selectionElement(u);var g=t(u).next();0!=g.size()&&"BR"===g[0].tagName&&g.remove()}}this.sync()},blockRemoveAttr:function(e,i){var s=this.getBlocks();t(s).removeAttr(e),this.sync()},blockSetAttr:function(e,i){var s=this.getBlocks();t(s).attr(e,i),this.sync()},blockRemoveStyle:function(e){var i=this.getBlocks();t(i).css(e,""),this.removeEmptyAttr(i,"style"),this.sync()},blockSetStyle:function(e,i){var s=this.getBlocks();t(s).css(e,i),this.sync()},blockRemoveClass:function(e){var i=this.getBlocks();t(i).removeClass(e),this.removeEmptyAttr(i,"class"),this.sync()},blockSetClass:function(e){var i=this.getBlocks();t(i).addClass(e),this.sync()},inlineRemoveClass:function(e){this.selectionSave(),this.inlineEachNodes(function(i){t(i).removeClass(e),this.removeEmptyAttr(i,"class")}),this.selectionRestore(),this.sync()},inlineSetClass:function(e){var i=this.getCurrent();t(i).hasClass(e)||this.inlineMethods("addClass",e)},inlineRemoveStyle:function(e){this.selectionSave(),this.inlineEachNodes(function(i){t(i).css(e,""),this.removeEmptyAttr(i,"style")}),this.selectionRestore(),this.sync()},inlineSetStyle:function(t,e){this.inlineMethods("css",t,e)},inlineRemoveAttr:function(e){this.selectionSave();var i=this.getRange(),s=this.getElement(),o=this.getNodes();(i.collapsed||i.startContainer===i.endContainer&&s)&&(o=t(s)),t(o).removeAttr(e),this.inlineUnwrapSpan(),this.selectionRestore(),this.sync()},inlineSetAttr:function(t,e){this.inlineMethods("attr",t,e)},inlineMethods:function(e,i,s){this.bufferSet(),this.selectionSave();var o=this.getRange(),r=this.getElement();if(!o.collapsed&&o.startContainer!==o.endContainer||!r||this.nodeTestBlocks(r)){this.document.execCommand("fontSize",!1,4);var a=this.$editor.find("font");t.each(a,t.proxy(function(t,o){this.inlineSetMethods(e,o,i,s)},this))}else t(r)[e](i,s);this.selectionRestore(),this.sync()},inlineSetMethods:function(e,i,s,o){var r,a=t(i).parent();return a&&"INLINE"===a[0].tagName&&0!=a[0].attributes.length?(r=a,t(i).replaceWith(t(i).html())):(r=t("<inline>").append(t(i).contents()),t(i).replaceWith(r)),t(r)[e](s,o),r},inlineEachNodes:function(e){var i,s=this.getRange(),o=this.getElement(),r=this.getNodes();(s.collapsed||s.startContainer===s.endContainer&&o)&&(r=t(o),i=!0),t.each(r,t.proxy(function(s,o){if(!i&&"INLINE"!==o.tagName){if("INLINE"!==o.parentNode.tagName||t(o.parentNode).hasClass("redactor_editor"))return;o=o.parentNode}e.call(this,o)},this))},inlineUnwrapSpan:function(){var e=this.$editor.find("inline");t.each(e,t.proxy(function(e,i){var s=t(i);void 0===s.attr("class")&&void 0===s.attr("style")&&s.contents().unwrap()},this))},inlineFormat:function(e){this.selectionSave(),this.document.execCommand("fontSize",!1,4);var i,s=this.$editor.find("font");t.each(s,function(s,o){var r=t("<"+e+"/>").append(t(o).contents());t(o).replaceWith(r),i=r}),this.selectionRestore(),this.sync()},inlineRemoveFormat:function(e){this.selectionSave();var i=e.toUpperCase(),s=this.getNodes(),o=t(this.getParent()).parent();t.each(s,function(t,e){e.tagName===i&&this.inlineRemoveFormatReplace(e)}),o&&o[0].tagName===i&&this.inlineRemoveFormatReplace(o),this.selectionRestore(),this.sync()},inlineRemoveFormatReplace:function(e){t(e).replaceWith(t(e).contents())},insertHtml:function(e,i){var s=this.getCurrent(),o=s.parentNode;this.$editor.focus(),this.bufferSet();var r=t("<div>").append(t.parseHTML(e));e=r.html(),e=this.cleanRemoveEmptyTags(e),r=t("<div>").append(t.parseHTML(e));var a=this.getBlock();if(1==r.contents().length){var n=r.contents()[0].tagName;("P"!=n&&n==a.tagName||"PRE"==n)&&(e=r.text(),r=t("<div>").append(e))}!this.opts.linebreaks&&1==r.contents().length&&3==r.contents()[0].nodeType&&(this.getRangeSelectedNodes().length>2||!s||"BODY"==s.tagName&&!o||"HTML"==o.tagName)&&(e="<p>"+e+"</p>"),e=this.setSpansVerifiedHtml(e),r.contents().length>1&&a||r.contents().is("p, :header, ul, ol, li, div, table, td, blockquote, pre, address, section, header, footer, aside, article")?this.browser("msie")?this.document.selection.createRange().pasteHTML(e):this.document.execCommand("inserthtml",!1,e):this.insertHtmlAdvanced(e,!1),this.selectall&&this.window.setTimeout(t.proxy(function(){this.opts.linebreaks?this.focusEnd():this.selectionEnd(this.$editor.contents().last())},this),1),this.observeStart(),this.setNonEditable(),i!==!1&&this.sync()},insertHtmlAdvanced:function(t,e){var i=this.getSelection();if(i.getRangeAt&&i.rangeCount){var s=i.getRangeAt(0);s.deleteContents();var o=this.document.createElement("div");o.innerHTML=t;for(var r,a,n=this.document.createDocumentFragment();r=o.firstChild;)a=n.appendChild(r);s.insertNode(n),a&&(s=s.cloneRange(),s.setStartAfter(a),s.collapse(!0),i.removeAllRanges(),i.addRange(s))}e!==!1&&this.sync()},insertText:function(e){var i=t(t.parseHTML(e));i.length&&(e=i.text()),this.$editor.focus(),this.browser("msie")?this.document.selection.createRange().pasteHTML(e):this.document.execCommand("inserthtml",!1,e),this.sync()},insertNode:function(t){t=t[0]||t;var e=this.getSelection();e.getRangeAt&&e.rangeCount&&(range=e.getRangeAt(0),range.deleteContents(),range.insertNode(t),range.setEndAfter(t),range.setStartAfter(t),e.removeAllRanges(),e.addRange(range))},insertNodeToCaretPositionFromPoint:function(t,e){var i,s=t.clientX,o=t.clientY;if(this.document.caretPositionFromPoint){var r=this.document.caretPositionFromPoint(s,o);i=this.getRange(),i.setStart(r.offsetNode,r.offset),i.collapse(!0),i.insertNode(e)}else if(this.document.caretRangeFromPoint)i=this.document.caretRangeFromPoint(s,o),i.insertNode(e);else if("undefined"!=typeof document.body.createTextRange){i=this.document.body.createTextRange(),i.moveToPoint(s,o);var a=i.duplicate();a.moveToPoint(s,o),i.setEndPoint("EndToEnd",a),i.select()}},insertAfterLastElement:function(e,i){if("undefined"!=typeof i&&(e=i),this.isEndOfElement()){if(this.opts.linebreaks){var s=t("<div>").append(t.trim(this.$editor.html())).contents();if(this.outerHtml(s.last()[0])!=this.outerHtml(e))return!1}else if(this.$editor.contents().last()[0]!==e)return!1;if(this.bufferSet(),this.opts.linebreaks===!1){var o=t(this.opts.emptyHtml);t(e).after(o),this.selectionStart(o)}else{var o=t('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>",this.document)[0];t(e).after(o),t(o).after(this.opts.invisibleSpace),this.selectionRestore(),this.$editor.find("span#selection-marker-1").removeAttr("id")}}},insertLineBreak:function(){this.selectionSave(),this.$editor.find("#selection-marker-1").before("<br>"+(this.browser("webkit")?this.opts.invisibleSpace:"")),this.selectionRestore()},insertDoubleLineBreak:function(){this.selectionSave(),this.$editor.find("#selection-marker-1").before("<br><br>"+(this.browser("webkit")?this.opts.invisibleSpace:"")),this.selectionRestore()},replaceLineBreak:function(e){var i=t("<br>"+this.opts.invisibleSpace);t(e).replaceWith(i),this.selectionStart(i)},pasteClean:function(e){if(e=this.callback("pasteBefore",!1,e),this.opts.pastePlainText){var i=this.document.createElement("div");return e=e.replace(/<br>|<\/H[1-6]>|<\/p>|<\/div>/gi,"\n"),i.innerHTML=e,e=i.textContent||i.innerText,e=t.trim(e),e=e.replace("\n","<br>"),e=this.cleanParagraphy(e),this.pasteInsert(e), !1}if(this.currentOrParentIs("PRE"))return e=this.pastePre(e),this.pasteInsert(e),!0;if(e=e.replace(/<p(.*?)class="MsoListParagraphCxSpFirst"([\w\W]*?)<\/p>/gi,"<ul><li$2</li>"),e=e.replace(/<p(.*?)class="MsoListParagraphCxSpMiddle"([\w\W]*?)<\/p>/gi,"<li$2</li>"),e=e.replace(/<p(.*?)class="MsoListParagraphCxSpLast"([\w\W]*?)<\/p>/gi,"<li$2</li></ul>"),e=e.replace(/<p(.*?)class="MsoListParagraph"([\w\W]*?)<\/p>/gi,"<ul><li$2</li></ul>"),e=e.replace(/·/g,""),e=e.replace(/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi,""),e=e.replace(/(&nbsp;){2,}/gi,"&nbsp;"),e=e.replace(/&nbsp;/gi," "),e=e.replace(/<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2"),e=e.replace(/<b(.*?)id="docs-internal-guid(.*?)">([\w\W]*?)<\/b>/gi,"$3"),e=this.cleanStripTags(e),e=e.replace(/<td><\/td>/gi,"[td]"),e=e.replace(/<td>&nbsp;<\/td>/gi,"[td]"),e=e.replace(/<td><br><\/td>/gi,"[td]"),e=e.replace(/<td(.*?)colspan="(.*?)"(.*?)>([\w\W]*?)<\/td>/gi,'[td colspan="$2"]$4[/td]'),e=e.replace(/<a(.*?)href="(.*?)"(.*?)>([\w\W]*?)<\/a>/gi,'[a href="$2"]$4[/a]'),e=e.replace(/<iframe(.*?)>([\w\W]*?)<\/iframe>/gi,"[iframe$1]$2[/iframe]"),e=e.replace(/<video(.*?)>([\w\W]*?)<\/video>/gi,"[video$1]$2[/video]"),e=e.replace(/<audio(.*?)>([\w\W]*?)<\/audio>/gi,"[audio$1]$2[/audio]"),e=e.replace(/<embed(.*?)>([\w\W]*?)<\/embed>/gi,"[embed$1]$2[/embed]"),e=e.replace(/<object(.*?)>([\w\W]*?)<\/object>/gi,"[object$1]$2[/object]"),e=e.replace(/<param(.*?)>/gi,"[param$1]"),e=e.replace(/<img(.*?)>/gi,"[img$1]"),e=e.replace(/ class="(.*?)"/gi,""),e=e.replace(/<(\w+)([\w\W]*?)>/gi,"<$1>"),e=e.replace(/<[^\/>][^>]*>(\s*|\t*|\n*|&nbsp;|<br>)<\/[^>]+>/gi,""),e=e.replace(/<div>\s*?\t*?\n*?(<ul>|<ol>|<p>)/gi,"$1"),e=e.replace(/\[td colspan="(.*?)"\]([\w\W]*?)\[\/td\]/gi,'<td colspan="$1">$2</td>'),e=e.replace(/\[td\]/gi,"<td>&nbsp;</td>"),e=e.replace(/\[a href="(.*?)"\]([\w\W]*?)\[\/a\]/gi,'<a href="$1">$2</a>'),e=e.replace(/\[iframe(.*?)\]([\w\W]*?)\[\/iframe\]/gi,"<iframe$1>$2</iframe>"),e=e.replace(/\[video(.*?)\]([\w\W]*?)\[\/video\]/gi,"<video$1>$2</video>"),e=e.replace(/\[audio(.*?)\]([\w\W]*?)\[\/audio\]/gi,"<audio$1>$2</audio>"),e=e.replace(/\[embed(.*?)\]([\w\W]*?)\[\/embed\]/gi,"<embed$1>$2</embed>"),e=e.replace(/\[object(.*?)\]([\w\W]*?)\[\/object\]/gi,"<object$1>$2</object>"),e=e.replace(/\[param(.*?)\]/gi,"<param$1>"),e=e.replace(/\[img(.*?)\]/gi,"<img$1>"),this.opts.convertDivs&&(e=e.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"<p>$2</p>"),e=e.replace(/<\/div><p>/gi,"<p>"),e=e.replace(/<\/p><\/div>/gi,"</p>")),e=this.currentOrParentIs("LI")?e.replace(/<p>([\w\W]*?)<\/p>/gi,"$1<br>"):this.cleanParagraphy(e),e=e.replace(/<span(.*?)>([\w\W]*?)<\/span>/gi,"$2"),e=e.replace(/<img>/gi,""),e=e.replace(/<[^\/>][^>][^img|param|source]*>(\s*|\t*|\n*|&nbsp;|<br>)<\/[^>]+>/gi,""),e=e.replace(/\n{3,}/gi,"\n"),e=e.replace(/<p><p>/gi,"<p>"),e=e.replace(/<\/p><\/p>/gi,"</p>"),e=e.replace(/<li>(\s*|\t*|\n*)<p>/gi,"<li>"),e=e.replace(/<\/p>(\s*|\t*|\n*)<\/li>/gi,"</li>"),this.opts.linebreaks===!0&&(e=e.replace(/<p(.*?)>([\w\W]*?)<\/p>/gi,"$2<br>")),e=e.replace(/<[^\/>][^>][^img|param|source]*>(\s*|\t*|\n*|&nbsp;|<br>)<\/[^>]+>/gi,""),e=e.replace(/<img src="webkit-fake-url\:\/\/(.*?)"(.*?)>/gi,""),e=e.replace(/<td(.*?)>(\s*|\t*|\n*)<p>([\w\W]*?)<\/p>(\s*|\t*|\n*)<\/td>/gi,"<td$1>$3</td>"),e=e.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"$2"),e=e.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"$2"),this.pasteClipboardMozilla=!1,this.browser("mozilla")){if(this.opts.clipboardUpload){var s=e.match(/<img src="data:image(.*?)"(.*?)>/gi);if(null!==s){this.pasteClipboardMozilla=s;for(k in s){var o=s[k].replace("<img",'<img data-mozilla-paste-image="'+k+'" ');e=e.replace(s[k],o)}}}for(;/<br>$/gi.test(e);)e=e.replace(/<br>$/gi,"")}for(e=e.replace(/<p>?([\w\W]*?)<\/p>/gi,"<li>$1</li>");/<font>([\w\W]*?)<\/font>/gi.test(e);)e=e.replace(/<font>([\w\W]*?)<\/font>/gi,"$1");this.pasteInsert(e)},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(e){this.selectall&&(this.opts.linebreaks?this.$editor.html(""):this.$editor.html(this.opts.emptyHtml),this.$editor.focus()),e=this.callback("pasteAfter",!1,e),this.insertHtml(e),this.selectall=!1,setTimeout(t.proxy(function(){this.rtePaste=!1,this.browser("mozilla")&&this.$editor.find("p:empty").remove(),this.pasteClipboardMozilla!==!1&&this.pasteClipboardUploadMozilla()},this),100),this.opts.autoresize?t(this.document.body).scrollTop(this.saveScroll):this.$editor.scrollTop(this.saveScroll)},pasteClipboardUploadMozilla:function(){var e=this.$editor.find("img[data-mozilla-paste-image]");t.each(e,t.proxy(function(e,i){var s=t(i),o=i.src.split(","),r=o[1],a=o[0].split(";")[0].split(":")[1];t.post(this.opts.clipboardUploadUrl,{contentType:a,data:r},t.proxy(function(e){var i="string"==typeof e?t.parseJSON(e):e;s.attr("src",i.filelink),s.removeAttr("data-mozilla-paste-image"),this.sync(),this.callback("imageUpload",s,i)},this))},this))},pasteClipboardUpload:function(e){var i=e.target.result,s=i.split(","),o=s[1],r=s[0].split(";")[0].split(":")[1];this.opts.clipboardUpload?t.post(this.opts.clipboardUploadUrl,{contentType:r,data:o},t.proxy(function(e){var i="string"==typeof e?t.parseJSON(e):e,s='<img src="'+i.filelink+'" id="clipboard-image-marker" />';this.execCommand("inserthtml",s,!1);var o=t(this.$editor.find("img#clipboard-image-marker"));o.length?o.removeAttr("id"):o=!1,this.sync(),o&&this.callback("imageUpload",o,i)},this)):this.insertHtml('<img src="'+i+'" />')},bufferSet:function(t){void 0!==t?this.opts.buffer.push(t):(this.selectionSave(),this.opts.buffer.push(this.$editor.html()),this.selectionRemoveMarkers("buffer"))},bufferUndo:function(){return 0===this.opts.buffer.length?void this.$editor.focus():(this.selectionSave(),this.opts.rebuffer.push(this.$editor.html()),this.selectionRestore(!1,!0),this.$editor.html(this.opts.buffer.pop()),this.selectionRestore(),void setTimeout(t.proxy(this.observeStart,this),100))},bufferRedo:function(){return 0===this.opts.rebuffer.length?(this.$editor.focus(),!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(t.proxy(this.observeStart,this),4))},observeStart:function(){this.observeImages(),this.opts.observeLinks&&this.observeLinks()},observeLinks:function(){this.$editor.find("a").on("click",t.proxy(this.linkObserver,this)),this.$editor.on("click.redactor",t.proxy(function(t){this.linkObserverTooltipClose(t)},this))},observeImages:function(){return this.opts.observeImages===!1?!1:void this.$editor.find("img").each(t.proxy(function(e,i){this.browser("msie")&&t(i).attr("unselectable","on"),this.imageResize(i)},this))},linkObserver:function(e){var i=t(e.target),s=i.offset();if(this.opts.iframe){var o=this.$frame.offset();s.top=o.top+(s.top-t(this.document).scrollTop()),s.left+=o.left}var r=t('<span class="redactor-link-tooltip"></span>'),a=i.attr("href");a.length>24&&(a=a.substring(0,24)+"...");var n=t('<a href="'+i.attr("href")+'" target="_blank">'+a+"</a>").on("click",t.proxy(function(t){this.linkObserverTooltipClose(!1)},this)),l=t('<a href="#">'+this.opts.curLang.edit+"</a>").on("click",t.proxy(function(t){t.preventDefault(),this.linkShow(),this.linkObserverTooltipClose(!1)},this)),c=t('<a href="#">'+this.opts.curLang.unlink+"</a>").on("click",t.proxy(function(t){t.preventDefault(),this.execCommand("unlink"),this.linkObserverTooltipClose(!1)},this));r.append(n),r.append(" | "),r.append(l),r.append(" | "),r.append(c),r.css({top:s.top+20+"px",left:s.left+"px"}),t(".redactor-link-tooltip").remove(),t("body").append(r)},linkObserverTooltipClose:function(e){return e!==!1&&"A"==e.target.tagName?!1:void t(".redactor-link-tooltip").remove()},getSelection:function(){return this.opts.rangy?this.opts.iframe?rangy.getSelection(this.$frame[0]):rangy.getSelection():this.document.getSelection()},getRange:function(){if(this.opts.rangy)return this.opts.iframe?rangy.createRange(this.iframeDoc()):rangy.createRange();if(this.document.getSelection){var t=this.getSelection();if(t.getRangeAt&&t.rangeCount)return t.getRangeAt(0)}return this.document.createRange()},selectionElement:function(t){this.setCaret(t)},selectionStart:function(t){this.selectionSet(t[0]||t,0,null,0)},selectionEnd:function(t){this.selectionSet(t[0]||t,1,null,1)},selectionSet:function(t,e,i,s){null==i&&(i=t),null==s&&(s=e);var o=this.getSelection();if(o){var r=this.getRange();r.setStart(t,e),r.setEnd(i,s);try{o.removeAllRanges()}catch(a){}o.addRange(r)}},selectionWrap:function(t){t=t.toLowerCase();var e=this.getBlock();if(e){var i=this.formatChangeTag(e,t);return this.sync(),i}var s=this.getSelection(),o=s.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(e){var i=0,s=this.getRange(),o=s.cloneRange();return o.selectNodeContents(e),o.setEnd(s.endContainer,s.endOffset),i=t.trim(o.toString()).length},getCaretOffsetRange:function(){return new o(this.getSelection().getRangeAt(0))},setCaret:function(t,e,i){"undefined"==typeof i&&(i=e),t=t[0]||t;var s=this.getRange();s.selectNodeContents(t);var o,r=this.getTextNodesIn(t),a=!1,n=0;if(1==r.length&&e)s.setStart(r[0],e),s.setEnd(r[0],i);else for(var l,c=0;l=r[c++];){if(o=n+l.length,!a&&e>=n&&(o>e||e==o&&c<r.length)&&(s.setStart(l,e-n),a=!0),a&&o>=i){s.setEnd(l,i-n);break}n=o}var d=this.getSelection();d.removeAllRanges(),d.addRange(s)},getTextNodesIn:function(t){var e=[];if(3==t.nodeType)e.push(t);else for(var i=t.childNodes,s=0,o=i.length;o>s;++s)e.push.apply(e,this.getTextNodesIn(i[s]));return e},getCurrent:function(){var t=!1,e=this.getSelection();return e.rangeCount>0&&(t=e.getRangeAt(0).startContainer),this.isParentRedactor(t)},getParent:function(e){return e=e||this.getCurrent(),e?this.isParentRedactor(t(e).parent()[0]):!1},getBlock:function(e){for("undefined"==typeof e&&(e=this.getCurrent());e;){if(this.nodeTestBlocks(e))return t(e).hasClass("redactor_editor")?!1:e;e=e.parentNode}return!1},getBlocks:function(e){var i=[];if("undefined"==typeof e){var s=this.getRange();if(s&&s.collapsed===!0)return[this.getBlock()];var e=this.getNodes(s)}return t.each(e,t.proxy(function(e,s){return this.opts.iframe===!1&&0==t(s).parents("div.redactor_editor").size()?!1:void(this.nodeTestBlocks(s)&&i.push(s))},this)),0===i.length&&(i=[this.getBlock()]),i},nodeTestBlocks:function(t){return 1==t.nodeType&&this.rTestBlock.test(t.nodeName)},tagTestBlock:function(t){return this.rTestBlock.test(t)},getNodes:function(e,i){if("undefined"==typeof e||0==e)var e=this.getRange();if(e&&e.collapsed===!0){if("undefined"==typeof i&&this.tagTestBlock(i)){var s=this.getBlock();return s.tagName==i?[s]:[]}return[this.getCurrent()]}var o=[],r=[],a=this.document.getSelection();if(a.isCollapsed||(o=this.getRangeSelectedNodes(a.getRangeAt(0))),t.each(o,t.proxy(function(e,s){return this.opts.iframe===!1&&0==t(s).parents("div.redactor_editor").size()?!1:void("undefined"==typeof i?""!=t.trim(s.textContent)&&r.push(s):s.tagName==i&&r.push(s))},this)),0==r.length){if("undefined"==typeof i&&this.tagTestBlock(i)){var s=this.getBlock();return s.tagName==i?r.push(s):[]}r.push(this.getCurrent())}return r},getElement:function(e){for(e||(e=this.getCurrent());e;){if(1==e.nodeType)return t(e).hasClass("redactor_editor")?!1:e;e=e.parentNode}return!1},getRangeSelectedNodes:function(t){t=t||this.getRange();var e=t.startContainer,i=t.endContainer;if(e==i)return[e];for(var s=[];e&&e!=i;)s.push(e=this.nextNode(e));for(e=t.startContainer;e&&e!=t.commonAncestorContainer;)s.unshift(e),e=e.parentNode;return s},nextNode:function(t){if(t.hasChildNodes())return t.firstChild;for(;t&&!t.nextSibling;)t=t.parentNode;return t?t.nextSibling:null},getSelectionText:function(){return this.getSelection().toString()},getSelectionHtml:function(){var t="",e=this.getSelection();if(e.rangeCount){for(var i=this.document.createElement("div"),s=e.rangeCount,o=0;s>o;++o)i.appendChild(e.getRangeAt(o).cloneContents());t=i.innerHTML}return this.syncClean(t)},selectionSave:function(){this.isFocused()||this.$editor.focus(),this.opts.rangy?this.savedSel=rangy.saveSelection():this.selectionCreateMarker(this.getRange())},selectionCreateMarker:function(e,i){if(e){var s=t('<span id="selection-marker-1" class="redactor-selection-marker">'+this.opts.invisibleSpace+"</span>",this.document)[0],o=t('<span id="selection-marker-2" class="redactor-selection-marker">'+this.opts.invisibleSpace+"</span>",this.document)[0];e.collapsed===!0?this.selectionSetMarker(e,s,!0):(this.selectionSetMarker(e,s,!0),this.selectionSetMarker(e,o,!1)),this.savedSel=this.$editor.html(),this.selectionRestore(!1,!1)}},selectionSetMarker:function(t,e,i){var s=t.cloneRange();s.collapse(i),s.insertNode(e),s.detach()},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"),s=this.$editor.find("span#selection-marker-2");this.browser("mozilla")?this.$editor.focus():this.isFocused()||this.$editor.focus(),0!=i.length&&0!=s.length?this.selectionSet(i[0],0,s[0],0):0!=i.length&&this.selectionSet(i[0],0,null,0),e!==!1&&(this.selectionRemoveMarkers(),this.savedSel=!1)}},selectionRemoveMarkers:function(e){this.opts.rangy?rangy.removeMarkers(this.savedSel):t.each(this.$editor.find("span.redactor-selection-marker"),function(){var e=t.trim(t(this).html().replace(/[^\u0000-\u1C7F]/g,""));""==e?t(this).remove():t(this).removeAttr("class").removeAttr("id")})},tableShow:function(){this.selectionSave(),this.modalInit(this.opts.curLang.table,this.opts.modal_table,300,t.proxy(function(){t("#redactor_insert_table_btn").click(t.proxy(this.tableInsert,this)),setTimeout(function(){t("#redactor_table_rows").focus()},200)},this))},tableInsert:function(){var e,i,s,o,r=t("#redactor_table_rows").val(),a=t("#redactor_table_columns").val(),n=t("<div></div>"),l=Math.floor(99999*Math.random()),c=t('<table id="table'+l+'"><tbody></tbody></table>');for(e=0;r>e;e++){for(i=t("<tr></tr>"),s=0;a>s;s++)o=t("<td>"+this.opts.invisibleSpace+"</td>"),0===e&&0===s&&o.append('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),t(i).append(o);c.append(i)}n.append(c);var d=n.html();this.modalClose(),this.selectionRestore();var h=this.getBlock()||this.getCurrent();h&&"BODY"!=h.tagName?t(h).after(d):this.insertHtmlAdvanced(d,!1),this.selectionRestore();var p=this.$editor.find("#table"+l);this.buttonActiveObserver(),p.find("span#selection-marker-1").remove(),p.removeAttr("id"),this.sync()},tableDeleteTable:function(){var e=t(this.getParent()).closest("table");return this.isParentRedactor(e)?0==e.size()?!1:(this.bufferSet(),e.remove(),void this.sync()):!1},tableDeleteRow:function(){var e=t(this.getParent()).closest("table");if(!this.isParentRedactor(e))return!1;if(0==e.size())return!1;this.bufferSet();var i=t(this.getParent()).closest("tr"),s=i.prev().length?i.prev():i.next();if(s.length){var o=s.children("td").first();o.length&&o.prepend('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>")}i.remove(),this.selectionRestore(),this.sync()},tableDeleteColumn:function(){var e=t(this.getParent()).closest("table");if(!this.isParentRedactor(e))return!1;if(0==e.size())return!1;this.bufferSet();var i=t(this.getParent()).closest("td"),s=i.get(0).cellIndex;e.find("tr").each(t.proxy(function(e,i){var o=0>s-1?s+1:s-1;0===e&&t(i).find("td").eq(o).prepend('<span id="selection-marker-1">'+this.opts.invisibleSpace+"</span>"),t(i).find("td").eq(s).remove()},this)),this.selectionRestore(),this.sync()},tableAddHead:function(){var e=t(this.getParent()).closest("table");if(!this.isParentRedactor(e))return!1;if(0==e.size())return!1;if(this.bufferSet(),0!==e.find("thead").size())this.tableDeleteHead();else{var i=e.find("tr").first().clone();i.find("td").html(this.opts.invisibleSpace),$thead=t("<thead></thead>"),$thead.append(i),e.prepend($thead),this.sync()}},tableDeleteHead:function(){var e=t(this.getParent()).closest("table");if(!this.isParentRedactor(e))return!1;var i=e.find("thead");return 0==i.size()?!1:(this.bufferSet(),i.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(e){var i=t(this.getParent()).closest("table");if(!this.isParentRedactor(i))return!1;if(0==i.size())return!1;this.bufferSet();var s=t(this.getParent()).closest("tr"),o=s.clone();o.find("td").html(this.opts.invisibleSpace),"after"===e?s.after(o):s.before(o),this.sync()},tableAddColumn:function(e){var i=t(this.getParent()).closest("table");if(!this.isParentRedactor(i))return!1;if(0==i.size())return!1;this.bufferSet();var s=0,o=t(this.getParent()).closest("tr"),r=t(this.getParent()).closest("td");o.find("td").each(t.proxy(function(e,i){t(i)[0]===r[0]&&(s=e)},this)),i.find("tr").each(t.proxy(function(i,o){var r=t(o).find("td").eq(s),a=r.clone();a.html(this.opts.invisibleSpace),"after"===e?r.after(a):r.before(a)},this)),this.sync()},videoShow:function(){this.selectionSave(),this.modalInit(this.opts.curLang.video,this.opts.modal_video,600,t.proxy(function(){t("#redactor_insert_video_btn").click(t.proxy(this.videoInsert,this)),setTimeout(function(){t("#redactor_insert_video_area").focus()},200)},this))},videoInsert:function(){var e=t("#redactor_insert_video_area").val();e=this.cleanStripTags(e),this.selectionRestore();var i=this.getBlock()||this.getCurrent();i?t(i).after(e):this.insertHtmlAdvanced(e,!1),this.sync(),this.modalClose()},linkShow:function(){this.selectionSave();var e=t.proxy(function(){this.insert_link_node=!1;var e=this.getSelection(),i="",s="",o="",r=this.getParent(),a=t(r).parent().get(0);a&&"A"===a.tagName&&(r=a),r&&"A"===r.tagName?(i=r.href,s=t(r).text(),o=r.target,this.insert_link_node=r):s=e.toString(),t(".redactor_link_text").val(s);var n=self.location.href.replace(/\/$/i,""),l=i.replace(n,"");if(this.opts.linkProtocol===!1){var c=new RegExp("^(http|ftp|https)://"+self.location.host,"i");l=l.replace(c,"")}var d=t("#redactor_tabs").find("a");this.opts.linkEmail===!1&&d.eq(1).remove(),this.opts.linkAnchor===!1&&d.eq(2).remove(),this.opts.linkEmail===!1&&this.opts.linkAnchor===!1?(t("#redactor_tabs").remove(),t("#redactor_link_url").val(l)):0===i.search("mailto:")?(this.modalSetTab.call(this,2),t("#redactor_tab_selected").val(2),t("#redactor_link_mailto").val(i.replace("mailto:",""))):0===l.search(/^#/gi)?(this.modalSetTab.call(this,3),t("#redactor_tab_selected").val(3),t("#redactor_link_anchor").val(l.replace(/^#/gi,""))):t("#redactor_link_url").val(l),"_blank"===o&&t("#redactor_link_blank").prop("checked",!0),t("#redactor_insert_link_btn").click(t.proxy(this.linkProcess,this)),setTimeout(function(){t("#redactor_link_url").focus()},200)},this);this.modalInit(this.opts.curLang.link,this.opts.modal_link,460,e)},linkProcess:function(){var e=t("#redactor_tab_selected").val(),i="",s="",o="",r="";if("1"===e){i=t("#redactor_link_url").val(),s=t("#redactor_link_url_text").val(),t("#redactor_link_blank").prop("checked")&&(o=' target="_blank"',r="_blank");var a="((xn--)?[a-z0-9]+(-[a-z0-9]+)*.)+[a-z]{2,}",n=new RegExp("^(http|ftp|https)://"+a,"i"),l=new RegExp("^"+a,"i");-1==i.search(n)&&0==i.search(l)&&this.opts.linkProtocol&&(i=this.opts.linkProtocol+i)}else"2"===e?(i="mailto:"+t("#redactor_link_mailto").val(),s=t("#redactor_link_mailto_text").val()):"3"===e&&(i="#"+t("#redactor_link_anchor").val(),s=t("#redactor_link_anchor_text").val());s=s.replace(/<|>/g,""),this.linkInsert('<a href="'+i+'"'+o+">"+s+"</a>",t.trim(s),i,r)},linkInsert:function(e,i,s,o){this.selectionRestore(),""!==i&&(this.insert_link_node?(this.bufferSet(),t(this.insert_link_node).text(i).attr("href",s),""!==o?t(this.insert_link_node).attr("target",o):t(this.insert_link_node).removeAttr("target"),this.sync()):this.exec("inserthtml",e)),setTimeout(t.proxy(function(){this.opts.observeLinks&&this.observeLinks()},this),5),this.modalClose()},fileShow:function(){this.selectionSave();var e=t.proxy(function(){var e=this.getSelection(),i="";i=this.oldIE()?e.text:e.toString(),t("#redactor_filename").val(i),this.isMobile()||this.draguploadInit("#redactor_file",{url:this.opts.fileUpload,uploadFields:this.opts.uploadFields,success:t.proxy(this.fileCallback,this),error:t.proxy(function(t,e){this.callback("fileUploadError",e)},this),uploadParam:this.opts.fileUploadParam}),this.uploadInit("redactor_file",{auto:!0,url:this.opts.fileUpload,success:t.proxy(this.fileCallback,this),error:t.proxy(function(t,e){this.callback("fileUploadError",e)},this)})},this);this.modalInit(this.opts.curLang.file,this.opts.modal_file,500,e)},fileCallback:function(e){if(this.selectionRestore(),e!==!1){var i=t("#redactor_filename").val();""===i&&(i=e.filename);var s='<a href="'+e.filelink+'" id="filelink-marker">'+i+"</a>";this.browser("webkit")&&this.window.chrome&&(s+="&nbsp;"),this.execCommand("inserthtml",s,!1);var o=t(this.$editor.find("a#filelink-marker"));0!=o.size()?o.removeAttr("id"):o=!1,this.sync(),this.callback("fileUpload",o,e)}this.modalClose()},imageShow:function(){this.selectionSave();var e=t.proxy(function(){if(this.opts.imageGetJson?t.getJSON(this.opts.imageGetJson,t.proxy(function(e){var i={},s=0;t.each(e,t.proxy(function(t,e){"undefined"!=typeof e.folder&&(s++,i[e.folder]=s)},this));var o=!1;if(t.each(e,t.proxy(function(e,s){var r="";"undefined"!=typeof s.title&&(r=s.title);var a=0;t.isEmptyObject(i)||"undefined"==typeof s.folder||(a=i[s.folder],o===!1&&(o=".redactorfolder"+a));var n=t('<img src="'+s.thumb+'" class="redactorfolder redactorfolder'+a+'" rel="'+s.image+'" title="'+r+'" />');t("#redactor_image_box").append(n),t(n).click(t.proxy(this.imageThumbClick,this))},this)),!t.isEmptyObject(i)){t(".redactorfolder").hide(),t(o).show();var r=function(e){t(".redactorfolder").hide(),t(".redactorfolder"+t(e.target).val()).show()},a=t('<select id="redactor_image_box_select">');t.each(i,function(e,i){a.append(t('<option value="'+i+'">'+e+"</option>"))}),t("#redactor_image_box").before(a),a.change(r)}},this)):t("#redactor_tabs").find("a").eq(1).remove(),this.opts.imageUpload||this.opts.s3)this.isMobile()||this.opts.s3!==!1||t("#redactor_file").length&&this.draguploadInit("#redactor_file",{url:this.opts.imageUpload,uploadFields:this.opts.uploadFields,success:t.proxy(this.imageCallback,this),error:t.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:t.proxy(this.imageCallback,this),error:t.proxy(function(t,e){this.callback("imageUploadError",e)},this)}):t("#redactor_file").on("change.redactor",t.proxy(this.s3handleFileSelect,this));else if(t(".redactor_tab").hide(),this.opts.imageGetJson){var e=t("#redactor_tabs").find("a");e.eq(0).remove(),e.eq(1).addClass("redactor_tabs_act"),t("#redactor_tab2").show()}else t("#redactor_tabs").remove(),t("#redactor_tab3").show();t("#redactor_upload_btn").click(t.proxy(this.imageCallbackLink,this)),this.opts.imageUpload||this.opts.imageGetJson||setTimeout(function(){t("#redactor_file_link").focus()},200)},this);this.modalInit(this.opts.curLang.image,this.opts.modal_image,610,e)},imageEdit:function(e){var i=e,s=i.parent().parent(),o=t.proxy(function(){t("#redactor_file_alt").val(i.attr("alt")),t("#redactor_image_edit_src").attr("href",i.attr("src")),t("#redactor_form_image_align").val(i.css("float")),"A"===t(s).get(0).tagName&&(t("#redactor_file_link").val(t(s).attr("href")),"_blank"==t(s).attr("target")&&t("#redactor_link_blank").prop("checked",!0)),t("#redactor_image_delete_btn").click(t.proxy(function(){this.imageRemove(i)},this)),t("#redactorSaveBtn").click(t.proxy(function(){this.imageSave(i)},this))},this);this.modalInit(this.opts.curLang.edit,this.opts.modal_image_edit,380,o)},imageRemove:function(e){var i=t(e).parent();t(e).remove(),i.length&&"P"===i[0].tagName&&(this.$editor.focus(),this.selectionStart(i)),this.callback("imageDelete",e),this.modalClose(),this.sync()},imageSave:function(e){var i=t(e),s=i.parent();i.attr("alt",t("#redactor_file_alt").val());var o=t("#redactor_form_image_align").val();if("left"===o)i.css({"float":"left",margin:"0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin+" 0"});else if("right"===o)i.css({"float":"right",margin:"0 0 "+this.opts.imageFloatMargin+" "+this.opts.imageFloatMargin});else{var r=i.closest("#redactor-image-box");0!=r.size()&&r.css({"float":"",margin:""}),i.css({"float":"",margin:""})}var a=t.trim(t("#redactor_file_link").val());if(""!==a){var n=!1;if(t("#redactor_link_blank").prop("checked")&&(n=!0),"A"!==s.get(0).tagName){var l=t('<a href="'+a+'">'+this.outerHtml(e)+"</a>");n&&l.attr("target","_blank"),i.replaceWith(l)}else s.attr("href",a),n?s.attr("target","_blank"):s.removeAttr("target")}else"A"===s.get(0).tagName&&s.replaceWith(this.outerHtml(e));this.modalClose(),this.observeImages(),this.sync()},imageResizeHide:function(e){if(e!==!1&&0!=t(e.target).parent().size()&&"redactor-image-box"===t(e.target).parent()[0].id)return!1;var i=this.$editor.find("#redactor-image-box");if(0==i.size())return!1;this.$editor.find("#redactor-image-editter, #redactor-image-resizer").remove();var s=i[0].style.margin;"0px"!=s&&(i.find("img").css("margin",s),i.css("margin","")),i.find("img").css("opacity",""),i.replaceWith(function(){return t(this).contents()}),t(document).off("click.redactor-image-resize-hide"),this.$editor.off("click.redactor-image-resize-hide"),this.$editor.off("keydown.redactor-image-delete"),this.sync()},imageResize:function(e){var i=t(e);i.on("mousedown",t.proxy(function(){this.imageResizeHide(!1)},this)),i.on("dragstart",t.proxy(function(){this.$editor.on("drop.redactor-image-inside-drop",t.proxy(function(){setTimeout(t.proxy(function(){this.observeImages(),this.$editor.off("drop.redactor-image-inside-drop"),this.sync()},this),1)},this))},this)),i.on("click",t.proxy(function(e){if(0!=this.$editor.find("#redactor-image-box").size())return!1;var s,o,r=i.width()/i.height(),a=20,n=this.imageResizeControls(i),l=!1;n.on("mousedown",function(t){l=!0,t.preventDefault(),r=i.width()/i.height(),s=Math.round(t.pageX-i.eq(0).offset().left),o=Math.round(t.pageY-i.eq(0).offset().top)}),t(this.document.body).on("mousemove",t.proxy(function(t){if(l){var e=(Math.round(t.pageX-i.eq(0).offset().left)-s,Math.round(t.pageY-i.eq(0).offset().top)-o),n=i.height(),c=parseInt(n,10)+e,d=Math.round(c*r);d>a&&(i.width(d),100>d?this.imageEditter.css({marginTop:"-7px",marginLeft:"-13px",fontSize:"9px",padding:"3px 5px"}):this.imageEditter.css({marginTop:"-11px",marginLeft:"-18px",fontSize:"11px",padding:"7px 10px"})),s=Math.round(t.pageX-i.eq(0).offset().left),o=Math.round(t.pageY-i.eq(0).offset().top),this.sync()}},this)).on("mouseup",function(){l=!1}),this.$editor.on("keydown.redactor-image-delete",t.proxy(function(t){var e=t.which;(this.keyCode.BACKSPACE==e||this.keyCode.DELETE==e)&&(this.imageResizeHide(!1),this.imageRemove(i))},this)),t(document).on("click.redactor-image-resize-hide",t.proxy(this.imageResizeHide,this)),this.$editor.on("click.redactor-image-resize-hide",t.proxy(this.imageResizeHide,this))},this))},imageResizeControls:function(e){var i=t('<span id="redactor-image-box" data-redactor="verified">');i.css({position:"relative",display:"inline-block",lineHeight:0,outline:"1px dashed rgba(0, 0, 0, .6)","float":e.css("float")}),i.attr("contenteditable",!1);var s=e[0].style.margin;"0px"!=s&&(i.css("margin",s),e.css("margin","")),e.css("opacity",.5).after(i),this.imageEditter=t('<span id="redactor-image-editter" data-redactor="verified">'+this.opts.curLang.edit+"</span>"),this.imageEditter.css({position:"absolute",zIndex:2,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",t.proxy(function(){this.imageEdit(e)},this)),i.append(this.imageEditter);var o=t('<span id="redactor-image-resizer" data-redactor="verified"></span>');return o.css({position:"absolute",zIndex:2,lineHeight:1,cursor:"nw-resize",bottom:"-4px",right:"-5px",border:"1px solid #fff",backgroundColor:"#000",width:"8px",height:"8px"}),o.attr("contenteditable",!1),i.append(o),i.append(e),o},imageThumbClick:function(e){var i='<img id="image-marker" src="'+t(e.target).attr("rel")+'" alt="'+t(e.target).attr("title")+'" />';this.opts.paragraphy&&(i="<p>"+i+"</p>"),this.imageInsert(i,!0)},imageCallbackLink:function(){var e=t("#redactor_file_link").val();if(""!==e){var i='<img id="image-marker" src="'+e+'" />';this.opts.linebreaks===!1&&(i="<p>"+i+"</p>"),this.imageInsert(i,!0)}else this.modalClose()},imageCallback:function(t){this.imageInsert(t)},imageInsert:function(e,i){if(this.selectionRestore(),e!==!1){var s="";i!==!0?(s='<img id="image-marker" src="'+e.filelink+'" />',this.opts.paragraphy&&(s="<p>"+s+"</p>")):s=e,this.execCommand("inserthtml",s,!1);var o=t(this.$editor.find("img#image-marker"));o.length?o.removeAttr("id"):o=!1,this.sync(),i!==!0&&this.callback("imageUpload",o,e)}this.modalClose(),this.observeImages()},modalTemplatesInit:function(){t.extend(this.opts,{modal_file:String()+'<section><div id="redactor-progress" class="redactor-progress redactor-progress-striped" style="display: none;"><div id="redactor-progress-bar" class="redactor-progress-bar" style="width: 100%;"></div></div><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+'" class="btn btn-file btn-default" /></div></form></section>',modal_image_edit:String()+"<section><label>"+this.opts.curLang.title+'</label><input id="redactor_file_alt" class="redactor_input" /><label>'+this.opts.curLang.link+'</label><input 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="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>&nbsp;&nbsp;&nbsp;<button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button><input type="button" name="save" class="redactor_modal_btn redactor_modal_action_btn" id="redactorSaveBtn" value="'+this.opts.curLang.save+'" /></footer>',modal_image:String()+'<section><div id="redactor_tabs"><a href="#" class="redactor_tabs_act">'+this.opts.curLang.upload+'</a><a href="#">'+this.opts.curLang.choose+'</a><a href="#">'+this.opts.curLang.link+'</a></div><div id="redactor-progress" class="redactor-progress redactor-progress-striped" style="display: none;"><div id="redactor-progress-bar" class="redactor-progress-bar" style="width: 100%;"></div></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+'" class="btn btn-file btn-default" /></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" /></div></section><footer><button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button><input type="button" name="upload" class="redactor_modal_btn redactor_modal_action_btn" id="redactor_upload_btn" value="'+this.opts.curLang.insert+'" /></footer>', modal_link:String()+'<section><form id="redactorInsertLinkForm" method="post" action=""><div id="redactor_tabs"><a href="#" class="redactor_tabs_act">URL</a><a href="#">Email</a><a href="#">'+this.opts.curLang.anchor+'</a></div><input type="hidden" id="redactor_tab_selected" value="1" /><div class="redactor_tab" id="redactor_tab1"><label>URL</label><input type="text" id="redactor_link_url" class="redactor_input" /><label>'+this.opts.curLang.text+'</label><input type="text" class="redactor_input redactor_link_text" id="redactor_link_url_text" /><label><input type="checkbox" id="redactor_link_blank"> '+this.opts.curLang.link_new_tab+'</label></div><div class="redactor_tab" id="redactor_tab2" style="display: none;"><label>Email</label><input type="text" id="redactor_link_mailto" class="redactor_input" /><label>'+this.opts.curLang.text+'</label><input type="text" class="redactor_input redactor_link_text" id="redactor_link_mailto_text" /></div><div class="redactor_tab" id="redactor_tab3" style="display: none;"><label>'+this.opts.curLang.anchor+'</label><input type="text" class="redactor_input" id="redactor_link_anchor" /><label>'+this.opts.curLang.text+'</label><input type="text" class="redactor_input redactor_link_text" id="redactor_link_anchor_text" /></div></form></section><footer><button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button><input type="button" class="redactor_modal_btn redactor_modal_action_btn" id="redactor_insert_link_btn" value="'+this.opts.curLang.insert+'" /></footer>',modal_table:String()+"<section><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><input type="button" name="upload" class="redactor_modal_btn redactor_modal_action_btn" id="redactor_insert_table_btn" value="'+this.opts.curLang.insert+'" /></footer>',modal_video:String()+'<section><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><input type="button" class="redactor_modal_btn redactor_modal_action_btn" id="redactor_insert_video_btn" value="'+this.opts.curLang.insert+'" /></footer>'})},modalInit:function(e,i,s,o){var r=t("#redactor_modal_overlay");r.length||(this.$overlay=r=t('<div id="redactor_modal_overlay" style="display: none;"></div>'),t("body").prepend(this.$overlay)),this.opts.modalOverlay&&r.show().on("click",t.proxy(this.modalClose,this));var a=t("#redactor_modal");a.length||(this.$modal=a=t('<div id="redactor_modal" style="display: none;"><div id="redactor_modal_close">&times;</div><header id="redactor_modal_header"></header><div id="redactor_modal_inner"></div></div>'),t("body").append(this.$modal)),t("#redactor_modal_close").on("click",t.proxy(this.modalClose,this)),this.hdlModalClose=t.proxy(function(t){return t.keyCode===this.keyCode.ESC?(this.modalClose(),!1):void 0},this),t(document).keyup(this.hdlModalClose),this.$editor.keyup(this.hdlModalClose),this.modalcontent=!1,0==i.indexOf("#")?(this.modalcontent=t(i),t("#redactor_modal_inner").empty().append(this.modalcontent.html()),this.modalcontent.html("")):t("#redactor_modal_inner").empty().append(i),a.find("#redactor_modal_header").html(e),"undefined"!=typeof t.fn.draggable&&(a.draggable({handle:"#redactor_modal_header"}),a.find("#redactor_modal_header").css("cursor","move"));var n=t("#redactor_tabs");if(n.length){var l=this;n.find("a").each(function(e,i){e++,t(i).on("click",function(i){if(i.preventDefault(),n.find("a").removeClass("redactor_tabs_act"),t(this).addClass("redactor_tabs_act"),t(".redactor_tab").hide(),t("#redactor_tab"+e).show(),t("#redactor_tab_selected").val(e),l.isMobile()===!1){var s=a.outerHeight();a.css("margin-top","-"+(s+10)/2+"px")}})})}a.find(".redactor_btn_modal_close").on("click",t.proxy(this.modalClose,this)),this.opts.autoresize===!0?this.saveModalScroll=this.document.body.scrollTop:this.saveModalScroll=this.$editor.scrollTop(),this.isMobile()===!1?(a.css({position:"fixed",top:"-2000px",left:"50%",width:s+"px",marginLeft:"-"+(s+60)/2+"px"}).show(),this.modalSaveBodyOveflow=t(document.body).css("overflow"),t(document.body).css("overflow","hidden")):a.css({position:"fixed",width:"100%",height:"100%",top:"0",left:"0",margin:"0",minHeight:"300px"}).show(),"function"==typeof o&&o(),this.isMobile()===!1&&setTimeout(function(){var t=a.outerHeight();a.css({top:"50%",height:"auto",minHeight:"auto",marginTop:"-"+(t+10)/2+"px"})},10)},modalClose:function(){return t("#redactor_modal_close").off("click",this.modalClose),t("#redactor_modal").fadeOut("fast",t.proxy(function(){var e=t("#redactor_modal_inner");this.modalcontent!==!1&&(this.modalcontent.html(e.html()),this.modalcontent=!1),e.html(""),this.opts.modalOverlay&&t("#redactor_modal_overlay").hide().off("click",this.modalClose),t(document).unbind("keyup",this.hdlModalClose),this.$editor.unbind("keyup",this.hdlModalClose),this.selectionRestore(),this.opts.autoresize&&this.saveModalScroll?t(this.document.body).scrollTop(this.saveModalScroll):this.opts.autoresize===!1&&this.saveModalScroll&&this.$editor.scrollTop(this.saveModalScroll)},this)),this.isMobile()===!1&&t(document.body).css("overflow",this.modalSaveBodyOveflow?this.modalSaveBodyOveflow:"visible"),!1},modalSetTab:function(e){t(".redactor_tab").hide(),t("#redactor_tabs").find("a").removeClass("redactor_tabs_act").eq(e-1).addClass("redactor_tabs_act"),t("#redactor_tab"+e).show()},s3handleFileSelect:function(t){for(var e,i=t.target.files,s=0;e=i[s];s++)this.s3uploadFile(e)},s3uploadFile:function(e){this.s3executeOnSignedUrl(e,t.proxy(function(t){this.s3uploadToS3(e,t)},this))},s3executeOnSignedUrl:function(e,i){var s=new XMLHttpRequest;s.open("GET",this.opts.s3+"?name="+e.name+"&type="+e.type,!0),s.overrideMimeType("text/plain; charset=x-user-defined"),s.onreadystatechange=function(e){4==this.readyState&&200==this.status?(t("#redactor-progress").fadeIn(),i(decodeURIComponent(this.responseText))):4==this.readyState&&200!=this.status},s.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(e,i){var s=this.s3createCORSRequest("PUT",i);s&&(s.onload=t.proxy(function(){if(200==s.status){t("#redactor-progress, #redactor-progress-drag").hide();var e=i.split("?");if(!e[0])return!1;this.selectionRestore();var o="";o='<img id="image-marker" src="'+e[0]+'" />',this.opts.paragraphy&&(o="<p>"+o+"</p>"),this.execCommand("inserthtml",o,!1);var r=t(this.$editor.find("img#image-marker"));r.length?r.removeAttr("id"):r=!1,this.sync(),this.callback("imageUpload",r,!1),this.modalClose(),this.observeImages()}},this),s.onerror=function(){},s.upload.onprogress=function(t){},s.setRequestHeader("Content-Type",e.type),s.setRequestHeader("x-amz-acl","public-read"),s.send(e))},uploadInit:function(e,i){this.uploadOptions={url:!1,success:!1,error:!1,start:!1,trigger:!1,auto:!1,input:!1},t.extend(this.uploadOptions,i);var s=t("#"+e);s.length&&"INPUT"===s[0].tagName?(this.uploadOptions.input=s,this.el=t(s[0].form)):this.el=s,this.element_action=this.el.attr("action"),this.uploadOptions.auto?t(this.uploadOptions.input).change(t.proxy(function(t){this.el.submit(function(t){return!1}),this.uploadSubmit(t)},this)):this.uploadOptions.trigger&&t("#"+this.uploadOptions.trigger).click(t.proxy(this.uploadSubmit,this))},uploadSubmit:function(e){t("#redactor-progress").fadeIn(),this.uploadForm(this.element,this.uploadFrame())},uploadFrame:function(){this.id="f"+Math.floor(99999*Math.random());var e=this.document.createElement("div"),i='<iframe style="display:none" id="'+this.id+'" name="'+this.id+'"></iframe>';return e.innerHTML=i,t(e).appendTo("body"),this.uploadOptions.start&&this.uploadOptions.start(),t("#"+this.id).load(t.proxy(this.uploadLoaded,this)),this.id},uploadForm:function(e,i){if(this.uploadOptions.input){var s="redactorUploadForm"+this.id,o="redactorUploadFile"+this.id;this.form=t('<form action="'+this.uploadOptions.url+'" method="POST" target="'+i+'" name="'+s+'" id="'+s+'" enctype="multipart/form-data" />'),this.opts.uploadFields!==!1&&"object"==typeof this.opts.uploadFields&&t.each(this.opts.uploadFields,t.proxy(function(e,i){null!=i&&0===i.toString().indexOf("#")&&(i=t(i).val());var s=t("<input/>",{type:"hidden",name:e,value:i});t(this.form).append(s)},this));var r=this.uploadOptions.input,a=t(r).clone();t(r).attr("id",o).before(a).appendTo(this.form),t(this.form).css("position","absolute").css("top","-2000px").css("left","-2000px").appendTo("body"),this.form.submit()}else e.attr("target",i).attr("method","POST").attr("enctype","multipart/form-data").attr("action",this.uploadOptions.url),this.element.submit()},uploadLoaded:function(){var e,i=t("#"+this.id)[0];if(e=i.contentDocument?i.contentDocument:i.contentWindow?i.contentWindow.document:window.frames[this.id].document,this.uploadOptions.success)if(t("#redactor-progress").hide(),"undefined"!=typeof e){var s=e.body.innerHTML,o=s.match(/\{(.|\n)*\}/)[0];o=o.replace(/^\[/,""),o=o.replace(/\]$/,"");var r=t.parseJSON(o);"undefined"==typeof r.error?this.uploadOptions.success(r):(this.uploadOptions.error(this,r),this.modalClose())}else this.modalClose(),alert("Upload failed!");this.el.attr("action",this.element_action),this.el.attr("target","")},draguploadInit:function(e,i){return this.draguploadOptions=t.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},i),void 0===window.FormData?!1:(this.droparea=t('<div class="redactor_droparea"></div>'),this.dropareabox=t('<div class="redactor_dropareabox">'+this.draguploadOptions.text+"</div>"),this.dropalternative=t('<div class="redactor_dropalternative">'+this.draguploadOptions.atext+"</div>"),this.droparea.append(this.dropareabox),t(e).before(this.droparea),t(e).before(this.dropalternative),this.dropareabox.on("dragover",t.proxy(function(){return this.draguploadOndrag()},this)),this.dropareabox.on("dragleave",t.proxy(function(){return this.draguploadOndragleave()},this)),void(this.dropareabox.get(0).ondrop=t.proxy(function(t){t.preventDefault(),this.dropareabox.removeClass("hover").addClass("drop"),this.dragUploadAjax(this.draguploadOptions.url,t.dataTransfer.files[0],!1,!1,!1,this.draguploadOptions.uploadParam)},this)))},dragUploadAjax:function(e,i,s,o,r,a){if(!s){var n=t.ajaxSettings.xhr();n.upload&&n.upload.addEventListener("progress",t.proxy(this.uploadProgress,this),!1),t.ajaxSetup({xhr:function(){return n}})}var l=new FormData;a!==!1?l.append(a,i):l.append("file",i),this.opts.uploadFields!==!1&&"object"==typeof this.opts.uploadFields&&t.each(this.opts.uploadFields,t.proxy(function(e,i){null!=i&&0===i.toString().indexOf("#")&&(i=t(i).val()),l.append(e,i)},this)),t.ajax({url:e,dataType:"html",data:l,cache:!1,contentType:!1,processData:!1,type:"POST",success:t.proxy(function(e){e=e.replace(/^\[/,""),e=e.replace(/\]$/,"");var i="string"==typeof e?t.parseJSON(e):e;if(s){o.fadeOut("slow",function(){t(this).remove()});var a=t("<img>");a.attr("src",i.filelink).attr("id","drag-image-marker"),this.insertNodeToCaretPositionFromPoint(r,a[0]);var n=t(this.$editor.find("img#drag-image-marker"));n.length?n.removeAttr("id"):n=!1,this.sync(),this.observeImages(),n&&this.callback("imageUpload",n,i),"undefined"!=typeof i.error&&this.callback("imageUploadError",i)}else"undefined"==typeof i.error?this.draguploadOptions.success(i):(this.draguploadOptions.error(this,i),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)},normalize:function(t){return"undefined"==typeof t?0:parseInt(t.replace("px",""),10)},outerHtml:function(e){return t("<div>").append(t(e).eq(0).clone()).html()},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},browser:function(t){var e=navigator.userAgent.toLowerCase(),i=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\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]:i[1]==t},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(e){return e?this.opts.iframe?e:0==t(e).parents("div.redactor_editor").length||t(e).hasClass("redactor_editor")?!1:e:!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 e=this.getBlock(),i=this.getCaretOffset(e),s=t.trim(t(e).text()).replace(/\n\r\n/g,""),o=s.length;return i==o?!0:!1},isFocused:function(){var e,i=this.getSelection();return i&&i.rangeCount&&i.rangeCount>0&&(e=i.getRangeAt(0).startContainer),e?this.opts.iframe?this.getCaretOffsetRange().equals()?!this.$editor.is(e):!0:0!=t(e).closest("div.redactor_editor").length:!1},removeEmptyAttr:function(e,i){""==t(e).attr(i)&&t(e).removeAttr(i)},removeFromArrayByValue:function(t,e){for(var i=null;-1!==(i=t.indexOf(e));)t.splice(i,1);return t}},e.prototype.init.prototype=e.prototype,t.Redactor.fn.formatLinkify=function(e,i,s,o,r){for(var a=/(^|&lt;|\s)(www\..+?\..+?)(\s|&gt;|$)/g,n=/(^|&lt;|\s)(((https?|ftp):\/\/|mailto:).+?)(\s|&gt;|$)/g,l=/(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/gi,c=/^.*(youtu.be\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/,d=/https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/,h=(this.$editor?this.$editor.get(0):this).childNodes,p=h.length;p--;){var u=h[p];if(3===u.nodeType){var f=u.nodeValue;if(o&&f){var m='<iframe width="500" height="281" src="',g='" frameborder="0" allowfullscreen></iframe>';f.match(c)?(f=f.replace(c,m+"//www.youtube.com/embed/$2"+g),t(u).after(f).remove()):f.match(d)&&(f=f.replace(d,m+"//player.vimeo.com/video/$2"+g),t(u).after(f).remove())}if(s&&f&&f.match(l)&&(f=f.replace(l,'<img src="$1">'),t(u).after(f).remove()),i&&f&&(f.match(a)||f.match(n))){var b=f.match(a)||f.match(n);b=b[0],b.length>r&&(b=b.substring(0,r)+"..."),f=f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(a,'$1<a href="'+e+'$2">'+b+"</a>$3").replace(n,'$1<a href="$2">'+b+"</a>$5"),t(u).after(f).remove()}}else 1!==u.nodeType||/^(a|button|textarea)$/i.test(u.tagName)||t.Redactor.fn.formatLinkify.call(u,e,i,s,o,r)}}}(jQuery),!RedactorPlugins)var RedactorPlugins={};RedactorPlugins.fontcolor={init:function(){for(var t=["#ffffff","#000000","#eeece1","#1f497d","#4f81bd","#c0504d","#9bbb59","#8064a2","#4bacc6","#f79646","#ffff00","#f2f2f2","#7f7f7f","#ddd9c3","#c6d9f0","#dbe5f1","#f2dcdb","#ebf1dd","#e5e0ec","#dbeef3","#fdeada","#fff2ca","#d8d8d8","#595959","#c4bd97","#8db3e2","#b8cce4","#e5b9b7","#d7e3bc","#ccc1d9","#b7dde8","#fbd5b5","#ffe694","#bfbfbf","#3f3f3f","#938953","#548dd4","#95b3d7","#d99694","#c3d69b","#b2a2c7","#b7dde8","#fac08f","#f2c314","#a5a5a5","#262626","#494429","#17365d","#366092","#953734","#76923c","#5f497a","#92cddc","#e36c09","#c09100","#7f7f7f","#0c0c0c","#1d1b10","#0f243e","#244061","#632423","#4f6128","#3f3151","#31859b","#974806","#7f6000"],e=["backcolor","fontcolor"],i=0;2>i;i++){var s=e[i],o=jQuery('<div class="redactor_dropdown redactor_dropdown_box_'+s+'" style="display: none; width: 210px;">');this.pickerBuild(o,s,t),$(this.$toolbar).append(o),this.buttonAddFirst(s,this.opts.curLang[s],jQuery.proxy(function(t,e,i,s){this.dropdownShow(s,t)},this))}},pickerBuild:function(t,e,i){var s="color";"backcolor"===e&&(s="background-color");for(var o=this,r=function(t){t.preventDefault();var e=jQuery(this);o.pickerSet(e.data("rule"),e.attr("rel"))},a=i.length,n=0;a>n;n++){var l=i[n],c=jQuery('<a rel="'+l+'" data-rule="'+s+'" href="#" style="float: left; font-size: 0; border: 2px solid #fff; padding: 0; margin: 0; width: 15px; height: 15px;"></a>');c.css("background-color",l),t.append(c),c.on("click",r)}var d=jQuery('<a href="#" style="display: block; clear: both; padding: 4px 0; font-size: 11px; line-height: 1;"></a>').html(this.opts.curLang.none).on("click",function(t){t.preventDefault(),o.pickerSet(s,!1)});t.append(d)},pickerSet:function(t,e){this.bufferSet(),this.$editor.focus(),this.inlineRemoveStyle(t),e!==!1&&this.inlineSetStyle(t,e),this.opts.air&&this.$air.fadeOut(100),this.sync()}};