Файловый менеджер - Редактировать - /home/pimjdymy/public_html/revisionroad/themes/ee/asset/javascript/compressed/fields/rte/redactor/redactor.min.js
Назад
if("undefined"==typeof CodeMirror)var CodeMirror=void 0;if("undefined"==typeof jQuery)var jQuery=void 0;!function(){var t={};t.settings={},t.post=function(t){return new e("post",t)},t.get=function(t){return new e("get",t)},t.request=function(t,i){return new e(t,i)};var e=function(e,i){var s={method:e,url:"",before:function(){},success:function(){},error:function(){},data:!1,async:!0,headers:{}};this.p=this.extend(s,i),this.p=this.extend(this.p,t.settings),this.p.method=this.p.method.toUpperCase(),this.prepareData(),this.xhr=new XMLHttpRequest,this.xhr.open(this.p.method,this.p.url,this.p.async),this.setHeaders();var n="function"!=typeof this.p.before||this.p.before(this.xhr);n!==!1&&this.send()};e.prototype={extend:function(t,e){if(e)for(var i in e)t[i]=e[i];return t},prepareData:function(){["POST","PUT"].indexOf(this.p.method)===-1||this.isFormData()||(this.p.headers["Content-Type"]="application/x-www-form-urlencoded"),"object"!=typeof this.p.data||this.isFormData()||(this.p.data=this.toParams(this.p.data)),"GET"===this.p.method&&(this.p.url=this.p.data?this.p.url+"?"+this.p.data:this.p.url)},setHeaders:function(){this.xhr.setRequestHeader("X-Requested-With",this.p.headers["X-Requested-With"]||"XMLHttpRequest");for(var t in this.p.headers)this.xhr.setRequestHeader(t,this.p.headers[t])},isFormData:function(){return"undefined"!=typeof window.FormData&&this.p.data instanceof window.FormData},isComplete:function(){return!(this.xhr.status<200||this.xhr.status>=300&&304!==this.xhr.status)},send:function(){this.p.async?(this.xhr.onload=this.loaded.bind(this),this.xhr.send(this.p.data)):(this.xhr.send(this.p.data),this.loaded.call(this))},loaded:function(){if(this.isComplete()){var t=this.parseResponse();"function"==typeof this.p.success&&this.p.success(t,this.xhr)}else{var t=this.parseResponse();"function"==typeof this.p.error&&this.p.error(t,this.xhr,this.xhr.status)}},parseResponse:function(){var t=this.xhr.response,e=this.parseJson(t);return e?e:t},parseJson:function(t){try{var e=JSON.parse(t);if(e&&"object"==typeof e)return e}catch(i){}return!1},toParams:function(t){return Object.keys(t).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])}).join("&")}};var i=[0],s="data"+(new Date).getTime(),n="is-hidden",r="is-hidden-mobile",o=function(t,e){return this.parse(t,e)};o.ready=function(t){"loading"!==document.readyState?t():document.addEventListener("DOMContentLoaded",t)},o.prototype={get sdom(){return!0},get length(){return this.nodes.length},parse:function(t,e){var i,s=/^\s*<(\w+|!)[^>]*>/;if(t){if(t.sdom)return this.nodes=t.nodes,t;i="string"!=typeof t?t.nodeType&&11===t.nodeType?t.childNodes:t.nodeType||t===window?[t]:t:s.test(t)?this.create(t):this._query(t,e)}else i=[];this.nodes=this._slice(i)},create:function(t){if(/^<(\w+)\s*\/?>(?:<\/\1>|)$/.test(t))return[document.createElement(RegExp.$1)];var e=[],i=document.createElement("div"),s=i.childNodes;i.innerHTML=t;for(var n=0,r=s.length;n<r;n++)e.push(s[n]);return e},add:function(t){this.nodes=this.nodes.concat(this._toArray(t))},get:function(t){return this.nodes[t||0]||!1},getAll:function(){return this.nodes},eq:function(t){return new o(this.nodes[t])},first:function(){return new o(this.nodes[0])},last:function(){return new o(this.nodes[this.nodes.length-1])},contents:function(){return this.get().childNodes},each:function(t){for(var e=this.nodes.length,i=0;i<e;i++)t.call(this,this.nodes[i].sdom?this.nodes[i].get():this.nodes[i],i);return this},is:function(t){return this.filter(t).length>0},filter:function(t){var e;return void 0===t?this:(e="function"==typeof t?t:function(e){return t instanceof Node?t===e:t&&t.sdom?t.nodes.indexOf(e)!==-1:(e.matches=e.matches||e.msMatchesSelector||e.webkitMatchesSelector,1===e.nodeType&&e.matches(t||"*"))},new o(this.nodes.filter(e)))},not:function(t){return this.filter(function(e){return!new o(e).is(t||!0)})},find:function(t){var e=[];return this.each(function(i){for(var s=this._query(t||"*",i),n=0;n<s.length;n++)e.push(s[n])}),new o(e)},children:function(t){var e=[];return this.each(function(t){if(t.children)for(var i=t.children,s=0;s<i.length;s++)e.push(i[s])}),new o(e).filter(t)},parent:function(t){var e=[];return this.each(function(t){t.parentNode&&e.push(t.parentNode)}),new o(e).filter(t)},parents:function(t,e){e=this._getContext(e);var i=[];return this.each(function(s){for(var n=s.parentNode;n&&n!==e;)t?new o(n).is(t)&&i.push(n):i.push(n),n=n.parentNode}),new o(i)},closest:function(t,e){e=this._getContext(e),t=t.sdom?t.get():t;var i=[],s=t&&t.nodeType;return this.each(function(n){do if(s&&n===t||new o(n).is(t))return i.push(n);while((n=n.parentNode)&&n!==e)}),new o(i)},next:function(t){return this._getSibling(t,"nextSibling")},nextElement:function(t){return this._getSibling(t,"nextElementSibling")},prev:function(t){return this._getSibling(t,"previousSibling")},prevElement:function(t){return this._getSibling(t,"previousElementSibling")},css:function(t,e){if(void 0===e&&"object"!=typeof t){var i=this.get();return"width"===t||"height"===t?i.style?this._getHeightOrWidth(t,i,!1)+"px":void 0:i.style?getComputedStyle(i,null)[t]:void 0}return this.each(function(i){var s={};"object"==typeof t?s=t:s[t]=e;for(var n in s)i.style&&(i.style[n]=s[n])})},attr:function(t,e,i){if(i=i?"data-":"",void 0===e&&"object"!=typeof t){var s=this.get();return s&&3!==s.nodeType?"checked"===t?s.checked:this._getBooleanFromStr(s.getAttribute(i+t)):void 0}return this.each(function(s){var n={};"object"==typeof t?n=t:n[t]=e;for(var r in n)3!==s.nodeType&&("checked"===r?s.checked=n[r]:s.setAttribute(i+r,n[r]))})},data:function(t,e){if(void 0===t){var i=/^data-(.+)$/,s=this.get().attributes,n={},r=function(t){return t[1].toUpperCase()};for(var o in s)if(s[o]&&i.test(s[o].nodeName)){var a=s[o].nodeName.match(i)[1],l=s[o].value;a=a.replace(/-([a-z])/g,r),l=this._isObjectString(l)?this._toObject(l):this._isNumber(l)?parseFloat(l):this._getBooleanFromStr(l),n[a]=l}return n}return this.attr(t,e,!0)},val:function(t){if(void 0===t){var e=this.get();return e.type&&"checkbox"===e.type?e.checked:e.value}return this.each(function(e){e.value=t})},removeAttr:function(t){return this.each(function(e){var i=function(t){3!==e.nodeType&&e.removeAttribute(t)};t.split(" ").forEach(i)})},removeData:function(t){return this.each(function(e){var i=function(t){3!==e.nodeType&&e.removeAttribute("data-"+t)};t.split(" ").forEach(i)})},dataset:function(t,e){return this.each(function(s){i[this.dataindex(s)][t]=e})},dataget:function(t){return i[this.dataindex(this.get())][t]},dataindex:function(t){var e=t[s],n=i.length;return e||(e=t[s]=n,i[e]={}),e},addClass:function(t){return this._eachClass(t,"add")},removeClass:function(t){return this._eachClass(t,"remove")},toggleClass:function(t){return this._eachClass(t,"toggle")},hasClass:function(t){return this.nodes.some(function(e){return!!e.classList&&e.classList.contains(t)})},empty:function(){return this.each(function(t){t.innerHTML=""})},html:function(t){return void 0===t?this.get().innerHTML||"":this.empty().append(t)},text:function(t){return void 0===t?this.get().textContent||"":this.each(function(e){e.textContent=t})},after:function(t){return this._inject(t,function(t,e){if("string"==typeof t)e.insertAdjacentHTML("afterend",t);else if(null!==e.parentNode)for(var i=t instanceof Node?[t]:this._toArray(t).reverse(),s=0;s<i.length;s++)e.parentNode.insertBefore(i[s],e.nextSibling);return e})},before:function(t){return this._inject(t,function(t,e){if("string"==typeof t)e.insertAdjacentHTML("beforebegin",t);else for(var i=t instanceof Node?[t]:this._toArray(t),s=0;s<i.length;s++)e.parentNode.insertBefore(i[s],e);return e})},append:function(t){return this._inject(t,function(t,e){if("string"==typeof t||"number"==typeof t)e.insertAdjacentHTML("beforeend",t);else for(var i=t instanceof Node?[t]:this._toArray(t),s=0;s<i.length;s++)e.appendChild(i[s]);return e})},prepend:function(t){return this._inject(t,function(t,e){if("string"==typeof t||"number"==typeof t)e.insertAdjacentHTML("afterbegin",t);else for(var i=t instanceof Node?[t]:this._toArray(t).reverse(),s=0;s<i.length;s++)e.insertBefore(i[s],e.firstChild);return e})},wrap:function(t){return this._inject(t,function(t,e){var i="string"==typeof t||"number"==typeof t?this.create(t)[0]:t instanceof Node?t:this._toArray(t)[0];return e.parentNode&&e.parentNode.insertBefore(i,e),i.appendChild(e),new o(i)})},unwrap:function(){return this.each(function(t){var e=new o(t);return e.replaceWith(e.contents())})},replaceWith:function(t){return this._inject(t,function(t,e){for(var i=document.createDocumentFragment(),s="string"==typeof t||"number"==typeof t?this.create(t):t instanceof Node?[t]:this._toArray(t),n=0;n<s.length;n++)i.appendChild(s[n]);var r=i.childNodes[0];return e.parentNode&&e.parentNode.replaceChild(i,e),r})},remove:function(){return this.each(function(t){t.parentNode&&t.parentNode.removeChild(t)})},clone:function(t){var e=[];return this.each(function(i){var s=this._clone(i);t&&(s=this._cloneEvents(i,s)),e.push(s)}),new o(e)},show:function(){return this.each(function(t){if(t.style&&this._hasDisplayNone(t)){var e,i=t.getAttribute("domTargetShow"),s=!!t.classList&&t.classList.contains(n),o=!!t.classList&&t.classList.contains(r);s?(e=n,t.classList.remove(n)):o?(e=r,t.classList.remove(r)):t.style.display=i?i:"block",e&&t.setAttribute("domTargetHide",e),t.removeAttribute("domTargetShow")}}.bind(this))},hide:function(){return this.each(function(t){if(t.style&&!this._hasDisplayNone(t)){var e=t.style.display,i=t.getAttribute("domTargetHide");i===n?t.classList.add(n):i===r?t.classList.add(r):("block"!==e&&t.setAttribute("domTargetShow",e),t.style.display="none"),t.removeAttribute("domTargetHide")}})},scrollTop:function(t){var e=this.get(),i=e===window,s=9===e.nodeType,n=s?document.scrollingElement||document.body.parentNode||document.body||document.documentElement:e;return void 0!==t?void(i?window.scrollTo(0,t):n.scrollTop=t):s?"undefined"!=typeof window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop?document.body.scrollTop:0:i?window.pageYOffset:n.scrollTop},offset:function(){return this._getDim("Offset")},position:function(){return this._getDim("Position")},width:function(t,e){return this._getSize("width","Width",t,e)},height:function(t,e){return this._getSize("height","Height",t,e)},outerWidth:function(){return this._getInnerOrOuter("width","outer")},outerHeight:function(){return this._getInnerOrOuter("height","outer")},innerWidth:function(){return this._getInnerOrOuter("width","inner")},innerHeight:function(){return this._getInnerOrOuter("height","inner")},click:function(){return this._triggerEvent("click")},focus:function(){return this._triggerEvent("focus")},trigger:function(t){return this.each(function(e){for(var i=t.split(" "),s=0;s<i.length;s++){var n,r={bubbles:!0,cancelable:!0};try{n=new window.CustomEvent(i[s],r)}catch(o){n=document.createEvent("CustomEvent"),n.initCustomEvent(i[s],!0,!0)}e.dispatchEvent(n)}})},on:function(t,e,i){return this.each(function(s){for(var n=t.split(" "),r=0;r<n.length;r++){var o=this._getEventName(n[r]),a=this._getEventNamespace(n[r]);e=i?this._getOneHandler(e,t):e,s.addEventListener(o,e),s._e=s._e||{},s._e[a]=s._e[a]||{},s._e[a][o]=s._e[a][o]||[],s._e[a][o].push(e)}})},one:function(t,e){return this.on(t,e,!0)},off:function(t,e){var i=function(t,e,i){return t===i},s=function(t,e,i,s){return e===s},n=function(t,e,i,s){return t===i&&e===s},r=function(){return!0};return void 0===t?this.each(function(t){this._offEvent(t,!1,!1,e,r)}):this.each(function(r){for(var o=t.split(" "),a=0;a<o.length;a++){var l=this._getEventName(o[a]),h=this._getEventNamespace(o[a]);"_events"===h?this._offEvent(r,l,h,e,i):l||"_events"===h?this._offEvent(r,l,h,e,n):this._offEvent(r,l,h,e,s)}})},serialize:function(t){for(var e={},i=this.get().elements,s=0;s<i.length;s++){var n=i[s];if((!/(checkbox|radio)/.test(n.type)||n.checked)&&n.name&&!n.disabled&&"file"!==n.type){if("select-multiple"===n.type)for(var r=0;r<n.options.length;r++){var o=n.options[r];o.selected&&(e[n.name]=o.value)}e[n.name]=this._isNumber(n.value)?parseFloat(n.value):this._getBooleanFromStr(n.value)}}return t?e:this._toParams(e)},ajax:function(t,i){if("undefined"!=typeof e){var s=this.attr("method")||"post",n={url:this.attr("action"),data:this.serialize(),success:t,error:i};return new e(s,n)}},_queryContext:function(t,e){return e=this._getContext(e),3!==e.nodeType&&"function"==typeof e.querySelectorAll?e.querySelectorAll(t):[]},_query:function(t,e){if(e)return this._queryContext(t,e);if(/^[.#]?[\w-]*$/.test(t)){if("#"===t[0]){var i=document.getElementById(t.slice(1));return i?[i]:[]}return"."===t[0]?document.getElementsByClassName(t.slice(1)):document.getElementsByTagName(t)}return document.querySelectorAll(t)},_getContext:function(t){return t="string"==typeof t?document.querySelector(t):t,t&&t.sdom?t.get():t||document},_inject:function(t,e){for(var i=this.nodes.length,s=[];i--;){var n="function"==typeof t?t.call(this,this.nodes[i]):t,r=0===i?n:this._clone(n),a=e.call(this,r,this.nodes[i]);a&&(a.sdom?s.push(a.get()):s.push(a))}return new o(s)},_cloneEvents:function(t,e){var i=t._e;if(i){e._e=i;for(var s in i._events)for(var n=0;n<i._events[s].length;n++)e.addEventListener(s,i._events[s][n])}return e},_clone:function(t){if("undefined"!=typeof t)return"string"==typeof t?t:t instanceof Node||t.nodeType?t.cloneNode(!0):"length"in t?[].map.call(this._toArray(t),function(t){return t.cloneNode(!0)}):void 0},_slice:function(t){return t&&0!==t.length?t.length?[].slice.call(t.nodes||t):[t]:[]},_eachClass:function(t,e){return this.each(function(i){if(t){var s=function(t){i.classList&&i.classList[e](t)};t.split(" ").forEach(s)}})},_triggerEvent:function(t){var e=this.get();return e&&3!==e.nodeType&&e[t](),this},_getOneHandler:function(t,e){var i=this;return function(){t.apply(this,arguments),i.off(e)}},_getEventNamespace:function(t){var e=t.split("."),i=e[1]?e[1]:"_events";return e[2]?i+e[2]:i},_getEventName:function(t){return t.split(".")[0]},_offEvent:function(t,e,i,s,n){for(var r in t._e)for(var o in t._e[r])if(n(o,r,e,i))for(var a=t._e[r][o],l=0;l<a.length;l++)"undefined"!=typeof s&&a[l].toString()!==s.toString()||(t.removeEventListener(o,a[l]),t._e[r][o].splice(l,1),0===t._e[r][o].length&&delete t._e[r][o],0===Object.keys(t._e[r]).length&&delete t._e[r])},_getInnerOrOuter:function(t,e){return this[t](void 0,e)},_getDocSize:function(t,e){var i=t.body,s=t.documentElement;return Math.max(i["scroll"+e],i["offset"+e],s["client"+e],s["scroll"+e],s["offset"+e])},_getSize:function(t,e,i,s){if(void 0===i){var n=this.get();return i=3===n.nodeType?0:9===n.nodeType?this._getDocSize(n,e):n===window?window["inner"+e]:this._getHeightOrWidth(t,n,s||"normal"),Math.round(i)}return this.each(function(e){i=parseFloat(i),i+=this._adjustResultHeightOrWidth(t,e,s||"normal"),new o(e).css(t,i+"px")}.bind(this))},_getHeightOrWidth:function(t,e,i){if(!e)return 0;var s=t.charAt(0).toUpperCase()+t.slice(1),n=0,r=getComputedStyle(e,null),a=new o(e),l=a.parents().filter(function(t){return 1===t.nodeType&&"none"===getComputedStyle(t,null).display&&t});if("none"===r.display&&l.add(e),0!==l.length){var h="visibility: hidden !important; display: block !important;",c=[];l.each(function(t){var e=new o(t),i=e.attr("style");null!==i&&c.push(i),e.attr("style",null!==i?i+";"+h:h)}),n=a.get()["offset"+s]-this._adjustResultHeightOrWidth(t,e,i),l.each(function(t,e){var i=new o(t);void 0===c[e]?i.removeAttr("style"):i.attr("style",c[e])})}else n=e["offset"+s]-this._adjustResultHeightOrWidth(t,e,i);return n},_adjustResultHeightOrWidth:function(t,e,i){if(!e||i===!1)return 0;var s=0,n=getComputedStyle(e,null),r="border-box"===n.boxSizing;return"height"===t?(("inner"===i||"normal"===i&&r)&&(s+=(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0)),"outer"===i&&(s-=(parseFloat(n.marginTop)||0)+(parseFloat(n.marginBottom)||0))):(("inner"===i||"normal"===i&&r)&&(s+=(parseFloat(n.borderLeftWidth)||0)+(parseFloat(n.borderRightWidth)||0)),"outer"===i&&(s-=(parseFloat(n.marginLeft)||0)+(parseFloat(n.marginRight)||0))),s},_getDim:function(t){var e=this.get();return 3===e.nodeType?{top:0,left:0}:this["_get"+t](e)},_getPosition:function(t){return{top:t.offsetTop,left:t.offsetLeft}},_getOffset:function(t){if("undefined"!=typeof t&&t!==!1){var e=t.getBoundingClientRect(),i=t.ownerDocument,s=i.documentElement,n=i.defaultView;return{top:e.top+n.pageYOffset-s.clientTop,left:e.left+n.pageXOffset-s.clientLeft}}},_getSibling:function(t,e){t=t&&t.sdom?t.get():t;var i,s=t&&t.nodeType;return this.each(function(n){for(;n=n[e];)if(s&&n===t||new o(n).is(t))return void(i=n)}),new o(i)},_toArray:function(t){if(t instanceof NodeList){for(var e=[],i=0;i<t.length;i++)e[i]=t[i];return e}return void 0===t?[]:t.sdom?t.nodes:t},_toParams:function(t){var e="";for(var i in t)e+="&"+this._encodeUri(i)+"="+this._encodeUri(t[i]);return e.replace(/^&/,"")},_toObject:function(t){return new Function("return "+t)()},_encodeUri:function(t){return encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")},_isNumber:function(t){return!isNaN(t)&&!isNaN(parseFloat(t))},_isObjectString:function(t){return t.search(/^{/)!==-1},_getBooleanFromStr:function(t){return"true"===t||"false"!==t&&t},_hasDisplayNone:function(t){return"none"===t.style.display||"none"===(t.currentStyle?t.currentStyle.display:getComputedStyle(t,null).display)}};var a=0,l=function(t,e){return h(t,e,[].slice.call(arguments,2))};l.app=[],l.version="3.5.2",l.options={},l.modules={},l.services={},l.classes={},l.plugins={},l.mixins={},l.modals={},l.lang={},l.dom=function(t,e){return new o(t,e)},l.ajax=t,l.Dom=o,l.keycodes={BACKSPACE:8,DELETE:46,UP:38,DOWN:40,ENTER:13,SPACE:32,ESC:27,TAB:9,CTRL:17,META:91,SHIFT:16,ALT:18,RIGHT:39,LEFT:37},l.env={plugin:"plugins",module:"modules",service:"services","class":"classes",mixin:"mixins"},"undefined"!=typeof jQuery&&!function(t){t.fn.redactor=function(t){return h(this.toArray(),t,[].slice.call(arguments,1))}}(jQuery);var h=function(t,e,i){for(var s,n="redactor",r=Array.isArray(t)?t:t&&t.nodeType?[t]:document.querySelectorAll(t),o="string"==typeof e||"function"==typeof e,h=[],d=0;d<r.length;d++){var u=r[d],p=l.dom(u);if(s=p.dataget(n),s||o||(s=new c(u,e,a),p.dataset(n,s),l.app[a]=s,a++),s&&o){var f="destroy"===e;e=f?"stop":e;var m;"function"==typeof e?m=e.apply(s,i):(i.unshift(e),m=s.api.apply(s,i)),void 0!==m&&h.push(m),f&&p.dataset(n,!1)}}return 0===h.length||1===h.length?0===h.length?s:h[0]:h};l.add=function(t,e,i){if("undefined"!=typeof l.env[t])if(i.translations&&(l.lang=l.extend(!0,{},l.lang,i.translations)),i.modals&&(l.modals=l.extend(!0,{},l.modals,i.modals)),"mixin"===t)l[l.env[t]][e]=i;else{var s=function(){};if(s.prototype=i,i.mixins)for(var n=0;n<i.mixins.length;n++)l.inherit(s,l.mixins[i.mixins[n]]);l[l.env[t]][e]=s}},l.addLang=function(t,e){"undefined"==typeof l.lang[t]&&(l.lang[t]={}),l.lang[t]=l.extend(l.lang[t],e)},l.create=function(t){var e=t.split("."),i=[].slice.call(arguments,1),s="classes";"undefined"!=typeof l.env[e[0]]&&(s=l.env[e[0]],t=e.slice(1).join("."));var n=new l[s][t];if(n.init){var r=n.init.apply(n,i);return r?r:n}return n},l.inherit=function(t,e){var i=function(){};i.prototype=e;var s=new i;for(var n in t.prototype)t.prototype.__lookupGetter__(n)?s.__defineGetter__(n,t.prototype.__lookupGetter__(n)):s[n]=t.prototype[n];return t.prototype=s,t.prototype["super"]=e,t},l.error=function(t){throw t},l.extend=function(){var t={},e=!1,i=0,s=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(e=arguments[0],i++);for(var n=function(i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e&&"[object Object]"===Object.prototype.toString.call(i[s])?t[s]=l.extend(!0,t[s],i[s]):t[s]=i[s])};i<s;i++){var r=arguments[i];n(r)}return t},l.opts={animation:!0,lang:"en",direction:"ltr",spellcheck:!0,structure:!1,scrollTarget:!1,styles:!0,stylesClass:"redactor-styles",placeholder:!1,source:!0,showSource:!1,inline:!1,breakline:!1,markup:"p",enterKey:!0,clickToEdit:!1,clickToSave:!1,clickToCancel:!1,focus:!1,focusEnd:!1,minHeight:!1,maxHeight:!1,maxWidth:!1,plugins:[],callbacks:{},preClass:!1,preSpaces:4,tabindex:!1,tabAsSpaces:!1,tabKey:!0,autosave:!1,autosaveName:!1,autosaveData:!1,autosaveMethod:"post",toolbar:!0,toolbarFixed:!0,toolbarFixedTarget:document,toolbarFixedTopOffset:0,toolbarExternal:!1,toolbarContext:!0,air:!1,formatting:["p","blockquote","pre","h1","h2","h3","h4","h5","h6"],formattingAdd:!1,formattingHide:!1,buttons:["html","format","bold","italic","deleted","lists","image","file","link"],buttonsTextLabeled:!1,buttonsAdd:[],buttonsAddFirst:[],buttonsAddAfter:!1,buttonsAddBefore:!1,buttonsHide:[],buttonsHideOnMobile:[],imageUpload:!1,imageUploadParam:"file",imageData:!1,imageEditable:!0,imageCaption:!0,imageLink:!0,imagePosition:!1,imageResizable:!1,imageFloatMargin:"10px",imageFigure:!0,imageObserve:!0,imageSrcData:!1,fileUpload:!1,fileUploadParam:"file",fileData:!1,fileAttachment:!1,uploadData:!1,dragUpload:!0,multipleUpload:!1,clipboardUpload:!0,uploadBase64:!1,linkTarget:!1,linkTitle:!1,linkNewTab:!0,linkNofollow:!1,linkSize:30,linkValidation:!0,cleanOnEnter:!0,cleanInlineOnEnter:!1,paragraphize:!0,removeScript:!0,removeNewLines:!1,removeComments:!0,replaceTags:{b:"strong",i:"em",strike:"del"},pastePlainText:!1,pasteLinkTarget:!1,pasteImages:!0,pasteLinks:!0,pasteClean:!0,pasteKeepStyle:[],pasteKeepClass:[],pasteKeepAttrs:["td","th"],pasteBlockTags:["pre","h1","h2","h3","h4","h5","h6","table","tbody","thead","tfoot","th","tr","td","ul","ol","li","blockquote","p","figure","figcaption"],pasteInlineTags:["a","img","br","strong","ins","code","del","span","samp","kbd","sup","sub","mark","var","cite","small","b","u","em","i","abbr"],activeButtons:{b:"bold",strong:"bold",i:"italic",em:"italic",del:"deleted",strike:"deleted",u:"underline"},activeButtonsAdd:{},activeButtonsObservers:{},autoparse:!0,autoparseStart:!0,autoparsePaste:!0,autoparseLinks:!0,autoparseImages:!0,autoparseVideo:!0,autoparseHttps:!1,shortcodes:{"p.":{format:"p"},"quote.":{format:"blockquote"},"pre.":{format:"pre"},"h1.":{format:"h1"},"h2.":{format:"h2"},"h3.":{format:"h3"},"h4.":{format:"h4"},"h5.":{format:"h5"},"h6.":{format:"h6"},"*.":{format:"ul"}},shortcodesAdd:!1,shortcuts:{"ctrl+shift+m, meta+shift+m":{api:"module.inline.clearformat"},"ctrl+b, meta+b":{api:"module.inline.format",args:"b"},"ctrl+i, meta+i":{api:"module.inline.format",args:"i"},"ctrl+u, meta+u":{api:"module.inline.format",args:"u"},"ctrl+h, meta+h":{api:"module.inline.format",args:"sup"},"ctrl+l, meta+l":{api:"module.inline.format",args:"sub"},"ctrl+k, meta+k":{api:"module.link.open"},"ctrl+alt+0, meta+alt+0":{api:"module.block.format",args:"p"},"ctrl+alt+1, meta+alt+1":{api:"module.block.format",args:"h1"},"ctrl+alt+2, meta+alt+2":{api:"module.block.format",args:"h2"},"ctrl+alt+3, meta+alt+3":{api:"module.block.format",args:"h3"},"ctrl+alt+4, meta+alt+4":{api:"module.block.format",args:"h4"},"ctrl+alt+5, meta+alt+5":{api:"module.block.format",args:"h5"},"ctrl+alt+6, meta+alt+6":{api:"module.block.format",args:"h6"},"ctrl+shift+7, meta+shift+7":{api:"module.list.toggle",args:"ol"},"ctrl+shift+8, meta+shift+8":{api:"module.list.toggle",args:"ul"}},shortcutsAdd:!1,grammarly:!0,notranslate:!1,bufferLimit:100,emptyHtml:"<p></p>",markerChar:"\ufeff",imageTypes:["image/png","image/jpeg","image/gif"],imageAttrs:["alt","title","src","class","width","height","srcset"],inlineTags:["a","span","strong","strike","b","u","em","i","code","del","ins","samp","kbd","sup","sub","mark","var","cite","small","abbr"],blockTags:["pre","ul","ol","li","p","h1","h2","h3","h4","h5","h6","dl","dt","dd","div","table","tbody","thead","tfoot","tr","th","td","blockquote","output","figcaption","figure","address","section","header","footer","aside","article","iframe"],regex:{youtube:/^https?\:\/\/(?:www\.youtube(?:\-nocookie)?\.com\/|m\.youtube\.com\/|youtube\.com\/)?(?:ytscreeningroom\?vi?=|youtu\.be\/|vi?\/|user\/.+\/u\/\w{1,2}\/|embed\/|watch\?(?:.*\&)?vi?=|\&vi?=|\?(?:.*\&)?vi?=)([^#\&\?\n\/<>"']*)/gi,vimeo:/(http|https)?:\/\/(?:www.|player.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/|)(\d+)(?:\/[a-zA-Z0-9_-]+)?/gi,imageurl:/((https?|www)[^\s]+\.)(jpe?g|png|gif)(\?[^\s-]+)?/gi,url:/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z\u00F0-\u02AF0-9()!@:%_+.~#?&//=]*)/gi,aurl1:/(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim,aurl2:/(^|[^\/])(www\.[\S]+(\b|$))/gim},input:!0,zindex:!1,modes:{inline:{pastePlainText:!0,pasteImages:!1,enterKey:!1,toolbar:!1,autoparse:!1,source:!1,showSource:!1,styles:!1,air:!1},original:{styles:!1}}},l.lang.en={format:"Format",image:"Image",file:"File",link:"Link",bold:"Bold",italic:"Italic",deleted:"Strikethrough",underline:"Underline",superscript:"Superscript",subscript:"Subscript","bold-abbr":"B","italic-abbr":"I","deleted-abbr":"S","underline-abbr":"U","superscript-abbr":"Sup","subscript-abbr":"Sub",lists:"Lists","link-insert":"Insert Link","link-edit":"Edit Link","link-in-new-tab":"Open link in new tab",unlink:"Unlink",cancel:"Cancel",close:"Close",insert:"Insert",save:"Save","delete":"Delete",text:"Text",edit:"Edit",title:"Alt",paragraph:"Normal text",quote:"Quote",code:"Code",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",filename:"Name",optional:"optional",unorderedlist:"Unordered List",orderedlist:"Ordered List",outdent:"Outdent",indent:"Indent",horizontalrule:"Line",upload:"Upload","upload-label":"Drop files here or click to upload","accessibility-help-label":"Rich text editor",caption:"Caption",bulletslist:"Bullets",numberslist:"Numbers","image-position":"Position",none:"None",left:"Left",right:"Right",center:"Center",undo:"Undo",redo:"Redo"},l.buttons={html:{title:"HTML",icon:!0,api:"module.source.toggle"},undo:{title:"## undo ##",icon:!0,api:"module.buffer.undo"},redo:{title:"## redo ##",icon:!0,api:"module.buffer.redo"},format:{title:"## format ##",icon:!0,dropdown:{p:{title:"## paragraph ##",api:"module.block.format",args:{tag:"p"}},blockquote:{title:"## quote ##",api:"module.block.format",args:{tag:"blockquote"}},pre:{title:"## code ##",api:"module.block.format",args:{tag:"pre"}},h1:{title:"## heading1 ##",api:"module.block.format",args:{tag:"h1"}},h2:{title:"## heading2 ##",api:"module.block.format",args:{tag:"h2"}},h3:{title:"## heading3 ##",api:"module.block.format",args:{tag:"h3"}},h4:{title:"## heading4 ##",api:"module.block.format",args:{tag:"h4"}},h5:{title:"## heading5 ##",api:"module.block.format",args:{tag:"h5"}},h6:{title:"## heading6 ##",api:"module.block.format",args:{tag:"h6"}}}},bold:{title:"## bold-abbr ##",icon:!0,tooltip:"## bold ##",api:"module.inline.format",args:{tag:"b"}},italic:{title:"## italic-abbr ##",icon:!0,tooltip:"## italic ##",api:"module.inline.format",args:{tag:"i"}},deleted:{title:"## deleted-abbr ##",icon:!0,tooltip:"## deleted ##",api:"module.inline.format",args:{tag:"del"}},underline:{title:"## underline-abbr ##",icon:!0,tooltip:"## underline ##",api:"module.inline.format",args:{tag:"u"}},sup:{title:"## superscript-abbr ##",icon:!0,tooltip:"## superscript ##",api:"module.inline.format",args:{tag:"sup"}},sub:{title:"## subscript-abbr ##",icon:!0,tooltip:"## subscript ##",api:"module.inline.format",args:{tag:"sub"}},lists:{title:"## lists ##",icon:!0,observe:"list",dropdown:{observe:"list",unorderedlist:{title:"• ## unorderedlist ##",api:"module.list.toggle",args:"ul"},orderedlist:{title:"1. ## orderedlist ##",api:"module.list.toggle",args:"ol"},outdent:{title:"< ## outdent ##",api:"module.list.outdent"},indent:{title:"> ## indent ##",api:"module.list.indent"}}},ul:{title:"• ## bulletslist ##",icon:!0,api:"module.list.toggle",observe:"list",args:"ul"},ol:{title:"1. ## numberslist ##",icon:!0,api:"module.list.toggle",observe:"list",args:"ol"},outdent:{title:"## outdent ##",icon:!0,api:"module.list.outdent",observe:"list"},indent:{title:"## indent ##",icon:!0,api:"module.list.indent",observe:"list"},image:{title:"## image ##",icon:!0,api:"module.image.open"},file:{title:"## file ##",icon:!0,api:"module.file.open"},link:{title:"## link ##",icon:!0,observe:"link",dropdown:{observe:"link",link:{title:"## link-insert ##",api:"module.link.open"},unlink:{title:"## unlink ##",api:"module.link.unlink"}}},line:{title:"## horizontalrule ##",icon:!0,api:"module.line.insert"}};var c=function(t,e,i){this.module={},this.plugin={},this.instances={},this.started=!1,this.stopped=!1,this.uuid=i,this.rootElement=t,this.rootOpts=e,this.dragInside=!1,this.dragComponentInside=!1,this.keycodes=l.keycodes,this.namespace="redactor",this.$win=l.dom(window),this.$doc=l.dom(document),this.$body=l.dom("body"),this.editorReadOnly=!1,this.opts=l.create("service.options",e,t),this.lang=l.create("service.lang",this),this.buildServices(),this.buildModules(),this.buildPlugins(),this.start()};c.prototype={start:function(){this.stopped=!1,this.broadcast("start"),this.broadcast("startcode"),this.opts.clickToEdit?this.broadcast("startclicktoedit"):(this.broadcast("enable"),this.opts.showSource&&this.broadcast("startcodeshow"),this.broadcast("enablefocus")),this.broadcast("started"),this.started=!0},stop:function(){this.started=!1,this.stopped=!0,this.broadcast("stop"),this.broadcast("disable"),this.broadcast("stopped")},isStarted:function(){return this.started},isStopped:function(){return this.stopped},buildServices:function(){var t=["options","lang"],e=["uuid","keycodes","opts","lang","$win","$doc","$body"],i=[];for(var s in l.services)t.indexOf(s)===-1&&(this[s]=l.create("service."+s,this),i.push(s),e.push(s));for(var n=0;n<i.length;n++)for(var r=i[n],o=0;o<e.length;o++){var a=e[o];r!==a&&(this[r][a]=this[a])}},buildModules:function(){for(var t in l.modules)this.module[t]=l.create("module."+t,this),this.instances[t]=this.module[t]},buildPlugins:function(){for(var t=this.opts.plugins,e=0;e<t.length;e++){var i=t[e];"undefined"!=typeof l.plugins[i]&&(this.plugin[i]=l.create("plugin."+i,this),this.instances[i]=this.plugin[i])}},isDragInside:function(){return this.dragInside},setDragInside:function(t){this.dragInside=t},isDragComponentInside:function(){return this.dragComponentInside},setDragComponentInside:function(t){this.dragComponentInside=t},getDragComponentInside:function(){return this.dragComponentInside},isReadOnly:function(){return this.editorReadOnly},enableReadOnly:function(){this.editorReadOnly=!0,this.broadcast("enablereadonly"),this.component.clearActive(),this.toolbar.disableButtons()},disableReadOnly:function(){this.editorReadOnly=!1,this.broadcast("disablereadonly"),this.toolbar.enableButtons()},callMessageHandler:function(t,e,i){var s,n=e.split(".");if(1===n.length)"function"==typeof t["on"+e]&&(s=t["on"+e].apply(t,i));else{n[0]="on"+n[0];var r=this.utils.checkProperty(t,n);"function"==typeof r&&(s=r.apply(t,i))}return s},broadcast:function(t){var e,i=[].slice.call(arguments,1);for(var s in this.instances){var n=this.callMessageHandler(this.instances[s],t,i);"undefined"!=typeof n&&(e=n)}var r=this.callback.trigger(t,i);return"undefined"!=typeof e?e:r},on:function(t,e){this.callback.add(t,e)},off:function(t,e){this.callback.remove(t,e)},api:function(t){if((this.isStarted()||"start"===t)&&(!this.isReadOnly()||"disableReadOnly"===t)){this.broadcast("state");var e=[].slice.call(arguments,1),i=t.split("."),s=1===i.length,n="on"===i[0]||"off"===i[0],r=!n&&2===i.length,o="plugin"===i[0],a="module"===i[0];if(s){if("function"==typeof this[i[0]])return this.callInstanceMethod(this,i[0],e)}else{if(n)return"on"===i[0]?this.on(i[1],e[0]):this.off(i[1],e[0]||void 0);if(r){if(this.isInstanceExists(this,i[0]))return this.callInstanceMethod(this[i[0]],i[1],e);l.error(new Error('Service "'+i[0]+'" not found')); }else if(o){if(this.isInstanceExists(this.plugin,i[1]))return this.callInstanceMethod(this.plugin[i[1]],i[2],e);l.error(new Error('Plugin "'+i[1]+'" not found'))}else if(a){if(this.isInstanceExists(this.module,i[1]))return this.callInstanceMethod(this.module[i[1]],i[2],e);l.error(new Error('Module "'+i[1]+'" not found'))}}}},isInstanceExists:function(t,e){return"undefined"!=typeof t[e]},callInstanceMethod:function(t,e,i){if("function"==typeof t[e])return t[e].apply(t,i)}},l.add("mixin","formatter",{buildArgs:function(t){this.args={"class":t["class"]||!1,style:t.style||!1,attr:t.attr||!1},this.args["class"]||this.args.style||this.args.attr||(this.args=!1)},applyArgs:function(t,e){return t=this.args?this[this.type](this.args,!1,t,e):this._clearAll(t,e)},clearClass:function(t,e){this.selection.save();var i=e?l.dom(e):this.getElements(t,!0);return i.removeAttr("class"),e=this._unwrapSpanWithoutAttr(i.getAll()),this.selection.restore(),e},clearStyle:function(t,e){this.selection.save();var i=e?l.dom(e):this.getElements(t,!0);return i.removeAttr("style"),e=this._unwrapSpanWithoutAttr(i.getAll()),this.selection.restore(),e},clearAttr:function(t,e){this.selection.save();var i=e?l.dom(e):this.getElements(t,!0);return this._removeAllAttr(i),e=this._unwrapSpanWithoutAttr(i.getAll()),this.selection.restore(),e},set:function(t,e,i,s){s!==!1&&this.selection.save();var n=i?l.dom(i):this.getElements(e);return t["class"]&&(n.removeAttr("class"),n.addClass(t["class"])),t.style&&(n.removeAttr("style"),n.css(t.style),n.each(function(t){var e=l.dom(t);e.attr("data-redactor-style-cache",e.attr("style"))})),t.attr&&(this._removeAllAttr(n),n.attr(t.attr)),s!==!1&&this.selection.restore(),n.getAll()},toggle:function(t,e,i,s){s!==!1&&this.selection.save();var n=i?l.dom(i):this.getElements(e);t["class"]&&(n.toggleClass(t["class"]),n.each(function(t){""===t.className&&t.removeAttribute("class")}));var r;return t.style&&(r=t.style,n.each(function(t){var e=l.dom(t);for(var i in r){var s=r[i],n=e.css(i);n=this.utils.isRgb(n)?this.utils.rgb2hex(n):n.replace(/"/g,""),s=this.utils.isRgb(s)?this.utils.rgb2hex(s):s.replace(/"/g,""),n=this.utils.hex2long(n),s=this.utils.hex2long(s);var o="string"==typeof s?s.toLowerCase():s,a="string"==typeof n?n.toLowerCase():n;o===a?e.css(i,""):e.css(i,s)}this._convertStyleQuotes(e),this.utils.removeEmptyAttr(t,"style")?e.removeAttr("data-redactor-style-cache"):e.attr("data-redactor-style-cache",e.attr("style"))}.bind(this))),t.attr&&(r=t.attr,n.each(function(t){var e=l.dom(t);for(var i in r)e.attr(i)?e.removeAttr(i):e.attr(i,r[i])})),s!==!1&&this.selection.restore(),n.getAll()},add:function(t,e,i,s){s!==!1&&this.selection.save();var n=i?l.dom(i):this.getElements(e);if(t["class"]&&n.addClass(t["class"]),t.style){var r=t.style;n.each(function(t){var e=l.dom(t);e.css(r),e.attr("data-redactor-style-cache",e.attr("style")),this._convertStyleQuotes(e)}.bind(this))}return t.attr&&n.attr(t.attr),s!==!1&&this.selection.restore(),n.getAll()},remove:function(t,e,i,s){s!==!1&&this.selection.save();var n=i?l.dom(i):this.getElements(e);if(t["class"]&&(n.removeClass(t["class"]),n.each(function(t){""===t.className&&t.removeAttribute("class")})),t.style){var r=t.style;n.each(function(t){var e=l.dom(t);e.css(r,""),this.utils.removeEmptyAttr(t,"style")?e.removeAttr("data-redactor-style-cache"):e.attr("data-redactor-style-cache",e.attr("style"))}.bind(this))}return t.attr&&n.removeAttr(t.attr),i=this._unwrapSpanWithoutAttr(n.getAll()),s!==!1&&this.selection.restore(),i},_removeAllAttr:function(t){t.each(function(t){for(var e=t.attributes.length;e-- >0;){var i=t.attributes[e],s=i.name;"style"!==s&&"class"!==s&&t.removeAttributeNode(i)}})},_convertStyleQuotes:function(t){var e=t.attr("style");e&&t.attr("style",e.replace(/"/g,"'"))},_clearAll:function(t,e){e!==!1&&this.selection.save();for(var i=0;i<t.length;i++)for(var s=t[i];s.attributes.length>0;)s.removeAttribute(s.attributes[0].name);return t=this._unwrapSpanWithoutAttr(t),e!==!1&&this.selection.restore(),t},_unwrapSpanWithoutAttr:function(t){for(var e=[],i=0;i<t.length;i++){var s=t[i],n=s.attributes.length;n<=0&&3!==s.nodeType&&"SPAN"===s.tagName?l.dom(s).unwrap():e.push(s)}return e}}),l.add("mixin","dom",l.Dom.prototype),l.add("mixin","component",{get cmnt(){return!0}}),l.add("service","options",{init:function(t,e){var i=l.dom(e),s=l.extend({},l.opts,e?i.data():{},l.options);return s=l.extend(!0,s,t)}}),l.add("service","lang",{init:function(t){this.app=t,this.opts=t.opts,this.vars=this._build(this.opts.lang)},rebuild:function(t){this.opts.lang=t,this.vars=this._build(t)},extend:function(t){this.vars=l.extend(this.vars,t)},parse:function(t){if(void 0===t)return"";var e=t.match(/## (.*?) ##/g);if(e)for(var i=0;i<e.length;i++){var s=e[i].replace(/^##\s/g,"").replace(/\s##$/g,"");t=t.replace(e[i],this.get(s))}return t},get:function(t){var e="";return"undefined"!=typeof this.vars[t]?e=this.vars[t]:"en"!==this.opts.lang&&"undefined"!=typeof l.lang.en[t]&&(e=l.lang.en[t]),e},_build:function(t){var e=l.lang.en;return"en"!==t&&(e=void 0!==l.lang[t]?l.lang[t]:e),e}}),l.add("service","callback",{init:function(t){this.app=t,this.opts=t.opts,this.callbacks={},this.opts.callbacks&&this._set(this.opts.callbacks,"")},stop:function(){this.callbacks={}},add:function(t,e){this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e)},remove:function(t,e){if(void 0===e)delete this.callbacks[t];else{for(var i=0;i<this.callbacks[t].length;i++)this.callbacks[t].splice(i,1);0===Object.keys(this.callbacks[t]).length&&delete this.callbacks[t]}},trigger:function(t,e){var i=this._loop(t,e,this.callbacks);return"undefined"==typeof i&&e&&e[0]!==!1?e[0]:i},_set:function(t,e){for(var i in t){var s=""===e?i:e+"."+i;"object"==typeof t[i]?this._set(t[i],s):(this.callbacks[s]=[],this.callbacks[s].push(t[i]))}},_loop:function(t,e,i){var s;for(var n in i)if(t===n)for(var r=0;r<i[n].length;r++)s=i[n][r].apply(this.app,e);return s}}),l.add("service","animate",{init:function(t){this.animationOpt=t.opts.animation},start:function(t,e,i,s){var n={duration:!1,iterate:!1,delay:!1,timing:!1,prefix:"redactor-"};return n="function"==typeof i?n:l.extend(n,i),s="function"==typeof i?i:s,new l.AnimatePlay(t,e,n,s,this.animationOpt)},stop:function(t){this.$el=l.dom(t),this.$el.removeClass("redactor-animated");var e=this.$el.attr("redactor-animate-effect");this.$el.removeClass(e),this.$el.removeAttr("redactor-animate-effect");var i=this.$el.attr("redactor-animate-hide");i&&this.$el.addClass(i).removeAttr("redactor-animate-hide"),this.$el.off("animationend webkitAnimationEnd")}}),l.AnimatePlay=function(t,e,i,s,n){return this.hidableEffects=["fadeOut","flipOut","slideUp","zoomOut","slideOutUp","slideOutRight","slideOutLeft"],this.prefixes=["","-webkit-"],this.$el=l.dom(t),this.$body=l.dom("body"),this.callback=s,this.animation=n?e:this.buildAnimationOff(e),this.defaults=i,"slideUp"===this.animation&&this.$el.height(this.$el.height()),this.isInanimate()?this.inanimate():this.animate()},l.AnimatePlay.prototype={buildAnimationOff:function(t){return this.isHidable(t)?"hide":"show"},buildHideClass:function(){return"redactor-animate-hide"},isInanimate:function(){return"show"===this.animation||"hide"===this.animation},isAnimated:function(){return this.$el.hasClass("redactor-animated")},isHidable:function(t){return this.hidableEffects.indexOf(t)!==-1},inanimate:function(){this.defaults.timing="linear";var t;return"show"===this.animation?(t=this.buildHideClass(),this.$el.attr("redactor-animate-hide",t),this.$el.removeClass(t)):(t=this.$el.attr("redactor-animate-hide"),this.$el.addClass(t).removeAttr("redactor-animate-hide")),"function"==typeof this.callback&&this.callback(this),this},animate:function(){var t=this.defaults.delay?this.defaults.delay:0;return setTimeout(function(){if(this.$body.addClass("no-scroll-x"),this.$el.addClass("redactor-animated"),!this.$el.attr("redactor-animate-hide")){var t=this.buildHideClass();this.$el.attr("redactor-animate-hide",t),this.$el.removeClass(t)}this.$el.addClass(this.defaults.prefix+this.animation),this.$el.attr("redactor-animate-effect",this.defaults.prefix+this.animation),this.set(this.defaults.duration+"s",this.defaults.iterate,this.defaults.timing),this.complete()}.bind(this),1e3*t),this},set:function(t,e,i){for(var s=this.prefixes.length;s--;)t===!1&&""!==t||this.$el.css(this.prefixes[s]+"animation-duration",t),e===!1&&""!==e||this.$el.css(this.prefixes[s]+"animation-iteration-count",e),i===!1&&""!==i||this.$el.css(this.prefixes[s]+"animation-timing-function",i)},clean:function(){this.$body.removeClass("no-scroll-x"),this.$el.removeClass("redactor-animated"),this.$el.removeClass(this.defaults.prefix+this.animation),this.$el.removeAttr("redactor-animate-effect"),this.set("","","")},complete:function(){this.$el.one("animationend webkitAnimationEnd",function(){if(this.$el.hasClass(this.defaults.prefix+this.animation)&&this.clean(),this.isHidable(this.animation)){var t=this.$el.attr("redactor-animate-hide");this.$el.addClass(t).removeAttr("redactor-animate-hide")}"slideUp"===this.animation&&this.$el.height(""),"function"==typeof this.callback&&this.callback(this.$el)}.bind(this))}},l.add("service","caret",{init:function(t){this.app=t},setStart:function(t){this._setCaret("Start",t)},setEnd:function(t){this._setCaret("End",t)},setBefore:function(t){this._setCaret("Before",t)},setAfter:function(t){this._setCaret("After",t)},isStart:function(t){return this._isStartOrEnd(t,"First")},isEnd:function(t){return this._isStartOrEnd(t,"Last")},setAtEnd:function(t){var e=this.inspector.parse(t),i=e.getTag(),s=document.createRange();if(this._isInPage(t)){if("a"===i){var n=this.utils.createInvisibleChar();l.dom(t).after(n),s.selectNodeContents(n),s.collapse(!0)}else s.selectNodeContents(t),s.collapse(!1);this.selection.setRange(s)}},setAtStart:function(t){var e=document.createRange(),i=this.inspector.parse(t);if(this._isInPage(t)){if(e.setStart(t,0),e.collapse(!0),i.isInline()){var s=this.utils.createInvisibleChar();e.insertNode(s),e.selectNodeContents(s),e.collapse(!1)}this.selection.setRange(e)}},setAtBefore:function(t){var e=this.inspector.parse(t),i=document.createRange();if(this._isInPage(t)){if(i.setStartBefore(t),i.collapse(!0),e.isInline()){var s=this.utils.createInvisibleChar();t.parentNode.insertBefore(s,t),i.selectNodeContents(s),i.collapse(!1)}this.selection.setRange(i)}},setAtAfter:function(t){var e=document.createRange();if(this._isInPage(t)){e.setStartAfter(t),e.collapse(!0);var i=this.utils.createInvisibleChar();e.insertNode(i),e.selectNodeContents(i),e.collapse(!1),this.selection.setRange(e)}},setAtPrev:function(t){var e=t.previousSibling;e&&(e=3===e.nodeType&&this._isEmptyTextNode(e)?e.previousElementSibling:e,e&&this.setEnd(e))},setAtNext:function(t){var e=t.nextSibling;e&&(e=3===e.nodeType&&this._isEmptyTextNode(e)?e.nextElementSibling:e,e&&this.setStart(e))},_setCaret:function(t,e){var i=this.inspector.parse(e),s=i.getNode();s&&(this.component.clearActive(),this["_set"+t](s,i,i.getTag()))},_setStart:function(t,e,i){if(e.isText())return this.editor.focus(),this.setAtStart(t);if("ul"===i||"ol"===i){t=e.findFirstNode("li");var s=this.utils.getFirstElement(t),n=this.inspector.parse(s);if(s&&n.isComponent())return this.setStart(n.getComponent())}else if("dl"===i)t=e.findFirstNode("dt");else{if("br"===i||"hr"===i)return this.setBefore(t);if("td"===i||"th"===i){var r=e.getFirstElement(t);if(r)return this.setStart(r)}else{if("table"===i||"tr"===i)return this.setStart(e.findFirstNode("th, td"));if(e.isComponentType("code")&&!e.isFigcaption()){var o=e.findLastNode("pre, code");return this.editor.focus(),this.setAtStart(o)}if("figure"===i&&e.isComponentType("table")){var a=e.getTable(),l=this.inspector.parse(a);return this.setStart(l.findFirstNode("th, td"))}if(!e.isComponentType("table")&&e.isComponent()&&!e.isFigcaption())return this.component.setActive(t)}}this.editor.focus(),this._setInline(t,"Start")||this.setAtStart(t)},_setEnd:function(t,e,i){if(e.isText())return this.editor.focus(),this.setAtEnd(t);if("ul"===i||"ol"===i){t=e.findLastNode("li");var s=this.utils.getLastElement(t),n=this.inspector.parse(s);if(s&&n.isComponent())return this.setEnd(n.getComponent())}else if("dl"===i)t=e.findLastNode("dd");else{if("br"===i||"hr"===i)return this.setAfter(t);if("td"===i||"th"===i){var r=e.getLastElement();if(r)return this.setEnd(r)}else{if("table"===i||"tr"===i)return this.setEnd(e.findLastNode("th, td"));if(e.isComponentType("code")&&!e.isFigcaption()){var o=e.findLastNode("pre, code");return this.editor.focus(),this.setAtEnd(o)}if("figure"===i&&e.isComponentType("table")){var a=e.getTable(),l=this.inspector.parse(a);return this.setEnd(l.findLastNode("th, td"))}if(!e.isComponentType("table")&&e.isComponent()&&!e.isFigcaption())return this.component.setActive(t)}}if(this.editor.focus(),!this._setInline(t,"End")){if(this.utils.isEmpty(t))return this.setStart(t);this.setAtEnd(t)}},_setBefore:function(t,e,i){return 3===t.nodeType?this.setAtBefore(t):e.isInline()?this.setAtBefore(t):e.isFirstTableCell()?this.setAtPrev(e.getComponent()):"td"===i||"th"===i?this.setAtPrev(t):e.isFirstListItem()?this.setAtPrev(e.getList()):e.isFigcaption()?this.setStart(e.getComponent()):!e.isComponentType("table")&&e.isComponent()?this.setAtPrev(e.getComponent()):e.isBlock()?this.setAtPrev(t):(this.editor.focus(),void this.setAtBefore(t))},_setAfter:function(t,e,i){return 3===t.nodeType?this.setAtAfter(t):e.isInline()?this.setAtAfter(t):e.isLastTableCell()?this.setAtNext(e.getComponent()):"td"===i||"th"===i?this.setAtNext(t):e.isFirstListItem()?this.setAtNext(e.getList()):!e.isComponentType("table")&&e.isComponent()?this.setAtNext(e.getComponent()):e.isBlock()?this.setAtNext(t):(this.editor.focus(),void this.setAtAfter(t))},_setInline:function(t,e){var i=this._hasInlineChild(t,"Start"===e?"first":"last");if(i)return"Start"===e?this.setStart(i):this.setEnd(i),!0},_isStartOrEnd:function(t,e){var i=this.utils.getNode(t);if(!i)return!1;var s=this.inspector.parse(i);if(i=this._getStartEndNode(i,s,e),i&&3!==i.nodeType&&"LI"!==i.tagName){var n=3===i.nodeType?i.textContent:i.innerHTML;if(n=this.utils.trimSpaces(n),""===n)return!0}if(!s.isFigcaption()&&s.isComponent()&&!s.isComponentEditable())return!0;var r=this.offset.get(i,!0);return!!r&&("First"===e?0===r.start:r.end===this.offset.size(i,!0))},_isInPage:function(t){return!(!t||!t.nodeType)&&(t!==document.body&&document.body.contains(t))},_hasInlineChild:function(t,e){var i=this.inspector.parse(t),s="first"===e?i.getFirstNode():i.getLastNode(),n=l.dom(s);if(s&&3!==s.nodeType&&this.inspector.isInlineTag(s.tagName)&&!n.hasClass("redactor-component")&&!n.hasClass("non-editable"))return s},_isEmptyTextNode:function(t){var e=t.textContent.trim().replace(/\n/,"");return e=this.utils.removeInvisibleChars(e),""===e},_getStartEndNode:function(t,e,i){return e.isFigcaption()?t=e.getFigcaption():e.isTable()?t=e["find"+i+"Node"]("th, td"):e.isList()?t=e["find"+i+"Node"]("li"):e.isComponentType("code")&&(t=e.findLastNode("pre, code")),t}});var d=function(t){return document.getSelection().containsNode(t,!0)},u=function(t){var e=document.getSelection(),i=e.anchorNode.parentNode,s=e.focusNode.parentNode,n=e.getRangeAt(0).getBoundingClientRect(),r=t.getBoundingClientRect();return!!l.dom(i).closest(t).length||(!!l.dom(s).closest(t).length||n.top<r.top&&n.height>r.height)};"containsNode"in Selection.prototype||(d=u),l.add("service","selection",{init:function(t){this.app=t},is:function(){var t=this.get();if(t){var e=t.anchorNode;return 0!==l.dom(e).closest(".redactor-in-"+this.uuid).length||e===this.editor.getElement().get()}return!1},isCollapsed:function(){var t=this.get(),e=this.getRange();return!(!t||!t.isCollapsed)||!(!e||0!==e.toString().length)},isBackwards:function(){var t=!1,e=this.get();if(e&&!e.isCollapsed){var i=document.createRange();i.setStart(e.anchorNode,e.anchorOffset),i.setEnd(e.focusNode,e.focusOffset),t=i.collapsed,i.detach()}return t},isIn:function(t){var e=l.dom(t).get(),i=this.getCurrent();return!(!i||!e)&&e.contains(i)},isText:function(){var t=this.get();if(t){var e=t.anchorNode,i=this.getBlock(e),s=this.getBlocks();if(i&&this.inspector.isTableCellTag(i.tagName)||i===!1&&0===s.length)return!0}return!1},isAll:function(t){var e=this.utils.getNode(t);if(!e)return!1;var i=this.editor.isEditor(e),s=this.inspector.parse(e);if(!s.isFigcaption()&&this.component.isNonEditable(e)&&this.component.isActive(e))return!0;if(i){var n=this.editor.getElement(),r=n.html().replace(/<p><\/p>$/i,""),o=this.getHtml(!1).length,a=r.length;if(o!==a)return!1}if(i&&this.editor.isEmpty()||this.isCollapsed())return!1;var l=this.offset.get(e,!0),h=this.offset.size(e,!0);return!i&&s.isComponentType("code")&&(h=this.getText().trim().length),!(!l||0!==l.start||l.end!==h)},hasNonEditable:function(){var t=this.getHtml(),e=l.dom("<div>").html(t);return!this.isCollapsed()&&0!==e.find(".non-editable").length},setRange:function(t){var e=window.getSelection();e.removeAllRanges(),e.addRange(t)},setAll:function(t){var e=this.utils.getNode(t);if(e){var i=this.inspector.parse(e);if(this.component.clearActive(),this.editor.focus(),this.editor.saveScroll(),this.editor.disableNonEditables(),e&&"TABLE"===e.tagName){var s=i.findFirstNode("td, th"),n=i.findLastNode("td, th");l.dom(s).prepend(this.marker.build("start")),l.dom(n).append(this.marker.build("end")),this.restoreMarkers()}else if(!i.isFigcaption()&&this.component.isNonEditable(e))this.component.setActive(e);else{i.isComponentType("code")&&(e=i.getComponentCodeElement(),e.focus());var r=document.createRange();r.selectNodeContents(e),this.setRange(r)}this.editor.enableNonEditables(),this.editor.restoreScroll()}},get:function(){var t=window.getSelection();return t.rangeCount>0?t:null},getRange:function(){var t=this.get();return t&&t.getRangeAt(0)?t.getRangeAt(0):null},getTextBeforeCaret:function(t){t="undefined"==typeof t?1:t;var e=this.editor.getElement().get(),i=this.getRange(),s=!1;return i&&(i=i.cloneRange(),i.collapse(!0),i.setStart(e,0),s=i.toString().slice(-t)),s},getTextAfterCaret:function(t){t="undefined"==typeof t?1:t;var e=this.editor.getElement().get(),i=this.getRange(),s=!1;if(i){var n=i.cloneRange();n.selectNodeContents(e),n.setStart(i.endContainer,i.endOffset),s=n.toString().slice(0,t)}return s},getPosition:function(){var t=this.getRange(),e={top:0,left:0,width:0,height:0};if(window.getSelection&&t.getBoundingClientRect){t=t.cloneRange();var i=t.startOffset-1;t.setStart(t.startContainer,i<0?0:i);var s=t.getBoundingClientRect();e={top:s.top,left:s.left,width:s.right-s.left,height:s.bottom-s.top}}return e},getCurrent:function(){var t=!1,e=this.get(),i=this.component.getActive();return i?t=i:e&&this.is()&&(t=e.anchorNode!==this.editor.getElement().get()&&e.anchorNode),t},getParent:function(){var t=!1,e=this.getCurrent();if(e){var i=e.parentNode;t=i!==this.editor.getElement().get()&&i}return t},getElement:function(t){for(var e=t||this.getCurrent();e;){var i=this.inspector.parse(e);if(i.isElement()&&i.isInEditor())return e;e=e.parentNode}return!1},getInline:function(t){for(var e=t||this.getCurrent(),i=!1;e;)this._isInlineNode(e)&&(i=e),e=e.parentNode;return i},getInlineFirst:function(t){for(var e=t||this.getCurrent();e;){if(this._isInlineNode(e))return e;e=e.parentNode}return!1},getInlineAll:function(t){for(var e=t||this.getCurrent(),i=[];e;)this._isInlineNode(e)&&i.push(e),e=e.parentNode;return i},getBlock:function(t){for(var e=t||this.getCurrent();e;){var i=this.inspector.parse(e),s=this.inspector.isBlockTag(e.tagName);if(s&&i.isInEditor(e))return e;e=e.parentNode}return!1},getInlinesAllSelected:function(t){if(this.isAll())return[];var e=this.getInlines({all:!0,inside:!0}),i=this.getText().replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&"),s=[];if(""===i)s=e;else if(e.length>1)for(var n=0;n<e.length;n++)this._isTextSelected(e[n],i)&&s.push(e[n]);else 1===e.length&&this._isTextSelected(e[0],i)&&(s=e);return s=t&&t.tags?this._filterNodesByTags(s,t.tags):s},getInlines:function(t){for(var e=this.getNodes(),i=[],s=0;s<e.length;s++){var n;if(t&&t.all)for(n=e[s];n;)this._isInlineNode(n)&&!this._isInNodesArray(i,n)&&i.push(n),n=n.parentNode;else n=this.getInline(e[s]),n&&!this._isInNodesArray(i,n)&&i.push(n)}return i=t&&t.tags?this._filterNodesByTags(i,t.tags):i,i=t&&t.inside?this._filterInlinesInside(i,t):i},getBlocks:function(t){var e=this.getNodes(),i=this.getBlock();e=0===e.length&&i?[i]:e;for(var s=[],n=0;n<e.length;n++){var r=this.getBlock(e[n]),o=l.dom(r);o.hasClass("non-editable")||r&&!this._isInNodesArray(s,r)&&s.push(r)}return s=t&&t.tags?this._filterNodesByTags(s,t.tags):s,s=t&&t.first?this._filterBlocksFirst(s,t):s},getElements:function(t){var e=this.getNodes({textnodes:!1}),i=this.getBlock();e=0===e.length&&i?[i]:e;for(var s=[],n=0;n<e.length;n++)this._isInNodesArray(s,e[n])||s.push(e[n]);return s=t&&t.tags?this._filterNodesByTags(s,t.tags):s},getNodes:function(t){var e=[],i=this.component.getActive();if(i)e=this._getNodesComponent(i);else if(this.isCollapsed()){var s=this.getCurrent();e=s?[s]:[]}else this.is()&&!i&&(e=this._getRangeSelectedNodes());return e=this._filterServicesNodes(e),e=this._filterEditor(e),e=t&&t.tags?this._filterNodesByTags(e,t.tags):e,e=t&&t.textnodes?this._filterNodesTexts(e,t):e,e=t&&!t.textnodes?this._filterNodesElements(e):e},getText:function(){var t=this.get();return t?this.utils.removeInvisibleChars(t.toString()):""},getHtml:function(t){var e="",i=this.get();if(i){for(var s=document.createElement("div"),n=i.rangeCount,r=0;r<n;++r)s.appendChild(i.getRangeAt(r).cloneContents());e=s.innerHTML,e=t!==!1?this.cleaner.output(e):e,e=e.replace(/<p><\/p>$/i,"")}return e},clear:function(){this.component.clearActive(),this.get().removeAllRanges()},collapseToStart:function(){var t=this.get();t&&!t.isCollapsed&&t.collapseToStart()},collapseToEnd:function(){var t=this.get();t&&!t.isCollapsed&&t.collapseToEnd()},saveActiveComponent:function(){var t=this.component.getActive();return!!t&&(this.savedComponent=t,!0)},restoreActiveComponent:function(){return!!this.savedComponent&&(this.component.setActive(this.savedComponent),!0)},save:function(){this._clearSaved();var t=this.getElement(),e=["TD","TH","P","DIV","PRE","H1","H2","H3","H4","H5","H6","LI","BLOCKQUOTE"];!t||e.indexOf(t.tagName)===-1||""!==t.innerHTML&&"<br>"!==t.innerHTML?this.saveActiveComponent()||(this.saved=this.offset.get()):this.savedElement=t},restore:function(){(this.saved||this.savedComponent||this.savedElement)&&(this.editor.saveScroll(),this.savedElement?this.caret.setStart(this.savedElement):this.restoreActiveComponent()||this.offset.set(this.saved),this._clearSaved(),this.editor.restoreScroll())},saveMarkers:function(){this._clearSaved(),this.saveActiveComponent()||this.marker.insert()},restoreMarkers:function(){this.editor.saveScroll(),this.restoreActiveComponent()||this.marker.restore(),this._clearSaved(),this.editor.restoreScroll()},_getNextNode:function(t){if(t.hasChildNodes())return t.firstChild;for(;t&&!t.nextSibling;)t=t.parentNode;return t?t.nextSibling:null},_getNodesComponent:function(t){var e=this.getCurrent(),i=this.inspector.parse(e);return i.isFigcaption()?[i.getFigcaption()]:[t]},_getRangeSelectedNodes:function(){var t=[],e=this.getRange(),i=e.startContainer,s=e.startContainer,n=e.endContainer,r=this.editor.getElement();if(s===r.get()&&this.isAll())t=this.utils.getChildNodes(r);else if(i===n)t=[i];else{for(;i&&i!==n;)t.push(i=this._getNextNode(i));for(i=e.startContainer;i&&i!==e.commonAncestorContainer;)t.unshift(i),i=i.parentNode}return t},_isInNodesArray:function(t,e){return t.indexOf(e)!==-1},_filterEditor:function(t){for(var e=[],i=0;i<t.length;i++){var s=this.inspector.parse(t[i]);s.isInEditor()&&e.push(t[i])}return e},_filterServicesNodes:function(t){for(var e=[],i=0;i<t.length;i++){var s=l.dom(t[i]),n=!1;t[i]&&3===t[i].nodeType&&this.utils.isEmpty(t[i])&&(n=!0),(s.hasClass("redactor-script-tag")||s.hasClass("redactor-component-caret")||s.hasClass("redactor-selection-marker")||s.hasClass("non-editable"))&&(n=!0),n||e.push(t[i])}return e},_filterNodesTexts:function(t,e){for(var i=[],s=0;s<t.length;s++)if(3===t[s].nodeType||e.keepbr&&"BR"===t[s].tagName){var n=this.getInline(t[s]),r=n&&e&&e.inline===!1;r||i.push(t[s])}return i},_filterNodesElements:function(t){for(var e=[],i=0;i<t.length;i++)3!==t[i].nodeType&&e.push(t[i]);return e},_filterNodesByTags:function(t,e,i){for(var s=[],n=0;n<t.length;n++)if(i&&3===t[n].nodeType)s.push(t[n]);else if(3!==t[n].nodeType){var r=t[n].tagName.toLowerCase();e.indexOf(r.toLowerCase())!==-1&&s.push(t[n])}return s},_filterBlocksFirst:function(t){for(var e=[],i=0;i<t.length;i++){var s=l.dom(t[i]),n=s.parent().get(),r=s.parent().hasClass("redactor-in"),o=n&&("TD"===n.tagName||"TH"===n.tagName);(r||o)&&e.push(t[i])}return e},_filterInlinesInside:function(t){for(var e=[],i=0;i<t.length;i++)d(t[i],!0)&&e.push(t[i]);return e},_isTextSelected:function(t,e){var i=9!==t.nodeType?this.utils.removeInvisibleChars(t.textContent):"";return e===i||i.search(e)!==-1||e.search(new RegExp("^"+this.utils.escapeRegExp(i)+"$"))!==-1},_isInlineNode:function(t){var e=this.inspector.parse(t);return this.inspector.isInlineTag(t.tagName)&&e.isInEditor()},_clearSaved:function(){this.saved=!1,this.savedComponent=!1,this.savedElement=!1}}),l.add("service","element",{init:function(t){this.app=t,this.rootElement=t.rootElement,this.$element={},this.type="inline"},start:function(){this._build(),this._buildType()},isType:function(t){return t===this.type},getType:function(){return this.type},getElement:function(){return this.$element},_build:function(){this.$element=l.dom(this.rootElement)},_buildType:function(){var t=this.$element.get().tagName;this.type="TEXTAREA"===t?"textarea":this.type,this.type="DIV"===t?"div":this.type,this.type=this.opts.inline?"inline":this.type}}),l.add("service","editor",{init:function(t){this.app=t,this.scrolltop=!1,this.pasting=!1},start:function(){this._build()},focus:function(){this.isFocus()||this._isContenteditableFocus()||(this.saveScroll(),this.$editor.focus(),this.restoreScroll())},startFocus:function(){this.caret.setStart(this.getFirstNode())},endFocus:function(){this.caret.setEnd(this.getLastNode())},isPasting:function(){return this.pasting},enablePasting:function(){this.pasting=!0},disablePasting:function(){this.pasting=!1},saveScroll:function(){this.scrolltop=this._getScrollTarget().scrollTop(),this.opts.maxHeight&&(this.scrolltopin=this.$editor.scrollTop())},restoreScroll:function(){this.scrolltop!==!1&&(this._getScrollTarget().scrollTop(this.scrolltop),this.scrolltop=!1),this.scrolltopin&&(this.$editor.scrollTop(this.scrolltopin),this.scrolltopin=!1)},disableNonEditables:function(){this.$noneditables=this.$editor.find("[contenteditable=false]"),this.$noneditables.attr("contenteditable",!0)},enableNonEditables:function(){this.$noneditables&&setTimeout(function(){this.$noneditables.attr("contenteditable",!1)}.bind(this),1)},getFirstNode:function(){return this.$editor.contents()[0]},getLastNode:function(){var t=this.$editor.contents();return t[t.length-1]},isSourceMode:function(){var t=this.source.getElement();return t.hasClass("redactor-source-open")},isEditor:function(t){var e=l.dom(t).get();return e===this.$editor.get()},isEmpty:function(t){return this.utils.isEmptyHtml(this.$editor.html(),!1,t)},isFocus:function(){var t=l.dom(document.activeElement),e=0!==this.$editor.find(".redactor-component-active").length;return e||0!==t.closest(".redactor-in-"+this.uuid).length},setEmpty:function(){this.$editor.html(this.opts.emptyHtml)},getElement:function(){return this.$editor},_build:function(){var t=this.element.getElement(),e=this.element.isType("textarea")?"<div>":t.get();this.$editor=l.dom(e)},_getScrollTarget:function(){var t=this.$doc;return t=this.opts.toolbarFixedTarget!==document?l.dom(this.opts.toolbarFixedTarget):this.opts.scrollTarget?l.dom(this.opts.scrollTarget):t},_isContenteditableFocus:function(){var t=this.selection.getBlock(),e=t?l.dom(t).closest("[contenteditable=true]").not(".redactor-in"):[];return 0!==e.length}}),l.add("service","container",{init:function(t){this.app=t},start:function(){this._build()},getElement:function(){return this.$container},_build:function(){var t=this.element.isType("inline")?"<span>":"<div>";this.$container=l.dom(t)}}),l.add("service","source",{init:function(t){this.app=t,this.$source={},this.content=""},start:function(){this._build(),this._buildName(),this._buildStartedContent()},getElement:function(){return this.$source},getCode:function(){return this.$source.val()},getName:function(){return this.$source.attr("name")},getStartedContent:function(){return this.content},setCode:function(t){return this.insertion.set(t,!0,!1)},isNameGenerated:function(){return this.name},rebuildStartedContent:function(){this._buildStartedContent()},_build:function(){var t=this.element.getElement(),e=this.element.isType("textarea"),i=e?t.get():"<textarea>";this.$source=l.dom(i)},_buildName:function(){var t=this.element.getElement();this.name=t.attr("name"),this.$source.attr("name",this.name?this.name:"content-"+this.uuid)},_buildStartedContent:function(){var t=this.element.getElement(),e=this.element.isType("textarea")?t.val():t.html();this.content=e.trim()}}),l.add("service","statusbar",{init:function(t){this.app=t,this.$statusbar={},this.items=[]},start:function(){this.$statusbar=l.dom("<ul>"),this.$statusbar.attr("dir",this.opts.direction)},add:function(t,e){return this.update(t,e)},update:function(t,e){var i;return"undefined"!=typeof this.items[t]?i=this.items[t]:(i=l.dom("<li>"),this.$statusbar.append(i),this.items[t]=i),i.html(e)},get:function(t){return!!this.items[t]&&this.items[t]},remove:function(t){this.items[t]&&(this.items[t].remove(),delete this.items[t])},getItems:function(){return this.items},removeItems:function(){this.items={},this.$statusbar.html("")},getElement:function(){return this.$statusbar}}),l.add("service","toolbar",{init:function(t){this.app=t,this.buttons=[],this.dropdownOpened=!1,this.buttonsObservers={}},start:function(){this.is()&&(this.opts.activeButtons=this.opts.activeButtonsAdd?this._extendActiveButtons():this.opts.activeButtons,this.create())},stopObservers:function(){this.buttonsObservers={}},create:function(){this.$wrapper=l.dom("<div>"),this.$toolbar=l.dom("<div>")},observe:function(){if(this.is()){this.setButtonsInactive();var t,e;for(var i in this.buttonsObservers)e=this.buttonsObservers[i],t=this.getButton(i),this.app.broadcast("button."+e+".observe",t);var s=this.opts.activeButtons,n=this.selection.getInlinesAllSelected(),r=this.selection.getInline(),o=this.selection.getInlineAll();this.selection.isCollapsed()&&(r&&n.push(r),0!==o.length&&(n=n.concat(o)));var a=this._inlinesToTags(n);for(var l in s)a.indexOf(l)!==-1&&(t=this.getButton(s[l]),t&&t.setActive())}},is:function(){return!(!this.opts.toolbar||this.detector.isMobile()&&this.opts.air)},isAir:function(){return!!this.is()&&this.$toolbar.hasClass("redactor-air")},isFixed:function(){return!!this.is()&&this.$toolbar.hasClass("redactor-toolbar-fixed")},isContextBar:function(){var t=this.$body.find("#redactor-context-toolbar-"+this.uuid);return t.hasClass("open")},isTarget:function(){return this.opts.toolbarFixedTarget!==document},getElement:function(){return this.$toolbar},getWrapper:function(){return this.$wrapper},getDropdown:function(){return this.dropdownOpened},getTargetElement:function(){return l.dom(this.opts.toolbarFixedTarget)},getButton:function(t){var e=this._findButton(".re-"+t);return 0!==e.length&&e.dataget("data-button-instance")},getButtons:function(){var t=[];return this._findButtons().each(function(e){var i=l.dom(e);t.push(i.dataget("data-button-instance"))}),t},getButtonsKeys:function(){var t=[];return this._findButtons().each(function(e){var i=l.dom(e);t.push(i.attr("data-re-name"))}),t},addButton:function(t,e,i,s,n){i=i||"end";var r=l.create("toolbar.button",this.app,t,e);if(e.observe&&(this.opts.activeButtonsObservers[t]={observe:e.observe,button:r}),this.is())if("first"===i)this.$toolbar.prepend(r);else if("after"===i)s.after(r);else if("before"===i)s.before(r);else{ var o=this.opts.buttons.indexOf(t);if(n!==!0&&o!==-1)if(0===o)this.$toolbar.prepend(r);else{var a=this._findButtons(),h=a.eq(o-1);h.length>0?h.after(r):this.$toolbar.append(r)}else this.$toolbar.append(r)}return r},addButtonFirst:function(t,e){return this.addButton(t,e,"first")},addButtonAfter:function(t,e,i){var s=this.getButton(t);return s?this.addButton(e,i,"after",s):this.addButton(e,i)},addButtonBefore:function(t,e,i){var s=this.getButton(t);return s?this.addButton(e,i,"before",s):this.addButton(e,i)},addButtonObserver:function(t,e){this.buttonsObservers[t]=e},setButtons:function(t){this.buttons=t},setDropdown:function(t){this.dropdownOpened=t},setButtonsInactive:function(){for(var t=this.getButtons(),e=0;e<t.length;e++)t[e].setInactive()},setButtonsActive:function(){for(var t=this.getButtons(),e=0;e<t.length;e++)t[e].setActive()},disableButtons:function(){for(var t=this.getButtons(),e=0;e<t.length;e++)t[e].disable()},enableButtons:function(){for(var t=this.getButtons(),e=0;e<t.length;e++)t[e].enable()},_findButton:function(t){return this.is()?this.$toolbar.find(t):l.dom()},_findButtons:function(){return this.is()?this.$toolbar.find(".re-button"):l.dom()},_extendActiveButtons:function(){return l.extend({},this.opts.activeButtons,this.opts.activeButtonsAdd)},_inlinesToTags:function(t){for(var e=[],i=0;i<t.length;i++)e.push(t[i].tagName.toLowerCase());return e}}),l.add("class","toolbar.button",{mixins:["dom"],init:function(t,e,i){this.app=t,this.opts=t.opts,this.lang=t.lang,this.$body=t.$body,this.toolbar=t.toolbar,this.detector=t.detector,this.obj=i,this.name=e,this.dropdown=!1,this.tooltip=!1,this._init()},isActive:function(){return this.hasClass("redactor-button-active")},isDisabled:function(){return this.hasClass("redactor-button-disabled")},hasIcon:function(){return this.obj.icon&&!this.opts.buttonsTextLabeled},setDropdown:function(t){this.obj.dropdown=t,this.obj.message=!1,this.dropdown=l.create("toolbar.dropdown",this.app,this.name,this.obj.dropdown),this.attr("data-dropdown",!0)},setMessage:function(t,e){this.obj.message=t,this.obj.args=e,this.obj.dropdown=!1},setApi:function(t,e){this.obj.api=t,this.obj.args=e,this.obj.dropdown=!1},setTitle:function(t){this.obj.title=this.lang.parse(t),this.obj.tooltip=this.obj.title,this.attr({alt:this.obj.tooltip,"aria-label":this.obj.tooltip}),this.attr("data-re-icon")||this.html(this.obj.title)},setTooltip:function(t){this.obj.tooltip=this.lang.parse(t),this.attr({alt:this.obj.tooltip,"aria-label":this.obj.tooltip})},setIcon:function(t){this.opts.buttonsTextLabeled||(this.obj.icon=!0,this.$icon=l.dom(t),this.html(""),this.append(this.$icon),this.attr("data-re-icon",!0),this.addClass("re-button-icon"),this.setTooltip(this.obj.title),this._buildTooltip())},setActive:function(){this.addClass("redactor-button-active")},setInactive:function(){this.removeClass("redactor-button-active")},hideTooltip:function(){this.$body.find(".re-button-tooltip").remove()},getDropdown:function(){return this.dropdown},disable:function(){this.addClass("redactor-button-disabled")},enable:function(){this.removeClass("redactor-button-disabled")},toggle:function(t){t&&t.preventDefault(),this.isDisabled()||(this.obj.dropdown?this.dropdown.toggle(t):this.obj.api?this.app.api(this.obj.api,this.obj.args,this.name):this.obj.message&&this.app.broadcast(this.obj.message,this.obj.args,this.name),this.hideTooltip())},_init:function(){this._parseTitle(),this._parseTooltip(),this._build(),this._buildCallback(),this._buildAttributes(),this._buildObserver(),this.hasIcon()?(this._buildIcon(),this._buildTooltip()):this.html(this.obj.title)},_parseTooltip:function(){this.obj.tooltip=this.obj.tooltip?this.lang.parse(this.obj.tooltip):this.obj.title},_parseTitle:function(){this.obj.title=this.lang.parse(this.obj.title)},_build:function(){this.parse("<a>"),this.addClass("re-button re-"+this.name),this.attr("data-re-name",this.name),this.dataset("data-button-instance",this),this.obj.dropdown&&this.setDropdown(this.obj.dropdown)},_buildCallback:function(){this.on("click",this.toggle.bind(this))},_buildAttributes:function(){var t={href:"#",alt:this.obj.tooltip,rel:this.name,role:"button","aria-label":this.obj.tooltip,tabindex:"-1"};this.attr(t)},_buildObserver:function(){"undefined"!=typeof this.obj.observe&&this.toolbar.addButtonObserver(this.name,this.obj.observe)},_buildIcon:function(){var t=this.obj.icon,e=/(<([^>]+)>)/gi.test(t);this.$icon=e?l.dom(t):l.dom("<i>"),e||this.$icon.addClass("re-icon-"+this.name),this.append(this.$icon),this.attr("data-re-icon",!0),this.addClass("re-button-icon")},_buildTooltip:function(){this.detector.isDesktop()&&(this.tooltip=l.create("toolbar.button.tooltip",this.app,this))}}),l.add("class","toolbar.button.tooltip",{mixins:["dom"],init:function(t,e){this.app=t,this.uuid=t.uuid,this.opts=t.opts,this.$body=t.$body,this.toolbar=t.toolbar,this.$button=e,this.created=!1,this._init()},open:function(){if(!this.$button.hasClass("redactor-button-disabled")&&!this.$button.hasClass("redactor-button-active")){this.created=!0,this.parse("<span>"),this.addClass("re-button-tooltip re-button-tooltip-"+this.uuid),this.$body.append(this),this.html(this.$button.attr("alt"));var t=this.$button.offset(),e="absolute",i=this.$button.height(),s=this.$button.width(),n=4;this.css({top:t.top+i+n+"px",left:t.left+s/2-this.width()/2+"px",position:e}),this.show()}},close:function(){this.created&&!this.$button.hasClass("redactor-button-disabled")&&(this.remove(),this.created=!1)},_init:function(){this.$button.on("mouseover",this.open.bind(this)),this.$button.on("mouseout",this.close.bind(this))}}),l.add("class","toolbar.dropdown",{mixins:["dom"],init:function(t,e,i){this.app=t,this.uuid=t.uuid,this.opts=t.opts,this.$win=t.$win,this.$doc=t.$doc,this.$body=t.$body,this.animate=t.animate,this.toolbar=t.toolbar,this.name=e,this.started=!1,this.items="format"===e?l.extend({},!0,i):i,this.$items=[]},toggle:function(t){this.started||this._build(),this.isOpened()&&this.isActive()?this.close(!1):this.open(t)},isOpened:function(){var t=this.$body.find(".redactor-dropdown-"+this.uuid+".open");return 0!==t.length&&t.attr("data-re-name")===this.name},isActive:function(){var t=this.$body.find("#redactor-dropdown-"+this.uuid+"-"+this.name+".open");return 0!==t.length},getName:function(){return this.attr("data-re-name")},getItem:function(t){return this.$items[t]},getItemsByClass:function(t){var e=[];for(var i in this.$items){var s=this.$items[i];"object"==typeof s&&s.attr("data-re-name")&&s.hasClass(t)&&e.push(s)}return e},open:function(t){this._closeAll(),this.$btn=this.toolbar.getButton(this.name),this.app.broadcast("dropdown.open",t,this,this.$btn),this.toolbar.setDropdown(this),this.show(),this.removeClass("redactor-animate-hide"),this.addClass("open"),this._observe(),this.$btn.hideTooltip(),this.$btn.setActive(),this.$doc.on("keyup.redactor.dropdown-"+this.uuid,this._handleKeyboard.bind(this)),this.$doc.on("click.redactor.dropdown-"+this.uuid,this.close.bind(this)),this.updatePosition(),this.app.broadcast("dropdown.opened",t,this,this.$btn)},close:function(t,e){if(t){var i=l.dom(t.target);if(this._isButton(t)||i.hasClass("redactor-dropdown-not-close")||i.hasClass("redactor-dropdown-item-disabled"))return void t.preventDefault()}this.app.broadcast("dropdown.close",this,this.$btn),this.toolbar.setDropdown(!1),this.$btn.setInactive(),e===!1?this._close():this.animate.start(this,"fadeOut",this._close.bind(this))},updatePosition:function(){var t=(this.toolbar.isFixed(),this.toolbar.isTarget(),this.$btn.height()),e=this.$btn.width(),i=this.$btn.offset(),s="absolute",n=2,r=0,o=i.left+r,a=parseFloat(this.css("width")),l=this.$win.width(),h=l<o+a?a-e:0,c=o-h,d=i.top+t+n;c=c<0?4:c,this.css({maxHeight:"",position:s,top:d+"px",left:c+"px"});var u=10,p=this.$win.height(),f=this.$doc.scrollTop(),m=p-(d-f)-u;this.css("max-height",m+"px")},_build:function(){this.parse("<div>"),this.attr("dir",this.opts.direction),this.attr("id","redactor-dropdown-"+this.uuid+"-"+this.name),this.attr("data-re-name",this.name),this.addClass("redactor-dropdown redactor-dropdown-"+this.uuid+" redactor-dropdown-"+this.name),this.dataset("data-dropdown-instance",this);var t=this.items.sdom||"string"==typeof this.items;t?this._buildDom():this._buildItems(),this.$body.append(this),this.started=!0},_buildDom:function(){this.html("").append(l.dom(this.items))},_buildItems:function(){this.items="format"===this.name?this._buildFormattingItems():this.items;for(var t in this.items){var e=this.items[t];if("observe"===t)this.attr("data-observe",this.items[t]);else{var i=l.create("toolbar.dropdown.item",this.app,t,e,this);this.$items[t]=i,this.append(i)}}},_buildFormattingItems:function(){for(var t in this.items)this.opts.formatting.indexOf(t)===-1&&delete this.items[t];if(this.opts.formattingHide)for(var t in this.items)this.opts.formattingHide.indexOf(t)!==-1&&delete this.items[t];if(this.opts.formattingAdd)for(var t in this.opts.formattingAdd)this.items[t]=this.opts.formattingAdd[t];return this.items},_handleKeyboard:function(t){27===t.which&&this.close()},_isButton:function(t){var e=l.dom(t.target),i=e.closest(".re-button");return i.get()===this.$btn.get()},_close:function(){this.$btn.setInactive(),this.$doc.off(".redactor.dropdown-"+this.uuid),this.removeClass("open"),this.addClass("redactor-animate-hide"),this.app.broadcast("dropdown.closed",this,this.$btn)},_closeAll:function(){this.$body.find(".redactor-dropdown-"+this.uuid+".open").each(function(t){var e=l.dom(t),i=e.dataget("data-dropdown-instance");i._close()})},_observe:function(){var t=this.attr("data-observe");t&&this.app.broadcast("dropdown."+t+".observe",this)}}),l.add("class","toolbar.dropdown.item",{mixins:["dom"],init:function(t,e,i,s){this.app=t,this.lang=t.lang,this.dropdown=s,this.name=e,this.obj=i,this._init()},setTitle:function(t){this.$span.html(t)},getTitle:function(){return this.$span.html()},enable:function(){this.removeClass("redactor-dropdown-item-disabled")},disable:function(){this.addClass("redactor-dropdown-item-disabled")},toggle:function(t){t&&t.preventDefault(),this.hasClass("redactor-dropdown-item-disabled")||(this.obj.message?this.app.broadcast(this.obj.message,this.obj.args,this.name):this.obj.api&&this.app.api(this.obj.api,this.obj.args,this.name))},_init:function(){this.parse("<a>"),this.attr("href","#"),this.addClass("redactor-dropdown-item-"+this.name),this.obj.classname&&this.addClass(this.obj.classname),this.attr("data-re-name",this.name),this.on("click",this.toggle.bind(this)),this.$span=l.dom("<span>"),this.append(this.$span),this.setTitle(this.lang.parse(this.obj.title))}}),l.add("service","cleaner",{init:function(t){this.app=t,this.opts=t.opts,this.storedComponents=[],this.storedComments=[],this.storedImages=[],this.storedLinks=[],this.deniedTags=["font","html","head","link","title","body","meta","applet"],this.convertRules={},this.unconvertRules={},this.reComments=/<!--[\s\S]*?-->\n?/g,this.reSpacedEmpty=/^(||\s||<br\s?\/?>|| )$/i,this.reScriptTag=/<script(.*?[^>]?)>([\w\W]*?)<\/script>/gi},addConvertRules:function(t,e){this.convertRules[t]=e},addUnconvertRules:function(t,e){this.unconvertRules[t]=e},input:function(t,e,i){t=t.replace(/¤t/gi,"¤t");var s=[];t=this.storeComments(t,s),t=this.encodeCode(t);var n=this.utils.buildWrapper(t);n.find("a, b, i, strong, em, img, svg, details, audio").removeAttr("onload onerror ontoggle onwheel onmouseover oncopy"),n.find("a, iframe, embed").each(function(t){var e=l.dom(t),i=e.attr("href"),s=e.attr("src");i&&i.trim().search(/^data|javascript:/i)!==-1&&e.attr("href",""),s&&s.trim().search(/^data|javascript:/i)!==-1&&e.attr("src","")});var r=["alt","title","src","class","width","height","srcset","style","usemap"];n.find("img").each(function(t){if(t.attributes.length>0)for(var e=t.attributes,i=e.length-1;i>=0;i--){var s=e[i].name.search(/^data-/)===-1&&r.indexOf(e[i].name)===-1,n="src"===e[i].name&&e[i].value.search(/^data|javascript:/i)!==-1;this.opts.imageSrcData&&(n=!1),(s||n)&&t.removeAttribute(e[i].name)}}.bind(this)),t=this.utils.getWrapperHtml(n),t=t.replace(/\$/g,"$"),t=t.replace(/&/g,"&");var o=l.create("cleaner.figure",this.app);return t=o.convert(t,this.convertRules),t=this.storeComponents(t),t=this.replaceTags(t,this.opts.replaceTags),t=this._setSpanAttr(t),t=this._setStyleCache(t),t=this.removeTags(t,this.deniedTags),t=this.opts.removeScript?this._removeScriptTag(t):this._replaceScriptTag(t),t=this.opts.removeComments?this.removeComments(t):t,t=this._isSpacedEmpty(t)?this.opts.emptyHtml:t,t=this.restoreComponents(t),t=this._cleanWrapped(t),t=this.restoreComments(t,s),t=e?this.paragraphize(t):t},output:function(t,e){if(t=this.removeInvisibleSpaces(t),this.opts.breakline&&(t=t.replace(/<\/(span|strong|b|i|em)><br\s?\/?><\/div>/gi,"</$1></div>"),t=t.replace(/<br\s?\/?><\/(span|strong|b|i|em)><\/div>/gi,"</$1></div>")),t=t.replace(/$/g,"$"),this._isSpacedEmpty(t))return"";if(this._isParagraphEmpty(t))return"";t=this.removeServiceTagsAndAttrs(t,e),t=this.storeComponents(t),t=this.removeSpanWithoutAttributes(t),t=this.removeFirstBlockBreaklineInHtml(t),t=this.opts.removeScript?t:this._unreplaceScriptTag(t),t=this.opts.preClass?this._setPreClass(t):t,t=this.opts.linkNofollow?this._setLinkNofollow(t):t,t=this.opts.removeNewLines?this.cleanNewLines(t):t,t=this.restoreComponents(t);var i=l.create("cleaner.figure",this.app);return t=i.unconvert(t,this.unconvertRules),t=this.removeEmptyAttributes(t,["style","class","rel","alt","title"]),t=this.cleanSpacesInPre(t),t=this.tidy(t),t=t.replace(/&/g,"&"),this.opts.breakline&&(t=t.replace(/<br\s?\/?>/gi,"<br>\n"),t=t.replace(/<br\s?\/?>\n+/gi,"<br>\n")),t=""===t.replace(/\n/g,"")?"":t},paste:function(t){t=this.storeComponents(t),t=t.replace(/<!--[\s\S]*?-->/g,"");var e=this.deniedTags.concat(["iframe"]);t=this.removeTags(t,e),t=t.replace(new RegExp("<!doctype([\\s\\S]+?)>","gi"),""),t=t.replace(new RegExp("<style([\\s\\S]+?)</style>","gi"),""),t=t.replace(new RegExp("</p><br /><p","gi"),"</p><p");var i=this._isHtmlMsWord(t);if(t=i?t:this._cleanGDocs(t),t=i?this._cleanMsWord(t):t,!this.opts.pasteClean)return t=this.restoreComponents(t);if(this.opts.pastePlainText)return t=this.restoreComponents(t),this.pastePlainText(t);var s=this.utils.buildWrapper(t);s.find("*").removeAttr("style"),s.find("[data-redactor-tag]").each(function(t){var e=l.dom(t);e.removeAttr("data-redactor-tag"),this.utils.isEmptyHtml(e.html())?e.html("<br>").unwrap():t.lastChild&&"BR"===t.lastChild.tagName?e.unwrap():e.append("<br>").unwrap()}.bind(this)),t=this.utils.getWrapperHtml(s),t=t.replace(/<br\s?\/?>$/,""),t=t.replace(/<br\s?\/?><\/(td|th)>/,"</$1>");var n=this.opts.pasteBlockTags.concat(this.opts.pasteInlineTags);t=this.removeTagsExcept(t,n),t=this.opts.pasteLinks?t:this.removeTags(t,["a"]),t=this.opts.pasteImages?t:this.removeTags(t,["img"]);var s=this.utils.buildWrapper(t),r=s.find("*"),o=0!==this.opts.pasteKeepStyle.length?","+this.opts.pasteKeepStyle.join(","):"";r.not("[data-redactor-style-cache]"+o).removeAttr("style");var a=0!==this.opts.pasteKeepClass.length?","+this.opts.pasteKeepClass.join(","):"";r.not("[data-redactor-style-cache], span.redactor-component"+a).removeAttr("class");var h=0!==this.opts.pasteKeepAttrs.length?","+this.opts.pasteKeepAttrs.join(","):"";r.not("img, a, span.redactor-component, [data-redactor-style-cache]"+h).each(function(t){for(var e=t.attributes,i=e.length-1;i>=0;i--)"class"!==t.attributes[i].name&&"dir"!==t.attributes[i].name&&t.removeAttribute(e[i].name)}),this.opts.pasteLinks&&this.opts.pasteLinkTarget!==!1&&s.find("a").attr("target",this.opts.pasteLinkTarget),s.find("[data-redactor-style-cache]").each(function(t){var e=t.getAttribute("data-redactor-style-cache");t.setAttribute("style",e)});var c=this.opts.imageAttrs;return s.find("img").each(function(t){if(t.attributes.length>0)for(var e=t.attributes,i=e.length-1;i>=0;i--)c.indexOf(e[i].name)===-1&&t.removeAttribute(e[i].name)}),s.find("span").each(function(t){0===t.attributes.length&&l.dom(t).unwrap()}),s.find(this.opts.inlineTags.join(",")).each(function(t){0===t.attributes.length&&this.utils.isEmptyHtml(t.innerHTML)&&l.dom(t).unwrap()}.bind(this)),s.find("ul, ol").each(function(t){var e=t.previousSibling;if(e&&"LI"===e.tagName){var i=l.dom(e);i.find("p").unwrap(),i.append(t)}}),t=this.utils.getWrapperHtml(s),t=t.replace(/<li><p>/gi,"<li>"),t=t.replace(/<\/p><\/li>/gi,"</li>"),t=t.replace(/^<li/gi,"<ul><li"),t=t.replace(/<\/li>$/gi,"</li></ul>"),this.opts.breakline&&(t=t.replace(/\n/g,"<br>")),t=t.replace(/<p> <\/p>/gi,"<p></p>"),t=t.replace(/<p><br\s?\/?><\/p>/gi,"<p></p>"),i&&(t=t.replace(/<p><\/p>/gi,""),t=t.replace(/<p>\s<\/p>/gi,""),t=t.replace(/<td\n/gi,"<td ")),t=this.restoreComponents(t)},pastePlainText:function(t){return t=this.opts.pasteLinks?this.storeLinks(t):t,t=this.opts.pasteImages?this.storeImages(t):t,t=this.getPlainText(t),t=this._replaceNlToBr(t),t=this.opts.pasteLinks?this.restoreLinks(t):t,t=this.opts.pasteImages?this.restoreImages(t):t},tidy:function(t){return t},paragraphize:function(t){var e=l.create("cleaner.paragraphize",this.app);return t=e.convert(t)},storeComments:function(t,e){var i=t.match(new RegExp("<!--([\\w\\W]*?)-->","gi"));if(null!==i)for(var s=0;s<i.length;s++)t=t.replace(i[s],"#####xstarthtmlcommentzz"+s+"xendhtmlcommentzz#####"),e.push(i[s]);return t},restoreComments:function(t,e){for(var i=0;i<e.length;i++)t=t.replace("#####xstarthtmlcommentzz"+i+"xendhtmlcommentzz#####",e[i]);return t},getFlatText:function(t){var e=l.dom("<div>");return t.nodeType||t.dom?e.append(t):(t=t.toString(),t=t.trim(),e.html(t)),t=e.get().textContent||e.get().innerText||"",void 0===t?"":t},getPlainText:function(t){t=t.replace(/<!--[\s\S]*?-->/gi,""),t=t.replace(/<style[\s\S]*?style>/gi,""),t=t.replace(/<p><\/p>/g,""),t=t.replace(/<\/div>|<\/li>|<\/td>/gi,"\n"),t=t.replace(/<\/p>/gi,"\n\n"),t=t.replace(/<\/H[1-6]>/gi,"\n\n");var e=document.createElement("div");return e.innerHTML=t,t=e.textContent||e.innerText,t.trim()},replaceTags:function(t,e){if(e){var i=this,s=Object.keys(e),n=this.utils.buildWrapper(t);n.find(s.join(",")).each(function(t){i.utils.replaceToTag(t,e[t.tagName.toLowerCase()])}),t=this.utils.getWrapperHtml(n)}return t},replaceNbspToSpaces:function(t){return t.replace(" "," ")},replaceBlocksToBr:function(t){return t=t.replace(/<div[^>]*><\/div>/gi,""),t=t.replace(/<td[^>]*><\/td>/gi,""),t=t.replace(/<\/div>|<\/li>|<\/td>|<\/p>|<\/H[1-6]>/gi,"<br>")},cleanNewLines:function(t){return t.replace(/\r?\n/g,"")},cleanSpacesInPre:function(t){return t.replace(" "," ")},removeInvisibleSpaces:function(t){return t=this.utils.removeInvisibleChars(t),t=t.replace(//gi,"")},removeNl:function(t){return t=t.replace(/\n/g," "),t=t.replace(/\s+/g,"s")},removeBrAtEnd:function(t){return t=t.replace(/<br\s?\/?>$/gi," "),t=t.replace(/<br\s?\/?><li/gi,"<li")},removeTags:function(t,e){var i=e?/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi:/(<([^>]+)>)/gi,s=e?function(t,i){return e.indexOf(i.toLowerCase())===-1?t:""}:"";return t.replace(i,s)},removeTagsExcept:function(t,e){if(void 0===e)return t.replace(/(<([^>]+)>)/gi,"");var i=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;return t.replace(i,function(t,i){return e.indexOf(i.toLowerCase())===-1?"":t})},removeComments:function(t){return t.replace(this.reComments,"")},removeServiceTagsAndAttrs:function(t,e){var i=this.utils.buildWrapper(t),s=this;return e!==!1&&i.find(".redactor-selection-marker").each(function(t){var e=l.dom(t),i=s.utils.removeInvisibleChars(e.text());return""===i?e.remove():e.unwrap()}),i.find("[data-redactor-style-cache]").removeAttr("data-redactor-style-cache"),this.utils.getWrapperHtml(i)},removeSpanWithoutAttributes:function(t){var e=this.utils.buildWrapper(t);return e.find("span").removeAttr("data-redactor-span data-redactor-style-cache").each(function(t){0===t.attributes.length&&l.dom(t).unwrap()}),this.utils.getWrapperHtml(e)},removeFirstBlockBreaklineInHtml:function(t){return t.replace(new RegExp("</li><br\\s?/?>","gi"),"</li>")},removeEmptyAttributes:function(t,e){for(var i=this.utils.buildWrapper(t),s=0;s<e.length;s++)i.find("["+e[s]+'=""]').removeAttr(e[s]);return this.utils.getWrapperHtml(i)},encodeHtml:function(t){return t=t.replace(/<br\s?\/?>/g,"\n"),t=t.replace(/ /g," "),t=t.replace(/”/g,'"'),t=t.replace(/“/g,'"'),t=t.replace(/‘/g,"'"),t=t.replace(/’/g,"'"),t=this.encodeEntities(t),t=t.replace(/\$/g,"$"),this.opts.preSpaces&&(t=t.replace(/\t/g,new Array(this.opts.preSpaces+1).join(" "))),t},encodeCode:function(t){return t=this.encodeAttrSings(t),t=t.replace(/<\s/gi,"< "),t=t.replace(/<([^>]+)</gi,"<$1<"),t=t.replace(/<(.*?)>/gi,"xtagstartz$1xtagendz"),t=t.replace(/xtagstartzpre(.*?)xtagendz/g,"<pre$1>"),t=t.replace(/xtagstartzcode(.*?)xtagendz/g,"<code$1>"),t=t.replace(/xtagstartz\/codextagendz/g,"</code>"),t=t.replace(/xtagstartz\/prextagendz/g,"</pre>"),t=this._encodeCode(t),t=t.replace(/xtagstartz([\w\W]*?)xtagendz/g,"<$1>"),t=t.replace(/xtagstartz\/(.*?)xtagendz/g,"</$1>"),t=this.decodeAttrSings(t)},_encodeCode:function(t){var e=this.utils.buildWrapper(t);return e.find("pre code, pre, code").each(this._encodeNode.bind(this)),this.utils.getWrapperHtml(e)},_encodeNode:function(t){var e=t.firstChild,i=t.innerHTML;if("PRE"!==t.tagName||!e||"CODE"!==e.tagName){i=i.replace(/xtagstartz/g,"<"),i=i.replace(/xtagendz/g,">");var s=this.decodeEntities(i);t.textContent=this._encodeNodeHtml(s)}},_encodeNodeHtml:function(t){return t=t.replace(/ /g," ").replace(/<br\s?\/?>/g,"\n"),t=this.opts.preSpaces?t.replace(/\t/g,new Array(this.opts.preSpaces+1).join(" ")):t},encodeAttrSings:function(t){var e=t.match(/="(.*?)"/g);if(null!==e)for(var i=0;i<e.length;i++)if(e[i].search(/^"</)===-1&&e[i].search(/>"$/)===-1){var s=e[i].replace(">","xmoresignz");s=s.replace("<","xlesssignz"),t=t.replace(e[i],s)}return t},encodeEntities:function(t){return t=this.decodeEntities(t),t=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},encodePhpCode:function(t){return t=t.replace("<?php","<?php"),t=t.replace("<?","<?"),t=t.replace("?>","?>")},decodeAttrSings:function(t){return t=t.replace(/xmoresignz/gi,">"),t=t.replace(/xlesssignz/gi,"<")},decodeEntities:function(t){return String(t).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&")},storeComponents:function(t){var e=this.utils.getElementsFromHtml(t,"figure","table");return this._storeMatched(t,e,"Components","figure")},restoreComponents:function(t){return this._restoreMatched(t,"Components","figure")},storeLinks:function(t){var e=this.utils.getElementsFromHtml(t,"a");return this._storeMatched(t,e,"Links","a")},storeImages:function(t){var e=this.utils.getElementsFromHtml(t,"img");return this._storeMatched(t,e,"Images","img")},restoreLinks:function(t){return this._restoreMatched(t,"Links","a")},restoreImages:function(t){return this._restoreMatched(t,"Images","img")},_cleanWrapped:function(t){return t=t.replace(new RegExp("<p><figure([\\w\\W]*?)</figure></p>","gi"),"<figure$1</figure>")},_cleanGDocs:function(t){return t=t.replace(/<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2"),t=t.replace(/<b(.*?)id="docs-internal-guid(.*?)">([\w\W]*?)<\/b>/gi,"$3"),t=t.replace(/<span[^>]*(font-style:\s?italic;\s?font-weight:\s?bold|font-weight:\s?bold;\s?font-style:\s?italic)[^>]*>([\w\W]*?)<\/span>/gi,"<b><i>$2</i></b>"),t=t.replace(/<span[^>]*(font-style:\s?italic;\s?font-weight:\s?600|font-weight:\s?600;\s?font-style:\s?italic)[^>]*>([\w\W]*?)<\/span>/gi,"<b><i>$2</i></b>"),t=t.replace(/<span[^>]*(font-style:\s?italic;\s?font-weight:\s?700|font-weight:\s?700;\s?font-style:\s?italic)[^>]*>([\w\W]*?)<\/span>/gi,"<b><i>$2</i></b>"),t=t.replace(/<span[^>]*font-style:\s?italic[^>]*>([\w\W]*?)<\/span>/gi,"<i>$1</i>"),t=t.replace(/<span[^>]*font-weight:\s?bold[^>]*>([\w\W]*?)<\/span>/gi,"<b>$1</b>"),t=t.replace(/<span[^>]*font-weight:\s?700[^>]*>([\w\W]*?)<\/span>/gi,"<b>$1</b>"),t=t.replace(/<span[^>]*font-weight:\s?600[^>]*>([\w\W]*?)<\/span>/gi,"<b>$1</b>")},_cleanMsWord:function(t){t=t.replace(/<!--[\s\S]+?-->/gi,""),t=t.replace(/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,""),t=t.replace(/<(\/?)s>/gi,"<$1strike>"),t=t.replace(/ /gi," "),t=t.replace(/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(t,e){return e.length>0?e.replace(/./," ").slice(Math.floor(e.length/2)).split("").join(" "):""});var e=this.utils.buildWrapper(t);e.find(".MsoFootnoteText").each(function(t){var e=l.dom(t),i=e.parent();0!==i.length&&i.attr("style").search(/mso-element:footnote/)!==-1&&e.find("a").attr("id","_"+i.attr("id"))}),e.find(".MsoFootnoteReference").each(function(t){var e=l.dom(t),i=e.parent();0!==i.length&&"A"===i.get().tagName&&i.attr("id",i.attr("name"))}),e.find("p").each(function(t){var e=l.dom(t),i=e.attr("style"),s=/mso-list:\w+ \w+([0-9]+)/.exec(i);s&&e.attr("data-listLevel",parseInt(s[1],10))}),this._parseWordLists(e),e.find("[align]").removeAttr("align"),e.find("[name]").removeAttr("name"),e.find("span").each(function(t){var e=l.dom(t),i=e.attr("style"),s=/mso-list:Ignore/.exec(i);s?e.remove():e.unwrap()}),e.find("[style]").removeAttr("style"),e.find("[class^='Mso']").removeAttr("class"),e.find("a").filter(function(t){return!t.hasAttribute("href")}).unwrap(),t=this.utils.getWrapperHtml(e),t=t.replace(/<p[^>]*><\/p>/gi,""),t=t.replace(/<li>·/gi,"<li>"),t=t.trim(),t=t.replace(/\/(p|ul|ol|h1|h2|h3|h4|h5|h6|blockquote)>\s+<(p|ul|ol|h1|h2|h3|h4|h5|h6|blockquote)/gi,"/$1>\n<$2");for(var i="",s=t.split(/\n/),n=0;n<s.length;n++){var r=""!==s[n]&&s[n].search(/>$/)===-1?" ":"\n";i+=s[n]+r}return i},_parseWordLists:function(t){var e=0,i=null,s=null,n=null;t.find("p").each(function(t){var r=l.dom(t),o=r.attr("data-listLevel");if(null===o&&r.hasClass("MsoListParagraphCxSpMiddle")&&(o=1),null!==o){var a=r.text(),h=/^\s*\w+\./.test(a)?"<ol></ol>":"<ul></ul>";if(r.hasClass("MsoListParagraphCxSpFirst")||r.hasClass("MsoNormal")?(s=l.dom(h),r.before(s)):o>e&&0!==e&&(n=l.dom(h),i.append(n),s=n),o<e)for(var c=e-o+1,d=0;d<c;d++)s=s.parent();r.find("span").first().unwrap(),i=l.dom("<li>"+r.html().trim()+"</li>"),null===s&&(r.before(h),s=r.prev()),s.append(i),r.remove(),e=o}else s=null,e=0})},_isSpacedEmpty:function(t){return t.search(this.reSpacedEmpty)!==-1},_isParagraphEmpty:function(t){return t.search(/^<p><\/p>$/i)!==-1},_isHtmlMsWord:function(t){return t.match(/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i)},_setSpanAttr:function(t){var e=this.utils.buildWrapper(t);return e.find("span").attr("data-redactor-span",!0),this.utils.getWrapperHtml(e)},_setStyleCache:function(t){var e=this.utils.buildWrapper(t);return e.find("[style]").each(function(t){var e=l.dom(t);e.attr("data-redactor-style-cache",e.attr("style"))}),this.utils.getWrapperHtml(e)},_setPreClass:function(t){var e=this.utils.buildWrapper(t);return e.find("pre").addClass(this.opts.preClass),this.utils.getWrapperHtml(e)},_setLinkNofollow:function(t){var e=this.utils.buildWrapper(t);return e.find("a").attr("rel","nofollow"),this.utils.getWrapperHtml(e)},_replaceScriptTag:function(t){return t.replace(this.reScriptTag,'<script class="redactor-script-tag" $1>$2</script>')},_unreplaceScriptTag:function(t){return t.replace(/<script class="redactor-script-tag"(.*?[^>]?)>([\w\W]*?)<\/script>/gi,"<script$1>$2</script>")},_replaceNlToBr:function(t){return t.replace(/\n/g,"<br />")},_removeScriptTag:function(t){return t.replace(this.reScriptTag,"")},_storeMatched:function(t,e,i,s){if(this["stored"+i]=[],e)for(var n=0;n<e.length;n++)this["stored"+i][n]=e[n],t=t.replace(e[n],"####"+s+n+"####");return t},_restoreMatched:function(t,e,i){if(this["stored"+e])for(var s=0;s<this["stored"+e].length;s++)t=t.replace("####"+i+s+"####",this["stored"+e][s]);return t}}),l.add("class","cleaner.figure",{init:function(t){this.app=t,this.opts=t.opts,this.utils=t.utils,this.detector=t.detector},convert:function(t,e){var i=this.utils.buildWrapper(t);return i.find("img").each(this._convertImage.bind(this)),i.find("hr").each(this._convertLine.bind(this)),i.find("iframe").each(this._convertIframe.bind(this)),i.find("table").each(this._convertTable.bind(this)),i.find("form").each(this._convertForm.bind(this)),i.find("figure pre").each(this._convertCode.bind(this)),i.find("[data-redactor-type=variable]").addClass("redactor-component"),i.find("figure").not(".redactor-component, .redactor-figure-code").each(this._convertWidget.bind(this)),i.find("figure pre").each(this._setContenteditableCode.bind(this)),i.find(".redactor-component, .non-editable").attr("contenteditable",!1),this.detector.isIe()&&i.find("[data-redactor-type=table]").removeAttr("contenteditable"),i.find("figcaption, td, th").attr("contenteditable",!0),i.find(".redactor-component, figcaption").attr("tabindex","-1"),this._acceptExtraRules(i,e),this.utils.getWrapperHtml(i)},unconvert:function(t,e){t=t.replace(/<\/([^>]+)><div data-redactor-tag/g,"</$1>\n<div data-redactor-tag"),t=t.replace(/<\/([^>]+)><p/g,"</$1>\n<p");var i=this.utils.buildWrapper(t);return i.find("th, td, figcaption, figure, pre, code, .redactor-component").removeAttr("contenteditable tabindex"),i.find("figure").removeClass("redactor-component redactor-component-active redactor-uploaded-figure"),i.find("[data-redactor-type=variable]").removeClass("redactor-component redactor-component-active"),i.find("figure[data-redactor-type=line]").unwrap(),i.find("figure[data-redactor-type=widget]").each(this._unconvertWidget.bind(this)),i.find("figure[data-redactor-type=form]").each(this._unconvertForm.bind(this)),i.find("figure[data-redactor-type=table]").each(this._unconvertTable.bind(this)),i.find("figure[data-redactor-type=image]").removeAttr("rel").each(this._unconvertImages.bind(this)),i.find("img").removeAttr("data-redactor-type").removeClass("redactor-component"),i.find(".non-editable").removeAttr("contenteditable"),i.find("figure").each(this._removeTypes.bind(this)),i.find("span.redactor-component-caret").remove(),i=this._unconvertBreakTag(i),this._acceptExtraRules(i,e),t=this.utils.getWrapperHtml(i),t=t.replace(/<br\s?\/?>$/,""),t=t.replace(/<br\s?\/?><\/(td|th)>/,"</$1>")},_convertImage:function(t){var e=l.dom(t);if(!this._isNonEditable(e)){this.opts.imageObserve&&!e.attr("data-image")&&e.attr("data-image",this.utils.getRandomId());var i=e.closest("a"),s=e.closest("figure"),n=0===s.children().not("a, img, br, figcaption").length;if(n){if(0===s.length){var r=0!==i.length?i.closest("p"):e.closest("p");if(this.opts.imageFigure===!1&&0!==r.length){var o=this.utils.replaceToTag(r,"figure");s=o,s.addClass("redactor-replace-figure")}else 0!==r.length&&r.unwrap(),s=0!==i.length?i.wrap("<figure>"):e.wrap("<figure>")}else s.hasClass("redactor-uploaded-figure")?s.removeClass("redactor-uploaded-figure"):s.addClass("redactor-keep-figure");this._setFigure(s,"image")}}},_convertTable:function(t){if(!this._isNonEditable(t)){var e=this._wrapFigure(t);this._setFigure(e,"table")}},_convertLine:function(t){if(!this._isNonEditable(t)){var e=this._wrapFigure(t);this._setFigure(e,"line")}},_convertForm:function(t){if(!this._isNonEditable(t)){var e=this.utils.replaceToTag(t,"figure");this._setFigure(e,"form")}},_convertIframe:function(t){if(!this._isNonEditable(t)){var e=l.dom(t);if(0===e.closest(".redactor-component").length){var i=t.getAttribute("src"),s=i&&(i.match(this.opts.regex.youtube)||i.match(this.opts.regex.vimeo)),n=this._wrapFigure(t);s&&this._setFigure(n,"video")}}},_convertCode:function(t){if(!this._isNonEditable(t)){var e=this._wrapFigure(t);this._setFigure(e,"code")}},_convertWidget:function(t){if(!this._isNonEditable(t)){var e=l.dom(t);e.addClass("redactor-component"),e.attr("data-redactor-type","widget"),e.attr("data-widget-code",encodeURI(t.innerHTML.trim()))}},_unconvertBreakTag:function(t){return t.find("[data-redactor-tag]").each(function(t){var e=l.dom(t);if(e.removeAttr("data-redactor-tag"), 0!==t.attributes.length)return void(t.lastChild&&"BR"===t.lastChild.tagName&&l.dom(t.lastChild).remove());if(t.lastChild&&"BR"===t.lastChild.tagName)e.unwrap();else{var i=e.nextElement();0!==i.length&&i.attr("data-redactor-tag")&&t.appendChild(document.createElement("br")),e.unwrap()}}.bind(this)),t},_unconvertForm:function(t){this.utils.replaceToTag(t,"form")},_unconvertTable:function(t){var e=l.dom(t);e.unwrap()},_unconvertWidget:function(t){var e=l.dom(t);e.html(decodeURI(e.attr("data-widget-code"))),e.removeAttr("data-widget-code")},_unconvertImages:function(t){var e=l.dom(t);e.removeClass("redactor-component");var i=0!==e.closest("li").length,s=0!==e.closest("table").length,n=0!==e.find("figcaption").length,r=e.attr("style"),o=!(null===r||""===r),a=""!==e.attr("class");(i||s&&!n&&!o&&!a)&&e.unwrap()},_removeTypes:function(t){var e=l.dom(t),i=e.attr("data-redactor-type"),s=["image","widget","line","video","code","form","table"];if(i&&s.indexOf(i)!==-1&&e.removeAttr("data-redactor-type"),e.hasClass("redactor-keep-figure"))e.removeClass("redactor-keep-figure");else if("image"===i&&this.opts.imageFigure===!1){var n=0!==e.find("figcaption").length;n||(e.hasClass("redactor-replace-figure")?(e.removeClass("redactor-replace-figure"),this.utils.replaceToTag(e,"p")):this.utils.replaceToTag(e,"p"))}e.removeClass("redactor-replace-figure")},_wrapFigure:function(t){var e=l.dom(t),i=e.closest("figure");return 0===i.length?e.wrap("<figure>"):i},_setFigure:function(t,e){t.addClass("redactor-component"),t.attr("data-redactor-type",e)},_setContenteditableCode:function(t){if(!this._isNonEditable(t)){var e=l.dom(t),i=e.children("code").first(),s=0!==i.length?i:e;s.attr("contenteditable",!0).attr("tabindex","-1")}},_acceptExtraRules:function(t,e){for(var i in e)"function"==typeof e[i]&&e[i](t)},_isNonEditable:function(t){return 0!==l.dom(t).closest(".non-editable").length}}),l.add("class","cleaner.paragraphize",{init:function(t){this.app=t,this.opts=t.opts,this.utils=t.utils,this.cleaner=t.cleaner,this.element=t.element,this.stored=[],this.remStart="#####replace",this.remEnd="#####",this.paragraphizeTags=["table","div","pre","form","ul","ol","h1","h2","h3","h4","h5","h6","dl","blockquote","figcaption","address","section","header","footer","aside","article","object","style","script","iframe","select","input","textarea","button","option","map","area","math","hr","fieldset","legend","hgroup","nav","figure","details","menu","summary","p"]},convert:function(t){var e=this._isConverted(t);return e=e===!0?this._convert(t):e,e=this._convertTable(e)},_convert:function(t,e){var i=this.opts.breakline||e?"sdivtag":this.opts.markup,s=e?"tbr":"br";t=this._storeTags(t);var n=[];t=this.cleaner.storeComments(t,n),t=t.trim(),t=this._trimLinks(t);var r=this.opts.inlineTags.join("|");t=t.replace(new RegExp("<("+r+")(.*?[^>]?)>\n</("+r+")>","gi"),"<$1$2></$3>"),t=t.replace(/xparagraphmarkerz(?:\r\n|\r|\n)$/g,""),t=t.replace(/xparagraphmarkerz$/g,""),t=t.replace(/xparagraphmarkerz(?:\r\n|\r|\n)/g,"\n"),t=t.replace(/xparagraphmarkerz/g,"\n"),this.opts.breakline?(t=t.replace(/<br\s?\/?>(?:\r\n|\r|\n)/gi,"xbreakmarkerz\n"),t=t.replace(/<br\s?\/?>/gi,"xbreakmarkerz\n"),t=t.replace(/xbreakmarkerz\n<\//gi,"xbreakmarkerz</")):t=t.replace(/[\n]+/g,"\n");for(var o="",a=t.split("\n"),l=0;l<a.length;l++)o+="<"+i+">"+a[l]+"</"+i+">\n";return t=o.replace(/\n$/,""),t=t.replace(new RegExp("<"+i+">\\s+#####","gi"),"#####"),t=t.replace(new RegExp("<"+i+">#####","gi"),"#####"),t=t.replace(new RegExp("#####</"+i+">","gi"),"#####"),t=this.opts.breakline?t.replace(/xbreakmarkerz/gi,"<br>"):t,t=this._restoreTags(t),t=this.cleaner.restoreComments(t,n),this.opts.breakline&&(t=t.replace(new RegExp("<"+i+"></"+i+">","gi"),"<"+i+"><br></"+i+">")),t=t.replace(new RegExp("<sdivtag>","gi"),'<div data-redactor-tag="'+s+'">'),t=t.replace(new RegExp("sdivtag","gi"),"div"),t=t.replace(/<\/([^>]+)><div data-redactor-tag/g,"</$1>\n<div data-redactor-tag")},_convertTable:function(t){var e=this.utils.buildWrapper(t);return e.find("td, th").each(this._convertCell.bind(this)),t=this.utils.getWrapperHtml(e)},_convertCell:function(t){var e=l.dom(t);this.stored=[];var i=this._convert(e.html(),!0);e.html(i)},_storeTags:function(t){var e=this,i=this.utils.buildWrapper(t);return i.find(this.paragraphizeTags.join(", ")).each(function(t,i){var s=document.createTextNode(e.remStart+i+e.remEnd+"xparagraphmarkerz");e.stored.push(t.outerHTML),t.parentNode.replaceChild(s,t)}),this.utils.getWrapperHtml(i)},_restoreTags:function(t){for(var e=0;e<this.stored.length;e++)this.stored[e]=this.stored[e].replace(/\$/g,"$"),t=t.replace(this.remStart+e+this.remEnd,this.stored[e]);return t},_trimLinks:function(t){var e=this.utils.buildWrapper(t);return e.find("a").each(this._trimLink.bind(this)),t=this.utils.getWrapperHtml(e)},_trimLink:function(t){var e=l.dom(t);e.html(e.html().trim())},_isConverted:function(t){return this._isDisabled(t)?t:!this._isEmptyHtml(t)||this.opts.emptyHtml},_isDisabled:function(){return this.opts.paragraphize===!1||this.element.isType("inline")},_isEmptyHtml:function(t){return""===t||"<p></p>"===t||"<div></div>"===t}}),l.add("service","detector",{init:function(t){this.app=t,this.userAgent=navigator.userAgent.toLowerCase()},isWebkit:function(){return/webkit/.test(this.userAgent)},isFirefox:function(){return this.userAgent.indexOf("firefox")>-1},isIe:function(t){if(document.documentMode||/Edge/.test(navigator.userAgent))return"edge";var e;return e=RegExp("msie"+(isNaN(t)?"":"\\s"+t),"i").test(navigator.userAgent),e||(e=!!navigator.userAgent.match(/Trident.*rv[ :]*11\./)),e},isMobile:function(){return/(iPhone|iPod|Android)/.test(navigator.userAgent)},isDesktop:function(){return!/(iPhone|iPod|iPad|Android)/.test(navigator.userAgent)},isIpad:function(){return/iPad/.test(navigator.userAgent)}}),l.add("service","offset",{init:function(t){this.app=t},get:function(t,e){var i={start:0,end:0},s=this.utils.getNode(t);if(!s)return!1;var n=this.editor.isEditor(s),r=!!n||this.selection.isIn(s),o=this.selection.getRange();if(n||r){if(this.selection.is()&&r){var a=l.dom(o.startContainer),h=a.hasClass("redactor-component")?o.startOffset:0,c=o.cloneRange();c.selectNodeContents(s),c.setEnd(o.startContainer,o.startOffset);var d=this._getString(o,e);i.start=this._getString(c,e).length-h,i.end=i.start+d.length+h}}else i=!1;return i},set:function(t,e){if(!this._setComponentOffset(e)){this.component.clearActive();var i=this.utils.getNode(e);if(i){var s=this.size(i),n=0,r=document.createRange();t.end=t.end>s?s:t.end,r.setStart(i,0),r.collapse(!0);for(var o=[i],a=!1,l=!1;!l&&(i=o.pop());)if(3===i.nodeType){var h=n+i.length;!a&&!this._isFigcaptionNext(i)&&t.start>=n&&t.start<=h&&(r.setStart(i,t.start-n),a=!0),a&&t.end>=n&&t.end<=h&&(r.setEnd(i,t.end-n),l=!0),n=h}else for(var c=i.childNodes.length;c--;)o.push(i.childNodes[c]);this.selection.setRange(r)}}},size:function(t,e){var i=this.utils.getNode(t);if(i){var s=document.createRange(),n=s.cloneRange();return n.selectNodeContents(i),this._getString(n,e).length}return 0},_getString:function(t,e){var i=t.toString();return i=this.editor.isEmpty()?i.replace(/\uFEFF/g,""):i,i=e?i.trim():i},_setComponentOffset:function(t){return!!this.component.isNonEditable(t)&&this.component.setActive(t)},_isFigcaptionNext:function(t){var e=t.nextSibling;return""===t.nodeValue.trim()&&e&&"FIGCAPTION"===e.tagName}}),l.add("service","inspector",{init:function(t){this.app=t},parse:function(t){return l.create("inspector.parser",this.app,this,t)},isText:function(t){if("string"==typeof t&&!/^\s*<(\w+|!)[^>]*>/.test(t))return!0;var e=l.dom(t).get();return e&&3===e.nodeType},isInlineTag:function(t,e){var i=this._extendTags(this.opts.inlineTags,e);return this._isTag(t)&&i.indexOf(t.toLowerCase())!==-1},isBlockTag:function(t,e){var i=this._extendTags(this.opts.blockTags,e);return this._isTag(t)&&i.indexOf(t.toLowerCase())!==-1},isTableCellTag:function(t){return["td","th"].indexOf(t.toLowerCase())!==-1},isHeadingTag:function(t){return["h1","h2","h3","h4","h5","h6"].indexOf(t.toLowerCase())!==-1},_isTag:function(t){return void 0!==t&&t},_extendTags:function(t,e){if(t=t.concat(t),e)for(var i=0;i<e.length;i++)t.push(e[i]);return t}}),l.add("class","inspector.parser",{init:function(t,e,i){this.app=t,this.uuid=t.uuid,this.opts=t.opts,this.utils=t.utils,this.editor=t.editor,this.selection=t.selection,this.inspector=e;var s=this.editor.getElement();this.el=i,this.$el=l.dom(this.el,s),this.node=this.$el.get(),this.node&&8===this.node.nodeType&&(this.node=!1),this.$component=this.$el.closest(".redactor-component",s)},isEditor:function(){return this.node===this.editor.getElement().get()},isInEditor:function(){return 0!==this.$el.parents(".redactor-in-"+this.uuid).length},isComponent:function(){return 0!==this.$component.length},isComponentType:function(t){return this.getComponentType()===t},isComponentActive:function(){return this.isComponent()&&this.$component.hasClass("redactor-component-active")},isComponentEditable:function(){var t=["code","table"],e=this.getComponentType();return this.isComponent()&&t.indexOf(e)!==-1},isFigcaption:function(){return this.getFigcaption()},isPre:function(){return this.getPre()},isCode:function(){var t=this.$el.closest("code"),e=t.parent("pre");return 0!==t.length&&0===e.length},isList:function(){return this.getList()},isFirstListItem:function(){return this._getLastOrFirstListItem("first")},isLastListItem:function(){return this._getLastOrFirstListItem("last")},isFirstTableCell:function(){return this._getLastOrFirstTableCell("first")},isLastTableCell:function(){return this._getLastOrFirstTableCell("last")},isTable:function(){return this.isComponentType("table")||this.getTable()},isHeading:function(){return this.getHeading()},isBlockquote:function(){return this.getBlockquote()},isDl:function(){return this.getDl()},isParagraph:function(){return this.getParagraph()},isLink:function(){return this.getLink()},isFile:function(){return this.getFile()},isText:function(){return this.inspector.isText(this.el)},isInline:function(){var t=this.opts.inlineTags;return!!this.isElement()&&t.indexOf(this.node.tagName.toLowerCase())!==-1},isBlock:function(){var t=this.opts.blockTags;return!!this.isElement()&&t.indexOf(this.node.tagName.toLowerCase())!==-1},isElement:function(){return this.node&&this.node.nodeType&&3!==this.node.nodeType},hasParent:function(t){return 0!==this.$el.closest(t.join(",")).length},getNode:function(){return this.node},getTag:function(){return!!this.isElement()&&this.node.tagName.toLowerCase()},getComponent:function(){return!!this.isComponent()&&this.$component.get()},getComponentType:function(){return!!this.isComponent()&&this.$component.attr("data-redactor-type")},getFirstNode:function(){return this.utils.getFirstNode(this.node)},getLastNode:function(){return this.utils.getLastNode(this.node)},getFirstElement:function(){return this.utils.getFirstElement(this.node)},getLastElement:function(){return this.utils.getLastElement(this.node)},getFigcaption:function(){return this._getClosestNode("figcaption")},getPre:function(){return this._getClosestNode("pre")},getCode:function(){return this._getClosestNode("code")},getList:function(){return this._getClosestNode("ul, ol")},getParentList:function(){return this._getClosestUpNode("ul, ol")},getListItem:function(){return this._getClosestNode("li")},getTable:function(){return this.getComponentType("table")?this.$component.find("table").get():this._getClosestNode("table")},getTableCell:function(){var t=this.$el.closest("td, th");return 0!==t.length&&t.get()},getComponentCodeElement:function(){return!!this.isComponentType("code")&&this.$component.find("pre code, pre").last().get()},getImageElement:function(){return!!this.isComponentType("image")&&this.$component.find("img").get()},getParagraph:function(){return this._getClosestNode("p")},getHeading:function(){return this._getClosestNode("h1, h2, h3, h4, h5, h6")},getDl:function(){return this._getClosestNode("dl")},getBlockquote:function(){return this._getClosestNode("blockquote")},getLink:function(){var t=this.isComponent()&&!this.isFigcaption(),e=this.isComponentType("table");if(e||!t){var i=this._getClosestElement("a");return!(!i||i.attr("data-file"))&&i.get()}return!1},getFile:function(){var t=this.isComponent(),e=this.isComponentType("table");if(e||!t){var i=this._getClosestElement("a");return!(!i||!i.attr("data-file"))&&i.get()}return!1},findFirstNode:function(t){return this.$el.find(t).first().get()},findLastNode:function(t){return this.$el.find(t).last().get()},_getLastOrFirstListItem:function(t){var e=this.getList(),i=this.getTag();if(e&&"li"===i){var s=l.dom(e).find("li")[t]().get();if(s&&this.node===s)return!0}return!1},_getLastOrFirstTableCell:function(t){var e=this.getTable(),i=this.getTag();if(e&&("td"===i||"th"===i)){var s=l.dom(e).find("td, th")[t]().get();if(s&&this.node===s)return!0}return!1},_getClosestUpNode:function(t){var e=this.editor.getElement(),i=this.$el.parents(t,e).last();return 0!==i.length&&i.get()},_getClosestNode:function(t){var e=this.editor.getElement(),i=this.$el.closest(t,e);return 0!==i.length&&i.get()},_getClosestElement:function(t){var e=this.editor.getElement(),i=this.$el.closest(t,e);return 0!==i.length&&i}}),l.add("service","marker",{init:function(t){this.app=t},build:function(t,e){var i=document.createElement("span");return i.id="selection-marker-"+this._getPos(t),i.className="redactor-selection-marker",i.innerHTML=this.opts.markerChar,e?i.outerHTML:i},buildHtml:function(t){return this.build(t,!0)},insert:function(t){this.remove();var e="both"!==t&&("start"===t||this.selection.isCollapsed());this.selection.is()||this.editor.focus();var i=this.selection.getRange();if(i){var s=this.build("start"),n=this.build("end"),r=i.cloneRange();return e||(r.collapse(!1),r.insertNode(n)),r.setStart(i.startContainer,i.startOffset),r.collapse(!0),r.insertNode(s),i.setStartAfter(s),e||i.setEndBefore(n),this.selection.setRange(i),s}},find:function(t,e){var i=this.editor.getElement(),s=(e||i).find("span#selection-marker-"+this._getPos(t));return 0!==s.length&&s.get()},restore:function(){var t=this.find("start"),e=this.find("end"),i=this.selection.getRange();if(i&&this.selection.is()||(this.editor.focus(),i=document.createRange()),t){var s=!!e&&e.previousSibling,n=t.nextSibling;n=(!n||3!==n.nodeType||""!==n.textContent.replace(/[\n\t]/g,""))&&n,e?n&&"selection-marker-end"===n.id?this._restoreInject(i,t):s&&n?(i.selectNodeContents(s),i.collapse(!1),i.setStart(n,0)):s&&!n?(i.selectNodeContents(s),i.collapse(!1),i.setStartAfter(t)):(i.setStartAfter(t),i.setEndBefore(e)):n?(i.selectNodeContents(n),i.collapse(!0)):this._restoreInject(i,t),this.selection.setRange(i),t&&t.parentNode.removeChild(t),e&&e.parentNode.removeChild(e)}},remove:function(){var t=this.find("start"),e=this.find("end");t&&t.parentNode.removeChild(t),e&&e.parentNode.removeChild(e)},_getPos:function(t){return void 0===t?"start":t},_restoreInject:function(t,e){var i=this.utils.createInvisibleChar();l.dom(e).after(i),t.selectNodeContents(i),t.collapse(!1)}}),l.add("service","component",{init:function(t){this.app=t,this.activeClass="redactor-component-active"},create:function(t,e){return l.create(t+".component",this.app,e)},build:function(t){var e,i=l.dom(t),s=i.attr("data-redactor-type");return s&&(e=this.create(s,t)),e?e:t},remove:function(t,e){var i=l.dom(t).closest(".redactor-component"),s=i.attr("data-redactor-type"),n=i.parent(),r=this.inspector.parse(n),o=this.utils.findSiblings(i,"prev"),a=this.utils.findSiblings(i,"next"),h=this.app.broadcast(s+".delete",i);if(h!==!1){if(i.remove(),this.app.broadcast(s+".deleted",i),this.app.broadcast("contextbar.close"),this.app.broadcast("imageresizer.stop"),e!==!1){var c=r.getTableCell();c&&this.utils.isEmptyHtml(c.innerHTML)?this.caret.setStart(c):a?this.caret.setStart(a):o?this.caret.setEnd(o):this.editor.startFocus()}this.editor.isEmpty()&&(this.editor.setEmpty(),this.editor.startFocus(),this.app.broadcast("empty"))}},isNonEditable:function(t){var e=this.inspector.parse(t);return e.isComponent()&&!e.isComponentEditable()},isActive:function(t){var e;if(t){var i=this.inspector.parse(t);return e=l.dom(i.getComponent()),e.hasClass(this.activeClass)}return e=this._find(),0!==e.length},getActive:function(t){var e=this._find();return 0!==e.length&&(t?e:e.get())},setActive:function(t){this.clearActive(),this.editor.focus();var e=this.inspector.parse(t),i=e.getComponent(),s=l.dom(i);if(!e.isFigcaption()){var n=s.find(".redactor-component-caret");0===n.length&&(n=this._buildCaret(),s.prepend(n)),this.caret.setAtStart(n.get())}s.addClass(this.activeClass)},clearActive:function(){var t=this._find();t.removeClass(this.activeClass),t.find(".redactor-component-caret").remove(),this.app.broadcast("imageresizer.stop")},setOnEvent:function(t,e){this.clearActive();var i=this.inspector.parse(t.target);i.isFigcaption()||i.isComponentEditable()||i.isComponent()&&(this.setActive(t.target),e!==!0&&t.preventDefault())},executeScripts:function(t){if(void 0===t){var e=this.editor.getElement(),t=e.find("[data-redactor-type]").find("script").getAll();this.executeScripts.call(this,t)}else for(var i=0;i<t.length;i++)if(""!==t[i].src){var s=t[i].src;this.$doc.find('head script[src="'+s+'"]').remove();var n=l.dom("<script>");n.attr("src",s),n.attr("async defer"),n.get().onload=function(){s.search("instagram")!==-1&&window.instgrm.Embeds.process(),this.executeScripts(t.slice(i+1))}.bind(this);var r=document.getElementsByTagName("head")[0];r&&r.appendChild(n.get());break}},_find:function(){return this.editor.getElement().find("."+this.activeClass)},_buildCaret:function(){var t=l.dom("<span>");return t.addClass("redactor-component-caret"),t.attr("contenteditable",!0),t}}),l.add("service","insertion",{init:function(t){this.app=t},set:function(t,e,i){null===t&&(t=""),t=e!==!1?this.cleaner.input(t):t,t=e!==!1?this.cleaner.paragraphize(t):t;var s=this.editor.getElement();return s.html(t),i!==!1&&this.editor.endFocus(),t},insertNode:function(t,e){this.editor.focus();var i=this.utils.isFragment(t)?t:this.utils.createFragment(t);return this._collapseSelection(),this._insertFragment(i),this._setCaret(e,i),this._sendNodes(i.nodes)},insertBreakLine:function(){return this.insertNode(document.createElement("br"),"after")},insertNewline:function(){return this.insertNode(document.createTextNode("\n"),"after")},insertText:function(t){return this.insertHtml(this.cleaner.getFlatText(t))},insertChar:function(t){return this.insertNode(t,"after")},insertRaw:function(t){return this.insertHtml(t,!1)},insertToEnd:function(t,e){if(t){3===t.nodeType&&t.nodeValue.search(/^\n/)!==-1&&(t=t.previousElementSibling);var i=l.dom(t);if(i.attr("data-redactor-type")===e){var s=this.opts.breakline?"<br>":"<p>",n=l.dom(s);i.after(n),this.caret.setStart(n)}}},insertPoint:function(t){var e,i,s=this.marker.build("start"),n=!1,r=t.clientX,o=t.clientY;if(document.caretPositionFromPoint){var a=document.caretPositionFromPoint(r,o),l=document.getSelection();i=this.inspector.parse(a.offsetNode),i.isInEditor()&&(e=l.getRangeAt(0),e.setStart(a.offsetNode,a.offset),e.collapse(!0),e.insertNode(s),n=!0)}else document.caretRangeFromPoint&&(e=document.caretRangeFromPoint(r,o),i=this.inspector.parse(e.startContainer),i.isInEditor()&&(e.insertNode(s),n=!0));return n},insertToPoint:function(t,e,i,s){var n=i===!0||this.insertPoint(t);if(!n){var r=this.editor.getLastNode();l.dom(r).after(this.marker.build("start"))}return this.component.clearActive(),this.selection.restoreMarkers(),this.insertHtml(e,s)},insertToOffset:function(t,e){return this.offset.set({start:t,end:t}),this.insertHtml(e)},insertHtml:function(t,e){if(this.opts.input){var i=this.utils.parseHtml(t);if(this.selection.isAll())return this._insertToAllSelected(i);if(!this.selection.is()){var s=l.dom("<p>"),n=this.editor.getElement();n.append(s),this.caret.setStart(s)}var r=this.selection.isCollapsed(),o=this.selection.isText(),a=this.selection.getCurrent(),h=this.selection.getBlock(),c=this.inspector.parse(a);this._collapseSelection(),i=this._getCleanedInput(i,c,e);var d,u,p=this._isFigure(i.html),f=this._isComponentSpan(i.html),m=this.inspector.isText(i.html);if(this.editor.isEmpty())return this._insertToEmptyEditor(i.html);if(c.isComponent()&&!c.isComponentEditable())return this._insertToWidget(a,c,i.html);if(f)return this.insertNode(i.nodes,"end");if(p&&!o&&!c.isList())return c.isInline()?this._insertToInline(a,i):(d=this.utils.createFragment(i.html),this.utils.splitNode(a,d),this.caret.setEnd(d.last),this._sendNodes(d.nodes));if(c.isCode())return this._insertToCode(i,a,e);if(c.isPre())return this._insertToPre(i,e);if(c.isHeading()||c.isFigcaption())return i.html=e!==!1?this.cleaner.removeTagsExcept(i.html,["a"]):i.html,i.html=e!==!1?this.cleaner.replaceNbspToSpaces(i.html):i.html,d=this.utils.createFragment(i.html),this.insertNode(d,"end");if(this.opts.breakline&&h&&"DIV"===h.tagName){if(this._isPlainHtml(i.html))return this.insertNode(i.nodes,"end");i.html=e!==!1?this.cleaner.paragraphize(i.html):i.html,d=this.utils.createFragment(i.html);var g=this.selection.getRange();return g&&!this.selection.isCollapsed()&&g.deleteContents(),this.utils.splitNode(a,d),this.caret.setEnd(d.last),this._sendNodes(d.nodes)}if(m)return!o&&"br"!==this.opts.markup&&this._hasBlocksAndImages(i.nodes)?(i.html=e!==!1?this.cleaner.paragraphize(i.html):i.html,d=this.utils.createFragment(i.html),this.utils.splitNode(a,d),this.caret.setEnd(d.last),this._sendNodes(d.nodes)):(i.html=e!==!1?i.html.replace(/\n/g,"<br>"):i.html,d=this.utils.createFragment(i.html),this.insertNode(d.nodes,"end"));if(!r&&!p)return this._isPlainHtml(i.html)?this.insertNode(i.nodes,"end"):(i.html=e!==!1?this.cleaner.paragraphize(i.html):i.html,d=this.utils.createFragment(i.html),this.insertNode(d,"end"));if(c.isInline()&&!this._isPlainHtml(i.html))return this._insertToInline(a,i);if(c.isBlockquote()||c.isDl())return u=this.opts.inlineTags,u.concat(["br"]),i.html=e!==!1?this.cleaner.replaceBlocksToBr(i.html):i.html,i.html=e!==!1?this.cleaner.removeTagsExcept(i.html,u):i.html,d=this.utils.createFragment(i.html),this.insertNode(d,"end");if(c.isParagraph())return this._isPlainHtml(i.html)?this.insertNode(i.nodes,"end"):(i.html=e!==!1?this.cleaner.paragraphize(i.html):i.html,d=this.utils.createFragment(i.html),this.utils.splitNode(a,d),this.caret.setEnd(d.last),this._sendNodes(d.nodes));if(c.isList()&&(u=this.opts.inlineTags,u=u.concat(["br","li","ul","ol","img"]),i.html=e!==!1?this.cleaner.replaceBlocksToBr(i.html):i.html,i.html=e!==!1?this.cleaner.removeTagsExcept(i.html,u):i.html,i.html=e!==!1?this.cleaner.removeBrAtEnd(i.html):i.html,d=this.utils.createFragment(i.html),i.nodes=d.nodes,this._containsTags(i.html,["ul","ol","li"]))){var v=this.selection.getElement(a);if(v&&"LI"===v.tagName&&this.caret.isStart(v)){i.nodes=l.dom(d.nodes).unwrap("ul, ol").getAll(),l.dom(v).before(i.nodes);var b=i.nodes[i.nodes.length-1];return this.caret.setEnd(b),this._sendNodes(i.nodes)}return this._isPlainHtml(i.html)?this.insertNode(d,"end"):(d=this._buildList(i,v,d),this.utils.splitNode(a,d,!0),this.caret.setEnd(d.last),this._sendNodes(d.nodes))}return this.insertNode(i.nodes,"end")}},_insertToAllSelected:function(t){var e=this.set(t.html),i=this.utils.parseHtml(e);return this._sendNodes(i.nodes)},_insertToEmptyEditor:function(t){t=this.cleaner.paragraphize(t);var e=this.utils.createFragment(t),i=this.editor.getElement();return i.html(""),i.append(e.frag),this.caret.setEnd(e.last),this._sendNodes(e.nodes)},_insertToInline:function(t,e){var i=this.utils.createFragment(e.html);return this.utils.splitNode(t,i,!1,!0),this.caret.setEnd(i.last),this._sendNodes(i.nodes)},_insertToCode:function(t,e,i){t.html=i!==!1?this.cleaner.encodeHtml(t.html):t.html,t.html=i!==!1?this.cleaner.removeNl(t.html):t.html;var s=this.utils.createFragment(t.html),n=this.insertNode(s,"end");return this.utils.normalizeTextNodes(e),n},_insertToPre:function(t,e){t.html=e!==!1?this.cleaner.encodeHtml(t.html):t.html;var i=this.utils.createFragment(t.html);return this.insertNode(i,"end")},_insertToWidget:function(t,e,i){i=this._isComponentSpan(i)?i:this.cleaner.paragraphize(i);var s=this.utils.createFragment(i),n=e.getComponent(),r=l.dom(n);return r.after(s.frag),r.remove(),this.caret.setEnd(s.last),this._sendNodes(s.nodes)},_insertFragment:function(t){var e=this.selection.getRange();if(e){if(this.selection.isCollapsed()){var i=e.startContainer;3!==i.nodeType&&"BR"===i.tagName&&(this.caret.setAfter(i),i.parentNode.removeChild(i))}else e.deleteContents();e.insertNode(t.frag)}},_sendNodes:function(t){for(var e=0;e<t.length;e++){var i=t[e],s=3!==i.nodeType&&"function"==typeof i.getAttribute&&i.getAttribute("data-redactor-type");s&&this.app.broadcast(s+".inserted",this.component.build(i))}return this.detector.isIe()&&this.editor.getElement().find("[data-redactor-type=table]").attr("contenteditable",!0),this.app.broadcast("inserted",t),this.component.executeScripts(),t},_setCaret:function(t,e){var i=this._isLastInline(e);t?(t=i&&"end"===t?"after":t,this.caret["set"+this.utils.ucfirst(t)](e.last)):t!==!1&&i&&this.caret.setAfter(e.last)},_isLastInline:function(t){if(t.last){var e=this.inspector.parse(t.last);return e.isInline()}return!1},_getCleanedInput:function(t,e,i){var s=e.isCode()||e.isPre();return t.html=t.html.replace(/ /g," "),t.html=s||i===!1?t.html:this.cleaner.input(t.html),t=s||i===!1?t:this.utils.parseHtml(t.html)},_getContainer:function(t){return l.dom(this.utils.createTmpContainer(t))},_buildList:function(t,e,i){var s=t.nodes,n=s[0];if(n&&3!==n.nodeType&&"li"===n.tagName){var r=l.dom(e),o=r.get().tagName.toLowerCase(),a=l.dom("<"+o+" />");return a.append(i.nodes),this.utils.createFragment(a.get().outerHTML)}return i},_containsTags:function(t,e){return 0!==this._getContainer(t).find(e.join(",")).length},_collapseSelection:function(){},_hasFigureOrTable:function(t){return 0!==this._getContainer(t).find("figure, table").length},_hasBlocks:function(t){return 0!==this._getContainer(t).find(this.opts.blockTags.join(",")).length},_hasBlocksAndImages:function(t){return 0!==this._getContainer(t).find(this.opts.blockTags.join(",")+",img").length},_isPlainHtml:function(t){return 0===this._getContainer(t).find(this.opts.blockTags.join(",")+", img").length},_isFigure:function(t){if(this._isHtmlString(t))return 0!==l.dom(t).closest("figure").length},_isComponentSpan:function(t){if(this._isHtmlString(t))return 0!==l.dom(t).closest("span.redactor-component").length},_isHtmlString:function(t){return!("string"==typeof t&&!/^\s*<(\w+|!)[^>]*>/.test(t))}}),l.add("service","block",{init:function(t){this.app=t,this.tags=["p","div","blockquote","pre","h1","h2","h3","h4","h5","h6"]},format:function(t){return this.params={args:!1},this.params.type=t.type?t.type:"set",this.params.tag="string"==typeof t?t:t.tag||this.opts.markup,this.params.tag=this.params.tag.toLowerCase(),this.params.args={"class":t["class"]||!1,style:t.style||!1,attr:t.attr||!1},t["class"]||t.style||t.attr||(this.params.args=!1),this._format()},add:function(t,e,i){return this._apply("add",t,e,!0,i)},set:function(t,e){return this._apply("set",t,e)},toggle:function(t,e){return this._apply("toggle",t,e)},remove:function(t,e){return this._apply("remove",t,e)},clearFormat:function(t){return this._clear(t,"all")},clearStyle:function(t){return this._clear(t,"style")},clearClass:function(t){return this._clear(t,"class")},clearAttr:function(t){return this._clear(t,"attr")},_format:function(){var t=[];this.collapsed=this.selection.isCollapsed(),this.selection.save();var e=(this.selection.getBlock(),this._getBlocks()),i=this._isToggleFormatType(e)?"toggle":"set",s=this._getReplacedTag(i);return t=this._replaceBlocks(e,s),t=this._buildNodes(t),this._restoreSelection(t),t},_clear:function(t,e,i,s){i!==!1&&this.selection.save();var n=this._getElements(t,s);return"all"===e?this._removeAllAttr(n,!1):"style"===e?(n.removeAttr("style"),n.removeAttr("data-redactor-style-cache")):"class"===e?n.removeAttr("class"):"attr"===e&&this._removeAllAttr(n),s=n.getAll(),i!==!1&&this._restoreSelection(s),s},_getElements:function(t,e){return e?l.dom(e):l.dom(this._getBlocks(t))},_getBlocks:function(t){for(var e=this.selection.getBlocks({tags:t||this.tags}),i=[],s=0;s<e.length;s++)("DIV"!==e[s].tagName||e[s].getAttribute("data-redactor-tag"))&&i.push(e[s]);return i},_getReplacedTag:function(t){return this.opts.breakline?"toggle"===t?"div":"p"===this.params.tag?"div":this.params.tag:"toggle"===t?this.opts.markup:this.params.tag},_isStandardParagraph:function(){return!this.opts.breakline&&"p"===this.opts.markup},_isStandardDiv:function(){return!this.opts.breakline&&"div"===this.opts.markup},_isBreaklineBlock:function(t){return t&&"DIV"===t.tagName&&"br"===t.getAttribute("data-redactor-tag")},_isToggleFormatType:function(t){for(var e=0,i=t.length,s=0;s<i;s++)t[s]&&this.params.tag===t[s].tagName.toLowerCase()&&e++;return e===i},_isCurrentBlockOneAndEmpty:function(t){return this.collapsed&&1===t.length&&this.utils.isEmpty(t[0])},_buildNodes:function(t){return t.length>0&&(t=this._applyArgs(t,!1),t=this._combinePre(t),t=this._cleanBlocks(t)),t},_replaceBlocks:function(t,e){for(var i=[],s=0;s<t.length;s++){var n=this.utils.replaceToTag(t[s],e);i.push(n.get())}return i},_combinePre:function(t){for(var e=[],i=0;i<t.length;i++){var s=t[i].nextElementSibling;if(s&&"PRE"===t[i].tagName&&"PRE"===s.tagName){var n=l.dom(t[i]),r=l.dom(s),o=document.createTextNode("\n");n.append(o),n.append(r),r.unwrap("pre")}e.push(t[i])}return e},_cleanBlocks:function(t){for(var e=["h1","h2","h3","h4","h5","h6"],i=this.opts.inlineTags,s=0;s<t.length;s++){var n=t[s].tagName.toLowerCase(),r=l.dom(t[s]);e.indexOf(n)!==-1?r.find("span").not(".redactor-component, .non-editable, .redactor-selection-marker").unwrap():"pre"===n&&r.find(i.join(",")).not(".redactor-selection-marker").unwrap(),this.params.args===!1&&"p"===this.params.tag&&r.removeAttr("class"),this.opts.breakline&&"div"===n?r.attr("data-redactor-tag","br"):r.removeAttr("data-redactor-tag"),this.utils.normalizeTextNodes(t[s])}return t},_cleanEmptyClass:function(t){t.each(function(t){""===t.className&&t.removeAttribute("class")})},_cleanEmptyStyle:function(t){this.utils.removeEmptyAttr(t.get(),"style")?t.removeAttr("data-redactor-style-cache"):t.attr("data-redactor-style-cache",t.attr("style"))},_apply:function(t,e,i,s,n){s!==!1&&this.selection.save();var r=this._getElements(i,n);if(e["class"]&&("set"===t?(r.removeAttr("class"),r.addClass(e["class"])):"add"===t?r.addClass(e["class"]):"toggle"===t?r.toggleClass(e["class"]):"remove"===t&&r.removeClass(e["class"]),this._cleanEmptyClass(r)),e.attr&&("set"===t?(this._removeAllAttr(r),r.attr(e.attr)):"add"===t?r.attr(e.attr):"toggle"===t?(o=e.attr,r.each(function(t){var e=l.dom(t);for(var i in o)e.attr(i)?e.removeAttr(i):e.attr(i,o[i])})):"remove"===t&&r.removeAttr(e.attr)),e.style)if("set"===t)r.removeAttr("style"),r.css(e.style),r.each(function(t){var e=l.dom(t);e.attr("data-redactor-style-cache",e.attr("style"))});else if("add"===t){var o=e.style;r.each(function(t){var e=l.dom(t);e.css(o),e.attr("data-redactor-style-cache",e.attr("style")),this._convertStyleQuotes(e)}.bind(this))}else if("toggle"===t){var o=e.style;r.each(function(t){var e=l.dom(t);for(var i in o){var s=o[i],n=e.css(i);n=this.utils.isRgb(n)?this.utils.rgb2hex(n):n.replace(/"/g,""),s=this.utils.isRgb(s)?this.utils.rgb2hex(s):s.replace(/"/g,""),n=this.utils.hex2long(n),s=this.utils.hex2long(s);var r="string"==typeof s?s.toLowerCase():s,a="string"==typeof n?n.toLowerCase():n;r===a?e.css(i,""):e.css(i,s)}this._convertStyleQuotes(e),this._cleanEmptyStyle(e)}.bind(this))}else if("remove"===t){var a=e.style;r.each(function(t){var e=l.dom(t);e.css(a,""),this._cleanEmptyStyle(e)}.bind(this))}return n=r.getAll(),s!==!1&&this._restoreSelection(n),n},_applyArgs:function(t){return t=this.params.args?this._apply(this.params.type,this.params.args,!1,!1,t):this._clear(!1,"all",!1,t)},_removeAllAttr:function(t,e){ t.each(function(t){var i=["data-redactor-tag","data-redactor-style-cache"];e===!1&&(i.push("style"),i.push("class"));for(var s=t.attributes.length;s-- >0;){var n=t.attributes[s],r=n.name;i.indexOf(r)===-1&&t.removeAttributeNode(n)}})},_restoreSelection:function(t){this._isCurrentBlockOneAndEmpty(t)?this.caret.setStart(t[0]):setTimeout(function(){this.selection.restore()}.bind(this),1)},_convertStyleQuotes:function(t){var e=t.attr("style");e&&t.attr("style",e.replace(/"/g,"'"))}}),l.add("service","inline",{mixins:["formatter"],init:function(t){this.app=t,this.count=0},format:function(t){if(!this._isFormat())return[];this.type=t.type?t.type:"set",this.tag="string"==typeof t?t:t.tag,this.tag=this.tag.toLowerCase(),this.tag=this.arrangeTag(this.tag),"string"==typeof t?this.args=!1:this.buildArgs(t),this.detector.isIe()||this.editor.disableNonEditables();var e=this.selection.isCollapsed()?this.formatCollapsed():this.formatUncollapsed();return this.detector.isIe()||this.editor.enableNonEditables(),e},_isFormat:function(){var t=this.selection.getCurrent(),e=this.inspector.parse(t),i=e.isComponent()&&!e.isComponentType("table")&&!e.isFigcaption();return!(t!==!1||!this.selection.isAll())||!(!t||e.isPre()||e.isCode()||i)},arrangeTag:function(t){var e=this.opts.replaceTags;for(var i in e)t===i&&(t=e[i]);return t},formatCollapsed:function(){var t,e,i,s,n=[],r=this.selection.getInlineFirst(),o=this.selection.getInlines({all:!0}),a=l.dom(r);if(r){var h=this.inspector.parse(r),c=this.utils.isEmptyHtml(r.innerHTML);if(c)if(r.tagName.toLowerCase()===this.tag)if(this.hasSameArgs(r)){this.caret.setAfter(r),a.remove();var d=this.selection.getElement();this.utils.normalizeTextNodes(d)}else"span"===this.tag?(n=this.applyArgs([r],!1),this.caret.setStart(r)):n=this.insertInline(n);else h.hasParent([this.tag])?(t=a.closest(this.tag),e=t.get(),this.hasSameArgs(e)?(t.unwrap(),this.caret.setStart(r)):n=this.insertInline(n)):n=this.insertInline(n);else if(r.tagName.toLowerCase()===this.tag)this.hasSameArgs(r)?(s=this.utils.extractHtmlFromCaret(r),i=l.dom("<"+this.tag+" />"),i=this.utils.cloneAttributes(r,i),a.after(i.append(s)),""===i.html().trim()&&i.remove(),this.caret.setAfter(r)):n=this.insertInline(n);else if(h.hasParent([this.tag]))if(t=a.closest(this.tag),e=t.get(),this.hasSameArgs(e)){s=this.utils.extractHtmlFromCaret(e,e),i=l.dom("<"+this.tag+" />"),i=this.utils.cloneAttributes(e,i);var u,p,f=0;o=o.reverse();for(var m=0;m<o.length;m++)o[m]!==e&&(p=l.dom("<"+o[m].tagName.toLowerCase()+">"),0===f?u=p:u.append(p),f++);t.after(i.append(s)),t.after(u),this.caret.setStart(p)}else n=this.insertInline(n);else n=this.insertInline(n)}else n=this.insertInline(n);return n},insertInline:function(t){var e=document.createElement(this.tag);return t=this.insertion.insertNode(e,"start"),this.applyArgs(t,!1)},hasSameArgs:function(t){if(0===t.attributes.length&&this.args===!1)return!0;var e=!0;if(this.args){var i=0;for(var s in this.args){var n=l.dom(t),r=this.args[s],o=this.utils.toParams(r),a=n.attr(s);if(r)if("style"===s){o=o.trim().replace(/;$/,"");for(var h=this.utils.styleToObj(n.attr("style")),c=o.split(";"),d=0,u=0;u<c.length;u++){var p=c[u].split(":"),f=p[0].trim(),m=p[1].trim();if(f.search(/color/)!==-1){var g=n.css(f);!g||g!==m&&this.utils.rgb2hex(g)!==m||d++}else n.css(f)===m&&d++}d===c.length&&Object.keys(h).length===c.length&&i++}else a===o&&i++;else a&&""!==a||i++}e=i===Object.keys(this.args).length}return e},formatUncollapsed:function(){var t=this.selection.getInlines({all:!0,inside:!0});this.detector.isIe()?this.selection.saveMarkers():this.selection.save(),this._convertTags("u"),this._convertTags("del"),this._convertToStrike(t),this.detector.isIe()?this.selection.restoreMarkers():this.selection.restore(),document.execCommand("strikethrough"),this._clearDecoration(),this.selection.save();var e=this._revertToInlines();e=this.applyArgs(e,!1);for(var i=0;i<e.length;i++){var s=e[i],n=s.tagName.toLowerCase(),r=s.attributes.length;n===this.tag&&0===r&&this.args&&(l.dom(s).unwrap(),e.splice(i,1))}return this.selection.restore(),this._clearEmptyStyle(),e=this._normalizeBlocks(e)},_convertTags:function(t){if(this.tag!==t){var e=this.editor.getElement();e.find(t).each(function(e){var i=this.utils.replaceToTag(e,"span");i.addClass("redactor-convertable-"+t)}.bind(this))}},_revertTags:function(t){var e=this.editor.getElement();e.find("span.redactor-convertable-"+t).each(function(e){var i=this.utils.replaceToTag(e,t);i.removeClass("redactor-convertable-"+t),this.utils.removeEmptyAttr(i,"class")&&i.removeAttr("class")}.bind(this))},_convertToStrike:function(t){for(var e=this.selection.getText().replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&"),i=0;i<t.length;i++){var s=this.arrangeTag(t[i].tagName.toLowerCase()),n=t[i],r=l.dom(n),o=this.hasSameArgs(n);if(s===this.tag)if("span"===this.tag&&this._isTextSelected(n,e))r.addClass("redactor-convertable-apply");else if(o&&"a"!==this.tag)this._replaceToStrike(r);else if("span"===this.tag){if(this.args&&this.args.style)for(var a in this.args.style)r.css(a,"");this.utils.removeEmptyAttr(r.get(),"style")?r.addClass("redactor-convertable-apply"):r.addClass("redactor-unconvertable-apply")}else o||r.addClass("redactor-convertable-apply")}},_replaceToStrike:function(t){t.replaceWith(function(){return l.dom("<strike>").append(t.contents())})},_revertToInlines:function(){var t=[],e=this.editor.getElement();return"u"!==this.tag&&e.find("u").unwrap(),e.find(".redactor-convertable-u").each(function(e){t.push(e)}),e.find(".redactor-convertable-apply").each(function(e){var i=l.dom(e);i.find("strike").unwrap(),this._forceRemoveClass(i,"redactor-convertable-apply"),t.push(e)}.bind(this)),e.find("span.redactor-unconvertable-apply").each(function(t){var e=l.dom(t);this._forceRemoveClass(e,"redactor-unconvertable-apply")}.bind(this)),e.find("strike").each(function(e){var i=this.utils.replaceToTag(e,this.tag);t.push(i.get())}.bind(this)),this._revertTags("u"),this._revertTags("del"),t},_normalizeBlocks:function(t){var e=this.opts.inlineTags,i=this.selection.getBlocks();if(i)for(var s=0;s<i.length;s++)if("PRE"===i[s].tagName){var n=l.dom(i[s]);n.find(e.join(",")).not(".redactor-selection-marker").each(function(e){t.indexOf(e)!==-1&&(t=this.utils.removeFromArrayByValue(t,e)),l.dom(e).unwrap()}.bind(this))}return t},_clearDecoration:function(){var t=this.editor.getElement();t.find(this.opts.inlineTags.join(",")).each(function(t){if("line-through"===t.style.textDecoration||"line-through"===t.style.textDecorationLine){var e=l.dom(t);e.css("textDecorationLine",""),e.css("textDecoration",""),e.wrap("<strike>")}})},_clearEmptyStyle:function(){for(var t=this.getInlines(),e=0;e<t.length;e++){this._clearEmptyStyleAttr(t[e]);var i=t[e].childNodes;if(i)for(var s=0;s<i.length;s++)this._clearEmptyStyleAttr(i[s])}},_clearEmptyStyleAttr:function(t){3!==t.nodeType&&this.utils.removeEmptyAttr(t,"style")&&(t.removeAttribute("style"),t.removeAttribute("data-redactor-style-cache"))},_forceRemoveClass:function(t,e){t.removeClass(e),this.utils.removeEmptyAttr(t,"class")&&t.removeAttr("class")},_isTextSelected:function(t,e){var i=this.utils.removeInvisibleChars(t.textContent);return e===i||e.search(new RegExp("^"+this.utils.escapeRegExp(i)+"$"))!==-1},getInlines:function(t){return t?this.selection.getInlines({tags:t,all:!0}):this.selection.getInlines({all:!0})},getElements:function(t){return l.dom(this.getInlines(t))},clearFormat:function(){this.selection.save();for(var t=this.selection.getInlines({all:!0}),e=0;e<t.length;e++){var i=l.dom(t[e]),s=this.selection.getInline(t[e]);s&&i.unwrap()}this.selection.restore()}}),l.add("service","autoparser",{init:function(t){this.app=t,this.cleaner=this.app.cleaner},observe:function(){var t=this.editor.getElement(),e=t.find(".redactor-autoparser-object").each(function(t){var e=l.dom(t);e.removeClass("redactor-autoparser-object"),""===e.attr("class")&&e.removeAttr("class")});e.length>0&&e.each(function(t){var e,i=!1,s=t.tagName;"A"===s?e="link":"IMG"===s?e="image":"IFRAME"===s&&(e="video"),e&&(i=l.create(e+".component",this.app,t),this.app.broadcast(e+".inserted",i),this.app.broadcast("autoparse",e,i))}.bind(this))},format:function(t,e){this._isKey(e)&&this._format(e===this.keycodes.ENTER)},parse:function(t){var e=["figure","html","form","pre","object","video","iframe","code","a","img"],i=[],s=0,n=[];t=this.cleaner.storeComments(t,n),t=this.cleaner.encodeCode(t),t=t.replace(/\$/g,"$"),t=t.replace(/&/g,"&");for(var r=0;r<e.length;r++){var o="img"===e[r]?"<"+e[r]+"[^>]*>":"<"+e[r]+"([\\w\\W]*?)</"+e[r]+">",a=t.match(new RegExp(o,"gi"));if(null!==a)for(var l=0;l<a.length;l++)t=t.replace(a[l],"#####replaceparse"+s+"#####"),i.push(a[l]),s++}if(this.opts.autoparseImages&&t.match(this.opts.regex.imageurl))for(var h=t.match(this.opts.regex.imageurl),r=0;r<h.length;r++)t=t.replace(h[r],'<img class="redactor-autoparser-object" src="'+h[r]+'">');if(this.opts.autoparseVideo&&(t.match(this.opts.regex.youtube)||t.match(this.opts.regex.vimeo))){var c,d,u='<iframe width="500" height="281" src="',p='" frameborder="0" allowfullscreen></iframe>',f=this.opts.autoparseHttps?"https:":"";t.match(this.opts.regex.youtube)?(c=f+"//www.youtube.com/embed/$1",d=this.opts.regex.youtube):t.match(this.opts.regex.vimeo)&&(c=f+"//player.vimeo.com/video/$2",d=this.opts.regex.vimeo);var m=this.component.create("video",u+c+p);t=t.replace(d,m.get().outerHTML)}for(var r=0;r<e.length;r++){var o="img"===e[r]?"<"+e[r]+"[^>]*>":"<"+e[r]+"([\\w\\W]*?)</"+e[r]+">",a=t.match(new RegExp(o,"gi"));if(null!==a)for(var l=0;l<a.length;l++)t=t.replace(a[l],"#####replaceparse"+s+"#####"),i.push(a[l]),s++}return this.opts.autoparseLinks&&t.match(this.opts.regex.url)&&(t=this._formatLinks(t)),t=this._restoreReplaced(i,t),t=this._restoreReplaced(i,t),t=this.cleaner.restoreComments(t,n)},_isKey:function(t){return t===this.keycodes.ENTER||t===this.keycodes.SPACE},_format:function(t){var e=this.selection.getParent(),i=l.dom(e),s=e&&0!==i.closest("figure, pre, code, img, a, iframe").length;if(!s&&this.selection.isCollapsed()){var n=this.utils.createInvisibleChar(),r=this.selection.getRange();r.insertNode(n);var o=this.selection.getCurrent(),a=this.inspector.parse(o),h=l.dom(o);if(n.parentNode.removeChild(n),o&&3===o.nodeType){var c,d=o.textContent;if(this.opts.autoparseImages&&d.match(this._convertToRegExp(this.opts.regex.imageurl))){var u=a.isList(),p=d.match(this.opts.regex.imageurl),f=u?void 0:"<figure><img></figure>",m=this.component.create("image",f);m.setSrc(p[0]),m.addClass("redactor-autoparser-object"),d=d.replace(p[0],m.get().outerHTML),c="image"}else if(this.opts.autoparseVideo&&(d.match(this._convertToRegExp(this.opts.regex.youtube))||d.match(this._convertToRegExp(this.opts.regex.vimeo)))){var g,v,b='<iframe width="500" height="281" src="',_='" frameborder="0" allowfullscreen></iframe>';d.match(this.opts.regex.youtube)?(g="//www.youtube.com/embed/$1",v=this.opts.regex.youtube):d.match(this.opts.regex.vimeo)&&(g="//player.vimeo.com/video/$2",v=this.opts.regex.vimeo);var y=this.component.create("video",b+g+_);y.addClass("redactor-autoparser-object"),d=d.replace(v,y.get().outerHTML),c="video"}else this.opts.autoparseLinks&&d.match(this._convertToRegExp(this.opts.regex.url))&&(d=this._formatLinks(d,t),c="link");if(c){t?(this.selection.save(),h.replaceWith(d),this.selection.restore()):h.replaceWith(d);var C=this.editor.getElement(),x=C.find(".redactor-autoparser-object").removeClass("redactor-autoparser-object");if(x="link"===c?l.create("link.component",this.app,x):x,"link"===c)t||this.caret.setAfter(x),this.app.broadcast("link.inserted",x);else{this.caret.setAfter(x);var k=x.clone();x.remove(),x=this.insertion.insertHtml(k),x=this.component.build(x)}this.app.broadcast("autoparse",c,x)}}}},_formatLinks:function(t){var e=this.opts.pasteLinkTarget!==!1?' target="'+this.opts.pasteLinkTarget+'"':"",i="http",s=' class="redactor-autoparser-object"',n=this;return t=t.replace(this.opts.regex.aurl1,function(t){return'<a href="'+t+'"'+e+s+">"+n._subLinkText(t)+"</a>"}),t=t.replace(this.opts.regex.aurl2,function(t,r,o){return r+'<a href="'+i+"://"+o+'"'+e+s+">"+n._subLinkText(o)+"</a>"})},_subLinkText:function(t){return t=t.length>this.opts.linkSize?t.substring(0,this.opts.linkSize)+"...":t,t=t.search("%")===-1?decodeURIComponent(t):t},_restoreReplaced:function(t,e){for(var i=0;i<t.length;i++)e=e.replace("#####replaceparse"+i+"#####",t[i]);return e},_convertToRegExp:function(t){return new RegExp(String(t).replace(/^\//,"").replace(/\/ig$/,"").replace(/\/gi$/,"")+"$","gi")}}),l.add("service","storage",{init:function(t){this.app=t,this.data=[]},observeImages:function(){if(this.opts.imageObserve){var t=this.editor.getElement(),e=t.find("[data-image]");e.each(this._addImage.bind(this))}},observeFiles:function(){var t=this.editor.getElement(),e=t.find("[data-file]");e.each(this._addFile.bind(this))},setStatus:function(t,e){this.data[t].status=e},getChanges:function(){var t=this.editor.getElement();for(var e in this.data){var i=this.data[e],s=t.find("[data-"+i.type+'="'+i.id+'"]');this.setStatus(i.id,0!==s.length)}return this.data},add:function(t,e){var i=l.dom(e),s=i.attr("data-"+t);this.data[s]={type:t,status:!0,node:i.get(),id:i.attr("data-"+t)}},_addImage:function(t){this.add("image",t)},_addFile:function(t){this.add("file",t)}}),l.add("service","utils",{init:function(t){this.app=t},isEmpty:function(t){var e=!1;return t=l.dom(t).get(),t&&(e=3===t.nodeType?""===t.textContent.trim().replace(/\n/,""):""===t.innerHTML),e},isEmptyHtml:function(t,e,i){return t=this.removeInvisibleChars(t),t=t.replace(/ /gi,""),t=t.replace(/<\/?br\s?\/?>/g,e?"br":""),t=t.replace(/\s/g,""),t=t.replace(/^<p>[^\W\w\D\d]*?<\/p>$/i,""),t=t.replace(/^<div>[^\W\w\D\d]*?<\/div>$/i,""),i&&(t=t.replace(/<ul(.*?[^>])>$/i,"ul"),t=t.replace(/<ol(.*?[^>])>$/i,"ol")),t=t.replace(/<hr(.*?[^>])>$/i,"hr"),t=t.replace(/<iframe(.*?[^>])>$/i,"iframe"),t=t.replace(/<source(.*?[^>])>$/i,"source"),t=t.replace(/<[^\/>][^>]*><\/[^>]+>/gi,""),t=t.replace(/<[^\/>][^>]*><\/[^>]+>/gi,""),t=t.trim(),""===t},trimSpaces:function(t){return t=this.removeInvisibleChars(t.trim())},createInvisibleChar:function(){return document.createTextNode(this.opts.markerChar)},searchInvisibleChars:function(t){return t.search(/^\uFEFF$/g)},removeInvisibleChars:function(t){return t.replace(/\uFEFF/g,"")},trimInvisibleChars:function(t){if(this.selection.isCollapsed()){var e=this.selection.getCurrent(),i="left"===t?this.selection.getTextBeforeCaret():this.selection.getTextAfterCaret(),s=e&&3===e.nodeType&&0===this.searchInvisibleChars(i);if(s)if("left"===t)l.dom(e).replaceWith(e.textContent.trim());else{var n=this.offset.get();this.offset.set({start:n.start+1,end:n.end+1})}}},buildWrapper:function(t){return l.dom("<div>").html(t)},getWrapperHtml:function(t){var e=t.html();return t.remove(),e},createTmpContainer:function(t){var e=l.dom("<div>");return"string"==typeof t?e.html(t):e.append(l.dom(t).clone(!0)),e.get()},createFragment:function(t){for(var e,i,s,n=this.createTmpContainer(t),r=document.createDocumentFragment(),o=[],a=0;e=n.firstChild;){a++;var l=r.appendChild(e);1===a&&(i=l),o.push(l),s=l}return{frag:r,first:i,last:s,nodes:o}},isFragment:function(t){return"object"==typeof t&&t.frag},parseHtml:function(t){var e=this.createTmpContainer(t);return{html:e.innerHTML,nodes:e.childNodes}},splitNode:function(t,e,i,s){e=this.isFragment(e)?e.frag:e;var n;n=s?this.inspector.isInlineTag(t.tagName)?t:this.selection.getInline(t):this.inspector.isBlockTag(t.tagName)?t:this.selection.getBlock(t);var r=l.dom(n);if(!s&&this.isEmptyHtml(n.innerHTML,!0))return r.after(e),r.remove(),e;var o=r.get().tagName.toLowerCase(),a=this.caret.isEnd(n),h=this.caret.isStart(n);if(!a&&!h){var c=this.extractHtmlFromCaret(s),d=l.dom("<"+o+" />");d=this.cloneAttributes(n,d),r.after(d.append(c))}if(h)return r.before(e);if(i)return r.append(e);e=r.after(e);var u=r.html();return u=this.removeInvisibleChars(u),u=u.replace(/ /gi,""),""===u&&r.remove(),e},extractHtmlFromCaret:function(t,e){var i=this.selection.getRange();if(i&&(e=e?e:t?this.selection.getInline():this.selection.getBlock())){var s=i.cloneRange();return s.selectNodeContents(e),s.setStart(i.endContainer,i.endOffset),s.extractContents()}},createMarkup:function(t){var e=document.createElement(this.opts.markup);this.opts.breakline&&e.setAttribute("data-redactor-tag","br");var i=l.dom(t);i.after(e),this.caret.setStart(e)},createMarkupBefore:function(t){var e=document.createElement(this.opts.markup);this.opts.breakline&&e.setAttribute("data-redactor-tag","br");var i=l.dom(t);i.before(e),this.caret.setEnd(e)},getNode:function(t){var e=l.dom(t).get(),i=this.editor.getElement().get();return"undefined"==typeof t?i:!!e&&e},findSiblings:function(t,e){for(t=l.dom(t).get(),e="next"===e?"nextSibling":"previousSibling";t=t[e];)if((3!==t.nodeType||""!==t.textContent.trim())&&"BR"!==t.tagName)return t;return!1},getElementsFromHtml:function(t,e,i){var s=document.createElement("div");s.innerHTML=t;var n=s.querySelectorAll(e),r=function(t,e){if("number"==typeof this.length&&"function"==typeof t){var i=[];if("object"==typeof this)for(var s=0;s<this.length;s++){if(!(s in this))return;i[s]=t.call(e||this,this[s],s,this)}return i}};return r.call(n,function(t){var e=t.getAttribute("data-redactor-type");if(!i||!e||e!==i)return t.outerHTML})},getChildNodes:function(t,e,i){t=t&&t.nodeType&&11===t.nodeType?t:l.dom(t).get();var s=t.childNodes,n=[];if(s)for(var r=0;r<s.length;r++)if(!(i===!0&&3===s[r].nodeType||3===s[r].nodeType&&this.isEmpty(s[r])||(n.push(s[r]),e===!1))){var o=this.getChildNodes(s[r],i);o.length>0&&(n=n.concat(o))}return n},getChildElements:function(t){return this.getChildNodes(t,!0,!0)},getFirstNode:function(t){return this._getFirst(this.getChildNodes(t,!1))},getLastNode:function(t){return this._getLast(this.getChildNodes(t,!1))},getFirstElement:function(t){return this._getFirst(this.getChildNodes(t,!1,!0))},getLastElement:function(t){return this._getLast(this.getChildNodes(t,!1,!0))},replaceToTag:function(t,e){var i=l.dom(t);return i.replaceWith(function(t){var i=l.dom("<"+e+">").append(l.dom(t).contents());if(t.attributes)for(var s=t.attributes,n=0;n<s.length;n++)i.attr(s[n].nodeName,s[n].value);return i})},ucfirst:function(t){return t.charAt(0).toUpperCase()+t.slice(1)},removeFromArrayByValue:function(t,e){for(var i,s=arguments,n=s.length;n>1&&t.length;)for(e=s[--n];(i=t.indexOf(e))!==-1;)t.splice(i,1);return t},removeEmptyAttr:function(t,e){var i=l.dom(t);return"undefined"==typeof i.attr(e)||null===i.attr(e)||""===i.attr(e)&&(i.removeAttr(e),!0)},cloneAttributes:function(t,e){t=l.dom(t).get(),e=l.dom(e);for(var i=t.attributes,s=i.length;s--;){var n=i[s];e.attr(n.name,n.value)}return e},toParams:function(t){if("object"!=typeof t)return t;var e=Object.keys(t);if(!e.length)return"";for(var i="",s=0;s<e.length;s++){var n=e[s];i+=n+":"+t[n]+";"}return i},styleToObj:function(t){var e={};if(t)for(var i=t.replace(/;$/,"").split(";"),s=0;s<i.length;s++){var n=i[s].split(":");e[n[0].trim()]=n[1].trim()}return e},checkProperty:function(t){for(var e=arguments[1]&&Array.isArray(arguments[1])?arguments[1]:[].slice.call(arguments,1),i=0;i<e.length;i++){if(!t||"undefined"==typeof t[e[i]])return!1;t=t[e[i]]}return t},extendData:function(t,e){for(var i in e)if("elements"===i){var s=l.dom(e[i]);s.each(function(e){var i=l.dom(e);if("FORM"===e.tagName){var s=i.serialize(!0);for(var n in s)t=this._setData(t,n,s[n])}else{var r=i.attr("name")?i.attr("name"):i.attr("id");t=this._setData(t,r,i.val())}}.bind(this))}else t=this._setData(t,i,e[i]);return t},_setData:function(t,e,i){return t instanceof FormData?t.append(e,i):t[e]=i,t},normalizeTextNodes:function(t){t=l.dom(t).get(),t&&t.normalize()},isRgb:function(t){return 0===t.search(/^rgb/i)},rgb2hex:function(t){return t=t.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i),t&&4===t.length?"#"+("0"+parseInt(t[1],10).toString(16)).slice(-2)+("0"+parseInt(t[2],10).toString(16)).slice(-2)+("0"+parseInt(t[3],10).toString(16)).slice(-2):""},hex2long:function(t){return t.search(/^#/)!==-1&&4===t.length&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]),t},escapeRegExp:function(t){return t.replace(/[-\/\\^$*~+?.()|[\]{}]/g,"\\$&")},getRandomId:function(){for(var t="",e="abcdefghijklmnopqrstuvwxyz0123456789",i=0;i<12;i++)t+=e.charAt(Math.floor(Math.random()*e.length));return t},_getFirst:function(t){return 0!==t.length&&t[0]},_getLast:function(t){return 0!==t.length&&t[t.length-1]}}),l.add("service","progress",{init:function(t){this.app=t,this.$box=null,this.$bar=null},show:function(){this._is()||this._build(),this.$box.show()},hide:function(){this._is()&&this.animate.start(this.$box,"fadeOut",this._destroy.bind(this))},update:function(t){this.show(),this.$bar.css("width",t+"%")},_is:function(){return null!==this.$box},_build:function(){this.$bar=l.dom("<span />"),this.$box=l.dom('<div id="redactor-progress" />'),this.$box.append(this.$bar),this.$body.append(this.$box)},_destroy:function(){this._is()&&this.$box.remove(),this.$box=null,this.$bar=null}}),l.add("module","starter",{init:function(t){this.app=t,this.opts=t.opts,this.plugin=t.plugin,this.module=t.module},onstart:function(){var t=["element","container","source","editor","statusbar","toolbar"],e=["element","container","source","editor","statusbar","contextbar","input"];this._startStop("start",this.app,t),this._startStop("start",this.module,e)},onstop:function(){var t=["observer","element","container","source","editor","contextbar"];this._startStop("stop",this.module,t)},onenable:function(){var t=["observer","toolbar"],e=this.opts.plugins;this._startStop("start",this.module,t),this._startStop("start",this.plugin,e)},ondisable:function(){var t=["observer","toolbar"],e=this.opts.plugins;this._startStop("stop",this.module,t),this._startStop("stop",this.plugin,e)},_startStop:function(t,e,i){for(var s=0;s<i.length;s++)"undefined"!=typeof e[i[s]]&&this.app.callInstanceMethod(e[i[s]],t)}}),l.add("module","element",{init:function(t){this.app=t,this.uuid=t.uuid,this.opts=t.opts,this.namespace=t.namespace,this.element=t.element,this.rootOpts=l.extend({},!0,l.options,t.rootOpts)},start:function(){this._build(),this._buildModes(),this._buildMarkup()},stop:function(){var t=this.element.getElement();t.removeData(this.namespace+"-uuid")},_build:function(){var t=this.element.getElement();t.data(this.namespace+"-uuid",this.uuid)},_buildModes:function(){var t=this.element.getType();"inline"===t&&this._redefineOptions(this.opts.modes.inline),"div"===t&&this._redefineOptions(this.opts.modes.original),"inline"!==t&&(this._isRootOption("styles")&&this.rootOpts.styles&&(this.opts.styles=!0),this._isRootOption("source")&&!this.rootOpts.source&&(this.opts.showSource=!1))},_buildMarkup:function(){var t=this.element.getType();"inline"===t?this.opts.emptyHtml="":this.opts.breakline?(this.opts.markup="div",this.opts.emptyHtml='<div data-redactor-tag="br">'+this.opts.markerChar+"</div>"):this.opts.emptyHtml="<"+this.opts.markup+"></"+this.opts.markup+">"},_redefineOptions:function(t){for(var e in t)this.opts[e]=t[e]},_isRootOption:function(){return"undefined"!=typeof this.rootOpts.styles}}),l.add("module","editor",{init:function(t){this.app=t,this.uuid=t.uuid,this.opts=t.opts,this.editor=t.editor,this.source=t.source,this.element=t.element,this.component=t.component,this.container=t.container,this.inspector=t.inspector,this.autoparser=t.autoparser,this.placeholder=!1,this.events=!1},onenable:function(){this.enable()},ondisable:function(){this.disable()},onenablefocus:function(){this._enableFocus()},oncontextmenu:function(t){this.component.setOnEvent(t,!0)},onclick:function(t){this.component.setOnEvent(t)},onkeyup:function(t){var e=this.inspector.parse(t.target);e.isComponent()||this.component.clearActive()},onenablereadonly:function(){this._enableReadOnly()},ondisablereadonly:function(){this._disableReadOnly()},onautoparseobserve:function(){this.autoparser.observe()},onplaceholder:{build:function(){this._buildPlaceholder()},toggle:function(){this._togglePlacehodler()}},start:function(){this._build(),this._buildEvents(),this._buildOptions(),this._buildAccesibility()},stop:function(){var t=this.editor.getElement(),e=this.container.getElement(),i=["redactor-in","redactor-in-"+this.uuid,"redactor-structure","redactor-placeholder","notranslate"];""!==this.opts.stylesClass&&i.push(this.opts.stylesClass);var s=["redactor-focus","redactor-blur","redactor-over","redactor-styles-on","redactor-styles-off","redactor-toolbar-on","redactor-text-labeled-on","redactor-source-view"];t.removeAttr("spellcheck"),t.removeAttr("dir"),t.removeAttr("contenteditable"),t.removeAttr("placeholder"),t.removeAttr("data-gramm_editor"),t.removeClass(i.join(" ")),e.removeClass(s.join(" ")),this._destroyEvents(),0===t.get().classList.length&&t.removeAttr("class")},enable:function(){var t=this.editor.getElement(),e=this.container.getElement();t.addClass("redactor-in redactor-in-"+this.uuid),t.attr({contenteditable:!0}),this.opts.structure&&t.addClass("redactor-structure"),!this.opts.toolbar||this.opts.air||this.opts.toolbarExternal||e.addClass("redactor-toolbar-on"),this._disableBrowsersEditing()},disable:function(){var t=this.editor.getElement(),e=this.container.getElement();t.removeClass("redactor-in redactor-in-"+this.uuid),t.removeClass("redactor-structure"),t.removeAttr("contenteditable"),e.addClass("redactor-toolbar-on")},_build:function(){var t=this.editor.getElement(),e=this.element.getElement(),i=this.container.getElement();i.addClass("redactor-blur"),this.opts.grammarly||t.attr("data-gramm_editor",!1),this.opts.notranslate&&t.addClass("notranslate"),this.opts.styles?(t.addClass(this.opts.stylesClass),i.addClass("redactor-styles-on")):i.addClass("redactor-styles-off"),this.opts.buttonsTextLabeled&&i.addClass("redactor-text-labeled-on"),this.element.isType("textarea")&&e.before(t)},_buildEvents:function(){this.events=l.create("editor.events",this.app)},_buildOptions:function(){var t=this.editor.getElement();t.attr("dir",this.opts.direction),this.opts.spellcheck||t.attr("spellcheck",!1),this.opts.tabindex&&t.attr("tabindex",this.opts.tabindex),this.opts.minHeight&&t.css("min-height",this.opts.minHeight),this.opts.maxHeight&&t.css("max-height",this.opts.maxHeight),this.opts.maxWidth&&t.css({"max-width":this.opts.maxWidth,margin:"auto"})},_buildAccesibility:function(){var t=this.editor.getElement();t.attr({"aria-labelledby":"redactor-voice-"+this.uuid,role:"presentation"})},_buildPlaceholder:function(){this.placeholder=l.create("editor.placeholder",this.app)},_enableFocus:function(){this.opts.showSource?this._enableFocusSource():this._enableFocusEditor()},_enableFocusSource:function(){var t=this.source.getElement();this.opts.focus?(t.focus(),t.get().setSelectionRange(0,0)):this.opts.focusEnd&&t.focus()},_enableFocusEditor:function(){this.opts.focus?setTimeout(this.editor.startFocus.bind(this.editor),100):this.opts.focusEnd&&setTimeout(this.editor.endFocus.bind(this.editor),100)},_togglePlacehodler:function(){this.placeholder&&this.placeholder.toggle()},_disableBrowsersEditing:function(){try{document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1),document.execCommand("AutoUrlDetect",!1,!1);var t=this.editor.getElement(),e=t.get();e.addEventListener?e.addEventListener("mscontrolselect",function(t){t.preventDefault()}):e.attachEvent("oncontrolselect",function(t){t.returnValue=!1})}catch(i){}},_destroyEvents:function(){this.events&&this.events.destroy()},_enableReadOnly:function(){var t=this.editor.getElement();this._getEditables(t).removeAttr("contenteditable"),t.removeAttr("contenteditable"),t.addClass("redactor-read-only"),this.events&&this.events.destroy()},_disableReadOnly:function(){var t=this.editor.getElement();this._getEditables(t).attr({contenteditable:!0}),t.removeClass("redactor-read-only"),t.attr({contenteditable:!0}),this._buildEvents()},_getEditables:function(t){return t.find("figcaption, td, th")}}),l.add("class","editor.placeholder",{init:function(t){this.app=t,this.opts=t.opts,this.editor=t.editor,this.element=t.element,this.build()},build:function(){var t=this.element.getElement(),e=this.editor.getElement();if(this.opts.placeholder!==!1||t.attr("placeholder")){var i=this.opts.placeholder!==!1?this.opts.placeholder:t.attr("placeholder");e.attr("placeholder",i),this.toggle()}},toggle:function(){return this.editor.isEmpty(!0)?this.show():this.hide()},show:function(){var t=this.editor.getElement();t.addClass("redactor-placeholder")},hide:function(){var t=this.editor.getElement();t.removeClass("redactor-placeholder")}}),l.add("class","editor.events",{init:function(t){this.app=t,this.opts=t.opts,this.$doc=t.$doc,this.uuid=t.uuid,this.source=t.source,this.editor=t.editor,this.cleaner=t.cleaner,this.container=t.container,this.insertion=t.insertion,this.inspector=t.inspector,this.selection=t.selection,this.component=t.component,this.blurNamespace=".redactor-blur."+this.uuid,this.eventsList=["paste","click","contextmenu","keydown","keyup","mouseup","touchstart","cut","copy","dragenter","dragstart","drop","dragover","dragleave"],this._init()},destroy:function(){var t=this.editor.getElement();t.off(".redactor-focus"),this.$doc.off("keyup"+this.blurNamespace+" mousedown"+this.blurNamespace),this._loop("off")},focus:function(t){var e=this.container.getElement();this.editor.isPasting()||e.hasClass("redactor-focus")||(e.addClass("redactor-focus"),e.removeClass("redactor-blur"),this.app.broadcast("observe",t),this.app.broadcast("focus",t),this.isFocused=!0,this.isBlured=!1)},blur:function(t){var e=this.container.getElement(),i=l.dom(t.target),s=[".redactor-in-"+this.uuid,".redactor-toolbar",".redactor-dropdown",".redactor-context-toolbar",".redactor-modal-box","#redactor-image-resizer"];this.app.broadcast("originalblur",t),this.app.stopBlur||this.app.isStarted()&&!this.editor.isPasting()&&0===i.closest(s.join(",")).length&&(this.isBlured||e.hasClass("redactor-blur")||(e.removeClass("redactor-focus"),e.addClass("redactor-blur"),this.app.broadcast("blur",t),this.isFocused=!1,this.isBlured=!0))},cut:function(t){var e=this.selection.getCurrent(),i=this.inspector.parse(e);this.app.broadcast("state",t),this.component.isNonEditable(e)&&(this._passSelectionToClipboard(t,i,!0),t.preventDefault())},copy:function(t){var e=this.selection.getCurrent(),i=this.inspector.parse(e);this.app.broadcast("state",t),this.component.isNonEditable(e)&&(this._passSelectionToClipboard(t,i,!1),t.preventDefault())},drop:function(t){if(t=t.originalEvent||t,t.stopPropagation(),this._removeOverClass(),this.opts.dragUpload===!1)return void t.preventDefault();if(this.app.isDragComponentInside()){var e=l.dom(this.app.getDragComponentInside()),i=e.clone(!0);return this.insertion.insertToPoint(t,i),e.remove(),this.app.setDragComponentInside(!1),this.app.broadcast("state",t),this.app.broadcast("drop",t),this.app.broadcast("image.observe",t),void t.preventDefault()}if(this.app.isDragInside()&&this.opts.input){this.insertion.insertPoint(t);var s=t.dataTransfer,n=s.getData("text/html"),r=this.selection.getRange();if(r){var o=this.selection.getBlocks();r.deleteContents();for(var a=0;a<o.length;a++)""===o[a].innerHTML&&l.dom(o[a]).remove()}return l.create("input.paste",this.app,t,!0,n,!0),this.app.broadcast("state",t),this.app.broadcast("drop",t),this.app.setDragInside(!1),void t.preventDefault()}this.app.broadcast("state",t),this.app.broadcast("paste",t,t.dataTransfer),this.app.broadcast("drop",t)},dragenter:function(t){t.preventDefault()},dragstart:function(t){this.app.setDragComponentInside(!1),this.app.setDragInside(!1);var e=this.inspector.parse(t.target);!e.isComponent()||e.isComponentEditable()||e.isFigcaption()?this.selection.is()&&!this.selection.isCollapsed()&&(this.app.setDragInside(!0),this._setDragData(t)):this.app.setDragComponentInside(e.getComponent()),this.app.broadcast("dragstart",t)},dragover:function(t){this.app.broadcast("dragover",t)},dragleave:function(t){ this.app.broadcast("dragleave",t)},paste:function(t){this.app.broadcast("paste",t)},contextmenu:function(t){},click:function(t){if(3===t.detail){t.preventDefault();var e=this.selection.getBlock();if(e){var i=document.createRange();i.selectNodeContents(e),this.selection.setRange(i)}}var s=l.dom(t.target);if(s.hasClass("redactor-in")){var n=s.offset().top,r=parseFloat(s.css("padding-bottom")),o=s.height(),a=n+o-2*r;a<t.pageY?this.app.broadcast("bottomclick",t):s.hasClass("redactor-placeholder")&&this.editor.startFocus(this.editor)}this.app.broadcast("state",t),this.app.broadcast("click",t)},keydown:function(t){this.app.broadcast("state",t);var e=this.app.broadcast("keydown",t);if(e===!1)return t.preventDefault()},keyup:function(t){this.app.broadcast("keyup",t)},mouseup:function(t){this.app.broadcast("observe",t),this.app.broadcast("state",t)},touchstart:function(t){this.app.broadcast("observe",t),this.app.broadcast("state",t)},_init:function(){var t=this.editor.getElement();t.on("focus.redactor-focus click.redactor-focus",this.focus.bind(this)),this.$doc.on("keyup"+this.blurNamespace+" mousedown"+this.blurNamespace,this.blur.bind(this)),this._loop("on")},_removeOverClass:function(){var t=this.editor.getElement();t.removeClass("over")},_loop:function(t){for(var e=this.editor.getElement(),i=0;i<this.eventsList.length;i++){var s=this.eventsList[i]+".redactor-events",n=this.eventsList[i];e[t](s,this[n].bind(this))}},_passAllToClipboard:function(t){var e=t.clipboardData,i=this.source.getCode();e.setData("text/html",i),e.setData("text/plain",i.toString().replace(/\n$/,""))},_passSelectionToClipboard:function(t,e,i){var s=t.clipboardData,n=e.getComponent(),r=l.dom(n),o=r.clone();o.find(".redactor-component-caret").remove(),o.removeClass("redactor-component-active"),o.removeAttr("contenteditable"),o.removeAttr("tabindex");var a=o.get().outerHTML;i&&this.component.remove(n),s.setData("text/html",a),s.setData("text/plain",a.toString().replace(/\n$/,""))},_setDragData:function(t){t=t.originalEvent||t;var e=t.dataTransfer;e.effectAllowed="move",e.setData("text/Html",this.selection.getHtml())}}),l.add("module","container",{init:function(t){this.app=t,this.uuid=t.uuid,this.opts=t.opts,this.lang=t.lang,this.element=t.element,this.container=t.container},start:function(){this._build(),this._buildAccesibility()},stop:function(){var t=this.element.getElement(),e=this.container.getElement();e.after(t),e.remove(),t.show()},_build:function(){var t=this.element.getElement(),e=this.container.getElement();e.addClass("redactor-box"),e.attr("dir",this.opts.direction),this.element.isType("inline")&&e.addClass("redactor-inline"),t.after(e),e.append(t)},_buildAccesibility:function(){var t=this.container.getElement(),e=l.dom("<span />");e.addClass("redactor-voice-label"),e.attr({id:"redactor-voice-"+this.uuid,"aria-hidden":!1}),e.html(this.lang.get("accessibility-help-label")),t.prepend(e)}}),l.add("module","source",{init:function(t){this.app=t,this.uuid=t.uuid,this.opts=t.opts,this.utils=t.utils,this.element=t.element,this.source=t.source,this.editor=t.editor,this.toolbar=t.toolbar,this.cleaner=t.cleaner,this.component=t.component,this.container=t.container,this.autoparser=t.autoparser,this.selection=t.selection,this.syncedHtml=""},onstartcode:function(){var t=this.source.getStartedContent(),e=this.editor.getElement(),i=this.source.getElement();this.opts.autoparse&&this.opts.autoparseStart&&(t=this.autoparser.parse(t));var s=this.cleaner.input(t,!0,!0),n=this.cleaner.output(s);e.html(s),i.val(n),this.syncedHtml=n,this.app.broadcast("placeholder.build"),this.app.broadcast("autoparseobserve"),this.component.executeScripts()},onstartcodeshow:function(){this.show()},ontrytosync:function(){this.sync()},onhardsync:function(){var t=this.editor.getElement(),e=t.html();e=this.app.broadcast("syncBefore",e),e=this.cleaner.output(e),this._syncing(e)},start:function(){this._build(),this._buildClasses()},stop:function(){var t=this.element.getElement(),e=this.source.getElement();t.removeClass("redactor-source redactor-source-open"),e.off("input.redactor-source"),e.removeAttr("data-gramm_editor"),0===e.get().classList.length&&e.removeAttr("class"),this.source.isNameGenerated()||t.removeAttr("name"),this.element.isType("textarea")||e.remove()},getCode:function(){return this.source.getCode()},toggle:function(){if(this.opts.source){var t=this.source.getElement();return t.hasClass("redactor-source-open")?this.hide():this.show()}},show:function(){if(this.opts.source){var t=this.editor.getElement(),e=this.source.getElement(),i=this.container.getElement(),s=e.val();this.app.isStarted()&&(s=this.app.broadcast("source.open",s));var n=t.height();if(t.hide(),e.height(n),e.val(s.trim()),e.show(),e.addClass("redactor-source-open"),e.on("input.redactor-source-events",this._onChangedSource.bind(this)),e.on("keydown.redactor-source-events",this._onTabKey.bind(this)),e.on("focus.redactor-source-events",this._onFocus.bind(this)),this.opts.source.hasOwnProperty("codemirror")){var r="object"==typeof this.opts.source.codemirror?this.opts.source.codemirror:{},o="undefined"!=typeof this.opts.source.codemirrorSrc?this.opts.source.codemirrorSrc:CodeMirror;this.codemirror=o.fromTextArea(e.get(),r),this.codemirror.setSize(null,n),this.codemirror.on("change",function(t,e){t.save()}),this.codemirror.on("change",this._onChangedSource.bind(this))}else i.addClass("redactor-source-view");setTimeout(function(){this._disableButtons(),this._setActiveSourceButton()}.bind(this),100),this.app.isStarted()&&this.app.broadcast("source.opened")}},hide:function(){if(this.opts.source){var t=this.editor.getElement(),e=this.source.getElement(),i=this.container.getElement(),s=e.val();this.opts.source.hasOwnProperty("codemirror")&&(s=this.codemirror.getValue(),this.codemirror.toTextArea()),s=this.cleaner.input(s,!0),s=this.utils.isEmptyHtml(s)?this.opts.emptyHtml:s,s=this.app.broadcast("source.close",s),this._enableButtons(),this._setInactiveSourceButton(),e.hide(),e.removeClass("redactor-source-open"),e.off(".redactor-source-events"),t.show(),t.html(s),i.removeClass("redactor-source-view"),setTimeout(function(){this.editor.startFocus(),this.component.executeScripts()}.bind(this),0),this.app.broadcast("source.closed")}},sync:function(){var t=this,e=this.editor.getElement(),i=e.html();i=this.app.broadcast("syncBefore",i),i=this.cleaner.output(i),this._isSync(i)&&(this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(function(){t._syncing(i)},200))},_build:function(){var t=this.source.getElement(),e=this.element.getElement();t.hide(),this.opts.grammarly||t.attr("data-gramm_editor",!1),this.element.isType("textarea")||e.after(t)},_buildClasses:function(){var t=this.source.getElement();t.addClass("redactor-source")},_syncing:function(t){t=this.app.broadcast("syncing",t);var e=this.source.getElement();e.val(t),this.app.broadcast("synced",t),this.app.broadcast("changed",t)},_isSync:function(t){return this.syncedHtml!==t&&(this.syncedHtml=t,!0)},_onChangedSource:function(){var t=this.source.getElement(),e=t.val();this.app.broadcast("changed",e),this.app.broadcast("source.changed",e)},_onTabKey:function(t){if(9!==t.keyCode)return!0;t.preventDefault();var e=this.source.getElement(),i=e.get(),s=i.selectionStart;e.val(e.val().substring(0,s)+" "+e.val().substring(i.selectionEnd)),i.selectionStart=i.selectionEnd=s+4},_onFocus:function(){this.app.broadcast("sourcefocus")},_disableButtons:function(){this.toolbar.disableButtons()},_enableButtons:function(){this.toolbar.enableButtons()},_setActiveSourceButton:function(){var t=this.toolbar.getButton("html");t.enable(),t.setActive()},_setInactiveSourceButton:function(){var t=this.toolbar.getButton("html");t.setInactive()}}),l.add("module","observer",{init:function(t){this.app=t,this.editor=t.editor,this.observerUnit=!1},start:function(){if(window.MutationObserver){var t=this.editor.getElement(),e=t.get();this.observerUnit=this._build(e),this.observerUnit.observe(e,{attributes:!0,subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0})}},stop:function(){this.observerUnit&&this.observerUnit.disconnect()},_build:function(t){var e=this;return new MutationObserver(function(i){e._observe(i[i.length-1],t)})},_observe:function(t,e){this.app.isReadOnly()||"attributes"===t.type&&t.target===e||(this.app.broadcast("observe"),this.app.broadcast("trytosync"),this.app.broadcast("placeholder.toggle"))}}),l.add("module","clicktoedit",{init:function(t){this.app=t,this.opts=t.opts,this.source=t.source,this.editor=t.editor,this.container=t.container,this.selection=t.selection},onstartclicktoedit:function(){this.start()},onenablereadonly:function(){this.opts.clickToEdit&&(this._isEnabled()||this.stop())},ondisablereadonly:function(){this.opts.clickToEdit&&(this._isEnabled()||this.start())},onstop:function(){this.stop()},start:function(){this._build()},stop:function(){this.buttonSave&&this.buttonSave.stop(),this.buttonCancel&&this.buttonCancel.stop(),this._destroy(),this.app.broadcast("disable")},enable:function(){this.app.broadcast("clickStart");var t=this.editor.isEmpty();t||this.selection.saveMarkers(),this._setFocus(),this._destroy(),this.app.broadcast("enable"),this.buttonSave.enable(),this.buttonCancel.enable(),t||this.selection.restoreMarkers(),t&&this.editor.focus();var e=this.container.getElement();e.addClass("redactor-clicktoedit-enabled"),this.source.rebuildStartedContent(),this.app.broadcast("startcode"),this.app.broadcast("image.observe")},save:function(t){t&&t.preventDefault();var e=this.source.getCode();this.app.broadcast("disable"),this.app.broadcast("clickSave",e),this.app.broadcast("clickStop"),this.app.broadcast("toolbar.removeexternal"),this._build()},cancel:function(t){t&&t.preventDefault();var e=this.saved,i=this.editor.getElement();i.html(e),this.saved="",this.app.broadcast("disable"),this.app.broadcast("clickCancel",e),this.app.broadcast("clickStop"),this.app.broadcast("toolbar.removeexternal"),this._build()},_build:function(){this.buttonSave=l.create("clicktoedit.button","save",this.app,this),this.buttonCancel=l.create("clicktoedit.button","cancel",this.app,this),this.buttonSave.stop(),this.buttonCancel.stop();var t=this.editor.getElement(),e=this.container.getElement();t.on("click.redactor-click-to-edit mouseup.redactor-click-to-edit",this.enable.bind(this)),e.addClass("redactor-over"),e.removeClass("redactor-clicktoedit-enabled")},_isEnabled:function(){return this.container.getElement().hasClass("redactor-clicktoedit-enabled")},_destroy:function(){var t=this.editor.getElement(),e=this.container.getElement();t.off(".redactor-click-to-edit"),e.removeClass("redactor-over redactor-clicktoedit-enabled")},_setFocus:function(){this.saved=this.source.getCode(),this.buttonSave.start(),this.buttonCancel.start()}}),l.add("class","clicktoedit.button",{init:function(t,e,i){this.app=e,this.opts=e.opts,this.toolbar=e.toolbar,this.context=i,this.type=t,this.name="save"===t?"clickToSave":"clickToCancel",this.objected=!1,this.enabled=!1,this.namespace=".redactor-click-to-edit",this._build()},enable:function(){if(this.objected){var t=this.opts[this.name];t.api="module.clicktoedit."+this.type,this.toolbar.addButton(this.type,t),this.enabled=!0}},start:function(){this.objected||(this.$button.off(this.namespace),this.$button.show(),this.$button.on("click"+this.namespace,this.context[this.type].bind(this.context)))},stop:function(){!this.objected&&this.enabled&&this.$button.hide()},_build:function(){this.objected="object"==typeof this.opts[this.name],this.objected||(this.$button=l.dom(this.opts[this.name]),this.enabled=!0)}}),l.add("module","statusbar",{init:function(t){this.app=t,this.opts=t.opts,this.element=t.element,this.statusbar=t.statusbar,this.container=t.container},start:function(){if(!this.element.isType("inline")){var t=this.statusbar.getElement(),e=this.container.getElement();t.addClass("redactor-statusbar"),e.append(t)}}}),l.add("module","contextbar",{init:function(t){this.app=t,this.opts=t.opts,this.uuid=t.uuid,this.$win=t.$win,this.$doc=t.$doc,this.$body=t.$body,this.editor=t.editor,this.toolbar=t.toolbar,this.detector=t.detector,this.$target=this.toolbar.isTarget()?this.toolbar.getTargetElement():this.$body},onstop:function(){this.stop()},onenablereadonly:function(){this.stop()},ondisablereadonly:function(){this.start()},oncontextbar:{close:function(){this.close()}},start:function(){if(this.opts.toolbarContext){var t=this.editor.getElement();this._build(),t.on("click.redactor-context mouseup.redactor-context",this.open.bind(this)),this.opts.scrollTarget?l.dom(this.opts.scrollTarget).on("scroll.redactor-context",this.close.bind(this)):this.opts.maxHeight!==!1&&t.on("scroll.redactor-context",this.close.bind(this))}},stop:function(){var t=this.editor.getElement();t.off(".redactor-context"),this.$doc.off(".redactor-context"),this.$win.off(".redactor-context"),this.$contextbar&&this.$contextbar.remove(),this.opts.scrollTarget&&l.dom(this.opts.scrollTarget).off(".redactor-context")},is:function(){return this.$contextbar&&this.$contextbar.hasClass("open")},set:function(t,e,i,s){this.$contextbar.html(""),this.$el=l.dom(e);for(var n in i){var r=l.create("contextbar.button",this.app,i[n]);""!==r.html()&&this.$contextbar.append(r)}var o=this._buildPosition(t,this.$el,s);this.$contextbar.css(o),this.$contextbar.show(),this.$contextbar.addClass("open"),this.$doc.on("click.redactor-context mouseup.redactor-context",this.close.bind(this)),this.$win.on("resize.redactor-context",this.close.bind(this))},open:function(t){setTimeout(function(){this.app.broadcast("contextbar",t,this)}.bind(this),0)},close:function(t){if(this.$contextbar){if(t){var e=l.dom(t.target);if(this.$el&&0!==e.closest(this.$el).length)return}this.$contextbar.hide(),this.$contextbar.removeClass("open"),this.$doc.off(".redactor.context")}},_build:function(){this.$contextbar=l.dom("<div>"),this.$contextbar.attr("id","redactor-context-toolbar-"+this.uuid),this.$contextbar.attr("dir",this.opts.direction),this.$contextbar.addClass("redactor-context-toolbar"),this.$contextbar.hide(),this.$target.append(this.$contextbar)},_buildPosition:function(t,e,i){var s,n,r=this.toolbar.isTarget(),o=r?e.position():e.offset(),a=e.width(),l=e.height(),h=this.$contextbar.width(),c=this.$contextbar.height(),d=r?this.$target.scrollTop()+this.$doc.scrollTop():this.$doc.scrollTop(),u=this.$target.offset(),p=r?u.left:0,f=r?u.top:0;return i?"top"===i?(s=o.top-c,n=o.left+a/2-h/2):"bottom"===i&&(s=o.top+l,n=o.left+a/2-h/2):(s=t.clientY+d-c,n=t.clientX-h/2),n<0&&(n=0),{top:s-f+"px",left:n-p+"px"}}}),l.add("class","contextbar.button",{mixins:["dom"],init:function(t,e){this.app=t,this.obj=e,this._init()},_init:function(){if(this.parse("<a>"),"string"!=typeof this.obj.title){var t=this.obj.title.attr("href");this.attr("href",t),t.search(/^#/)===-1&&this.attr("target","_blank"),this.text(this.obj.html||t)}else this.attr("href","#"),this._buildTitle(),this._buildMessage()},_buildTitle:function(){this.html(this.obj.title)},_buildMessage:function(){"undefined"==typeof this.obj.message&&"undefined"==typeof this.obj.api||this.on("click",this._toggle.bind(this))},_toggle:function(t){t.preventDefault(),this.obj.message?this.app.broadcast(this.obj.message,this.obj.args):this.obj.api&&this.app.api(this.obj.api,this.obj.args)}}),l.add("module","toolbar",{init:function(t){this.app=t,this.uuid=t.uuid,this.opts=t.opts,this.utils=t.utils,this.toolbar=t.toolbar,this.detector=t.detector,this.buttons=[],this.toolbarModule=!1},onsource:{open:function(){!this.toolbar.isAir()&&this.toolbar.isFixed()&&this.toolbarModule.resetPosition()},opened:function(){this.toolbar.isAir()&&this.toolbarModule&&this.toolbarModule.createSourceHelper(),setTimeout(function(){l.dom(".re-button-tooltip-"+this.uuid).remove()}.bind(this),100)},close:function(){this.toolbar.isAir()&&this.toolbarModule&&this.toolbarModule.destroySourceHelper()},closed:function(){this.toolbar.is()&&this.opts.air&&this.toolbarModule.openSelected()}},ontoolbar:{removeexternal:function(){!this.opts.air&&this.opts.toolbarExternal&&this.opts.clickToEdit&&l.dom(this.opts.toolbarExternal).html("")}},onobserve:function(){this.toolbar.is()&&this.toolbar.observe()},onfocus:function(){this._setExternalOnFocus()},onsourcefocus:function(){this._setExternalOnFocus()},onempty:function(){this.toolbar.isFixed()&&this.toolbarModule.resetPosition()},onenablereadonly:function(){this.toolbar.isAir()&&this.toolbarModule.close()},start:function(){this.toolbar.is()&&(this._buildButtons(),this._initToolbar(),this._initButtons())},stop:function(){this.toolbarModule&&this.toolbarModule.stop(),l.dom(".re-button-tooltip-"+this.uuid).remove(),l.dom(".redactor-dropdown-"+this.uuid).remove()},_buildButtons:function(){this.buttons=this.opts.buttons.concat(),this._buildImageButton(),this._buildFileButton(),this._buildSourceButton(),this._buildAdditionalButtons(),this._buildHiddenButtons()},_buildImageButton:function(){this.opts.imageUpload||this.opts.imageManagerJson||this.utils.removeFromArrayByValue(this.buttons,"image")},_buildFileButton:function(){this.opts.fileUpload||this.utils.removeFromArrayByValue(this.buttons,"file")},_buildSourceButton:function(){this.opts.source||this.utils.removeFromArrayByValue(this.buttons,"html")},_buildAdditionalButtons:function(){0!==this.opts.buttonsAdd.length&&(this.opts.buttonsAdd=this._removeExistButtons(this.opts.buttonsAdd),this.buttons=this.buttons.concat(this.opts.buttonsAdd)),0!==this.opts.buttonsAddFirst.length&&(this.opts.buttonsAddFirst=this._removeExistButtons(this.opts.buttonsAddFirst),this.buttons.unshift(this.opts.buttonsAddFirst));var t,e;if(this.opts.buttonsAddAfter!==!1){t=this.buttons.indexOf(this.opts.buttonsAddAfter.after)+1,e=this.opts.buttonsAddAfter.buttons;for(var i=0;i<e.length;i++)this.buttons.splice(t+i,0,e[i])}if(this.opts.buttonsAddBefore!==!1){t=this.buttons.indexOf(this.opts.buttonsAddBefore.before)+1,e=this.opts.buttonsAddBefore.buttons;for(var i=0;i<e.length;i++)this.buttons.splice(t-(1-i),0,e[i])}},_buildHiddenButtons:function(){if(0!==this.opts.buttonsHide.length)for(var t=this.opts.buttonsHide,e=0;e<t.length;e++)this.utils.removeFromArrayByValue(this.buttons,t[e]);if(this.detector.isMobile()&&0!==this.opts.buttonsHideOnMobile.length)for(var t=this.opts.buttonsHideOnMobile,e=0;e<t.length;e++)this.utils.removeFromArrayByValue(this.buttons,t[e])},_removeExistButtons:function(t){for(var e=0;e<t.length;e++)this.opts.buttons.indexOf(t[e])!==-1&&this.utils.removeFromArrayByValue(t,t[e]);return t},_setExternalOnFocus:function(){!this.opts.air&&this.opts.toolbarExternal&&this.toolbarModule.setExternal()},_initToolbar:function(){this.toolbarModule=this.opts.air?l.create("toolbar.air",this.app):l.create("toolbar.standard",this.app)},_initButtons:function(){this.toolbar.setButtons(this.buttons);for(var t=0;t<this.buttons.length;t++){var e=this.buttons[t];l.buttons[e]&&this.toolbar.addButton(e,l.extend(!0,{},l.buttons[e]),!1,!1,!0)}}}),l.add("class","toolbar.air",{init:function(t){this.app=t,this.uuid=t.uuid,this.$doc=t.$doc,this.$win=t.$win,this.utils=t.utils,this.editor=t.editor,this.animate=t.animate,this.toolbar=t.toolbar,this.container=t.container,this.inspector=t.inspector,this.selection=t.selection,this.clicks=0,this._init()},stop:function(){var t=this.toolbar.getWrapper();t.remove();var e=this.editor.getElement();e.off(".redactor-air-trigger-"+this.uuid),this.$doc.off(".redactor-air-"+this.uuid),this.$doc.off(".redactor-air-trigger-"+this.uuid),this.toolbar.stopObservers()},createSourceHelper:function(){this.$airHelper=l.dom("<span>"),this.$airHelper.addClass("redactor-air-helper"),this.$airHelper.html('<i class="re-icon-html"></i>'),this.$airHelper.on("click",function(t){t.preventDefault(),this.app.api("module.source.hide")}.bind(this));var t=this.container.getElement();t.append(this.$airHelper)},destroySourceHelper:function(){this.$airHelper&&this.$airHelper.remove()},openSelected:function(){setTimeout(function(){this._isSelection()&&this._open(!1)}.bind(this),0)},close:function(){this.$doc.off(".redactor-air-"+this.uuid);var t=this.toolbar.getElement();t.removeClass("open"),t.hide()},_init:function(){this.toolbar.create();var t=this.toolbar.getWrapper(),e=this.toolbar.getElement(),i=this.editor.getElement(),s=this.container.getElement();t.addClass("redactor-toolbar-wrapper-air"),e.addClass("redactor-air"),e.hide(),t.append(e),s.prepend(t),this.openSelected(),this.$doc.on("mouseup.redactor-air-trigger-"+this.uuid,this._open.bind(this)),i.on("keyup.redactor-air-trigger-"+this.uuid,this._openCmd.bind(this))},_isSelection:function(){return this.selection.is()&&!this.selection.isCollapsed()},_isOpened:function(){var t=this.toolbar.getElement();return t.hasClass("open")},_open:function(t){var e=!!t&&t.target,i=!!t&&l.dom(t.target),s=this.inspector.parse(e),n=s.isComponent()&&!s.isComponentType("table"),r=s.isFigcaption(),o=i&&0!==i.closest(".redactor-modal").length,a=t&&0!==i.closest(".re-button").length,h=t&&0!==i.closest(".redactor-dropdown").length;if(!(h||a||o||r||n||this.toolbar.isContextBar())&&this._isSelection()){var c=this.selection.getPosition();setTimeout(function(){this.app.isReadOnly()||this._isSelection()&&this._doOpen(c)}.bind(this),1)}},_openCmd:function(){if(this.selection.isAll()){var t=this.toolbar.getElement(),e=this.selection.getPosition();e.top=e.top<20?0:e.top-t.height(),e.height=0,this._doOpen(e)}},_doOpen:function(t){var e=this.toolbar.getWrapper(),i=this.toolbar.getElement(),s=this.container.getElement(),n=s.offset(),r=0,o=this.$win.width(),a=i.width();if(o<t.left+a){var l=this.selection.getPosition();r=a-l.width}e.css({left:t.left-n.left-r+"px",top:t.top-n.top+t.height+this.$doc.scrollTop()+"px"}),this.app.broadcast("airOpen"),i.addClass("open"),i.show(),this.$doc.on("click.redactor-air-"+this.uuid,this._close.bind(this)),this.$doc.on("keydown.redactor-air-"+this.uuid,this._close.bind(this)),this.app.broadcast("airOpened")},_close:function(t){var e=!!t&&l.dom(t.target),i=t&&0!==e.closest("[data-dropdown], .redactor-dropdown-not-close").length,s=!i&&t&&0!==e.closest(".re-button").length;(s||!i&&this._isOpened())&&(this.app.broadcast("airClose"),this.close(),this.app.broadcast("airClosed"))}}),l.add("class","toolbar.fixed",{init:function(t){this.app=t,this.uuid=t.uuid,this.opts=t.opts,this.$doc=t.$doc,this.$win=t.$win,this.editor=t.editor,this.toolbar=t.toolbar,this.detector=t.detector,this.container=t.container,this._init()},stop:function(){this.$fixedTarget.off(".redactor-toolbar-"+this.uuid),this.$win.off(".redactor-toolbar-"+this.uuid)},reset:function(){var t=this.toolbar.getElement(),e=this.toolbar.getWrapper();e.css("height",""),t.removeClass("redactor-toolbar-fixed"),t.css({position:"",top:"",left:"",width:""});var i=this.toolbar.getDropdown();i&&i.updatePosition()},_init:function(){this.$fixedTarget=this.toolbar.isTarget()?this.toolbar.getTargetElement():this.$win,this._doFixed(),this.toolbar.isTarget()&&(this.$win.on("scroll.redactor-toolbar-"+this.uuid,this._doFixed.bind(this)),this.$win.on("resize.redactor-toolbar-"+this.uuid,this._doFixed.bind(this))),this.$fixedTarget.on("scroll.redactor-toolbar-"+this.uuid,this._doFixed.bind(this)),this.$fixedTarget.on("resize.redactor-toolbar-"+this.uuid,this._doFixed.bind(this))},_doFixed:function(){var t=this.editor.getElement(),e=this.container.getElement(),i=this.toolbar.getElement(),s=this.toolbar.getWrapper(),n=$(".tab-bar"),r=0;if(!this.editor.isSourceMode()){var o=e.parents().filter(function(t){return"none"===getComputedStyle(t,null).display&&t});if(0===o.length){var a=t.height()<100,l=this.editor.isEmpty();if(a||l)return void this.reset();if(!this.editor.isSourceMode()){var h=i.height(),c=60,d=this.toolbar.isTarget()?e.position():e.offset(),u=d.top,p=u+e.height()-c,f=this.$fixedTarget.scrollTop()+this.opts.toolbarFixedTopOffset,m=this.toolbar.isTarget()?this.$fixedTarget.offset().top-this.$win.scrollTop():0;if(this.toolbar.isTarget()&&"fixed"===this.$fixedTarget.css("position")){var g=this.$fixedTarget.hasClass("modal")&&this.$fixedTarget.hasClass("fade"),v=g?e.closest(".modal-dialog").position().top:0;m=this.$fixedTarget.scrollTop()-v}if(f>u&&f<p){var b=this.detector.isDesktop()?"fixed":"absolute";m=this.detector.isDesktop()?m:f-u,this.detector.isMobile()&&(this.fixedScrollTimeout&&clearTimeout(this.fixedScrollTimeout),i.hide(),this.fixedScrollTimeout=setTimeout(function(){i.show()},250)),s.height(h),i.addClass("redactor-toolbar-fixed"),e.hasClass("redactor-box-fullscreen")?i.css({position:b,top:"0px",width:e.width()+"px"}):(n.length&&!this.detector.isMobile()&&(r=n.outerHeight()),i.css({position:b,top:m+this.opts.toolbarFixedTopOffset+r+"px",width:e.width()+"px"}));var _=this.toolbar.getDropdown();_&&_.updatePosition(),this.app.broadcast("toolbar.fixed")}else this.reset(),this.app.broadcast("toolbar.unfixed")}}}}}),l.add("class","toolbar.standard",{init:function(t){this.app=t,this.opts=t.opts,this.uuid=t.uuid,this.$body=t.$body,this.toolbar=t.toolbar,this.container=t.container,this.isExternalMultiple=!1,this.toolbarFixed=!1,this._init()},stop:function(){var t=this.toolbar.getWrapper();t.remove(),this.toolbarFixed&&this.toolbarFixed.stop(),this.opts.toolbarExternal&&this._findToolbars(),this.toolbar.stopObservers(),this.$body.find(".re-button-tooltip-"+this.uuid).remove()},setExternal:function(){if(this._findToolbars(),this.isExternalMultiple){this.$toolbars.hide();var t=this.$external.find(".redactor-toolbar-external-"+this.uuid);t.show()}},resetPosition:function(){this.toolbarFixed&&this.toolbarFixed.reset()},_init:function(){if(this._build(),this.opts.toolbarExternal)this._buildExternal();else{this._buildFixed();var t=this.toolbar.getElement();t.show()}},_build:function(){this.toolbar.create();var t=this.toolbar.getWrapper(),e=this.toolbar.getElement();if(t.addClass("redactor-toolbar-wrapper"),e.addClass("redactor-toolbar"),e.hide(),t.append(e),!this.opts.toolbarExternal){var i=this.container.getElement();i.prepend(t)}},_buildExternal:function(){if(this._initExternal(),this._findToolbars(),this.isExternalMultiple)this._hideToolbarsExceptFirst();else{var t=this.toolbar.getElement();t.show()}},_buildFixed:function(){this.opts.toolbarFixed&&(this.toolbarFixed=l.create("toolbar.fixed",this.app))},_initExternal:function(){var t=this.toolbar.getElement(),e=this.toolbar.getElement();t.addClass("redactor-toolbar-external redactor-toolbar-external-"+this.uuid),this.$external=l.dom(this.opts.toolbarExternal),this.$external.append(e)},_findToolbars:function(){this.$toolbars=this.$external.find(".redactor-toolbar-external"),this.isExternalMultiple=this.$toolbars.length>1},_hideToolbarsExceptFirst:function(){this.$toolbars.hide();var t=this.$toolbars.first();t.show()}}),l.add("module","line",{init:function(t){this.app=t,this.lang=t.lang,this.component=t.component,this.inspector=t.inspector,this.insertion=t.insertion},oncontextbar:function(t,e){var i=this.inspector.parse(t.target);if(i.isComponentType("line")){var s=i.getComponent(),n={remove:{title:this.lang.get("delete"),api:"module.line.remove",args:s}};e.set(t,s,n,"bottom")}},insert:function(){var t=this.component.create("line");this.insertion.insertRaw(t)},remove:function(t){this.component.remove(t)}}),l.add("class","line.component",{mixins:["dom","component"],init:function(t,e){return this.app=t,e&&void 0!==e.cmnt?e:this._init(e)},_init:function(t){var e,i;if("undefined"!=typeof t){var s=l.dom(t),n=s.get();"HR"===n.tagName?i=n:"FIGURE"===n.tagName&&(e=n,i=s.find("hr").get())}this._buildWrapper(e),this._buildElement(i),this._initWrapper()},_buildElement:function(t){t?this.$element=l.dom(t):(this.$element=l.dom("<hr>"),this.append(this.$element))},_buildWrapper:function(t){t=t||"<figure>",this.parse(t)},_initWrapper:function(){this.addClass("redactor-component"),this.attr({"data-redactor-type":"line",tabindex:"-1",contenteditable:!1})}}),l.add("module","link",{modals:{link:'<form action=""> <div class="form-item"> <label for="modal-link-url">URL <span class="req">*</span></label> <input type="text" id="modal-link-url" name="url"> </div> <div class="form-item"> <label for="modal-link-text">## text ##</label> <input type="text" id="modal-link-text" name="text"> </div> <div class="form-item form-item-title"> <label for="modal-link-title">## title ##</label> <input type="text" id="modal-link-title" name="title"> </div> <div class="form-item form-item-target"> <label class="checkbox-label"> <div class="checkbox-label__text" style="padding-left: 20px;">## link-in-new-tab ##</div> <input type="checkbox" class="checkbox" name="target"> </label> </div> </form>'},init:function(t){this.app=t,this.opts=t.opts,this.lang=t.lang,this.caret=t.caret,this.utils=t.utils,this.inline=t.inline,this.editor=t.editor,this.inspector=t.inspector,this.insertion=t.insertion,this.selection=t.selection,this.isCurrentLink=!1,this.currentText=!1},onmodal:{link:{open:function(t,e){this._setFormData(e,t)},opened:function(t,e){this._setFormFocus(e)},update:function(t,e){var i=e.getData();this._validateData(e,i)&&this._update(i)},insert:function(t,e){var i=e.getData();this._validateData(e,i)&&this._insert(i)},unlink:function(){this._unlink()}}},onbutton:{link:{observe:function(t){this._observeButton(t)}}},ondropdown:{link:{observe:function(t){this._observeUnlink(t),this._observeEdit(t)}}},oncontextbar:function(t,e){var i=this._getCurrent(),s=this.inspector.parse(i);if(s.isLink()||s.isFile()){var n=s.isFile()?s.getFile():s.getLink(),r=l.dom(n),o=l.dom("<a>"),a=r.attr("href");o.text(this._truncateText(a)),o.attr("href",a),o.attr("target","_blank");var h={link:{title:o,html:this._truncateText(a)},edit:{title:this.lang.get("edit"),api:"module.link.open"},unlink:{title:this.lang.get("unlink"),api:"module.link.unlink"}};e.set(t,n,h,"bottom")}},open:function(){this.$link=this._buildCurrent(),this.app.api("module.modal.build",this._getModalData())},insert:function(t){this._insert(t)},update:function(t){this._update(t)},unlink:function(){this._unlink()},_observeButton:function(t){var e=this.selection.getCurrent(),i=this.inspector.parse(e);i.isPre()||i.isCode()?t.disable():t.enable()},_observeUnlink:function(t){var e=t.getItem("unlink"),i=this._getLinks();0===i.length?e.disable():e.enable()},_observeEdit:function(t){var e=this._getCurrent(),i=t.getItem("link"),s=this.inspector.parse(e),n=s.isLink()||s.isFile()?this.lang.get("link-edit"):this.lang.get("link-insert");i.setTitle(n)},_unlink:function(){this.app.api("module.modal.close");var t=[],e=this._getLinks();this.selection.save();for(var i=0;i<e.length;i++){var s=l.create("link.component",this.app,e[i]);t.push(this.selection.getElement(e[i])),s.unwrap(),this.app.broadcast("link.deleted",s)}this.selection.restore();for(var i=0;i<t.length;i++){var n=t[i]?t[i]:this.editor.getElement();this.utils.normalizeTextNodes(n)}this._resetCurrent()},_update:function(t){this.app.api("module.modal.close");var e=this._getLinks();this._setLinkData(e,t,"updated"),this._resetCurrent(),this.app.broadcast("link.changed",e)},_insert:function(t){this.app.api("module.modal.close");var e=this._getLinks();this._insertSingle(e,t)||(this._removeInSelection(e),this._insertMultiple(t)),this._resetCurrent()},_removeInSelection:function(t){this.selection.save();for(var e=0;e<t.length;e++){var i=l.create("link.component",this.app,t[e]),s=i.clone();i.unwrap(),this.app.broadcast("link.deleted",s)}this.selection.restore()},_insertMultiple:function(t){var e=this.selection.getRange();e&&this._isCurrentTextChanged(t)&&this._deleteContents(e);var i=this.inline.format({tag:"a"});this._setLinkData(i,t,"inserted")},_insertSingle:function(t,e){var i=this.selection.getInline();if(1===t.length&&(t[0].textContext===this.selection.getText()||i&&"A"===i.tagName)){ var s=l.create("link.component",this.app,t[0]);return s.setData(e),this.caret.setAfter(s),this.app.broadcast("link.inserted",s),!0}return!1},_setLinkData:function(t,e,i){e.text=""===e.text.trim()?this._truncateText(e.url):e.text;var s=!this.currentText||this.currentText!==e.text;this.selection.save();for(var n=0;n<t.length;n++){var r=l.create("link.component",this.app,t[n]),o={};e.text&&s&&(o.text=e.text),e.url&&(o.url=e.url),void 0!==e.title&&(o.title=e.title),void 0!==e.target&&(o.target=e.target),r.setData(o),this.app.broadcast("link."+i,r)}setTimeout(this.selection.restore.bind(this.selection),0)},_deleteContents:function(t){var e=this.selection.getHtml(),i=this.utils.parseHtml(e),s=i.nodes[0];if(s&&3!==s.nodeType){var n=s.tagName.toLowerCase(),r=document.createElement(n);this.insertion.insertNode(r,"start")}else t.deleteContents()},_getModalData:function(){var t;t=this._isLink()?{update:{title:this.lang.get("save")},unlink:{title:this.lang.get("unlink"),type:"danger"},cancel:{title:this.lang.get("cancel")}}:{insert:{title:this.lang.get("insert")},cancel:{title:this.lang.get("cancel")}};var e={name:"link",title:this._isLink()?this.lang.get("link-edit"):this.lang.get("link-insert"),handle:this._isLink()?"update":"insert",commands:t};return e},_isLink:function(){return this.currentLink},_isCurrentTextChanged:function(t){return this.currentText&&this.currentText!==t.text},_buildCurrent:function(){var t,e=this._getCurrent(),i=this.inspector.parse(e);if(i.isLink()||i.isFile())this.currentLink=!0,t=i.isFile()?i.getFile():i.getLink(),t=l.create("link.component",this.app,t);else{this.currentLink=!1,t=l.create("link.component",this.app);var s={text:this.selection.getText()};t.setData(s)}return t},_getCurrent:function(){return this.selection.getInlinesAllSelected({tags:["a"]})[0]},_getLinks:function(){for(var t=this.selection.getInlines({all:!0,tags:["a"]}),e=[],i=0;i<t.length;i++){var s=this.inspector.parse(t[i]);(s.isLink()||s.isFile())&&e.push(t[i])}return e},_resetCurrent:function(){this.isCurrentLink=!1,this.currentText=!1},_truncateText:function(t){return t&&t.length>this.opts.linkSize?t.substring(0,this.opts.linkSize)+"...":t},_validateData:function(t,e){return""!==e.url.trim()||t.setError("url")},_setFormFocus:function(t){t.getField("url").focus()},_setFormData:function(t,e){var i=this.$link.getData(),s={url:i.url,text:i.text,title:i.title,target:this.opts.linkTarget||i.target};this.opts.linkNewTab||e.find(".form-item-target").hide(),this.opts.linkTitle||e.find(".form-item-title").hide(),t.setData(s),this.currentText=t.getField("text").val()}}),l.add("class","link.component",{mixins:["dom","component"],init:function(t,e){return this.app=t,this.opts=t.opts,this.reUrl=/^(?:(?:(?:https?|ftp):)?\/\/)?(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i,e&&void 0!==e.cmnt?e:this._init(e)},setData:function(t){for(var e in t)this._set(e,t[e])},getData:function(){for(var t=["url","text","target","title"],e={},i=0;i<t.length;i++)e[t[i]]=this._get(t[i]);return e},_init:function(t){var e=l.dom(t);void 0===t?this.parse("<a>"):this.parse(e)},_set:function(t,e){this["_set_"+t](e)},_get:function(t){return this["_get_"+t]()},_get_target:function(){return!!this.attr("target")&&this.attr("target")},_get_url:function(){return this.attr("href")},_get_title:function(){return this.attr("title")},_get_text:function(){return this._getContext().text()},_getContext:function(){return this._findDeepestChild(this).element},_set_target:function(t){t===!1?this.removeAttr("target"):t&&this.attr("target",t===!0?"_blank":t)},_set_text:function(t){t=this._escapeHtml(t),this._getContext().html(t)},_set_title:function(t){t&&""!==t?this.attr("title",t):this.removeAttr("title")},_set_url:function(t){this.opts.linkValidation&&(t=this._cleanUrl(t),this._isMailto(t)?t="mailto:"+t.replace("mailto:",""):this._isUrl(t)&&t.search(/^(ftp|https?)/i)===-1&&(t="http://"+t.replace(/(ftp|https?):\/\//i,""))),this.attr("href",t)},_isMailto:function(t){return t.search("@")!==-1&&/(ftp|https?):\/\//i.test(t)===!1},_isUrl:function(t){return this.reUrl.test(t)},_cleanUrl:function(t){return t=this._escapeHtml(t),t.trim().replace(/[^\W\w\D\d+&\'@#/%?=~_|!:,.;\(\)]/gi,"")},_escapeHtml:function(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},_findDeepestChild:function(t){var e={depth:0,element:t};return t.children().each(function(i){var s=l.dom(i);if(i.outerHTML===t.html()){var n=this._findDeepestChild(s);n.depth+1>e.depth&&(e={depth:1+n.depth,element:n.element})}}.bind(this)),e}}),l.add("module","modal",{init:function(t){this.app=t,this.uuid=t.uuid,this.lang=t.lang,this.$doc=t.$doc,this.$win=t.$win,this.$body=t.$body,this.utils=t.utils,this.editor=t.editor,this.animate=t.animate,this.detector=t.detector,this.selection=t.selection,this.$box=!1,this.$modal=!1,this.selectionMarkers=!1,this.defaults={name:!1,url:!1,title:!1,width:"600px",height:!1,handle:!1,commands:!1}},build:function(t){this._open(t)},close:function(){this._close()},onstop:function(){this.$body.find("#redactor-modal-"+this.uuid).remove(),this.$body.find("#redactor-overlay-"+this.uuid).remove()},stop:function(){this.$box&&(this.$box.remove(),this.$box=!1,this.$modal=!1),this.$overlay&&this.$overlay.remove(),this.$doc.off(".redactor.modal"),this.$win.off(".redactor.modal")},resize:function(){this.$modal.setWidth(this.p.width),this.$modal.updatePosition()},_isOpened:function(){return this.$modal&&this.$modal.hasClass("redactor-modal-open")},_open:function(t){this._buildDefaults(t),this.p.url?this._openUrl():this._openTemplate()},_openUrl:function(){l.ajax.post({url:this.p.url,success:this._doOpen.bind(this)})},_openTemplate:function(){if("undefined"!=typeof l.modals[this.p.name]){var t=this.lang.parse(l.modals[this.p.name]);this._doOpen(t)}},_doOpen:function(t){this.stop(),this.selection.isCollapsed()?(this.selection.save(),this.selectionMarkers=!1):(this.selection.saveMarkers(),this.selectionMarkers=!0),this.detector.isDesktop()||document.activeElement.blur(),this._createModal(t),this._buildModalBox(),this._buildOverlay(),this._buildModal(),this._buildModalForm(),this._buildModalCommands(),this._broadcast("open"),this.$modal.updatePosition(),this._buildModalTabs(),this.animate.start(this.$box,"fadeIn",this._opened.bind(this)),this.animate.start(this.$overlay,"fadeIn")},_opened:function(){this.$modal.addClass("open").addClass("redactor-modal-open"),this.$box.on("mousedown.redactor.modal",this._close.bind(this)),this.$doc.on("keyup.redactor.modal",this._handleEscape.bind(this)),this.$win.on("resize.redactor.modal",this.resize.bind(this)),this.$modal.getBody().find("input[type=text],input[type=url],input[type=email]").on("keydown.redactor.modal",this._handleEnter.bind(this)),window.jQuery&&window.jQuery(document).off("focusin.modal"),this._broadcast("opened")},_close:function(t){if(this.$box&&this._isOpened()){if(t){if(!this._needToClose(t.target))return;t.stopPropagation(),t.preventDefault()}this.selectionMarkers?this.selection.restoreMarkers():this.selection.restore(),this.selectionMarkers=!1,this._broadcast("close"),this.animate.start(this.$box,"fadeOut",this._closed.bind(this)),this.animate.start(this.$overlay,"fadeOut")}},_closed:function(){this.$modal.removeClass("open").removeClass("redactor-modal-open"),this.$box.off(".redactor.modal"),this.$doc.off(".redactor.modal"),this.$win.off(".redactor.modal"),this._broadcast("closed")},_createModal:function(t){this.$modal=l.create("modal.element",this.app,t)},_broadcast:function(t){this.app.broadcast("modal."+t,this.$modal,this.$modalForm),this.app.broadcast("modal."+this.p.name+"."+t,this.$modal,this.$modalForm)},_buildDefaults:function(t){this.p=l.extend({},this.defaults,t)},_buildModalBox:function(){this.$box=l.dom("<div>"),this.$box.attr("id","redactor-modal-"+this.uuid),this.$box.addClass("redactor-modal-box redactor-animate-hide"),this.$box.html(""),this.$body.append(this.$box)},_buildOverlay:function(){this.$overlay=l.dom("#redactor-overlay-"+this.uuid),0===this.$overlay.length&&(this.$overlay=l.dom("<div>"),this.$overlay.attr("id","redactor-overlay-"+this.uuid),this.$overlay.addClass("redactor-overlay redactor-animate-hide"),this.$body.prepend(this.$overlay))},_buildModal:function(){this.$box.append(this.$modal),this.$modal.setTitle(this.p.title),this.$modal.setHeight(this.p.height),this.$modal.setWidth(this.p.width)},_buildModalCommands:function(){if(this.p.commands){var t=this.p.commands,e=this.$modal.getFooter();for(var i in t){var s=l.dom("<button>");s.html(t[i].title),s.attr("data-command",i),"cancel"===i&&(s.attr("data-action","close"),s.addClass("redactor-button-unstyled")),"undefined"!=typeof t[i].type&&"danger"===t[i].type&&s.addClass("redactor-button-danger"),s.on("click",this._handleCommand.bind(this)),e.append(s)}}},_buildModalTabs:function(){var t=this.$modal.getBody(),e=t.find(".redactor-modal-tab"),i=t.find(".redactor-modal-tabs");e.length>1&&(i=0===i.length?l.dom("<div>"):i.html(""),i.addClass("redactor-modal-tabs"),e.each(function(t,e){var s=l.dom(t),n=l.dom("<a>");n.attr("href","#"),n.attr("rel",e),n.text(s.attr("data-title")),n.on("click",this._showTab.bind(this)),0===e&&n.addClass("active"),i.append(n)}.bind(this)),t.prepend(i)),1===e.length&&e.show()},_buildModalForm:function(){this.$modalForm=l.create("modal.form",this.app,this.$modal.getForm())},_showTab:function(t){t.preventDefault();var e=l.dom(t.target),i=e.attr("rel"),s=this.$modal.getBody(),n=s.find(".redactor-modal-tab");n.hide(),n.eq(i).show(),s.find(".redactor-modal-tabs a").removeClass("active"),e.addClass("active")},_needToClose:function(t){var e=l.dom(t);return!("close"!==e.attr("data-action")&&!this.$modal.isCloseNode(t)&&0!==e.closest(".redactor-modal").length)},_handleCommand:function(t){var e=l.dom(t.target).closest("button"),i=e.attr("data-command");"cancel"!==i&&t.preventDefault(),this._broadcast(i)},_handleEnter:function(t){13===t.which&&this.p.handle&&(t.preventDefault(),this._broadcast(this.p.handle))},_handleEscape:function(t){27===t.which&&this._close()}}),l.add("class","modal.element",{mixins:["dom"],init:function(t,e){this.app=t,this.opts=t.opts,this.$win=t.$win,this._init(e)},getForm:function(){return this.find("form")},getHeader:function(){return this.$modalHeader},getBody:function(){return this.$modalBody},getFooter:function(){return this.$modalFooter},setTitle:function(t){t&&this.$modalHeader.html(t)},setWidth:function(t){t=parseInt(t)>=this.$win.width()?"96%":t,this.css("max-width",t)},setHeight:function(t){t!==!1&&this.$modalBody.css("height",t)},updatePosition:function(){var t=this.width();this.css({left:"50%","margin-left":"-"+t/2+"px"});var e=this.$win.height(),i=this.height(),s=e/2-i/2;i<e&&0!==s&&this.css("margin-top",s+"px")},isCloseNode:function(t){return t===this.$modalClose.get()},_init:function(t){this._build(),this._buildClose(),this._buildHeader(),this._buildBody(),this._buildFooter(),this._buildTemplate(t)},_build:function(){this.parse("<div>"),this.addClass("redactor-modal"),this.attr("dir",this.opts.direction)},_buildClose:function(){this.$modalClose=l.dom("<span>"),this.$modalClose.addClass("redactor-close"),this.append(this.$modalClose)},_buildHeader:function(){this.$modalHeader=l.dom("<div>"),this.$modalHeader.addClass("redactor-modal-header"),this.append(this.$modalHeader)},_buildBody:function(){this.$modalBody=l.dom("<div>"),this.$modalBody.addClass("redactor-modal-body"),this.append(this.$modalBody)},_buildFooter:function(){this.$modalFooter=l.dom("<div>"),this.$modalFooter.addClass("redactor-modal-footer"),this.append(this.$modalFooter)},_buildTemplate:function(t){this.$modalBody.html(t)}}),l.add("class","modal.form",{mixins:["dom"],init:function(t,e){this.app=t,this.build(e)},build:function(t){this.parse(t)},getData:function(){var t={};return this.find("[name]").each(function(e){var i=l.dom(e);t[i.attr("name")]=i.val()}),t},setData:function(t){this.find("[name]").each(function(e){var i=l.dom(e),s=i.attr("name");t.hasOwnProperty(s)&&(e.type&&"checkbox"===e.type?e.checked=t[s]:i.val(t[s]))})},getField:function(t){return this.find("[name="+t+"]")},setError:function(t){var e=this.getField(t);return e.addClass("error"),e.one(this._getFieldEventName(e.get()),this._clearError),!1},_clearError:function(){return l.dom(this).removeClass("error")},_getFieldEventName:function(t){return"SELECT"===t.tagName||"checkbox"===t.type||"radio"===t.type?"change":"keyup"}}),l.add("module","block",{init:function(t){this.app=t,this.block=t.block},format:function(t){var e=this.block.format(t);this.app.broadcast("format","block",e)},clearformat:function(){this.block.clearFormat()},clearstyle:function(){this.block.clearStyle()},clearclass:function(){this.block.clearClass()},clearattr:function(){this.block.clearAttr()},add:function(t,e){this.block.add(t,e)},toggle:function(t,e){this.block.toggle(t,e)},set:function(t,e){this.block.set(t,e)},remove:function(t,e){this.block.remove(t,e)}}),l.add("module","inline",{init:function(t){this.app=t,this.inline=t.inline},format:function(t){var e=this.inline.format(t);this.app.broadcast("format","inline",e)},clearformat:function(){this.inline.clearFormat()},clearstyle:function(){this.inline.clearStyle()},clearclass:function(){this.inline.clearClass()},clearattr:function(){this.inline.clearAttr()},add:function(t,e){this.inline.add(t,e)},toggle:function(t,e){this.inline.toggle(t,e)},set:function(t,e){this.inline.set(t,e)},remove:function(t,e){this.inline.remove(t,e)}}),l.add("module","autosave",{init:function(t){this.app=t,this.opts=t.opts,this.utils=t.utils,this.source=t.source},onsynced:function(){this.opts.autosave&&this._send()},_send:function(){var t=this.opts.autosaveName?this.opts.autosaveName:this.source.getName(),e={};e[t]=this.source.getCode(),e=this.utils.extendData(e,this.opts.autosaveData),l.ajax.request(this.opts.autosaveMethod,{url:this.opts.autosave,data:e,success:function(i){this._complete(i,t,e)}.bind(this)})},_complete:function(t,e,i){var s=t&&t.error?"autosaveError":"autosave";this.app.broadcast(s,e,i,t)}}),l.add("module","input",{init:function(t){this.app=t,this.opts=t.opts,this.utils=t.utils,this.editor=t.editor,this.keycodes=t.keycodes,this.element=t.element,this.selection=t.selection,this.insertion=t.insertion,this.inspector=t.inspector,this.autoparser=t.autoparser,this.lastShiftKey=!1},onpaste:function(t,e){if(this.opts.input)return l.create("input.paste",this.app,t,e)},onkeydown:function(t){if(this.opts.input){var e=t.which,i=l.create("input.shortcut",this.app,t);if(!i.is()){if((t.ctrlKey||t.metaKey)&&!t.altKey&&65===e)return t.preventDefault(),this._selectAll();var s=[this.keycodes.ENTER,this.keycodes.SPACE,this.keycodes.BACKSPACE,this.keycodes.DELETE],n=[this.keycodes.UP,this.keycodes.DOWN,this.keycodes.LEFT,this.keycodes.RIGHT],r=s.indexOf(e)!==-1,o=n.indexOf(e)!==-1,a=(t.ctrlKey||t.metaKey)&&88===e,h=!t.ctrlKey&&!t.metaKey&&(e>=48&&e<=57||e>=65&&e<=90);if(this.selection.isAll()&&o&&(a||!t.ctrlKey&&!t.metaKey&&!t.altKey&&!t.shiftKey)){if(a)return this.editor.disableNonEditables(),void this.app.broadcast("empty");if(this._isArrowKey(e))return!0;if(r&&t.preventDefault(),this.element.isType("inline")){var c=this.editor.getElement();c.html(""),this.editor.startFocus()}else this.insertion.set(this.opts.emptyHtml);if(r)return;this.app.broadcast("empty")}return this.opts.autoparse&&this.autoparser.format(t,e),h&&this.selection.hasNonEditable()?void t.preventDefault():e===this.keycodes.ENTER?l.create("input.enter",this.app,t,e):t.metaKey&&219===e?(t.preventDefault(),void this.app.api("module.list.outdent")):e===this.keycodes.TAB||t.metaKey&&221===e?l.create("input.tab",this.app,t,e):e===this.keycodes.SPACE?l.create("input.space",this.app,t,e,this.lastShiftKey):this._isDeleteKey(e)?l.create("input.delete",this.app,t,e):this._isArrowKey(e)?l.create("input.arrow",this.app,t,e):void 0}}},onkeyup:function(t){if(this.opts.input){var e=t.which;this.lastShiftKey=t.shiftKey,this.app.broadcast("contextbar.close");var i=l.create("input.shortcode",this.app,t,e);if(!i.is()){if(e===this.keycodes.BACKSPACE){var s=this.editor.getElement(),n=this.utils.trimSpaces(s.html());if(n=n.replace(/<br\s?\/?>/g,""),n=n.replace(/<div><\/div>/,""),""===n)return t.preventDefault(),this.editor.setEmpty(),void this.editor.startFocus()}this.editor.isEmpty()&&this.app.broadcast("empty")}}},start:function(){this.opts.shortcutsAdd&&(this.opts.shortcuts=l.extend({},!0,this.opts.shortcuts,this.opts.shortcutsAdd))},_selectAll:function(){var t,e=this.selection.getCurrent(),i=this.inspector.parse(e);return i.isComponentType("table")?(t=i.getTable(),void this.selection.setAll(t)):i.isComponentType("code")?(t=i.getComponentCodeElement(),void this.selection.setAll(t)):void this.selection.setAll()},_isArrowKey:function(t){return[this.keycodes.UP,this.keycodes.DOWN,this.keycodes.RIGHT,this.keycodes.LEFT].indexOf(t)!==-1},_isDeleteKey:function(t){return t===this.keycodes.BACKSPACE||t===this.keycodes.DELETE}}),l.add("class","input.arrow",{init:function(t,e,i){this.app=t,this.opts=t.opts,this.utils=t.utils,this.caret=t.caret,this.offset=t.offset,this.marker=t.marker,this.editor=t.editor,this.keycodes=t.keycodes,this.component=t.component,this.inspector=t.inspector,this.selection=t.selection,this.key=i,this._init(e)},_init:function(t){if(!this._isRightLeftKey()||!this._isExitVariable(t)){if(this._isRightDownKey()){if(this._isExitOnDownRight(t))return;if(this._selectComponent(t,"End","next"))return}if(this._isLeftUpKey()){if(this._isExitOnUpLeft(t))return;if(this._selectComponent(t,"Start","prev"))return}this.key===this.keycodes.LEFT?this.utils.trimInvisibleChars("left"):this.key===this.keycodes.RIGHT&&this.utils.trimInvisibleChars("right")}},_isRightDownKey:function(){return[this.keycodes.DOWN,this.keycodes.RIGHT].indexOf(this.key)!==-1},_isLeftUpKey:function(){return[this.keycodes.UP,this.keycodes.LEFT].indexOf(this.key)!==-1},_isRightLeftKey:function(){return[this.keycodes.RIGHT,this.keycodes.LEFT].indexOf(this.key)!==-1},_isExitVariable:function(t){var e=this.selection.getCurrent(),i=this.inspector.parse(e),s=i.getComponent();if(i.isComponentType("variable")&&i.isComponentActive()){t.preventDefault();var n=this.key===this.keycodes.LEFT?"setBefore":"setAfter";return void this.caret[n](s)}},_isExitOnUpLeft:function(t){var e=this.selection.getCurrent(),i=this.selection.getBlock(e),s=this.inspector.parse(e),n=i.previousElementSibling,r=this.caret.isStart(i);if(r&&n&&"TABLE"===n.tagName)return t.preventDefault(),this.caret.setEnd(n),!0;if(s.isFigcaption()){i=s.getFigcaption(),r=this.caret.isStart(i);var o=l.dom(i).closest(".redactor-component");if(r&&0!==o.length)return t.preventDefault(),this.caret.setEnd(o),!0}else{if(s.isTable()&&r)return t.preventDefault(),this.caret.setEnd(i.previousElementSibling),!0;if(!s.isComponentEditable()&&s.isComponent()&&!s.isComponentType("variable")){var a=s.getComponent();if(!a.previousElementSibling)return t.preventDefault(),this.component.clearActive(),this._exitPrevElement(t,s.getComponent());if(a.previousElementSibling)return t.preventDefault(),this.component.clearActive(),this.caret.setEnd(a.previousElementSibling),!0}}},_isExitOnDownRight:function(t){var e,i,s=this.editor.getElement(),n=this.selection.getCurrent(),r=this.inspector.parse(n),o=this.caret.isEnd();if(r.isTable()){if(e=r.getTable(),i=this.caret.isEnd(e),i||o)return this._exitNextElement(t,r.getComponent())}else if(r.isFigcaption()){if(e=r.getFigcaption(),i=this.caret.isEnd(e),i||o)return this._exitNextElement(t,r.getComponent())}else if(r.isComponentType("code")){var a=r.getComponent(),h=l.dom(r.getComponentCodeElement()).closest("pre");i=this.caret.isEnd(e);var c=h&&h.get().nextElementSibling;if(i&&!c)return this._exitNextElement(t,a)}else if(r.isPre()||r.isBlockquote()||r.isDl()){if(o){if(r.isPre())return this._exitNextElement(t,r.getPre());if(r.isBlockquote())return this._exitNextElement(t,r.getBlockquote());if(r.isDl())return this._exitNextElement(t,r.getDl())}}else if(r.isList()){var d=l.dom(n).parents("ul, ol",s).last();if(i=this.caret.isEnd(d),i||o)return this._exitNextElement(t,d.get())}else if(r.isComponent()&&!r.isComponentType("variable")&&"span"!==r.getTag())return this.component.clearActive(),this._exitNextElement(t,r.getComponent())},_exitPrevElement:function(t,e){return t.preventDefault(),e.previousElementSibling?this.caret.setEnd(e.previousElementSibling):this.utils.createMarkupBefore(e),!0},_exitNextElement:function(t,e){return t.preventDefault(),e.nextElementSibling?this.caret.setStart(e.nextElementSibling):this.utils.createMarkup(e),!0},_selectComponent:function(t,e,i){var s=this.selection.getCurrent(),n=this.selection.getBlock(s),r=this.utils.findSiblings(s,i),o=this.utils.findSiblings(n,i);r&&this.caret["is"+e](s)?this._selectComponentItem(t,r,e):o&&this.caret["is"+e](n)&&this._selectComponentItem(t,o,e)},_selectComponentItem:function(t,e,i){if(this.component.isNonEditable(e))return t.preventDefault(),this.caret["set"+i](e),!0}}),l.add("class","input.delete",{init:function(t,e,i){this.app=t,this.opts=t.opts,this.caret=t.caret,this.utils=t.utils,this.editor=t.editor,this.marker=t.marker,this.keycodes=t.keycodes,this.component=t.component,this.inspector=t.inspector,this.selection=t.selection,this.insertion=t.insertion,this.key=i,this._init(e)},_init:function(t){if(!this._removeActiveComponent(t)&&!this._removeAllSelectedTable(t)){if(this.key===this.keycodes.BACKSPACE){var e=this.editor.getElement(),i=this.utils.trimSpaces(e.html());if(i===this.opts.emptyHtml)return void t.preventDefault()}if(this._detectVariableOrNonEditable()||this.selection.hasNonEditable())return void t.preventDefault();if(this.selection.isAll())return t.preventDefault(),void this.insertion.set(this.opts.emptyHtml);this.selection.isCollapsed()&&(this.key===this.keycodes.BACKSPACE?this._traverseBackspace(t):this.key===this.keycodes.DELETE&&this._traverseDelete(t)),this.key===this.keycodes.BACKSPACE&&this.utils.trimInvisibleChars("left"),this._removeUnwantedStyles(),this._removeEmptySpans(),this._removeSpanTagsInHeadings(),this._removeInlineTagsInPre()}},_detectVariableOrNonEditable:function(){var t,e=this.selection.getBlock(),i=this.caret.isStart(e),s=this.caret.isEnd(e);if(this.key===this.keycodes.BACKSPACE&&i){if(t=e.previousSibling,this._isNonEditable(t))return!0}else if(this.key===this.keycodes.DELETE&&s&&(t=e.nextSibling,this._isNonEditable(t)))return!0;var n=this.selection.getCurrent(),r=this.caret.isStart(n),o=this.caret.isEnd(n),a=""===this.selection.getTextBeforeCaret().trim(),l=""===this.selection.getTextAfterCaret().trim();if(this.key===this.keycodes.BACKSPACE&&r&&!a){if(t=n.previousSibling,this._isVariable(t))return this.caret.setEnd(t),!0;if(this._isNonEditable(t))return!0}else if(this.key===this.keycodes.DELETE&&o&&!l){if(t=n.nextSibling,this._isVariable(t))return this.caret.setStart(t),!0;if(this._isNonEditable(t))return!0}},_isVariable:function(t){return 0!==l.dom(t).closest('[data-redactor-type="variable"]').length},_isNonEditable:function(t){return 0!==l.dom(t).closest(".non-editable").length},_getBlock:function(){var t=this.editor.getElement(),e=this.selection.getBlock(),i=this.inspector.parse(e);return e=i.isList()?l.dom(e).parents("ul, ol",t).last().get():e,e=i.isDl()?i.getDl():e,e=i.isTable()?i.getTable():e},_traverseDelete:function(t){var e,i,s,n=this.selection.getCurrent(),r=this.inspector.parse(n);if(r.isFigcaption()){if(e=r.getFigcaption(),i=this.caret.isEnd(e))return void t.preventDefault()}else if(r.isComponentType("code")&&(e=r.getComponent(),i=this.caret.isEnd(e)))return void t.preventDefault();e=this._getBlock();var o=this.utils.findSiblings(e,"next");if(o){i=this.caret.isEnd(e);var a=this.inspector.parse(o),h="P"===o.tagName||"DIV"===o.tagName;if(i&&a.isComponentType("table"))return t.preventDefault(),void this.caret.setStart(o);if(i&&a.isComponentEditable())return t.preventDefault(),void this.component.remove(o,!1);if(i&&a.isComponent())return t.preventDefault(),this.caret.setStart(o),void(this.utils.isEmptyHtml(e.innerHTML)&&l.dom(e).remove());if(i&&a.isList()){var c=l.dom(e);if(s=l.dom(o),r.isList())return t.preventDefault(),c.append(s),void s.unwrap();var d=s.children("li").first(),u=d.find("ul, ol");if(0!==u.length)return t.preventDefault(),s.prepend(u),u.unwrap(),c.append(d),void d.unwrap()}else if(i&&!r.isList()&&!r.isTable()&&h&&!this.utils.isEmptyHtml(e.innerHTML)){t.preventDefault();var p=l.dom(e);return s=l.dom(o),p.append(s),void s.unwrap()}}},_traverseBackspace:function(t){var e,i,s,n,r=this.selection.getCurrent(),o=this.inspector.parse(r);if(o.isFigcaption()){if(e=o.getFigcaption(),i=this.caret.isStart(e))return void t.preventDefault()}else if(o.isComponentType("code")&&(e=o.getComponent(),i=this.caret.isStart(e),i&&e.previousElementSibling))return t.preventDefault(),this.caret.setEnd(e.previousElementSibling),!0;e=this._getBlock();var a=this.utils.findSiblings(e,"prev");if(!a)return void setTimeout(this._replaceBlock.bind(this),1);i=this.caret.isStart(e);var h=this.inspector.parse(a),c="P"===a.tagName||"DIV"===a.tagName;if(i&&h.isComponentType("code"))return t.preventDefault(),void this.component.remove(a,!1);if(i&&h.isComponentType("table"))return t.preventDefault(),void this.caret.setEnd(a);if(i&&h.isComponent())return t.preventDefault(),this.caret.setStart(a),void(this.utils.isEmptyHtml(e.innerHTML)&&l.dom(e).remove());if(i&&o.isList())if(t.preventDefault(),n=l.dom(e),s=l.dom(a),h.isList())n.children("li").first().prepend(this.marker.build("start")),s.append(n),n.unwrap(),this.selection.restoreMarkers();else{var d=n.children("li").first(),u=d.get(),p=d.find("ul, ol"),f=this.utils.replaceToTag(u,this.opts.markup);this.opts.breakline&&f.attr("data-redactor-tag","br"),n.before(f),this.caret.setStart(f),0!==p.length&&(n.prepend(p),p.unwrap())}else if(i&&c){if(t.preventDefault(),this.utils.isEmpty(a))return s=l.dom(a),void s.remove();var m=this.utils.createInvisibleChar(),g=l.dom(e);return s=l.dom(a),this.caret.setEnd(s),g.prepend(m),s.append(g.contents()),void g.remove()}},_replaceBlock:function(){var t=this.selection.getBlock(),e=l.dom(t);if("p"===this.opts.markup&&t&&this._isNeedToReplaceBlock(t)){var i=document.createElement(this.opts.markup);e.replaceWith(i),this.caret.setStart(i)}this.opts.breakline&&t&&"DIV"===t.tagName&&e.attr("data-redactor-tag","br")},_isNeedToReplaceBlock:function(t){return"DIV"===t.tagName&&this.utils.isEmptyHtml(t.innerHTML)},_removeActiveComponent:function(t){var e=this.selection.getCurrent(),i=this.inspector.parse(e),s=i.getComponent();if(i.isComponent()&&this.component.isActive(s))return t.preventDefault(),this.component.remove(s),!0},_removeAllSelectedTable:function(t){var e=this.selection.getCurrent(),i=this.inspector.parse(e),s=i.getTable();if(s&&this.selection.isAll(s))return t.preventDefault(),this.component.remove(s),!0},_removeUnwantedStyles:function(){var t=this.editor.getElement();setTimeout(function(){var e=t.find("*[style]");e.not("img, figure, figcaption, iframe, [data-redactor-style-cache], [data-redactor-span]").removeAttr("style")},0)},_removeEmptySpans:function(){var t=this.editor.getElement();setTimeout(function(){t.find("span").each(function(t){0===t.attributes.length&&l.dom(t).replaceWith(t.childNodes)})},0)},_removeSpanTagsInHeadings:function(){var t=this.editor.getElement();setTimeout(function(){t.find("h1, h2, h3, h4, h5, h6").each(function(t){var e=l.dom(t);0===e.closest("figure").length&&e.find("span").not(".redactor-component, .non-editable, .redactor-selection-marker, [data-redactor-style-cache], [data-redactor-span]").unwrap()})},1)},_removeInlineTagsInPre:function(){var t=this.editor.getElement(),e=this.opts.inlineTags;setTimeout(function(){t.find("pre").each(function(t){var i=l.dom(t);0===i.closest("figure").length&&i.find(e.join(",")).not("code, .redactor-selection-marker").unwrap()})},1)}}),l.add("class","input.enter",{init:function(t,e){this.app=t,this.opts=t.opts,this.utils=t.utils,this.caret=t.caret,this.editor=t.editor,this.keycodes=t.keycodes,this.detector=t.detector,this.insertion=t.insertion,this.selection=t.selection,this.inspector=t.inspector,this._init(e)},_init:function(t){if(!this.opts.enterKey)return this._disable(t);var e=this.app.broadcast("enter",t);return e===!1?t.preventDefault():this.selection.hasNonEditable()?void t.preventDefault():t.ctrlKey||t.shiftKey?this._insertBreak(t):void(this._isExit(t)||this._traverse(t))},_disable:function(t){t.preventDefault();var e=this.selection.getRange();e&&!e.collapsed&&e.deleteContents()},_insertBreak:function(t){t.preventDefault();var e=this.selection.getCurrent(),i=this.selection.getBlock(),s=this.inspector.parse(e);if(s.isHeading()&&this.caret.isStart(i)){var n=l.dom(i),r=n.clone().html("");n.before(r),this.caret.setStart(n)}else{if(s.isComponent()&&!s.isComponentEditable()||s.isCode())return;s.isPre()?this.insertion.insertNewline():this.insertion.insertBreakLine()}},_isExit:function(t){var e=this.editor.getElement(),i=this.selection.getBlock(),s=this.inspector.parse(i),n=this.caret.isEnd(i),r=this.selection.getCurrent(),o=r.previousSibling;if(s.isBlockquote()){var a=n&&this._isExitableBlock(i,"P"),h=n&&this._isExitableDblBreak(o);if(a||h)return this._exitFromElement(t,h?o:i,s.getBlockquote())}else if(!s.isComponentType("code")&&s.isPre()){if(n){var c=i.innerHTML;if(c=this.utils.removeInvisibleChars(c),null!==c.match(/(\n\n\n)$/))return l.dom(o.previousSibling.previousSibling).remove(),this._exitFromElement(t,o,i)}}else if(s.isDl()){if(n&&this._isExitableBlock(i,"DT"))return this._exitFromElement(t,i,s.getDl())}else if(s.isList()){var d=l.dom(r).parents("ul, ol",e).last();if(n=this.caret.isEnd(d),n&&this._isExitableBlock(i,"LI"))return this._exitFromElement(t,i,d)}else if(s.isComponent()&&s.isComponentActive()&&!s.isFigcaption()&&!s.isComponentEditable())return this._exitFromElement(t,!1,s.getComponent())},_isExitableDblBreak:function(t){var e=!!t&&t.nextSibling;if(e){var i=this.utils.removeInvisibleChars(e.textContent);return 3===e.nodeType&&""===i.trim()}},_isExitableBlock:function(t,e){return t&&t.tagName===e&&this.utils.isEmptyHtml(t.innerHTML)},_exitFromElement:function(t,e,i){return t.preventDefault(),e&&l.dom(e).remove(),this.utils.createMarkup(i),!0},_exitNextElement:function(t,e){return t.preventDefault(),e.nextSibling?this.caret.setStart(e.nextSibling):this.utils.createMarkup(e),!0},_traverse:function(t){var e=this.selection.getCurrent(),i=this.selection.isText(),s=this.selection.getBlock(),n=this.inspector.parse(e),r=!!s&&s.tagName.toLowerCase(),o=l.dom(e).closest("[data-redactor-type=variable]");if(0!==o.length&&this.caret.setAfter(o),n.isPre())return t.preventDefault(),this.insertion.insertNewline();if(!n.isBlockquote()){if(n.isFigcaption()){s=n.getFigcaption();var a=this.caret.isEnd(s),h=this.caret.isEnd();return a||h?this._exitNextElement(t,n.getComponent()):void t.preventDefault()}if(n.isDl())return t.preventDefault(),this._traverseDl(e);if(this.opts.breakline&&"div"===r)return void setTimeout(this._replaceBlock.bind(this),1);if(i)return t.preventDefault(),this.insertion.insertBreakLine();if(n.isList())return;var c=this.detector.isDesktop()?50:1;return void setTimeout(this._replaceBlock.bind(this),c)}return s=this.selection.getBlock(e),s&&"BLOCKQUOTE"===s.tagName?(t.preventDefault(),this.insertion.insertBreakLine()):void 0},_traverseDl:function(t){var e=this.selection.getBlock(t),i=this.inspector.parse(e),s=i.getTag(),n=l.dom(e),r=n.get().nextSibling||!1,o=l.dom(r),a=r&&o.is("dd"),h=r&&o.is("dt"),c=this.caret.isEnd(e);if("dt"===s&&!a&&c){var d=document.createElement("dd");return n.after(d),void this.caret.setStart(d)}if("dd"===s&&!h&&c){ var u=document.createElement("dt");return n.after(u),void this.caret.setStart(u)}return this.insertion.insertBreakLine()},_replaceBlock:function(){var t=this.selection.getBlock(),e=l.dom(t);if("p"===this.opts.markup&&t&&this._isNeedToReplaceBlock(t)){var i=document.createElement(this.opts.markup);e.replaceWith(i),this.caret.setStart(i)}else if(t)if(this.utils.isEmptyHtml(t.innerHTML))this._clearBlock(e,t);else{var s=this.utils.getFirstNode(t);s&&"BR"===s.tagName&&(l.dom(s).remove(),this.caret.setStart(t))}e.removeAttr("id"),t&&this._isNeedToCleanBlockStyle(t)&&this.opts.cleanOnEnter&&e.removeAttr("class style"),this.opts.breakline&&t&&"DIV"===t.tagName},_clearBlock:function(t,e){"DIV"===e.tagName&&t.find("br").remove(),(this.opts.cleanInlineOnEnter||"<br>"===e.innerHTML)&&t.html(""),this.caret.setStart(e)},_isNeedToReplaceBlock:function(t){return"DIV"===t.tagName&&this.utils.isEmptyHtml(t.innerHTML)},_isNeedToCleanBlockStyle:function(t){return"P"===t.tagName&&this.utils.isEmptyHtml(t.innerHTML)}}),l.add("class","input.paste",{init:function(t,e,i,s,n){this.app=t,this.opts=t.opts,this.editor=t.editor,this.cleaner=t.cleaner,this.container=t.container,this.inspector=t.inspector,this.insertion=t.insertion,this.selection=t.selection,this.autoparser=t.autoparser,this.pasteHtml=s,this.pointInserted=n,this.dataTransfer=i,this._init(e)},_init:function(t){var e=this.dataTransfer||t.clipboardData,i=this.selection.getCurrent(),s=this.inspector.parse(i);if(this.dropPasted=this.dataTransfer,this.isRawCode=s.isPre()||s.isCode(),this.editor.enablePasting(),this.editor.saveScroll(),this.dropPasted||this.selection.saveMarkers(),this.isRawCode||!e){var n;return n=this.isRawCode||e||!window.clipboardData?e.getData("text/plain"):window.clipboardData.getData("text"),t.preventDefault(),void this._insert(t,n)}if(this.pasteHtml)t.preventDefault(),this._insert(t,this.pasteHtml);else{var r=e.getData("URL"),o=this._isPlainText(e)?this.cleaner.encodeEntities(e.getData("text/plain")):e.getData("text/html");if(o=r&&""!==r?r:o,null!==e.files&&e.files.length>0&&""===o){for(var a=[],l=0;l<e.files.length;l++){var h=e.files[l]||e.items[l].getAsFile();h&&a.push(h)}if(a.length>0)return t.preventDefault(),void this._insertFiles(t,a)}t.preventDefault(),this._insert(t,o)}},_isPlainText:function(t){var e=t.getData("text/plain"),i=t.getData("text/html");if(!e||!i)return null!==e;var s=document.createElement("div");return s.innerHTML=i,s.textContent===e?!s.querySelector(":not(meta)"):void 0},_restoreSelection:function(){this.editor.restoreScroll(),this.editor.disablePasting(),this.dropPasted||this.selection.restoreMarkers()},_insert:function(t,e){var i=this.app.broadcast("pasteBefore",e);if(e=void 0===i?e:i,e=e.trim(),e=this.isRawCode?e:this.cleaner.paste(e),e=e.trim(),e=this.isRawCode?this.cleaner.encodePhpCode(e):e,i=this.app.broadcast("pasting",e),e=void 0===i?e:i,this._restoreSelection(),this.opts.input){this.app.broadcast("state",!1);var s=[];if(this.isRawCode){e=e.replace("<?php","<?php");var n=document.createTextNode(e);s=this.insertion.insertNode(n,"after"),this.app.broadcast("pasted",s)}else this.opts.autoparse&&this.opts.autoparsePaste&&(e=this.autoparser.parse(e)),s=this.dropPasted?this.insertion.insertToPoint(t,e,this.pointInserted):this.insertion.insertHtml(e),this.app.broadcast("pasted",s),this.app.broadcast("autoparseobserve")}},_insertFiles:function(t,e){this._restoreSelection();var i=this.opts.imageTypes.indexOf(e[0].type)!==-1,s="undefined"==typeof this.dropPasted;i?this.app.broadcast("dropimage",t,e,s):this.app.broadcast("dropfile",t,e,s)}}),l.add("class","input.shortcode",{init:function(t,e,i){this.app=t,this.opts=t.opts,this.utils=t.utils,this.marker=t.marker,this.keycodes=t.keycodes,this.selection=t.selection,this.worked=!1,i===this.keycodes.SPACE&&this._init()},is:function(){return this.worked},_init:function(){var t=this.selection.getCurrent();if(t&&3===t.nodeType){var e=this.utils.removeInvisibleChars(t.textContent),i=this.opts.shortcodes;for(var s in i){var n=new RegExp("^"+this.utils.escapeRegExp(s)),r=e.match(n);if(null!==r&&"undefined"!=typeof i[s].format)return this._format(i[s].format,t,n)}}},_format:function(t,e,i){var s=this.marker.insert("start");e=s.previousSibling;var n=e.textContent;n=this.utils.trimSpaces(n),n=n.replace(i,""),e.textContent=n;var r="ul"===t||"ol"===t?"module.list.toggle":"module.block.format";this.app.api(r,t),this.selection.restoreMarkers(),this.worked=!0}}),l.add("class","input.shortcut",{init:function(t,e){this.app=t,this.opts=t.opts,this.worked=!1,this.hotkeys={8:"backspace",9:"tab",10:"return",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",59:";",61:"=",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},this.hotkeysShiftNums={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"},this._init(e)},is:function(){return this.worked},_init:function(t){if(this.opts.shortcuts===!1)return void(!t.ctrlKey&&!t.metaKey||66!==t.which&&73!==t.which||t.preventDefault());for(var e in this.opts.shortcuts)this._build(t,e,this.opts.shortcuts[e])},_build:function(t,e,i){for(var s=e.split(","),n=s.length,r=0;r<n;r++)"string"==typeof s[r]&&this._handler(t,s[r].trim(),i)},_handler:function(t,e,i){e=e.toLowerCase().split(" ");for(var s=this.hotkeys[t.keyCode],n=String.fromCharCode(t.which).toLowerCase(),r="",o={},a=["meta","ctrl","alt","shift"],l=0;l<a.length;l++){var h=a[l];t[h+"Key"]&&s!==h&&(r+=h+"+")}s&&(o[r+s]=!0),n&&(o[r+n]=!0,o[r+this.hotkeysShiftNums[n]]=!0,"shift+"===r&&(o[this.hotkeysShiftNums[n]]=!0));for(var c=e.length,l=0;l<c;l++)if(o[e[l]])return t.preventDefault(),this.worked=!0,void(i.message?(this.app.broadcast(i.message,i.args),this.app.broadcast("buffer.trigger")):i.api&&(this.app.api(i.api,i.args),this.app.broadcast("buffer.trigger")))}}),l.add("class","input.space",{init:function(t,e,i,s){this.app=t,this.keycodes=t.keycodes,this.insertion=t.insertion,this.selection=t.selection,this.key=i,this.lastShiftKey=s,this._init(e)},_init:function(t){return this.selection.hasNonEditable()?void t.preventDefault():this.lastShiftKey||this.key!==this.keycodes.SPACE||!t.ctrlKey&&!t.shiftKey||t.metaKey?void 0:(t.preventDefault(),void this.insertion.insertChar(" "))}}),l.add("class","input.tab",{init:function(t,e){this.app=t,this.opts=t.opts,this.inspector=t.inspector,this.insertion=t.insertion,this.selection=t.selection,this._init(e)},_init:function(t){if(this.opts.tabKey){var e=this.app.broadcast("tab",t);return e===!1?t.preventDefault():void this._traverse(t)}},_traverse:function(t){var e=this.selection.getCurrent(),i=this.inspector.parse(e);return!i.isComponent()&&t.shiftKey?this._insertHardTab(t,4):i.isList()?(t.preventDefault(),this.app.api("module.list.indent")):i.isPre()||i.isComponentType("code")&&!i.isFigcaption()?this._tabCode(t):this.opts.tabAsSpaces!==!1?this._insertHardTab(t,this.opts.tabAsSpaces):void 0},_insertHardTab:function(t,e){t.preventDefault();var i=document.createTextNode(Array(e+1).join(" "));return this.insertion.insertNode(i,"end")},_tabCode:function(t){t.preventDefault();var e=this.opts.preSpaces?document.createTextNode(Array(this.opts.preSpaces+1).join(" ")):document.createTextNode("\t");return this.insertion.insertNode(e,"end")}}),l.add("module","upload",{init:function(t){this.app=t,this.opts=t.opts,this.lang=t.lang,this.utils=t.utils,this.editor=t.editor,this.progress=t.progress,this.defaults={event:!1,element:!1,name:!1,files:!1,url:!1,data:!1,paramName:!1}},build:function(t){this.p=l.extend(this.defaults,t),this.$el=l.dom(this.p.element),"INPUT"===this.$el.get().tagName?this._buildInput():this._buildBox()},send:function(t){this.p=l.extend(this.defaults,t),this.$uploadbox=this.editor.getElement(),this._send(this.p.event,this.p.files)},complete:function(t,e){this._complete(t,e)},_buildInput:function(){this.box=!1,this.prefix="",this.$uploadbox=l.dom('<div class="upload-redactor-box" />'),this.$el.hide(),this.$el.after(this.$uploadbox),this.opts.multipleUpload?this.$el.attr("multiple","multiple"):this.$el.removeAttr("multiple"),"file"!==this.p.name&&this.$el.attr("accept","image/*"),this._buildPlaceholder(),this._buildEvents()},_buildBox:function(){this.box=!0,this.prefix="box-",this.$uploadbox=this.$el,this.$uploadbox.attr("ondragstart","return false;"),this.$uploadbox.on("drop.redactor.upload",this._onDropBox.bind(this)),this.$uploadbox.on("dragover.redactor.upload",this._onDragOver.bind(this)),this.$uploadbox.on("dragleave.redactor.upload",this._onDragLeave.bind(this))},_buildPlaceholder:function(){this.$placeholder=l.dom('<div class="upload-redactor-placeholder" />'),this.$placeholder.html(this.lang.get("upload-label")),this.$uploadbox.append(this.$placeholder)},_buildEvents:function(){this.$el.on("change.redactor.upload",this._onChange.bind(this)),this.$uploadbox.on("click.redactor.upload",this._onClick.bind(this)),this.$uploadbox.on("drop.redactor.upload",this._onDrop.bind(this)),this.$uploadbox.on("dragover.redactor.upload",this._onDragOver.bind(this)),this.$uploadbox.on("dragleave.redactor.upload",this._onDragLeave.bind(this))},_onClick:function(t){t.preventDefault(),this.$el.click()},_onChange:function(t){this._send(t,this.$el.get().files)},_onDrop:function(t){t.preventDefault(),this._clear(),this._setStatusDrop(),this._send(t)},_onDragOver:function(t){return t.preventDefault(),this._setStatusHover(),!1},_onDragLeave:function(t){return t.preventDefault(),this._removeStatusHover(),!1},_onDropBox:function(t){t.preventDefault(),this._clear(),this._setStatusDrop(),this._send(t)},_removeStatusHover:function(){this.$uploadbox.removeClass("upload-redactor-"+this.prefix+"hover")},_setStatusDrop:function(){this.$uploadbox.addClass("upload-redactor-"+this.prefix+"drop")},_setStatusHover:function(){this.$uploadbox.addClass("upload-redactor-"+this.prefix+"hover")},_setStatusError:function(){this.$uploadbox.addClass("upload-redactor-"+this.prefix+"error")},_setStatusSuccess:function(){this.$uploadbox.addClass("upload-redactor-"+this.prefix+"success")},_clear:function(){for(var t=["drop","hover","error","success"],e=0;e<t.length;e++)this.$uploadbox.removeClass("upload-redactor-"+this.prefix+t[e]);this.$uploadbox.removeAttr("ondragstart")},_send:function(t,e){t=t.originalEvent||t,e=e?e:t.dataTransfer.files;var i=new FormData,s=this._getUploadParam();i=this._buildData(s,e,i),i=this.utils.extendData(i,this.p.data);var n=this.app.broadcast("upload.start",t,i,e);n!==!1&&this._sendData(i,e,t)},_sendData:function(t,e,i){if(this.progress.show(),"function"==typeof this.p.url){var s=this.p.url(t,e,i,this);s instanceof Promise||this._complete(s,i)}else l.ajax.post({url:this.p.url,data:t,before:function(t){return this.app.broadcast("upload.beforeSend",t)}.bind(this),success:function(t){this._complete(t,i)}.bind(this),error:function(t,e,s){this._complete(t,i,s)}.bind(this)})},_getUploadParam:function(){return this.p.paramName?this.p.paramName:"file"},_buildData:function(t,e,i){if(1===e.length)i.append(t,e[0]);else if(e.length>1&&this.opts.multipleUpload!==!1)for(var s=0;s<e.length;s++)i.append(t+"[]",e[s]);return i},_complete:function(t,e,i){this._clear(),this.progress.hide(),t&&t.error?(this._setStatusError(),this.app.broadcast("upload."+this.p.name+".error",t,e,i),this.app.broadcast("upload.error",t,i)):(this._setStatusSuccess(),this.app.broadcast("upload."+this.p.name+".complete",t,e),this.app.broadcast("upload.complete",t),setTimeout(this._clear.bind(this),500))}}),l.add("class","code.component",{mixins:["dom","component"],init:function(t,e){return this.app=t,e&&void 0!==e.cmnt?e:this._init(e)},_init:function(t){var e;if("undefined"!=typeof t){var i=l.dom(t),s=i.closest("figure");0!==s.length?this.parse(s):(this.parse("<figure>"),this.append(t)),e=this.find("pre code, pre").last()}else e=l.dom("<pre>"),this.parse("<figure>"),this.append(e);this._initElement(e),this._initWrapper()},_initElement:function(t){t.attr({tabindex:"-1",contenteditable:!0})},_initWrapper:function(){this.addClass("redactor-component"),this.attr({"data-redactor-type":"code",tabindex:"-1",contenteditable:!1})}}),l.add("module","form",{init:function(t){this.app=t,this.lang=t.lang,this.component=t.component,this.inspector=t.inspector},onform:{remove:function(t){this._remove(t)}},oncontextbar:function(t,e){var i=this.inspector.parse(t.target);if(i.isComponentType("form")){var s=i.getComponent(),n={remove:{title:this.lang.get("delete"),api:"module.form.remove",args:s}};e.set(t,s,n,"top")}},_remove:function(t){this.component.remove(t)}}),l.add("class","form.component",{mixins:["dom","component"],init:function(t,e){return this.app=t,this.utils=t.utils,e&&void 0!==e.cmnt?e:this._init(e)},_init:function(t){if("undefined"!=typeof t){var e=l.dom(t),i=e.closest("form");if(0!==i.length){var s=this.utils.replaceToTag(t,"figure");this.parse(s)}else this.parse("<figure>"),this.append(t)}else this.parse("<figure>");this._initWrapper()},_initWrapper:function(){this.addClass("redactor-component"),this.attr({"data-redactor-type":"form",tabindex:"-1",contenteditable:!1})}}),l.add("module","image",{modals:{image:'<div class="redactor-modal-tab redactor-modal-tab-upload" data-title="## upload ##"><form action=""> <input type="file" name="file"> </form></div>',imageedit:'<div class="redactor-modal-group"> <div id="redactor-modal-image-preview" class="redactor-modal-side"></div> <form action="" class="redactor-modal-area"> <div class="form-item"> <label for="modal-image-title"> ## title ##</label> <input type="text" id="modal-image-title" name="title" /> </div> <div class="form-item form-item-caption"> <label for="modal-image-caption">## caption ##</label> <input type="text" id="modal-image-caption" name="caption" aria-label="## caption ##" /> </div> <div class="form-item form-item-align"> <label>## image-position ##</label> <select name="align" aria-label="## image-position ##"> <option value="none">## none ##</option> <option value="left">## left ##</option> <option value="center">## center ##</option> <option value="right">## right ##</option> </select> </div> <div class="form-item form-item-link"> <label for="modal-image-url">## link ##</label> <input type="text" id="modal-image-url" name="url" aria-label="## link ##" /> </div> <div class="form-item form-item-link"> <label class="checkbox-label"> <div class="checkbox-label__text" style="padding-left: 20px;">## link-in-new-tab ##</div> <input type="checkbox" class="checkbox" name="target"> </label> </div> </form> </div>'},init:function(t){this.app=t,this.opts=t.opts,this.lang=t.lang,this.caret=t.caret,this.utils=t.utils,this.editor=t.editor,this.storage=t.storage,this.component=t.component,this.inspector=t.inspector,this.insertion=t.insertion,this.selection=t.selection,this.justResized=!1},oninsert:function(){this._observeImages()},onstarted:function(){this.storage.observeImages(),this.opts.imageResizable&&(this.resizer=l.create("image.resize",this.app)),this._observeImages()},ondropimage:function(t,e,i){if(this.opts.imageUpload){var s={url:this.opts.imageUpload,event:!i&&t,files:e,name:"imagedrop",data:this.opts.imageData,paramName:this.opts.imageUploadParam};this.app.api("module.upload.send",s)}},onstop:function(){this.resizer&&this.resizer.stop()},onbottomclick:function(){this.insertion.insertToEnd(this.editor.getLastNode(),"image")},onimageresizer:{stop:function(){this.resizer&&this.resizer.hide()}},onsource:{open:function(){this.resizer&&this.resizer.hide()},closed:function(){this._observeImages(),this.resizer&&this.resizer.rebuild()}},onupload:{complete:function(){this._observeImages()},image:{complete:function(t){this._insert(t),this.app.broadcast("state",!1)},error:function(t){this._uploadError(t)}},imageedit:{complete:function(t){this._change(t)},error:function(t){this._uploadError(t)}},imagedrop:{complete:function(t,e){this._insert(t,e)},error:function(t){this._uploadError(t)}},imagereplace:{complete:function(t){this._change(t,!1)},error:function(t){this._uploadError(t)}}},onmodal:{image:{open:function(t,e){this._setUpload(t,e)}},imageedit:{open:function(t,e){this._setFormData(t,e)},opened:function(t,e){this._setFormFocus(e)},remove:function(){this._remove(this.$image)},save:function(t,e){this._save(t,e)}}},onimage:{observe:function(){this._observeImages()},resized:function(){this.justResized=!0}},oncontextbar:function(t,e){if(this.justResized)return void(this.justResized=!1);var i=this.selection.getCurrent(),s=this.inspector.parse(i),n=l.dom(i).closest("img");if(!s.isFigcaption()&&s.isComponentType("image")||0!==n.length){var r=0!==n.length?n.get():s.getComponent(),o={edit:{title:this.lang.get("edit"),api:"module.image.open"},remove:{title:this.lang.get("delete"),api:"module.image.remove",args:r}};e.set(t,r,o)}},open:function(){this.$image=this._getCurrent(),this.app.api("module.modal.build",this._getModalData())},insert:function(t){this._insert(t)},remove:function(t){this._remove(t)},_getModalData:function(){var t;return t=this._isImage()&&this.opts.imageEditable?{name:"imageedit",width:"800px",title:this.lang.get("edit"),handle:"save",commands:{save:{title:this.lang.get("save")},remove:{title:this.lang.get("delete"),type:"danger"},cancel:{title:this.lang.get("cancel")}}}:{name:"image",title:this.lang.get("image")}},_isImage:function(){return this.$image},_getCurrent:function(){var t=this.selection.getCurrent(),e=this.inspector.parse(t),i=l.dom(t).closest("img");return 0!==i.length?this.component.create("image",i):!(!e.isComponentType("image")||!e.isComponentActive())&&this.component.create("image",e.getComponent())},_insert:function(t,e){if(this.app.api("module.modal.close"),Array.isArray(t)){for(var i={},s=0;s<t.length;s++)i=l.extend(i,t[s]);t=i}else"string"==typeof t&&(t={file:{url:t}});if("object"==typeof t){var n=0;for(var r in t)"object"==typeof t[r]&&n++;n>1?this._insertMultiple(t,e):this._insertSingle(t,e)}},_insertSingle:function(t,e){for(var i in t)if("object"==typeof t[i]){var s=this._createImageAndStore(t[i]),n=e?this.insertion.insertToPoint(e,s,!1,!1):this.insertion.insertHtml(s,!1);this._removeSpaceBeforeFigure(n[0]),this.component.setActive(n[0]),this.app.broadcast("image.uploaded",n[0],t)}},_insertMultiple:function(t,e){var i,s=0,n=[];for(var r in t)if("object"==typeof t[r]){s++;var o=this._createImageAndStore(t[r]);if(1===s)n=e?this.insertion.insertToPoint(e,o,!1,!1):this.insertion.insertHtml(o,!1);else{var a=l.dom(n[0]);a.after(o),n=[o.get()],this.app.broadcast("image.inserted",o)}i=n[0],this._removeSpaceBeforeFigure(n[0]),this.app.broadcast("image.uploaded",n[0],t)}this.component.setActive(i)},_createImageAndStore:function(t){var e=this.component.create("image");return e.addClass("redactor-uploaded-figure"),e.setData({src:t.url,id:t.id?t.id:this.utils.getRandomId()}),this.storage.add("image",e.getElement()),e},_removeSpaceBeforeFigure:function(t){if(t){var e=t.previousSibling,i=t.nextSibling,s=l.dom(e),n=l.dom(i);this.opts.breakline&&(i&&"br"===n.attr("data-redactor-tag")&&n.find("br").first().remove(),e&&"br"===s.attr("data-redactor-tag")&&s.find("br").last().remove()),e&&(this._removeInvisibleSpace(e),this._removeInvisibleSpace(e.previousSibling))}},_removeInvisibleSpace:function(t){t&&3===t.nodeType&&this.utils.searchInvisibleChars(t.textContent)!==-1&&t.parentNode.removeChild(t)},_save:function(t,e){var i=e.getData(),s={title:i.title};this.opts.imageLink&&(s.link={url:i.url,target:i.target}),this.opts.imageCaption&&(s.caption=i.caption),this.opts.imagePosition&&(s.align=i.align),this.$image.setData(s),this.resizer&&this.resizer.rebuild(),this.app.broadcast("image.changed",this.$image),this.app.api("module.modal.close")},_change:function(t,e){if("string"==typeof t&&(t={file:{url:t}}),"object"==typeof t){var i;for(var s in t)if("object"==typeof t[s]){i=l.dom("<img>"),i.attr("src",t[s].url),this.$image.changeImage(t[s]),this.app.broadcast("image.changed",this.$image,t),this.app.broadcast("image.uploaded",this.$image,t),this.app.broadcast("hardsync");break}e!==!1&&i.on("load",function(){this.$previewBox.html(i)}.bind(this))}},_uploadError:function(t){this.app.broadcast("image.uploadError",t)},_remove:function(t){this.app.api("module.modal.close"),this.component.remove(t)},_observeImages:function(){var t=this.editor.getElement(),e=this;t.find("img").each(function(t){var i=l.dom(t);i.off(".drop-to-replace"),i.on("dragover.drop-to-replace dragenter.drop-to-replace",function(t){t.preventDefault()}),i.on("drop.drop-to-replace",function(t){if(!e.app.isDragComponentInside())return e._setReplaceUpload(t,i)})})},_setFormData:function(t,e){this._buildPreview(t),this._buildPreviewUpload();var i=this.$image.getData(),s={title:i.title};this.opts.imageCaption?s.caption=i.caption:t.find(".form-item-caption").hide(),this.opts.imagePosition?s.align=i.align:t.find(".form-item-align").hide(),this.opts.imageLink?i.link&&(s.url=i.link.url,i.link.target&&(s.target=!0)):t.find(".form-item-link").hide(),e.setData(s)},_setFormFocus:function(t){t.getField("title").focus()},_setReplaceUpload:function(t,e){if(t=t.originalEvent||t,t.stopPropagation(),t.preventDefault(),this.opts.imageUpload){this.$image=this.component.create("image",e);var i={url:this.opts.imageUpload,files:t.dataTransfer.files,name:"imagereplace",data:this.opts.imageData,paramName:this.opts.imageUploadParam};this.app.api("module.upload.send",i)}},_setUpload:function(t,e){if(!this.opts.imageUpload){var i=t.getBody(),s=i.find(".redactor-modal-tab-upload");s.remove()}var n={url:this.opts.imageUpload,element:e.getField("file"),name:"image",data:this.opts.imageData,paramName:this.opts.imageUploadParam};this.app.api("module.upload.build",n)},_buildPreview:function(t){this.$preview=t.find("#redactor-modal-image-preview");var e=this.$image.getData(),i=l.dom("<img>");i.attr("src",e.src),this.$previewBox=l.dom("<div>"),this.$previewBox.append(i),this.$preview.html(""),this.$preview.append(this.$previewBox)},_buildPreviewUpload:function(){if(this.opts.imageUpload){var t=l.dom('<div class="desc">');t.html(this.lang.get("upload-change-label")),this.$preview.append(t);var e={url:this.opts.imageUpload,element:this.$previewBox,name:"imageedit",data:this.opts.imageData,paramName:this.opts.imageUploadParam};this.app.api("module.upload.build",e)}}}),l.add("class","image.component",{mixins:["dom","component"],init:function(t,e){return this.app=t,this.opts=t.opts,this.selection=t.selection,e&&void 0!==e.cmnt?e:this._init(e)},setData:function(t){for(var e in t)this._set(e,t[e])},getData:function(){for(var t=["src","title","caption","align","link","id"],e={},i=0;i<t.length;i++)e[t[i]]=this._get(t[i]);return e},getElement:function(){return this.$element},changeImage:function(t){this.$element.attr("src",t.url)},_init:function(t){var e=l.dom(t),i=e.closest("figure");void 0===t?(this.$element=l.dom("<img>"),this.parse("<figure>"),this.append(this.$element)):0===i.length?(this.parse("<figure>"),this.$element=e,this.$element.wrap(this)):(this.parse(i),this.$element=this.find("img")),this._initWrapper()},_set:function(t,e){this["_set_"+t](e)},_get:function(t){return this["_get_"+t]()},_set_src:function(t){this.$element.attr("src",t)},_set_id:function(t){this.opts.imageObserve&&this.$element.attr("data-image",t)},_set_title:function(t){t=t.trim().replace(/(<([^>]+)>)/gi,""),""===t?this.$element.removeAttr("alt"):this.$element.attr("alt",t)},_set_caption:function(t){var e=this.find("figcaption");return 0===e.length&&(e=l.dom("<figcaption>"),e.attr("contenteditable","true"),this.append(e)),""===t?e.remove():e.html(t),e},_set_align:function(t){var e="",i="",s="",n=this,r=this.find("img"),o=this.find("figcaption");if("object"==typeof this.opts.imagePosition){var a=this.opts.imagePosition;for(var l in a)n.removeClass(a[l]);var h="undefined"!=typeof a[t]&&a[t];h&&n.addClass(h)}else{var c=r.width();switch(t){case"left":e="left",i=this.opts.imageFloatMargin;break;case"right":e="right",i=this.opts.imageFloatMargin;break;case"center":s="center",i="auto"}n.css({"float":e,width:c+"px",maxWidth:c+"px","margin-left":i,"margin-right":i,"text-align":s}),n.attr("rel",n.attr("style")),"none"===t&&(n.css("max-width",""),n.css("width","")),"center"===t?(n.css("max-width",""),n.css("width",""),o.css("text-align","center")):o.css("text-align","")}},_set_link:function(t){var e=this._findLink();return""===t.url?void(e&&e.unwrap()):(e||(e=l.dom("<a>"),this.$element.wrap(e)),e.attr("href",t.url),t.target?e.attr("target",t.target===!0?"_blank":t.target):e.removeAttr("target"),e)},_get_src:function(){return this.$element.attr("src")},_get_id:function(){return this.$element.attr("data-image")},_get_title:function(){var t=this.$element.attr("alt");return t?t:""},_get_caption:function(){var t=this.find("figcaption");return 0===t.length?"":t.html()},_get_align:function(){var t="";if("object"==typeof this.opts.imagePosition){t="none";var e=this.opts.imagePosition;for(var i in e)if(this.hasClass(e[i])){t=i;break}}else t="center"===this.css("text-align")?"center":this.css("float");return t},_get_link:function(){var t=this._findLink();if(t){var e=!!t.attr("target");return{url:t.attr("href"),target:e}}},_initWrapper:function(){this.addClass("redactor-component"),this.attr({"data-redactor-type":"image",tabindex:"-1",contenteditable:!1})},_findLink:function(){var t=this.find("a").filter(function(t){return 0===l.dom(t).closest("figcaption").length});return 0!==t.length&&t}}),l.add("class","image.resize",{init:function(t){this.app=t,this.$doc=t.$doc,this.$win=t.$win,this.$body=t.$body,this.editor=t.editor,this.toolbar=t.toolbar,this.inspector=t.inspector,this.$target=this.toolbar.isTarget()?this.toolbar.getTargetElement():this.$body,this._init()},rebuild:function(){this._setResizerPosition()},hide:function(){this.$target.find("#redactor-image-resizer").remove()},stop:function(){var t=this.editor.getElement();t.off(".redactor.image-resize"),this.$doc.off(".redactor.image-resize"),this.$win.off("resize.redactor.image-resize"),this.hide()},_init:function(){var t=this.editor.getElement();t.on("click.redactor.image-resize",this._build.bind(this)),this.$win.on("resize.redactor.image-resize",this._setResizerPosition.bind(this))},_build:function(t){if(this.$target.find("#redactor-image-resizer").remove(),!this.app.isReadOnly()){var e=this.inspector.parse(t.target),i=this.editor.getElement();e.isComponentType("image")&&(this.$resizableBox=i,this.$resizableImage=l.dom(e.getImageElement()),this.$resizer=l.dom("<span>"),this.$resizer.attr("id","redactor-image-resizer"),this.$target.append(this.$resizer),this._setResizerPosition(),this.$resizer.on("mousedown touchstart",this._set.bind(this)))}},_setResizerPosition:function(){if(this.$resizer){var t=this.toolbar.isTarget(),e=this.$target.offset(),i=7,s=t?i-e.top+this.$target.scrollTop():i,n=t?i-e.left:i,r=this.$resizableImage.offset(),o=this.$resizableImage.width(),a=this.$resizableImage.height(),l=this.$resizer.width(),h=this.$resizer.height();this.$resizer.css({top:Math.round(r.top+a-h+s)+"px",left:Math.round(r.left+o-l+n)+"px"})}},_set:function(t){t.preventDefault(),this.resizeHandle={x:t.pageX,y:t.pageY,el:this.$resizableImage,$figure:this.$resizableImage.closest("figure"),ratio:this.$resizableImage.width()/this.$resizableImage.height(),h:this.$resizableImage.height()},t=t.originalEvent||t,t.targetTouches&&(this.resizeHandle.x=t.targetTouches[0].pageX,this.resizeHandle.y=t.targetTouches[0].pageY),this.app.broadcast("contextbar.close"),this.app.broadcast("image.resize",this.$resizableImage),this._start()},_start:function(){this.$doc.on("mousemove.redactor.image-resize touchmove.redactor.image-resize",this._move.bind(this)),this.$doc.on("mouseup.redactor.image-resize touchend.redactor.image-resize",this._stop.bind(this))},_stop:function(){this.$doc.off(".redactor.image-resize"),this.app.broadcast("image.resized",this.$resizableImage)},_move:function(t){t.preventDefault(),t=t.originalEvent||t;var e=this.resizeHandle.h;e+=t.targetTouches?t.targetTouches[0].pageY-this.resizeHandle.y:t.pageY-this.resizeHandle.y;var i=e*this.resizeHandle.ratio;i=Math.round(i),e=Math.round(e),e<20||i<100||this._getResizableBoxWidth()<=i||(0!==this.resizeHandle.$figure.length&&""!==this.resizeHandle.$figure.css("max-width")&&this.resizeHandle.$figure.css({width:i+"px","max-width":i+"px"}),this.resizeHandle.el.attr({width:i,height:e}),this.resizeHandle.el.width(i),this.resizeHandle.el.css("max-width",i+"px"),this.resizeHandle.el.height(e),this._setResizerPosition())},_getResizableBoxWidth:function(){var t=this.$resizableBox.width();return t-parseInt(this.$resizableBox.css("padding-left"))-parseInt(this.$resizableBox.css("padding-right"))}}),l.add("module","file",{modals:{file:'<div class="redactor-modal-tab" data-title="## upload ##"><form action=""> <div class="form-item form-item-title"> <label for="modal-file-title"> ## filename ## <span class="desc">(## optional ##)</span></label> <input type="text" id="modal-file-title" name="title" /> </div> <input type="file" name="file"> </form></div>'},init:function(t){this.app=t,this.opts=t.opts,this.lang=t.lang,this.caret=t.caret,this.utils=t.utils,this.storage=t.storage,this.component=t.component,this.inspector=t.inspector,this.insertion=t.insertion,this.selection=t.selection},onstarted:function(){this.storage.observeFiles()},ondropfile:function(t,e,i){if(this.opts.fileUpload){var s={url:this.opts.fileUpload,event:!i&&t,files:e,name:"filedrop",data:this.opts.fileData};this.app.api("module.upload.send",s)}},onmodal:{file:{open:function(t,e){this._setFormData(t,e),this._setUpload(e)},opened:function(t,e){this._setFormFocus(e),this.$form=e}}},onupload:{file:{complete:function(t){this._insert(t)},error:function(t){this._uploadError(t)}},filedrop:{complete:function(t,e){this._insert(t,e)},error:function(t){this._uploadError(t)}}},open:function(){this._open()},insert:function(t){this._insert(t)},remove:function(t){this._remove(t)},_open:function(){this.app.api("module.modal.build",this._getModalData())},_getModalData:function(){var t={name:"file",title:this.lang.get("file")};return t},_insert:function(t,e){if(this.app.api("module.modal.close"),"object"==typeof t){if(Array.isArray(t)){for(var i={},s=0;s<t.length;s++)i=l.extend(i,t[s]);t=i}var n=Object.keys(t).length>1;n?this._insertMultiple(t,e):this._insertSingle(t,e),this.$form=!1}},_insertSingle:function(t,e){var i=[];for(var s in t){var n=this._createFileAndStore(t[s]);i=this.opts.fileAttachment?this._insertAsAttachment(n):e?this.insertion.insertToPoint(e,n):this.insertion.insertRaw(n),this.app.broadcast("file.uploaded",i[0],t)}},_insertMultiple:function(t,e){var i,s=0,n=[];for(var r in t){s++;var o=this._createFileAndStore(t[r]);if(this.opts.fileAttachment)n=this._insertAsAttachment(o,t);else if(1===s)n=e?this.insertion.insertToPoint(e,o):this.insertion.insertRaw(o);else{ var a=l.dom(n[0]);a.after(o).after(" "),n=[o.get()],this.app.broadcast("file.inserted",o)}i=o,this.app.broadcast("file.uploaded",n[0],t)}this.opts.fileAttachment||this.caret.setAfter(i)},_insertAsAttachment:function(t,e){var i=l.dom(this.opts.fileAttachment),s=t.wrapAttachment();i.append(s);var n=[s.get()];return this.app.broadcast("file.appended",n[0],e),n},_createFileAndStore:function(t){var e=!!this.$form&&this.$form.getData(),i=t.name?t.name:t.url,s=!this.opts.fileAttachment&&e&&""!==e.title?e.title:this._truncateUrl(i),n=this.component.create("file");return n.attr("href",t.url),n.attr("data-file",t.id?t.id:this.utils.getRandomId()),n.attr("data-name",t.name),n.html(s),this.storage.add("file",n),n},_remove:function(t){this.selection.save();var e=this.component.create("file",t),i=this.app.broadcast("file.delete",e);i!==!1?(e.unwrap(),this.selection.restore(),this.app.broadcast("file.deleted",e)):this.selection.restore()},_truncateUrl:function(t){return t.search(/^http/)!==-1&&t.length>20?t.substring(0,20)+"...":t},_setUpload:function(t){var e={url:this.opts.fileUpload,element:t.getField("file"),name:"file",data:this.opts.fileData,paramName:this.opts.fileUploadParam};this.app.api("module.upload.build",e)},_setFormData:function(t,e){this.opts.fileAttachment?t.find(".form-item-title").hide():e.setData({title:this.selection.getText()})},_setFormFocus:function(t){t.getField("title").focus()},_uploadError:function(t){this.app.broadcast("file.uploadError",t)}}),l.add("class","file.component",{mixins:["dom","component"],init:function(t,e){return this.app=t,this.opts=t.opts,e&&void 0!==e.cmnt?e:this._init(e)},wrapAttachment:function(){return this.$wrapper=l.dom('<span class="redactor-file-item">'),this.$remover=l.dom('<span class="redactor-file-remover">'),this.$remover.html("×"),this.$remover.on("click",this.removeAttachment.bind(this)),this.$wrapper.append(this),this.$wrapper.append(this.$remover),this.$wrapper},removeAttachment:function(t){t.preventDefault();var e=this.app.broadcast("file.delete",this,this.$wrapper);e!==!1&&(this.$wrapper.remove(),this.app.broadcast("file.deleted",this),this.app.broadcast("file.removeAttachment",this))},_init:function(t){if(void 0===t)this.parse("<a>");else{var e=l.dom(t).closest("a");this.parse(e)}}}),l.add("module","buffer",{init:function(t){this.app=t,this.opts=t.opts,this.editor=t.editor,this.offset=t.offset,this.keycodes=t.keycodes,this.selection=t.selection,this.state=!1,this.passed=!1,this.keyPressed=!1,this.undoStorage=[],this.redoStorage=[]},onkeydown:function(t){this._listen(t)},onsyncing:function(){this.keyPressed||this.trigger(),this.keyPressed=!1},onbuffer:{trigger:function(){this.trigger()}},onstate:function(t,e,i){t&&(t.ctrlKey||t.metaKey)||t&&(this._isUndo(t)||this._isRedo(t))||(this.passed=!1,this._saveState(e,i),t===!1&&this._setUndo())},onenable:function(){this.clear()},clear:function(){this.state=!1,this.undoStorage=[],this.redoStorage=[]},undo:function(){this._getUndo()},redo:function(){this._getRedo()},trigger:function(){this.state&&this.passed===!1&&this._setUndo()},_saveState:function(t,e){var i=this.editor.getElement();this.state={html:t||i.html(),offset:e||this.offset.get()}},_listen:function(t){var e=t.which,i=t.ctrlKey||t.metaKey,s=i||t.shiftKey||t.altKey,n=[this.keycodes.SPACE,this.keycodes.ENTER,this.keycodes.BACKSPACE,this.keycodes.DELETE,this.keycodes.TAB,this.keycodes.LEFT,this.keycodes.RIGHT,this.keycodes.UP,this.keycodes.DOWN];return this._isUndo(t)?(t.preventDefault(),void this.undo()):this._isRedo(t)?(t.preventDefault(),void this.redo()):(i||n.indexOf(e)===-1?!i||88!==e&&67!==e||(s=!0,this.trigger()):(s=!0,this.trigger()),s||this._hasUndo()||this.trigger(),void(this.keyPressed=!0))},_isUndo:function(t){var e=t.which,i=t.ctrlKey||t.metaKey;return i&&90===e&&!t.shiftKey&&!t.altKey},_isRedo:function(t){var e=t.which,i=t.ctrlKey||t.metaKey;return i&&(90===e&&t.shiftKey||89===e&&!t.shiftKey)&&!t.altKey},_setUndo:function(){var t=this.undoStorage[this.undoStorage.length-1];"undefined"!=typeof t&&t[0]===this.state.html||(this.undoStorage.push([this.state.html,this.state.offset]),this._removeOverStorage())},_setRedo:function(){var t=this.editor.getElement(),e=this.offset.get(),i=t.html();this.redoStorage.push([i,e]),this.redoStorage=this.redoStorage.slice(0,this.opts.bufferLimit)},_getUndo:function(){if(this._hasUndo()){this.passed=!0;var t=this.editor.getElement(),e=this.undoStorage.pop();this._setRedo(),t.html(e[0]),this.offset.set(e[1]),this._saveState(e[0],e[1]),this.app.broadcast("undo",e[0],e[1])}},_getRedo:function(){if(this._hasRedo()){this.passed=!0;var t=this.editor.getElement(),e=this.redoStorage.pop();this._setUndo(),t.html(e[0]),this.offset.set(e[1]),this._saveState(e[0],e[1]),this.app.broadcast("redo",e[0],e[1])}},_removeOverStorage:function(){this.undoStorage.length>this.opts.bufferLimit&&(this.undoStorage=this.undoStorage.slice(0,this.undoStorage.length-this.opts.bufferLimit))},_hasUndo:function(){return 0!==this.undoStorage.length},_hasRedo:function(){return 0!==this.redoStorage.length}}),l.add("module","list",{init:function(t){this.app=t,this.uuid=t.uuid,this.opts=t.opts,this.utils=t.utils,this.block=t.block,this.editor=t.editor,this.toolbar=t.toolbar,this.inspector=t.inspector,this.selection=t.selection},onbutton:{list:{observe:function(t){this._observeButton(t)}}},ondropdown:{list:{observe:function(t){this._observeDropdown(t)}}},toggle:function(t){var e=this._getBlocks(),i=this.selection.getBlock(),s=l.dom(i).parents("ul, ol",this.editor.getElement()).last();return 0===e.length&&0!==s.length&&(e=[s.get()]),!i||"TD"!==i.tagName&&"TH"!==i.tagName||(e=this.block.format("div")),this.selection.saveMarkers(),e=0!==e.length&&this._isUnformat(t,e)?this._unformat(t,e):this._format(t,e),this.selection.restoreMarkers(),e},indent:function(){var t=this.selection.isCollapsed(),e=this.selection.getCurrent(),i=this.inspector.parse(e),s=!!i.isList()&&i.getListItem(),n=l.dom(s),r=n.prevElement(),o=r.get(),a=t&&s&&o&&"LI"===o.tagName;if(a){this.selection.saveMarkers(),r=l.dom(o);var h=r.children("ul, ol"),c=n.closest("ul, ol");if(0!==h.length)h.append(n);else{var d=c.get().tagName.toLowerCase(),u=l.dom("<"+d+">");u.append(n),r.append(u)}this.selection.restoreMarkers(),this.utils.isEmptyHtml(n.html())&&this.app.caret.setStart(n)}},outdent:function(){var t=this.selection.isCollapsed(),e=this.selection.getCurrent(),i=this.inspector.parse(e),s=!!i.isList()&&i.getListItem(),n=l.dom(s);if(t&&s){var r,o,a,h,c=n.parent(),d=c.closest("li",".redactor-in-"+this.uuid),u=n.prevElement(),p=n.nextElement(),f=u.get(),m=p.get(),g=f===!1,v=f!==!1&&m!==!1,b=!g&&m===!1;if(this.selection.saveMarkers(),0!==d.length)if(v){r=this._getAllNext(n.get()),a=l.dom("<"+c.get().tagName.toLowerCase()+">");for(var _=0;_<r.length;_++)a.append(r[_]);d.after(n),n.append(a)}else d.after(n),0===c.children().length?c.remove():g&&n.append(c);else{var y=this._createUnformatContainer(n),C=y.find("ul, ol").first();if(g)c.before(y);else if(b)c.after(y);else if(v){a=l.dom("<"+c.get().tagName.toLowerCase()+">"),r=this._getAllNext(n.get());for(var _=0;_<r.length;_++)a.append(r[_]);c.after(y),y.after(a)}0!==C.length&&(h=y.nextElement(),o=h.get(),o&&o.tagName===c.get().tagName?(l.dom(o).prepend(C),C.unwrap()):y.after(C)),n.remove()}this.selection.restoreMarkers()}},_getAllNext:function(t){for(var e=[];t;){var i=l.dom(t).nextElement();if(t=i.get(),!t)return e;e.push(t)}return e},_isUnformat:function(t,e){for(var i=0,s=0;s<e.length;s++)if(3!==e[s].nodeType){var n=e[s].tagName.toLowerCase();n!==t&&"figure"!==n||i++}return i===e.length},_format:function(t,e){var i=["p","div","blockquote","pre","h1","h2","h3","h4","h5","h6","ul","ol"],s=this._uniteBlocks(e,i),n=[];for(var r in s){for(var o=s[r],a=this._createList(t,s[r]),h=0;h<o.length;h++){var c;if(3===o[h].nodeType||"UL"!==o[h].tagName&&"OL"!==o[h].tagName){c=this._createListItem(o[h]);var d=c.get().lastChild;d&&"BR"===d.tagName&&l.dom(d).remove(),this.utils.normalizeTextNodes(c),a.append(c)}else{var u=l.dom(o[h]);c=u.contents(),a.append(c),this.utils.isEmpty(u)&&u.remove()}}n.push(a.get())}return n},_uniteBlocks:function(t,e){for(var i=0,s={0:[]},n=!1,r=0;r<t.length;r++){var o=l.dom(t[r]),a=o.closest("th, td");0!==a.length?(a.get()!==n&&(i++,s[i]=[]),this._isUniteBlock(t[r],e)&&s[i].push(t[r])):this._isUniteBlock(t[r],e)?s[i].push(t[r]):(i++,s[i]=[]),n=a.get()}return s},_isUniteBlock:function(t,e){return 3===t.nodeType||e.indexOf(t.tagName.toLowerCase())!==-1},_createList:function(t,e){var i=e[e.length-1],s=l.dom(i),n=l.dom("<"+t+">");return s.after(n),n},_createListItem:function(t){var e=l.dom("<li>");if(3===t.nodeType)e.append(t);else{var i=l.dom(t);e.append(i.contents()),i.remove()}return e},_unformat:function(t,e){if(1===e.length){var i=l.dom(e[0]),s=i.find("li"),n=this.selection.getNodes({tags:["li"]}),r=this.selection.getBlock(),o=l.dom(r).closest("li");if(0===n.length&&0!==o.length&&(n=[o.get()]),n.length===s.length)return this._unformatEntire(e[0]);var a=this._getItemsPosition(s,n);if("Top"===a)return this._unformatAtSide("before",n,i);if("Bottom"===a)return n.reverse(),this._unformatAtSide("after",n,i);if("Middle"===a){var h=l.dom(n[n.length-1]),c=!1,d=!1,u=l.dom("<"+i.get().tagName.toLowerCase()+">");s.each(function(t){if(c){var e=l.dom(t);0!==e.closest(".redactor-split-item").length||d!==!1&&0!==e.closest(d).length||e.addClass("redactor-split-item"),d=e}t===h.get()&&(c=!0)}),s.filter(".redactor-split-item").each(function(t){var e=l.dom(t);e.removeClass("redactor-split-item"),u.append(t)}),i.after(u),n.reverse();for(var p=0;p<n.length;p++){var f=l.dom(n[p]),m=this._createUnformatContainer(f);i.after(m),m.find("ul, ol").remove(),f.remove()}return}}else for(var p=0;p<e.length;p++)3!==e[p].nodeType&&e[p].tagName.toLowerCase()===t&&this._unformatEntire(e[p])},_unformatEntire:function(t){var e=l.dom(t),i=e.find("li");i.each(function(t){var i=l.dom(t),s=this._createUnformatContainer(i);i.remove(),e.before(s)}.bind(this)),e.remove()},_unformatAtSide:function(t,e,i){for(var s=0;s<e.length;s++){var n=l.dom(e[s]),r=this._createUnformatContainer(n);i[t](r);var o=r.find("ul, ol").first();n.append(o),o.each(function(t){var i=l.dom(t),n=i.closest("li");n.get()===e[s]&&(i.unwrap(),n.addClass("r-unwrapped"))}),this.utils.isEmptyHtml(n.html())&&n.remove()}i.find(".r-unwrapped").each(function(t){var e=l.dom(t);""===e.html().trim()?e.remove():e.removeClass("r-unwrapped")})},_getItemsPosition:function(t,e){var i="Middle",s=e[0],n=e[e.length-1],r=t.first().get(),o=t.last().get();return r===s&&o!==n?i="Top":r!==s&&o===n&&(i="Bottom"),i},_createUnformatContainer:function(t){var e=l.dom("<"+this.opts.markup+">");return this.opts.breakline&&e.attr("data-redactor-tag","br"),e.append(t.contents()),e},_getBlocks:function(){return this.selection.getBlocks({first:!0})},_observeButton:function(){var t=this.selection.getCurrent(),e=this.inspector.parse(t),i=e.isPre()||e.isCode()||e.isFigcaption();this._observeButtonsList(i,["lists","ul","ol","outdent","indent"]);var s=this.toolbar.getButton("outdent"),n=this.toolbar.getButton("indent");this._observeIndent(n,s)},_observeDropdown:function(t){var e=t.getItem("outdent"),i=t.getItem("indent");this._observeIndent(i,e)},_observeIndent:function(t,e){var i=this.selection.isCollapsed(),s=this.selection.getCurrent(),n=this.inspector.parse(s),r=!!n.isList()&&n.getListItem(),o=l.dom(r),a=o.prevElement(),h=a.get(),c=i&&r&&h&&"LI"===h.tagName;e&&(r&&i?e.enable():e.disable()),t&&(r&&c?t.enable():t.disable())},_observeButtonsList:function(t,e){for(var i=0;i<e.length;i++){var s=this.toolbar.getButton(e[i]);s&&(t?s.disable():s.enable())}}}),l.add("class","video.component",{mixins:["dom","component"],init:function(t,e){return this.app=t,e&&void 0!==e.cmnt?e:this._init(e)},_init:function(t){if("undefined"!=typeof t){var e=l.dom(t),i=e.closest("figure");0!==i.length?this.parse(i):(this.parse("<figure>"),this.append(t))}else this.parse("<figure>");this._initWrapper()},_initWrapper:function(){this.addClass("redactor-component"),this.attr({"data-redactor-type":"video",tabindex:"-1",contenteditable:!1})}}),l.add("class","widget.component",{mixins:["dom","component"],init:function(t,e){return this.app=t,e&&void 0!==e.cmnt?e:this._init(e)},getData:function(){return{html:this._getHtml()}},_init:function(t){if("undefined"!=typeof t){var e=l.dom(t),i=e.closest("figure");0!==i.length?this.parse(i):(this.parse("<figure>"),this.html(t))}else this.parse("<figure>");this._initWrapper()},_getHtml:function(){var t=l.dom("<div>");return t.html(this.html()),t.find(".redactor-component-caret").remove(),t.html()},_initWrapper:function(){this.addClass("redactor-component"),this.attr({"data-redactor-type":"widget",tabindex:"-1",contenteditable:!1})}});var p=l;window.Redactor=window.$R=l,window.addEventListener("load",function(){l("[data-redactor]")}),"object"==typeof module&&module.exports&&(module.exports=p,module.exports.Redactor=p)}(),function(t){t.add("plugin","alignment",{translations:{en:{align:"Align","align-left":"Align Left","align-center":"Align Center","align-right":"Align Right","align-justify":"Align Justify"}},init:function(t){this.app=t,this.opts=t.opts,this.lang=t.lang,this.block=t.block,this.toolbar=t.toolbar},start:function(){var t={};t.left={title:this.lang.get("align-left"),api:"plugin.alignment.set",args:"left"},t.center={title:this.lang.get("align-center"),api:"plugin.alignment.set",args:"center"},t.right={title:this.lang.get("align-right"),api:"plugin.alignment.set",args:"right"},t.justify={title:this.lang.get("align-justify"),api:"plugin.alignment.set",args:"justify"};var e=this.toolbar.addButton("alignment",{title:this.lang.get("align")});e.setIcon('<i class="re-icon-alignment"></i>'),e.setDropdown(t)},set:function(t){if("left"===t&&"ltr"===this.opts.direction)return this._remove();var e={style:{"text-align":t}};this.block.toggle(e)},_remove:function(){this.block.remove({style:"text-align"})}})}(Redactor),function(t){t.add("plugin","beyondgrammar",{init:function(t){this.app=t,this.opts=t.opts,this.editor=t.editor,this.cleaner=t.cleaner},onoriginalblur:function(e){var i=t.dom(e.target);if(i.hasClass("pwa-suggest")){e.preventDefault(),this.app.stopBlur=!0;var s=this.app.offset.get();return void setTimeout(function(){this.app.offset.set(s)}.bind(this),10)}this.app.stopBlur=!1},onsource:{closed:function(){this.editor.focus(),this._activate()}},start:function(){this.GrammarChecker=this._getGrammarChecker(),this.opts.beyondgrammar&&this.GrammarChecker&&(this.cleaner.addUnconvertRules("spellcheck",function(t){t.find(".pwa-mark").unwrap()}),this._activate())},_activate:function(){var t=this.editor.getElement();t.attr("spellcheck",!1);var e=new this.GrammarChecker(t.get(),this.opts.beyondgrammar.service,this.opts.beyondgrammar.grammar);e.init().then(function(){e.activate()})},_getGrammarChecker:function(){return"undefined"!=typeof window.BeyondGrammar&&window.BeyondGrammar.GrammarChecker}})}(Redactor),function(t){t.add("plugin","clips",{translations:{en:{clips:"Clips","clips-select":"Please, select a clip"}},modals:{clips:""},init:function(t){this.app=t,this.opts=t.opts,this.lang=t.lang,this.toolbar=t.toolbar,this.insertion=t.insertion},onmodal:{clips:{open:function(t){this._build(t)}}},start:function(){if(this.opts.clips){var t={title:this.lang.get("clips"),api:"plugin.clips.open"},e=this.toolbar.addButton("clips",t);e.setIcon('<i class="re-icon-clips"></i>')}},open:function(t){var e={title:this.lang.get("clips"),width:"600px",name:"clips"};this.app.api("module.modal.build",e)},_build:function(t){var e=t.getBody(),i=this._buildLabel(),s=this._buildList();this._buildItems(s),e.html(""),e.append(i),e.append(s)},_buildLabel:function(){var e=t.dom("<label>");return e.html(this.lang.parse("## clips-select ##:")),e},_buildList:function(){var e=t.dom("<ul>");return e.addClass("redactor-clips-list"),e},_buildItems:function(e){for(var i=this.opts.clips,s=0;s<i.length;s++){var n=t.dom("<li>"),r=t.dom("<span>");r.attr("data-index",s),r.html(i[s][0]),r.on("click",this._insert.bind(this)),n.append(r),e.append(n)}},_insert:function(e){var i=t.dom(e.target),s=i.attr("data-index"),n=this.opts.clips[s][1];this.app.api("module.modal.close"),this.insertion.insertHtml(n)}})}(Redactor),function(t){t.add("plugin","counter",{translations:{en:{words:"words",chars:"chars"}},init:function(t){this.app=t,this.lang=t.lang,this.utils=t.utils,this.editor=t.editor,this.statusbar=t.statusbar},start:function(){var t=this.editor.getElement();t.on("keyup.redactor-plugin-counter paste.redactor-plugin-counter",this.count.bind(this)),this.count()},stop:function(){var t=this.editor.getElement();t.off(".redactor-plugin-counter"),this.statusbar.remove("words"),this.statusbar.remove("chars")},count:function(){var t=0,e=0,i=0,s=this.editor.getElement(),n=s.html();if(n=this._clean(n),""!==n){var r=n.split(/\s+/),o=n.match(/\s/g);t=r?r.length:0,i=o?o.length:0,e=n.length}var a={words:t,characters:e,spaces:i};this.app.broadcast("counter",a),this.statusbar.add("words",this.lang.get("words")+": "+a.words),this.statusbar.add("chars",this.lang.get("chars")+": "+a.characters)},_clean:function(t){return t=t.replace(/<\/(.*?)>/gi," "),t=t.replace(/<(.*?)>/gi,""),t=t.replace(/\t/gi,""),t=t.replace(/\n/gi," "),t=t.replace(/\r/gi," "),t=t.replace(/ /g,"1"),t=t.trim(),t=this.utils.removeInvisibleChars(t)}})}(Redactor),function(t){t.add("plugin","filebrowser",{init:function(t){this.app=t,this.lang=t.lang,this.toolbar=t.toolbar,this.insertion=t.insertion},start:function(){var t={title:this.lang.get("file"),api:"plugin.filebrowser.open"};this.$button=this.toolbar.addButton("filebrowser",t),this.$button.setIcon('<i class="re-icon-filebrowser"></i>')},open:function(){function t(t){return t.app.selection.save(),function e(i){t.app.selection.restore(),window.document.removeEventListener("filepicker:pick",e);const s=i.detail;if("[object String]"===Object.prototype.toString.call(s))t.app.api("module.image.insert",s);else if(s.file_id){EE.Rte.filedirUrls[s.upload_location_id]+s.file_name;s.isImage||s.isSVG?t.app.api("module.image.insert",s.path):t.app.api("module.link.insert",{text:s.path,url:s.path})}}}window.document.addEventListener("filepicker:pick",t(this)),window.Rte_browseImages(this.insertion,{})}})}(Redactor),function(t){t.add("plugin","fontcolor",{translations:{en:{fontcolor:"Text Color",text:"Text",highlight:"Highlight"}},init:function(t){this.app=t,this.opts=t.opts,this.lang=t.lang,this.inline=t.inline,this.toolbar=t.toolbar,this.selection=t.selection,this.colors=this.opts.fontcolors?this.opts.fontcolors:["#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"]},onfontcolor:{set:function(t,e){this._set(t,e)},remove:function(t){this._remove(t)}},start:function(){var t={title:this.lang.get("fontcolor")},e=this._buildDropdown();this.$button=this.toolbar.addButton("fontcolor",t),this.$button.setIcon('<i class="re-icon-fontcolor"></i>'),this.$button.setDropdown(e)},_buildDropdown:function(){var e=t.dom('<div class="redactor-dropdown-cells">');return this.$selector=this._buildSelector(),this.$selectorText=this._buildSelectorItem("text",this.lang.get("text")),this.$selectorText.addClass("active"),this.$selectorBack=this._buildSelectorItem("back",this.lang.get("highlight")),this.$selector.append(this.$selectorText),this.$selector.append(this.$selectorBack),this.$pickerText=this._buildPicker("textcolor"),this.$pickerBack=this._buildPicker("backcolor"),e.append(this.$selector),e.append(this.$pickerText),e.append(this.$pickerBack),this._buildSelectorEvents(),e.width(242),e},_buildSelector:function(){var e=t.dom("<div>");return e.addClass("redactor-dropdown-selector"),e},_buildSelectorItem:function(e,i){var s=t.dom("<span>");return s.attr("rel",e).html(i),s.addClass("redactor-dropdown-not-close"),s},_buildSelectorEvents:function(){this.$selectorText.on("mousedown",function(t){t.preventDefault(),this.$selector.find("span").removeClass("active"),this.$pickerBack.hide(),this.$pickerText.show(),this.$selectorText.addClass("active")}.bind(this)),this.$selectorBack.on("mousedown",function(t){t.preventDefault(),this.$selector.find("span").removeClass("active"),this.$pickerText.hide(),this.$pickerBack.show(),this.$selectorBack.addClass("active")}.bind(this))},_buildPicker:function(e){for(var i=t.dom('<div class="re-dropdown-box-'+e+'">'),s="backcolor"==e?"background-color":"color",n=this.colors.length,r=this,o=function(e){e.preventDefault();var i=t.dom(e.target);r._set(i.data("rule"),i.attr("rel"))},a=0;a<n;a++){var l=this.colors[a],h=t.dom("<span>");h.attr({rel:l,"data-rule":s}),h.css({"background-color":l,"font-size":0,border:"2px solid #fff",width:"22px",height:"22px"}),h.on("mousedown",o),i.append(h)}var c=t.dom("<a>");return c.attr({href:"#"}),c.css({display:"block",clear:"both",padding:"8px 5px","font-size":"12px","line-height":1}),c.html(this.lang.get("none")),c.on("click",function(t){t.preventDefault(),r._remove(s)}),i.append(c),"backcolor"==e&&i.hide(),i},_set:function(t,e){var i={};i[t]=e;var s={tag:"span",style:i,type:"toggle"};this.inline.format(s)},_remove:function(t){this.inline.remove({style:t})}})}(Redactor),function(t){t.add("plugin","fontfamily",{translations:{en:{fontfamily:"Font","remove-font-family":"Remove Font Family"}},init:function(t){this.app=t,this.opts=t.opts,this.lang=t.lang,this.inline=t.inline,this.toolbar=t.toolbar,this.fonts=this.opts.fontfamily?this.opts.fontfamily:["Arial","Helvetica","Georgia","Times New Roman","Monospace"]},start:function(){for(var t={},e=0;e<this.fonts.length;e++){var i=this.fonts[e];t[e]={title:i.replace(/'/g,""),api:"plugin.fontfamily.set",args:i}}t.remove={title:this.lang.get("remove-font-family"),api:"plugin.fontfamily.remove"};var s=this.toolbar.addButton("fontfamily",{title:this.lang.get("fontfamily")});s.setIcon('<i class="re-icon-fontfamily"></i>'),s.setDropdown(t)},set:function(t){var e={tag:"span",style:{"font-family":t},type:"toggle"};this.inline.format(e)},remove:function(){this.inline.remove({style:"font-family"})}})}(Redactor),function(t){t.add("plugin","fontsize",{translations:{en:{size:"Size","remove-size":"Remove Font Size"}},init:function(t){this.app=t,this.lang=t.lang,this.inline=t.inline,this.toolbar=t.toolbar,this.sizes=[10,11,12,14,16,18,20,24,28,30]},start:function(){for(var t={},e=0;e<this.sizes.length;e++){var i=this.sizes[e];t[e]={title:i+"px",api:"plugin.fontsize.set",args:i}}t.remove={title:this.lang.get("remove-size"),api:"plugin.fontsize.remove"};var s=this.toolbar.addButton("fontsize",{title:this.lang.get("size")});s.setIcon('<i class="re-icon-fontsize"></i>'),s.setDropdown(t)},set:function(t){var e={tag:"span",style:{"font-size":t+"px"},type:"toggle"};this.inline.format(e)},remove:function(){this.inline.remove({style:"font-size"})}})}(Redactor),function(t){t.add("plugin","fullscreen",{translations:{en:{fullscreen:"Fullscreen"}},init:function(t){this.app=t,this.opts=t.opts,this.lang=t.lang,this.$win=t.$win,this.$doc=t.$doc,this.$body=t.$body,this.editor=t.editor,this.toolbar=t.toolbar,this.container=t.container,this.selection=t.selection,this.isOpen=!1,this.docScroll=0},start:function(){var t={title:this.lang.get("fullscreen"),api:"plugin.fullscreen.toggle"},e=this.toolbar.addButton("fullscreen",t);e.setIcon('<i class="re-icon-expand"></i>'),this.$target=this.toolbar.isTarget()?this.toolbar.getTargetElement():this.$body,this.opts.fullscreen&&this.toggle()},toggle:function(){return this.isOpen?this.close():this.open()},open:function(){this.docScroll=this.$doc.scrollTop(),this._createPlacemarker(),this.selection.save();var e=this.container.getElement(),i=this.editor.getElement(),s=this.toolbar.isTarget()?t.dom("body, html"):this.$target;this.opts.toolbarExternal&&this._buildInternalToolbar(),this.$target.prepend(e),this.$target.addClass("redactor-body-fullscreen"),e.addClass("redactor-box-fullscreen"),this.isTarget&&e.addClass("redactor-box-fullscreen-target"),s.css("overflow","hidden"),this.opts.maxHeight&&i.css("max-height",""),this.opts.minHeight&&i.css("min-height",""),this._resize(),this.$win.on("resize.redactor-plugin-fullscreen",this._resize.bind(this)),this.$doc.scrollTop(0);var n=this.toolbar.getButton("fullscreen");n.setIcon('<i class="re-icon-retract"></i>'),this.selection.restore(),this.isOpen=!0,this.opts.zindex=1051,window.jQuery&&window.jQuery(document).off("focusin.modal")},close:function(){this.isOpen=!1,this.opts.zindex=!1,this.selection.save();var e=this.container.getElement(),i=this.editor.getElement(),s=t.dom("body, html");this.opts.toolbarExternal&&this._buildExternalToolbar(),this.$target.removeClass("redactor-body-fullscreen"),this.$win.off("resize.redactor-plugin-fullscreen"),s.css("overflow",""),e.removeClass("redactor-box-fullscreen redactor-box-fullscreen-target"),i.css("height","auto"),this.opts.minHeight&&i.css("minHeight",this.opts.minHeight),this.opts.maxHeight&&i.css("maxHeight",this.opts.maxHeight);var n=this.toolbar.getButton("fullscreen");n.setIcon('<i class="re-icon-expand"></i>'),this._removePlacemarker(e),this.selection.restore(),this.$doc.scrollTop(this.docScroll)},_resize:function(){var t=this.toolbar.getElement(),e=this.editor.getElement(),i=this.$win.height()-t.height();e.height(i)},_buildInternalToolbar:function(){var t=this.toolbar.getWrapper(),e=this.toolbar.getElement();t.addClass("redactor-toolbar-wrapper"),t.append(e),e.removeClass("redactor-toolbar-external"),$container.prepend(t)},_buildExternalToolbar:function(){var e=this.toolbar.getWrapper(),i=this.toolbar.getElement();this.$external=t.dom(this.opts.toolbarExternal),i.addClass("redactor-toolbar-external"),this.$external.append(i),e.remove()},_createPlacemarker:function(){var e=this.container.getElement();this.$placemarker=t.dom("<span />"),e.after(this.$placemarker)},_removePlacemarker:function(t){this.$placemarker.before(t),this.$placemarker.remove()}})}(Redactor),function(t){t.add("plugin","handle",{init:function(t){this.app=t,this.opts=t.opts,this.$doc=t.$doc,this.$body=t.$body,this.editor=t.editor,this.marker=t.marker,this.keycodes=t.keycodes,this.container=t.container,this.selection=t.selection,this.handleTrigger="undefined"!=typeof this.opts.handleTrigger?this.opts.handleTrigger:"@",this.handleStart="undefined"!=typeof this.opts.handleStart?this.opts.handleStart:0,this.handleStr="",this.handleLen=this.handleStart},start:function(){if(this.opts.handle){var t=this.editor.getElement();t.on("keyup.redactor-plugin-handle",this._handle.bind(this)),t.on("keydown.redactor-plugin-handle",this._listen.bind(this))}},stop:function(){var e=this.editor.getElement();e.off(".redactor-plugin-handle"),this.$doc.off(".redactor-plugin-handle");var i=t.dom("#redactor-handle-list");i.remove()},_handle:function(t){var e=t.which,i=t.ctrlKey||t.metaKey,s=[37,38,39,40];if(e===this.keycodes.BACKSPACE){if(!(this._isShown()&&this.handleLen>this.handleStart))return;this.handleLen=this.handleLen-2,this.handleLen<=this.handleStart&&this._hide()}if(e!==this.keycodes.DELETE&&e!==this.keycodes.ESC&&e!==this.keycodes.SHIFT&&!i&&s.indexOf(e)===-1){var n=new RegExp("^"+this.handleTrigger);this.handleStr=this.selection.getTextBeforeCaret(this.handleLen+1),n.test(this.handleStr)&&(this.handleStr=this.handleStr.replace(this.handleTrigger,""),this.handleLen++,this._load())}},_listen:function(t){var e=t.which,i=this.keycodes;if(this._isShown()&&e===i.ENTER){var s=this._getActiveItem();return 0===s.length?void this._hideForce():(t.preventDefault(),this._replace(t,s),void this._hideForce())}if(!this._isShown()||40!==e&&38!==e);else{t.preventDefault();var s=this._getActiveItem();if(0===s.length){var n=this._getFirstItem();this._setActive(n)}else 40===e?this._setNextActive(s):38===e&&this._setPrevActive(s)}},_getItems:function(){return this.$list.find("a")},_getActiveItem:function(){return this._getItems().filter(function(e){return t.dom(e).hasClass("active")})},_getFirstItem:function(){return this._getItems().first()},_getLastItem:function(){return this._getItems().last()},_setActive:function(t){this._getItems().removeClass("active"),t.addClass("active");var e=t.outerHeight(),i=t.position().top,s=this.$list.scrollTop(),n=i+2*e,r=this.$list.outerHeight();this.$list.scrollTop(n>s+r?n-r:i-e<s?i-e:s)},_setNextActive:function(t){var e=t.next();if(0!==e.length)this._setActive(e);else{var i=this._getFirstItem();this._setActive(i)}},_setPrevActive:function(t){var e=t.prev();if(0!==e.length)this._setActive(e);else{var i=this._getLastItem();this._setActive(i)}},_load:function(){t.ajax.post({url:this.opts.handle,data:"handle="+this.handleStr,success:this._parse.bind(this)})},_parse:function(t){if(""!==t){var e="object"==typeof t?t:JSON.parse(t);this._build(),this._buildData(e)}},_build:function(){this.$list=t.dom("#redactor-handle-list"),0===this.$list.length&&(this.$list=t.dom('<div id="redactor-handle-list">'),this.$body.append(this.$list))},_buildData:function(t){this.data=t,this._update(),this._show()},_update:function(){this.$list.html("");for(var e in this.data){var i=t.dom('<a href="#">');i.html(this.data[e].item),i.attr("data-key",e),i.on("click",this._replace.bind(this)),this.$list.append(i)}var s=this.container.getElement(),n=(s.offset(),this.selection.getPosition());this.$list.addClass("open"),this.$list.css({top:n.top+n.height+this.$doc.scrollTop()+"px",left:n.left+"px"})},_isShown:function(){return this.$list&&this.$list.hasClass("open")},_show:function(){this.$list.addClass("open"),this.$list.show(),this.$doc.off(".redactor-plugin-handle"),this.$doc.on("click.redactor-plugin-handle keydown.redactor-plugin-handle",this._hide.bind(this))},_hide:function(t){var e=!1,i=t&&t.which;t?"click"!==t.type&&i!==this.keycodes.ESC&&i!==this.keycodes.SPACE||(e=!0):e=!0,e&&this._hideForce()},_hideForce:function(){this.$list.removeClass("open"),this.$list.hide(),this._reset()},_reset:function(){this.handleStr="",this.handleLen=this.handleStart},_replace:function(e,i){e.preventDefault();var s=i?i:t.dom(e.target),n=s.attr("data-key"),r=this.data[n].replacement,o=this.marker.insert("start"),a=t.dom(o),l=o.previousSibling,h=l.textContent,c=new RegExp(this.handleTrigger+this.handleStr+"$");h=h.replace(c,""),l.textContent=h,a.before(r),this.selection.restoreMarkers()}})}(Redactor),function(t){t.add("plugin","inlinestyle",{translations:{en:{style:"Style"}},init:function(t){this.app=t,this.lang=t.lang,this.toolbar=t.toolbar,this.styles={marked:{title:"Marked",args:"mark"},code:{title:"Code",args:"code"},variable:{title:"Variable",args:"var"},shortcut:{title:"Shortcut",args:"kbd"},sup:{title:"Superscript",args:"sup"},sub:{title:"Subscript",args:"sub"}}},start:function(){var t={};for(var e in this.styles){var i=this.styles[e];t[e]={title:i.title,api:"module.inline.format",args:i.args}}var s=this.toolbar.addButtonAfter("format","inline",{title:this.lang.get("style")});s.setIcon('<i class="re-icon-inline"></i>'),s.setDropdown(t)}})}(Redactor),function(t){t.add("plugin","limiter",{init:function(t){this.app=t,this.utils=t.utils,this.opts=t.opts,this.editor=t.editor,this.keycodes=t.keycodes},onpasting:function(t){if(this.opts.limiter){t=this.utils.removeInvisibleChars(t);var e=this._getText(),i=t.length+e.length;this.opts.input=!(i>=this.opts.limiter)}},start:function(){if(this.opts.limiter){this._count();var t=this.editor.getElement();t.on("keydown.redactor-plugin-limiter",this._limit.bind(this))}},stop:function(){var t=this.editor.getElement();t.off(".redactor-plugin-limiter"), this.opts.input=!0},_limit:function(t){var e=t.which,i=t.ctrlKey||t.metaKey,s=[37,38,39,40];e===this.keycodes.BACKSPACE||e===this.keycodes.DELETE||e===this.keycodes.ESC||e===this.keycodes.SHIFT||i&&65===e||i&&88===e||i&&82===e||i&&116===e||s.indexOf(e)!==-1||this._count(t)},_count:function(t){var e=this._getText(),i=e.length;return i>=this.opts.limiter?(t&&t.preventDefault(),this.opts.input=!1,!1):void(this.opts.input=!0)},_getText:function(){var t=this.editor.getElement(),e=t.text();return this.utils.removeInvisibleChars(e)}})}(Redactor),function(t){t.add("plugin","pages",{init:function(t){this.app=t,this.opts=t.opts,this.$doc=t.$doc,this.$body=t.$body,this.editor=t.editor,this.marker=t.marker,this.keycodes=t.keycodes,this.container=t.container,this.selection=t.selection,this.handleTrigger="undefined"!=typeof this.opts.handleTrigger?this.opts.handleTrigger:"@",this.handleStart="undefined"!=typeof this.opts.handleStart?this.opts.handleStart:3,this.handleStr="",this.handleLen=this.handleStart},start:function(){if(this.opts.handle){var t=this.editor.getElement();t.on("keyup.redactor-plugin-handle",this._handle.bind(this)),t.on("keydown.redactor-plugin-handle",this._listen.bind(this))}},stop:function(){var e=this.editor.getElement();e.off(".redactor-plugin-handle"),this.$doc.off(".redactor-plugin-handle");var i=t.dom("#redactor-handle-list");i.remove()},_handle:function(t){var e=t.which,i=t.ctrlKey||t.metaKey,s=[37,38,39,40];if(e===this.keycodes.BACKSPACE){if(!(this._isShown()&&this.handleLen>this.handleStart))return;this.handleLen=this.handleLen-2,this.handleLen<=this.handleStart&&this._hide()}if(e!==this.keycodes.DELETE&&e!==this.keycodes.ESC&&e!==this.keycodes.SHIFT&&!i&&s.indexOf(e)===-1){var n=new RegExp("^"+this.handleTrigger);this.handleStr=this.selection.getTextBeforeCaret(this.handleLen+1),n.test(this.handleStr)&&(this.handleStr=this.handleStr.replace(this.handleTrigger,""),this.handleLen++,this._load())}},_listen:function(t){var e=t.which,i=this.keycodes;if(this._isShown()&&e===i.ENTER){var s=this._getActiveItem();return 0===s.length?void this._hideForce():(t.preventDefault(),this._replace(t,s),void this._hideForce())}if(!this._isShown()||40!==e&&38!==e);else{t.preventDefault();var s=this._getActiveItem();if(0===s.length){var n=this._getFirstItem();this._setActive(n)}else 40===e?this._setNextActive(s):38===e&&this._setPrevActive(s)}},_getItems:function(){return this.$list.find("a")},_getActiveItem:function(){return this._getItems().filter(function(e){return t.dom(e).hasClass("active")})},_getFirstItem:function(){return this._getItems().first()},_getLastItem:function(){return this._getItems().last()},_setActive:function(t){this._getItems().removeClass("active"),t.addClass("active");var e=t.outerHeight(),i=t.position().top,s=this.$list.scrollTop(),n=i+2*e,r=this.$list.outerHeight();this.$list.scrollTop(n>s+r?n-r:i-e<s?i-e:s)},_setNextActive:function(t){var e=t.next();if(0!==e.length)this._setActive(e);else{var i=this._getFirstItem();this._setActive(i)}},_setPrevActive:function(t){var e=t.prev();if(0!==e.length)this._setActive(e);else{var i=this._getLastItem();this._setActive(i)}},_load:function(){t.ajax.get({url:this.opts.handle+"&search="+this.handleStr,success:this._parse.bind(this)})},_parse:function(t){if(""!==t){var e="object"==typeof t?t:JSON.parse(t);this._build(),this._buildData(e)}},_build:function(){this.$list=t.dom("#redactor-handle-list"),0===this.$list.length&&(this.$list=t.dom('<div id="redactor-handle-list">'),this.$body.append(this.$list))},_buildData:function(t){this.data=t,this._update(),this._show()},_update:function(){this.$list.html("");for(var e in this.data){var i=t.dom('<a href="#">');i.html(this.data[e].text),i.attr("data-href",this.data[e].href),i.attr("data-text",this.data[e].text),i.on("click",this._replace.bind(this)),this.$list.append(i)}var s=this.container.getElement(),n=(s.offset(),this.selection.getPosition());this.$list.addClass("open"),this.$list.css({top:n.top+n.height+this.$doc.scrollTop()+"px",left:n.left+"px"})},_isShown:function(){return this.$list&&this.$list.hasClass("open")},_show:function(){this.$list.addClass("open"),this.$list.show(),this.$doc.off(".redactor-plugin-handle"),this.$doc.on("click.redactor-plugin-handle keydown.redactor-plugin-handle",this._hide.bind(this))},_hide:function(t){var e=!1,i=t&&t.which;t?"click"!==t.type&&i!==this.keycodes.ESC||(e=!0):e=!0,e&&this._hideForce()},_hideForce:function(){this.$list.removeClass("open"),this.$list.hide(),this._reset()},_reset:function(){this.handleStr="",this.handleLen=this.handleStart},_replace:function(e,i){e.preventDefault();var s=i?i:t.dom(e.target),n=document.createElement("a");n.setAttribute("href",s.attr("data-href")),n.innerHTML=s.attr("data-text");var r=this.marker.insert("start"),o=t.dom(r),a=r.previousSibling,l=a.textContent,h=new RegExp("@"+this.handleStr+"$");l=l.replace(h,""),a.textContent=l,o.before(n),this.selection.restoreMarkers()}})}(Redactor),function(t){t.add("plugin","properties",{modals:{properties:'<form action=""> <div class="form-item"> <label>Id</label> <input type="text" name="id"> </div> <div class="form-item"> <label>Class</label> <input type="text" name="classname"> </div> </form>'},translations:{en:{properties:"Properties"}},init:function(t){this.app=t,this.opts=t.opts,this.lang=t.lang,this.$body=t.$body,this.toolbar=t.toolbar,this.inspector=t.inspector,this.selection=t.selection,this.labelStyle={"font-family":"monospace",position:"absolute",padding:"2px 5px","line-height":1,"border-radius":"3px","font-size":"11px",color:"rgba(255, 255, 255, .9)"}},onmodal:{properties:{open:function(t,e){if(this.$block){var i=this._getData(this.$block);e.setData(i)}},opened:function(t,e){e.getField("id").focus()},save:function(t,e){var i=e.getData();this._save(i)}}},onbutton:{properties:{observe:function(t){this._observeButton(t)}}},onclick:function(){},start:function(){var t={title:this.lang.get("properties"),api:"plugin.properties.open",observe:"properties"},e=this.toolbar.addButton("properties",t);e.setIcon('<i class="re-icon-properties"></i>'),this._createLabel()},stop:function(){this._removeLabel()},open:function(){var e=this.selection.getBlock();if(e){this.$block=t.dom(e);var i={title:this.lang.get("properties"),width:"500px",name:"properties",handle:"save",commands:{save:{title:this.lang.get("save")},cancel:{title:this.lang.get("cancel")}}};this.app.api("module.modal.build",i)}},_save:function(t){this.app.api("module.modal.close"),""===t.id?this.$block.removeAttr("id"):this.$block.attr("id",t.id),""===t.classname?this.$block.removeAttr("class"):this.$block.attr("class",t.classname)},_getData:function(e){var i=t.dom(e),s={id:i.attr("id"),classname:i.attr("class")};return s},_showData:function(e,i){var s="";if(i.id&&(s+="#"+i.id+" "),i.classname&&(s+="."+i.classname),""!==s){var n=t.dom(e),r=n.offset();this.$label.css({top:r.top-12+"px",left:r.left+"px","z-index":this.opts.zindex?this.opts.zindex+3:"auto"}),this.$label.html(s),this.$label.show()}else this.$label.hide()},_createLabel:function(){this.$label=t.dom("<span />"),this.$label.hide(),this.$label.css(this.labelStyle).css("background","rgba(229, 57, 143, .7)"),this.$body.append(this.$label)},_removeLabel:function(){this.$label&&this.$label.remove()},_observeButton:function(t){var e=this.selection.getBlock(),i=this.inspector.parse(e);if(e&&!i.isComponent()){var s=this._getData(e);this._showData(e,s),t.enable()}else t.disable(),this.$label&&this.$label.hide()}})}(Redactor),function(t){t.add("plugin","readmore",{translations:{en:{readmore:"Read more"}},init:function(t){this.app=t,this.lang=t.lang,this.toolbar=t.toolbar,this.component=t.component,this.insertion=t.insertion,this.inspector=t.inspector},oncontextbar:function(t,e){var i=this.inspector.parse(t.target);if("undefined"!=typeof i.$el&&1==i.$el.find("div.readmore").length){var s=i.getComponent();if("undefined"!=typeof s&&s!==!1){var n={remove:{title:this.lang.get("delete"),api:"plugin.widget.remove",args:s}};e.set(t,s,n,"bottom")}}},start:function(){var t={title:this.lang.get("readmore"),api:"plugin.readmore.open"},e=this.toolbar.addButton("readmore",t);e.setIcon('<i class="re-icon-readmore"></i>')},open:function(){this._insert()},remove:function(t){this.component.remove(t)},_insert:function(t){var e='<div class="readmore"><span class="readmore__label">'+this.lang.get("readmore")+"</span></div>",i=this.component.create("widget",e);i.attr("data-widget-code",encodeURI(e)),this.insertion.insertHtml(i)}})}(Redactor),function(t){t.add("plugin","rte_definedlinks",{translations:{en:{pages:"Pages"}},init:function(t){this.app=t,this.opts=t.opts,this.component=t.component,this.links=[]},onmodal:{link:{open:function(t,e){this.opts.definedlinks&&(this.$modal=t,this.$form=e,this._load())}}},_load:function(){"object"==typeof this.opts.definedlinks?this._build(this.opts.definedlinks):t.ajax.get({url:this.opts.definedlinks,success:this._build.bind(this)})},_build:function(e){var i=this.$modal.find("#redactor-defined-links");if(0===i.length){var s=this.$modal.getBody(),n=t.dom('<div class="form-item" />'),r=t.dom('<label for="redactor-defined-links">'+t.lang[t.opts.lang].pages+"</label>"),i=t.dom('<select id="redactor-defined-links" />');n.append(r),n.append(i),s.prepend(n)}this.links=[],i.html(""),i.off("change"),i.append(t.dom("<option>"));for(var o in e)if(e.hasOwnProperty(o)&&"object"==typeof e[o]){this.links[o]=e[o];var a=t.dom("<option>");a.val(o),a.html(e[o].text),i.append(a)}i.on("change",this._select.bind(this))},_select:function(e){var i=this.$form.getData(),s=t.dom(e.target).val(),n={text:"",url:""};""!==s&&(n.text=this.links[s].text,n.url=this.links[s].href),""!==i.text&&(n={url:n.url}),this.$form.setData(n)}})}(Redactor),function(t){t.add("plugin","specialchars",{translations:{en:{specialchars:"Special Characters"}},init:function(t){this.app=t,this.lang=t.lang,this.toolbar=t.toolbar,this.insertion=t.insertion,this.chars=["‘","’","“","”","–","—","÷","…","™","•","→","≈","$","€","¢","£","¥","¡","¤","¦","§","¨","©","ª","«","»","¬","®","¯","°","¹","²","³","´","µ","¶","·","¸","º","¼","½","¾","¿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","ø","ù","ú","û","ü","ý","þ","ÿ","Œ","œ","Ŵ","Ŷ","ŵ","ŷ"]},start:function(){var t={title:this.lang.get("specialchars")},e=this._buildDropdown();this.$button=this.toolbar.addButton("specialchars",t),this.$button.setIcon('<i class="re-icon-specialcharacters"></i>'),this.$button.setDropdown(e)},_set:function(t){this.insertion.insertChar(t)},_buildDropdown:function(){for(var e=this,i=t.dom('<div class="redactor-dropdown-cells">'),s=function(i){i.preventDefault();var s=t.dom(i.target);e._set(s.data("char"))},n=0;n<this.chars.length;n++){var r=t.dom("<a>");r.attr({href:"#","data-char":this.chars[n]}),r.css({"line-height":"32px",width:"32px",height:"32px"}),r.html(this.chars[n]),r.on("click",s),i.append(r)}return i}})}(Redactor),function(t){t.add("plugin","table",{translations:{en:{table:"Table","insert-table":"Insert table","insert-row-above":"Insert row above","insert-row-below":"Insert row below","insert-column-left":"Insert column left","insert-column-right":"Insert column right","add-head":"Add head","delete-head":"Delete head","delete-column":"Delete column","delete-row":"Delete row","delete-table":"Delete table"}},init:function(t){this.app=t,this.lang=t.lang,this.opts=t.opts,this.caret=t.caret,this.editor=t.editor,this.toolbar=t.toolbar,this.component=t.component,this.inspector=t.inspector,this.insertion=t.insertion,this.selection=t.selection},ondropdown:{table:{observe:function(t){this._observeDropdown(t)}}},onbottomclick:function(){this.insertion.insertToEnd(this.editor.getLastNode(),"table")},start:function(){var t={observe:"table","insert-table":{title:this.lang.get("insert-table"),api:"plugin.table.insert"},"insert-row-above":{title:this.lang.get("insert-row-above"),classname:"redactor-table-item-observable",api:"plugin.table.addRowAbove"},"insert-row-below":{title:this.lang.get("insert-row-below"),classname:"redactor-table-item-observable",api:"plugin.table.addRowBelow"},"insert-column-left":{title:this.lang.get("insert-column-left"),classname:"redactor-table-item-observable",api:"plugin.table.addColumnLeft"},"insert-column-right":{title:this.lang.get("insert-column-right"),classname:"redactor-table-item-observable",api:"plugin.table.addColumnRight"},"add-head":{title:this.lang.get("add-head"),classname:"redactor-table-item-observable",api:"plugin.table.addHead"},"delete-head":{title:this.lang.get("delete-head"),classname:"redactor-table-item-observable",api:"plugin.table.deleteHead"},"delete-column":{title:this.lang.get("delete-column"),classname:"redactor-table-item-observable",api:"plugin.table.deleteColumn"},"delete-row":{title:this.lang.get("delete-row"),classname:"redactor-table-item-observable",api:"plugin.table.deleteRow"},"delete-table":{title:this.lang.get("delete-table"),classname:"redactor-table-item-observable",api:"plugin.table.deleteTable"}},e={title:this.lang.get("table")},i=this.toolbar.addButtonBefore("link","table",e);i.setIcon('<i class="re-icon-table"></i>'),i.setDropdown(t)},insert:function(){for(var t=2,e=3,i=this.component.create("table"),s=0;s<t;s++)i.addRow(e);i=this.insertion.insertHtml(i),this.caret.setStart(i)},addRowAbove:function(){var t=this._getComponent();if(t){var e=this.selection.getCurrent(),i=t.addRowTo(e,"before");this.caret.setStart(i)}},addRowBelow:function(){var t=this._getComponent();if(t){var e=this.selection.getCurrent(),i=t.addRowTo(e,"after");this.caret.setStart(i)}},addColumnLeft:function(){var t=this._getComponent();if(t){var e=this.selection.getCurrent();this.selection.save(),t.addColumnTo(e,"left"),this.selection.restore()}},addColumnRight:function(){var t=this._getComponent();if(t){var e=this.selection.getCurrent();this.selection.save(),t.addColumnTo(e,"right"),this.selection.restore()}},addHead:function(){var t=this._getComponent();t&&(this.selection.save(),t.addHead(),this.selection.restore())},deleteHead:function(){var e=this._getComponent();if(e){var i=this.selection.getCurrent(),s=t.dom(i).closest("thead");0!==s.length?(e.removeHead(),this.caret.setStart(e)):(this.selection.save(),e.removeHead(),this.selection.restore())}},deleteColumn:function(){var e=this._getComponent();if(e){var i=this.selection.getCurrent(),s=t.dom(i).closest("td, th"),n=s.nextElement().get(),r=s.prevElement().get();e.removeColumn(i),n?this.caret.setStart(n):r?this.caret.setEnd(r):this.deleteTable()}},deleteRow:function(){var e=this._getComponent();if(e){var i=this.selection.getCurrent(),s=t.dom(i).closest("tr"),n=s.nextElement().get(),r=s.prevElement().get(),o=t.dom(i).closest("thead");e.removeRow(i),n?this.caret.setStart(n):r?this.caret.setEnd(r):0!==o.length?(e.removeHead(),this.caret.setStart(e)):this.deleteTable()}},deleteTable:function(){var t=this._getTable();t&&this.component.remove(t)},_getTable:function(){var t=this.selection.getCurrent(),e=this.inspector.parse(t);if(e.isTable())return e.getTable()},_getComponent:function(){var t=this.selection.getCurrent(),e=this.inspector.parse(t);if(e.isTable()){var i=e.getTable();return this.component.create("table",i)}},_observeDropdown:function(t){var e=this._getTable(),i=t.getItemsByClass("redactor-table-item-observable"),s=t.getItem("insert-table");e?(this._observeItems(i,"enable"),s.disable()):(this._observeItems(i,"disable"),s.enable())},_observeItems:function(t,e){for(var i=0;i<t.length;i++)t[i][e]()}})}(Redactor),function(t){t.add("class","table.component",{mixins:["dom","component"],init:function(t,e){return this.app=t,e&&void 0!==e.cmnt?e:this._init(e)},addHead:function(){this.removeHead();var e=this.$element.find("tr").first().children("td, th").length,i=t.dom("<thead>"),s=this._buildRow(e,"<th>");i.append(s),this.$element.prepend(i)},addRow:function(t){var e=this._buildRow(t);return this.$element.append(e),e},addRowTo:function(t,e){return this._addRowTo(t,e)},addColumnTo:function(e,i){var s=t.dom(e),n=s.closest("tr"),r=s.closest("td, th"),o=0;n.find("td, th").each(function(t,e){t===r.get()&&(o=e)}),this.$element.find("tr").each(function(e){var s=t.dom(e),n=s.find("td, th").get(o),r=t.dom(n),a=r.clone();a.html('<div data-redactor-tag="tbr"></div>'),"right"===i?r.after(a):r.before(a)})},removeHead:function(){var t=this.$element.find("thead");0!==t.length&&t.remove()},removeRow:function(e){var i=t.dom(e),s=i.closest("tr");s.remove()},removeColumn:function(e){var i=t.dom(e),s=i.closest("tr"),n=i.closest("td, th"),r=0;s.find("td, th").each(function(t,e){t===n.get()&&(r=e)}),this.$element.find("tr").each(function(e){var i=t.dom(e),s=i.find("td, th").get(r),n=t.dom(s);n.remove()})},_init:function(e){var i,s;if("undefined"!=typeof e){var n=t.dom(e),r=n.get(),o=n.closest("figure");0!==o.length?(i=o,s=o.find("table").get()):"TABLE"===r.tagName&&(s=r)}this._buildWrapper(i),this._buildElement(s),this._initWrapper()},_addRowTo:function(e,i){var s=t.dom(e),n=s.closest("tr");if(0!==n.length){var r=n.children("td, th").length,o=this._buildRow(r);return n[i](o),o}},_buildRow:function(e,i){i=i||"<td>";for(var s=t.dom("<tr>"),n=0;n<e;n++){var r=t.dom(i);r.attr("contenteditable",!0),r.html('<div data-redactor-tag="tbr"></div>'),s.append(r)}return s},_buildElement:function(e){e?this.$element=t.dom(e):(this.$element=t.dom("<table>"),this.append(this.$element))},_buildWrapper:function(t){t=t||"<figure>",this.parse(t)},_initWrapper:function(){this.addClass("redactor-component"),this.attr({"data-redactor-type":"table",tabindex:"-1",contenteditable:!1}),this.app.detector.isIe()&&this.removeAttr("contenteditable")}})}(Redactor),function(t){t.add("plugin","textdirection",{translations:{en:{"change-text-direction":"RTL-LTR","left-to-right":"Left to Right","right-to-left":"Right to Left"}},init:function(t){this.app=t,this.lang=t.lang,this.block=t.block,this.editor=t.editor,this.toolbar=t.toolbar,this.selection=t.selection},start:function(){var t={};t.ltr={title:this.lang.get("left-to-right"),api:"plugin.textdirection.set",args:"ltr"},t.rtl={title:this.lang.get("right-to-left"),api:"plugin.textdirection.set",args:"rtl"};var e=this.toolbar.addButton("textdirection",{title:this.lang.get("change-text-direction")});e.setIcon('<i class="re-icon-textdirection"></i>'),e.setDropdown(t)},set:function(e){var i=this.selection.getBlock();if(i&&"LI"===i.tagName){var s=t.dom(i).parents("ul, ol",this.editor.getElement()).last();this.block.add({attr:{dir:e}},!1,s)}else this.block.add({attr:{dir:e}})}})}(Redactor),function(t){t.add("plugin","textexpander",{init:function(t){this.app=t,this.opts=t.opts,this.utils=t.utils,this.editor=t.editor,this.marker=t.marker,this.keycodes=t.keycodes,this.selection=t.selection},start:function(){if(this.opts.textexpander){var t=this.editor.getElement();t.on("keyup.redactor-plugin-textexpander",this._expand.bind(this))}},stop:function(){var t=this.editor.getElement();t.off(".redactor-plugin-textexpander")},_expand:function(t){var e=t.which;if(e===this.keycodes.SPACE)for(var i=this.opts.textexpander.length,s=0;s<i;s++){var n=this.opts.textexpander[s],r=new RegExp(this.utils.escapeRegExp(n[0])+"\\s$"),o=this.selection.getTextBeforeCaret(n[0].length+1).replace(/\s$/,"");if(n[0]===o)return this._replaceSelection(r,n[1])}},_replaceSelection:function(t,e){var i=this.marker.insert("start"),s=i.previousSibling,n=s.textContent;n=n.replace(/ /," "),n=n.replace(t,e),s.textContent=n,this.selection.restoreMarkers()}})}(Redactor),function(t){t.add("plugin","variable",{translations:{en:{change:"Change",variable:"Variable","variable-select":"Please, select a variable"}},modals:{variable:""},init:function(t){this.app=t,this.lang=t.lang,this.opts=t.opts,this.toolbar=t.toolbar,this.component=t.component,this.insertion=t.insertion,this.inspector=t.inspector,this.selection=t.selection},onmodal:{variable:{open:function(t,e){this._build(t)}}},oncontextbar:function(t,e){var i=this.inspector.parse(t.target);if(i.isComponentType("variable")){var s=i.getComponent(),n={change:{title:this.lang.get("change"),api:"plugin.variable.open",args:s},remove:{title:this.lang.get("delete"),api:"plugin.variable.remove",args:s}};e.set(t,s,n,"bottom")}},start:function(){if(this.opts.variables){var t={title:this.lang.get("variable"),api:"plugin.variable.open"},e=this.toolbar.addButton("variable",t);e.setIcon('<i class="re-icon-variable"></i>')}},open:function(){var t={title:this.lang.get("variable"),width:"600px",name:"variable"};this.$currentItem=this._getCurrent(),this.app.api("module.modal.build",t)},insert:function(t){this.app.api("module.modal.close");var e=t.attr("data-type"),i=this.component.create("variable");i.html(e),this.insertion.insertRaw(i)},remove:function(t){this.component.remove(t)},_getCurrent:function(){var t=this.selection.getCurrent(),e=this.inspector.parse(t);if(e.isComponentType("variable"))return this.component.build(e.getComponent())},_build:function(t){var e=t.getBody(),i=this._buildLabel(),s=this._buildList();this._buildItems(s),e.html(""),e.append(i),e.append(s)},_buildLabel:function(){var e=t.dom("<label>");return e.html(this.lang.parse("## variable-select ##:")),e},_buildList:function(){var e=t.dom("<ul>");return e.addClass("redactor-variables-list"),e},_buildItems:function(e){for(var i=this._getCurrentType(),s=this.opts.variables,n=0;n<s.length;n++){var r=s[n].trim(),o=t.dom("<li>"),a=t.dom("<span>");a.attr("data-type",r),a.html(r),a.on("click",this._toggle.bind(this)),i===r&&a.addClass("redactor-variables-item-selected"),o.append(a),e.append(o)}},_getCurrentType:function(){if(this.$currentItem){var t=this.$currentItem.getData();return t.type}return!1},_toggle:function(e){var i=t.dom(e.target);this.app.api("plugin.variable.insert",i)}})}(Redactor),function(t){t.add("class","variable.component",{mixins:["dom","component"],init:function(t,e){return this.app=t,this.utils=t.utils,e&&void 0!==e.cmnt?e:this._init(e)},getData:function(){return{type:this._getType()}},_init:function(t){t=t||"<span>",this.parse(t),this._initWrapper()},_getType:function(){var t=this.text().trim();return this.utils.removeInvisibleChars(t)},_initWrapper:function(){this.addClass("redactor-component"),this.attr({"data-redactor-type":"variable",tabindex:"-1",contenteditable:!1})}})}(Redactor),function(t){t.add("plugin","video",{translations:{en:{video:"Video","video-html-code":"Video Embed Code or Youtube/Vimeo Link"}},modals:{video:'<form action=""> <div class="form-item"> <label for="modal-video-input">## video-html-code ##</label> <textarea id="modal-video-input" name="video" style="height: 160px;"></textarea> </div> </form>'},init:function(t){this.app=t,this.lang=t.lang,this.opts=t.opts,this.toolbar=t.toolbar,this.component=t.component,this.insertion=t.insertion,this.inspector=t.inspector,this.selection=t.selection},onmodal:{video:{opened:function(t,e){$video=e.getField("video"),$video.focus()},insert:function(t,e){var i=e.getData();this._insert(i)}}},oncontextbar:function(t,e){var i=this.inspector.parse(t.target);if(i.isComponentType("video")){var s=i.getComponent(),n={remove:{title:this.lang.get("delete"),api:"plugin.video.remove",args:s}};e.set(t,s,n,"bottom")}},start:function(){var t={title:this.lang.get("video"),api:"plugin.video.open"},e=this.toolbar.addButtonAfter("image","video",t);e.setIcon('<i class="re-icon-video"></i>')},open:function(){var t={title:this.lang.get("video"),width:"600px",name:"video",handle:"insert",commands:{insert:{title:this.lang.get("insert")},cancel:{title:this.lang.get("cancel")}}};this.app.api("module.modal.build",t)},remove:function(t){this.component.remove(t)},_insert:function(t){if(this.app.api("module.modal.close"),""!==t.video.trim()&&(t.video=this._matchData(t.video),this._isVideoIframe(t.video))){var e=this.component.create("video",t.video);this.insertion.insertHtml(e)}},_isVideoIframe:function(t){return null!==t.match(/<iframe|<video/gi)},_matchData:function(t){var e='<iframe style="width: 500px; height: 281px;" src="',i='" frameborder="0" allowfullscreen></iframe>';if(this._isVideoIframe(t)){var s=["iframe","video","source"],n=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;t=t.replace(/<p(.*?[^>]?)>([\w\W]*?)<\/p>/gi,""),t=t.replace(n,function(t,e){return s.indexOf(e.toLowerCase())===-1?"":t})}else if(t.match(this.opts.regex.youtube)){var r="//www.youtube.com";t.search("youtube-nocookie.com")!==-1&&(r="//www.youtube-nocookie.com"),t=t.replace(this.opts.regex.youtube,e+r+"/embed/$1"+i)}else t.match(this.opts.regex.vimeo)&&(t=t.replace(this.opts.regex.vimeo,e+"//player.vimeo.com/video/$2"+i));return t}})}(Redactor),function(t){t.add("plugin","widget",{translations:{en:{widget:"Widget","widget-html-code":"Widget HTML Code"}},modals:{widget:'<form action=""> <div class="form-item"> <label for="modal-widget-input">## widget-html-code ##</label> <textarea id="modal-widget-input" name="widget" style="height: 200px;"></textarea> </div> </form>'},init:function(t){this.app=t,this.lang=t.lang,this.opts=t.opts,this.toolbar=t.toolbar,this.component=t.component,this.insertion=t.insertion,this.inspector=t.inspector,this.selection=t.selection},onmodal:{widget:{opened:function(t,e){if(e.getField("widget").focus(),this.$currentItem){var i=decodeURI(this.$currentItem.attr("data-widget-code"));e.getField("widget").val(i)}},insert:function(t,e){var i=e.getData();this._insert(i)}}},oncontextbar:function(t,e){var i=this.inspector.parse(t.target);if(!i.isFigcaption()&&i.isComponentType("widget")){var s=i.getComponent(),n={edit:{title:this.lang.get("edit"),api:"plugin.widget.open",args:s},remove:{title:this.lang.get("delete"),api:"plugin.widget.remove",args:s}};e.set(t,s,n,"bottom")}},onbutton:{widget:{observe:function(t){this._observeButton(t)}}},start:function(){var t={title:this.lang.get("widget"),api:"plugin.widget.open",observe:"widget"},e=this.toolbar.addButton("widget",t);e.setIcon('<i class="re-icon-widget"></i>')},open:function(){this.$currentItem=this._getCurrent();var t={title:this.lang.get("widget"),width:"600px",name:"widget",handle:"insert",commands:{insert:{title:this.$currentItem?this.lang.get("save"):this.lang.get("insert")},cancel:{title:this.lang.get("cancel")}}};this.app.api("module.modal.build",t)},remove:function(t){this.component.remove(t)},_getCurrent:function(){var t=this.selection.getCurrent(),e=this.inspector.parse(t);if(e.isComponentType("widget"))return this.component.build(e.getComponent())},_insert:function(t){if(this.app.api("module.modal.close"),""!==t.widget.trim()){var e=this._isHtmlString(t.widget)?t.widget:document.createTextNode(t.widget),i=this.component.create("widget",e);i.attr("data-widget-code",encodeURI(t.widget.trim())),this.insertion.insertHtml(i)}},_isHtmlString:function(t){return!("string"==typeof t&&!/^\s*<(\w+|!)[^>]*>/.test(t))},_observeButton:function(t){var e=this.selection.getCurrent(),i=this.inspector.parse(e);i.isComponentType("table")?t.disable():t.enable()}})}(Redactor);
| ver. 1.4 |
Github
|
.
| PHP 8.2.30 | Генерация страницы: 0.12 |
proxy
|
phpinfo
|
Настройка