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