KISSY.Editor.add("colorsupport",function(){function n(){if(!e){e="<div class='ke-color-panel'><a class='ke-color-remove' href=\"javascript:void('\u6e05\u9664');\">\u6e05\u9664</a>";for(var a=0;a<3;a++){e+="<div class='ke-color-palette'><table>";for(var b=o[a],c=b.length/8,d=0;d<c;d++){e+="<tr>";for(var g=0;g<8;g++){var h="#"+b[8*d+g];e+="<td>";e+="<a href='javascript:void(0);' class='ke-color-a' style='background-color:"+h+"'></a>";e+="</td>"}e+="</tr>"}e+="</table></div>"}e+="<div><a class='ke-button ke-color-others'>\u5176\u4ed6\u989c\u8272</a></div></div>"}}
var j=KISSY,f=j.Editor,l=j.Node,k=j.Event,m=j.DOM;m.addStyleSheet(".ke-color-panel a {display: block;color:black;text-decoration: none;}.ke-color-panel a:hover {color:black;text-decoration: none;}.ke-color-panel a:active {color:black;}.ke-color-palette {    margin: 5px 8px 8px;}.ke-color-palette table {    border: 1px solid #666666;    border-collapse: collapse;}.ke-color-palette td {    border-right: 1px solid #666666;    height: 18px;    width: 18px;}a.ke-color-a {    height: 18px;    width: 18px;}a.ke-color-a:hover {    border: 1px solid #ffffff;    height: 16px;    width: 16px;}a.ke-color-remove {  padding:3px 8px;  margin:2px 0 3px 0;}a.ke-color-remove:hover {    background-color: #D6E9F8;}",
"ke-color-plugin");var o=[["000","444","666","999","CCC","EEE","F3F3F3","FFF"],["F00","F90","FF0","0F0","0FF","00F","90F","F0F"],["F4CCCC","FCE5CD","FFF2CC","D9EAD3","D0E0E3","CFE2F3","D9D2E9","EAD1DC","EA9999","F9CB9C","FFE599","B6D7A8","A2C4C9","9FC5E8","B4A7D6","D5A6BD","E06666","F6B26B","FFD966","93C47D","76A5AF","6FA8DC","8E7CC3","C27BAD","CC0000","E69138","F1C232","6AA84F","45818E","3D85C6","674EA7","A64D79","990000","B45F06","BF9000","38761D","134F5C","0B5394","351C75","741B47","660000","783F04",
"7F6000","274E13","0C343D","073763","20124D","4C1130"]],e,p=f.Utils.addRes,q=f.Utils.destroyRes;f.ColorSupport={offClick:function(a){var b=this,c=b.cfg;f.use("overlay",function(){c._prepare.call(b,a)})},onClick:function(){this.colorWin&&this.colorWin.hide()},_prepare:function(){var a=this,b=a.cfg,c=document,d=a.btn,g=a.editor,h;n();a.colorWin=new f.Overlay({elCls:"ks-popup",content:e,focus4e:false,autoRender:true,width:"190px",zIndex:f.baseZIndex(f.zIndexManager.POPUP_MENU)});var i=a.colorWin;h=i.get("contentEl");
h.on("click",b._selectColor,a);k.on(c,"click",b._hidePanel,a);k.on(g.document,"click",b._hidePanel,a);i.on("show",d.bon,d);i.on("hide",d.boff,d);c=h.one(".ke-color-others");c.on("click",function(r){r.halt();i.hide();g.useDialog("color/dialog",function(s){s.show(a)})});b._prepare=b._show;b._show.call(a);p.call(a,h,i,c)},_show:function(){var a=this.btn.get("el"),b=this.colorWin,c=parseInt(b.get("width")),d=m.viewportWidth();b.align(a,["bl","tl"],[0,2]);b.get("x")+c>d-30&&b.set("x",d-30-c);b.show()},
_hidePanel:function(a){var b=this.btn.get("el");a=new l(a.target);var c=this.colorWin;b._4e_equals(a)||b.contains(a)||c.hide()},_selectColor:function(a){a.halt();var b=this.cfg;a=new l(a.target);if(a._4e_name()=="a"&&!a.hasClass("ke-button")){b._applyColor.call(this,a._4e_style("background-color"));this.colorWin.hide()}},_applyColor:function(a){var b=this.editor,c=b.document,d=this.cfg.styles;b.fire("save");a?(new f.Style(d,{color:a})).apply(c):(new f.Style(d,{color:"inherit"})).remove(c);b.fire("save")},
destroy:function(){q.call(this);var a=this.editor;k.remove(document,"click",this.cfg._hidePanel,this);a.destroyDialog("color/dialog")}}},{attach:false});
