/* Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ CKEDITOR.plugins.add("colorbutton",{requires:"panelbutton,floatpanel",lang:"af,ar,az,bg,bn,bs,ca,cs,cy,da,de,de-ch,el,en,en-au,en-ca,en-gb,eo,es,es-mx,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 w(a){var u=a.name,f=a.type,h=a.title,v=a.order,t=a.commandName;a=a.contentTransformations||{};var p=new CKEDITOR.style(k["colorButton_"+ f+"Style"]),q=CKEDITOR.tools.getNextId()+"_colorBox",r={type:f},l=new CKEDITOR.style(k["colorButton_"+f+"Style"],{color:"inherit"}),n;d.addCommand(t,{contextSensitive:!0,exec:function(a,b){if(!a.readOnly){var c=b.newStyle;a.removeStyle(l);a.focus();c&&a.applyStyle(c);a.fire("saveSnapshot")}},refresh:function(a,b){l.checkApplicable(b,a,a.activeFilter)?l.checkActive(b,a)?this.setState(CKEDITOR.TRISTATE_ON):this.setState(CKEDITOR.TRISTATE_OFF):this.setState(CKEDITOR.TRISTATE_DISABLED)}});d.ui.add(u, CKEDITOR.UI_PANELBUTTON,{label:h,title:h,command:t,editorFocus:0,toolbar:"colors,"+v,allowedContent:p,requiredContent:p,contentTransformations:a,panel:{css:CKEDITOR.skin.getPath("editor"),attributes:{role:"listbox","aria-label":g.panelTitle}},select:function(a){var b=k.colorButton_colors.split(",");a=CKEDITOR.tools.array.find(b,a);a=m(a);x(n,a);n._.markFirstDisplayed()},onBlock:function(a,b){n=b;b.autoSize=!0;b.element.addClass("cke_colorblock");b.element.setHtml(B({type:f,colorBoxId:q,colorData:r, commandName:t}));b.element.getDocument().getBody().setStyle("overflow","hidden");CKEDITOR.ui.fire("ready",this);var c=b.keys,e="rtl"==d.lang.dir;c[e?37:39]="next";c[40]="next";c[9]="next";c[e?39:37]="prev";c[38]="prev";c[CKEDITOR.SHIFT+9]="prev";c[32]="click"},onOpen:function(){var a=d.getSelection(),b=a&&a.getStartElement(),c=d.elementPath(b);if(!c)return null;b=c.block||c.blockLimit||d.document.getBody();do c=b&&b.getComputedStyle("back"==f?"background-color":"color")||"transparent";while("back"== f&&"transparent"==c&&b&&(b=b.getParent()));c&&"transparent"!=c||(c="#ffffff");!1!==k.colorButton_enableAutomatic&&this._.panel._.iframe.getFrameDocument().getById(q).setStyle("background-color",c);if(b=a&&a.getRanges()[0]){for(var a=new CKEDITOR.dom.walker(b),e=b.collapsed?b.startContainer:a.next(),b="";e;){e.type!==CKEDITOR.NODE_ELEMENT&&(e=e.getParent());e=m(e.getComputedStyle("back"==f?"background-color":"color"));b=b||e;if(b!==e){b="";break}e=a.next()}"transparent"==b&&(b="");"fore"==f&&(r.automaticTextColor= "#"+m(c));r.selectionColor=b?"#"+b:"";x(n,b)}return c}})}function B(a){function u(a){a=a&&new CKEDITOR.style(n,{color:a});d.execCommand(t,{newStyle:a})}var f=a.type,h=a.colorBoxId,v=a.colorData,t=a.commandName;a=[];var p=k.colorButton_colors.split(","),q=k.colorButton_colorsPerRow||6,r=d.plugins.colordialog&&!1!==k.colorButton_enableMore,l=p.length+(r?2:1),n=d.config["colorButton_"+f+"Style"];n.childRule="back"==f?function(a){return y(a)}:function(a){return!(a.is("a")||a.getElementsByTag("a").count())|| y(a)};var m=CKEDITOR.tools.addFunction(function(a){d.focus();d.fire("saveSnapshot");"?"==a?d.getColorFromDialog(function(a){a&&u(a)},null,v):u(a&&"#"+a)});!1!==k.colorButton_enableAutomatic&&a.push('\x3ca class\x3d"cke_colorauto" _cke_focus\x3d1 hidefocus\x3dtrue title\x3d"',g.auto,'" draggable\x3d"false" ondragstart\x3d"return false;" onclick\x3d"CKEDITOR.tools.callFunction(',m,",null,'",f,"');return false;\" href\x3d\"javascript:void('",g.auto,'\')" role\x3d"option" aria-posinset\x3d"1" aria-setsize\x3d"', l,'"\x3e\x3ctable role\x3d"presentation" cellspacing\x3d0 cellpadding\x3d0 width\x3d"100%"\x3e\x3ctr\x3e\x3ctd colspan\x3d"'+q+'" align\x3d"center"\x3e\x3cspan class\x3d"cke_colorbox" id\x3d"',h,'"\x3e\x3c/span\x3e',g.auto,"\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e\x3c/a\x3e");a.push('\x3ctable role\x3d"presentation" cellspacing\x3d0 cellpadding\x3d0 width\x3d"100%"\x3e');for(h=0;h