button.js revision bb09a8bcec28d3fcfe6649ea17c5042b68ea1627
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith/**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* A Button Widget
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith*
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* @module button
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* @since 3.5.0
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith*/
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smithvar CLASS_NAMES = Y.ButtonCore.CLASS_NAMES,
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith ARIA_STATES = Y.ButtonCore.ARIA_STATES,
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith ARIA_ROLES = Y.ButtonCore.ARIA_ROLES;
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith/**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* Creates a ButtonWidget
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith*
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* @class ButtonWidget
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* @extends Widget
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* @param config {Object} Configuration object
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* @constructor
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith*/
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smithfunction ButtonWidget(config) {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith ButtonWidget.superclass.constructor.apply(this, arguments);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith}
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith/* ButtonWidget extends Widget */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke SmithY.extend(ButtonWidget, Y.Widget, {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith BOUNDING_TEMPLATE: Y.ButtonCore.prototype.TEMPLATE,
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith CONTENT_TEMPLATE: null,
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @method initializer
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @description Internal init() handler.
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @param config {Object} Config object.
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @private
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith initializer: function(config) {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith this._host = this.get('boundingBox');
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * bindUI implementation
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith *
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @description Hooks up events for the widget
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @method bindUI
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith bindUI: function() {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith var button = this;
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith button.after('labelChange', button._afterLabelChange);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith button.after('disabledChange', button._afterDisabledChange);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @method syncUI
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @description Updates button attributes
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith syncUI: function() {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith var button = this;
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith button._setLabel(button.get('label'));
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith button._setDisabled(button.get('disabled'));
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @method _afterLabelChange
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @private
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith _afterLabelChange: function(e) {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith this._setLabel(e.newVal);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @method _afterDisabledChange
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @private
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith _afterDisabledChange: function(e) {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith this._setDisabled(e.newVal);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith }
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith}, {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith // Y.Button static properties
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * The identity of the widget.
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith *
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @property NAME
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @type String
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @default 'button'
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @readOnly
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @protected
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @static
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith NAME: 'button',
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * Static property used to define the default attribute configuration of
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * the Widget.
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith *
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @property ATTRS
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @type {Object}
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @protected
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @static
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith ATTRS: {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith label: {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith value: Y.ButtonCore.ATTRS.label.value
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith disabled: {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith value: false
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith }
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @property HTML_PARSER
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @type {Object}
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @protected
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @static
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith HTML_PARSER: {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith label: function(node) {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith this._host = node; // TODO: remove
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith return this._getLabel();
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith disabled: function(node) {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith return node.getDOMNode().disabled;
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith }
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * List of class names used in the ButtonGroup's DOM
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith *
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @property CLASS_NAMES
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @type Object
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @static
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith CLASS_NAMES: CLASS_NAMES
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith});
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke SmithY.mix(ButtonWidget.prototype, Y.ButtonCore.prototype);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith/**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* Creates a ToggleButton
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith*
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* @class ToggleButton
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* @extends ButtonWidget
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* @param config {Object} Configuration object
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith* @constructor
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith*/
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smithfunction ToggleButton(config) {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith ButtonWidget.superclass.constructor.apply(this, arguments);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith}
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith// TODO: move to ButtonCore subclass to enable toggle plugin, widget, etc.
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith/* ToggleButton extends ButtonWidget */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke SmithY.extend(ToggleButton, ButtonWidget, {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith trigger: 'click',
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith selectedAttrName: '',
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith initializer: function (config) {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith var button = this,
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith type = button.get('type'),
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith selectedAttrName = (type === "checkbox" ? 'checked' : 'pressed'),
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith selectedState = config[selectedAttrName] || false;
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith // Create the checked/pressed attribute
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith button.addAttr(selectedAttrName, {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith value: selectedState
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith });
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith button.selectedAttrName = selectedAttrName;
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith destructor: function () {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith delete this.selectedAttrName;
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @method bindUI
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @description Hooks up events for the widget
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith bindUI: function() {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith var button = this,
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith cb = button.get('contentBox');
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith ToggleButton.superclass.bindUI.call(button);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith cb.on(button.trigger, button.toggle, button);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith button.after(button.selectedAttrName + 'Change', button._afterSelectedChange);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @method bindUI
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @description Syncs the UI for the widget
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith syncUI: function() {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith var button = this,
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith cb = button.get('contentBox'),
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith type = button.get('type'),
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith ROLES = ToggleButton.ARIA_ROLES,
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith role = (type === 'checkbox' ? ROLES.CHECKBOX : ROLES.TOGGLE),
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith selectedAttrName = button.selectedAttrName;
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith ToggleButton.superclass.syncUI.call(button);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith cb.set('role', role);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith button._uiSetSelected(button.get(selectedAttrName));
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith _afterSelectedChange: function(e){
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith this._uiSetSelected(e.newVal);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @method _uiSetSelected
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @private
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith _uiSetSelected: function(value) {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith var button = this,
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith cb = button.get('contentBox'),
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith STATES = ToggleButton.ARIA_STATES,
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith type = button.get('type'),
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith ariaState = (type === 'checkbox' ? STATES.CHECKED : STATES.PRESSED);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith cb.toggleClass(ButtonWidget.CLASS_NAMES.SELECTED, value);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith cb.set(ariaState, value);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @method toggle
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @description Toggles the selected/pressed/checked state of a ToggleButton
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @public
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith toggle: function() {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith var button = this;
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith button._set(button.selectedAttrName, !button.get(button.selectedAttrName));
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith }
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith}, {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * The identity of the widget.
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith *
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @property NAME
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @type {String}
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @default 'buttongroup'
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @readOnly
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @protected
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @static
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith NAME: 'toggleButton',
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * Static property used to define the default attribute configuration of
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * the Widget.
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith *
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @property ATTRS
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @type {Object}
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @protected
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @static
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith ATTRS: {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith type: {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith value: 'toggle',
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith writeOnce: 'initOnly'
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith }
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @property HTML_PARSER
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @type {Object}
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @protected
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @static
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith HTML_PARSER: {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith checked: function(node) {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith return node.hasClass(CLASS_NAMES.SELECTED);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith pressed: function(node) {
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith return node.hasClass(CLASS_NAMES.SELECTED);
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith }
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith },
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith /**
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @property ARIA_STATES
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @type {Object}
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @protected
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith * @static
5d3dc0444c51f18e44c016a89b16a8951529518cLuke Smith */
ARIA_STATES: ARIA_STATES,
/**
* @property ARIA_ROLES
* @type {Object}
* @protected
* @static
*/
ARIA_ROLES: ARIA_ROLES,
/**
* List of class names used in the ButtonGroup's DOM
*
* @property CLASS_NAMES
* @type Object
* @static
*/
CLASS_NAMES: CLASS_NAMES
});
// Export
Y.Button = ButtonWidget;
Y.ToggleButton = ToggleButton;