/*

Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license

*/ (function(){CKEDITOR.on(“dialogDefinition”,function(a){var b;b=a.data.name;a=a.data.definition;“link”==b?(a.removeContents(“target”),a.removeContents(“upload”),a.removeContents(“advanced”),b=a.getContents(“info”),b.remove(“emailSubject”),b.remove(“emailBody”)):“image”==b&&(a.removeContents(“advanced”),b=a.getContents(“Link”),b.remove(“cmbTarget”),b=a.getContents(“info”),b.remove(“txtAlt”),b.remove(“basic”))});var l={b:“strong”,u:“u”,i:“em”,color:“span”,size:“span”,quote:“blockquote”,code:“code”,url:“a”, email:“span”,img:“span”,“*”:“li”,list:“ol”},x={strong:“b”,b:“b”,u:“u”,em:“i”,i:“i”,code:“code”,li:“*”},m={strong:“b”,em:“i”,u:“u”,li:“*”,ul:“list”,ol:“list”,code:“code”,a:“link”,img:“img”,blockquote:“quote”},y={color:“color”,size:“font-size”},z={url:“href”,email:“mailhref”,quote:“cite”,list:“listType”},n=CKEDITOR.dtd,A=CKEDITOR.tools.extend({table:1},n.$block,n.$listItem,n.$tableContent,n.$list),C=/s*(?:;s*|$)/,q={smiley:“:)”,sad:“:(”,wink:“;)”,laugh:“:D”,cheeky:“:P”,blush:“:*)”,surprise:“:-o”, indecision:“:|”,angry:“x3e:(”,angel:“o:)”,cool:“8-)”,devil:“x3e:-)”,crying:“;(”,kiss:“:-*”},B={},r=[],t;for(t in q)B[q]=t,r.push(q.replace(/(|)|:|/|*|-||/g,function(a){return“\”+a}));var r=new RegExp(r.join(“|”),“g”),D=function(){var a=[],b={nbsp:“ ”,shy:“­”},c;for(c in b)a.push©;a=new RegExp(“x26(”+a.join(“|”)+“);”,“g”);return function©{return c.replace(a,function(a,c){return b})}}();CKEDITOR.BBCodeParser=function(){this._={bbcPartsRegex:/(?:[(=]*?)(?:=([^]]*?))?])|(?:[/([a-z]{1,16})])/ig}}; CKEDITOR.BBCodeParser.prototype={parse:function(a){for(var b,c,h=0;b=this._.bbcPartsRegex.exec(a);)if(c=b.index,c>h&&(h=a.substring(h,c),this.onText(h,1)),h=this._.bbcPartsRegex.lastIndex,(c=(b||b||“”).toLowerCase())&&!l)this.onText(b);else if(b){var f=l,k={},g={};if(b=b)if(“list”==c&&(isNaN(b)?/^+$/.test(b)?b=“lower-alpha”:/^+$/.test(b)&&(b=“upper-alpha”):b=“decimal”),y){“size”==c&&(b+=“%”);g[y]=b;b=k;var e=“”,d=void 0;for(d in g)var u=(d+“:”+g).replace(C, “;”),e=e+u;b.style=e}else z&&(k[z]=CKEDITOR.tools.htmlDecode(b));if(“email”==c||“img”==c)k.bbcode=c;this.onTagOpen(f,k,CKEDITOR.dtd.$empty)}else if(b)this.onTagClose(l);if(a.length>h)this.onText(a.substring(h,a.length),1)}};CKEDITOR.htmlParser.fragment.fromBBCode=function(a){function b(a){if(0<g.length)for(var f=0;f<g.length;f++){var b=g,c=b.name,k=CKEDITOR.dtd,e=d.name&&CKEDITOR.dtd;e&&!e||a&&k&&!k&&CKEDITOR.dtd||(b=b.clone(),b.parent=d,d=b,g.splice(f,1),f–)}} function c(a,f){var b=d.children.length,c=0,b=!c&&v.getRule(m,“breakAfterOpen”),c=c&&c.type==CKEDITOR.NODE_ELEMENT&&v.getRule(m,“breakAfterClose”),k=a&&v.getRule(m,f?“breakBeforeClose”:“breakBeforeOpen”);e&&(b||c||k)&&e–;e&&a in A&&e++;for(;e&&e–;)d.children.push(new CKEDITOR.htmlParser.element(“br”))}function h(a,f){c(a.name,1);f=f||d||k;var b=f.children.length;a.previous=0||null;a.parent=f;f.children.push(a);a.returnPoint&&(d=a.returnPoint, delete a.returnPoint)}var f=new CKEDITOR.BBCodeParser,k=new CKEDITOR.htmlParser.fragment,g=[],e=0,d=k,u;f.onTagOpen=function(a,k){var e=new CKEDITOR.htmlParser.element(a,k);if(CKEDITOR.dtd.$removeEmpty)g.push(e);else{var w=d.name,p=w&&(CKEDITOR.dtd||(d._.isBlockLike?CKEDITOR.dtd.div:CKEDITOR.dtd.span));if(p&&!p){var p=!1,l;a==w?h(d,d.parent):(a in CKEDITOR.dtd.$listItem?(f.onTagOpen(“ul”,{}),l=d):(h(d,d.parent),g.unshift(d)),p=!0);d=l?l:d.returnPoint||d.parent;if(p){f.onTagOpen.apply(this, arguments);return}}b(a);c(a);e.parent=d;e.returnPoint=u;u=0;e.isEmpty?h(e):d=e}};f.onTagClose=function(a){for(var f=g.length-1;0<=f;f--)if(a==g.name){g.splice(f,1);return}for(var b=[],c=,e=d;e.type&&e.name!=a;)e._.isBlockLike||c.unshift(e),b.push(e),e=e.parent;if(e.type){for(f=0;f,h(a,a.parent);d=e;h(e,e.parent);e==d&&(d=d.parent);g=g.concat©}};f.onText=function(a){var f=CKEDITOR.dtd;if(!f||f)c(),b(),a.replace(/(rn|)|[^rn]*/g,function(a,f){if(void 0!== f&&f.length)e++;else if(a.length){var b=0;a.replace(r,function(f,c){h(new CKEDITOR.htmlParser.text(a.substring(b,c)),d);h(new CKEDITOR.htmlParser.element(“smiley”,{desc:B}),d);b=c+f.length});b!=a.length&&h(new CKEDITOR.htmlParser.text(a.substring(b,a.length)),d)}})};for(f.parse(CKEDITOR.tools.htmlEncode(a));d.type!=CKEDITOR.NODE_DOCUMENT_FRAGMENT;)a=d.parent,h(d,a),d=a;return k};var v=new (CKEDITOR.tools.createClass({$:function(){this._={output:[],rules:};this.setRules(“list”,{breakBeforeOpen:1, breakAfterOpen:1,breakBeforeClose:1,breakAfterClose:1});this.setRules(“*”,{breakBeforeOpen:1,breakAfterOpen:0,breakBeforeClose:1,breakAfterClose:0});this.setRules(“quote”,{breakBeforeOpen:1,breakAfterOpen:0,breakBeforeClose:0,breakAfterClose:1})},proto:{setRules:function(a,b){var c=this._.rules;c?CKEDITOR.tools.extend(c,b,!0):this._.rules=b},getRule:function(a,b){return this._.rules&&this._.rules[b]},openTag:function(a){a in l&&(this.getRule(a,“breakBeforeOpen”)&&this.lineBreak(1),this.write(“[”, a))},openTagClose:function(a){“br”==a?this._.output.push(“n”):a in l&&(this.write(“]”),this.getRule(a,“breakAfterOpen”)&&this.lineBreak(1))},attribute:function(a,b){“option”==a&&this.write(“x3d”,b)},closeTag:function(a){a in l&&(this.getRule(a,“breakBeforeClose”)&&this.lineBreak(1),“*”!=a&&this.write(“”),this.getRule(a,“breakAfterClose”)&&this.lineBreak(1))},text:function(a){this.write(a)},comment:function(){},lineBreak:function(){!this._.hasLineBreak&&this._.output.length&&(this.write(“n”), this._.hasLineBreak=1)},write:function(){this._.hasLineBreak=0;var a=Array.prototype.join.call(arguments,“”);this._.output.push(a)},reset:function(){this._.output=[];this._.hasLineBreak=0},getHtml:function(a){var b=this._.output.join(“”);a&&this.reset();return D(b)}}}));CKEDITOR.plugins.add(“bbcode”,{requires:“entities”,beforeInit:function(a){CKEDITOR.tools.extend(a.config,{enterMode:CKEDITOR.ENTER_BR,basicEntities:!1,entities:!1,fillEmptyBlocks:!1},!0);a.filter.disable();a.activeEnterMode=a.enterMode= CKEDITOR.ENTER_BR},init:function(a){function b(a){var b=a.data;a=CKEDITOR.htmlParser.fragment.fromBBCode(a.data.dataValue);var c=new CKEDITOR.htmlParser.basicWriter;a.writeHtml(c,h);a=c.getHtml(!0);b.dataValue=a}var c=a.config,h=new CKEDITOR.htmlParser.filter;h.addRules({elements:{blockquote:function(a){var b=new CKEDITOR.htmlParser.element(“div”);b.children=a.children;a.children=;if(b=a.attributes.cite){var c=new CKEDITOR.htmlParser.element(“cite”);c.add(new CKEDITOR.htmlParser.text(b.replace(/^“|”$/g, “”)));delete a.attributes.cite;a.children.unshift©}},span:function(a){var b;if(b=a.attributes.bbcode)“img”==b?(a.name=“img”,a.attributes.src=a.children.value,a.children=[]):“email”==b&&(a.name=“a”,a.attributes.href=“mailto:”+a.children[0].value),delete a.attributes.bbcode},ol:function(a){a.attributes.listType?“decimal”!=a.attributes.listType&&(a.attributes.style=“list-style-type:”+a.attributes.listType):a.name=“ul”;delete a.attributes.listType},a:function(a){a.attributes.href||(a.attributes.href= a.children.value)},smiley:function(a){a.name=“img”;var b=a.attributes.desc,g=c.smiley_images,g=CKEDITOR.tools.htmlEncode(c.smiley_path+g);a.attributes={src:g,“data-cke-saved-src”:g,title:b,alt:b}}}});a.dataProcessor.htmlFilter.addRules({elements:{$:function(b){var c=b.attributes,g=CKEDITOR.tools.parseCssText(c.style,1),e,d=b.name;if(d in x)d=x;else if(“span”==d)if(e=g.color)d=“color”,e=CKEDITOR.tools.convertRgbToHex(e);else{if(e=g)if(c= e.match(/(d+)%$/))e=c,d=“size”}else if(“ol”==d||“ul”==d){if(e=g)switch(e){case “lower-alpha”:e=“a”;break;case “upper-alpha”:e=“A”}else“ol”==d&&(e=1);d=“list”}else if(“blockquote”==d){try{var h=b.children,l=b.children,m=“cite”==h.name&&h.children.value;m&&(e='“'m'”',b.children=l.children)}catch(n){}d=“quote”}else if(“a”==d){if(e=c.href)-1!==e.indexOf(“”)?(d=“email”,b.children=[new CKEDITOR.htmlParser.text(e.replace(“”,“”))],e=“”):((d=1==b.children.length&& b.children)&&d.type==CKEDITOR.NODE_TEXT&&d.value==e&&(e=“”),d=“url”)}else if(“img”==d){b.isEmpty=0;g=c||c.src;c=c.alt;if(g&&-1!=g.indexOf(a.config.smiley_path)&&c)return new CKEDITOR.htmlParser.text(q);b.children=[new CKEDITOR.htmlParser.text(g)]}b.name=d;e&&(b.attributes.option=e);return null},br:function(a){if((a=a.next)&&a.name in A)return!1}}},1);a.dataProcessor.writer=v;if(a.elementMode==CKEDITOR.ELEMENT_MODE_INLINE)a.once(“contentDom”,function(){a.on(“setData”,b)}); else a.on(“setData”,b)},afterInit:function(a){var b;a._.elementsPath&&(b=a._.elementsPath.filters)&&b.push(function(b){var h=b.getName(),f=m||!1;“link”==f&&0===b.getAttribute(“href”).indexOf(“”)?f=“email”:“span”==h?b.getStyle(“font-size”)?f=“size”:b.getStyle(“color”)&&(f=“color”):“img”==f&&(b=b.data(“cke-saved-src”)||b.getAttribute(“src”))&&0===b.indexOf(a.config.smiley_path)&&(f=“smiley”);return f})}})})();