/*
Copyright 2012, KISSY UI Library v1.31
MIT Licensed
build time: Dec 25 23:19
*/
KISSY.add("toolbar",function(f,j,k,n,g){function e(a,b,c){var c=c.get("children"),h=0,d=c.length;if(a==g&&(a=1==b?0:d-1,!c[a].get("disabled")))return c[a];do h++,a=(a+d+b)%d;while(h<d&&c[a].get("disabled"));return h!=d?c[a]:null}function l(a){a.target!=this&&(a.newVal?this.set("expandedItem",null):this.set("expandedItem",a.target))}function m(a){var b=this.get("el")[0],c,d=a.target;if(f.inArray(d,this.get("children"))&&a.newVal&&(d.get("el")[0].ownerDocument.activeElement!=b&&b.focus(),(a=this.get("highlightedItem"))&&
a!=d&&a.set("highlighted",!1),this.set("highlightedItem",d),(c=this.get("expandedItem"))&&c.hasAttr("collapsed")&&c!=d))c.set("collapsed",!0),d.set("collapsed",!1)}var d=k.KeyCodes,i=j.Container.extend({addChild:function(){var a=i.superclass.addChild.apply(this,arguments),b=a;b.set("handleMouseEvents",!1);b.set("focusable",!1);return a},createDom:function(){this.get("el").attr("role","toolbar")},_onSetHighlightedItem:function(a){var b,c=this.get("el");a?(b=a.get("el"),(a=b.attr("id"))||b.attr("id",
a=f.guid("ks-toolbar-item")),c.attr("aria-activedescendant",a)):c.attr("aria-activedescendant","")},bindUI:function(){this.on("afterCollapsedChange",l,this);this.on("afterHighlightedChange",m,this)},handleBlur:function(){var a;(a=this.get("expandedItem"))&&a.set("collapsed",!0);if(a=this.get("highlightedItem"))a.set("highlighted",!1),this.set("highlightedItem",null)},getNextItemByKeyEventInternal:function(a,b){this.get("orientation");var c=this.get("children"),c=b&&f.indexOf(b,c);if(b&&b.handleKeyEventInternal(a))return!0;
if(a.shiftKey||a.ctrlKey||a.metaKey||a.altKey)return!1;switch(a.keyCode){case d.ESC:return this.getKeyEventTarget().fire("blur"),!0;case d.HOME:b=e(g,1,this);break;case d.END:b=e(g,-1,this);break;case d.UP:b=e(c,-1,this);break;case d.LEFT:b=e(c,-1,this);break;case d.DOWN:b=e(c,1,this);break;case d.RIGHT:b=e(c,1,this);break;default:return!1}return b},handleKeyEventInternal:function(a){var b=this.get("highlightedItem"),a=this.getNextItemByKeyEventInternal(a,b);if(f.isBoolean(a))return a;a&&a.set("highlighted",
!0);return!0}},{ATTRS:{highlightedItem:{},expandedItem:{},defaultChildXClass:{value:"button"}}},{xclass:"toolbar",priority:10});return i},{requires:["component/base","node"]});
