mirror of
https://github.com/documize/community.git
synced 2025-07-18 20:59:43 +02:00
8 lines
No EOL
221 KiB
JavaScript
8 lines
No EOL
221 KiB
JavaScript
!function(factory){"function"==typeof define&&define.amd?define(["jquery"],factory):"object"==typeof module&&module.exports?module.exports=function(root,jQuery){return void 0===jQuery&&(jQuery="undefined"!=typeof window?require("jquery"):require("jquery")(root)),factory(jQuery),jQuery}:factory(jQuery)}(function($){"use strict";var FroalaEditor=function(element,options){this.opts=$.extend({},FroalaEditor.DEFAULTS,$(element).data(),"object"==typeof options&&options),this.$original_element=$(element),this.$original_element.data("froala.editor",this),this.id=++$.FroalaEditor.ID,this.original_document=element.ownerDocument,this.original_window="defaultView"in this.original_document?this.original_document.defaultView:this.original_document.parentWindow;var c_scroll=$(this.original_window).scrollTop();this.$original_element.on("froala.doInit",$.proxy(function(){this.$original_element.off("froala.doInit"),this.document=this.$el.get(0).ownerDocument,this.window="defaultView"in this.document?this.document.defaultView:this.document.parentWindow,this.$document=$(this.document),this.$window=$(this.window),this.opts.initOnClick?(this.load($.FroalaEditor.MODULES),this.$el.on("mousedown.init dragenter.init focus.init",$.proxy(function(e){if(1===e.which){this.$el.off("mousedown.init dragenter.init focus.init"),this.load($.FroalaEditor.MODULES),this.load($.FroalaEditor.PLUGINS);var target=e.originalEvent&&e.originalEvent.originalTarget;target&&"IMG"==target.tagName&&$(target).trigger("mousedown"),"undefined"==typeof this.ul&&this.destroy(),this.events.trigger("initialized")}},this))):(this.load($.FroalaEditor.MODULES),this.load($.FroalaEditor.PLUGINS),$(this.original_window).scrollTop(c_scroll),"undefined"==typeof this.ul&&this.destroy(),this.events.trigger("initialized"))},this)),this._init()};FroalaEditor.DEFAULTS={initOnClick:!1},FroalaEditor.MODULES={},FroalaEditor.PLUGINS={},FroalaEditor.VERSION="2.0.5",FroalaEditor.INSTANCES=[],FroalaEditor.ID=0,FroalaEditor.prototype._init=function(){var tag_name=this.$original_element.prop("tagName"),initOnDefault=$.proxy(function(){this._original_html=this._original_html||this.$original_element.html(),this.$box=this.$box||this.$original_element,this.opts.fullPage&&(this.opts.iframe=!0),this.opts.iframe?(this.$iframe=$('<iframe src="about:blank" frameBorder="0">'),this.$wp=$("<div></div>"),this.$box.html(this.$wp),this.$wp.append(this.$iframe),this.$iframe.get(0).contentWindow.document.open(),this.$iframe.get(0).contentWindow.document.write("<!DOCTYPE html>"),this.$iframe.get(0).contentWindow.document.write("<html><head></head><body></body></html>"),this.$iframe.get(0).contentWindow.document.close(),this.$el=this.$iframe.contents().find("body"),this.$head=this.$iframe.contents().find("head"),this.$html=this.$iframe.contents().find("html"),this.iframe_document=this.$iframe.get(0).contentWindow.document,this.$original_element.trigger("froala.doInit")):(this.$el=$("<div></div>"),this.$wp=$("<div></div>").append(this.$el),this.$box.html(this.$wp),this.$original_element.trigger("froala.doInit"))},this),initOnTextarea=$.proxy(function(){this.$box=$("<div>"),this.$original_element.before(this.$box).hide(),this._original_html=this.$original_element.val(),this.$original_element.parents("form").on("submit."+this.id,$.proxy(function(){this.events.trigger("form.submit")},this)),initOnDefault()},this),initOnA=$.proxy(function(){this.$el=this.$original_element,this.$el.attr("contenteditable",!0).css("outline","none"),this.opts.multiLine=!1,this.$original_element.trigger("froala.doInit")},this),initOnImg=$.proxy(function(){this.$el=this.$original_element,this.$original_element.trigger("froala.doInit")},this),editInPopup=$.proxy(function(){this.$el=this.$original_element,this.$original_element.trigger("froala.doInit")},this);this.opts.editInPopup?editInPopup():"TEXTAREA"==tag_name?initOnTextarea():"A"==tag_name?initOnA():"IMG"==tag_name?initOnImg():"BUTTON"==tag_name?(this.opts.editInPopup=!0,editInPopup()):("DIV"!==tag_name&&(this.opts.enter=$.FroalaEditor.ENTER_BR),initOnDefault())},FroalaEditor.prototype.load=function(module_list){for(var m_name in module_list)if(!this[m_name]&&(this[m_name]=new module_list[m_name](this),this[m_name]._init&&(this[m_name]._init(),this.opts.initOnClick&&"core"==m_name)))return!1},FroalaEditor.prototype.destroy=function(){this.events.trigger("destroy"),this.$original_element.parents("form").off("submit."+this.id),this.$original_element.removeData("froala.editor")},$.fn.froalaEditor=function(option){for(var arg_list=[],i=0;i<arguments.length;i++)arg_list.push(arguments[i]);if("string"==typeof option){var returns=[];return this.each(function(){var $this=$(this),editor=$this.data("froala.editor");if(!editor)return console.warn("Editor should be initialized before calling the "+option+" method.");var context,nm;if(option.indexOf(".")>0&&editor[option.split(".")[0]]?(editor[option.split(".")[0]]&&(context=editor[option.split(".")[0]]),nm=option.split(".")[1]):(context=editor,nm=option.split(".")[0]),!context[nm])return $.error("Method "+option+" does not exist in Froala Editor.");var returned_value=context[nm].apply(editor,arg_list.slice(1));void 0===returned_value?returns.push(this):0===returns.length&&returns.push(returned_value)}),1==returns.length?returns[0]:returns}return"object"!=typeof option&&option?void 0:this.each(function(){var editor=$(this).data("froala.editor");editor||new FroalaEditor(this,option)})},$.fn.froalaEditor.Constructor=FroalaEditor,$.FroalaEditor=FroalaEditor,$.FroalaEditor.MODULES.node=function(editor){function getContents(node){return node&&"IFRAME"!=node.tagName?$(node).contents():[]}function isBlock(node){return node?node.nodeType!=Node.ELEMENT_NODE?!1:$.FroalaEditor.BLOCK_TAGS.indexOf(node.tagName.toLowerCase())>=0:!1}function isEmpty(el,ignore_markers){if($(el).find("table").length>0)return!1;var contents=getContents(el);1==contents.length&&isBlock(contents[0])&&(contents=getContents(contents[0]));for(var has_br=!1,i=0;i<contents.length;i++){var node=contents[i];if(!ignore_markers||!$(node).hasClass("fr-marker")){if(!("BR"==node.tagName||node.textContent&&0==node.textContent.replace(/\u200B/gi,"").length)||1==has_br)return!1;"BR"==node.tagName&&(has_br=!0)}}return!0}function blockParent(node){for(;node&&node.parentNode!==editor.$el.get(0)&&(!node.parentNode||!$(node.parentNode).hasClass("fr-inner"));)if(node=node.parentNode,isBlock(node))return node;return null}function deepestParent(node,until,simple_enter){if("undefined"==typeof until&&(until=[]),"undefined"==typeof simple_enter&&(simple_enter=!0),until.push(editor.$el.get(0)),until.indexOf(node.parentNode)>=0||node.parentNode&&$(node.parentNode).hasClass("fr-inner")||node.parentNode&&$.FroalaEditor.SIMPLE_ENTER_TAGS.indexOf(node.parentNode.tagName)>=0&&simple_enter)return null;for(;until.indexOf(node.parentNode)<0&&node.parentNode&&!$(node.parentNode).hasClass("fr-inner")&&($.FroalaEditor.SIMPLE_ENTER_TAGS.indexOf(node.parentNode.tagName)<0||!simple_enter)&&(!isBlock(node)||!isBlock(node.parentNode)||!simple_enter);)node=node.parentNode;return node}function rawAttributes(node){var attrs={},atts=node.attributes;if(atts)for(var i=0;i<atts.length;i++){var att=atts[i];attrs[att.nodeName]=att.value}return attrs}function attributes(node){for(var str="",atts=rawAttributes(node),keys=Object.keys(atts).sort(),i=0;i<keys.length;i++){var nodeName=keys[i],value=atts[nodeName];str+=value.indexOf('"')<0?" "+nodeName+'="'+value+'"':" "+nodeName+"='"+value+"'"}return str}function clearAttributes(node){for(var atts=node.attributes,i=0;i<atts.length;i++){var att=atts[i];node.removeAttribute(att.nodeName)}}function openTagString(node){return"<"+node.tagName.toLowerCase()+attributes(node)+">"}function closeTagString(node){return"</"+node.tagName.toLowerCase()+">"}function isFirstSibling(node,ignore_markers){"undefined"==typeof ignore_markers&&(ignore_markers=!0);for(var sibling=node.previousSibling;sibling&&ignore_markers&&$(sibling).hasClass("fr-marker");)sibling=sibling.previousSibling;return sibling?sibling.nodeType==Node.TEXT_NODE&&""===sibling.textContent?isFirstSibling(sibling):!1:!0}function isVoid(node){return node&&$.FroalaEditor.VOID_ELEMENTS.indexOf((node.tagName||"").toLowerCase())>=0}function isList(node){return node?["UL","OL"].indexOf(node.tagName)>=0:!1}function isElement(node){return node===editor.$el.get(0)}function hasFocus(node){return node===editor.document.activeElement&&(!editor.document.hasFocus||editor.document.hasFocus())&&!!(isElement(node)||node.type||node.href||~node.tabIndex)}function isEditable(node){return!node.getAttribute||"false"!=node.getAttribute("contenteditable")}return{isBlock:isBlock,isEmpty:isEmpty,blockParent:blockParent,deepestParent:deepestParent,rawAttributes:rawAttributes,attributes:attributes,clearAttributes:clearAttributes,openTagString:openTagString,closeTagString:closeTagString,isFirstSibling:isFirstSibling,isList:isList,isElement:isElement,contents:getContents,isVoid:isVoid,hasFocus:hasFocus,isEditable:isEditable}},$.extend($.FroalaEditor.DEFAULTS,{htmlAllowedTags:["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","br","button","canvas","caption","cite","code","col","colgroup","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meter","nav","noscript","object","ol","optgroup","option","output","p","param","pre","progress","queue","rp","rt","ruby","s","samp","script","style","section","select","small","source","span","strike","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","var","video","wbr"],htmlRemoveTags:["script","style"],htmlAllowedAttrs:["accept","accept-charset","accesskey","action","align","allowfullscreen","allowtransparency","alt","async","autocomplete","autofocus","autoplay","autosave","background","bgcolor","border","charset","cellpadding","cellspacing","checked","cite","class","color","cols","colspan","content","contenteditable","contextmenu","controls","coords","data","data-.*","datetime","default","defer","dir","dirname","disabled","download","draggable","dropzone","enctype","for","form","formaction","fr-.*","frameborder","headers","height","hidden","high","href","hreflang","http-equiv","icon","id","ismap","itemprop","keytype","kind","label","lang","language","list","loop","low","max","maxlength","media","method","min","mozallowfullscreen","multiple","name","novalidate","open","optimum","pattern","ping","placeholder","poster","preload","pubdate","radiogroup","readonly","rel","required","reversed","rows","rowspan","sandbox","scope","scoped","scrolling","seamless","selected","shape","size","sizes","span","src","srcdoc","srclang","srcset","start","step","summary","spellcheck","style","tabindex","target","title","type","translate","usemap","value","valign","webkitallowfullscreen","width","wrap"],htmlAllowComments:!0,fullPage:!1}),$.FroalaEditor.HTML5Map={B:"STRONG",I:"EM",STRIKE:"S"},$.FroalaEditor.MODULES.clean=function(editor){function _removeInvisible(node){if(node.className&&node.className.indexOf("fr-marker")>=0)return!1;var i,contents=editor.node.contents(node),markers=[];for(i=0;i<contents.length;i++)contents[i].className&&contents[i].className.indexOf("fr-marker")>=0&&markers.push(contents[i]);if(contents.length-markers.length==1&&0===node.textContent.replace(/\u200b/g,"").length){for(i=0;i<markers.length;i++)node.parentNode.insertBefore(markers[i].cloneNode(!0),node);return node.parentNode.removeChild(node),!1}for(i=0;i<contents.length;i++)contents[i].nodeType==Node.ELEMENT_NODE?contents[i].textContent.replace(/\u200b/g,"").length!=contents[i].textContent.length&&_removeInvisible(contents[i]):contents[i].nodeType==Node.TEXT_NODE&&(contents[i].textContent=contents[i].textContent.replace(/\u200b/g,""))}function _toHTML(el){if(el.nodeType==Node.COMMENT_NODE)return"<!--"+el.nodeValue+"-->";if(el.nodeType==Node.TEXT_NODE)return el.textContent.replace(/\</g,"<").replace(/\>/g,">").replace(/\u00A0/g," ");if(el.nodeType!=Node.ELEMENT_NODE)return el.outerHTML;if(el.nodeType==Node.ELEMENT_NODE&&["STYLE","SCRIPT"].indexOf(el.tagName)>=0)return el.outerHTML;if("IFRAME"==el.tagName)return el.outerHTML;var contents=el.childNodes;if(0===contents.length)return el.outerHTML;for(var str="",i=0;i<contents.length;i++)str+=_toHTML(contents[i]);return editor.node.openTagString(el)+str+editor.node.closeTagString(el)}function _encode(dirty_html){return scripts=[],dirty_html=dirty_html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,function(str){return scripts.push(str),"<!--[FROALA.EDITOR.SCRIPT "+(scripts.length-1)+"]-->"}),dirty_html=dirty_html.replace(/<img((?:[\w\W]*?)) src="/g,'<img$1 data-src="')}function _decode(dirty_html){return dirty_html=dirty_html.replace(/<!--\[FROALA\.EDITOR\.SCRIPT ([\d]*)]-->/gi,function(str,a1){return scripts[parseInt(a1,10)]}),editor.opts.htmlRemoveTags.indexOf("script")>=0&&(dirty_html=dirty_html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"")),dirty_html=dirty_html.replace(/<img((?:[\w\W]*?)) data-src="/g,'<img$1 src="')}function _cleanAttrs(attrs){var nm;for(nm in attrs)nm.match(allowedAttrsRE)||delete attrs[nm];for(var str="",keys=Object.keys(attrs).sort(),i=0;i<keys.length;i++)nm=keys[i],str+=attrs[nm].indexOf('"')<0?" "+nm+'="'+attrs[nm]+'"':" "+nm+"='"+attrs[nm]+"'";return str}function _rebuild(body_html,head_html,original_html){if(editor.opts.fullPage){var doctype=editor.html.extractDoctype(original_html),html_attrs=_cleanAttrs(editor.html.extractNodeAttrs(original_html,"html"));head_html=null==head_html?editor.html.extractNode(original_html,"head")||"<title></title>":head_html;var head_attrs=_cleanAttrs(editor.html.extractNodeAttrs(original_html,"head")),body_attrs=_cleanAttrs(editor.html.extractNodeAttrs(original_html,"body"));return doctype+"<html"+html_attrs+"><head"+head_attrs+">"+head_html+"</head><body"+body_attrs+">"+body_html+"</body></html>"}return body_html}function _process(html,func){var $el=$("<div>"+html+"</div>"),new_html="";if($el){for(var els=editor.node.contents($el.get(0)),i=0;i<els.length;i++)func(els[i]);els=editor.node.contents($el.get(0));for(var i=0;i<els.length;i++)new_html+=_toHTML(els[i])}return new_html}function exec(html,func,parse_head){html=_encode(html);var b_html=html,h_html=null;if(editor.opts.fullPage){var b_html=(editor.html.extractNode(html,"body")||html).replace(/\r|\n/g,"");parse_head&&(h_html=(editor.html.extractNode(html,"head")||"").replace(/\r|\n/g,""))}b_html=_process(b_html,func),h_html&&(h_html=_process(h_html,func));var new_html=_rebuild(b_html,h_html,html).replace(/\r|\n/g,"");return _decode(new_html)}function invisibleSpaces(dirty_html){return dirty_html.replace(/\u200b/g,"").length==dirty_html.length?dirty_html:editor.clean.exec(dirty_html,_removeInvisible)}function toHTML5(){var $els=editor.$el.find(Object.keys($.FroalaEditor.HTML5Map).join(",")).filter(function(){return""===editor.node.attributes(this)});$els.length&&(editor.selection.save(),$els.each(function(){$(this).replaceWith("<"+$.FroalaEditor.HTML5Map[this.tagName]+">"+$(this).html()+"</"+$.FroalaEditor.HTML5Map[this.tagName]+">")}),editor.selection.restore())}function _node(node){if("PRE"==node.tagName&&_cleanPre(node),node.nodeType==Node.ELEMENT_NODE&&(node.getAttribute("data-src")&&node.setAttribute("data-src",editor.helpers.sanitizeURL(node.getAttribute("data-src"))),node.getAttribute("href")&&node.setAttribute("href",editor.helpers.sanitizeURL(node.getAttribute("href"))),["TABLE","TBODY","TFOOT","TR"].indexOf(node.tagName)>=0&&(node.innerHTML=node.innerHTML.trim())),!editor.opts.pasteAllowLocalImages&&node.nodeType==Node.ELEMENT_NODE&&"IMG"==node.tagName&&node.getAttribute("data-src")&&0==node.getAttribute("data-src").indexOf("file://"))return node.parentNode.removeChild(node),!1;if(node.nodeType==Node.ELEMENT_NODE&&$.FroalaEditor.HTML5Map[node.tagName]&&""===editor.node.attributes(node)){var tg=$.FroalaEditor.HTML5Map[node.tagName],new_node="<"+tg+">"+node.innerHTML+"</"+tg+">";node.insertAdjacentHTML("beforebegin",new_node),node=node.previousSibling,node.parentNode.removeChild(node.nextSibling)}if(editor.opts.htmlAllowComments||node.nodeType!=Node.COMMENT_NODE)if(node.tagName&&node.tagName.match(removeTagsRE))node.parentNode.removeChild(node);else if(node.tagName&&!node.tagName.match(allowedTagsRE))node.outerHTML=node.innerHTML;else{var attrs=node.attributes;if(attrs)for(var i=attrs.length-1;i>=0;i--){var attr=attrs[i];attr.nodeName.match(allowedAttrsRE)||node.removeAttribute(attr.nodeName)}}else 0!==node.data.indexOf("[FROALA.EDITOR")&&node.parentNode.removeChild(node)}function _run(node){for(var contents=editor.node.contents(node),i=0;i<contents.length;i++)contents[i].nodeType!=Node.TEXT_NODE&&_run(contents[i]);_node(node)}function _cleanPre(pre){var content=pre.innerHTML;content.indexOf("\n")>=0&&(pre.innerHTML=content.replace(/\n/g,"<br>"))}function html(dirty_html,denied_tags,denied_attrs,full_page){"undefined"==typeof denied_tags&&(denied_tags=[]),"undefined"==typeof denied_attrs&&(denied_attrs=[]),"undefined"==typeof full_page&&(full_page=!1),dirty_html=dirty_html.replace(/\u0009/g,"");var i,allowed_tags=$.merge([],editor.opts.htmlAllowedTags);for(i=0;i<denied_tags.length;i++)allowed_tags.indexOf(denied_tags[i])>=0&&allowed_tags.splice(allowed_tags.indexOf(denied_tags[i]),1);var allowed_attrs=$.merge([],editor.opts.htmlAllowedAttrs);for(i=0;i<denied_attrs.length;i++)allowed_attrs.indexOf(denied_attrs[i])>=0&&allowed_attrs.splice(allowed_attrs.indexOf(denied_attrs[i]),1);return allowedTagsRE=new RegExp("^"+allowed_tags.join("$|^")+"$","gi"),allowedAttrsRE=new RegExp("^"+allowed_attrs.join("$|^")+"$","gi"),removeTagsRE=new RegExp("^"+editor.opts.htmlRemoveTags.join("$|^")+"$","gi"),dirty_html=exec(dirty_html,_run,!0)}function quotes(){for(var sibling_quotes=editor.$el.find("blockquote + blockquote"),k=0;k<sibling_quotes.length;k++){var $quote=$(sibling_quotes[k]);editor.node.attributes(sibling_quotes[k])==editor.node.attributes($quote.prev().get(0))&&($quote.prev().append($quote.html()),$quote.remove())}}function tables(){for(var trs=editor.$el.find("tr").filter(function(){return $(this).find("th").length>0}),i=0;i<trs.length;i++){var $thead=$(trs[i]).parents("table:first").find("thead");0===$thead.length&&($thead=$("<thead>"),$(trs[i]).parents("table:first").prepend($thead),$thead.append(trs[i]))}editor.$el.find("table").filter(function(){for(var prev_node=this.previousSibling;prev_node&&prev_node.nodeType==Node.TEXT_NODE&&0==prev_node.textContent.length;)prev_node=prev_node.previousSibling;return prev_node&&!editor.node.isBlock(prev_node)&&"BR"!=prev_node.tagName?!0:!1}).before("<br>");var default_tag=editor.html.defaultTag();default_tag&&editor.$el.find("td > "+default_tag+", th > "+default_tag).each(function(){""===editor.node.attributes(this)&&$(this).replaceWith(this.innerHTML+"<br>")})}function lists(){for(var sibling_lists=editor.$el.find("ol + ol, ul + ul"),k=0;k<sibling_lists.length;k++){var $list=$(sibling_lists[k]);editor.node.attributes(sibling_lists[k])==editor.node.attributes($list.prev().get(0))&&($list.prev().append($list.html()),$list.remove())}var $lis=[],filterListItem=function(){return!editor.node.isList(this.parentNode)};do{if($lis.length){var li=$lis.get(0),$ul=$("<ul></ul>").insertBefore($(li));do{var tmp=li;li=li.nextSibling,$ul.append($(tmp))}while(li&&"LI"==li.tagName)}$lis=editor.$el.find("li").filter(filterListItem)}while($lis.length>0);var do_remove,removeEmptyList=function(index,lst){var $lst=$(lst);0===$lst.find("LI").length&&(do_remove=!0,$lst.remove())};do do_remove=!1,editor.$el.find("li:empty").remove(),editor.$el.find("ul, ol").each(removeEmptyList);while(do_remove===!0);for(var direct_lists=editor.$el.find("ol, ul").find("> ul, > ol"),i=0;i<direct_lists.length;i++){var list=direct_lists[i],prev_li=list.previousSibling;prev_li&&("LI"==prev_li.tagName?$(prev_li).append(list):$(list).wrap("<li></li>"))}editor.$el.find("li > ul, li > ol").each(function(idx,lst){if(lst.nextSibling){var node=lst.nextSibling,$new_li=$("<li>");$(lst.parentNode).after($new_li);do{var tmp=node;node=node.nextSibling,$new_li.append(tmp)}while(node)}}),editor.$el.find("li > ul, li > ol").each(function(idx,lst){if(editor.node.isFirstSibling(lst))$(lst).before("<br/>");else if(lst.previousSibling&&"BR"==lst.previousSibling.tagName){for(var prev_node=lst.previousSibling.previousSibling;prev_node&&$(prev_node).hasClass("fr-marker");)prev_node=prev_node.previousSibling;prev_node&&"BR"!=prev_node.tagName&&$(lst.previousSibling).remove()}}),editor.$el.find("li:empty").remove()}function _init(){editor.opts.fullPage&&$.merge(editor.opts.htmlAllowedTags,["head","title","style","link","base","body","html"])}var allowedTagsRE,removeTagsRE,allowedAttrsRE,scripts=[],scripts=[];return{_init:_init,html:html,toHTML5:toHTML5,tables:tables,lists:lists,quotes:quotes,invisibleSpaces:invisibleSpaces,exec:exec}},$.FroalaEditor.XS=0,$.FroalaEditor.SM=1,$.FroalaEditor.MD=2,$.FroalaEditor.LG=3,$.FroalaEditor.MODULES.helpers=function(editor){function _ieVersion(){var ua,re,rv=-1;return"Microsoft Internet Explorer"==navigator.appName?(ua=navigator.userAgent,re=new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})"),null!==re.exec(ua)&&(rv=parseFloat(RegExp.$1))):"Netscape"==navigator.appName&&(ua=navigator.userAgent,re=new RegExp("Trident/.*rv:([0-9]{1,}[\\.0-9]{0,})"),null!==re.exec(ua)&&(rv=parseFloat(RegExp.$1))),rv}function _browser(){var browser={};if(_ieVersion()>0)browser.msie=!0;else{var ua=navigator.userAgent.toLowerCase(),match=/(edge)[ \/]([\w.]+)/.exec(ua)||/(chrome)[ \/]([\w.]+)/.exec(ua)||/(webkit)[ \/]([\w.]+)/.exec(ua)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua)||/(msie) ([\w.]+)/.exec(ua)||ua.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua)||[],matched={browser:match[1]||"",version:match[2]||"0"};match[1]&&(browser[matched.browser]=!0),parseInt(matched.version,10)<9&&browser.msie&&(browser.oldMsie=!0),browser.chrome?browser.webkit=!0:browser.webkit&&(browser.safari=!0)}return browser}function isIOS(){return/(iPad|iPhone|iPod)/g.test(navigator.userAgent)&&!isWindowsPhone()}function isAndroid(){return/(Android)/g.test(navigator.userAgent)&&!isWindowsPhone()}function isBlackberry(){return/(Blackberry)/g.test(navigator.userAgent)}function isWindowsPhone(){return/(Windows Phone)/gi.test(navigator.userAgent)}function isMobile(){return isAndroid()||isIOS()||isBlackberry()}function requestAnimationFrame(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(callback){window.setTimeout(callback,1e3/60)}}function getPX(val){return parseInt(val,10)||0}function screenSize(){var $test=$('<div class="fr-visibility-helper"></div>').appendTo("body"),size=getPX($test.css("margin-left"));return $test.remove(),size}function isTouch(){return"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch}function isURL(url){if(!/^(https?:|ftps?:|)\/\//.test(url))return!1;url=String(url).replace(/</g,"%3C").replace(/>/g,"%3E").replace(/"/g,"%22").replace(/ /g,"%20");var test_reg=/\(?(?:(https?:|ftps?:|)\/\/)?(?:((?:[^\W\s]|\.|-|[:]{1})+)@{1})?((?:www.)?(?:[^\W\s]|\.|-)+[\.][^\W\s]{2,4}|(?:www.)?(?:[^\W\s]|\.|-)|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?::(\d*))?([\/]?[^\s\?]*[\/]{1})*(?:\/?([^\s\n\?\[\]\{\}\#]*(?:(?=\.)){1}|[^\s\n\?\[\]\{\}\.\#]*)?([\.]{1}[^\s\?\#]*)?)?(?:\?{1}([^\s\n\#\[\]]*))?([\#][^\s\n]*)?\)?/gi;return test_reg.test(url)}function sanitizeURL(url){if(/^(https?:|ftps?:|)\/\//.test(url)){if(!isURL(url))return""}else url=encodeURIComponent(url).replace(/%23/g,"#").replace(/%2F/g,"/").replace(/%25/g,"%").replace(/mailto%3A/g,"mailto:").replace(/file%3A/g,"file:").replace(/sms%3A/g,"sms:").replace(/tel%3A/g,"tel:").replace(/data%3Aimage/g,"data:image").replace(/webkit-fake-url%3A/g,"webkit-fake-url:").replace(/%3F/g,"?").replace(/%3D/g,"=").replace(/%26/g,"&").replace(/&/g,"&").replace(/%2C/g,",").replace(/%3B/g,";").replace(/%2B/g,"+").replace(/%40/g,"@");return url}function isArray(obj){return obj&&!obj.propertyIsEnumerable("length")&&"object"==typeof obj&&"number"==typeof obj.length}function RGBToHex(rgb){function hex(x){return("0"+parseInt(x,10).toString(16)).slice(-2)}try{return rgb&&"transparent"!==rgb?/^#[0-9A-F]{6}$/i.test(rgb)?rgb:(rgb=rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/),("#"+hex(rgb[1])+hex(rgb[2])+hex(rgb[3])).toUpperCase()):""}catch(ex){return null}}function HEXtoRGB(hex){var shorthandRegex=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;hex=hex.replace(shorthandRegex,function(m,r,g,b){return r+r+g+g+b+b});var result=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);return result?"rgb("+parseInt(result[1],16)+", "+parseInt(result[2],16)+", "+parseInt(result[3],16)+")":""}function getAlignment($block){var alignment=($block.css("text-align")||"").replace(/-(.*)-/g,"");if(["left","right","justify","center"].indexOf(alignment)<0){if(!default_alignment){var $div=$('<div dir="auto" style="text-align: initial; position: fixed; left: -3000px;"><span id="s1">.</span><span id="s2">.</span></div>');$("body").append($div);var l1=$div.find("#s1").get(0).getBoundingClientRect().left,l2=$div.find("#s2").get(0).getBoundingClientRect().left;$div.remove(),default_alignment=l2>l1?"left":"right"}alignment=default_alignment}return alignment}function _init(){editor.browser=_browser(),editor.ie_version=_ieVersion()}var default_alignment;return{_init:_init,isIOS:isIOS,isAndroid:isAndroid,isBlackberry:isBlackberry,isWindowsPhone:isWindowsPhone,isMobile:isMobile,requestAnimationFrame:requestAnimationFrame,getPX:getPX,screenSize:screenSize,isTouch:isTouch,sanitizeURL:sanitizeURL,isArray:isArray,RGBToHex:RGBToHex,HEXtoRGB:HEXtoRGB,isURL:isURL,getAlignment:getAlignment}},$.FroalaEditor.MODULES.events=function(editor){function _assignEvent($el,events,handler){$el.on(events.split(" ").join("."+editor.id+" ")+"."+editor.id,handler),on("destroy",function(){$el.off(events.split(" ").join("."+editor.id+" ")+"."+editor.id)})}function _forPaste(){_assignEvent(editor.$el,"cut copy paste beforepaste",function(e){trigger(e.type,[e])})}function _forElement(){_assignEvent(editor.$el,"click mouseup mousedown touchstart touchend dragenter dragover dragleave dragend drop",function(e){trigger(e.type,[e])})}function _forKeys(){_assignEvent(editor.$el,"keydown keypress keyup input",function(e){trigger(e.type,[e])})}function _forWindow(){_assignEvent(editor.$window,editor._mousedown,function(e){trigger("window.mousedown",[e]),enableBlur()}),_assignEvent(editor.$window,editor._mouseup,function(e){trigger("window.mouseup",[e])}),_assignEvent(editor.$window,"keydown keyup touchmove",function(e){trigger("window."+e.type,[e])})}function _forDocument(){_assignEvent(editor.$document,"drop",function(e){trigger("document.drop",[e])})}function focus(do_focus){if("undefined"==typeof do_focus&&(do_focus=!0),!editor.$wp)return!1;if(!editor.core.hasFocus()&&do_focus)return editor.$el.focus(),!1;if(!editor.core.hasFocus()||editor.$el.find(".fr-marker").length>0)return!1;var info=editor.selection.info(editor.$el.get(0));if(info.atStart&&editor.selection.isCollapsed()&&null!=editor.html.defaultTag()){var marker=editor.markers.insert();if(marker&&!editor.node.blockParent(marker)){$(marker).remove();var element=editor.$el.find(editor.html.blockTagsQuery()).get(0);element&&($(element).prepend($.FroalaEditor.MARKERS),editor.selection.restore())}else marker&&$(marker).remove()}}function _forFocus(){_assignEvent(editor.$el,"focus",function(e){blurActive()&&(focus(!1),focused===!1&&trigger(e.type,[e]))}),_assignEvent(editor.$el,"blur",function(e){blurActive()&&focused===!0&&trigger(e.type,[e])}),on("focus",function(){focused=!0}),on("blur",function(){focused=!1})}function _forMouse(){editor.helpers.isMobile()?(editor._mousedown="touchstart",editor._mouseup="touchend",editor._move="touchmove",editor._mousemove="touchmove"):(editor._mousedown="mousedown",editor._mouseup="mouseup",editor._move="",editor._mousemove="mousemove")}function _buttonMouseDown(e){var $btn=$(e.currentTarget);return editor.edit.isDisabled()||$btn.hasClass("fr-disabled")?(e.preventDefault(),!1):"mousedown"===e.type&&1!==e.which?!0:(editor.helpers.isMobile()||e.preventDefault(),(editor.helpers.isAndroid()||editor.helpers.isWindowsPhone())&&0===$btn.parents(".fr-dropdown-menu").length&&(e.preventDefault(),e.stopPropagation()),$btn.addClass("fr-selected"),void editor.events.trigger("commands.mousedown",[$btn]))}function _buttonMouseUp(e,handler){var $btn=$(e.currentTarget);if(editor.edit.isDisabled()||$btn.hasClass("fr-disabled"))return e.preventDefault(),!1;if("mouseup"===e.type&&1!==e.which)return!0;if(!$btn.hasClass("fr-selected"))return!0;if("touchmove"!=e.type){if(e.stopPropagation(),e.stopImmediatePropagation(),e.preventDefault(),!$btn.hasClass("fr-selected"))return $(".fr-selected").removeClass("fr-selected"),!1;if($(".fr-selected").removeClass("fr-selected"),$btn.data("dragging")||$btn.attr("disabled"))return $btn.removeData("dragging"),!1;var timeout=$btn.data("timeout");timeout&&(clearTimeout(timeout),$btn.removeData("timeout")),handler.apply(editor,[e])}else $btn.data("timeout")||$btn.data("timeout",setTimeout(function(){$btn.data("dragging",!0)},100))}function enableBlur(){_do_blur=!0}function disableBlur(){_do_blur=!1}function blurActive(){return _do_blur}function bindClick($element,selector,handler){$element.on(editor._mousedown,selector,function(e){_buttonMouseDown(e)}),$element.on(editor._mouseup+" "+editor._move,selector,function(e){_buttonMouseUp(e,handler)}),$element.on("mousedown click mouseup",selector,function(e){e.stopPropagation()}),on("window.mouseup",function(){$element.find(selector).removeClass("fr-selected"),enableBlur()}),on("destroy",function(){$element.off(editor._mousedown,selector),$element.off(editor._mouseup+" "+editor._move)})}function on(name,callback,first){"undefined"==typeof first&&(first=!1);var callbacks=_events[name]=_events[name]||[];first?callbacks.unshift(callback):callbacks.push(callback)}function trigger(name,args,force){if(!editor.edit.isDisabled()||force){var val,callbacks=_events[name];if(callbacks)for(var i=0;i<callbacks.length;i++)if(val=callbacks[i].apply(editor,args),val===!1)return!1;return val=editor.$original_element.triggerHandler("froalaEditor."+name,$.merge([editor],args||[])),val===!1?!1:val}}function chainTrigger(name,param,force){if(!editor.edit.isDisabled()||force){var resp,callbacks=_events[name];if(callbacks)for(var i=0;i<callbacks.length;i++)resp=callbacks[i].apply(editor,[param]),"undefined"!=typeof resp&&(param=resp);return resp=editor.$original_element.triggerHandler("froalaEditor."+name,$.merge([editor],[param])),"undefined"!=typeof resp&&(param=resp),param}}function _destroy(){for(var k in _events)delete _events[k]}function _init(){_forMouse(),_forElement(),_forWindow(),_forDocument(),_forKeys(),_forFocus(),enableBlur(),_forPaste(),on("destroy",_destroy)}var _do_blur,_events={},focused=!1;return{_init:_init,on:on,trigger:trigger,bindClick:bindClick,disableBlur:disableBlur,enableBlur:enableBlur,blurActive:blurActive,focus:focus,chainTrigger:chainTrigger}},$.FroalaEditor.INVISIBLE_SPACE="​",$.FroalaEditor.START_MARKER='<span class="fr-marker" data-id="0" data-type="true" style="display: none; line-height: 0;">'+$.FroalaEditor.INVISIBLE_SPACE+"</span>",$.FroalaEditor.END_MARKER='<span class="fr-marker" data-id="0" data-type="false" style="display: none; line-height: 0;">'+$.FroalaEditor.INVISIBLE_SPACE+"</span>",$.FroalaEditor.MARKERS=$.FroalaEditor.START_MARKER+$.FroalaEditor.END_MARKER,$.FroalaEditor.MODULES.markers=function(editor){function _build(marker,id){return $('<span class="fr-marker" data-id="'+id+'" data-type="'+marker+'" style="display: '+(editor.browser.safari?"none":"inline-block")+'; line-height: 0;">'+$.FroalaEditor.INVISIBLE_SPACE+"</span>",editor.document)[0];
|
||
}function place(range,marker,id){try{var boundary=range.cloneRange();if(boundary.collapse(marker),boundary.insertNode(_build(marker,id)),marker===!0&&range.collapsed)for(var sibling=editor.$el.find('span.fr-marker[data-type="true"][data-id="'+id+'"]').get(0).nextSibling;sibling&&sibling.nodeType===Node.TEXT_NODE&&0===sibling.textContent.length;)$(sibling).remove(),sibling=editor.$el.find('span.fr-marker[data-type="true"][data-id="'+id+'"]').get(0).nextSibling;if(marker===!0&&!range.collapsed){var marker=editor.$el.find('span.fr-marker[data-type="true"][data-id="'+id+'"]').get(0),sibling=marker.nextSibling;if(sibling&&sibling.nodeType===Node.ELEMENT_NODE&&editor.node.isBlock(sibling)){var contents=[sibling];do sibling=contents[0],contents=editor.node.contents(sibling);while(contents[0]&&editor.node.isBlock(contents[0]));$(sibling).prepend($(marker))}}if(marker===!1&&!range.collapsed){var marker=editor.$el.find('span.fr-marker[data-type="false"][data-id="'+id+'"]').get(0),sibling=marker.previousSibling;if(sibling&&sibling.nodeType===Node.ELEMENT_NODE&&editor.node.isBlock(sibling)){var contents=[sibling];do sibling=contents[contents.length-1],contents=editor.node.contents(sibling);while(contents[contents.length-1]&&editor.node.isBlock(contents[contents.length-1]));$(sibling).append($(marker))}marker.parentNode&&["TD","TH"].indexOf(marker.parentNode.tagName)>=0&&marker.parentNode.previousSibling&&!marker.previousSibling&&$(marker.parentNode.previousSibling).append(marker)}return marker}catch(ex){return null}}function insert(){if(!editor.$wp)return null;try{var range=editor.selection.ranges(0),containter=range.commonAncestorContainer;if(containter!=editor.$el.get(0)&&0==editor.$el.find(containter).length)return null;var boundary=range.cloneRange(),original_range=range.cloneRange();boundary.collapse(!0);var mk=$('<span class="fr-marker" style="display: none; line-height: 0;">'+$.FroalaEditor.INVISIBLE_SPACE+"</span>",editor.document)[0];if(boundary.insertNode(mk),mk=editor.$el.find("span.fr-marker").get(0)){for(var sibling=mk.nextSibling;sibling&&sibling.nodeType===Node.TEXT_NODE&&0===sibling.textContent.length;)$(sibling).remove(),sibling=editor.$el.find("span.fr-marker").get(0).nextSibling;return editor.selection.clear(),editor.selection.get().addRange(original_range),mk}return null}catch(ex){console.warn("MARKER",ex)}}function insertAtPoint(e){var x=e.clientX,y=e.clientY;remove();var start,range=null;if("undefined"!=typeof editor.document.caretPositionFromPoint?(start=editor.document.caretPositionFromPoint(x,y),range=editor.document.createRange(),range.setStart(start.offsetNode,start.offset),range.setEnd(start.offsetNode,start.offset)):"undefined"!=typeof editor.document.caretRangeFromPoint&&(start=editor.document.caretRangeFromPoint(x,y),range=editor.document.createRange(),range.setStart(start.startContainer,start.startOffset),range.setEnd(start.startContainer,start.startOffset)),null!==range&&"undefined"!=typeof editor.window.getSelection){var sel=editor.window.getSelection();sel.removeAllRanges(),sel.addRange(range)}else if("undefined"!=typeof editor.document.body.createTextRange)try{range=editor.document.body.createTextRange(),range.moveToPoint(x,y);var end_range=range.duplicate();end_range.moveToPoint(x,y),range.setEndPoint("EndToEnd",end_range),range.select()}catch(ex){}insert()}function remove(){editor.$el.find(".fr-marker").remove()}return{place:place,insert:insert,insertAtPoint:insertAtPoint,remove:remove}},$.FroalaEditor.MODULES.selection=function(editor){function text(){var text="";return editor.window.getSelection?text=editor.window.getSelection():editor.document.getSelection?text=editor.document.getSelection():editor.document.selection&&(text=editor.document.selection.createRange().text),text.toString()}function get(){var selection="";return selection=editor.window.getSelection?editor.window.getSelection():editor.document.getSelection?editor.document.getSelection():editor.document.selection.createRange()}function ranges(index){var sel=get(),ranges=[];if(sel&&sel.getRangeAt&&sel.rangeCount)for(var ranges=[],i=0;i<sel.rangeCount;i++)ranges.push(sel.getRangeAt(i));else ranges=editor.document.createRange?[editor.document.createRange()]:[];return"undefined"!=typeof index?ranges[index]:ranges}function clear(){var sel=get();try{sel.removeAllRanges?sel.removeAllRanges():sel.empty?sel.empty():sel.clear&&sel.clear()}catch(ex){}}function element(){var sel=get();try{if(sel.rangeCount){var range=ranges(0),node=range.startContainer;if(node.nodeType==Node.ELEMENT_NODE){var node_found=!1;if(node.childNodes.length>0&&node.childNodes[range.startOffset]){for(var child=node.childNodes[range.startOffset];child&&child.nodeType==Node.TEXT_NODE&&0==child.textContent.length;)child=child.nextSibling;child&&child.textContent.replace(/\u200B/g,"")===text().replace(/\u200B/g,"")&&(node=child,node_found=!0)}else if(!range.collapsed&&node.nextSibling&&node.nextSibling.nodeType==Node.ELEMENT_NODE){var child=node.nextSibling;child&&child.textContent.replace(/\u200B/g,"")===text().replace(/\u200B/g,"")&&(node=child,node_found=!0)}!node_found&&node.childNodes.length>0&&$(node.childNodes[0]).text().replace(/\u200B/g,"")===text().replace(/\u200B/g,"")&&["BR","IMG","HR"].indexOf(node.childNodes[0].tagName)<0&&(node=node.childNodes[0])}for(;node.nodeType!=Node.ELEMENT_NODE&&node.parentNode;)node=node.parentNode;for(var p=node;p&&"HTML"!=p.tagName;){if(p==editor.$el.get(0))return node;p=$(p).parent()[0]}}}catch(ex){}return editor.$el.get(0)}function endElement(){var sel=get();try{if(sel.rangeCount){var range=ranges(0),node=range.endContainer;if(node.nodeType==Node.ELEMENT_NODE){var node_found=!1;if(node.childNodes.length>0&&node.childNodes[range.endOffset]&&$(node.childNodes[range.endOffset]).text()===text())node=node.childNodes[range.endOffset],node_found=!0;else if(!range.collapsed&&node.previousSibling&&node.previousSibling.nodeType==Node.ELEMENT_NODE){var child=node.previousSibling;child&&child.textContent.replace(/\u200B/g,"")===text().replace(/\u200B/g,"")&&(node=child,node_found=!0)}!node_found&&node.childNodes.length>0&&$(node.childNodes[node.childNodes.length-1]).text()===text()&&["BR","IMG","HR"].indexOf(node.childNodes[node.childNodes.length-1].tagName)<0&&(node=node.childNodes[node.childNodes.length-1])}for(node.nodeType==Node.TEXT_NODE&&0==range.endOffset&&node.previousSibling&&node.previousSibling.nodeType==Node.ELEMENT_NODE&&(node=node.previousSibling);node.nodeType!=Node.ELEMENT_NODE&&node.parentNode;)node=node.parentNode;for(var p=node;p&&"HTML"!=p.tagName;){if(p==editor.$el.get(0))return node;p=$(p).parent()[0]}}}catch(ex){}return editor.$el.get(0)}function rangeElement(rangeContainer,offset){var node=rangeContainer;return node.nodeType==Node.ELEMENT_NODE&&node.childNodes.length>0&&node.childNodes[offset]&&(node=node.childNodes[offset]),node.nodeType==Node.TEXT_NODE&&(node=node.parentNode),node}function blocks(){var blks=[],sel=get();if(inEditor()&&sel.rangeCount)for(var rngs=ranges(),i=0;i<rngs.length;i++){var range=rngs[i],start_node=rangeElement(range.startContainer,range.startOffset),end_node=rangeElement(range.endContainer,range.endOffset);editor.node.isBlock(start_node)&&blks.indexOf(start_node)<0&&blks.push(start_node);var block_parent=editor.node.blockParent(start_node);block_parent&&blks.indexOf(block_parent)<0&&blks.push(block_parent);for(var was_into=[],next_node=start_node;next_node!==end_node&&next_node!==editor.$el.get(0);)was_into.indexOf(next_node)<0&&next_node.children&&next_node.children.length?(was_into.push(next_node),next_node=next_node.children[0]):next_node.nextSibling?next_node=next_node.nextSibling:next_node.parentNode&&(next_node=next_node.parentNode,was_into.push(next_node)),editor.node.isBlock(next_node)&&was_into.indexOf(next_node)<0&&blks.indexOf(next_node)<0&&blks.push(next_node);editor.node.isBlock(end_node)&&blks.indexOf(end_node)<0&&blks.push(end_node);var block_parent=editor.node.blockParent(end_node);block_parent&&blks.indexOf(block_parent)<0&&blks.push(block_parent)}for(var i=blks.length-1;i>0;i--)$(blks[i]).find(blks).length&&"LI"!=blks[i].tagName&&blks.splice(i,1);return blks}function save(){if(editor.$wp){editor.markers.remove();for(var rgs=ranges(),new_ranges=[],i=0;i<rgs.length;i++)if(rgs[i].startContainer!==editor.document){var range=rgs[i],collapsed=range.collapsed,start_m=editor.markers.place(range,!0,i),end_m=editor.markers.place(range,!1,i);if(editor.browser.safari&&!collapsed){var range=editor.document.createRange();range.setStartAfter(start_m),range.setEndBefore(end_m),new_ranges.push(range)}}if(editor.browser.safari&&new_ranges.length){editor.selection.clear();for(var i=0;i<new_ranges.length;i++)editor.selection.get().addRange(new_ranges[i])}}}function restore(){var markers=editor.$el.find('.fr-marker[data-type="true"]');if(!editor.$wp)return markers.remove(),!1;if(0===markers.length)return!1;editor.core.hasFocus()||editor.browser.msie||editor.$el.focus(),clear();for(var sel=get(),i=0;i<markers.length;i++){var id=$(markers[i]).data("id"),start_marker=markers[i],range=editor.document.createRange(),end_marker=editor.$el.find('.fr-marker[data-type="false"][data-id="'+id+'"]'),ghost=null;if(end_marker.length>0){end_marker=end_marker[0];try{for(var special_case=!1,s_node=start_marker.nextSibling;s_node&&s_node.nodeType==Node.TEXT_NODE&&0==s_node.textContent.length;){var tmp=s_node;s_node=s_node.nextSibling,$(tmp).remove()}for(var e_node=end_marker.nextSibling;e_node&&e_node.nodeType==Node.TEXT_NODE&&0==e_node.textContent.length;){var tmp=e_node;e_node=e_node.nextSibling,$(tmp).remove()}if(start_marker.nextSibling==end_marker||end_marker.nextSibling==start_marker){for(var first_node=start_marker.nextSibling==end_marker?start_marker:end_marker,last_node=first_node==start_marker?end_marker:start_marker,prev_node=first_node.previousSibling;prev_node&&prev_node.nodeType==Node.TEXT_NODE&&0==prev_node.length;){var tmp=prev_node;prev_node=prev_node.previousSibling,$(tmp).remove()}if(prev_node&&prev_node.nodeType==Node.TEXT_NODE)for(;prev_node&&prev_node.previousSibling&&prev_node.previousSibling.nodeType==Node.TEXT_NODE;)prev_node.previousSibling.textContent=prev_node.previousSibling.textContent+prev_node.textContent,prev_node=prev_node.previousSibling,$(prev_node.nextSibling).remove();for(var next_node=last_node.nextSibling;next_node&&next_node.nodeType==Node.TEXT_NODE&&0==next_node.length;){var tmp=next_node;next_node=next_node.nextSibling,$(tmp).remove()}if(next_node&&next_node.nodeType==Node.TEXT_NODE)for(;next_node&&next_node.nextSibling&&next_node.nextSibling.nodeType==Node.TEXT_NODE;)next_node.nextSibling.textContent=next_node.textContent+next_node.nextSibling.textContent,next_node=next_node.nextSibling,$(next_node.previousSibling).remove();if(prev_node&&editor.node.isVoid(prev_node)&&(prev_node=null),next_node&&editor.node.isVoid(next_node)&&(next_node=null),prev_node&&next_node&&prev_node.nodeType==Node.TEXT_NODE&&next_node.nodeType==Node.TEXT_NODE){$(start_marker).remove(),$(end_marker).remove();var len=prev_node.textContent.length;prev_node.textContent=prev_node.textContent+next_node.textContent,$(next_node).remove(),editor.html.normalizeSpaces(prev_node),range.setStart(prev_node,len),range.setEnd(prev_node,len),special_case=!0}else!prev_node&&next_node&&next_node.nodeType==Node.TEXT_NODE?($(start_marker).remove(),$(end_marker).remove(),editor.html.normalizeSpaces(next_node),ghost=$(editor.document.createTextNode("")),$(next_node).before(ghost),range.setStart(next_node,0),range.setEnd(next_node,0),special_case=!0):!next_node&&prev_node&&prev_node.nodeType==Node.TEXT_NODE&&($(start_marker).remove(),$(end_marker).remove(),editor.html.normalizeSpaces(prev_node),ghost=$(editor.document.createTextNode("")),$(prev_node).after(ghost),range.setStart(prev_node,prev_node.textContent.length),range.setEnd(prev_node,prev_node.textContent.length),special_case=!0)}if(!special_case){var x,y;editor.browser.chrome&&start_marker.nextSibling==end_marker?(x=_normalizedMarker(end_marker,range,!0)||range.setStartAfter(end_marker),y=_normalizedMarker(start_marker,range,!1)||range.setEndBefore(start_marker)):(start_marker.previousSibling==end_marker&&(start_marker=end_marker,end_marker=start_marker.nextSibling),end_marker.nextSibling&&"BR"===end_marker.nextSibling.tagName||!end_marker.nextSibling&&editor.node.isBlock(start_marker.previousSibling)||start_marker.previousSibling&&"BR"==start_marker.previousSibling.tagName||(start_marker.style.display="inline",end_marker.style.display="inline",ghost=$(editor.document.createTextNode(""))),x=_normalizedMarker(start_marker,range,!0)||$(start_marker).before(ghost)&&range.setStartBefore(start_marker),y=_normalizedMarker(end_marker,range,!1)||$(end_marker).after(ghost)&&range.setEndAfter(end_marker)),"function"==typeof x&&x(),"function"==typeof y&&y()}}catch(ex){console.warn("RESTORE RANGE",ex)}}ghost&&ghost.remove(),sel.addRange(range)}editor.markers.remove()}function _normalizedMarker(marker,range,start){var prev_node=marker.previousSibling,next_node=marker.nextSibling;if(prev_node&&next_node&&prev_node.nodeType==Node.TEXT_NODE&&next_node.nodeType==Node.TEXT_NODE){var len=prev_node.textContent.length;return start?(next_node.textContent=prev_node.textContent+next_node.textContent,$(prev_node).remove(),$(marker).remove(),editor.html.normalizeSpaces(next_node),function(){range.setStart(next_node,len)}):(prev_node.textContent=prev_node.textContent+next_node.textContent,$(next_node).remove(),$(marker).remove(),editor.html.normalizeSpaces(prev_node),function(){range.setEnd(prev_node,len)})}return!1}function _canDelete(){return!0}function isCollapsed(){for(var rgs=ranges(),i=0;i<rgs.length;i++)if(!rgs[i].collapsed)return!1;return!0}function info(el){var selRange,testRange,atStart=!1,atEnd=!1;if(editor.window.getSelection){var sel=editor.window.getSelection();sel.rangeCount&&(selRange=sel.getRangeAt(0),testRange=selRange.cloneRange(),testRange.selectNodeContents(el),testRange.setEnd(selRange.startContainer,selRange.startOffset),atStart=""===testRange.toString(),testRange.selectNodeContents(el),testRange.setStart(selRange.endContainer,selRange.endOffset),atEnd=""===testRange.toString())}else editor.document.selection&&"Control"!=editor.document.selection.type&&(selRange=editor.document.selection.createRange(),testRange=selRange.duplicate(),testRange.moveToElementText(el),testRange.setEndPoint("EndToStart",selRange),atStart=""===testRange.text,testRange.moveToElementText(el),testRange.setEndPoint("StartToEnd",selRange),atEnd=""===testRange.text);return{atStart:atStart,atEnd:atEnd}}function isFull(){if(isCollapsed())return!1;editor.$el.find("td").prepend('<span class="fr-mk">'+$.FroalaEditor.INVISIBLE_SPACE+"</span>"),editor.$el.find("img").append('<span class="fr-mk">'+$.FroalaEditor.INVISIBLE_SPACE+"</span>");var full=!1,inf=info(editor.$el.get(0));return inf.atStart&&inf.atEnd&&(full=!0),editor.$el.find(".fr-mk").remove(),full}function _emptyInnerNodes(node,first){"undefined"==typeof first&&(first=!0);var h=$(node).html();h&&h.replace(/\u200b/g,"").length!=h.length&&$(node).html(h.replace(/\u200b/g,""));for(var contents=editor.node.contents(node),j=0;j<contents.length;j++)contents[j].nodeType!=Node.ELEMENT_NODE?$(contents[j]).remove():(_emptyInnerNodes(contents[j],0==j),0==j&&(first=!1));node.nodeType==Node.TEXT_NODE?$(node).replaceWith('<span data-first="true" data-text="true"></span>'):first&&$(node).attr("data-first",!0)}function _processNodeDelete($node,should_delete){var contents=editor.node.contents($node.get(0));["TD","TH"].indexOf($node.get(0).tagName)>=0&&1==$node.find(".fr-marker").length&&$(contents[0]).hasClass("fr-marker")&&$node.attr("data-del-cell",!0);for(var i=0;i<contents.length;i++){var node=contents[i];$(node).hasClass("fr-marker")?should_delete=(should_delete+1)%2:should_delete?$(node).find(".fr-marker").length>0?should_delete=_processNodeDelete($(node),should_delete):["TD","TH"].indexOf(node.tagName)<0&&!$(node).hasClass("fr-inner")?!editor.opts.keepFormatOnDelete||should_delete>1||editor.$el.find("[data-first]").length>0?$(node).remove():_emptyInnerNodes(node):$(node).hasClass("fr-inner")?0==$(node).find(".fr-inner").length?$(node).html("<br>"):$(node).find(".fr-inner").filter(function(){return 0==$(this).find("fr-inner").length}).html("<br>"):($(node).empty(),$(node).attr("data-del-cell",!0)):$(node).find(".fr-marker").length>0&&(should_delete=_processNodeDelete($(node),should_delete))}return should_delete}function inEditor(){try{if(!editor.$wp)return!1;for(var range=ranges(0),container=range.commonAncestorContainer;container&&!editor.node.isElement(container);)container=container.parentNode;return editor.node.isElement(container)?!0:!1}catch(ex){return!1}}function remove(){save();for(var _prevSibling=function(node){for(var prev_node=node.previousSibling;prev_node&&prev_node.nodeType==Node.TEXT_NODE&&0==prev_node.textContent.length;){var tmp=prev_node,prev_node=prev_node.previousSibling;$(tmp).remove()}return prev_node},_nextSibling=function(node){for(var next_node=node.nextSibling;next_node&&next_node.nodeType==Node.TEXT_NODE&&0==next_node.textContent.length;){var tmp=next_node,next_node=next_node.nextSibling;$(tmp).remove()}return next_node},start_markers=editor.$el.find('.fr-marker[data-type="true"]'),i=0;i<start_markers.length;i++)for(var sm=start_markers[i];!_prevSibling(sm)&&!editor.node.isBlock(sm.parentNode);)$(sm.parentNode).before(sm);for(var end_markers=editor.$el.find('.fr-marker[data-type="false"]'),i=0;i<end_markers.length;i++)for(var em=end_markers[i];!_nextSibling(em)&&!editor.node.isBlock(em.parentNode);)$(em.parentNode).after(em);if(_canDelete()){_processNodeDelete(editor.$el,0);var $first_node=editor.$el.find('[data-first="true"]');if($first_node.length)editor.$el.find(".fr-marker").remove(),$first_node.append($.FroalaEditor.INVISIBLE_SPACE+$.FroalaEditor.MARKERS).removeAttr("data-first"),$first_node.attr("data-text")&&$first_node.replaceWith($first_node.html());else{editor.$el.find("table").filter(function(){var ok=$(this).find("[data-del-cell]").length>0&&$(this).find("[data-del-cell]").length==$(this).find("td, th").length;return ok}).remove(),editor.$el.find("[data-del-cell]").removeAttr("data-del-cell");for(var start_markers=editor.$el.find('.fr-marker[data-type="true"]'),i=0;i<start_markers.length;i++){var start_marker=start_markers[i],next_node=start_marker.nextSibling,end_marker=editor.$el.find('.fr-marker[data-type="false"][data-id="'+$(start_marker).data("id")+'"]').get(0);if(end_marker){if(next_node&&next_node==end_marker);else if(start_marker){var start_parent=editor.node.blockParent(start_marker),end_parent=editor.node.blockParent(end_marker);if($(start_marker).after(end_marker),start_parent==end_parent);else if(null==start_parent){var deep_parent=editor.node.deepestParent(start_marker);deep_parent?($(deep_parent).after($(end_parent).html()),$(end_parent).remove()):0==$(end_parent).parentsUntil(editor.$el,"table").length&&($(start_marker).next().after($(end_parent).html()),$(end_parent).remove())}else if(null==end_parent&&0==$(start_parent).parentsUntil(editor.$el,"table").length){for(var next_node=start_parent;!next_node.nextSibling&&next_node.parentNode!=editor.$el.get(0);)next_node=next_node.parentNode;for(next_node=next_node.nextSibling;next_node&&"BR"!=next_node.tagName;){var tmp_node=next_node.nextSibling;$(start_parent).append(next_node),next_node=tmp_node}}else 0==$(start_parent).parentsUntil(editor.$el,"table").length&&0==$(end_parent).parentsUntil(editor.$el,"table").length&&($(start_parent).append($(end_parent).html()),$(end_parent).remove())}}else end_marker=$(start_marker).clone().attr("data-type",!1),$(start_marker).after(end_marker)}}}editor.opts.keepFormatOnDelete||editor.html.fillEmptyBlocks(!0),editor.html.cleanEmptyTags(!0),editor.clean.lists(),editor.html.normalizeSpaces(),restore()}function setAtStart(node){if($(node).find(".fr-marker").length>0)return!1;for(var contents=editor.node.contents(node);contents.length&&editor.node.isBlock(contents[0]);)node=contents[0],contents=editor.node.contents(node);$(node).prepend($.FroalaEditor.MARKERS)}function setAtEnd(node){if($(node).find(".fr-marker").length>0)return!1;for(var contents=editor.node.contents(node);contents.length&&editor.node.isBlock(contents[contents.length-1]);)node=contents[contents.length-1],contents=editor.node.contents(node);$(node).append($.FroalaEditor.MARKERS)}function setBefore(node){for(var prev_node=node.previousSibling;prev_node&&prev_node.nodeType==Node.TEXT_NODE&&0==prev_node.textContent.length;)prev_node=prev_node.previousSibling;return prev_node?(editor.node.isBlock(prev_node)?setAtEnd(prev_node):"BR"==prev_node.tagName?$(prev_node).before($.FroalaEditor.MARKERS):$(prev_node).after($.FroalaEditor.MARKERS),!0):!1}function setAfter(node){for(var next_node=node.nextSibling;next_node&&next_node.nodeType==Node.TEXT_NODE&&0==next_node.textContent.length;)next_node=next_node.nextSibling;return next_node?(editor.node.isBlock(next_node)?setAtStart(next_node):$(next_node).before($.FroalaEditor.MARKERS),!0):!1}return{text:text,get:get,ranges:ranges,clear:clear,element:element,endElement:endElement,save:save,restore:restore,isCollapsed:isCollapsed,isFull:isFull,inEditor:inEditor,remove:remove,blocks:blocks,info:info,setAtEnd:setAtEnd,setAtStart:setAtStart,setBefore:setBefore,setAfter:setAfter,rangeElement:rangeElement}},$.FroalaEditor.UNICODE_NBSP=String.fromCharCode(160),$.FroalaEditor.VOID_ELEMENTS=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],$.FroalaEditor.BLOCK_TAGS=["p","div","h1","h2","h3","h4","h5","h6","pre","blockquote","ul","ol","li","table","td","th","thead","tfoot","tbody","tr","hr"],$.extend($.FroalaEditor.DEFAULTS,{htmlAllowedEmptyTags:["textarea","a","iframe","object","video","style","script"],htmlSimpleAmpersand:!1}),$.FroalaEditor.MODULES.html=function(editor){function defaultTag(){return editor.opts.enter==$.FroalaEditor.ENTER_P?"p":editor.opts.enter==$.FroalaEditor.ENTER_DIV?"div":editor.opts.enter==$.FroalaEditor.ENTER_BR?null:void 0}function emptyBlocks(with_text){"undefined"==typeof with_text&&(with_text=!1);var els,i,empty_blocks=[];if(with_text)for(els=editor.$el.find(blockTagsQuery()),i=0;i<els.length;i++){for(var contents=editor.node.contents(els[i]),found=!1,j=0;j<contents.length;j++)if(contents[j].nodeType!=Node.COMMENT_NODE&&(contents[j].nodeType==Node.ELEMENT_NODE&&$.FroalaEditor.VOID_ELEMENTS.indexOf(contents[j].tagName.toLowerCase())>=0||contents[j].textContent&&contents[j].textContent.replace(/\u200B/g,"").length>0)){found=!0;break}found||0!==$(els[i]).find(blockTagsQuery()).length||empty_blocks.push(els[i])}else for(els=editor.$el.find(emptyBlockTagsQuery()),i=0;i<els.length;i++)0===$(els[i]).find(blockTagsQuery()).length&&empty_blocks.push(els[i]);return $($.makeArray(empty_blocks))}function emptyBlockTagsQuery(){return $.FroalaEditor.BLOCK_TAGS.join(":empty, ")+":empty"}function blockTagsQuery(){return $.FroalaEditor.BLOCK_TAGS.join(", ")}function cleanEmptyTags(){var els=$.merge(["TD","TH"],$.FroalaEditor.VOID_ELEMENTS);els=$.merge(els,editor.opts.htmlAllowedEmptyTags);var elms,ok;do{ok=!1,elms=editor.$el.find("*:empty").not(els.join(", ")+", .fr-marker");for(var i=0;i<elms.length;i++)0===elms[i].attributes.length&&($(elms[i]).remove(),ok=!0);elms=editor.$el.find("*:empty").not(els.join(", ")+", .fr-marker")}while(elms.length&&ok)}function _wrapElement($el,temp){var default_tag=defaultTag();if(temp&&(default_tag='div class="fr-temp-div"'),default_tag)for(var contents=editor.node.contents($el.get(0)),$anchor=null,i=0;i<contents.length;i++){var node=contents[i];if(node.nodeType==Node.ELEMENT_NODE&&editor.node.isBlock(node))$anchor=null;else if(node.nodeType!=Node.ELEMENT_NODE&&node.nodeType!=Node.TEXT_NODE)$anchor=null;else if(node.nodeType==Node.ELEMENT_NODE&&"BR"==node.tagName)if(null==$anchor)temp?$(node).replaceWith("<"+default_tag+' data-empty="true"><br></div>'):$(node).replaceWith("<"+default_tag+"><br></"+default_tag+">");else{$(node).remove();for(var cnts=editor.node.contents($anchor),found=!1,j=0;j<cnts.length;j++)if(!$(cnts[j]).hasClass("fr-marker")&&(cnts[j].nodeType!=Node.TEXT_NODE||0!==cnts[j].textContent.replace(/ /g,"").length)){found=!0;break}found===!1&&($anchor.append("<br>"),$anchor.data("empty",!0)),$anchor=null}else node.nodeType==Node.TEXT_NODE&&0==$(node).text().trim().length?$(node).remove():(null==$anchor&&($anchor=$("<"+default_tag+">"),$(node).before($anchor)),node.nodeType==Node.TEXT_NODE&&$(node).text().trim().length>0?($anchor.append($(node).clone()),$(node).remove()):$anchor.append($(node)))}}function _wrap(temp,tables,blockquote){return editor.$wp?("undefined"==typeof temp&&(temp=!1),"undefined"==typeof tables&&(tables=!1),"undefined"==typeof blockquote&&(blockquote=!1),_wrapElement(editor.$el,temp),editor.$el.find(".fr-inner").each(function(){_wrapElement($(this),temp)}),tables&&editor.$el.find("td, th").each(function(){_wrapElement($(this),temp)}),void(blockquote&&editor.$el.find("blockquote").each(function(){_wrapElement($(this),temp)}))):!1}function unwrap(){editor.$el.find("div.fr-temp-div").each(function(){$(this).data("empty")||"LI"==this.parentNode.tagName?$(this).replaceWith($(this).html()):$(this).replaceWith($(this).html()+"<br>")}),editor.$el.find(".fr-temp-div").removeClass("fr-temp-div").filter(function(){return""==$(this).attr("class")}).removeAttr("class")}function fillEmptyBlocks(with_text){emptyBlocks(with_text).not("hr").append("<br/>")}function blocks(){return editor.$el.find(blockTagsQuery())}function cleanBlankSpaces(node){"undefined"==typeof node&&(node=editor.$el.get(0));for(var contents=editor.node.contents(node),i=contents.length-1;i>=0;i--)if(contents[i].nodeType==Node.TEXT_NODE&&editor.node.isBlock(node)){for(var len=-1;len!=contents[i].textContent.length;)len=contents[i].textContent.length,contents[i].textContent=contents[i].textContent.replace(/(?!^) (?!$)/g," ");contents[i].textContent=contents[i].textContent.replace(/^ /g," "),contents[i].textContent=contents[i].textContent.replace(/ $/g," "),editor.node.isBlock(node)&&(contents[i].previousSibling||(contents[i].textContent=contents[i].textContent.replace(/^ */,"")),contents[i].nextSibling||(contents[i].textContent=contents[i].textContent.replace(/ *$/,"")))}else cleanBlankSpaces(contents[i])}function _isBlock(node){return node&&(editor.node.isBlock(node)||["STYLE","SCRIPT","HEAD","BR","HR"].indexOf(node.tagName)>=0||node.nodeType==Node.COMMENT_NODE)}function normalizeSpaces(node){if("undefined"==typeof node&&(node=editor.$el.get(0)),node.nodeType==Node.ELEMENT_NODE&&["STYLE","SCRIPT","HEAD"].indexOf(node.tagName)<0)for(var contents=editor.node.contents(node),i=contents.length-1;i>=0;i--)$(contents[i]).hasClass("fr-marker")||normalizeSpaces(contents[i]);else if(node.nodeType==Node.TEXT_NODE&&node.textContent.length>0){var prev_node=node.previousSibling,next_node=node.nextSibling;if(_isBlock(prev_node)&&_isBlock(next_node)&&0===node.textContent.trim().length)$(node).remove();else{var txt=node.textContent;txt=txt.replace(new RegExp($.FroalaEditor.UNICODE_NBSP,"g")," ");for(var new_text="",t=0;t<txt.length;t++)new_text+=32!=txt.charCodeAt(t)||0!==t&&32!=new_text.charCodeAt(t-1)?txt[t]:$.FroalaEditor.UNICODE_NBSP;node.nextSibling||(new_text=new_text.replace(/ $/,$.FroalaEditor.UNICODE_NBSP)),node.previousSibling&&!editor.node.isVoid(node.previousSibling)&&(new_text=new_text.replace(/^\u00A0([^ $])/," $1")),new_text=new_text.replace(/([^ \u00A0])\u00A0([^ \u00A0])/g,"$1 $2"),node.textContent!=new_text&&(node.textContent=new_text)}}}function _extractMatch(html,re,id){var reg_exp=new RegExp(re,"gi"),matches=reg_exp.exec(html);return matches?matches[id]:null}function _newDoctype(string,doc){var matches=string.match(/<!DOCTYPE ?([^ ]*) ?([^ ]*) ?"?([^"]*)"? ?"?([^"]*)"?>/i);return matches?doc.implementation.createDocumentType(matches[1],matches[3],matches[4]):doc.implementation.createDocumentType("html")}function getDoctype(doc){var node=doc.doctype,doctype="<!DOCTYPE html>";return node&&(doctype="<!DOCTYPE "+node.name+(node.publicId?' PUBLIC "'+node.publicId+'"':"")+(!node.publicId&&node.systemId?" SYSTEM":"")+(node.systemId?' "'+node.systemId+'"':"")+">"),doctype}function _normalize(){_wrap(),cleanBlankSpaces(),cleanEmptyTags(),normalizeSpaces(),fillEmptyBlocks(!0),editor.clean.quotes(),editor.clean.lists(),editor.clean.tables(),editor.clean.toHTML5(),editor.clean.quotes(),editor.placeholder.refresh(),editor.selection.restore(),checkIfEmpty()}function checkIfEmpty(){editor.core.isEmpty()&&(null!=defaultTag()?0===editor.$el.find(blockTagsQuery()).length&&(editor.core.hasFocus()?(editor.$el.html("<"+defaultTag()+">"+$.FroalaEditor.MARKERS+"<br/></"+defaultTag()+">"),editor.selection.restore()):editor.$el.html("<"+defaultTag()+"><br/></"+defaultTag()+">")):0===editor.$el.find("*:not(.fr-marker):not(br)").length&&(editor.core.hasFocus()?(editor.$el.html($.FroalaEditor.MARKERS+"<br/>"),editor.selection.restore()):editor.$el.html("<br/>")))}function extractNode(html,tag){return _extractMatch(html,"<"+tag+"[^>]*?>([\\w\\W]*)</"+tag+">",1)}function extractNodeAttrs(html,tag){var $dv=$("<div "+(_extractMatch(html,"<"+tag+"([^>]*?)>",1)||"")+">");return editor.node.rawAttributes($dv.get(0))}function extractDoctype(html){return _extractMatch(html,"<!DOCTYPE([^>]*?)>",0)||"<!DOCTYPE html>"}function set(html){var clean_html=editor.clean.html(html,[],[],editor.opts.fullPage);if(clean_html=clean_html.replace(/\r|\n/g,""),editor.opts.fullPage){var body_html=(extractNode(clean_html,"body")||clean_html).replace(/\r|\n/g,""),body_attrs=extractNodeAttrs(clean_html,"body"),head_html=extractNode(clean_html,"head")||"<title></title>",head_attrs=extractNodeAttrs(clean_html,"head"),doctype=extractDoctype(clean_html),html_attrs=extractNodeAttrs(clean_html,"html");editor.$el.html(body_html),editor.node.clearAttributes(editor.$el.get(0)),editor.$el.attr(body_attrs),editor.$head.html(head_html),editor.node.clearAttributes(editor.$head.get(0)),editor.$head.attr(head_attrs),editor.node.clearAttributes(editor.$html.get(0)),editor.$html.attr(html_attrs),editor.iframe_document.doctype.parentNode.replaceChild(_newDoctype(doctype,editor.iframe_document),editor.iframe_document.doctype)}else editor.$el.html(clean_html);editor.edit.on(),editor.core.injectStyle(editor.opts.iframeStyle),_normalize(),editor.$el.find("[fr-original-class]").each(function(){this.setAttribute("class",this.getAttribute("fr-original-class")),this.removeAttribute("fr-original-class")}),editor.$el.find("[fr-original-style]").each(function(){this.setAttribute("style",this.getAttribute("fr-original-style")),this.removeAttribute("fr-original-style")}),editor.events.trigger("html.set")}function get(keep_markers,keep_classes){var html="";editor.events.trigger("html.beforeGet");var i,updated_elms=[];if(!editor.opts.useClasses&&!keep_classes){for(i=0;i<editor.document.styleSheets.length;i++){var rules;try{rules=editor.document.styleSheets[i].cssRules}catch(ex){}if(rules)for(var idx=0,len=rules.length;len>idx;idx++){var class_selector=editor.opts.iframe?"body ":".fr-view ";if(rules[idx].selectorText&&0===rules[idx].selectorText.indexOf(class_selector)&&rules[idx].style.cssText.length>0)for(var selector=rules[idx].selectorText.replace(class_selector,"").replace(/::/g,":"),elms=editor.$el.get(0).querySelectorAll(selector),j=0;j<elms.length;j++)!elms[j].getAttribute("fr-original-style")&&elms[j].getAttribute("style")&&(elms[j].setAttribute("fr-original-style",elms[j].getAttribute("style")),updated_elms.push(elms[j])),elms[j].style.cssText+=rules[idx].style.cssText}}for(i=0;i<updated_elms.length;i++)updated_elms[i].getAttribute("class")&&(updated_elms[i].setAttribute("fr-original-class",updated_elms[i].getAttribute("class")),updated_elms[i].removeAttribute("class"))}if(editor.core.isEmpty()?editor.opts.fullPage&&(html=getDoctype(editor.iframe_document),html+="<html"+editor.node.attributes(editor.$html.get(0))+">"+editor.$html.html()+"</html>"):("undefined"==typeof keep_markers&&(keep_markers=!1),
|
||
editor.opts.fullPage?(html=getDoctype(editor.iframe_document),html+="<html"+editor.node.attributes(editor.$html.get(0))+">"+editor.$html.html()+"</html>"):html=editor.$el.html()),!editor.opts.useClasses&&!keep_classes)for(i=0;i<updated_elms.length;i++)updated_elms[i].getAttribute("fr-original-class")&&(updated_elms[i].setAttribute("class",updated_elms[i].getAttribute("fr-original-class")),updated_elms[i].removeAttribute("fr-original-class")),updated_elms[i].setAttribute("style",updated_elms[i].getAttribute("fr-original-style")),updated_elms[i].removeAttribute("fr-original-style");html=html.replace(/<pre(?:[\w\W]*?)>(?:[\w\W]*?)<\/pre>/g,function(str){return str.replace(/<br>/g,"\n")}),editor.opts.fullPage&&(html=html.replace(/<style data-fr-style="true">(?:[\w\W]*?)<\/style>/g,""),html=html.replace(/<style(?:[\w\W]*?)class="firebugResetStyles"(?:[\w\W]*?)>(?:[\w\W]*?)<\/style>/g,""),html=html.replace(/<body((?:[\w\W]*?)) spellcheck="true"((?:[\w\W]*?))>((?:[\w\W]*?))<\/body>/g,"<body$1$2>$3</body>"),html=html.replace(/<body((?:[\w\W]*?)) contenteditable="(true|false)"((?:[\w\W]*?))>((?:[\w\W]*?))<\/body>/g,"<body$1$3>$4</body>"),html=html.replace(/<body((?:[\w\W]*?)) dir="([\w]*)"((?:[\w\W]*?))>((?:[\w\W]*?))<\/body>/g,"<body$1$3>$4</body>"),html=html.replace(/<body((?:[\w\W]*?))class="([\w\W]*?)(fr-rtl|fr-ltr)([\w\W]*?)"((?:[\w\W]*?))>((?:[\w\W]*?))<\/body>/g,'<body$1class="$2$4"$5>$6</body>'),html=html.replace(/<body((?:[\w\W]*?)) class=""((?:[\w\W]*?))>((?:[\w\W]*?))<\/body>/g,"<body$1$2>$3</body>")),editor.opts.htmlSimpleAmpersand&&(html=html.replace(/\&/gi,"&")),editor.events.trigger("html.afterGet"),keep_markers||(html=html.replace(/<span[^>]*? class\s*=\s*["']?fr-marker["']?[^>]+>\u200b<\/span>/gi,"")),html=editor.clean.invisibleSpaces(html);var new_html=editor.events.chainTrigger("html.get",html);return"string"==typeof new_html&&(html=new_html),html}function getSelected(){var wrapSelection=function(container,node){for(;node&&(node.nodeType==Node.TEXT_NODE||!editor.node.isBlock(node));)node&&node.nodeType!=Node.TEXT_NODE&&$(container).wrapInner(editor.node.openTagString(node)+editor.node.closeTagString(node)),node=node.parentNode;node&&container.innerHTML==node.innerHTML&&(container.innerHTML=node.outerHTML)},selectionParent=function(){var sel,parent=null;return editor.window.getSelection?(sel=editor.window.getSelection(),sel&&sel.rangeCount&&(parent=sel.getRangeAt(0).commonAncestorContainer,parent.nodeType!=Node.ELEMENT_NODE&&(parent=parent.parentNode))):(sel=editor.document.selection)&&"Control"!=sel.type&&(parent=sel.createRange().parentElement()),null!=parent&&($.inArray(editor.$el.get(0),$(parent).parents())>=0||parent==editor.$el.get(0))?parent:null},html="";if("undefined"!=typeof editor.window.getSelection){editor.browser.mozilla&&(editor.selection.save(),editor.$el.find('.fr-marker[data-type="false"]').length>1&&(editor.$el.find('.fr-marker[data-type="false"][data-id="0"]').remove(),editor.$el.find('.fr-marker[data-type="false"]:last').attr("data-id","0"),editor.$el.find(".fr-marker").not('[data-id="0"]').remove()),editor.selection.restore());for(var ranges=editor.selection.ranges(),i=0;i<ranges.length;i++){var container=document.createElement("div");container.appendChild(ranges[i].cloneContents()),wrapSelection(container,selectionParent()),html+=container.innerHTML}}else"undefined"!=typeof editor.document.selection&&"Text"==editor.document.selection.type&&(html=editor.document.selection.createRange().htmlText);return html}function _hasBlockTags(html){var $tmp=$("<div>").html(html);return $tmp.find(blockTagsQuery()).length>0}function _setCursorAtEnd(html){var tmp=editor.document.createElement("div");return tmp.innerHTML=html,editor.selection.setAtEnd(tmp),tmp.innerHTML}function escapeEntities(str){return str.replace(/</gi,"<").replace(/>/gi,">").replace(/"/gi,""").replace(/'/gi,"'")}function insert(dirty_html,clean){""!==editor.selection.text()&&editor.selection.remove();var clean_html;if(clean_html=clean?dirty_html:editor.clean.html(dirty_html),dirty_html.indexOf('class="fr-marker"')<0&&(clean_html=_setCursorAtEnd(clean_html)),editor.core.isEmpty())editor.$el.html(clean_html);else{editor.markers.insert();var deep_parent,marker=editor.$el.find(".fr-marker").get(0);if(_hasBlockTags(clean_html)&&(deep_parent=editor.node.deepestParent(marker)))if(editor.node.isBlock(deep_parent)&&editor.node.isEmpty(deep_parent))$(deep_parent).replaceWith(clean_html);else{var node=marker,close_str="",open_str="";do node=node.parentNode,close_str+=editor.node.closeTagString(node),open_str=editor.node.openTagString(node)+open_str;while(node!=deep_parent);$(marker).replaceWith('<span id="fr-break"></span>');var h=editor.node.openTagString(deep_parent)+$(deep_parent).html()+editor.node.closeTagString(deep_parent);h=h.replace(/<span id="fr-break"><\/span>/g,close_str+clean_html+open_str),$(deep_parent).replaceWith(h)}else $(marker).replaceWith(clean_html)}_normalize(),editor.events.trigger("html.inserted")}function cleanWhiteTags(ignore_selection){var $el=null;"undefined"==typeof ignore_selection&&($el=editor.selection.element());var $possible_elements,removed;do{removed=!1,$possible_elements=editor.$el.find("*").not($el).not(".fr-marker");for(var i=0;i<$possible_elements.length;i++){var el=$possible_elements.get(i),text=el.textContent;0===$(el).find("*").length&&1===text.length&&8203==text.charCodeAt(0)&&($(el).remove(),removed=!0)}}while(removed)}function _init(){var cleanTags=function(){cleanWhiteTags(),editor.placeholder&&editor.placeholder.refresh()};editor.events.on("mouseup",cleanTags),editor.events.on("keydown",cleanTags),editor.events.on("contentChanged",checkIfEmpty)}return{defaultTag:defaultTag,emptyBlocks:emptyBlocks,emptyBlockTagsQuery:emptyBlockTagsQuery,blockTagsQuery:blockTagsQuery,fillEmptyBlocks:fillEmptyBlocks,cleanEmptyTags:cleanEmptyTags,cleanWhiteTags:cleanWhiteTags,normalizeSpaces:normalizeSpaces,cleanBlankSpaces:cleanBlankSpaces,blocks:blocks,getDoctype:getDoctype,set:set,get:get,getSelected:getSelected,insert:insert,wrap:_wrap,unwrap:unwrap,escapeEntities:escapeEntities,checkIfEmpty:checkIfEmpty,extractNode:extractNode,extractNodeAttrs:extractNodeAttrs,extractDoctype:extractDoctype,_init:_init}},$.extend($.FroalaEditor.DEFAULTS,{height:null,heightMax:null,heightMin:null,width:null}),$.FroalaEditor.MODULES.size=function(editor){function syncIframe(){editor.opts.height&&editor.$el.css("minHeight",editor.opts.height-editor.helpers.getPX(editor.$el.css("padding-top"))-editor.helpers.getPX(editor.$el.css("padding-bottom"))),editor.$iframe.height(editor.$el.outerHeight(!0))}function refresh(){editor.opts.height&&(editor.$wp.height(editor.opts.height),editor.$el.css("minHeight",editor.opts.height-editor.helpers.getPX(editor.$el.css("padding-top"))-editor.helpers.getPX(editor.$el.css("padding-bottom")))),editor.opts.heightMin&&editor.$el.css("minHeight",editor.opts.heightMin),editor.opts.heightMax&&editor.$wp.css("maxHeight",editor.opts.heightMax),editor.opts.width&&editor.$box.width(editor.opts.width)}function _init(){return editor.$wp?(refresh(),void(editor.opts.iframe&&(editor.events.on("keyup",syncIframe),editor.events.on("commands.after",syncIframe),editor.events.on("html.set",syncIframe),editor.events.on("init",syncIframe),editor.events.on("initialized",syncIframe)))):!1}return{_init:_init,syncIframe:syncIframe,refresh:refresh}},$.extend($.FroalaEditor.DEFAULTS,{language:null}),$.FroalaEditor.LANGUAGE={},$.FroalaEditor.MODULES.language=function(editor){function translate(str){return lang&&lang.translation[str]?lang.translation[str]:str}function _init(){$.FroalaEditor.LANGUAGE&&(lang=$.FroalaEditor.LANGUAGE[editor.opts.language]),lang&&lang.direction&&(editor.opts.direction=lang.direction)}var lang;return{_init:_init,translate:translate}},$.extend($.FroalaEditor.DEFAULTS,{placeholderText:"Type something",placeholderFontFamily:"Arial, Helvetica, sans-serif"}),$.FroalaEditor.MODULES.placeholder=function(editor){function show(){var margin_top=0,contents=editor.node.contents(editor.$el.get(0));contents.length&&contents[0].nodeType==Node.ELEMENT_NODE?(margin_top=editor.helpers.getPX($(contents[0]).css("margin-top")),editor.$placeholder.css("font-size",$(contents[0]).css("font-size")),editor.$placeholder.css("line-height",$(contents[0]).css("line-height"))):(editor.$placeholder.css("font-size",editor.$el.css("font-size")),editor.$placeholder.css("line-height",editor.$el.css("line-height"))),editor.$wp.addClass("show-placeholder"),editor.$placeholder.css("margin-top",margin_top).text(editor.language.translate(editor.opts.placeholderText||editor.$original_element.attr("placeholder")||""))}function hide(){editor.$wp.removeClass("show-placeholder")}function isVisible(){return editor.$wp.hasClass("show-placeholder")}function refresh(){return editor.$wp?void(editor.core.isEmpty()?show():hide()):!1}function _init(){return editor.$wp?(editor.$placeholder=$('<span class="fr-placeholder"></span>'),editor.$wp.append(editor.$placeholder),editor.events.on("init",refresh),editor.events.on("input",refresh),editor.events.on("keydown",refresh),editor.events.on("keyup",refresh),void editor.events.on("contentChanged",refresh)):!1}return{_init:_init,show:show,hide:hide,refresh:refresh,isVisible:isVisible}},$.FroalaEditor.MODULES.edit=function(editor){function disableDesign(){editor.browser.mozilla&&(editor.document.execCommand("enableObjectResizing",!1,"false"),editor.document.execCommand("enableInlineTableEditing",!1,"false"))}function on(){editor.$wp&&(editor.$el.attr("contenteditable",!0),editor.$el.removeClass("fr-disabled"),editor.$tb&&editor.$tb.removeClass("fr-disabled"),disableDesign()),disabled=!1}function off(){editor.$wp&&(editor.$el.attr("contenteditable",!1),editor.$el.addClass("fr-disabled"),editor.$tb.addClass("fr-disabled")),disabled=!0}function isDisabled(){return disabled}var disabled=!1;return{on:on,off:off,disableDesign:disableDesign,isDisabled:isDisabled}},$.extend($.FroalaEditor.DEFAULTS,{editorClass:null,typingTimer:500,iframe:!1,requestWithCORS:!0,requestHeaders:{},useClasses:!0,spellcheck:!0,iframeStyle:'html{margin: 0px;}body{padding:10px;background:transparent;color:#000000;position:relative;z-index: 2;-webkit-user-select:auto;margin:0px}body:after{content:"";clear:both;display:block}',direction:"auto",zIndex:1,disableRightClick:!1,scrollableContainer:"body",keepFormatOnDelete:!1}),$.FroalaEditor.MODULES.core=function(editor){function injectStyle(style){editor.opts.iframe&&editor.$head.append('<style data-fr-style="true">'+style+"</style>")}function _initElementStyle(){editor.opts.iframe||editor.$el.addClass("fr-element fr-view")}function _initStyle(){if(editor.$box.addClass("fr-box"+(editor.opts.editorClass?" "+editor.opts.editorClass:"")),editor.$wp.addClass("fr-wrapper"),_initElementStyle(),editor.opts.iframe){editor.$iframe.addClass("fr-iframe");for(var i=0;i<editor.original_document.styleSheets.length;i++){var rules;try{rules=editor.original_document.styleSheets[i].cssRules}catch(ex){}if(rules)for(var idx=0,len=rules.length;len>idx;idx++)rules[idx].selectorText&&0===rules[idx].selectorText.indexOf(".fr-view")&&rules[idx].style.cssText.length>0&&(editor.opts.iframeStyle+=rules[idx].selectorText.replace(/\.fr-view/g,"body")+"{"+rules[idx].style.cssText+"}")}}"auto"!=editor.opts.direction&&editor.$box.removeClass("fr-ltr fr-rtl").addClass("fr-"+editor.opts.direction),editor.$el.attr("dir",editor.opts.direction),editor.$wp.attr("dir",editor.opts.direction),editor.opts.zIndex>1&&editor.$box.css("z-index",editor.opts.zIndex),editor.$box&&editor.opts.theme&&editor.$box.addClass(editor.opts.theme+"-theme")}function isEmpty(){return editor.node.isEmpty(editor.$el.get(0))}function _initDrag(){editor.drag_support={filereader:"undefined"!=typeof FileReader,formdata:!!editor.window.FormData,progress:"upload"in new XMLHttpRequest}}function getXHR(url,method){var xhr=new XMLHttpRequest;xhr.open(method,url,!0),editor.opts.requestWithCORS&&(xhr.withCredentials=!0);for(var header in editor.opts.requestHeaders)xhr.setRequestHeader(header,editor.opts.requestHeaders[header]);return xhr}function _destroy(){"TEXTAREA"==editor.$original_element.get(0).tagName&&editor.$original_element.val(editor.html.get()),editor.$wp&&("TEXTAREA"==editor.$original_element.get(0).tagName?(editor.$box.replaceWith(editor.$original_element),editor.$original_element.show()):(editor.$el.off("contextmenu.rightClick"),editor.$wp.replaceWith(editor.html.get()),editor.$box.removeClass("fr-view fr-ltr fr-box "+(editor.opts.editorClass||"")),editor.opts.theme&&editor.$box.addClass(editor.opts.theme+"-theme")))}function hasFocus(){return editor.node.hasFocus(editor.$el.get(0))}function _init(){if($.FroalaEditor.INSTANCES.push(editor),_initDrag(),editor.$wp){_initStyle(),editor.html.set(editor._original_html),editor.$el.attr("spellcheck",editor.opts.spellcheck),editor.helpers.isMobile()&&(editor.$el.attr("autocomplete",editor.opts.spellcheck?"on":"off"),editor.$el.attr("autocorrect",editor.opts.spellcheck?"on":"off"),editor.$el.attr("autocapitalize",editor.opts.spellcheck?"on":"off")),editor.opts.disableRightClick&&editor.$el.on("contextmenu.rightClick",function(e){return 2==e.button?!1:void 0});try{editor.document.execCommand("styleWithCSS",!1,!1)}catch(ex){}}editor.events.trigger("init"),editor.events.on("destroy",_destroy),"TEXTAREA"==editor.$original_element.get(0).tagName&&(editor.events.on("contentChanged",function(){editor.$original_element.val(editor.html.get())}),editor.events.on("form.submit",function(){editor.$original_element.val(editor.html.get())}),editor.$original_element.val(editor.html.get()))}return{_init:_init,isEmpty:isEmpty,getXHR:getXHR,injectStyle:injectStyle,hasFocus:hasFocus}},$.FroalaEditor.COMMANDS={bold:{title:"Bold"},italic:{title:"Italic"},underline:{title:"Underline"},strikeThrough:{title:"Strikethrough"},subscript:{title:"Subscript"},superscript:{title:"Superscript"},outdent:{title:"Decrease Indent"},indent:{title:"Increase Indent"},undo:{title:"Undo",undo:!1,forcedRefresh:!0,disabled:!0},redo:{title:"Redo",undo:!1,forcedRefresh:!0,disabled:!0},insertHR:{title:"Insert Horizontal Line"},clearFormatting:{title:"Clear Formatting"},selectAll:{title:"Select All",undo:!1}},$.FroalaEditor.RegisterCommand=function(name,info){$.FroalaEditor.COMMANDS[name]=info},$.FroalaEditor.MODULES.commands=function(editor){function exec(cmd,params){if(editor.events.trigger("commands.before",$.merge([cmd],params||[]))!==!1){var callback=$.FroalaEditor.COMMANDS[cmd]&&$.FroalaEditor.COMMANDS[cmd].callback||mapping[cmd],focus=!0;$.FroalaEditor.COMMANDS[cmd]&&"undefined"!=typeof $.FroalaEditor.COMMANDS[cmd].focus&&(focus=$.FroalaEditor.COMMANDS[cmd].focus),editor.core.hasFocus()||!focus||editor.popups.areVisible()||editor.events.focus(!0),$.FroalaEditor.COMMANDS[cmd]&&$.FroalaEditor.COMMANDS[cmd].undo!==!1&&editor.undo.saveStep(),callback&&callback.apply(editor,$.merge([cmd],params||[])),editor.events.trigger("commands.after",$.merge([cmd],params||[])),$.FroalaEditor.COMMANDS[cmd]&&$.FroalaEditor.COMMANDS[cmd].undo!==!1&&editor.undo.saveStep()}}function _execCommand(cmd,tag){if(editor.selection.isCollapsed()&&editor.document.queryCommandState(cmd)===!1){editor.markers.insert();var $marker=editor.$el.find(".fr-marker");$marker.replaceWith("<"+tag+">"+$.FroalaEditor.INVISIBLE_SPACE+$.FroalaEditor.MARKERS+"</"+tag+">"),editor.selection.restore()}else{var el=editor.selection.element();if(editor.selection.isCollapsed()&&editor.document.queryCommandState(cmd)===!0&&el.tagName==tag.toUpperCase()&&0===(el.textContent||"").replace(/\u200B/g,"").length)$(el).replaceWith($.FroalaEditor.MARKERS),editor.selection.restore();else{var spans=editor.$el.find("span"),selection_saved=!1;editor.document.queryCommandState(cmd)===!1&&(editor.selection.save(),selection_saved=!0),editor.document.execCommand(cmd,!1,!1),selection_saved&&editor.selection.restore();var new_spans=editor.$el.find("span[style]").not(spans).filter(function(){return $(this).attr("style").indexOf("font-weight: normal")>=0});new_spans.length&&(editor.selection.save(),new_spans.each(function(){$(this).replaceWith($(this).html())}),editor.selection.restore()),editor.clean.toHTML5()}}}function _processIndent(indent){editor.selection.save(),editor.html.wrap(!0,!0),editor.selection.restore();for(var blocks=editor.selection.blocks(),i=0;i<blocks.length;i++)if("LI"!=blocks[i].tagName&&"LI"!=blocks[i].parentNode.tagName){var $block=$(blocks[i]),prop="rtl"==editor.opts.direction||"rtl"==$block.css("direction")?"margin-right":"margin-left",margin_left=editor.helpers.getPX($block.css(prop));$block.css(prop,Math.max(margin_left+20*indent,0)||""),$block.removeClass("fr-temp-div")}editor.selection.save(),editor.html.unwrap(),editor.selection.restore()}function _saveFontSize(){var hasFontSizeSet=function($el){return $el.attr("style").indexOf("font-size")>=0};editor.$el.find("[style]").each(function(){var $el=$(this);hasFontSizeSet($el)&&($el.attr("data-font-size",$el.css("font-size")),$el.css("font-size",""))})}function _restoreFontSize(){editor.$el.find("[data-font-size]").each(function(){var $el=$(this);$el.css("font-size",$el.attr("data-font-size")),$el.removeAttr("data-font-size")})}function _clearBlankSpans(){editor.$el.find("span").each(function(){""===editor.node.attributes(this)&&$(this).replaceWith($(this).html())})}function applyProperty(prop,val){if(editor.selection.isCollapsed()){editor.markers.insert();var $marker=editor.$el.find(".fr-marker");$marker.replaceWith('<span style="'+prop+": "+val+';">'+$.FroalaEditor.INVISIBLE_SPACE+$.FroalaEditor.MARKERS+"</span>"),editor.selection.restore()}else{_saveFontSize(),editor.document.execCommand("fontSize",!1,4),editor.selection.save(),_restoreFontSize();for(var i,clean_format=function(elem){var $elem=$(elem);$elem.css(prop,""),""===$elem.attr("style")&&$elem.replaceWith($elem.html())},filter_spans=function(){return 0===$(this).attr("style").indexOf(prop+":")||$(this).attr("style").indexOf(";"+prop+":")>=0||$(this).attr("style").indexOf("; "+prop+":")>=0};editor.$el.find("font").length>0;){var $font=editor.$el.find("font:first"),$span=$('<span class="fr-just" style="'+prop+": "+val+';">'+$font.html()+"</span>");$font.replaceWith($span);var inner_spans=$span.find("span");for(i=inner_spans.length-1;i>=0;i--)clean_format(inner_spans[i]);var $outer_span=$span.parentsUntil(editor.$el,"span:first").filter(filter_spans);if($outer_span.length){var c_str="",o_str="",ic_str="",io_str="",c_node=$span.get(0);do c_node=c_node.parentNode,c_str+=editor.node.closeTagString(c_node),o_str=editor.node.openTagString(c_node)+o_str,$outer_span.get(0)!=c_node&&(ic_str+=editor.node.closeTagString(c_node),io_str=editor.node.openTagString(c_node)+io_str);while($outer_span.get(0)!=c_node);var str=c_str+'<span class="fr-just" style="'+prop+": "+val+';">'+io_str+$span.html()+ic_str+"</span>"+o_str;$span.replaceWith('<span id="fr-break"></span>');var html=$outer_span.get(0).outerHTML;$outer_span.replaceWith(html.replace(/<span id="fr-break"><\/span>/g,str))}}editor.html.cleanEmptyTags(),_clearBlankSpans();var just_spans=editor.$el.find(".fr-just + .fr-just");for(i=0;i<just_spans.length;i++){var $s=$(just_spans[i]);$s.prepend($s.prev().html()),$s.prev().remove()}editor.$el.find(".fr-marker + .fr-just").each(function(){$(this).prepend($(this).prev())}),editor.$el.find(".fr-just + .fr-marker").each(function(){$(this).append($(this).next())}),editor.$el.find(".fr-just").removeAttr("class"),editor.selection.restore()}}function callExec(k){return function(){exec(k)}}var mapping={bold:function(){_execCommand("bold","strong")},subscript:function(){_execCommand("subscript","sub")},superscript:function(){_execCommand("superscript","sup")},italic:function(){_execCommand("italic","em")},strikeThrough:function(){_execCommand("strikeThrough","s")},underline:function(){_execCommand("underline","u")},undo:function(){editor.undo.run()},redo:function(){editor.undo.redo()},indent:function(){_processIndent(1)},outdent:function(){_processIndent(-1)},show:function(){editor.opts.toolbarInline&&editor.toolbar.showInline(null,!0)},insertHR:function(){editor.selection.remove(),editor.html.insert('<hr id="fr-just">');var $hr=editor.$el.find("hr#fr-just");$hr.removeAttr("id"),editor.selection.setAfter($hr.get(0))||editor.selection.setBefore($hr.get(0)),editor.selection.restore()},clearFormatting:function(){editor.document.execCommand("removeFormat",!1,!1),editor.document.execCommand("unlink",!1,!1)},selectAll:function(){editor.document.execCommand("selectAll",!1,!1)}},resp={};for(var k in mapping)resp[k]=callExec(k);return $.extend(resp,{exec:exec,applyProperty:applyProperty})},$.FroalaEditor.MODULES.cursorLists=function(editor){function _firstParentLI(node){for(var p_node=node;"LI"!=p_node.tagName;)p_node=p_node.parentNode;return p_node}function _firstParentList(node){for(var p_node=node;!editor.node.isList(p_node);)p_node=p_node.parentNode;return p_node}function _startEnter(marker){var ul,li=_firstParentLI(marker),next_li=li.nextSibling,prev_li=li.previousSibling,default_tag=editor.html.defaultTag();if(editor.node.isEmpty(li,!0)&&next_li){for(var o_str="",c_str="",p_node=marker.parentNode;!editor.node.isList(p_node)&&p_node.parentNode&&"LI"!==p_node.parentNode.tagName;)o_str=editor.node.openTagString(p_node)+o_str,c_str+=editor.node.closeTagString(p_node),p_node=p_node.parentNode;o_str=editor.node.openTagString(p_node)+o_str,c_str+=editor.node.closeTagString(p_node);var str="";for(str=p_node.parentNode&&"LI"==p_node.parentNode.tagName?c_str+"<li>"+$.FroalaEditor.MARKERS+"<br>"+o_str:default_tag?c_str+"<"+default_tag+">"+$.FroalaEditor.MARKERS+"<br></"+default_tag+">"+o_str:c_str+$.FroalaEditor.MARKERS+"<br>"+o_str,$(li).html('<span id="fr-break"></span>');["UL","OL"].indexOf(p_node.tagName)<0||p_node.parentNode&&"LI"===p_node.parentNode.tagName;)p_node=p_node.parentNode;var html=editor.node.openTagString(p_node)+$(p_node).html()+editor.node.closeTagString(p_node);html=html.replace(/<span id="fr-break"><\/span>/g,str),$(p_node).replaceWith(html),editor.$el.find("li:empty").remove()}else prev_li&&next_li||!editor.node.isEmpty(li,!0)?($(li).before("<li><br></li>"),$(marker).remove()):prev_li?(ul=_firstParentList(li),ul.parentNode&&"LI"==ul.parentNode.tagName?$(ul.parentNode).after("<li>"+$.FroalaEditor.MARKERS+"<br></li>"):default_tag?$(ul).after("<"+default_tag+">"+$.FroalaEditor.MARKERS+"<br></"+default_tag+">"):$(ul).after($.FroalaEditor.MARKERS+"<br>"),$(li).remove()):(ul=_firstParentList(li),ul.parentNode&&"LI"==ul.parentNode.tagName?$(ul.parentNode).before("<li>"+$.FroalaEditor.MARKERS+"<br></li>"):default_tag?$(ul).before("<"+default_tag+">"+$.FroalaEditor.MARKERS+"<br></"+default_tag+">"):$(ul).before($.FroalaEditor.MARKERS+"<br>"),$(li).remove())}function _middleEnter(marker){for(var li=_firstParentLI(marker),str="",node=marker,o_str="",c_str="";node!=li;){node=node.parentNode;var cls="A"==node.tagName&&editor.cursor.isAtEnd(marker,node)?"fr-to-remove":"";o_str=editor.node.openTagString($(node).clone().addClass(cls).get(0))+o_str,c_str=editor.node.closeTagString(node)+c_str}str=c_str+str+o_str+$.FroalaEditor.MARKERS,$(marker).replaceWith('<span id="fr-break"></span>');var html=editor.node.openTagString(li)+$(li).html()+editor.node.closeTagString(li);html=html.replace(/<span id="fr-break"><\/span>/g,str),$(li).replaceWith(html)}function _endEnter(marker){for(var li=_firstParentLI(marker),str=$.FroalaEditor.MARKERS,node=marker;node!=li;){node=node.parentNode;var cls="A"==node.tagName&&editor.cursor.isAtEnd(marker,node)?"fr-to-remove":"";str=editor.node.openTagString($(node).clone().addClass(cls).get(0))+str+editor.node.closeTagString(node)}$(marker).remove(),$(li).after(str)}function _backspace(marker){var li=_firstParentLI(marker),prev_li=li.previousSibling;if(prev_li){prev_li=$(prev_li).find(editor.html.blockTagsQuery()).get(-1)||prev_li,$(marker).replaceWith($.FroalaEditor.MARKERS);var contents=editor.node.contents(prev_li);contents.length&&"BR"==contents[contents.length-1].tagName&&$(contents[contents.length-1]).remove(),$(li).find(editor.html.blockTagsQuery()).not("ol, ul, table").each(function(){this.parentNode==li&&$(this).replaceWith($(this).html()+(editor.node.isEmpty(this)?"":"<br>"))});for(var tmp,node=editor.node.contents(li)[0];node&&!editor.node.isList(node);)tmp=node.nextSibling,$(prev_li).append(node),node=tmp;for(prev_li=li.previousSibling;node;)tmp=node.nextSibling,$(prev_li).append(node),node=tmp;$(li).remove()}else{var ul=_firstParentList(li);if($(marker).replaceWith($.FroalaEditor.MARKERS),ul.parentNode&&"LI"==ul.parentNode.tagName){var prev_node=ul.previousSibling;editor.node.isBlock(prev_node)?($(li).find(editor.html.blockTagsQuery()).not("ol, ul, table").each(function(){this.parentNode==li&&$(this).replaceWith($(this).html()+(editor.node.isEmpty(this)?"":"<br>"))}),$(prev_node).append($(li).html())):$(ul).before($(li).html())}else{var default_tag=editor.html.defaultTag();default_tag&&0===$(li).find(editor.html.blockTagsQuery()).length?$(ul).before("<"+default_tag+">"+$(li).html()+"</"+default_tag+">"):$(ul).before($(li).html())}$(li).remove(),0===$(ul).find("li").length&&$(ul).remove()}}function _del(marker){var contents,li=_firstParentLI(marker),next_li=li.nextSibling;if(next_li){contents=editor.node.contents(next_li),contents.length&&"BR"==contents[0].tagName&&$(contents[0]).remove(),$(next_li).find(editor.html.blockTagsQuery()).not("ol, ul, table").each(function(){this.parentNode==next_li&&$(this).replaceWith($(this).html()+(editor.node.isEmpty(this)?"":"<br>"))});for(var tmp,last_node=marker,node=editor.node.contents(next_li)[0];node&&!editor.node.isList(node);)tmp=node.nextSibling,$(last_node).after(node),last_node=node,node=tmp;for(;node;)tmp=node.nextSibling,$(li).append(node),node=tmp;$(marker).replaceWith($.FroalaEditor.MARKERS),$(next_li).remove()}else{for(var next_node=li;!next_node.nextSibling&&next_node!=editor.$el.get(0);)next_node=next_node.parentNode;if(next_node==editor.$el.get(0))return!1;if(next_node=next_node.nextSibling,editor.node.isBlock(next_node))$.FroalaEditor.NO_DELETE_TAGS.indexOf(next_node.tagName)<0&&($(marker).replaceWith($.FroalaEditor.MARKERS),contents=editor.node.contents(li),contents.length&&"BR"==contents[contents.length-1].tagName&&$(contents[contents.length-1]).remove(),$(li).append($(next_node).html()),$(next_node).remove());else for(contents=editor.node.contents(li),contents.length&&"BR"==contents[contents.length-1].tagName&&$(contents[contents.length-1]).remove(),$(marker).replaceWith($.FroalaEditor.MARKERS);next_node&&!editor.node.isBlock(next_node)&&"BR"!=next_node.tagName;)$(li).append($(next_node)),next_node=next_node.nextSibling}}return{_startEnter:_startEnter,_middleEnter:_middleEnter,_endEnter:_endEnter,_backspace:_backspace,_del:_del}},$.FroalaEditor.NO_DELETE_TAGS=["TH","TD","TABLE"],$.FroalaEditor.SIMPLE_ENTER_TAGS=["TH","TD","LI"],$.FroalaEditor.MODULES.cursor=function(editor){function _atEnd(node){return editor.node.isBlock(node)?!0:node.nextSibling?!1:_atEnd(node.parentNode)}function _atStart(node){return editor.node.isBlock(node)?!0:node.previousSibling?!1:_atStart(node.parentNode)}function _isAtStart(node,container){return node?node==editor.$wp.get(0)?!1:node.previousSibling?!1:node.parentNode==container?!0:_isAtStart(node.parentNode,container):!1}function _isAtEnd(node,container){return node?node==editor.$wp.get(0)?!1:node.nextSibling?!1:node.parentNode==container?!0:_isAtEnd(node.parentNode,container):!1}function _inLi(node){return $(node).parentsUntil(editor.$el,"LI").length>0&&0===$(node).parentsUntil("LI","TABLE").length}function _startBackspace(marker){var quote=$(marker).parentsUntil(editor.$el,"BLOCKQUOTE").length>0,deep_parent=editor.node.deepestParent(marker,[],!quote);if(deep_parent&&"BLOCKQUOTE"==deep_parent.tagName){var m_parent=editor.node.deepestParent(marker,[$(marker).parentsUntil(editor.$el,"BLOCKQUOTE").get(0)]);m_parent&&m_parent.previousSibling&&(deep_parent=m_parent)}if(null!==deep_parent){var contents,prev_node=deep_parent.previousSibling;if(editor.node.isBlock(deep_parent)&&editor.node.isEditable(deep_parent)&&prev_node&&$.FroalaEditor.NO_DELETE_TAGS.indexOf(prev_node.tagName)<0&&editor.node.isEditable(prev_node))if(editor.node.isBlock(prev_node))if(editor.node.isEmpty(prev_node)&&!editor.node.isList(prev_node))$(prev_node).remove();else{if(editor.node.isList(prev_node)&&(prev_node=$(prev_node).find("li:last").get(0)),contents=editor.node.contents(prev_node),contents.length&&"BR"==contents[contents.length-1].tagName&&$(contents[contents.length-1]).remove(),"BLOCKQUOTE"==prev_node.tagName&&"BLOCKQUOTE"!=deep_parent.tagName)for(contents=editor.node.contents(prev_node);contents.length&&editor.node.isBlock(contents[contents.length-1]);)prev_node=contents[contents.length-1],contents=editor.node.contents(prev_node);else if("BLOCKQUOTE"!=prev_node.tagName&&"BLOCKQUOTE"==deep_parent.tagName)for(contents=editor.node.contents(deep_parent);contents.length&&editor.node.isBlock(contents[0]);)deep_parent=contents[0],contents=editor.node.contents(deep_parent);$(marker).replaceWith($.FroalaEditor.MARKERS),$(prev_node).append(deep_parent.innerHTML),$(deep_parent).remove()}else $(marker).replaceWith($.FroalaEditor.MARKERS),"BLOCKQUOTE"==deep_parent.tagName&&prev_node.nodeType==Node.ELEMENT_NODE?$(prev_node).remove():($(prev_node).after(editor.node.isEmpty(deep_parent)?"":$(deep_parent).html()),$(deep_parent).remove(),"BR"==prev_node.tagName&&$(prev_node).remove())}}function _middleBackspace(marker){for(var prev_node=marker;!prev_node.previousSibling;)prev_node=prev_node.parentNode;prev_node=prev_node.previousSibling;var contents;if(editor.node.isBlock(prev_node)){if($.FroalaEditor.NO_DELETE_TAGS.indexOf(prev_node.tagName)<0)if(editor.node.isEmpty(prev_node)&&!editor.node.isList(prev_node))$(prev_node).remove(),$(marker).replaceWith($.FroalaEditor.MARKERS);else{for(editor.node.isList(prev_node)&&(prev_node=$(prev_node).find("li:last").get(0)),contents=editor.node.contents(prev_node),contents&&"BR"==contents[contents.length-1].tagName&&$(contents[contents.length-1]).remove(),contents=editor.node.contents(prev_node);contents&&editor.node.isBlock(contents[contents.length-1]);)prev_node=contents[contents.length-1],contents=editor.node.contents(prev_node);$(prev_node).append($.FroalaEditor.MARKERS);for(var next_node=marker;!next_node.previousSibling;)next_node=next_node.parentNode;for(;next_node&&"BR"!==next_node.tagName&&!editor.node.isBlock(next_node);){var copy_node=next_node;next_node=next_node.nextSibling,$(prev_node).append(copy_node)}next_node&&"BR"==next_node.tagName&&$(next_node).remove(),$(marker).remove()}}else{for(contents=editor.node.contents(prev_node);prev_node.nodeType!=Node.TEXT_NODE&&contents.length&&!$(prev_node).is("[contenteditable='false']");)prev_node=contents[contents.length-1],contents=editor.node.contents(prev_node);if(prev_node.nodeType==Node.TEXT_NODE){if(editor.helpers.isIOS())return!0;$(prev_node).after($.FroalaEditor.MARKERS);var txt=prev_node.textContent,len=txt.length-1;if(editor.opts.tabSpaces&&txt.length>=editor.opts.tabSpaces){var tab_str=txt.substr(txt.length-editor.opts.tabSpaces,txt.length-1);0==tab_str.replace(/ /g,"").replace(new RegExp($.FroalaEditor.UNICODE_NBSP,"g"),"").length&&(len=txt.length-editor.opts.tabSpaces)}prev_node.textContent=txt.substring(0,len),prev_node.textContent.length&&55357==prev_node.textContent.charCodeAt(prev_node.textContent.length-1)&&(prev_node.textContent=prev_node.textContent.substr(0,prev_node.textContent.length-1))}else editor.events.trigger("node.remove",[$(prev_node)])!==!1&&($(prev_node).after($.FroalaEditor.MARKERS),$(prev_node).remove())}}function backspace(){var do_default=!1,marker=editor.markers.insert();if(!marker)return!1;editor.$el.get(0).normalize();var prev_node=marker.previousSibling;if(prev_node){var txt=prev_node.textContent;txt&&txt.length&&8203==txt.charCodeAt(txt.length-1)&&(1==txt.length?$(prev_node).remove():(prev_node.textContent=prev_node.textContent.substr(0,txt.length-1),
|
||
prev_node.textContent.length&&55357==prev_node.textContent.charCodeAt(prev_node.textContent.length-1)&&(prev_node.textContent=prev_node.textContent.substr(0,prev_node.textContent.length-1))))}return _atEnd(marker)?do_default=_middleBackspace(marker):_atStart(marker)?_inLi(marker)&&_isAtStart(marker,$(marker).parents("li:first").get(0))?editor.cursorLists._backspace(marker):_startBackspace(marker):do_default=_middleBackspace(marker),$(marker).remove(),editor.$el.find("blockquote:empty").remove(),editor.html.fillEmptyBlocks(!0),editor.html.cleanEmptyTags(!0),editor.clean.quotes(),editor.clean.lists(),editor.html.normalizeSpaces(),editor.selection.restore(),do_default}function _endDel(marker){var quote=$(marker).parentsUntil(editor.$el,"BLOCKQUOTE").length>0,deep_parent=editor.node.deepestParent(marker,[],!quote);if(deep_parent&&"BLOCKQUOTE"==deep_parent.tagName){var m_parent=editor.node.deepestParent(marker,[$(marker).parentsUntil(editor.$el,"BLOCKQUOTE").get(0)]);m_parent&&m_parent.nextSibling&&(deep_parent=m_parent)}if(null!==deep_parent){var contents,next_node=deep_parent.nextSibling;if(editor.node.isBlock(deep_parent)&&editor.node.isEditable(deep_parent)&&next_node&&$.FroalaEditor.NO_DELETE_TAGS.indexOf(next_node.tagName)<0)if(editor.node.isBlock(next_node)&&editor.node.isEditable(next_node))if(editor.node.isList(next_node))if(editor.node.isEmpty(deep_parent,!0))$(deep_parent).remove(),$(next_node).find("li:first").prepend($.FroalaEditor.MARKERS);else{var $li=$(next_node).find("li:first");"BLOCKQUOTE"==deep_parent.tagName&&(contents=editor.node.contents(deep_parent),contents.length&&editor.node.isBlock(contents[contents.length-1])&&(deep_parent=contents[contents.length-1])),0===$li.find("ul, ol").length&&($(marker).replaceWith($.FroalaEditor.MARKERS),$li.find(editor.html.blockTagsQuery()).not("ol, ul, table").each(function(){this.parentNode==$li.get(0)&&$(this).replaceWith($(this).html()+(editor.node.isEmpty(this)?"":"<br>"))}),$(deep_parent).append(editor.node.contents($li.get(0))),$li.remove(),0===$(next_node).find("li").length&&$(next_node).remove())}else{if(contents=editor.node.contents(next_node),contents.length&&"BR"==contents[0].tagName&&$(contents[0]).remove(),"BLOCKQUOTE"!=next_node.tagName&&"BLOCKQUOTE"==deep_parent.tagName)for(contents=editor.node.contents(deep_parent);contents.length&&editor.node.isBlock(contents[contents.length-1]);)deep_parent=contents[contents.length-1],contents=editor.node.contents(deep_parent);else if("BLOCKQUOTE"==next_node.tagName&&"BLOCKQUOTE"!=deep_parent.tagName)for(contents=editor.node.contents(next_node);contents.length&&editor.node.isBlock(contents[0]);)next_node=contents[0],contents=editor.node.contents(next_node);$(marker).replaceWith($.FroalaEditor.MARKERS),$(deep_parent).append(next_node.innerHTML),$(next_node).remove()}else{for($(marker).replaceWith($.FroalaEditor.MARKERS);next_node&&"BR"!==next_node.tagName&&!editor.node.isBlock(next_node)&&editor.node.isEditable(next_node);){var copy_node=next_node;next_node=next_node.nextSibling,$(deep_parent).append(copy_node)}next_node&&"BR"==next_node.tagName&&editor.node.isEditable(next_node)&&$(next_node).remove()}}}function _middleDel(marker){for(var next_node=marker;!next_node.nextSibling;)next_node=next_node.parentNode;if(next_node=next_node.nextSibling,"BR"==next_node.tagName&&editor.node.isEditable(next_node))if(next_node.nextSibling){if(editor.node.isBlock(next_node.nextSibling)&&editor.node.isEditable(next_node.nextSibling)){if(!($.FroalaEditor.NO_DELETE_TAGS.indexOf(next_node.nextSibling.tagName)<0))return;next_node=next_node.nextSibling,$(next_node.previousSibling).remove()}}else if(_atEnd(next_node)){if(_inLi(marker))editor.cursorLists._del(marker);else{var deep_parent=editor.node.deepestParent(next_node);deep_parent&&($(next_node).remove(),_endDel(marker))}return}var contents;if(!editor.node.isBlock(next_node)&&editor.node.isEditable(next_node)){for(contents=editor.node.contents(next_node);next_node.nodeType!=Node.TEXT_NODE&&contents.length&&editor.node.isEditable(next_node);)next_node=contents[0],contents=editor.node.contents(next_node);next_node.nodeType==Node.TEXT_NODE?($(next_node).before($.FroalaEditor.MARKERS),next_node.textContent.length&&55357==next_node.textContent.charCodeAt(0)?next_node.textContent=next_node.textContent.substring(2,next_node.textContent.length):next_node.textContent=next_node.textContent.substring(1,next_node.textContent.length)):editor.events.trigger("node.remove",[$(next_node)])!==!1&&($(next_node).before($.FroalaEditor.MARKERS),$(next_node).remove()),$(marker).remove()}else if($.FroalaEditor.NO_DELETE_TAGS.indexOf(next_node.tagName)<0)if(editor.node.isList(next_node))marker.previousSibling?($(next_node).find("li:first").prepend(marker),editor.cursorLists._backspace(marker)):($(next_node).find("li:first").prepend($.FroalaEditor.MARKERS),$(marker).remove());else if(contents=editor.node.contents(next_node),contents&&"BR"==contents[0].tagName&&$(contents[0]).remove(),contents&&"BLOCKQUOTE"==next_node.tagName){var node=contents[0];for($(marker).before($.FroalaEditor.MARKERS);node&&"BR"!=node.tagName;){var tmp=node;node=node.nextSibling,$(marker).before(tmp)}node&&"BR"==node.tagName&&$(node).remove()}else $(marker).after($(next_node).html()).after($.FroalaEditor.MARKERS),$(next_node).remove()}function del(){var marker=editor.markers.insert();if(!marker)return!1;if(editor.$el.get(0).normalize(),_atEnd(marker))if(_inLi(marker))if(0===$(marker).parents("li:first").find("ul, ol").length)editor.cursorLists._del(marker);else{var $li=$(marker).parents("li:first").find("ul:first, ol:first").find("li:first");$li=$li.find(editor.html.blockTagsQuery()).get(-1)||$li,$li.prepend(marker),editor.cursorLists._backspace(marker)}else _endDel(marker);else _middleDel(_atStart(marker)?marker:marker);$(marker).remove(),editor.$el.find("blockquote:empty").remove(),editor.html.fillEmptyBlocks(!0),editor.html.cleanEmptyTags(!0),editor.clean.quotes(),editor.clean.lists(),editor.html.normalizeSpaces(),editor.selection.restore()}function _cleanNodesToRemove(){editor.$el.find(".fr-to-remove").each(function(){for(var contents=editor.node.contents(this),i=0;i<contents.length;i++)contents[i].nodeType==Node.TEXT_NODE&&(contents[i].textContent=contents[i].textContent.replace(/\u200B/g,""));$(this).replaceWith(this.innerHTML)})}function _endEnter(marker,shift,quote){var default_tag,deep_parent=editor.node.deepestParent(marker,[],!quote);if(deep_parent&&"BLOCKQUOTE"==deep_parent.tagName)return _isAtEnd(marker,deep_parent)?(default_tag=editor.html.defaultTag(),default_tag?$(deep_parent).after("<"+default_tag+">"+$.FroalaEditor.MARKERS+"<br></"+default_tag+">"):$(deep_parent).after($.FroalaEditor.MARKERS+"<br>"),$(marker).remove(),!1):(_middleEnter(marker,shift,quote),!1);if(null==deep_parent)$(marker).replaceWith("<br/>"+$.FroalaEditor.MARKERS+"<br/>");else{var c_node=marker,str="";(!editor.node.isBlock(deep_parent)||shift)&&(str="<br/>");var c_str="",o_str="";default_tag=editor.html.defaultTag();var open_default_tag="",close_default_tag="";default_tag&&editor.node.isBlock(deep_parent)&&(open_default_tag="<"+default_tag+">",close_default_tag="</"+default_tag+">");do if(c_node=c_node.parentNode,!shift||c_node!=deep_parent||shift&&!editor.node.isBlock(deep_parent))if(c_str+=editor.node.closeTagString(c_node),c_node==deep_parent&&editor.node.isBlock(deep_parent))o_str=open_default_tag+o_str;else{var cls="A"==c_node.tagName&&_isAtEnd(marker,c_node)?"fr-to-remove":"";o_str=editor.node.openTagString($(c_node).clone().addClass(cls).get(0))+o_str}while(c_node!=deep_parent);str=c_str+str+o_str+(marker.parentNode==deep_parent&&editor.node.isBlock(deep_parent)?"":$.FroalaEditor.INVISIBLE_SPACE)+$.FroalaEditor.MARKERS,editor.node.isBlock(deep_parent)&&!$(deep_parent).find("*:last").is("br")&&$(deep_parent).append("<br/>"),$(marker).after('<span id="fr-break"></span>'),$(marker).remove(),deep_parent.nextSibling&&!editor.node.isBlock(deep_parent.nextSibling)||editor.node.isBlock(deep_parent)||$(deep_parent).after("<br>");var html;html=!shift&&editor.node.isBlock(deep_parent)?editor.node.openTagString(deep_parent)+$(deep_parent).html()+close_default_tag:editor.node.openTagString(deep_parent)+$(deep_parent).html()+editor.node.closeTagString(deep_parent),html=html.replace(/<span id="fr-break"><\/span>/g,str),$(deep_parent).replaceWith(html)}}function _startEnter(marker,shift,quote){var deep_parent=editor.node.deepestParent(marker,[],!quote);if(deep_parent&&"BLOCKQUOTE"==deep_parent.tagName){if(_isAtStart(marker,deep_parent)){var default_tag=editor.html.defaultTag();return default_tag?$(deep_parent).before("<"+default_tag+">"+$.FroalaEditor.MARKERS+"<br></"+default_tag+">"):$(deep_parent).before($.FroalaEditor.MARKERS+"<br>"),$(marker).remove(),!1}_isAtEnd(marker,deep_parent)?_endEnter(marker,shift,!0):_middleEnter(marker,shift,!0)}if(null==deep_parent)$(marker).replaceWith("<br>"+$.FroalaEditor.MARKERS);else{if(editor.node.isBlock(deep_parent))if(shift)$(marker).remove(),$(deep_parent).prepend("<br>"+$.FroalaEditor.MARKERS);else{if(editor.node.isEmpty(deep_parent,!0))return _endEnter(marker,shift,quote);$(deep_parent).before(editor.node.openTagString(deep_parent)+"<br>"+editor.node.closeTagString(deep_parent))}else $(deep_parent).before("<br>");$(marker).remove()}}function _middleEnter(marker,shift,quote){var deep_parent=editor.node.deepestParent(marker,[],!quote);if(null==deep_parent)(!marker.nextSibling||editor.node.isBlock(marker.nextSibling))&&$(marker).after("<br>"),$(marker).replaceWith("<br>"+$.FroalaEditor.MARKERS);else{var c_node=marker,str="";"PRE"==deep_parent.tagName&&(shift=!0),(!editor.node.isBlock(deep_parent)||shift)&&(str="<br>");var c_str="",o_str="";do{var tmp=c_node;if(c_node=c_node.parentNode,"BLOCKQUOTE"==deep_parent.tagName&&editor.node.isEmpty(tmp)&&!$(tmp).hasClass("fr-marker")&&$(tmp).find(marker).length>0&&$(tmp).after(marker),("BLOCKQUOTE"!=deep_parent.tagName||!_isAtEnd(marker,c_node)&&!_isAtStart(marker,c_node))&&(!shift||c_node!=deep_parent||shift&&!editor.node.isBlock(deep_parent))){c_str+=editor.node.closeTagString(c_node);var cls="A"==c_node.tagName&&_isAtEnd(marker,c_node)?"fr-to-remove":"";o_str=editor.node.openTagString($(c_node).clone().addClass(cls).get(0))+o_str}}while(c_node!=deep_parent);var add=deep_parent==marker.parentNode&&editor.node.isBlock(deep_parent)||marker.nextSibling;if("BLOCKQUOTE"==deep_parent.tagName){marker.previousSibling&&editor.node.isBlock(marker.previousSibling)&&marker.nextSibling&&"BR"==marker.nextSibling.tagName&&($(marker.nextSibling).after(marker),marker.nextSibling&&"BR"==marker.nextSibling.tagName&&$(marker.nextSibling).remove());var default_tag=editor.html.defaultTag();str=c_str+str+(default_tag?"<"+default_tag+">":"")+$.FroalaEditor.MARKERS+"<br>"+(default_tag?"</"+default_tag+">":"")+o_str}else str=c_str+str+o_str+(add?"":$.FroalaEditor.INVISIBLE_SPACE)+$.FroalaEditor.MARKERS;$(marker).replaceWith('<span id="fr-break"></span>');var html=editor.node.openTagString(deep_parent)+$(deep_parent).html()+editor.node.closeTagString(deep_parent);html=html.replace(/<span id="fr-break"><\/span>/g,str),$(deep_parent).replaceWith(html)}}function enter(shift){var marker=editor.markers.insert();if(!marker)return!1;editor.$el.get(0).normalize();var quote=!1;$(marker).parentsUntil(editor.$el,"BLOCKQUOTE").length>0&&(shift=!1,quote=!0),$(marker).parentsUntil(editor.$el,"TD, TH").length&&(quote=!1),_atEnd(marker)?!_inLi(marker)||shift||quote?_endEnter(marker,shift,quote):editor.cursorLists._endEnter(marker):_atStart(marker)?!_inLi(marker)||shift||quote?_startEnter(marker,shift,quote):editor.cursorLists._startEnter(marker):!_inLi(marker)||shift||quote?_middleEnter(marker,shift,quote):editor.cursorLists._middleEnter(marker),_cleanNodesToRemove(),editor.html.fillEmptyBlocks(!0),editor.html.cleanEmptyTags(!0),editor.clean.lists(),editor.html.normalizeSpaces(),editor.selection.restore()}return{enter:enter,backspace:backspace,del:del,isAtEnd:_isAtEnd}},$.FroalaEditor.MODULES.data=function(a){function b(a){return a}function c(a){if(!a)return a;for(var c="",f=b("charCodeAt"),g=b("fromCharCode"),h=l.indexOf(a[0]),i=1;i<a.length-2;i++){for(var j=d(++h),k=a[f](i),m="";/[0-9-]/.test(a[i+1]);)m+=a[++i];m=parseInt(m,10)||0,k=e(k,j,m),k^=h-1&31,c+=String[g](k)}return c}function d(a){for(var b=a.toString(),c=0,d=0;d<b.length;d++)c+=parseInt(b.charAt(d),10);return c>10?c%9+1:c}function e(a,b,c){for(var d=Math.abs(c);d-- >0;)a-=b;return 0>c&&(a+=123),a}function f(a){return a&&"none"==a.css("display")?(a.remove(),!0):!1}function g(){return f(j)||f(k)}function h(){return a.$box?(a.$box.append(n(b(n("kTDD4spmKD1klaMB1C7A5RA1G3RA10YA5qhrjuvnmE1D3FD2bcG-7noHE6B2JB4C3xXA8WF6F-10RG2C3G3B-21zZE3C3H3xCA16NC4DC1f1hOF1MB3B-21whzQH5UA2WB10kc1C2F4D3XC2YD4D1C4F3GF2eJ2lfcD-13HF1IE1TC11TC7WE4TA4d1A2YA6XA4d1A3yCG2qmB-13GF4A1B1KH1HD2fzfbeQC3TD9VE4wd1H2A20A2B-22ujB3nBG2A13jBC10D3C2HD5D1H1KB11uD-16uWF2D4A3F-7C9D-17c1E4D4B3d1D2CA6B2B-13qlwzJF2NC2C-13E-11ND1A3xqUA8UE6bsrrF-7C-22ia1D2CF2H1E2akCD2OE1HH1dlKA6PA5jcyfzB-22cXB4f1C3qvdiC4gjGG2H2gklC3D-16wJC1UG4dgaWE2D5G4g1I2H3B7vkqrxH1H2EC9C3E4gdgzKF1OA1A5PF5C4WWC3VA6XA4e1E3YA2YA5HE4oGH4F2H2IB10D3D2NC5G1B1qWA9PD6PG5fQA13A10XA4C4A3e1H2BA17kC-22cmOB1lmoA2fyhcptwWA3RA8A-13xB-11nf1I3f1B7GB3aD3pavFC10D5gLF2OG1LSB2D9E7fQC1F4F3wpSB5XD3NkklhhaE-11naKA9BnIA6D1F5bQA3A10c1QC6Kjkvitc2B6BE3AF3E2DA6A4JD2IC1jgA-64MB11D6C4==")))),j=a.$box.find("> div:last"),k=j.find("> a"),void("rtl"==a.opts.direction&&j.css("left","auto").css("right",0))):!1}function i(){var c=a.opts.key||[""];"string"==typeof c&&(c=[c]),a.ul=!0;for(var d=0;d<c.length;d++){var e=n(c[d])||"";if(!(e!==n(b(n("mcVRDoB1BGILD7YFe1BTXBA7B6==")))&&e.indexOf(m,e.length-m.length)<0&&[n("9qqG-7amjlwq=="),n("KA3B3C2A6D1D5H5H1A3==")].indexOf(m)<0)){a.ul=!1;break}}a.ul===!0&&h(),a.events.on("contentChanged",function(){a.ul===!0&&g()&&h()})}var j,k,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",m=function(){for(var a=0,b=document.domain,c=b.split("."),d="_gd"+(new Date).getTime();a<c.length-1&&-1==document.cookie.indexOf(d+"="+d);)b=c.slice(-1-++a).join("."),document.cookie=d+"="+d+";domain="+b+";";return document.cookie=d+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain="+b+";",b}(),n=b(c);return{_init:i}},$.FroalaEditor.ENTER_P=0,$.FroalaEditor.ENTER_DIV=1,$.FroalaEditor.ENTER_BR=2,$.FroalaEditor.KEYCODE={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,FF_SEMICOLON:59,FF_EQUALS:61,QUESTION_MARK:63,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,META:91,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,SEMICOLON:186,DASH:189,EQUALS:187,COMMA:188,PERIOD:190,SLASH:191,APOSTROPHE:192,TILDE:192,SINGLE_QUOTE:222,OPEN_SQUARE_BRACKET:219,BACKSLASH:220,CLOSE_SQUARE_BRACKET:221},$.extend($.FroalaEditor.DEFAULTS,{enter:$.FroalaEditor.ENTER_P,multiLine:!0,tabSpaces:0}),$.FroalaEditor.MODULES.keys=function(editor){function _hideShowiOSKeyboard(){editor.helpers.isIOS()&&(editor.events.disableBlur(),editor.selection.save(),editor.$el.blur(),editor.selection.restore(),editor.events.enableBlur())}function _enter(e){e.preventDefault(),e.stopPropagation(),editor.opts.multiLine&&(editor.selection.isCollapsed()||editor.selection.remove(),editor.cursor.enter()),_hideShowiOSKeyboard()}function _shiftEnter(e){e.preventDefault(),e.stopPropagation(),editor.opts.multiLine&&(editor.selection.isCollapsed()||editor.selection.remove(),editor.cursor.enter(!0))}function _backspace(e){editor.selection.isCollapsed()?editor.cursor.backspace()||(e.preventDefault(),e.stopPropagation(),regular_backspace=!1):(e.preventDefault(),e.stopPropagation(),editor.selection.remove(),editor.html.fillEmptyBlocks(!0),regular_backspace=!1),editor.placeholder.refresh()}function _del(e){e.preventDefault(),e.stopPropagation(),""===editor.selection.text()?editor.cursor.del():editor.selection.remove(),editor.placeholder.refresh()}function _space(e){if(editor.browser.mozilla){e.preventDefault(),e.stopPropagation(),editor.selection.isCollapsed()||editor.selection.remove(),editor.markers.insert();var marker=editor.$el.find(".fr-marker").get(0),prev_node=marker.previousSibling;prev_node&&prev_node.nodeType==Node.TEXT_NODE&&1==prev_node.textContent.length&&160==prev_node.textContent.charCodeAt(0)?$(prev_node).after(" "):$(marker).before(" "),$(marker).replaceWith($.FroalaEditor.MARKERS),editor.selection.restore()}}function _input(){if(editor.browser.mozilla&&editor.selection.isCollapsed()&&!IME){var range=editor.selection.ranges(0),start_container=range.startContainer,start_offset=range.startOffset;start_container&&start_container.nodeType==Node.TEXT_NODE&&start_offset<=start_container.textContent.length&&start_offset>0&&32==start_container.textContent.charCodeAt(start_offset-1)&&(editor.selection.save(),editor.html.normalizeSpaces(),editor.selection.restore())}}function _cut(){editor.selection.isFull()&&setTimeout(function(){var default_tag=editor.html.defaultTag();default_tag?editor.$el.html("<"+default_tag+">"+$.FroalaEditor.MARKERS+"<br/></"+default_tag+">"):editor.$el.html($.FroalaEditor.MARKERS+"<br/>"),editor.selection.restore(),editor.placeholder.refresh(),editor.button.bulkRefresh(),editor.undo.saveStep()},0)}function _tab(e){if(editor.opts.tabSpaces>0)if(editor.selection.isCollapsed()){e.preventDefault(),e.stopPropagation();for(var str="",i=0;i<editor.opts.tabSpaces;i++)str+=" ";editor.html.insert(str),editor.placeholder.refresh()}else e.preventDefault(),e.stopPropagation(),e.shiftKey?editor.commands.outdent():editor.commands.indent()}function _mapKeyPress(e){IME=!1}function isIME(){return IME}function _mapKeyDown(e){editor.events.disableBlur(),regular_backspace=!0;var key_code=e.which;if(229===key_code)return IME=!0,!0;IME=!1;var char_key=isCharacter(key_code)&&!ctrlKey(e),del_key=key_code==$.FroalaEditor.KEYCODE.BACKSPACE||key_code==$.FroalaEditor.KEYCODE.DELETE;if(editor.selection.isFull()&&!editor.opts.keepFormatOnDelete||del_key&&editor.placeholder.isVisible()&&editor.opts.keepFormatOnDelete){if(char_key||del_key){var default_tag=editor.html.defaultTag();default_tag?editor.$el.html("<"+default_tag+">"+$.FroalaEditor.MARKERS+"<br/></"+default_tag+">"):editor.$el.html($.FroalaEditor.MARKERS+"<br/>")}editor.selection.restore()}key_code==$.FroalaEditor.KEYCODE.ENTER?e.shiftKey?_shiftEnter(e):_enter(e):key_code!=$.FroalaEditor.KEYCODE.BACKSPACE||ctrlKey(e)?key_code!=$.FroalaEditor.KEYCODE.DELETE||ctrlKey(e)?key_code==$.FroalaEditor.KEYCODE.SPACE?_space(e):key_code==$.FroalaEditor.KEYCODE.TAB?_tab(e):ctrlKey(e)||!isCharacter(e.which)||editor.selection.isCollapsed()||editor.selection.remove():_del(e):_backspace(e),editor.events.enableBlur()}function _replaceU200B(contents){for(var i=0;i<contents.length;i++)contents[i].nodeType==Node.TEXT_NODE&&/\u200B/gi.test(contents[i].textContent)?(contents[i].textContent=contents[i].textContent.replace(/\u200B/gi,""),0===contents[i].textContent.length&&$(contents[i]).remove()):contents[i].nodeType==Node.ELEMENT_NODE&&"IFRAME"!=contents[i].nodeType&&_replaceU200B(editor.node.contents(contents[i]))}function _positionCaret(){var info;editor.opts.height||editor.opts.heightMax?(info=editor.position.getBoundingRect().top,editor.opts.iframe&&(info+=editor.$iframe.offset().top),info>editor.$wp.offset().top-$(editor.original_window).scrollTop()+editor.$wp.height()-20&&editor.$wp.scrollTop(info+editor.$wp.scrollTop()-(editor.$wp.height()+editor.$wp.offset().top)+$(editor.original_window).scrollTop()+20)):(info=editor.position.getBoundingRect().top,editor.opts.iframe&&(info+=editor.$iframe.offset().top),info>editor.original_window.innerHeight-20&&$(editor.original_window).scrollTop(info+$(editor.original_window).scrollTop()-editor.original_window.innerHeight+20),info=editor.position.getBoundingRect().top,editor.opts.iframe&&(info+=editor.$iframe.offset().top),info<editor.$tb.height()+20&&$(editor.original_window).scrollTop(info+$(editor.original_window).scrollTop()-editor.$tb.height()-20))}function _mapKeyUp(e){if(IME)return!1;if(!editor.selection.isCollapsed())return!1;!e||e.which!=$.FroalaEditor.KEYCODE.ENTER&&e.which!=$.FroalaEditor.KEYCODE.BACKSPACE||e.which==$.FroalaEditor.KEYCODE.BACKSPACE&®ular_backspace||_positionCaret();for(var brs=editor.$el.find(editor.html.blockTagsQuery()).andSelf().not("TD, TH").find(" > br"),i=0;i<brs.length;i++){var br=brs[i],prev_node=br.previousSibling,next_node=br.nextSibling,parent_node=editor.node.blockParent(br)||editor.$el.get(0);prev_node&&parent_node&&"BR"!=prev_node.tagName&&!editor.node.isBlock(prev_node)&&!next_node&&$(parent_node).text().replace(/\u200B/g,"").length>0&&$(prev_node).text().length>0&&(editor.selection.save(),$(br).remove(),editor.selection.restore())}var has_invisible=function(node){if(!node)return!1;var text=$(node).html();return text=text.replace(/<span[^>]*? class\s*=\s*["']?fr-marker["']?[^>]+>\u200b<\/span>/gi,""),text&&/\u200B/.test(text)&&text.replace(/\u200B/gi,"").length>0?!0:!1},el=editor.selection.element();has_invisible(el)&&0===$(el).find("li").length&&!$(el).hasClass("fr-marker")&&"IFRAME"!=el.tagName&&(editor.selection.save(),_replaceU200B(editor.node.contents(el)),editor.selection.restore())}function ctrlKey(e){if(-1!=navigator.userAgent.indexOf("Mac OS X")){if(e.metaKey&&!e.altKey)return!0}else if(e.ctrlKey&&!e.altKey)return!0;return!1}function isCharacter(key_code){if(key_code>=$.FroalaEditor.KEYCODE.ZERO&&key_code<=$.FroalaEditor.KEYCODE.NINE)return!0;if(key_code>=$.FroalaEditor.KEYCODE.NUM_ZERO&&key_code<=$.FroalaEditor.KEYCODE.NUM_MULTIPLY)return!0;if(key_code>=$.FroalaEditor.KEYCODE.A&&key_code<=$.FroalaEditor.KEYCODE.Z)return!0;if(editor.browser.webkit&&0===key_code)return!0;switch(key_code){case $.FroalaEditor.KEYCODE.SPACE:case $.FroalaEditor.KEYCODE.QUESTION_MARK:case $.FroalaEditor.KEYCODE.NUM_PLUS:case $.FroalaEditor.KEYCODE.NUM_MINUS:case $.FroalaEditor.KEYCODE.NUM_PERIOD:case $.FroalaEditor.KEYCODE.NUM_DIVISION:case $.FroalaEditor.KEYCODE.SEMICOLON:case $.FroalaEditor.KEYCODE.FF_SEMICOLON:case $.FroalaEditor.KEYCODE.DASH:case $.FroalaEditor.KEYCODE.EQUALS:case $.FroalaEditor.KEYCODE.FF_EQUALS:case $.FroalaEditor.KEYCODE.COMMA:case $.FroalaEditor.KEYCODE.PERIOD:case $.FroalaEditor.KEYCODE.SLASH:case $.FroalaEditor.KEYCODE.APOSTROPHE:case $.FroalaEditor.KEYCODE.SINGLE_QUOTE:case $.FroalaEditor.KEYCODE.OPEN_SQUARE_BRACKET:case $.FroalaEditor.KEYCODE.BACKSLASH:case $.FroalaEditor.KEYCODE.CLOSE_SQUARE_BRACKET:return!0;default:return!1}}function _typingKeyDown(e){var keycode=e.which;return ctrlKey(e)||keycode>=37&&40>=keycode?!0:(_typing_timeout||(_temp_snapshot=editor.snapshot.get()),clearTimeout(_typing_timeout),void(_typing_timeout=setTimeout(function(){_typing_timeout=null,editor.undo.saveStep()},500)))}function _typingKeyUp(e){return ctrlKey(e)?!0:void(_temp_snapshot&&_typing_timeout&&(editor.undo.saveStep(_temp_snapshot),_temp_snapshot=null))}function forceUndo(){_typing_timeout&&(clearTimeout(_typing_timeout),editor.undo.saveStep(),_temp_snapshot=null)}function _init(){if(editor.events.on("keydown",_typingKeyDown),editor.events.on("input",_input),editor.events.on("keyup",_typingKeyUp),editor.events.on("keypress",_mapKeyPress),editor.events.on("keydown",_mapKeyDown),editor.events.on("keyup",_mapKeyUp),editor.events.on("html.inserted",_mapKeyUp),editor.events.on("cut",_cut),editor.$el.get(0).msGetInputContext)try{editor.$el.get(0).msGetInputContext().addEventListener("MSCandidateWindowShow",function(){IME=!0}),editor.$el.get(0).msGetInputContext().addEventListener("MSCandidateWindowHide",function(){IME=!1,_mapKeyUp()})}catch(ex){}}var regular_backspace,_typing_timeout,_temp_snapshot,IME=!1;return{_init:_init,ctrlKey:ctrlKey,isCharacter:isCharacter,forceUndo:forceUndo,isIME:isIME}},$.extend($.FroalaEditor.DEFAULTS,{pastePlain:!1,pasteDeniedTags:["colgroup","col"],pasteDeniedAttrs:["class","id","style"],pasteAllowLocalImages:!1}),$.FroalaEditor.MODULES.paste=function(editor){function _handleCopy(e){copied_html=editor.html.getSelected(),copied_text=$("<div>").html(copied_html).text(),"cut"==e.type&&(editor.undo.saveStep(),setTimeout(function(){editor.html.wrap(),editor.events.focus(),editor.undo.saveStep()},0))}function _handlePaste(e){if(e.originalEvent&&(e=e.originalEvent),editor.events.trigger("paste.before",[e])===!1)return!1;if(scroll_position=editor.$window.scrollTop(),e&&e.clipboardData&&e.clipboardData.getData){var types="",clipboard_types=e.clipboardData.types;if(editor.helpers.isArray(clipboard_types))for(var i=0;i<clipboard_types.length;i++)types+=clipboard_types[i]+";";else types=clipboard_types;if(clipboard_html="",/text\/html/.test(types)?clipboard_html=e.clipboardData.getData("text/html"):/text\/rtf/.test(types)&&editor.browser.safari?clipboard_html=e.clipboardData.getData("text/rtf"):/text\/plain/.test(types)&&!this.browser.mozilla&&(clipboard_html=editor.html.escapeEntities(e.clipboardData.getData("text/plain")).replace(/\n/g,"<br>")),""!==clipboard_html)return _processPaste(),e.preventDefault&&(e.stopPropagation(),e.preventDefault()),!1;clipboard_html=null}_beforePaste()}function _beforePaste(){editor.selection.save(),editor.events.disableBlur(),clipboard_html=null,$paste_div?$paste_div.html(""):($paste_div=$('<div contenteditable="true" style="position: fixed; top: 0; left: -9999px; height: 100%; width: 0; z-index: 9999; line-height: 140%;" tabindex="-1"></div>'),editor.$box.after($paste_div)),$paste_div.focus(),editor.window.setTimeout(_processPaste,1)}function _wordClean(html){html=html.replace(/<p(.*?)class="?'?MsoListParagraph"?'? ([\s\S]*?)>([\s\S]*?)<\/p>/gi,"<ul><li>$3</li></ul>"),html=html.replace(/<p(.*?)class="?'?NumberedText"?'? ([\s\S]*?)>([\s\S]*?)<\/p>/gi,"<ol><li>$3</li></ol>"),html=html.replace(/<p(.*?)class="?'?MsoListParagraphCxSpFirst"?'?([\s\S]*?)(level\d)?([\s\S]*?)>([\s\S]*?)<\/p>/gi,"<ul><li$3>$5</li>"),html=html.replace(/<p(.*?)class="?'?NumberedTextCxSpFirst"?'?([\s\S]*?)(level\d)?([\s\S]*?)>([\s\S]*?)<\/p>/gi,"<ol><li$3>$5</li>"),html=html.replace(/<p(.*?)class="?'?MsoListParagraphCxSpMiddle"?'?([\s\S]*?)(level\d)?([\s\S]*?)>([\s\S]*?)<\/p>/gi,"<li$3>$5</li>"),html=html.replace(/<p(.*?)class="?'?NumberedTextCxSpMiddle"?'?([\s\S]*?)(level\d)?([\s\S]*?)>([\s\S]*?)<\/p>/gi,"<li$3>$5</li>"),html=html.replace(/<p(.*?)class="?'?MsoListParagraphCxSpLast"?'?([\s\S]*?)(level\d)?([\s\S]*?)>([\s\S]*?)<\/p>/gi,"<li$3>$5</li></ul>"),html=html.replace(/<p(.*?)class="?'?NumberedTextCxSpLast"?'?([\s\S]*?)(level\d)?([\s\S]*?)>([\s\S]*?)<\/p>/gi,"<li$3>$5</li></ol>"),html=html.replace(/<span([^<]*?)style="?'?mso-list:Ignore"?'?([\s\S]*?)>([\s\S]*?)<span/gi,"<span><span"),html=html.replace(/<!--\[if \!supportLists\]-->([\s\S]*?)<!--\[endif\]-->/gi,""),html=html.replace(/<!\[if \!supportLists\]>([\s\S]*?)<!\[endif\]>/gi,""),html=html.replace(/(\n|\r| class=(")?Mso[a-zA-Z0-9]+(")?)/gi," "),html=html.replace(/<!--[\s\S]*?-->/gi,""),html=html.replace(/<(\/)*(meta|link|span|\\?xml:|st1:|o:|font)(.*?)>/gi,"");for(var word_tags=["style","script","applet","embed","noframes","noscript"],i=0;i<word_tags.length;i++){var regex=new RegExp("<"+word_tags[i]+".*?"+word_tags[i]+"(.*?)>","gi");html=html.replace(regex,"")}html=html.replace(/ /gi," "),html=html.replace(/<td([^>]*)><\/td>/g,"<td$1><br></td>"),html=html.replace(/<th([^>]*)><\/th>/g,"<th$1><br></th>");var oldHTML;do oldHTML=html,html=html.replace(/<[^\/>][^>]*><\/[^>]+>/gi,"");while(html!=oldHTML);html=html.replace(/<lilevel([^1])([^>]*)>/gi,'<li data-indent="true"$2>'),html=html.replace(/<lilevel1([^>]*)>/gi,"<li$1>"),html=editor.clean.html(html,editor.opts.pasteDeniedTags,editor.opts.pasteDeniedAttrs),html=html.replace(/<a>(.[^<]+)<\/a>/gi,"$1");var $div=$("<div>").html(html);return $div.find("li[data-indent]").each(function(index,li){var $li=$(li);if($li.prev("li").length>0){var $list=$li.prev("li").find("> ul, > ol");0===$list.length&&($list=$("ul"),$li.prev("li").append($list)),$list.append(li)}else $li.removeAttr("data-indent")}),html=$div.html()}function _plainPasteClean(html){var $div=$("<div>").html(html);$div.find("p, div, h1, h2, h3, h4, h5, h6, pre, blockquote").each(function(i,el){$(el).replaceWith("<"+(editor.html.defaultTag()||"DIV")+">"+$(el).html()+"</"+(editor.html.defaultTag()||"DIV")+">")}),$($div.find("*").not("p, div, h1, h2, h3, h4, h5, h6, pre, blockquote, ul, ol, li, table, tbody, thead, tr, td, br").get().reverse()).each(function(){$(this).replaceWith($(this).html())});var cleanComments=function(node){for(var contents=editor.node.contents(node),i=0;i<contents.length;i++)3!=contents[i].nodeType&&1!=contents[i].nodeType?$(contents[i]).remove():cleanComments(contents[i])};return cleanComments($div.get(0)),$div.html()}function _processPaste(){editor.keys.forceUndo();var snapshot=editor.snapshot.get();null===clipboard_html&&(clipboard_html=$paste_div.html(),editor.selection.restore(),editor.events.enableBlur());var response=editor.events.chainTrigger("paste.beforeCleanup",clipboard_html);if("string"==typeof response&&(clipboard_html=response),clipboard_html.indexOf("<body")>=0&&(clipboard_html=clipboard_html.replace(/[.\s\S\w\W<>]*<body[^>]*>([.\s\S\w\W<>]*)<\/body>[.\s\S\w\W<>]*/g,"$1")),clipboard_html.match(/(class=\"?Mso|style=\"[^\"]*\bmso\-|w:WordDocument)/gi)?(clipboard_html=clipboard_html.replace(/^\n*/g,"").replace(/^ /g,""),0===clipboard_html.indexOf("<colgroup>")&&(clipboard_html="<table>"+clipboard_html+"</table>"),clipboard_html=_wordClean(clipboard_html),clipboard_html=_removeEmptyTags(clipboard_html)):(editor.opts.htmlAllowComments=!1,clipboard_html=editor.clean.html(clipboard_html,editor.opts.pasteDeniedTags,editor.opts.pasteDeniedAttrs),editor.opts.htmlAllowComments=!0,clipboard_html=_removeEmptyTags(clipboard_html),clipboard_html=clipboard_html.replace(/\r|\n|\t/g,""),copied_text&&$("<div>").html(clipboard_html).text().replace(/(\u00A0)/gi," ").replace(/\r|\n/gi,"")==copied_text.replace(/(\u00A0)/gi," ").replace(/\r|\n/gi,"")&&(clipboard_html=copied_html),clipboard_html=clipboard_html.replace(/^ */g,"").replace(/ *$/g,"")),editor.opts.pastePlain&&(clipboard_html=_plainPasteClean(clipboard_html)),response=editor.events.chainTrigger("paste.afterCleanup",clipboard_html),"string"==typeof response&&(clipboard_html=response),""!==clipboard_html){var $tmp=$("<div>").html(clipboard_html);editor.html.cleanBlankSpaces($tmp.get(0)),editor.html.normalizeSpaces($tmp.get(0)),clipboard_html=$tmp.html(),editor.html.insert(clipboard_html,!0)}_afterPaste(),editor.undo.saveStep(snapshot),editor.undo.saveStep()}function _afterPaste(){editor.events.trigger("paste.after")}function _removeEmptyTags(html){for(var i,$div=$("<div>").html(html),empty_tags=$div.find("*:empty:not(br, img, td, th)");empty_tags.length;){for(i=0;i<empty_tags.length;i++)$(empty_tags[i]).remove();empty_tags=$div.find("*:empty:not(br, img, td, th)")}for(var divs=$div.find("> div:not([style]), td > div, th > div, li > div");divs.length;){var $dv=$(divs[divs.length-1]);$dv.replaceWith($dv.html()+"<br>"),divs=$div.find("> div:not([style]), td > div, th > div, li > div")}for(divs=$div.find("div:not([style])");divs.length;){for(i=0;i<divs.length;i++){var $el=$(divs[i]),text=$el.html().replace(/\u0009/gi,"").trim();$el.replaceWith(text)}divs=$div.find("div:not([style])")}return $div.html()}function _init(){editor.events.on("copy",_handleCopy),editor.events.on("cut",_handleCopy),editor.events.on("paste",_handlePaste),editor.events.on("beforepaste",_handlePaste)}var copied_html,copied_text,scroll_position,clipboard_html,$paste_div;return{_init:_init}},$.FroalaEditor.MODULES.tooltip=function(editor){function hide(){editor.$tooltip.removeClass("fr-visible").css("left","-3000px")}function to($el,above){if($el.data("title")||$el.data("title",$el.attr("title")),
|
||
!$el.data("title"))return!1;$el.removeAttr("title"),editor.$tooltip.text($el.data("title")),editor.$tooltip.addClass("fr-visible");var left=$el.offset().left+($el.outerWidth()-editor.$tooltip.outerWidth())/2;0>left&&(left=0),left+editor.$tooltip.outerWidth()>$(editor.original_window).width()&&(left=$(editor.original_window).width()-editor.$tooltip.outerWidth()),editor.$tooltip.css("left",left),"undefined"==typeof above&&(above=editor.opts.toolbarBottom),editor.$tooltip.css("top",above?$el.offset().top-editor.$tooltip.height():$el.offset().top+$el.outerHeight())}function bind($el,selector,above){editor.helpers.isMobile()||($el.on("mouseenter",selector,function(e){$(e.currentTarget).hasClass("fr-disabled")||to($(e.currentTarget),above)}),$el.on("mouseleave "+editor._mousedown+" "+editor._mouseup,selector,function(e){hide()})),editor.events.on("destroy",function(){$el.off("mouseleave "+editor._mousedown+" "+editor._mouseup,selector),$el.off("mouseenter",selector)},!0)}function _init(){editor.helpers.isMobile()||(editor.$tooltip=$('<div class="fr-tooltip"></div>'),editor.opts.theme&&editor.$tooltip.addClass(editor.opts.theme+"-theme"),$(editor.original_document).find("body").append(editor.$tooltip),editor.events.on("destroy",function(){editor.$tooltip.html("").removeData().remove()},!0))}return{_init:_init,hide:hide,to:to,bind:bind}},$.FroalaEditor.ICON_DEFAULT_TEMPLATE="font_awesome",$.FroalaEditor.ICON_TEMPLATES={font_awesome:'<i class="fa fa-[NAME]"></i>',text:'<span style="text-align: center;">[NAME]</span>',image:"<img src=[SRC] alt=[ALT] />"},$.FroalaEditor.ICONS={bold:{NAME:"bold"},italic:{NAME:"italic"},underline:{NAME:"underline"},strikeThrough:{NAME:"strikethrough"},subscript:{NAME:"subscript"},superscript:{NAME:"superscript"},color:{NAME:"tint"},outdent:{NAME:"outdent"},indent:{NAME:"indent"},undo:{NAME:"rotate-left"},redo:{NAME:"rotate-right"},insertHR:{NAME:"minus"},clearFormatting:{NAME:"eraser"},selectAll:{NAME:"mouse-pointer"}},$.FroalaEditor.DefineIconTemplate=function(name,options){$.FroalaEditor.ICON_TEMPLATES[name]=options},$.FroalaEditor.DefineIcon=function(name,options){$.FroalaEditor.ICONS[name]=options},$.FroalaEditor.MODULES.icon=function(editor){function create(command){var icon=null,info=$.FroalaEditor.ICONS[command];if("undefined"!=typeof info){var template=info.template||$.FroalaEditor.ICON_DEFAULT_TEMPLATE;template&&(template=$.FroalaEditor.ICON_TEMPLATES[template])&&(icon=template.replace(/\[([a-zA-Z]*)\]/g,function(str,a1){return"NAME"==a1?info[a1]||command:info[a1]}))}return icon||command}return{create:create}},$.FroalaEditor.MODULES.button=function(editor){function _dropdownButtonClick(e){var $btn=$(e.currentTarget),$dropdown=$btn.next(),active=$btn.hasClass("fr-active"),$active_dropdowns=(editor.helpers.isMobile(),$(".fr-dropdown.fr-active").not($btn));if(editor.helpers.isIOS()&&0==editor.$el.find(".fr-marker").length&&(editor.selection.save(),editor.selection.clear(),editor.selection.restore()),!active){var cmd=$btn.data("cmd");$dropdown.find(".fr-command").removeClass("fr-active"),$.FroalaEditor.COMMANDS[cmd]&&$.FroalaEditor.COMMANDS[cmd].refreshOnShow&&$.FroalaEditor.COMMANDS[cmd].refreshOnShow.apply(editor,[$btn,$dropdown]),$dropdown.css("left",$btn.offset().left-$btn.parent().offset().left-("rtl"==editor.opts.direction?$dropdown.width()-$btn.outerWidth():0)),editor.opts.toolbarBottom?$dropdown.css("bottom",editor.$tb.height()-$btn.position().top):$dropdown.css("top",$btn.position().top+$btn.outerHeight())}$btn.addClass("fr-blink").toggleClass("fr-active"),setTimeout(function(){$btn.removeClass("fr-blink")},300),$dropdown.offset().left+$dropdown.outerWidth()>$(editor.opts.scrollableContainer).offset().left+$(editor.opts.scrollableContainer).outerWidth()&&$dropdown.css("margin-left",-($dropdown.offset().left+$dropdown.outerWidth()-$(editor.opts.scrollableContainer).offset().left-$(editor.opts.scrollableContainer).outerWidth())),$active_dropdowns.removeClass("fr-active")}function exec($btn){$btn.addClass("fr-blink"),setTimeout(function(){$btn.removeClass("fr-blink")},500);for(var cmd=$btn.data("cmd"),params=[];"undefined"!=typeof $btn.data("param"+(params.length+1));)params.push($btn.data("param"+(params.length+1)));var $active_dropdowns=$(".fr-dropdown.fr-active");$active_dropdowns.length&&$active_dropdowns.removeClass("fr-active"),editor.commands.exec(cmd,params)}function _commandButtonClick(e){var $btn=$(e.currentTarget);exec($btn)}function _click(e){var $btn=$(e.currentTarget);0!=$btn.parents(".fr-popup").length||$btn.data("popup")||editor.popups.hideAll(),$btn.hasClass("fr-dropdown")?_dropdownButtonClick(e):(_commandButtonClick(e),$.FroalaEditor.COMMANDS[$btn.data("cmd")]&&0!=$.FroalaEditor.COMMANDS[$btn.data("cmd")].refreshAfterCallback&&bulkRefresh())}function _hideActiveDropdowns($el){var $active_dropdowns=$el.find(".fr-dropdown.fr-active");$active_dropdowns.length&&$active_dropdowns.removeClass("fr-active")}function _dropdownMenuClick(e){e.preventDefault(),e.stopPropagation()}function _dropdownWrapperClick(e){return e.stopPropagation(),editor.opts.toolbarInline?!1:void 0}function bindCommands($el,tooltipAbove){editor.events.bindClick($el,".fr-command:not(.fr-disabled)",_click),$el.on(editor._mousedown+" "+editor._mouseup+" "+editor._move,".fr-dropdown-menu",_dropdownMenuClick),$el.on(editor._mousedown+" "+editor._mouseup+" "+editor._move,".fr-dropdown-menu .fr-dropdown-wrapper",_dropdownWrapperClick);var _document=$el.get(0).ownerDocument,_window="defaultView"in _document?_document.defaultView:_document.parentWindow,hideDropdowns=function(e){(!e||e.type==editor._mouseup&&e.target!=$("html").get(0)||"keydown"==e.type&&(editor.keys.isCharacter(e.which)&&!editor.keys.ctrlKey(e)||e.which==$.FroalaEditor.KEYCODE.ESC))&&_hideActiveDropdowns($el)};$(_window).on(editor._mouseup+".command"+editor.id+" resize.command"+editor.id+" keydown.command"+editor.id,hideDropdowns),$.merge(buttons,$el.find(".fr-btn").toArray()),editor.tooltip.bind($el,".fr-btn, .fr-title",tooltipAbove),editor.events.on("destroy",function(){$el.off(editor._mousedown+" "+editor._mouseup+" "+editor._move,".fr-dropdown-menu"),$el.on(editor._mousedown+" "+editor._mouseup+" "+editor._move,".fr-dropdown-menu .fr-dropdown-wrapper"),$(_window).off(editor._mouseup+".command"+editor.id+" resize.command"+editor.id+" keydown.command"+editor.id)},!0)}function _content(command,info){var c="";if(info.html)c+="function"==typeof info.html?info.html.call(editor):info.html;else{var options=info.options;"function"==typeof options&&(options=options()),c+='<ul class="fr-dropdown-list">';for(var val in options)c+='<li><a class="fr-command" data-cmd="'+command+'" data-param1="'+val+'" title="'+options[val]+'">'+editor.language.translate(options[val])+"</a></li>";c+="</ul>"}return c}function _build(command,info,visible){var display_selection=info.displaySelection;"function"==typeof display_selection&&(display_selection=display_selection(editor));var icon;if(display_selection){var default_selection="function"==typeof info.defaultSelection?info.defaultSelection(editor):info.defaultSelection;icon='<span style="width:'+(info.displaySelectionWidth||100)+'px">'+(default_selection||editor.language.translate(info.title))+"</span>"}else icon=editor.icon.create(info.icon||command);var popup=info.popup?' data-popup="true"':"",btn='<button type="button" tabindex="-1" title="'+(editor.language.translate(info.title)||"")+'" class="fr-command fr-btn'+("dropdown"==info.type?" fr-dropdown":"")+(info.back?" fr-back":"")+(info.disabled?" fr-disabled":"")+(visible?"":" fr-hidden")+'" data-cmd="'+command+'"'+popup+">"+icon+"</button>";if("dropdown"==info.type){var dropdown='<div class="fr-dropdown-menu"><div class="fr-dropdown-wrapper"><div class="fr-dropdown-content" tabindex="-1">';dropdown+=_content(command,info),dropdown+="</div></div></div>",btn+=dropdown}return btn}function buildList(buttons,visible_buttons){for(var str="",i=0;i<buttons.length;i++){var cmd_name=buttons[i],cmd_info=$.FroalaEditor.COMMANDS[cmd_name];if(cmd_info){var visible="undefined"!=typeof visible_buttons?visible_buttons.indexOf(cmd_name)>=0:!0;str+=_build(cmd_name,cmd_info,visible)}else"|"==cmd_name?str+='<div class="fr-separator fr-vs"></div>':"-"==cmd_name&&(str+='<div class="fr-separator fr-hs"></div>')}return str}function refresh($btn){var $dropdown,cmd=$btn.data("cmd");$btn.hasClass("fr-dropdown")?$dropdown=$btn.next():$btn.removeClass("fr-active"),$.FroalaEditor.COMMANDS[cmd]&&$.FroalaEditor.COMMANDS[cmd].refresh?$.FroalaEditor.COMMANDS[cmd].refresh.apply(editor,[$btn,$dropdown]):editor.refresh[cmd]?editor.refresh[cmd]($btn,$dropdown):editor.refresh["default"]($btn,cmd)}function bulkRefresh(){return 0==editor.events.trigger("buttons.refresh")?!0:void setTimeout(function(){for(var focused=editor.selection.inEditor()&&editor.core.hasFocus(),i=0;i<buttons.length;i++){var $btn=$(buttons[i]),cmd=$btn.data("cmd");0==$btn.parents(".fr-popup").length?focused||$.FroalaEditor.COMMANDS[cmd]&&$.FroalaEditor.COMMANDS[cmd].forcedRefresh?refresh($btn):$btn.hasClass("fr-dropdown")||$btn.removeClass("fr-active"):$btn.parents(".fr-popup").is(":visible")&&refresh($btn)}},0)}function _init(){editor.events.on("mouseup",bulkRefresh),editor.events.on("keyup",bulkRefresh),editor.events.on("blur",bulkRefresh),editor.events.on("focus",bulkRefresh),editor.events.on("contentChanged",bulkRefresh)}var buttons=[];return{_init:_init,buildList:buildList,bindCommands:bindCommands,refresh:refresh,bulkRefresh:bulkRefresh,exec:exec}},$.FroalaEditor.MODULES.position=function(editor){function getBoundingRect(){var boundingRect,range=editor.selection.ranges(0);if(range&&range.collapsed&&editor.selection.inEditor()){var remove=!1;0==editor.$el.find(".fr-marker").length&&(editor.selection.save(),remove=!0);var $marker=editor.$el.find(".fr-marker:first");$marker.css("display","inline");var offset=$marker.offset();$marker.css("display","none"),boundingRect={},boundingRect.left=offset.left,boundingRect.width=0,boundingRect.height=parseInt($marker.css("line-height"),10)||20,boundingRect.top=offset.top-$(editor.original_window).scrollTop(),boundingRect.right=1,boundingRect.bottom=1,boundingRect.ok=!0,remove&&editor.selection.restore()}else range&&(boundingRect=range.getBoundingClientRect());return boundingRect}function _topNormalized($el,top,obj_height){var height=$el.outerHeight();if(!editor.helpers.isMobile()&&editor.$tb&&$el.parent().get(0)!=editor.$tb.get(0)){var p_offset=($el.parent().height()-20-(editor.opts.toolbarBottom?editor.$tb.outerHeight():0),$el.parent().offset().top),new_top=top-height-(obj_height||0);$el.parent().get(0)==$(editor.opts.scrollableContainer).get(0)&&(p_offset-=$el.parent().position().top),p_offset+top+height>$(editor.original_document).outerHeight()&&$el.parent().offset().top+new_top>0?(top=new_top,$el.addClass("fr-above")):$el.removeClass("fr-above")}return top}function _leftNormalized($el,left){var width=$el.outerWidth();return $el.parent().offset().left+left+width>$(editor.opts.scrollableContainer).width()-10&&(left=$(editor.opts.scrollableContainer).width()-width-10-$el.parent().offset().left+$(editor.opts.scrollableContainer).offset().left),$el.parent().offset().left+left<$(editor.opts.scrollableContainer).offset().left&&(left=10-$el.parent().offset().left+$(editor.opts.scrollableContainer).offset().left),left}function forSelection($el){var selection_rect=getBoundingRect();$el.css("top",0).css("left",0);var top=selection_rect.top+selection_rect.height,left=selection_rect.left+selection_rect.width/2-$el.outerWidth()/2+$(editor.original_window).scrollLeft();editor.opts.iframe||(top+=$(editor.original_window).scrollTop()),at(left,top,$el,selection_rect.height)}function at(left,top,$el,obj_height){var $container=$el.data("container");$container&&"BODY"!=$container.get(0).tagName&&(left&&(left-=$container.offset().left),top&&(top-=$container.offset().top-$container.scrollTop())),editor.opts.iframe&&$container&&editor.$tb&&$container.get(0)!=editor.$tb.get(0)&&(left&&(left+=editor.$iframe.offset().left),top&&(top+=editor.$iframe.offset().top));var new_left=_leftNormalized($el,left);if(left){$el.css("left",new_left);var $arrow=$el.find(".fr-arrow");$arrow.data("margin-left")||$arrow.data("margin-left",editor.helpers.getPX($arrow.css("margin-left"))),$arrow.css("margin-left",left-new_left+$arrow.data("margin-left"))}top&&$el.css("top",_topNormalized($el,top,obj_height))}function _updateIOSSticky(el){var $el=$(el),$parent=$el.parent(),is_on=$el.is(".fr-sticky-on"),prev_top=$el.data("sticky-top"),scheduled_top=$el.data("sticky-scheduled");if("undefined"==typeof prev_top&&($el.data("sticky-top",0),$el.after('<div class="fr-sticky-dummy" style="height: '+$el.outerHeight()+'px;"></div>'),$el.data("sticky-dummy",$el.next())),editor.core.hasFocus()||editor.$tb.find("input:visible:focus").length>0){var x_scroll=$(window).scrollTop(),x_top=Math.min(Math.max(x_scroll-$parent.offset().top,0),$parent.outerHeight()-$el.outerHeight());x_top!=prev_top&&x_top!=scheduled_top&&(clearTimeout($el.data("sticky-timeout")),$el.data("sticky-scheduled",x_top),$el.outerHeight()<x_scroll-$parent.offset().top&&$el.addClass("fr-opacity-0"),$el.data("sticky-timeout",setTimeout(function(){var c_scroll=$(window).scrollTop(),c_top=Math.min(Math.max(c_scroll-$parent.offset().top,0),$parent.outerHeight()-$el.outerHeight());c_top>0&&"BODY"==$parent.get(0).tagName&&(c_top+=$parent.position().top),c_top!=prev_top&&($el.css("top",Math.max(c_top,0)),$el.data("sticky-top",c_top),$el.data("sticky-scheduled",c_top)),$el.removeClass("fr-opacity-0"),editor.$tb.hasClass("fr-inline")&&editor.toolbar.show()},100))),is_on||($el.css("top",""),$el.width($parent.width()),$el.addClass("fr-sticky-on"))}else clearTimeout($(el).css("sticky-timeout")),$el.css("top",""),$el.css("position",""),$el.width(""),$el.data("sticky-top",0),$el.removeClass("fr-sticky-on"),editor.$tb.hasClass("fr-inline")&&editor.toolbar.hide()}function _updateSticky(el){if(el.offsetWidth){var el_top,el_bottom,$el=$(el),height=$el.outerHeight(),position=$el.data("sticky-position"),viewport_height=$("body"==editor.opts.scrollableContainer?editor.original_window:editor.opts.scrollableContainer).outerHeight(),scrollable_top=0,scrollable_bottom=0;"body"!==editor.opts.scrollableContainer&&(scrollable_top=$(editor.opts.scrollableContainer).offset().top,scrollable_bottom=$(editor.original_window).outerHeight()-scrollable_top-viewport_height);var offset_top="body"==editor.opts.scrollableContainer?$(editor.original_window).scrollTop():scrollable_top,is_on=$el.is(".fr-sticky-on");$el.data("sticky-parent")||$el.data("sticky-parent",$el.parent());var $parent=$el.data("sticky-parent"),parent_top=$parent.offset().top,parent_height=$parent.outerHeight();if($el.data("sticky-offset")||($el.data("sticky-offset",!0),$el.after('<div class="fr-sticky-dummy" style="height: '+height+'px;"></div>')),!position){var skip_setting_fixed="auto"!==$el.css("top")||"auto"!==$el.css("bottom");skip_setting_fixed||$el.css("position","fixed"),position={top:"auto"!==$el.css("top"),bottom:"auto"!==$el.css("bottom")},skip_setting_fixed||$el.css("position",""),$el.data("sticky-position",position),$el.data("top",$el.css("top")),$el.data("bottom",$el.css("bottom"))}var isFixedToTop=function(){return offset_top+el_top>parent_top&&parent_top+parent_height-height>=offset_top+el_top},isFixedToBottom=function(){return offset_top+viewport_height-el_bottom>parent_top+height&&parent_top+parent_height>offset_top+viewport_height-el_bottom};el_top=editor.helpers.getPX($el.data("top")),el_bottom=editor.helpers.getPX($el.data("bottom"));var at_top=position.top&&isFixedToTop(),at_bottom=position.bottom&&isFixedToBottom();at_top||at_bottom?($el.css("width",$parent.width()+"px"),is_on||($el.addClass("fr-sticky-on"),$el.removeClass("fr-sticky-off"),$el.css("top")&&("auto"!=$el.data("top")?$el.css("top",editor.helpers.getPX($el.data("top"))+scrollable_top):$el.data("top","auto")),$el.css("bottom")&&("auto"!=$el.data("bottom")?$el.css("bottom",editor.helpers.getPX($el.data("bottom"))+scrollable_bottom):$el.css("bottom","auto")))):$el.hasClass("fr-sticky-off")||($el.width(""),$el.removeClass("fr-sticky-on"),$el.addClass("fr-sticky-off"),$el.css("top")&&"auto"!=$el.css("top")&&$el.css("top",0),$el.css("bottom")&&$el.css("bottom",0))}}function _testSticky(){var el=document.createElement("test"),mStyle=el.style;return mStyle.cssText="position:"+["-webkit-","-moz-","-ms-","-o-",""].join("sticky; position:")+" sticky;",-1!==mStyle.position.indexOf("sticky")&&!editor.helpers.isIOS()&&!editor.helpers.isAndroid()}function _initSticky(){if(!_testSticky())if(editor._stickyElements=[],editor.helpers.isIOS()){var animate=function(){editor.helpers.requestAnimationFrame()(animate);for(var i=0;i<editor._stickyElements.length;i++)_updateIOSSticky(editor._stickyElements[i])};animate(),$(editor.original_window).on("scroll.sticky"+editor.id,function(){if(editor.core.hasFocus())for(var i=0;i<editor._stickyElements.length;i++){var $el=$(editor._stickyElements[i]),$parent=$el.parent(),c_scroll=$(window).scrollTop();$el.outerHeight()<c_scroll-$parent.offset().top&&($el.addClass("fr-opacity-0"),$el.data("sticky-top",-1),$el.data("sticky-scheduled",-1))}})}else $("body"==editor.opts.scrollableContainer?editor.original_window:editor.opts.scrollableContainer).on("scroll.sticky"+editor.id,refresh),$(editor.original_window).on("resize.sticky"+editor.id,refresh),editor.events.on("initialized",refresh),editor.events.on("focus",refresh),$(editor.original_window).on("resize","textarea",refresh)}function refresh(){for(var i=0;i<editor._stickyElements.length;i++)_updateSticky(editor._stickyElements[i])}function addSticky($el){$el.addClass("fr-sticky"),editor.helpers.isIOS()&&$el.addClass("fr-sticky-ios"),_testSticky()||editor._stickyElements.push($el.get(0))}function _destroy(){$(editor.original_window).off("scroll.sticky"+editor.id),$(editor.original_window).off("resize.sticky"+editor.id)}function _init(){_initSticky(),editor.events.on("destroy",_destroy,!0)}return{_init:_init,forSelection:forSelection,addSticky:addSticky,refresh:refresh,at:at,getBoundingRect:getBoundingRect}},$.extend($.FroalaEditor.DEFAULTS,{toolbarInline:!1,toolbarVisibleWithoutSelection:!0,toolbarSticky:!0,toolbarButtons:["fullscreen","bold","italic","underline","strikeThrough","subscript","superscript","fontFamily","fontSize","|","color","emoticons","inlineStyle","paragraphStyle","|","paragraphFormat","align","formatOL","formatUL","outdent","indent","quote","insertHR","-","insertLink","insertImage","insertVideo","insertFile","insertTable","undo","redo","clearFormatting","selectAll","html"],toolbarButtonsXS:["bold","italic","fontFamily","fontSize","|","undo","redo"],toolbarButtonsSM:["bold","italic","underline","|","fontFamily","fontSize","insertLink","insertImage","table","|","undo","redo"],toolbarButtonsMD:["fullscreen","bold","italic","underline","fontFamily","fontSize","color","paragraphStyle","paragraphFormat","align","formatOL","formatUL","outdent","indent","quote","insertHR","-","insertLink","insertImage","insertVideo","insertFile","insertTable","undo","redo","clearFormatting"],toolbarStickyOffset:0}),$.FroalaEditor.MODULES.toolbar=function(editor){function _addOtherButtons(buttons,toolbarButtons){for(var i=0;i<toolbarButtons.length;i++)"-"!=toolbarButtons[i]&&"|"!=toolbarButtons[i]&&buttons.indexOf(toolbarButtons[i])<0&&buttons.push(toolbarButtons[i])}function _addButtons(){var _buttons=$.merge([],_screenButtons());_addOtherButtons(_buttons,editor.opts.toolbarButtonsXS||[]),_addOtherButtons(_buttons,editor.opts.toolbarButtonsSM||[]),_addOtherButtons(_buttons,editor.opts.toolbarButtonsMD||[]),_addOtherButtons(_buttons,editor.opts.toolbarButtons);for(var i=_buttons.length-1;i>=0;i--)"-"!=_buttons[i]&&"|"!=_buttons[i]&&_buttons.indexOf(_buttons[i])<i&&_buttons.splice(i,1);var buttons_list=editor.button.buildList(_buttons,_screenButtons());editor.$tb.append(buttons_list),editor.button.bindCommands(editor.$tb)}function _screenButtons(){var screen_size=editor.helpers.screenSize();return _buttons_map[screen_size]}function _showScreenButtons(){var c_buttons=_screenButtons();editor.$tb.find(".fr-separator").remove(),editor.$tb.find("> .fr-command").addClass("fr-hidden");for(var i=0;i<c_buttons.length;i++)if("|"==c_buttons[i]||"-"==c_buttons[i])editor.$tb.append(editor.button.buildList([c_buttons[i]]));else{var $btn=editor.$tb.find('> .fr-command[data-cmd="'+c_buttons[i]+'"]'),$dropdown=null;$btn.next().hasClass("fr-dropdown-menu")&&($dropdown=$btn.next()),$btn.removeClass("fr-hidden").appendTo(editor.$tb),$dropdown&&$dropdown.appendTo(editor.$tb)}}function _setVisibility(){$(editor.original_window).on("resize.buttons."+editor.id,_showScreenButtons),$(editor.original_window).on("orientationchange.buttons."+editor.id,_showScreenButtons)}function showInline(e,force){editor.helpers.isMobile()?editor.toolbar.show():setTimeout(function(){if(e&&e.which==$.FroalaEditor.KEYCODE.ESC);else if(editor.selection.inEditor()&&editor.core.hasFocus()&&!editor.popups.areVisible()&&(editor.opts.toolbarVisibleWithoutSelection&&e&&"keyup"!=e.type||!editor.selection.isCollapsed()&&!editor.keys.isIME()||force)){if(0==editor.events.trigger("toolbar.show"))return!1;editor.helpers.isMobile()||editor.position.forSelection(editor.$tb),editor.$tb.show()}},0)}function hide(){return 0==editor.events.trigger("toolbar.hide")?!1:void editor.$tb.hide()}function show(){return 0==editor.events.trigger("toolbar.show")?!1:void editor.$tb.show()}function _initInlineBehavior(){editor.events.on("window.mousedown",hide),editor.events.on("keydown",hide),editor.events.on("blur",hide),editor.events.on("window.mouseup",showInline),editor.events.on("window.keyup",showInline),editor.events.on("keydown",function(e){e&&e.which==$.FroalaEditor.KEYCODE.ESC&&hide()}),editor.$wp.on("scroll.toolbar",showInline),editor.events.on("commands.after",showInline)}function _initInlineMobileBehavior(){editor.events.on("focus",showInline,!0),editor.events.on("blur",hide,!0)}function _initPositioning(){editor.opts.toolbarInline?(editor.$box.addClass("fr-inline"),editor.helpers.isMobile()?(editor.helpers.isIOS()?($("body").append(editor.$tb),editor.position.addSticky(editor.$tb)):(editor.$tb.addClass("fr-bottom"),editor.$box.append(editor.$tb),editor.position.addSticky(editor.$tb),editor.opts.toolbarBottom=!0),editor.$tb.addClass("fr-inline"),_initInlineMobileBehavior(),editor.opts.toolbarInline=!1):($(editor.opts.scrollableContainer).append(editor.$tb),editor.$tb.data("container",$(editor.opts.scrollableContainer)),editor.$tb.addClass("fr-inline"),editor.$tb.prepend('<span class="fr-arrow"></span>'),_initInlineBehavior(),editor.opts.toolbarBottom=!1)):(editor.opts.toolbarBottom&&!editor.helpers.isIOS()?(editor.$box.append(editor.$tb),editor.$tb.addClass("fr-bottom"),editor.$box.addClass("fr-bottom")):(editor.opts.toolbarBottom=!1,editor.$box.prepend(editor.$tb),editor.$tb.addClass("fr-top"),editor.$box.addClass("fr-top")),editor.$box.addClass("fr-basic"),editor.$tb.addClass("fr-basic"),editor.opts.toolbarSticky&&(editor.opts.toolbarStickyOffset&&(editor.opts.toolbarBottom?editor.$tb.css("bottom",editor.opts.toolbarStickyOffset):editor.$tb.css("top",editor.opts.toolbarStickyOffset)),editor.position.addSticky(editor.$tb)))}function _destroy(){$(editor.original_window).off("resize.buttons."+editor.id),$(editor.original_window).off("orientationchange.buttons."+editor.id),editor.$box.removeClass("fr-top fr-bottom fr-inline fr-basic"),editor.$box.find(".fr-sticky-dummy").remove(),editor.$tb.off(editor._mousedown+" "+editor._mouseup),editor.$tb.html("").removeData().remove()}function _init(){return editor.$wp?(editor.$tb=$('<div class="fr-toolbar"></div>'),editor.opts.theme&&editor.$tb.addClass(editor.opts.theme+"-theme"),editor.opts.zIndex>1&&editor.$tb.css("z-index",editor.opts.zIndex+1),"auto"!=editor.opts.direction&&editor.$tb.removeClass("fr-ltr fr-rtl").addClass("fr-"+editor.opts.direction),editor.helpers.isMobile()?editor.$tb.addClass("fr-mobile"):editor.$tb.addClass("fr-desktop"),_initPositioning(),_document=editor.$tb.get(0).ownerDocument,_window="defaultView"in _document?_document.defaultView:_document.parentWindow,_addButtons(),_setVisibility(),editor.$tb.on(editor._mousedown+" "+editor._mouseup,function(e){var originalTarget=e.originalEvent?e.originalEvent.target||e.originalEvent.originalTarget:null;return originalTarget&&"INPUT"!=originalTarget.tagName?(e.stopPropagation(),e.preventDefault(),!1):void 0}),void editor.events.on("destroy",_destroy,!0)):!1}function disable(){!disabled&&editor.$tb&&(editor.$tb.find("> .fr-command").addClass("fr-disabled fr-no-refresh"),disabled=!0)}function enable(){disabled&&editor.$tb&&(editor.$tb.find("> .fr-command").removeClass("fr-disabled fr-no-refresh"),disabled=!1),editor.button.bulkRefresh()}var _document,_window,_buttons_map=[];_buttons_map[$.FroalaEditor.XS]=editor.opts.toolbarButtonsXS||editor.opts.toolbarButtons,_buttons_map[$.FroalaEditor.SM]=editor.opts.toolbarButtonsSM||editor.opts.toolbarButtons,_buttons_map[$.FroalaEditor.MD]=editor.opts.toolbarButtonsMD||editor.opts.toolbarButtons,_buttons_map[$.FroalaEditor.LG]=editor.opts.toolbarButtons;var disabled=!1;return{_init:_init,hide:hide,show:show,showInline:showInline,disable:disable,enable:enable}},$.FroalaEditor.SHORTCUTS_MAP={69:{cmd:"show"},66:{cmd:"bold"},73:{cmd:"italic"},85:{cmd:"underline"},83:{cmd:"strikeThrough"},221:{cmd:"indent"},219:{cmd:"outdent"},90:{cmd:"undo"},"-90":{cmd:"redo"}},$.extend($.FroalaEditor.DEFAULTS,{shortcutsEnabled:["show","bold","italic","underline","strikeThrough","indent","outdent","undo","redo"]}),$.FroalaEditor.RegisterShortcut=function(key,cmd,val,shift){$.FroalaEditor.SHORTCUTS_MAP[key*(shift?-1:1)]={cmd:cmd,val:val},$.FroalaEditor.DEFAULTS.shortcutsEnabled.push(cmd)},$.FroalaEditor.MODULES.shortcuts=function(editor){function exec(e){var keycode=e.which;if(editor.keys.ctrlKey(e)&&(e.shiftKey&&$.FroalaEditor.SHORTCUTS_MAP[-keycode]||!e.shiftKey&&$.FroalaEditor.SHORTCUTS_MAP[keycode])){var cmd=$.FroalaEditor.SHORTCUTS_MAP[keycode*(e.shiftKey?-1:1)].cmd;if(cmd&&editor.opts.shortcutsEnabled.indexOf(cmd)>=0){var $btn,val=$.FroalaEditor.SHORTCUTS_MAP[keycode*(e.shiftKey?-1:1)].val;if(cmd&&!val?$btn=editor.$tb.find('.fr-command[data-cmd="'+cmd+'"]'):cmd&&val&&($btn=editor.$tb.find('.fr-command[data-cmd="'+cmd+'"][data-param0="'+val+'"]')),$btn.length)return e.preventDefault(),e.stopPropagation(),"keydown"==e.type&&editor.button.exec($btn),!1;if(cmd&&editor.commands[cmd])return e.preventDefault(),e.stopPropagation(),"keydown"==e.type&&editor.commands[cmd](),!1}}}function _init(){editor.events.on("keydown",exec,!0),editor.events.on("keyup",exec,!0)}return{_init:_init}},$.FroalaEditor.MODULES.snapshot=function(editor){function _getNodeIndex(node){for(var childNodes=node.parentNode.childNodes,idx=0,prevNode=null,i=0;i<childNodes.length;i++){if(prevNode){var isEmptyText=childNodes[i].nodeType===Node.TEXT_NODE&&""===childNodes[i].textContent,twoTexts=prevNode.nodeType===Node.TEXT_NODE&&childNodes[i].nodeType===Node.TEXT_NODE;isEmptyText||twoTexts||idx++}if(childNodes[i]==node)return idx;prevNode=childNodes[i]}}function _getNodeLocation(node){var loc=[];if(!node.parentNode)return[];for(;!editor.node.isElement(node);)loc.push(_getNodeIndex(node)),node=node.parentNode;return loc.reverse()}function _getRealNodeOffset(node,offset){for(;node&&node.nodeType===Node.TEXT_NODE;){var prevNode=node.previousSibling;prevNode&&prevNode.nodeType==Node.TEXT_NODE&&(offset+=prevNode.textContent.length),node=prevNode}return offset}function _getRange(range){return{scLoc:_getNodeLocation(range.startContainer),scOffset:_getRealNodeOffset(range.startContainer,range.startOffset),ecLoc:_getNodeLocation(range.endContainer),ecOffset:_getRealNodeOffset(range.endContainer,range.endOffset)}}function get(){var snapshot={};if(editor.events.trigger("snapshot.before"),snapshot.html=editor.$el.html(),snapshot.ranges=[],editor.selection.inEditor()&&editor.core.hasFocus())for(var ranges=editor.selection.ranges(),i=0;i<ranges.length;i++)snapshot.ranges.push(_getRange(ranges[i]));return editor.events.trigger("snapshot.after"),snapshot}function _getNodeByLocation(loc){for(var node=editor.$el.get(0),i=0;i<loc.length;i++)node=node.childNodes[loc[i]];return node}function _restoreRange(sel,range_snapshot){try{var startNode=_getNodeByLocation(range_snapshot.scLoc),startOffset=range_snapshot.scOffset,endNode=_getNodeByLocation(range_snapshot.ecLoc),endOffset=range_snapshot.ecOffset,range=editor.document.createRange();range.setStart(startNode,startOffset),range.setEnd(endNode,endOffset),sel.addRange(range)}catch(ex){console.warn(ex)}}function restore(snapshot){editor.$el.html()!=snapshot.html&&editor.$el.html(snapshot.html);var sel=editor.selection.get();editor.selection.clear(),editor.events.focus(!0);for(var i=0;i<snapshot.ranges.length;i++)_restoreRange(sel,snapshot.ranges[i])}function equal(s1,s2){return s1.html!=s2.html?!1:JSON.stringify(s1.ranges)!=JSON.stringify(s2.ranges)?!1:!0}return{get:get,restore:restore,equal:equal}},$.FroalaEditor.MODULES.undo=function(editor){function _disableBrowserUndo(e){var keyCode=e.which,ctrlKey=editor.keys.ctrlKey(e);ctrlKey&&(90==keyCode&&e.shiftKey&&e.preventDefault(),90==keyCode&&e.preventDefault())}function canDo(){return 0===editor.undo_stack.length||editor.undo_index<=1?!1:!0}function canRedo(){return editor.undo_index==editor.undo_stack.length?!1:!0}function saveStep(snapshot){if(!editor.undo_stack||editor.undoing)return!1;for(;editor.undo_stack.length>editor.undo_index;)editor.undo_stack.pop();"undefined"==typeof snapshot?(snapshot=editor.snapshot.get(),editor.undo_stack[editor.undo_index-1]&&editor.snapshot.equal(editor.undo_stack[editor.undo_index-1],snapshot)||(editor.undo_stack.push(snapshot),editor.undo_index++,snapshot.html!=last_html&&(editor.events.trigger("contentChanged"),last_html=snapshot.html))):editor.undo_index>0?editor.undo_stack[editor.undo_index-1]=snapshot:(editor.undo_stack.push(snapshot),editor.undo_index++)}function _do(){if(editor.undo_index>1){editor.undoing=!0;var snapshot=editor.undo_stack[--editor.undo_index-1];clearTimeout(editor._content_changed_timer),editor.snapshot.restore(snapshot),editor.popups.hideAll(),editor.toolbar.enable(),editor.events.trigger("contentChanged"),editor.events.trigger("commands.undo"),editor.undoing=!1}}function _redo(){if(editor.undo_index<editor.undo_stack.length){editor.undoing=!0;var snapshot=editor.undo_stack[editor.undo_index++];clearTimeout(editor._content_changed_timer),editor.snapshot.restore(snapshot),editor.popups.hideAll(),editor.toolbar.enable(),editor.events.trigger("contentChanged"),editor.events.trigger("commands.redo"),editor.undoing=!1}}function reset(){editor.undo_index=0,editor.undo_stack=[]}function _init(){reset(),editor.events.on("initialized",function(){last_html=editor.html.get(!1,!0)}),editor.events.on("keydown",_disableBrowserUndo)}var last_html=null;return{_init:_init,run:_do,redo:_redo,canDo:canDo,canRedo:canRedo,reset:reset,saveStep:saveStep}},$.FroalaEditor.POPUP_TEMPLATES={"text.edit":"[_EDIT_]"},$.FroalaEditor.RegisterTemplate=function(name,template){$.FroalaEditor.POPUP_TEMPLATES[name]=template},$.FroalaEditor.MODULES.popups=function(editor){function setContainer(id,$container){popups[id].data("container",$container),$container.append(popups[id])}function show(id,left,top,obj_height){if(areVisible()&&editor.$el.find(".fr-marker").length>0&&(editor.events.disableBlur(),editor.selection.restore()),hideAll([id]),!popups[id])return!1;var width=popups[id].outerWidth(),is_visible=(popups[id].outerHeight(),isVisible(id));popups[id].addClass("fr-active").find("input, textarea").removeAttr("disabled");var $container=popups[id].data("container");editor.opts.toolbarInline&&$container&&editor.$tb&&$container.get(0)==editor.$tb.get(0)&&(setContainer(id,editor.opts.toolbarInline?$(editor.opts.scrollableContainer):editor.$box),top&&(top=editor.$tb.offset().top-editor.helpers.getPX(editor.$tb.css("margin-top"))),
|
||
left&&(left=editor.$tb.offset().left+editor.$tb.width()/2),editor.$tb.hasClass("fr-above")&&(top+=editor.$tb.outerHeight()),obj_height=0),$container=popups[id].data("container"),!editor.opts.iframe||obj_height||is_visible||(left&&(left-=editor.$iframe.offset().left),top&&(top-=editor.$iframe.offset().top)),left&&(left-=width/2),editor.opts.toolbarBottom&&$container&&editor.$tb&&$container.get(0)==editor.$tb.get(0)&&(popups[id].addClass("fr-above"),top-=popups[id].outerHeight()),editor.position.at(left,top,popups[id],obj_height||0);var active_popup=popups[id].find("input:visible, textarea:visible").get(0);active_popup&&(0==editor.$el.find(".fr-marker").length&&editor.core.hasFocus()&&editor.selection.save(),editor.events.disableBlur(),$(active_popup).select().focus()),editor.opts.toolbarInline&&!editor.helpers.isMobile()&&editor.toolbar.hide(),editor.events.trigger("popups.show."+id)}function onShow(id,callback){editor.events.on("popups.show."+id,callback)}function isVisible(id){return popups[id]&&popups[id].hasClass("fr-active")||!1}function areVisible(){for(var id in popups)if(isVisible(id))return!0;return!1}function hide(id){popups[id]&&popups[id].hasClass("fr-active")&&(popups[id].removeClass("fr-active fr-above"),editor.events.trigger("popups.hide."+id),editor.events.disableBlur(),popups[id].find("input, textarea, button").filter(":focus").blur(),popups[id].find("input, textarea").attr("disabled","disabled"))}function onHide(id,callback){editor.events.on("popups.hide."+id,callback)}function get(id){return popups[id]}function onRefresh(id,callback){editor.events.on("popups.refresh."+id,callback)}function refresh(id){editor.events.trigger("popups.refresh."+id);for(var btns=popups[id].find(".fr-command"),i=0;i<btns.length;i++){var $btn=$(btns[i]);0==$btn.parents(".fr-dropdown-menu").length&&editor.button.refresh($btn)}}function hideAll(except){"undefined"==typeof except&&(except=[]);for(var id in popups)except.indexOf(id)<0&&hide(id)}function _markExit(){exit_flag=!0}function _unmarkExit(){exit_flag=!1}function _buildTemplate(id,template){var html=$.FroalaEditor.POPUP_TEMPLATES[id];"function"==typeof html&&(html=html.apply(editor));for(var nm in template)html=html.replace("[_"+nm.toUpperCase()+"_]",template[nm]);return html}function create(id,template){var html=_buildTemplate(id,template),$popup=$('<div class="fr-popup'+(editor.helpers.isMobile()?" fr-mobile":" fr-desktop")+(editor.opts.toolbarInline?" fr-inline":"")+'"><span class="fr-arrow"></span>'+html+"</div>");editor.opts.theme&&$popup.addClass(editor.opts.theme+"-theme"),editor.opts.zIndex>1&&editor.$tb.css("z-index",editor.opts.zIndex+2),"auto"!=editor.opts.direction&&$popup.removeClass("fr-ltr fr-rtl").addClass("fr-"+editor.opts.direction),$popup.find("input, textarea").attr("dir",editor.opts.direction).attr("disabled","disabled");var $container=$("body");return $container.append($popup),$popup.data("container",$container),popups[id]=$popup,editor.button.bindCommands($popup,!1),$(editor.original_window).on("resize.popups"+editor.id,function(){editor.helpers.isMobile()||(editor.events.disableBlur(),hide(id),editor.events.enableBlur())}),$popup.on(editor._mousedown+" "+editor._mouseup,function(e){var originalTarget=e.originalEvent?e.originalEvent.target||e.originalEvent.originalTarget:null;return originalTarget&&"INPUT"!=originalTarget.tagName?(e.preventDefault(),e.stopPropagation(),!1):void e.stopPropagation()}),$popup.on("focus","input, textarea, button, select",function(e){if(e.preventDefault(),e.stopPropagation(),setTimeout(function(){editor.events.enableBlur()},0),editor.helpers.isMobile()){var t=$(editor.original_window).scrollTop();setTimeout(function(){$(editor.original_window).scrollTop(t)},0)}}),$popup.on("keydown","input, textarea, button, select",function(e){var key_code=e.which;if($.FroalaEditor.KEYCODE.TAB==key_code){e.preventDefault();var inputs=$popup.find("input, textarea, button, select").filter(":visible").not(":disabled").toArray();inputs.sort(function(a,b){return e.shiftKey?$(a).attr("tabIndex")<$(b).attr("tabIndex"):$(a).attr("tabIndex")>$(b).attr("tabIndex")}),editor.events.disableBlur();var idx=inputs.indexOf(this)+1;idx==inputs.length&&(idx=0),$(inputs[idx]).focus()}if($.FroalaEditor.KEYCODE.ENTER==key_code)$popup.find(".fr-submit:visible").length>0&&(e.preventDefault(),e.stopPropagation(),editor.events.disableBlur(),editor.button.exec($popup.find(".fr-submit:visible:first")));else{if($.FroalaEditor.KEYCODE.ESC==key_code)return e.preventDefault(),e.stopPropagation(),editor.$el.find(".fr-marker")&&(editor.events.disableBlur(),$(this).data("skip",!0),editor.selection.restore(),editor.events.enableBlur()),isVisible(id)&&$popup.find(".fr-back:visible").length?editor.button.exec($popup.find(".fr-back:visible:first")):hide(id),editor.opts.toolbarInline&&editor.toolbar.showInline(null,!0),!1;e.stopPropagation()}}),editor.events.on("window.keydown",function(e){var key_code=e.which;if($.FroalaEditor.KEYCODE.ESC==key_code){if(isVisible(id)&&editor.opts.toolbarInline)return e.stopPropagation(),isVisible(id)&&$popup.find(".fr-back:visible").length?editor.button.exec($popup.find(".fr-back:visible:first")):(hide(id),editor.toolbar.showInline(null,!0)),!1;isVisible(id)&&$popup.find(".fr-back:visible").length?editor.button.exec($popup.find(".fr-back:visible:first")):hide(id)}}),editor.$wp&&(editor.events.on("keydown",function(e){editor.keys.ctrlKey(e)||e.which==$.FroalaEditor.KEYCODE.ESC||(isVisible(id)&&$popup.find(".fr-back:visible").length?editor.button.exec($popup.find(".fr-back:visible:first")):hide(id))}),$popup.on("blur","input, textarea, button, select",function(e){document.activeElement!=this&&$(this).is(":visible")&&(editor.events.blurActive()&&editor.events.trigger("blur"),editor.events.enableBlur())})),$popup.on("mousedown touchstart touch","*",function(e){["INPUT","TEXTAREA","BUTTON","SELECT","LABEL"].indexOf(e.currentTarget.tagName)>=0&&e.stopPropagation(),editor.events.disableBlur()}),editor.events.on("mouseup",function(e){$popup.is(":visible")&&exit_flag&&$popup.find("input:focus, textarea:focus, button:focus, select:focus").filter(":visible").length>0&&editor.events.disableBlur()},!0),editor.events.on("window.mouseup",function(e){$popup.is(":visible")&&exit_flag&&(e.stopPropagation(),editor.markers.remove(),hide(id))},!0),editor.events.on("blur",function(e){hideAll()}),$popup.on("keydown keyup change input","input, textarea",function(e){var $span=$(this).next();0==$span.length&&$(this).after("<span>"+$(this).attr("placeholder")+"</span>"),$(this).toggleClass("fr-not-empty",""!=$(this).val())}),editor.$wp&&!editor.helpers.isMobile()&&editor.$wp.on("scroll.popup"+id,function(e){if(isVisible(id)&&$popup.parent().get(0)==$(editor.opts.scrollableContainer).get(0)){var p_top=$popup.offset().top-editor.$wp.offset().top,w_height=(editor.$wp.scrollTop(),editor.$wp.outerHeight());p_top>w_height||0>p_top?$popup.addClass("fr-hidden"):$popup.removeClass("fr-hidden")}}),editor.helpers.isIOS()&&$popup.on("touchend","label",function(){$("#"+$(this).attr("for")).prop("checked",function(i,val){return!val})}),$popup}function _destroy(){for(var id in popups){var $popup=popups[id];$popup.off("mousedown mouseup touchstart touchend"),$popup.off("focus","input, textarea, button, select"),$popup.off("keydown","input, textarea, button, select"),$popup.off("blur","input, textarea, button, select"),$popup.off("keydown keyup change","input, textarea"),$popup.off(editor._mousedown,"*"),$popup.html("").removeData().remove(),$(editor.original_window).off("resize.popups"+editor.id),editor.$wp&&editor.$wp.off("scroll.popup"+id)}}function _init(){editor.events.on("destroy",_destroy,!0),editor.events.on("window.mousedown",_markExit),editor.events.on("window.touchmove",_unmarkExit),editor.events.on("mousedown",function(e){areVisible()&&editor.$el.find(".fr-marker").remove()}),editor.events.on("window.mouseup",function(){exit_flag=!1})}var popups={},exit_flag=!1;return{_init:_init,create:create,get:get,show:show,hide:hide,onHide:onHide,hideAll:hideAll,setContainer:setContainer,refresh:refresh,onRefresh:onRefresh,onShow:onShow,isVisible:isVisible,areVisible:areVisible}},$.FroalaEditor.MODULES.refresh=function(editor){function _default($btn,cmd){try{editor.document.queryCommandState(cmd)===!0&&$btn.addClass("fr-active")}catch(ex){}}function undo($btn){$btn.toggleClass("fr-disabled",!editor.undo.canDo())}function redo($btn){$btn.toggleClass("fr-disabled",!editor.undo.canRedo())}function indent($btn){if($btn.hasClass("fr-no-refresh"))return!1;for(var blocks=editor.selection.blocks(),i=0;i<blocks.length;i++){if("LI"!=blocks[i].tagName||blocks[i].previousSibling)return $btn.removeClass("fr-disabled"),!0;$btn.addClass("fr-disabled")}}function outdent($btn){if($btn.hasClass("fr-no-refresh"))return!1;for(var blocks=editor.selection.blocks(),i=0;i<blocks.length;i++){var prop="rtl"==editor.opts.direction||"rtl"==$(blocks[i]).css("direction")?"margin-right":"margin-left";if("LI"==blocks[i].tagName||"LI"==blocks[i].parentNode.tagName)return $btn.removeClass("fr-disabled"),!0;if(editor.helpers.getPX($(blocks[i]).css(prop))>0)return $btn.removeClass("fr-disabled"),!0}$btn.addClass("fr-disabled")}return{"default":_default,undo:undo,redo:redo,outdent:outdent,indent:indent}},$.extend($.FroalaEditor.DEFAULTS,{editInPopup:!1}),$.FroalaEditor.MODULES.textEdit=function(editor){function _initPopup(){var txt='<div id="fr-text-edit-'+editor.id+'" class="fr-layer fr-text-edit-layer"><div class="fr-input-line"><input type="text" placeholder="'+editor.language.translate("Text")+'" tabIndex="1"></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="updateText" tabIndex="2">'+editor.language.translate("Update")+"</button></div></div>",template={edit:txt};editor.popups.create("text.edit",template)}function _showPopup(){var $popup=editor.popups.get("text.edit");$popup.find("input").val(editor.$el.text()).trigger("change"),editor.popups.setContainer("text.edit",$("body")),editor.popups.show("text.edit",editor.$el.offset().left+editor.$el.outerWidth()/2,editor.$el.offset().top+editor.$el.outerHeight(),editor.$el.outerHeight())}function _initEvents(){editor.$el.on(editor._mouseup,function(e){setTimeout(function(){_showPopup()},10)})}function update(){var $popup=editor.popups.get("text.edit");editor.$el.text($popup.find("input").val()),editor.events.trigger("contentChanged"),editor.popups.hide("text.edit")}function _init(){editor.opts.editInPopup&&(_initPopup(),_initEvents())}return{_init:_init,update:update}},$.FroalaEditor.RegisterCommand("updateText",{focus:!1,undo:!1,callback:function(){this.textEdit.update()}}),$.FroalaEditor.DEFAULTS.key="4Wa1WDPTf1ZNRGb1OG1g1==",$.FroalaEditor.ICON_DEFAULT_TEMPLATE="material_design",$.FroalaEditor.DefineIconTemplate("material_design",'<i class="material-icons">[NAME]</i>')}),function(factory){"function"==typeof define&&define.amd?define(["jquery"],factory):"object"==typeof module&&module.exports?module.exports=function(root,jQuery){return void 0===jQuery&&(jQuery="undefined"!=typeof window?require("jquery"):require("jquery")(root)),factory(jQuery),jQuery}:factory(jQuery)}(function($){"use strict";$.extend($.FroalaEditor.POPUP_TEMPLATES,{"table.insert":"[_BUTTONS_][_ROWS_COLUMNS_]","table.edit":"[_BUTTONS_]","table.colors":"[_BUTTONS_][_COLORS_]","table.colors.text":"[_BUTTONS_][_COLORS_]"}),$.extend($.FroalaEditor.DEFAULTS,{tableInsertMaxSize:10,tableEditButtons:["tableHeader","|","tableRows","tableColumns","|","tableCells","tableCellForeground","tableCellBackground","|","tableCellVerticalAlign","tableCellHorizontalAlign","|","tableStyle"],tableInsertButtons:["tableBack","|"],tableResizerOffset:5,tableResizingLimit:30,tableColorsButtons:["tableBack","|"],tableColors:["#61BD6D","#1ABC9C","#54ACD2","#2C82C9","#9365B8","#475577","#CCCCCC","#41A85F","#00A885","#3D8EB9","#2969B0","#553982","#28324E","#000000","#F7DA64","#FBA026","#EB6B56","#E25041","#A38F84","#EFEFEF","#FFFFFF","#FAC51C","#F37934","#D14841","#B8312F","#7C706B","#D1D5D8","REMOVE"],tableColorsStep:7,tableCellStyles:{"fr-highlighted":"Highlighted","fr-thick":"Thick"},tableStyles:{"fr-dashed-borders":"Dashed Borders","fr-alternate-rows":"Alternate Rows"},tableCellMultipleStyles:!0,tableMultipleStyles:!0}),$.FroalaEditor.PLUGINS.table=function(editor){function _showInsertPopup(){var $btn=editor.$tb.find('.fr-command[data-cmd="insertTable"]'),$popup=editor.popups.get("table.insert");if($popup||($popup=_initInsertPopup()),!$popup.hasClass("fr-active")){editor.popups.refresh("table.insert"),editor.popups.setContainer("table.insert",editor.$tb);var left=$btn.offset().left+$btn.outerWidth()/2,top=$btn.offset().top+(editor.opts.toolbarBottom?10:$btn.outerHeight()-10);editor.popups.show("table.insert",left,top,$btn.outerHeight())}}function _showEditPopup(){var map=_tableMap();if(map){var $popup=editor.popups.get("table.edit");$popup||($popup=_initEditPopup()),editor.popups.setContainer("table.edit",$(editor.opts.scrollableContainer));var offset=_selectionOffset(map),left=(offset.left+offset.right)/2,top=offset.bottom;if(editor.popups.show("table.edit",left,top,offset.bottom-offset.top),editor.$el.find(".fr-selected-cell").length>1){editor.toolbar.disable(),editor.$el.removeClass("fr-no-selection"),editor.edit.on();var scroll_top=$(editor.original_window).scrollTop();editor.$el.focus(),editor.selection.setAtEnd(editor.$el.find(".fr-selected-cell:last").get(0)),editor.selection.restore(),$(editor.original_window).scrollTop(scroll_top),editor.button.bulkRefresh()}}}function _showColorsPopup(){var map=_tableMap();if(map){var $popup=editor.popups.get("table.colors");$popup||($popup=_initColorsPopup()),editor.popups.setContainer("table.colors",$(editor.opts.scrollableContainer));var offset=_selectionOffset(map),left=(offset.left+offset.right)/2,top=offset.bottom;_refreshColor(),editor.popups.show("table.colors",left,top,offset.bottom-offset.top)}}function _showColorsTextPopup(){var map=_tableMap();if(map){var $popup=editor.popups.get("table.colors.text");$popup||($popup=_initColorsTextPopup()),editor.popups.setContainer("table.colors.text",$(editor.opts.scrollableContainer));var offset=_selectionOffset(map),left=(offset.left+offset.right)/2,top=offset.bottom;_refreshTextColor(),editor.popups.show("table.colors.text",left,top,offset.bottom-offset.top)}}function _hideEditPopup(){0===editor.$el.get(0).querySelectorAll(".fr-selected-cell").length&&editor.toolbar.enable()}function _initInsertPopup(){var table_buttons="";editor.opts.tableInsertButtons.length>0&&(table_buttons='<div class="fr-buttons">'+editor.button.buildList(editor.opts.tableInsertButtons)+"</div>");var template={buttons:table_buttons,rows_columns:_insertTableHtml()},$popup=editor.popups.create("table.insert",template);return editor.popups.onHide("table.insert",function(){$popup.find('.fr-table-size .fr-select-table-size > span[data-row="1"][data-col="1"]').trigger("mouseenter")}),$popup.on("mouseenter",".fr-table-size .fr-select-table-size .fr-table-cell",function(e){var $table_cell=$(e.currentTarget),row=$table_cell.data("row"),col=$table_cell.data("col"),$select_size=$table_cell.parent();$select_size.siblings(".fr-table-size-info").html(row+" × "+col),$select_size.find("> span").removeClass("hover");for(var i=1;i<=editor.opts.tableInsertMaxSize;i++)for(var j=0;j<=editor.opts.tableInsertMaxSize;j++){var $cell=$select_size.find('> span[data-row="'+i+'"][data-col="'+j+'"]');row>=i&&col>=j?$cell.addClass("hover"):row+1>=i||2>=i&&!editor.helpers.isMobile()?$cell.css("display","inline-block"):i>2&&!editor.helpers.isMobile()&&$cell.css("display","none")}}),editor.events.on("destroy",function(){$popup.off("mouseenter",".fr-table-size .fr-select-table-size .fr-table-cell")},!0),$popup}function _insertTableHtml(){for(var rows_columns='<div class="fr-table-size"><div class="fr-table-size-info">1 × 1</div><div class="fr-select-table-size">',i=1;i<=editor.opts.tableInsertMaxSize;i++){for(var j=1;j<=editor.opts.tableInsertMaxSize;j++){var display="inline-block";i>2&&!editor.helpers.isMobile()&&(display="none");var cls="fr-table-cell ";1==i&&1==j&&(cls+=" hover"),rows_columns+='<span class="fr-command '+cls+'" data-cmd="tableInsert" data-row="'+i+'" data-col="'+j+'" data-param1="'+i+'" data-param2="'+j+'" style="display: '+display+';"><span></span></span>'}rows_columns+='<div class="new-line"></div>'}return rows_columns+="</div></div>"}function _initEditPopup(){var table_buttons="";editor.opts.tableEditButtons.length>0&&(table_buttons='<div class="fr-buttons">'+editor.button.buildList(editor.opts.tableEditButtons)+"</div>");var template={buttons:table_buttons},$popup=editor.popups.create("table.edit",template);return editor.popups.onHide("table.edit",_hideEditPopup),editor.$wp.on("scroll.table-edit",function(){editor.popups.isVisible("table.edit")&&_showEditPopup()}),editor.events.on("destroy",function(){editor.$wp.off("scroll.table-edit")}),$popup}function _initColorsPopup(){var table_buttons="";editor.opts.tableColorsButtons.length>0&&(table_buttons='<div class="fr-buttons fr-table-colors-buttons">'+editor.button.buildList(editor.opts.tableColorsButtons)+"</div>");var template={buttons:table_buttons,colors:_colorsHTML()},$popup=editor.popups.create("table.colors",template);return editor.$wp.on("scroll.table-colors",function(){editor.popups.isVisible("table.colors")&&_showColorsPopup()}),editor.events.on("destroy",function(){editor.$wp.off("scroll.table-colors")}),$popup}function _colorsHTML(){for(var colors_html='<div class="fr-table-colors">',i=0;i<editor.opts.tableColors.length;i++)0!==i&&i%editor.opts.tableColorsStep===0&&(colors_html+="<br>"),colors_html+="REMOVE"!=editor.opts.tableColors[i]?'<span class="fr-command" style="background: '+editor.opts.tableColors[i]+';" data-cmd="tableCellBackgroundColor" data-param1="'+editor.opts.tableColors[i]+'"></span>':'<span class="fr-command" data-cmd="tableCellBackgroundColor" data-param1="REMOVE" title="'+editor.language.translate("Clear Formatting")+'"><i class="fa fa-eraser"></i></span>';return colors_html+="</div>"}function _refreshColor(){var $popup=editor.popups.get("table.colors"),$cell=editor.$el.find(".fr-selected-cell:first");$popup.find(".fr-selected-color").removeClass("fr-selected-color"),$popup.find('span[data-param1="'+editor.helpers.RGBToHex($cell.css("background-color"))+'"]').addClass("fr-selected-color")}function _initColorsTextPopup(){var table_buttons="";editor.opts.tableColorsButtons.length>0&&(table_buttons='<div class="fr-buttons fr-table-colors-buttons">'+editor.button.buildList(editor.opts.tableColorsButtons)+"</div>");var template={buttons:table_buttons,colors:_colorsTextHTML()},$popup=editor.popups.create("table.colors.text",template);return editor.$wp.on("scroll.table-colors",function(){editor.popups.isVisible("table.colors.text")&&_showColorsTextPopup()}),editor.events.on("destroy",function(){editor.$wp.off("scroll.table-colors")}),$popup}function _colorsTextHTML(){for(var colors_html='<div class="fr-table-colors">',i=0;i<editor.opts.tableColors.length;i++)0!==i&&i%editor.opts.tableColorsStep===0&&(colors_html+="<br>"),colors_html+="REMOVE"!=editor.opts.tableColors[i]?'<span class="fr-command" style="background-color: '+editor.opts.tableColors[i]+';" data-cmd="tableCellForegroundColor" data-param1="'+editor.opts.tableColors[i]+'"></span>':'<span class="fr-command" data-cmd="tableCellForegroundColor" data-param1="REMOVE" title="'+editor.language.translate("Clear Formatting")+'"><i class="fa fa-eraser"></i></span>';return colors_html+="</div>"}function _refreshTextColor(){var $popup=editor.popups.get("table.colors.text"),$cell=editor.$el.find(".fr-selected-cell:first");$popup.find(".fr-selected-color-text").removeClass("fr-selected-color-text"),$popup.find('span[data-param1="'+editor.helpers.RGBToHex($cell.css("color"))+'"]').addClass("fr-selected-color-text")}function insert(rows,cols){var i,j,table='<table style="width: 100%;"><tbody>',cell_width=100/cols;for(i=0;rows>i;i++){for(table+="<tr>",j=0;cols>j;j++)table+='<td style="width: '+cell_width.toFixed(4)+'%;">',0===i&&0===j&&(table+=$.FroalaEditor.MARKERS),table+="<br></td>";table+="</tr>"}table+="</tbody></table>",editor.html.insert(table),editor.selection.restore()}function remove(){if(editor.$el.find(".fr-selected-cell").length>0){var $current_table=editor.$el.find(".fr-selected-cell").closest("table");editor.selection.setBefore($current_table.get(0))||editor.selection.setAfter($current_table.get(0)),editor.selection.restore(),editor.popups.hide("table.edit"),$current_table.remove()}}function addHeader(){var $table=editor.$el.find(".fr-selected-cell").closest("table");if($table.length>0&&0===$table.find("th").length){var i,thead="<thead><tr>",col=0;for($table.find("tr:first > td").each(function(){var $td=$(this);col+=parseInt($td.attr("colspan"),10)||1}),i=0;col>i;i++)thead+="<th><br></th>";thead+="</tr></thead>",$table.prepend(thead),_showEditPopup()}}function removeHeader(){var $current_table=editor.$el.find(".fr-selected-cell").closest("table"),$table_header=$current_table.find("thead");if($table_header.length>0)if(0===$current_table.find("tbody tr").length)remove();else if($table_header.remove(),editor.$el.find(".fr-selected-cell").length>0)_showEditPopup();else{editor.popups.hide("table.edit");var td=$current_table.find("tbody tr:first td:first").get(0);td&&(editor.selection.setAtEnd(td),editor.selection.restore())}}function insertRow(position){var $table=editor.$el.find(".fr-selected-cell").closest("table");if($table.length>0){if(editor.$el.find("th.fr-selected-cell").length>0&&"above"==position)return;var i,ref_row,map=_tableMap(),selection=_currentSelection(map);ref_row="above"==position?selection.min_i:selection.max_i;var tr="<tr>";for(i=0;i<map[ref_row].length;i++)if("below"==position&&ref_row<map.length-1&&map[ref_row][i]==map[ref_row+1][i]||"above"==position&&ref_row>0&&map[ref_row][i]==map[ref_row-1][i]){if(0===i||i>0&&map[ref_row][i]!=map[ref_row][i-1]){var $cell=$(map[ref_row][i]);$cell.attr("rowspan",parseInt($cell.attr("rowspan"),10)+1)}}else tr+="<td><br></td>";tr+="</tr>";var $ref_row=$($table.find("tr").not($table.find("table tr")).get(ref_row));"below"==position?$ref_row.after(tr):"above"==position&&($ref_row.before(tr),_showEditPopup())}}function deleteRow(){var $table=editor.$el.find(".fr-selected-cell").closest("table");if($table.length>0){var i,j,$row,map=_tableMap(),selection=_currentSelection(map);if(0===selection.min_i&&selection.max_i==map.length-1)remove();else{for(i=selection.max_i;i>=selection.min_i;i--){for($row=$($table.find("tr").not($table.find("table tr")).get(i)),j=0;j<map[i].length;j++)if(0===j||map[i][j]!=map[i][j-1]){var $cell=$(map[i][j]);if(parseInt($cell.attr("rowspan"),10)>1){var rowspan=parseInt($cell.attr("rowspan"),10)-1;1==rowspan?$cell.removeAttr("rowspan"):$cell.attr("rowspan",rowspan)}if(i<map.length-1&&map[i][j]==map[i+1][j]&&(0===i||map[i][j]!=map[i-1][j])){for(var td=map[i][j],col=j;col>0&&map[i][col]==map[i][col-1];)col--;0===col?$($table.find("tr").not($table.find("table tr")).get(i+1)).prepend(td):$(map[i+1][col-1]).after(td)}}var $row_parent=$row.parent();$row.remove(),0===$row_parent.find("tr").length&&$row_parent.remove(),map=_tableMap($table)}selection.min_i>0?editor.selection.setAtEnd(map[selection.min_i-1][0]):editor.selection.setAtEnd(map[0][0]),editor.selection.restore(),editor.popups.hide("table.edit")}}}function insertColumn(position){var $table=editor.$el.find(".fr-selected-cell").closest("table");if($table.length>0){var ref_col,map=_tableMap(),selection=_currentSelection(map);ref_col="before"==position?selection.min_j:selection.max_j;var $cell,old_width=100/map[0].length,new_width=100/(map[0].length+1);$table.find("th, td").each(function(){$cell=$(this),$cell.data("old-width",$cell.outerWidth()/$table.outerWidth()*100)}),$table.find("tr").not($table.find("table tr")).each(function(index){for(var ref_td,$row=$(this),col_no=0,td_no=0;ref_col>col_no-1;){if(ref_td=$row.find("> th, > td").get(td_no),!ref_td){ref_td=null;break}ref_td==map[index][col_no]?(col_no+=parseInt($(ref_td).attr("colspan"),10)||1,td_no++):(col_no+=parseInt($(map[index][col_no]).attr("colspan"),10)||1,"after"==position&&(ref_td=0===td_no?-1:$row.find("> th, > td").get(td_no-1)))}var $ref_td=$(ref_td);if("after"==position&&col_no-1>ref_col||"before"==position&&ref_col>0&&map[index][ref_col]==map[index][ref_col-1]){if(0===index||index>0&&map[index][ref_col]!=map[index-1][ref_col]){var colspan=parseInt($ref_td.attr("colspan"),10)+1;$ref_td.attr("colspan",colspan),$ref_td.css("width",($ref_td.data("old-width")*new_width/old_width+new_width).toFixed(4)+"%"),$ref_td.removeData("old-width")}}else{var td;td=$row.find("th").length>0?'<th style="width: '+new_width.toFixed(4)+'%;"><br></th>':'<td style="width: '+new_width.toFixed(4)+'%;"><br></td>',-1==ref_td?$row.prepend(td):null==ref_td?$row.append(td):"before"==position?$ref_td.before(td):"after"==position&&$ref_td.after(td)}}),$table.find("th, td").each(function(){$cell=$(this),$cell.data("old-width")&&($cell.css("width",($cell.data("old-width")*new_width/old_width).toFixed(4)+"%"),$cell.removeData("old-width"))}),_showEditPopup()}}function deleteColumn(){var $table=editor.$el.find(".fr-selected-cell").closest("table");if($table.length>0){var i,j,$cell,map=_tableMap(),selection=_currentSelection(map);if(0===selection.min_j&&selection.max_j==map[0].length-1)remove();else{var old_width=100/map[0].length,new_width=100/(map[0].length-selection.max_j+selection.min_j-1);for($table.find("th, td").each(function(){$cell=$(this),$cell.hasClass("fr-selected-cell")||$cell.data("old-width",$cell.outerWidth()/$table.outerWidth()*100)}),j=selection.max_j;j>=selection.min_j;j--)for(i=0;i<map.length;i++)if(0===i||map[i][j]!=map[i-1][j])if($cell=$(map[i][j]),parseInt($cell.attr("colspan"),10)>1){var colspan=parseInt($cell.attr("colspan"),10)-1;1==colspan?$cell.removeAttr("colspan"):$cell.attr("colspan",colspan),$cell.css("width",(($cell.data("old-width")-_columnWidth(j,map))*new_width/old_width).toFixed(4)+"%"),$cell.removeData("old-width")}else{var $row=$($cell.parent().get(0));$cell.remove(),0===$row.find("> th, > td").length&&(0===$row.prev().length||0===$row.next().length||$row.prev().find("> th[rowspan], > td[rowspan]").length<$row.prev().find("> th, > td").length)&&$row.remove()}selection.min_j>0?editor.selection.setAtEnd(map[selection.min_i][selection.min_j-1]):editor.selection.setAtEnd(map[selection.min_i][0]),editor.selection.restore(),editor.popups.hide("table.edit"),$table.find("th, td").each(function(){$cell=$(this),$cell.data("old-width")&&($cell.css("width",($cell.data("old-width")*new_width/old_width).toFixed(4)+"%"),$cell.removeData("old-width"))})}}}function mergeCells(){if(editor.$el.find(".fr-selected-cell").length>1&&(0===editor.$el.find("th.fr-selected-cell").length||0===editor.$el.find("td.fr-selected-cell").length)){var i,$cell,$row,map=_tableMap(),selection=_currentSelection(map),cells=editor.$el.find(".fr-selected-cell"),$first_cell=$(cells[0]),$first_row=$first_cell.parent(),first_row_cells=$first_row.find(".fr-selected-cell"),$current_table=$first_cell.closest("table"),content=$first_cell.html(),width=0;for(i=0;i<first_row_cells.length;i++)width+=$(first_row_cells[i]).outerWidth();for($first_cell.css("width",(width/$first_row.outerWidth()*100).toFixed(4)+"%"),selection.min_j<selection.max_j&&$first_cell.attr("colspan",selection.max_j-selection.min_j+1),selection.min_i<selection.max_i&&$first_cell.attr("rowspan",selection.max_i-selection.min_i+1),i=1;i<cells.length;i++)$cell=$(cells[i]),"<br>"!=$cell.html()&&""!==$cell.html()&&(content+="<br>"+$cell.html()),$cell.remove();$first_cell.html(content),editor.selection.setAtEnd($first_cell.get(0)),editor.selection.restore(),editor.toolbar.enable();var empty_trs=$current_table.find("tr:empty");for(i=empty_trs.length-1;i>=0;i--)$row=$(empty_trs[i]),(0===$row.prev().length||0===$row.next().length||$row.prev().find("> th[rowspan], > td[rowspan]").length<$row.prev().find("> th, > td").length)&&$row.remove();_showEditPopup()}}function splitCellHorizontally(){if(1==editor.$el.find(".fr-selected-cell").length){var $selected_cell=editor.$el.find(".fr-selected-cell"),$current_row=$selected_cell.parent(),$current_table=$selected_cell.closest("table"),current_rowspan=parseInt($selected_cell.attr("rowspan"),10),map=_tableMap(),cell_origin=_cellOrigin($selected_cell.get(0),map),$new_td=$selected_cell.clone().html("<br>");if(current_rowspan>1){var new_rowspan=Math.ceil(current_rowspan/2);new_rowspan>1?$selected_cell.attr("rowspan",new_rowspan):$selected_cell.removeAttr("rowspan"),current_rowspan-new_rowspan>1?$new_td.attr("rowspan",current_rowspan-new_rowspan):$new_td.removeAttr("rowspan");for(var row=cell_origin.row+new_rowspan,col=0===cell_origin.col?cell_origin.col:cell_origin.col-1;col>=0&&(map[row][col]==map[row][col-1]||row>0&&map[row][col]==map[row-1][col]);)col--;-1==col?$($current_table.find("tr").not($current_table.find("table tr")).get(row)).prepend($new_td):$(map[row][col]).after($new_td)}else{var i,$row=$("<tr>").append($new_td);for(i=0;i<map[0].length;i++)if(0===i||map[cell_origin.row][i]!=map[cell_origin.row][i-1]){var $cell=$(map[cell_origin.row][i]);$cell.is($selected_cell)||$cell.attr("rowspan",(parseInt($cell.attr("rowspan"),10)||1)+1)}$current_row.after($row)}_removeSelection(),editor.popups.hide("table.edit")}}function splitCellVertically(){if(1==editor.$el.find(".fr-selected-cell").length){var $selected_cell=editor.$el.find(".fr-selected-cell"),current_colspan=parseInt($selected_cell.attr("colspan"),10)||1,parent_width=$selected_cell.parent().outerWidth(),width=$selected_cell.outerWidth(),$new_td=$selected_cell.clone().html("<br>"),map=_tableMap(),cell_origin=_cellOrigin($selected_cell.get(0),map);if(current_colspan>1){var new_colspan=Math.ceil(current_colspan/2);width=_columnsWidth(cell_origin.col,cell_origin.col+new_colspan-1,map)/parent_width*100;var new_width=_columnsWidth(cell_origin.col+new_colspan,cell_origin.col+current_colspan-1,map)/parent_width*100;new_colspan>1?$selected_cell.attr("colspan",new_colspan):$selected_cell.removeAttr("colspan"),current_colspan-new_colspan>1?$new_td.attr("colspan",current_colspan-new_colspan):$new_td.removeAttr("colspan"),$selected_cell.css("width",width.toFixed(4)+"%"),$new_td.css("width",new_width.toFixed(4)+"%")}else{var i;for(i=0;i<map.length;i++)if(0===i||map[i][cell_origin.col]!=map[i-1][cell_origin.col]){var $cell=$(map[i][cell_origin.col]);if(!$cell.is($selected_cell)){var colspan=(parseInt($cell.attr("colspan"),10)||1)+1;$cell.attr("colspan",colspan)}}width=width/parent_width*100/2,$selected_cell.css("width",width.toFixed(4)+"%"),$new_td.css("width",width.toFixed(4)+"%")}$selected_cell.after($new_td),_removeSelection(),editor.popups.hide("table.edit")}}function setBackground(color){"REMOVE"!=color?editor.$el.find(".fr-selected-cell").css("background-color",editor.helpers.HEXtoRGB(color)):editor.$el.find(".fr-selected-cell").css("background-color","")}function setForeground(color){"REMOVE"!=color?editor.$el.find(".fr-selected-cell").css("color",editor.helpers.HEXtoRGB(color)):editor.$el.find(".fr-selected-cell").css("color","")}function verticalAlign(val){editor.$el.find(".fr-selected-cell").css("vertical-align",val)}function horizontalAlign(val){editor.$el.find(".fr-selected-cell").css("text-align",val)}function applyStyle(val,obj,multiple_styles,styles){if(obj.length>0){if(!multiple_styles){var classes=Object.keys(styles);classes.splice(classes.indexOf(val),1),obj.removeClass(classes.join(" "))}obj.toggleClass(val)}}function _tableMap(table){table=table||null;var map=[];if(null==table&&editor.$el.find(".fr-selected-cell").length>0&&(table=editor.$el.find(".fr-selected-cell").closest("table")),table){var $table=$(table);return $table.find("tr").not($table.find("table tr")).each(function(row,tr){var $tr=$(tr),c_index=0;$tr.find("> th, > td").each(function(col,td){
|
||
for(var $td=$(td),cspan=parseInt($td.attr("colspan"),10)||1,rspan=parseInt($td.attr("rowspan"),10)||1,i=row;row+rspan>i;i++)for(var j=c_index;c_index+cspan>j;j++)map[i]||(map[i]=[]),map[i][j]?c_index++:map[i][j]=td;c_index+=cspan})}),map}}function _cellOrigin(td,map){for(var i=0;i<map.length;i++)for(var j=0;j<map[i].length;j++)if(map[i][j]==td)return{row:i,col:j}}function _cellEnds(origin_i,origin_j,map){for(var max_i=origin_i+1,max_j=origin_j+1;max_i<map.length;){if(map[max_i][origin_j]!=map[origin_i][origin_j]){max_i--;break}max_i++}for(max_i==map.length&&max_i--;max_j<map[origin_i].length;){if(map[origin_i][max_j]!=map[origin_i][origin_j]){max_j--;break}max_j++}return max_j==map[origin_i].length&&max_j--,{row:max_i,col:max_j}}function _removeSelection(){var cells=editor.$el.find(".fr-selected-cell");cells.length>0&&cells.each(function(){var $cell=$(this);$cell.removeClass("fr-selected-cell"),""===$cell.attr("class")&&$cell.removeAttr("class")})}function _clearSelection(){setTimeout(function(){editor.selection.clear(),editor.$el.addClass("fr-no-selection"),editor.edit.off(),editor.$el.blur()},0)}function _currentSelection(map){var i,min_i=map.length,max_i=0,min_j=map[0].length,max_j=0,cells=editor.$el.find(".fr-selected-cell");for(i=0;i<cells.length;i++){var cellOrigin=_cellOrigin(cells[i],map),cellEnd=_cellEnds(cellOrigin.row,cellOrigin.col,map);min_i=Math.min(cellOrigin.row,min_i),max_i=Math.max(cellEnd.row,max_i),min_j=Math.min(cellOrigin.col,min_j),max_j=Math.max(cellEnd.col,max_j)}return{min_i:min_i,max_i:max_i,min_j:min_j,max_j:max_j}}function _selectionLimits(min_i,max_i,min_j,max_j,map){var i,j,cellOrigin,cellEnd,first_i=min_i,last_i=max_i,first_j=min_j,last_j=max_j;for(i=first_i;last_i>=i;i++)((parseInt($(map[i][first_j]).attr("rowspan"),10)||1)>1||(parseInt($(map[i][first_j]).attr("colspan"),10)||1)>1)&&(cellOrigin=_cellOrigin(map[i][first_j],map),cellEnd=_cellEnds(cellOrigin.row,cellOrigin.col,map),first_i=Math.min(cellOrigin.row,first_i),last_i=Math.max(cellEnd.row,last_i),first_j=Math.min(cellOrigin.col,first_j),last_j=Math.max(cellEnd.col,last_j)),((parseInt($(map[i][last_j]).attr("rowspan"),10)||1)>1||(parseInt($(map[i][last_j]).attr("colspan"),10)||1)>1)&&(cellOrigin=_cellOrigin(map[i][last_j],map),cellEnd=_cellEnds(cellOrigin.row,cellOrigin.col,map),first_i=Math.min(cellOrigin.row,first_i),last_i=Math.max(cellEnd.row,last_i),first_j=Math.min(cellOrigin.col,first_j),last_j=Math.max(cellEnd.col,last_j));for(j=first_j;last_j>=j;j++)((parseInt($(map[first_i][j]).attr("rowspan"),10)||1)>1||(parseInt($(map[first_i][j]).attr("colspan"),10)||1)>1)&&(cellOrigin=_cellOrigin(map[first_i][j],map),cellEnd=_cellEnds(cellOrigin.row,cellOrigin.col,map),first_i=Math.min(cellOrigin.row,first_i),last_i=Math.max(cellEnd.row,last_i),first_j=Math.min(cellOrigin.col,first_j),last_j=Math.max(cellEnd.col,last_j)),((parseInt($(map[last_i][j]).attr("rowspan"),10)||1)>1||(parseInt($(map[last_i][j]).attr("colspan"),10)||1)>1)&&(cellOrigin=_cellOrigin(map[last_i][j],map),cellEnd=_cellEnds(cellOrigin.row,cellOrigin.col,map),first_i=Math.min(cellOrigin.row,first_i),last_i=Math.max(cellEnd.row,last_i),first_j=Math.min(cellOrigin.col,first_j),last_j=Math.max(cellEnd.col,last_j));return first_i==min_i&&last_i==max_i&&first_j==min_j&&last_j==max_j?{min_i:min_i,max_i:max_i,min_j:min_j,max_j:max_j}:_selectionLimits(first_i,last_i,first_j,last_j,map)}function _selectionOffset(map){var selection=_currentSelection(map),$tl=$(map[selection.min_i][selection.min_j]),$tr=$(map[selection.min_i][selection.max_j]),$bl=$(map[selection.max_i][selection.min_j]),left=$tl.offset().left,right=$tr.offset().left+$tr.outerWidth(),top=$tl.offset().top,bottom=$bl.offset().top+$bl.outerHeight();return{left:left,right:right,top:top,bottom:bottom}}function _selectCells(firstCell,lastCell){if($(firstCell).is(lastCell))_removeSelection(),$(firstCell).addClass("fr-selected-cell");else{_clearSelection();var map=_tableMap(),firstCellOrigin=_cellOrigin(firstCell,map),lastCellOrigin=_cellOrigin(lastCell,map),limits=_selectionLimits(Math.min(firstCellOrigin.row,lastCellOrigin.row),Math.max(firstCellOrigin.row,lastCellOrigin.row),Math.min(firstCellOrigin.col,lastCellOrigin.col),Math.max(firstCellOrigin.col,lastCellOrigin.col),map);_removeSelection();for(var i=limits.min_i;i<=limits.max_i;i++)for(var j=limits.min_j;j<=limits.max_j;j++)$(map[i][j]).addClass("fr-selected-cell")}}function _getCellUnder(e){var cell=null,$target=$(e.target);return"TD"==e.target.tagName||"TH"==e.target.tagName?cell=e.target:$target.closest("td").length>0?cell=$target.closest("td").get(0):$target.closest("th").length>0&&(cell=$target.closest("th").get(0)),0===editor.$el.find(cell).length?null:cell}function _mouseDown(e){if(editor.$el.find(".fr-selected-cell").length>0&&!e.shiftKey&&(_removeSelection(),editor.$el.removeClass("fr-no-selection"),editor.edit.on()),1==e.which){var cell=_getCellUnder(e);if(cell){editor.popups.hide("table.edit"),e.stopPropagation(),editor.events.trigger("image.hideResizer"),editor.events.trigger("video.hideResizer"),mouseDownFlag=!0;var tag_name=cell.tagName.toLowerCase();e.shiftKey&&$(tag_name+".fr-selected-cell").length>0?$($(tag_name+".fr-selected-cell").closest("table")).is($(cell).closest("table"))?_selectCells(mouseDownCell,cell):_clearSelection():((editor.keys.ctrlKey(e)||e.shiftKey)&&_clearSelection(),mouseDownCell=cell,_selectCells(mouseDownCell,mouseDownCell))}}}function _mouseUp(e){if(1==e.which){if(mouseDownFlag){mouseDownFlag=!1;var cell=_getCellUnder(e);cell||1!=editor.$el.find(".fr-selected-cell").length?editor.$el.find(".fr-selected-cell").length>0&&(editor.selection.isCollapsed()?_showEditPopup():_removeSelection()):_removeSelection()}else editor.$tb.is(e.target)||editor.$tb.is($(e.target).closest(editor.$tb.get(0)))||(editor.$el.get(0).querySelectorAll(".fr-selected-cell").length>0&&editor.toolbar.enable(),_removeSelection());if(resizingFlag){resizingFlag=!1,$resizer.removeClass("fr-moving"),editor.$el.removeClass("fr-no-selection"),editor.edit.on(),$resizer.find("div").css("opacity",0),$resizer.hide();var left=parseFloat($resizer.css("left"))+editor.opts.tableResizerOffset;editor.opts.iframe&&(left-=editor.$iframe.offset().left),$resizer.data("release-position",left),$resizer.removeData("max-left"),$resizer.removeData("max-right"),_resize(e)}}}function _mouseEnter(e){if(mouseDownFlag===!0){var $cell=$(e.currentTarget);if($cell.closest("table").is(editor.$el.find(".fr-selected-cell").closest("table"))){if("TD"==e.currentTarget.tagName&&0===editor.$el.find("th.fr-selected-cell").length)return void _selectCells(mouseDownCell,e.currentTarget);if("TH"==e.currentTarget.tagName&&0===editor.$el.find("td.fr-selected-cell").length)return void _selectCells(mouseDownCell,e.currentTarget)}_clearSelection()}}function _usingArrows(e){(37==e.which||38==e.which||39==e.which||40==e.which)&&editor.$el.find(".fr-selected-cell").length>0&&(_removeSelection(),editor.popups.hide("table.edit"))}function _initResizer(){$resizer=$('<div class="fr-table-resizer"><div></div></div>'),editor.$wp.append($resizer),$resizer.on("mousedown",function(){resizingFlag=!0,$resizer.addClass("fr-moving"),_removeSelection(),_clearSelection(),$resizer.find("div").css("opacity",1)}),editor.events.on("destroy",function(){$resizer.off("mousedown"),$resizer.html("").removeData().remove()},!0)}function _placeResizer(e){mouseMoveTimer=null;var tag_under=editor.document.elementFromPoint(e.pageX-editor.window.pageXOffset,e.pageY-editor.window.pageYOffset),$tag_under=$(tag_under);if(tag_under&&"TD"!=tag_under.tagName&&"TH"!=tag_under.tagName&&($tag_under.closest("td").length>0?tag_under=$tag_under.closest("td"):$tag_under.closest("th").length>0&&(tag_under=$tag_under.closest("th"))),tag_under&&("TD"==tag_under.tagName||"TH"==tag_under.tagName)){if($tag_under=$(tag_under),0===editor.$el.find($tag_under).length)return!1;var tag_left=$tag_under.offset().left-1,tag_right=tag_left+$tag_under.outerWidth();if(Math.abs(e.pageX-tag_left)<=editor.opts.tableResizerOffset||Math.abs(tag_right-e.pageX)<=editor.opts.tableResizerOffset){var first,second,resizer_left,max_left,max_right,map=_tableMap($tag_under.closest("table")),tag_origin=_cellOrigin(tag_under,map),tag_end=_cellEnds(tag_origin.row,tag_origin.col,map),$table=$tag_under.closest("table"),resizer_top=$table.offset().top,resizer_height=$table.outerHeight()-1;if(e.pageX-tag_left<=editor.opts.tableResizerOffset)if(resizer_left=tag_left,tag_origin.col>0&&map[tag_origin.row][tag_origin.col-1]){var $prev_tag=$(map[tag_origin.row][tag_origin.col-1]);max_left=1==(parseInt($prev_tag.attr("colspan"),10)||1)?$prev_tag.offset().left-1+editor.opts.tableResizingLimit:tag_left-_columnWidth(tag_origin.col-1,map)+editor.opts.tableResizingLimit,max_right=1==(parseInt($tag_under.attr("colspan"),10)||1)?tag_left+$tag_under.outerWidth()-editor.opts.tableResizingLimit:tag_left+_columnWidth(tag_origin.col,map)-editor.opts.tableResizingLimit,first=tag_origin.col-1,second=tag_origin.col}else first=null,second=tag_origin.col,max_left=$table.parent().offset().left+parseFloat($table.parent().css("padding-left")),max_right=$table.offset().left-1+$table.outerWidth()-map[0].length*editor.opts.tableResizingLimit;else if(tag_right-e.pageX<=editor.opts.tableResizerOffset)if(resizer_left=tag_right,tag_end.col<map[tag_end.row].length&&map[tag_end.row][tag_end.col+1]){var $next_tag=$(map[tag_end.row][tag_end.col+1]);max_left=1==(parseInt($tag_under.attr("colspan"),10)||1)?tag_left+editor.opts.tableResizingLimit:tag_right-_columnWidth(tag_end.col,map)+editor.opts.tableResizingLimit,max_right=1==(parseInt($next_tag.attr("colspan"),10)||1)?tag_right+$next_tag.outerWidth()-editor.opts.tableResizingLimit:tag_right+_columnWidth(tag_origin.col+1,map)-editor.opts.tableResizingLimit,first=tag_end.col,second=tag_end.col+1}else{first=tag_end.col,second=null;var $table_parent=$table.parent();max_left=$table.offset().left-1+map[0].length*editor.opts.tableResizingLimit,max_right=$table_parent.offset().left-1+$table_parent.width()+parseFloat($table_parent.css("padding-left"))}$resizer.data("table",$table),$resizer.data("first",first),$resizer.data("second",second);var left=resizer_left-editor.window.pageXOffset-editor.opts.tableResizerOffset,top=resizer_top-editor.window.pageYOffset;editor.opts.iframe&&(left+=editor.$iframe.offset().left-$(editor.original_window).scrollLeft(),top+=editor.$iframe.offset().top-$(editor.original_window).scrollTop(),max_left+=editor.$iframe.offset().left,max_right+=editor.$iframe.offset().left),$resizer.data("max-left",max_left),$resizer.data("max-right",max_right),$resizer.data("origin",resizer_left-editor.window.pageXOffset),$resizer.css("top",top),$resizer.css("left",left),$resizer.css("height",resizer_height),$resizer.find("div").css("height",resizer_height),$resizer.css("padding-left",editor.opts.tableResizerOffset),$resizer.css("padding-right",editor.opts.tableResizerOffset),$resizer.show()}else $resizer.hide()}}function _repositionResizer(){if(resizingFlag){var $table=$resizer.data("table");$resizer.css("top",$table.offset().top-editor.window.pageYOffset)}}function _resize(){var initial_positon=$resizer.data("origin"),release_position=$resizer.data("release-position");if(initial_positon!==release_position){var first=$resizer.data("first"),second=$resizer.data("second"),$table=$resizer.data("table"),table_width=$table.outerWidth();if(null!==first&&null!==second){var i,$first_cell,$second_cell,map=_tableMap($table),first_widths=[],first_percentages=[],second_widths=[],second_percentages=[];for(i=0;i<map.length;i++)$first_cell=$(map[i][first]),$second_cell=$(map[i][second]),first_widths[i]=$first_cell.outerWidth(),second_widths[i]=$second_cell.outerWidth(),first_percentages[i]=first_widths[i]/table_width*100,second_percentages[i]=second_widths[i]/table_width*100;for(i=0;i<map.length;i++){$first_cell=$(map[i][first]),$second_cell=$(map[i][second]);var first_cell_percentage=(first_percentages[i]*(first_widths[i]+release_position-initial_positon)/first_widths[i]).toFixed(4);$first_cell.css("width",first_cell_percentage+"%"),$second_cell.css("width",(first_percentages[i]+second_percentages[i]-first_cell_percentage).toFixed(4)+"%")}}else{var width,$table_parent=$table.parent(),table_percentage=table_width/$table_parent.width()*100;width=null==first?(table_width-release_position+initial_positon)/table_width*table_percentage:(table_width+release_position-initial_positon)/table_width*table_percentage,$table.css("width",Math.round(width).toFixed(4)+"%")}}$resizer.removeData("origin"),$resizer.removeData("release-position"),$resizer.removeData("first"),$resizer.removeData("second"),$resizer.removeData("table"),editor.undo.saveStep()}function _columnWidth(col,map){var i,width=$(map[0][col]).outerWidth();for(i=1;i<map.length;i++)width=Math.min(width,$(map[i][col]).outerWidth());return width}function _columnsWidth(col1,col2,map){var i,width=0;for(i=col1;col2>=i;i++)width+=_columnWidth(i,map);return width}function _mouseMove(e){if(mouseDownFlag===!1&&resizingFlag===!1)mouseMoveTimer&&clearTimeout(mouseMoveTimer),mouseMoveTimer=setTimeout(_placeResizer,30,e);else if(resizingFlag){var pos=e.pageX-editor.window.pageXOffset;editor.opts.iframe&&(pos+=editor.$iframe.offset().left);var left_limit=$resizer.data("max-left"),right_limit=$resizer.data("max-right");pos>=left_limit&&right_limit>=pos?$resizer.css("left",pos-editor.opts.tableResizerOffset):left_limit>pos&&parseFloat($resizer.css("left"),10)>left_limit-editor.opts.tableResizerOffset?$resizer.css("left",left_limit-editor.opts.tableResizerOffset):pos>right_limit&&parseFloat($resizer.css("left"),10)<right_limit-editor.opts.tableResizerOffset&&$resizer.css("left",right_limit-editor.opts.tableResizerOffset)}}function _addMarkersInCell($cell){editor.node.isEmpty($cell.get(0))?$cell.prepend($.FroalaEditor.MARKERS):$cell.prepend($.FroalaEditor.START_MARKER).append($.FroalaEditor.END_MARKER)}function _useTab(e){var key_code=e.which;if(key_code==$.FroalaEditor.KEYCODE.TAB&&0===editor.opts.tabSpaces){var $cell;if(editor.$el.find(".fr-selected-cell").length>0)$cell=editor.$el.find(".fr-selected-cell:last");else{var cell=editor.selection.element();"TD"==cell.tagName||"TH"==cell.tagName?$cell=$(cell):$(cell).closest("td").length>0?$cell=$(cell).closest("td"):$(cell).closest("th").length>0&&($cell=$(cell).closest("th"))}$cell&&(e.preventDefault(),_removeSelection(),editor.popups.hide("table.edit"),e.shiftKey?$cell.prev().length>0?_addMarkersInCell($cell.prev()):$cell.closest("tr").length>0&&$cell.closest("tr").prev().length>0?_addMarkersInCell($cell.closest("tr").prev().find("td:last")):$cell.closest("tbody").length>0&&$cell.closest("table").find("thead tr").length>0&&_addMarkersInCell($cell.closest("table").find("thead tr th:last")):$cell.next().length>0?_addMarkersInCell($cell.next()):$cell.closest("tr").length>0&&$cell.closest("tr").next().length>0?_addMarkersInCell($cell.closest("tr").next().find("td:first")):$cell.closest("thead").length>0&&$cell.closest("table").find("tbody tr").length>0?_addMarkersInCell($cell.closest("table").find("tbody tr td:first")):($cell.addClass("fr-selected-cell"),insertRow("below"),_removeSelection(),_addMarkersInCell($cell.closest("tr").next().find("td:first"))),editor.selection.restore())}}function _init(){return editor.$wp?(editor.helpers.isMobile()||(mouseDownFlag=!1,resizingFlag=!1,_initResizer(),editor.$el.on("mousedown.table"+editor.id,_mouseDown),editor.popups.onShow("image.edit",function(){_removeSelection(),mouseDownFlag=!1}),editor.popups.onShow("link.edit",function(){_removeSelection(),mouseDownFlag=!1}),editor.events.on("commands.mousedown",function($btn){$btn.parents(".fr-toolbar").length>0&&_removeSelection()}),editor.$el.on("mouseenter.table"+editor.id,"th, td",_mouseEnter),editor.$window.on("mouseup.table"+editor.id,_mouseUp),editor.$el.on("keydown.table"+editor.id,_usingArrows),editor.$window.on("mousemove.table"+editor.id,_mouseMove),$(editor.window).on("scroll.table"+editor.id,_repositionResizer),editor.events.on("contentChanged",function(){editor.$el.find(".fr-selected-cell").length>0&&(_showEditPopup(),editor.$el.find("img").on("load.selected-cells",function(){$(this).off("load.selected-cells"),editor.$el.find(".fr-selected-cell").length>0&&_showEditPopup()}))}),$(editor.original_window).on("resize.table"+editor.id,function(){_removeSelection()}),$(editor.window).on("keydown.table"+editor.id,function(e){if(editor.$el.find(".fr-selected-cell").length>0){if(e.which==$.FroalaEditor.KEYCODE.ESC)return _removeSelection(),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),!1;if(e.which==$.FroalaEditor.KEYCODE.BACKSPACE)return e.preventDefault(),!1;if(editor.$el.find(".fr-selected-cell").length>1)return e.preventDefault(),!1}}),$(editor.window).on("keydown.table"+editor.id,_showEditPopup),$(editor.window).on("input.table"+editor.id,_showEditPopup),$(editor.window).on("keyup.table"+editor.id,_showEditPopup),editor.events.on("html.get",function(html){return html=html.replace(/<(td|th)((?:[\w\W]*?))class="([\w\W]*?)fr-selected-cell([\w\W]*?)"((?:[\w\W]*?))>((?:[\w\W]*?))<\/(td|th)>/g,'<$1$2class="$3$4"$5>$6</$7>'),html=html.replace(/<(td|th)((?:[\w\W]*?)) class=""((?:[\w\W]*?))>((?:[\w\W]*?))<\/(td|th)>/g,"<$1$2$3>$4</$5>")}),editor.events.on("destroy",function(){editor.$el.off("mousedown.table"+editor.id),editor.$el.off("mouseenter.table"+editor.id,"th, td"),editor.$window.off("mouseup.table"+editor.id),editor.$el.off("keydown.table"+editor.id),editor.$window.off("mousemove.table"+editor.id),$(editor.window).off("scroll.table"+editor.id),$(editor.window).off("keydown.table"+editor.id),$(editor.window).off("input.table"+editor.id),$(editor.window).off("keyup.table"+editor.id)},!0)),void editor.events.on("keydown",_useTab,!0)):!1}function back(){editor.$el.find(".fr-selected-cell").length>0?_showEditPopup():(editor.popups.hide("table.insert"),editor.toolbar.showInline())}var $resizer,mouseDownFlag,mouseDownCell,mouseMoveTimer,resizingFlag;return{_init:_init,insert:insert,remove:remove,insertRow:insertRow,deleteRow:deleteRow,insertColumn:insertColumn,deleteColumn:deleteColumn,mergeCells:mergeCells,splitCellVertically:splitCellVertically,splitCellHorizontally:splitCellHorizontally,addHeader:addHeader,removeHeader:removeHeader,setBackground:setBackground,setForeground:setForeground,showInsertPopup:_showInsertPopup,showEditPopup:_showEditPopup,showColorsPopup:_showColorsPopup,showColorsTextPopup:_showColorsTextPopup,back:back,verticalAlign:verticalAlign,horizontalAlign:horizontalAlign,applyStyle:applyStyle}},$.FroalaEditor.DefineIcon("insertTable",{NAME:"table"}),$.FroalaEditor.RegisterCommand("insertTable",{title:"Insert Table",undo:!1,focus:!0,refreshOnCallback:!1,popup:!0,callback:function(){this.popups.isVisible("table.insert")?(this.$el.find(".fr-marker")&&(this.events.disableBlur(),this.selection.restore()),this.popups.hide("table.insert")):this.table.showInsertPopup()}}),$.FroalaEditor.RegisterCommand("tableInsert",{callback:function(cmd,rows,cols){this.table.insert(rows,cols),this.popups.hide("table.insert")}}),$.FroalaEditor.DefineIcon("tableHeader",{NAME:"view_day"}),$.FroalaEditor.RegisterCommand("tableHeader",{title:"Table Header",focus:!1,callback:function(){var $btn=this.popups.get("table.edit").find('.fr-command[data-cmd="tableHeader"]');$btn.hasClass("fr-active")?this.table.removeHeader():this.table.addHeader()},refresh:function($btn){var $table=this.$el.find(".fr-selected-cell").closest("table");$table.length>0&&(0===$table.find("th").length?$btn.removeClass("fr-active"):$btn.addClass("fr-active"))}}),$.FroalaEditor.DefineIcon("tableRows",{NAME:"border_horizontal"}),$.FroalaEditor.RegisterCommand("tableRows",{type:"dropdown",focus:!1,title:"Row",options:{above:"Insert row above",below:"Insert row below","delete":"Delete row"},html:function(){var c='<ul class="fr-dropdown-list">',options=$.FroalaEditor.COMMANDS.tableRows.options;for(var val in options)c+='<li><a class="fr-command" data-cmd="tableRows" data-param1="'+val+'" title="'+this.language.translate(options[val])+'">'+this.language.translate(options[val])+"</a></li>";return c+="</ul>"},callback:function(cmd,val){"above"==val||"below"==val?this.table.insertRow(val):this.table.deleteRow()}}),$.FroalaEditor.DefineIcon("tableColumns",{NAME:"border_vertical"}),$.FroalaEditor.RegisterCommand("tableColumns",{type:"dropdown",focus:!1,title:"Column",options:{before:"Insert column before",after:"Insert column after","delete":"Delete column"},html:function(){var c='<ul class="fr-dropdown-list">',options=$.FroalaEditor.COMMANDS.tableColumns.options;for(var val in options)c+='<li><a class="fr-command" data-cmd="tableColumns" data-param1="'+val+'" title="'+this.language.translate(options[val])+'">'+this.language.translate(options[val])+"</a></li>";return c+="</ul>"},callback:function(cmd,val){"before"==val||"after"==val?this.table.insertColumn(val):this.table.deleteColumn()}}),$.FroalaEditor.DefineIcon("tableCells",{NAME:"merge_type"}),$.FroalaEditor.RegisterCommand("tableCells",{type:"dropdown",focus:!1,title:"Cell",options:{merge:"Merge cells","vertical-split":"Vertical split","horizontal-split":"Horizontal split"},html:function(){var c='<ul class="fr-dropdown-list">',options=$.FroalaEditor.COMMANDS.tableCells.options;for(var val in options)c+='<li><a class="fr-command" data-cmd="tableCells" data-param1="'+val+'" title="'+this.language.translate(options[val])+'">'+this.language.translate(options[val])+"</a></li>";return c+="</ul>"},callback:function(cmd,val){"merge"==val?this.table.mergeCells():"vertical-split"==val?this.table.splitCellVertically():this.table.splitCellHorizontally()},refreshOnShow:function($btn,$dropdown){this.$el.find(".fr-selected-cell").length>1?($dropdown.find('a[data-param1="vertical-split"]').addClass("fr-disabled"),$dropdown.find('a[data-param1="horizontal-split"]').addClass("fr-disabled"),$dropdown.find('a[data-param1="merge"]').removeClass("fr-disabled")):($dropdown.find('a[data-param1="merge"]').addClass("fr-disabled"),$dropdown.find('a[data-param1="vertical-split"]').removeClass("fr-disabled"),$dropdown.find('a[data-param1="horizontal-split"]').removeClass("fr-disabled"))}}),$.FroalaEditor.DefineIcon("tableRemove",{NAME:"trash"}),$.FroalaEditor.RegisterCommand("tableRemove",{title:"Remove Table",focus:!1,callback:function(){this.table.remove()}}),$.FroalaEditor.DefineIcon("tableStyle",{NAME:"format_paint"}),$.FroalaEditor.RegisterCommand("tableStyle",{title:"Table Style",type:"dropdown",focus:!1,html:function(){var c='<ul class="fr-dropdown-list">',options=this.opts.tableStyles;for(var val in options)c+='<li><a class="fr-command" data-cmd="tableStyle" data-param1="'+val+'" title="'+this.language.translate(options[val])+'">'+this.language.translate(options[val])+"</a></li>";return c+="</ul>"},callback:function(cmd,val){this.table.applyStyle(val,this.$el.find(".fr-selected-cell").closest("table"),this.opts.tableMultipleStyles,this.opts.tableStyles)},refreshOnShow:function($btn,$dropdown){var $table=this.$el.find(".fr-selected-cell").closest("table");$table&&$dropdown.find(".fr-command").each(function(){var cls=$(this).data("param1");$(this).toggleClass("fr-active",$table.hasClass(cls))})}}),$.FroalaEditor.DefineIcon("tableCellBackground",{NAME:"format_color_fill"}),$.FroalaEditor.RegisterCommand("tableCellBackground",{title:"Cell Background",focus:!1,callback:function(){this.table.showColorsPopup()}}),$.FroalaEditor.RegisterCommand("tableCellBackgroundColor",{undo:!0,focus:!1,callback:function(cmd,val){this.table.setBackground(val)}}),$.FroalaEditor.DefineIcon("tableCellForeground",{NAME:"format_color_text"}),$.FroalaEditor.RegisterCommand("tableCellForeground",{title:"Cell Foreground",focus:!1,callback:function(){this.table.showColorsTextPopup()}}),$.FroalaEditor.RegisterCommand("tableCellForegroundColor",{undo:!0,focus:!1,callback:function(cmd,val){this.table.setForeground(val)}}),$.FroalaEditor.DefineIcon("tableBack",{NAME:"arrow_back"}),$.FroalaEditor.RegisterCommand("tableBack",{title:"Back",undo:!1,focus:!1,back:!0,callback:function(){this.table.back()},refresh:function($btn){0!==this.$el.find(".fr-selected-cell").length||this.opts.toolbarInline?($btn.removeClass("fr-hidden"),$btn.next(".fr-separator").removeClass("fr-hidden")):($btn.addClass("fr-hidden"),$btn.next(".fr-separator").addClass("fr-hidden"))}}),$.FroalaEditor.DefineIcon("tableCellVerticalAlign",{NAME:"vertical_align_center"}),$.FroalaEditor.RegisterCommand("tableCellVerticalAlign",{type:"dropdown",focus:!1,title:"Vertical Align",options:{Top:"Align Top",Middle:"Align Middle",Bottom:"Align Bottom"},html:function(){var c='<ul class="fr-dropdown-list">',options=$.FroalaEditor.COMMANDS.tableCellVerticalAlign.options;for(var val in options)c+='<li><a class="fr-command" data-cmd="tableCellVerticalAlign" data-param1="'+val.toLowerCase()+'" title="'+this.language.translate(options[val])+'">'+this.language.translate(val)+"</a></li>";return c+="</ul>"},callback:function(cmd,val){this.table.verticalAlign(val)},refreshOnShow:function($btn,$dropdown){$dropdown.find('.fr-command[data-param1="'+this.$el.find(".fr-selected-cell").css("vertical-align")+'"]').addClass("fr-active")}}),$.FroalaEditor.DefineIcon("tableCellHorizontalAlign",{NAME:"format_align_left"}),$.FroalaEditor.DefineIcon("align-left",{NAME:"format_align_left"}),$.FroalaEditor.DefineIcon("align-right",{NAME:"format_align_right"}),$.FroalaEditor.DefineIcon("align-center",{NAME:"format_align_center"}),$.FroalaEditor.DefineIcon("align-justify",{NAME:"format_align_justify"}),$.FroalaEditor.RegisterCommand("tableCellHorizontalAlign",{type:"dropdown",focus:!1,title:"Horizontal Align",options:{left:"Align Left",center:"Align Center",right:"Align Right",justify:"Align Justify"},html:function(){var c='<ul class="fr-dropdown-list">',options=$.FroalaEditor.COMMANDS.tableCellHorizontalAlign.options;for(var val in options)c+='<li><a class="fr-command fr-title" data-cmd="tableCellHorizontalAlign" data-param1="'+val+'" title="'+this.language.translate(options[val])+'">'+this.icon.create("align-"+val)+"</a></li>";return c+="</ul>"},callback:function(cmd,val){this.table.horizontalAlign(val)},refresh:function($btn){$btn.find("> *:first").replaceWith(this.icon.create("align-"+this.helpers.getAlignment(this.$el.find(".fr-selected-cell:first"))))},refreshOnShow:function($btn,$dropdown){$dropdown.find('.fr-command[data-param1="'+this.helpers.getAlignment(this.$el.find(".fr-selected-cell:first"))+'"]').addClass("fr-active")}}),$.FroalaEditor.DefineIcon("tableCellStyle",{NAME:"format_italic"}),$.FroalaEditor.RegisterCommand("tableCellStyle",{title:"Cell Style",type:"dropdown",focus:!1,html:function(){var c='<ul class="fr-dropdown-list">',options=this.opts.tableCellStyles;for(var val in options)c+='<li><a class="fr-command" data-cmd="tableCellStyle" data-param1="'+val+'" title="'+this.language.translate(options[val])+'">'+this.language.translate(options[val])+"</a></li>";return c+="</ul>"},callback:function(cmd,val){this.table.applyStyle(val,this.$el.find(".fr-selected-cell"),this.opts.tableCellMultipleStyles,this.opts.tableCellStyles)},refreshOnShow:function($btn,$dropdown){var $cell=this.$el.find(".fr-selected-cell:first");$cell&&$dropdown.find(".fr-command").each(function(){var cls=$(this).data("param1");$(this).toggleClass("fr-active",$cell.hasClass(cls))})}})}),function(factory){"function"==typeof define&&define.amd?define(["jquery"],factory):"object"==typeof module&&module.exports?module.exports=function(root,jQuery){return void 0===jQuery&&(jQuery="undefined"!=typeof window?require("jquery"):require("jquery")(root)),factory(jQuery),jQuery}:factory(jQuery)}(function($){"use strict";$.extend($.FroalaEditor.POPUP_TEMPLATES,{"colors.picker":"[_BUTTONS_][_TEXT_COLORS_][_BACKGROUND_COLORS_]"}),$.extend($.FroalaEditor.DEFAULTS,{colorsText:["#61BD6D","#1ABC9C","#54ACD2","#2C82C9","#9365B8","#475577","#CCCCCC","#41A85F","#00A885","#3D8EB9","#2969B0","#553982","#28324E","#000000","#F7DA64","#FBA026","#EB6B56","#E25041","#A38F84","#EFEFEF","#FFFFFF","#FAC51C","#F37934","#D14841","#B8312F","#7C706B","#D1D5D8","REMOVE"],colorsBackground:["#61BD6D","#1ABC9C","#54ACD2","#2C82C9","#9365B8","#475577","#CCCCCC","#41A85F","#00A885","#3D8EB9","#2969B0","#553982","#28324E","#000000","#F7DA64","#FBA026","#EB6B56","#E25041","#A38F84","#EFEFEF","#FFFFFF","#FAC51C","#F37934","#D14841","#B8312F","#7C706B","#D1D5D8","REMOVE"],colorsStep:7,colorsDefaultTab:"text",colorsButtons:["colorsBack"]}),$.FroalaEditor.PLUGINS.colors=function(editor){function _showColorsPopup(){var $btn=editor.$tb.find('.fr-command[data-cmd="color"]'),$popup=editor.popups.get("colors.picker");if($popup||($popup=_initColorsPopup()),!$popup.hasClass("fr-active")){editor.popups.setContainer("colors.picker",editor.$tb),_refreshColor($popup.find(".fr-selected-tab").attr("data-param1"));var left=$btn.offset().left+$btn.outerWidth()/2,top=$btn.offset().top+(editor.opts.toolbarBottom?10:$btn.outerHeight()-10);editor.popups.show("colors.picker",left,top,$btn.outerHeight())}}function _hideColorsPopup(){editor.popups.hide("colors.picker")}function _initColorsPopup(){var colors_buttons='<div class="fr-buttons fr-colors-buttons">';editor.opts.toolbarInline&&editor.opts.colorsButtons.length>0&&(colors_buttons+=editor.button.buildList(editor.opts.colorsButtons)),colors_buttons+=_colorsTabsHTML()+"</div>";var template={buttons:colors_buttons,text_colors:_colorPickerHTML("text"),background_colors:_colorPickerHTML("background")},$popup=editor.popups.create("colors.picker",template);return $popup}function _colorsTabsHTML(){var tabs_html='<div class="fr-colors-tabs">';return tabs_html+='<span class="fr-colors-tab '+("background"==editor.opts.colorsDefaultTab?"":"fr-selected-tab ")+'fr-command" data-param1="text" data-cmd="colorChangeSet" title="'+editor.language.translate("Text")+'">'+editor.language.translate("Text")+"</span>",tabs_html+='<span class="fr-colors-tab '+("background"==editor.opts.colorsDefaultTab?"fr-selected-tab ":"")+'fr-command" data-param1="background" data-cmd="colorChangeSet" title="'+editor.language.translate("Background")+'">'+editor.language.translate("Background")+"</span>",tabs_html+"</div>"}function _colorPickerHTML(tab){for(var colors="text"==tab?editor.opts.colorsText:editor.opts.colorsBackground,colors_html='<div class="fr-color-set fr-'+tab+"-color"+(editor.opts.colorsDefaultTab==tab||"text"!=editor.opts.colorsDefaultTab&&"background"!=editor.opts.colorsDefaultTab&&"text"==tab?" fr-selected-set":"")+'">',i=0;i<colors.length;i++)0!==i&&i%editor.opts.colorsStep===0&&(colors_html+="<br>"),colors_html+="REMOVE"!=colors[i]?'<span class="fr-command fr-select-color" style="background: '+colors[i]+';" data-cmd="'+tab+'Color" data-param1="'+colors[i]+'"></span>':'<span class="fr-command fr-select-color" data-cmd="'+tab+'Color" data-param1="REMOVE" title="'+editor.language.translate("Clear Formatting")+'"><i class="fa fa-eraser"></i></span>';return colors_html+"</div>"}function _refreshColor(tab){var color_type,$popup=editor.popups.get("colors.picker"),$element=$(editor.selection.element());for(color_type="background"==tab?"background-color":"color",$popup.find(".fr-"+tab+"-color .fr-select-color").removeClass("fr-selected-color");$element.get(0)!=editor.$el.get(0);){if("transparent"!=$element.css(color_type)&&"rgba(0, 0, 0, 0)"!=$element.css(color_type)){$popup.find(".fr-"+tab+'-color .fr-select-color[data-param1="'+editor.helpers.RGBToHex($element.css(color_type))+'"]').addClass("fr-selected-color");break}$element=$element.parent()}}function _changeSet($tab,val){$tab.hasClass("fr-selected-tab")||($tab.siblings().removeClass("fr-selected-tab"),$tab.addClass("fr-selected-tab"),$tab.parents(".fr-popup").find(".fr-color-set").removeClass("fr-selected-set"),$tab.parents(".fr-popup").find(".fr-color-set.fr-"+val+"-color").addClass("fr-selected-set"),_refreshColor(val))}function background(val){"REMOVE"!=val?editor.commands.applyProperty("background-color",editor.helpers.HEXtoRGB(val)):(editor.commands.applyProperty("background-color","#123456"),
|
||
editor.selection.save(),editor.$el.find("span").each(function(index,span){var $span=$(span),color=$span.css("background-color");("#123456"===color||"#123456"===editor.helpers.RGBToHex(color))&&$span.replaceWith($span.html())}),editor.selection.restore()),_hideColorsPopup()}function text(val){"REMOVE"!=val?editor.commands.applyProperty("color",editor.helpers.HEXtoRGB(val)):(editor.commands.applyProperty("color","#123456"),editor.selection.save(),editor.$el.find("span").each(function(index,span){var $span=$(span),color=$span.css("color");("#123456"===color||"#123456"===editor.helpers.RGBToHex(color))&&$span.replaceWith($span.html())}),editor.selection.restore()),_hideColorsPopup()}function back(){editor.popups.hide("colors.picker"),editor.toolbar.showInline()}function _init(){}return{_init:_init,showColorsPopup:_showColorsPopup,hideColorsPopup:_hideColorsPopup,changeSet:_changeSet,background:background,text:text,back:back}},$.FroalaEditor.DefineIcon("colors",{NAME:"format_color_text"}),$.FroalaEditor.RegisterCommand("color",{title:"Colors",undo:!1,focus:!0,refreshOnCallback:!1,popup:!0,callback:function(){this.popups.isVisible("colors.picker")?(this.$el.find(".fr-marker")&&(this.events.disableBlur(),this.selection.restore()),this.popups.hide("colors.picker")):this.colors.showColorsPopup()}}),$.FroalaEditor.RegisterCommand("textColor",{undo:!0,callback:function(cmd,val){this.colors.text(val)}}),$.FroalaEditor.RegisterCommand("backgroundColor",{undo:!0,callback:function(cmd,val){this.colors.background(val)}}),$.FroalaEditor.RegisterCommand("colorChangeSet",{undo:!1,focus:!1,callback:function(cmd,val){var $tab=this.popups.get("colors.picker").find('.fr-command[data-cmd="'+cmd+'"][data-param1="'+val+'"]');this.colors.changeSet($tab,val)}}),$.FroalaEditor.DefineIcon("colorsBack",{NAME:"arrow_back"}),$.FroalaEditor.RegisterCommand("colorsBack",{title:"Back",undo:!1,focus:!1,back:!0,refreshAfterCallback:!1,callback:function(){this.colors.back()}})}); |