button-base-min.js revision 6488e8ec7810820c85fba59e135d021265f3e71a
YUI.add("button-base",function(c){function a(d){this._eventsToAssign={};a.superclass.constructor.apply(this,arguments);}function b(d){if(d){return c.ClassNameManager.getClassName(a.NAME,d);}else{return c.ClassNameManager.getClassName(a.NAME);}}c.extend(a,c.Base,{initializer:function(d){this.renderUI();this.bindUI();this.on(this._eventsToAssign);},renderUI:function(){var d=this.getNode();d.addClass(a.CLASS_NAMES.button);d.setAttribute("role","button");},bindUI:function(){var d=this;var e=d.getNode();e.on("mousedown",this._onMouseDown,d);e.on("mouseup",this._onMouseUp,d);e.on("focus",this._onFocus,d);e.on("blur",this._onBlur,d);d.on("selectedChange",function(f){if(f.propagate===false){f.stopImmediatePropagation();}});},getNode:function(){return this.get("srcNode");},select:function(){this.set("selected",true);},unselect:function(){this.set("selected",false);},enable:function(){this.set("disabled",false);},disable:function(){this.set("disabled",true);},on:function(h,g,e,d){if(c.Lang.isObject(arguments[0])){c.Object.each(arguments[0],function(){this.on(arguments[1],arguments[0]);},this);}else{var f=this;var i=f.getNode();if(c.Object.hasKey(c.Node.DOM_EVENTS,h)){if(i){return c.Node.prototype.on.apply(i,arguments);}else{this._eventsToAssign[h]=g;}}else{return c.EventTarget.prototype.on.apply(f,arguments);}}},_labelSetter:function(e){var d=this.getNode();d.set(d.test("input")?"value":"text",e);},_disabledSetter:function(d){this.getNode().set("disabled",d).toggleClass(a.CLASS_NAMES.disabled,d);},_selectedSetter:function(d){this.getNode().set("aria-selected",d).toggleClass(a.CLASS_NAMES.selected,d);},_typeSetter:function(f){var d=this;if(f==="toggle"){var e=d.getNode();d._clickHandler=e.on("click",function(){d.set("selected",!d.get("selected"));},d);}else{if(d._clickHandler){d._clickHandler.detach();d._clickHandler=false;}}}},{ATTRS:{srcNode:{writeOnce:"initOnly",setter:c.one,valueFn:function(){return c.Node.create("<button></button>");}},label:{lazyAdd:false,setter:"_labelSetter"},type:{value:"push",lazyAdd:false,setter:"_typeSetter"},disabled:{value:false,lazyAdd:false,setter:"_disabledSetter"},selected:{value:false,lazyAdd:false,setter:"_selectedSetter"}}});a.NAME="button";a.CLASS_NAMES={button:b(),selected:b("selected"),focused:b("focused"),disabled:b("disabled")};a.prototype._onBlur=function(d){d.target.removeClass(a.CLASS_NAMES.focused);};a.prototype._onFocus=function(d){d.target.addClass(a.CLASS_NAMES.focused);};a.prototype._onMouseUp=function(d){d.target.setAttribute("aria-pressed","false");};a.prototype._onMouseDown=function(d){d.target.setAttribute("aria-pressed","true");};c.Button=a;},"@VERSION@",{requires:["yui-base","attribute","node","array-extras"]});