YUI.add("aui-button-core",function(e,t){var n=e.Lang,r=n.isArray,i=n.isNumber,s=n.isString,o=n.isUndefined,u="active",a="boundingBox",f="btn",l="btngroup",c="button",h="className",p="disabled",d="group",v="i",m="icon",g="iconAlign",y="iconElement",b="label",w="left",E="primary",S="right",x="submit",T="syncUI",N="togglebtn",C="checkbox",k="type",L="widgetConstructor",A=e.getClassName,O={BUTTON:A(f),BUTTON_GROUP:A(f,d),DISABLED:A(p),LABEL:A(b),PRIMARY:A(f,E),SELECTED:A(u),TOGGLE:A(N)},M=function(e){var t=this;t._setEarlyButtonDomType(e.domType)};M.ATTRS={domType:{writeOnce:!0,validator:function(e){return e.toLowerCase()===c||e.toLowerCase()===x}},icon:{},iconElement:{valueFn:function(){var t=this;return e.Node.create(t.ICON_TEMPLATE)}},iconAlign:{value:w,validator:s},primary:{value:!1}},M.HTML_PARSER={iconElement:v},M.getTypedButtonTemplate=function(e,t){return n.sub(e,{type:t?' type="'+t+'"':""})},M.prototype={TEMPLATE:"<button{type}></button>",ICON_TEMPLATE:"<i></i>",iconElement:null,initializer:function(){var e=this;e.after(e.syncButtonExtUI,e,T),e.after({iconChange:e._afterIconChange,iconAlignChange:e._afterIconAlignChange,primaryChange:e._afterPrimaryChange})},syncButtonExtUI:function(){var e=this;e._uiSetIcon(e.get(m)),e._uiSetPrimary(e.get(E))},_afterIconChange:function(e){var t=this;t._uiSetIcon(e.newVal)},_afterIconAlignChange:function(e){var t=this;t._uiSetIconAlign(e.newVal)},_afterPrimaryChange:function(e){var t=this;t._uiSetPrimary(e.newVal)},_setEarlyButtonDomType:function(t){var n=this;n.BOUNDING_TEMPLATE=e.ButtonExt.getTypedButtonTemplate(M.prototype.TEMPLATE,t)},_uiSetPrimary:function(e){var t=this;t.get(a).toggleClass(O.PRIMARY,e)},_uiSetIcon:function(e){var t=this;if(!e)return;var n=t.get(y);n.set(h,e),t._uiSetIconAlign(t.get(g))},_uiSetIconAlign:function(t){var n=this;e.Button.syncIconUI(n.get(a),n.get(y),t)}},e.ButtonExt=M;var _=e.ButtonCore;_.CLASS_NAMES=O,_.prototype._uiSetLabel=function(e){return function(t){var n=this,r=n.getNode();if(t!==""||r.one("."+_.CLASS_NAMES.LABEL))return e.apply(n,arguments)}}(_.prototype._uiSetLabel);var D=e.Button;D.NAME=f,D.CSS_PREFIX=O.BUTTON,D.CLASS_NAMES=O,e.Button=e.Base.create(D.NAME,D,[M,e.WidgetCssClass,e.WidgetToggle],{},{CSS_PREFIX:O.BUTTON,getWidgetLazyConstructorFromNodeData:function(e){var t=e.getData(L)||{};return t.boundingBox=e,t.render=!0,t},hasWidgetLazyConstructorData:function(e){return e.getData(L)!==undefined},setWidgetLazyConstructorNodeData:function(e,t){e.setData(L,t)},syncIconUI:function(t,n,r){var i=e.config.doc.createTextNode(" "),s=0;r===S&&(s=null),t.insert(i,s),t.insert(n,s)}});var P=e.ToggleButton;P.NAME=N,P.CSS_PREFIX=O.TOGGLE,P.CLASS_NAMES=O,e.ToggleButton=e.Base.create(P.NAME,P,[M,e.WidgetCssClass],{},{});var H=e.ButtonGroup;H.NAME=l,H.CSS_PREFIX=O.BUTTON_GROUP,H.CLASS_NAMES=O,e.mix(H.prototype,{CONTENT_TEMPLATE:null,item:function(t){var n=this,r=n.getButtons().item(t),i=e.Widget.getByNode(r);return e.instanceOf(i,D)?i:r},renderUI:function(){var t=this;t.getButtons().each(function(t){!t.button&&!e.instanceOf(e.Widget.getByNode(t),e.Button)&&(e.Button.hasWidgetLazyConstructorData(t)?(new e.Button(e.Button.getWidgetLazyConstructorFromNodeData(t)),e.Button.setWidgetLazyConstructorNodeData(t,null)):t.plug(e.Plugin.Button))})},select:function(e){var t=this;return t.toggleSelect(e,!0)},toggleSelect:function(t,n){var s=this,u=s.get(k),a=s.getButtons();o(t)&&(t=a.getDOMNodes()),r(t)||(t=e.Array(t)),e.Array.each(t,function(t){i(t)&&(t=a.item(t)),t=e.one(t);if(u===C)if(t.hasClass(e.ButtonGroup.CLASS_NAMES.SELECTED)){if(n===!0)return}else if(n===!1)return;s._handleClick({target:t})})},unselect:function(e){var t=this;return t.toggleSelect(e,!1)}},!0)},"2.0.0",{requires:["button","button-group","button-plugin","aui-component","aui-widget-cssclass","aui-widget-toggle"]});
