KISSY.Editor.add("font",function(d){d.addPlugin("font",function(){function w(a){for(var c=[],e=0;e<a.length;e++)c.push({name:a[e],value:a[e]});return c}var i=KISSY,g=i.Editor,o=g.Style,p=g.TripleButton,f=d.cfg.pluginConfig,j=f["font-size"],b,m,n,k=[];if(j!==false){j=j||{};i.mix(j,{items:w(["8px","10px","12px","14px","18px","24px","36px","48px","60px","72px","84px","96px"]),width:"55px"},false);var q={},r=[],h={element:"span",styles:{"font-size":"#(size)"},overrides:[{element:"font",attributes:{size:null}}]};
for(l=0;l<j.items.length;l++){b=j.items[l];m=b.name;n=b.attrs;b=b.value;q[b]=new o(h,{size:b});r.push({name:m,value:b,attrs:n})}f["font-size"]=j}h=f["font-family"];if(h!==false){h=h||{};i.mix(h,{items:[{name:"\u5b8b\u4f53",value:"SimSun"},{name:"\u9ed1\u4f53",value:"SimHei"},{name:"\u96b6\u4e66",value:"LiSu"},{name:"\u6977\u4f53",value:"KaiTi_GB2312"},{name:"\u5fae\u8f6f\u96c5\u9ed1",value:"Microsoft YaHei"},{name:"Georgia",value:"Georgia"},{name:"Times New Roman",value:"Times New Roman"},{name:"Impact",value:"Impact"},{name:"Courier New",value:"Courier New"},
{name:"Arial",value:"Arial"},{name:"Verdana",value:"Verdana"},{name:"Tahoma",value:"Tahoma"}],width:"130px"},false);var s={},t=[],x={element:"span",styles:{"font-family":"#(family)"},overrides:[{element:"font",attributes:{face:null}}]},l;f["font-family"]=h;for(l=0;l<h.items.length;l++){b=h.items[l];m=b.name;n=b.attrs||{};b=b.value;n.style=n.style||"";n.style+=";font-family:"+b;s[b]=new o(x,{family:b});t.push({name:m,value:b,attrs:n})}}m={click:function(a){var c=a.newVal;a=a.prevVal;var e=this.cfg.styles;
d.focus();d.fire("save");e=e[c];if(c==a){e.remove(d.document);this.btn.set("value","")}else e.apply(d.document);d.fire("save")},selectionChange:function(a){a=a.path.elements;for(var c=this.cfg.styles,e=0,u;e<a.length;e++){u=a[e];for(var v in c)if(c[v].checkElementRemovable(u,true)){this.btn.set("value",v);return}}this.btn.reset("value")}};false!==f["font-size"]&&k.push(d.addSelect("font-size",i.mix({title:"\u5927\u5c0f",width:"30px",mode:g.WYSIWYG_MODE,showValue:true,popUpWidth:j.width,items:r,styles:q},m)));
false!==f["font-family"]&&k.push(d.addSelect("font-family",i.mix({title:"\u5b57\u4f53",width:"110px",mode:g.WYSIWYG_MODE,popUpWidth:h.width,items:t,styles:s},m)));g={mode:g.WYSIWYG_MODE,offClick:function(){var a=this.editor,c=this.cfg.style;a.fire("save");c.apply(a.document);a.fire("save");a.notifySelectionChange();a.focus()},onClick:function(){var a=this.editor,c=this.cfg.style;a.fire("save");c.remove(a.document);a.fire("save");a.notifySelectionChange();a.focus()},selectionChange:function(a){var c=this.btn;
this.cfg.style.checkActive(a.path)?c.set("state",p.ON):c.set("state",p.OFF)}};false!==f["font-bold"]&&k.push(d.addButton("font-bold",i.mix({contentCls:"ke-toolbar-bold",title:"\u7c97\u4f53 ",style:new o({element:"strong",overrides:[{element:"b"},{element:"span",attributes:{style:"font-weight: bold;"}}]})},g)));false!==f["font-italic"]&&k.push(d.addButton("font-italic",i.mix({contentCls:"ke-toolbar-italic",title:"\u659c\u4f53 ",style:new o({element:"em",overrides:[{element:"i"},{element:"span",attributes:{style:"font-style: italic;"}}]})},
g)));false!==f["font-underline"]&&k.push(d.addButton("font-underline",i.mix({contentCls:"ke-toolbar-underline",title:"\u4e0b\u5212\u7ebf ",style:new o({element:"u",overrides:[{element:"span",attributes:{style:"text-decoration: underline;"}}]})},g)));if(false!==f["font-strikeThrough"])k.push(d.addButton("font-underline",i.mix({contentCls:"ke-toolbar-strikeThrough",title:"\u5220\u9664\u7ebf ",style:new o((f["font-strikeThrough"]||{}).style||{element:"del",overrides:[{element:"span",attributes:{style:"text-decoration: line-through;"}},
{element:"s"},{element:"strike"}]})},g)));this.destroy=function(){for(var a=0;a<k.length;a++)k[a].destroy()}})},{attach:false});
