button-debug.js revision d0f9ee99aee2d631a24062cd95d30c1d6955fc0f
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* A Button Widget
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* @module button
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* @since 3.5.0
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* Creates a ButtonWidget
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* @class ButtonWidget
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* @extends Widget
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* @param config {Object} Configuration object
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* @constructor
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots ButtonWidget.superclass.constructor.apply(this, arguments);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots/* ButtonWidget extends Widget */
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots BOUNDING_TEMPLATE: Y.ButtonCore.prototype.TEMPLATE,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method initializer
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Internal init() handler.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param config {Object} Config object.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * bindUI implementation
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Hooks up events for the widget
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method bindUI
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots bindUI: function() {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots button.after('labelChange', button._afterLabelChange);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots button.after('disabledChange', button._afterDisabledChange);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots button.after('selectedChange', button._afterSelectedChange);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @method syncUI
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @description
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots syncUI: function() {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @method _setSelected
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @description
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots this.get('contentBox').toggleClass(ButtonWidget.CLASS_NAMES.SELECTED, value).set('aria-pressed', value); // TODO should support aria-checked (if applicable)
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @method _afterLabelChange
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @description
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots * @method _afterDisabledChange
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @description
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @method _afterSelectedChange
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots // Y.Button static properties
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * The identity of the widget.
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @property NAME
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type String
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @default 'button'
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * Static property used to define the default attribute configuration of
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * the Widget.
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @property ATTRS
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @type {Object}
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @protected
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @property HTML_PARSER
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @type {Object}
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @protected
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots return this._getLabel();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots return node.hasClass(ButtonWidget.CLASS_NAMES.SELECTED);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * List of class names used in the ButtonGroup's DOM
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @property CLASS_NAMES
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @type Object
5f40f927dba3cf399373572f6ed6fe59a376376eTodd KlootsY.mix(ButtonWidget.prototype, Y.ButtonCore.prototype);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots* Creates a ToggleButton
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots* @class ToggleButton
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots* @extends ButtonWidget
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots* @param config {Object} Configuration object
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots* @constructor
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots ButtonWidget.superclass.constructor.apply(this, arguments);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots// TODO: move to ButtonCore subclass to enable toggle plugin, widget, etc.
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots/* ButtonWidget extends ButtonWidget */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * bindUI implementation
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * Hooks up events for the widget
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @method bindUI
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bindUI: function() {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots button.get('contentBox').on(button.trigger, button.toggle, button);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method select
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots * @description
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots select: function() {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method unselect
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots unselect: function() {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method toggle
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots toggle: function() {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots button.set('selected', !button.get('selected'));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots}, '@VERSION@' ,{requires:['button-core', 'cssbutton', 'widget']});