KISSY.Editor.add("button",function(){var e=KISSY,h=e.Editor;if(h.TripleButton)e.log("TripleButton attach twice","warn");else{var d=e.UIBase.create([e.UIBase.Box.Render||e.UIBase.Box],{bindUI:function(){var b=this,a=b.get("el");a.on("click",b._action,b);a.on("mousedown",function(){b.get("state")=="off"&&a.addClass("ke-triplebutton-active")});a.on("mouseup mouseleave",function(){b.get("state")=="off"&&a.hasClass("ke-triplebutton-active")&&setTimeout(function(){a.removeClass("ke-triplebutton-active")},
300)})},_uiSetTitle:function(){this.get("el").attr("title",this.get("title"))},_uiSetContentCls:function(b){var a=this.get("el");if(b!==undefined){a.html("<span class='ke-toolbar-item "+b+"'>");a._4e_unselectable()}},_uiSetText:function(b){var a=this.get("el");b!==undefined&&a.html(b)},_uiSetState:function(b){this["_"+b]()},disable:function(){this._savedState=this.get("state");this.set("state","disabled")},enable:function(){this.get("state")=="disabled"&&this.set("state",this._savedState)},_action:function(b){this.fire(this.get("state")+
"Click",{TripleEvent:b});this.fire("click",{TripleClickType:this.get("state")+"Click"});b&&b.preventDefault()},bon:function(){this.set("state","on")},boff:function(){this.set("state","off")},_on:function(){var b=this.get("el");b.removeClass("ke-triplebutton-off ke-triplebutton-disabled");b.addClass("ke-triplebutton-on")},_off:function(){var b=this.get("el");b.removeClass("ke-triplebutton-on ke-triplebutton-disabled");b.addClass("ke-triplebutton-off")},_disabled:function(){var b=this.get("el");b.removeClass("ke-triplebutton-off ke-triplebutton-on");
b.addClass("ke-triplebutton-disabled")}},{ATTRS:{state:{value:"off"},elCls:{value:"ke-triplebutton ke-triplebutton-off"},elAttrs:{value:{hideFocus:true,tabIndex:0}},elTagName:{value:"a"},title:{},contentCls:{},text:{}}});d.ON="on";d.OFF="off";d.DISABLED="disabled";d.ON_CLASS="ke-triplebutton-on";d.OFF_CLASS="ke-triplebutton-off";d.DISABLED_CLASS="ke-triplebutton-disabled";h.TripleButton=d;h.prototype.addButton=function(b,a){var g=this,c=new d({render:g.toolBarDiv,autoRender:true,title:a.title,text:a.text,
contentCls:a.contentCls}),f={btn:c,editor:g,cfg:a,call:function(){var j=e.makeArray(arguments),i=j.shift();return a[i].apply(f,j)},reload:function(j){e.mix(a,j);c.enable();g.on("selectionChange",function(){g.getMode()!=h.SOURCE_MODE&&a.selectionChange&&a.selectionChange.apply(f,arguments)});c.on("click",function(i){var k=i.TripleClickType;a[k]&&a[k].apply(f,arguments);i&&i.halt()});if(a.mode==h.WYSIWYG_MODE){g.on("wysiwygmode",c.enable,c);g.on("sourcemode",c.disable,c)}a.init&&a.init.call(f)},destroy:function(){a.destroy&&
a.destroy.call(f);c.destroy()}};a.loading?c.disable():f.reload(undefined);return f}}});
