KISSY.Editor.add("tabs",function(){function i(a){this.cfg=a;this._init()}var e=KISSY,j=e.Editor,l=e.DOM,h=e.Node;if(j.Tabs)e.log("ke tabs attach more","warn");else{e.augment(i,e.EventTarget,{_init:function(){var a=this,b=a.cfg,c=b.tabs,f=b.contents.children("div"),g=c.children("li");c.on("click",function(d){d&&d.halt();d=new h(d.target);if(d=d._4e_ascendant(function(k){return k._4e_name()==="li"&&c.contains(k)},true)){g.removeClass("ke-tab-selected");var m=d.attr("rel");d.addClass("ke-tab-selected");
f.hide();l.show(f[e.indexOf(d[0],g)]);a.fire(m)}})},getTab:function(a){var b=this.cfg,c=b.tabs;b=b.contents.children("div");c=c.children("li");for(var f=0;f<c.length;f++){var g=new h(c[f]),d=new h(b[f]);if(e.isNumber(a)&&a==f||e.isString(a)&&a==g.attr("rel"))return{tab:g,content:d}}},remove:function(a){a=this.getTab(a);a.tab.remove();a.content.remove()},_getActivate:function(){for(var a=this.cfg.tabs.children("li"),b=0;b<a.length;b++){var c=new h(a[b]);if(c.hasClass("ke-tab-selected"))return c.attr("rel")}},
activate:function(a){if(arguments.length==0)return this._getActivate();var b=this.cfg,c=b.tabs;b=b.contents.children("div");c.children("li").removeClass("ke-tab-selected");b.hide();c=this.getTab(a);c.tab.addClass("ke-tab-selected");c.content.show()},destroy:function(){var a=this.cfg.tabs;a.detach();a.remove()}});j.Tabs=i}},{attach:false});
