/*
 Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.md or http://ckeditor.com/license
*/
CKEDITOR.plugins.add("colorbutton",{requires:"panelbutton,floatpanel",lang:"af,ar,bg,bn,bs,ca,cs,cy,da,de,de-ch,el,en,en-au,en-ca,en-gb,eo,es,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,oc,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,tt,ug,uk,vi,zh,zh-cn",icons:"bgcolor,textcolor",hidpi:!0,init:function(d){function r(a,c,e,g,k){var n=new CKEDITOR.style(l["colorButton_"+c+"Style"]),m=CKEDITOR.tools.getNextId()+"_colorBox";k=k||{};d.ui.add(a,CKEDITOR.UI_PANELBUTTON,
{label:e,title:e,modes:{wysiwyg:1},editorFocus:0,toolbar:"colors,"+g,allowedContent:n,requiredContent:n,contentTransformations:k.contentTransformations,panel:{css:CKEDITOR.skin.getPath("editor"),attributes:{role:"listbox","aria-label":h.panelTitle}},onBlock:function(a,b){b.autoSize=!0;b.element.addClass("cke_colorblock");b.element.setHtml(w(a,c,m));b.element.getDocument().getBody().setStyle("overflow","hidden");CKEDITOR.ui.fire("ready",this);var f=b.keys,e="rtl"==d.lang.dir;f[e?37:39]="next";f[40]=
"next";f[9]="next";f[e?39:37]="prev";f[38]="prev";f[CKEDITOR.SHIFT+9]="prev";f[32]="click"},refresh:function(){d.activeFilter.check(n)||this.setState(CKEDITOR.TRISTATE_DISABLED)},onOpen:function(){var a=d.getSelection(),a=a&&a.getStartElement(),a=d.elementPath(a),b;if(a){a=a.block||a.blockLimit||d.document.getBody();do b=a&&a.getComputedStyle("back"==c?"background-color":"color")||"transparent";while("back"==c&&"transparent"==b&&a&&(a=a.getParent()));b&&"transparent"!=b||(b="#ffffff");!1!==l.colorButton_enableAutomatic&&
this._.panel._.iframe.getFrameDocument().getById(m).setStyle("background-color",b);return b}}})}function w(a,c,e){var g=[],k=l.colorButton_colors.split(","),n=d.plugins.colordialog&&!1!==l.colorButton_enableMore,m=k.length+(n?2:1),p=CKEDITOR.tools.addFunction(function(b,c){function e(a){this.removeListener("ok",e);this.removeListener("cancel",e);"ok"==a.name&&f(this.getContentElement("picker","selectedColor").getValue(),c)}var f=arguments.callee;if("?"==b)d.openDialog("colordialog",function(){this.on("ok",
e);this.on("cancel",e)});else{d.focus();a.hide();d.fire("saveSnapshot");d.removeStyle(new CKEDITOR.style(l["colorButton_"+c+"Style"],{color:"inherit"}));if(b){var g=l["colorButton_"+c+"Style"];g.childRule="back"==c?function(a){return t(a)}:function(a){return!(a.is("a")||a.getElementsByTag("a").count())||t(a)};d.applyStyle(new CKEDITOR.style(g,{color:b}))}d.fire("saveSnapshot")}});!1!==l.colorButton_enableAutomatic&&g.push('\x3ca class\x3d"cke_colorauto" _cke_focus\x3d1 hidefocus\x3dtrue title\x3d"',
h.auto,'" onclick\x3d"CKEDITOR.tools.callFunction(',p,",null,'",c,"');return false;\" href\x3d\"javascript:void('",h.auto,'\')" role\x3d"option" aria-posinset\x3d"1" aria-setsize\x3d"',m,'"\x3e\x3ctable role\x3d"presentation" cellspacing\x3d0 cellpadding\x3d0 width\x3d"100%"\x3e\x3ctr\x3e\x3ctd\x3e\x3cspan class\x3d"cke_colorbox" id\x3d"',e,'"\x3e\x3c/span\x3e\x3c/td\x3e\x3ctd colspan\x3d7 align\x3dcenter\x3e',h.auto,"\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e\x3c/a\x3e");g.push('\x3ctable role\x3d"presentation" cellspacing\x3d0 cellpadding\x3d0 width\x3d"100%"\x3e');
for(e=0;e<k.length;e++){0===e%8&&g.push("\x3c/tr\x3e\x3ctr\x3e");var b=k[e].split("/"),f=b[0],q=b[1]||f;b[1]||(f="#"+f.replace(/^(.)(.)(.)$/,"$1$1$2$2$3$3"));b=d.lang.colorbutton.colors[q]||q;g.push('\x3ctd\x3e\x3ca class\x3d"cke_colorbox" _cke_focus\x3d1 hidefocus\x3dtrue title\x3d"',b,'" onclick\x3d"CKEDITOR.tools.callFunction(',p,",'",f,"','",c,"'); return false;\" href\x3d\"javascript:void('",b,'\')" role\x3d"option" aria-posinset\x3d"',e+2,'" aria-setsize\x3d"',m,'"\x3e\x3cspan class\x3d"cke_colorbox" style\x3d"background-color:#',
q,'"\x3e\x3c/span\x3e\x3c/a\x3e\x3c/td\x3e')}n&&g.push('\x3c/tr\x3e\x3ctr\x3e\x3ctd colspan\x3d8 align\x3dcenter\x3e\x3ca class\x3d"cke_colormore" _cke_focus\x3d1 hidefocus\x3dtrue title\x3d"',h.more,'" onclick\x3d"CKEDITOR.tools.callFunction(',p,",'?','",c,"');return false;\" href\x3d\"javascript:void('",h.more,"')\"",' role\x3d"option" aria-posinset\x3d"',m,'" aria-setsize\x3d"',m,'"\x3e',h.more,"\x3c/a\x3e\x3c/td\x3e");g.push("\x3c/tr\x3e\x3c/table\x3e");return g.join("")}function t(a){return"false"==
a.getAttribute("contentEditable")||a.getAttribute("data-nostyle")}var l=d.config,h=d.lang.colorbutton;if(!CKEDITOR.env.hc){r("TextColor","fore",h.textColorTitle,10,{contentTransformations:[[{element:"font",check:"span{color}",left:function(a){return!!a.attributes.color},right:function(a){a.name="span";a.attributes.color&&(a.styles.color=a.attributes.color);delete a.attributes.color}}]]});var u={},v=d.config.colorButton_normalizeBackground;if(void 0===v||v)u.contentTransformations=[[{element:"span",
left:function(a){var c=CKEDITOR.tools;if("span"!=a.name||!a.styles||!a.styles.background)return!1;a=c.style.parse.background(a.styles.background);return a.color&&1===c.objectKeys(a).length},right:function(a){var c=(new CKEDITOR.style(d.config.colorButton_backStyle,{color:a.styles.background})).getDefinition();a.name=c.element;a.styles=c.styles;a.attributes=c.attributes||{};return a}}]];r("BGColor","back",h.bgColorTitle,20,u)}}});CKEDITOR.config.colorButton_colors="000,800000,8B4513,2F4F4F,008080,000080,4B0082,696969,B22222,A52A2A,DAA520,006400,40E0D0,0000CD,800080,808080,F00,FF8C00,FFD700,008000,0FF,00F,EE82EE,A9A9A9,FFA07A,FFA500,FFFF00,00FF00,AFEEEE,ADD8E6,DDA0DD,D3D3D3,FFF0F5,FAEBD7,FFFFE0,F0FFF0,F0FFFF,F0F8FF,E6E6FA,FFF";
CKEDITOR.config.colorButton_foreStyle={element:"span",styles:{color:"#(color)"},overrides:[{element:"font",attributes:{color:null}}]};CKEDITOR.config.colorButton_backStyle={element:"span",styles:{"background-color":"#(color)"}};