CKEDITOR.plugins.add('colorbutton',{requires:['panelbutton','floatpanel','styles'],init:function(a){var b=a.config,c=a.lang.colorButton,d;if(!CKEDITOR.env.hc){e('TextColor','fore',c.textColorTitle);e('BGColor','back',c.bgColorTitle);}function e(h,i,j){var k=CKEDITOR.tools.getNextId()+'_colorBox';a.ui.add(h,CKEDITOR.UI_PANELBUTTON,{label:j,title:j,className:'cke_button_'+h.toLowerCase(),modes:{wysiwyg:1},panel:{css:a.skin.editor.css,attributes:{role:'listbox','aria-label':c.panelTitle}},onBlock:function(l,m){m.autoSize=true;m.element.addClass('cke_colorblock');m.element.setHtml(f(l,i,k));m.element.getDocument().getBody().setStyle('overflow','hidden');CKEDITOR.ui.fire('ready',this);var n=m.keys,o=a.lang.dir=='rtl';n[o?37:39]='next';n[40]='next';n[9]='next';n[o?39:37]='prev';n[38]='prev';n[CKEDITOR.SHIFT+9]='prev';n[32]='click';},onOpen:function(){var l=a.getSelection(),m=l&&l.getStartElement(),n=new CKEDITOR.dom.elementPath(m),o;m=n.block||n.blockLimit||a.document.getBody();do o=m&&m.getComputedStyle(i=='back'?'background-color':'color')||'transparent';while(i=='back'&&o=='transparent'&&m&&(m=m.getParent()))if(!o||o=='transparent')o='#ffffff';this._.panel._.iframe.getFrameDocument().getById(k).setStyle('background-color',o);}});};function f(h,i,j){var k=[],l=b.colorButton_colors.split(','),m=l.length+(b.colorButton_enableMore?2:1),n=CKEDITOR.tools.addFunction(function(t,u){if(t=='?'){var v=arguments.callee;function w(y){this.removeListener('ok',w);this.removeListener('cancel',w);y.name=='ok'&&v(this.getContentElement('picker','selectedColor').getValue(),u);};a.openDialog('colordialog',function(){this.on('ok',w);this.on('cancel',w);});return;}a.focus();h.hide();a.fire('saveSnapshot');new CKEDITOR.style(b['colorButton_'+u+'Style'],{color:'inherit'}).remove(a.document);if(t){var x=b['colorButton_'+u+'Style'];x.childRule=u=='back'?function(y){return g(y);}:function(y){return y.getName()!='a'||g(y);};new CKEDITOR.style(x,{color:t}).apply(a.document);}a.fire('saveSnapshot');});k.push('<a class="cke_colorauto" _cke_focus=1 hidefocus=true title="',c.auto,'" onclick="CKEDITOR.tools.callFunction(',n,",null,'",i,"');return false;\" href=\"javascript:void('",c.auto,'\')" role="option" aria-posinset="1" aria-setsize="',m,'"><table role="presentation" cellspacing=0 cellpadding=0 width="100%"><tr><td><span class="cke_colorbox" id="',j,'"></span></td><td colspan=7 align=center>',c.auto,'</td></tr></table></a><table role="presentation" cellspacing=0 cellpadding=0 width="100%">');
for(var o=0;o<l.length;o++){if(o%8===0)k.push('</tr><tr>');var p=l[o].split('/'),q=p[0],r=p[1]||q;if(!p[1])q='#'+q.replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3');var s=a.lang.colors[r]||r;k.push('<td><a class="cke_colorbox" _cke_focus=1 hidefocus=true title="',s,'" onclick="CKEDITOR.tools.callFunction(',n,",'",q,"','",i,"'); return false;\" href=\"javascript:void('",s,'\')" role="option" aria-posinset="',o+2,'" aria-setsize="',m,'"><span class="cke_colorbox" style="background-color:#',r,'"></span></a></td>');}if(b.colorButton_enableMore===undefined||b.colorButton_enableMore)k.push('</tr><tr><td colspan=8 align=center><a class="cke_colormore" _cke_focus=1 hidefocus=true title="',c.more,'" onclick="CKEDITOR.tools.callFunction(',n,",'?','",i,"');return false;\" href=\"javascript:void('",c.more,"')\"",' role="option" aria-posinset="',m,'" aria-setsize="',m,'">',c.more,'</a></td>');k.push('</tr></table>');return k.join('');};function g(h){return h.getAttribute('contentEditable')=='false'||h.getAttribute('data-nostyle');};}});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)'}};
