b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright* A Button Widget
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright* @module button
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright* @since 3.5.0
32db3cd3a46c3850c354f593f6ea5ebef8b50591Derek Gathright* Creates a Button
32db3cd3a46c3850c354f593f6ea5ebef8b50591Derek Gathright* @class Button
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright* @extends Widget
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright* @param config {Object} Configuration object
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright* @constructor
32db3cd3a46c3850c354f593f6ea5ebef8b50591Derek Gathright Button.superclass.constructor.apply(this, arguments);
32db3cd3a46c3850c354f593f6ea5ebef8b50591Derek Gathright/* Button extends Widget */
a7e9ca67d735ae1bcdc1f7deb35ab98dd9c9f614Derek Gathright BOUNDING_TEMPLATE: Y.ButtonCore.prototype.TEMPLATE,
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @method initializer
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @description Internal init() handler.
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @param config {Object} Config object.
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * bindUI implementation
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @description Hooks up events for the widget
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @method bindUI
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright button.after('labelChange', button._afterLabelChange);
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright button.after('disabledChange', button._afterDisabledChange);
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @method syncUI
347511d70b1f81d9b08363612fdabcef8a85e7a6Derek Gathright * @description Updates button attributes
79a7949ec943200ad3c7f1c20af065cf8936907dDerek Gathright button._uiSetDisabled(button.get('disabled'));
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @method _afterLabelChange
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @method _afterDisabledChange
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright // Y.Button static properties
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * The identity of the widget.
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @property NAME
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @type String
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @default 'button'
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * Static property used to define the default attribute configuration of
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * the Widget.
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @property ATTRS
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @type {Object}
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @property HTML_PARSER
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @type {Object}
f6eaca952977579049a77179dc827c5fc1d6c808Derek Gathright return this._getLabel();
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * List of class names used in the ButtonGroup's DOM
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @property CLASS_NAMES
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @type Object
32db3cd3a46c3850c354f593f6ea5ebef8b50591Derek GathrightY.mix(Button.prototype, Y.ButtonCore.prototype);
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright* Creates a ToggleButton
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright* @class ToggleButton
32db3cd3a46c3850c354f593f6ea5ebef8b50591Derek Gathright* @extends Button
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright* @param config {Object} Configuration object
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright* @constructor
32db3cd3a46c3850c354f593f6ea5ebef8b50591Derek Gathright Button.superclass.constructor.apply(this, arguments);
a7e9ca67d735ae1bcdc1f7deb35ab98dd9c9f614Derek Gathright// TODO: move to ButtonCore subclass to enable toggle plugin, widget, etc.
32db3cd3a46c3850c354f593f6ea5ebef8b50591Derek Gathright/* ToggleButton extends Button */
bb09a8bcec28d3fcfe6649ea17c5042b68ea1627Derek Gathright selectedAttrName = (type === "checkbox" ? 'checked' : 'pressed'),
bb09a8bcec28d3fcfe6649ea17c5042b68ea1627Derek Gathright selectedState = config[selectedAttrName] || false;
bb09a8bcec28d3fcfe6649ea17c5042b68ea1627Derek Gathright // Create the checked/pressed attribute
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @method bindUI
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * @description Hooks up events for the widget
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright ToggleButton.superclass.bindUI.call(button);
c3e956d9b62a538911d580547f2dff07b7f0a4b0Derek Gathright cb.on(button.trigger, button.toggle, button);
bb09a8bcec28d3fcfe6649ea17c5042b68ea1627Derek Gathright button.after(button.selectedAttrName + 'Change', button._afterSelectedChange);
cceccdb28016ec7a8589d981db1237c1f72c6f93Derek Gathright * @method syncUI
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * @description Syncs the UI for the widget
bb09a8bcec28d3fcfe6649ea17c5042b68ea1627Derek Gathright role = (type === 'checkbox' ? ROLES.CHECKBOX : ROLES.TOGGLE),
bb09a8bcec28d3fcfe6649ea17c5042b68ea1627Derek Gathright ToggleButton.superclass.syncUI.call(button);
bb09a8bcec28d3fcfe6649ea17c5042b68ea1627Derek Gathright button._uiSetSelected(button.get(selectedAttrName));
bb09a8bcec28d3fcfe6649ea17c5042b68ea1627Derek Gathright * @method _uiSetSelected
bb09a8bcec28d3fcfe6649ea17c5042b68ea1627Derek Gathright ariaState = (type === 'checkbox' ? STATES.CHECKED : STATES.PRESSED);
32db3cd3a46c3850c354f593f6ea5ebef8b50591Derek Gathright cb.toggleClass(Button.CLASS_NAMES.SELECTED, value);
b2e3e4e5b9ad601bb552e859ade3329168457dd6Derek Gathright * @method toggle
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * @description Toggles the selected/pressed/checked state of a ToggleButton
bb09a8bcec28d3fcfe6649ea17c5042b68ea1627Derek Gathright button._set(button.selectedAttrName, !button.get(button.selectedAttrName));
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * The identity of the widget.
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * @property NAME
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * @type {String}
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * @default 'buttongroup'
615e6a4633b53af433f9bfb616363b682d487043Derek Gathright * Static property used to define the default attribute configuration of
615e6a4633b53af433f9bfb616363b682d487043Derek Gathright * the Widget.
615e6a4633b53af433f9bfb616363b682d487043Derek Gathright * @property ATTRS
615e6a4633b53af433f9bfb616363b682d487043Derek Gathright * @type {Object}
615e6a4633b53af433f9bfb616363b682d487043Derek Gathright * @property HTML_PARSER
615e6a4633b53af433f9bfb616363b682d487043Derek Gathright * @type {Object}
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * @property ARIA_STATES
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * @type {Object}
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * @property ARIA_ROLES
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * @type {Object}
cceccdb28016ec7a8589d981db1237c1f72c6f93Derek Gathright * Array of static constants used to identify the classnames applied to DOM nodes
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * @property CLASS_NAMES
e592b34ac3f93557b9c7b30f9debc810a4875e79Derek Gathright * @type Object