button-debug.js revision acbf78fbb0e5ea3c5353314fcbaa6b7e3b82ad7c
/**
* A Button Widget
*
* @module button
* @since 3.5.0
*/
/**
* Creates a ButtonWidget
*
* @class ButtonWidget
* @extends Widget
* @param config {Object} Configuration object
* @constructor
*/
function ButtonWidget(config) {
}
/* ButtonWidget extends Widget */
CONTENT_TEMPLATE: null,
/**
* @method initializer
* @description Internal init() handler.
* @param config {Object} Config object.
* @private
*/
initializer: function(config) {
},
/**
* bindUI implementation
*
* @description Hooks up events for the widget
* @method bindUI
*/
bindUI: function() {
var button = this;
},
/**
* @method syncUI
* @description Updates button attributes
*/
syncUI: function() {
var button = this;
},
/**
* @method _setSelected
* @private
*/
_setSelected: function(value) {
this.get('contentBox').toggleClass(ButtonWidget.CLASS_NAMES.SELECTED, value).set('aria-pressed', value); // TODO should support aria-checked (if applicable)
},
/**
* @method _afterLabelChange
* @private
*/
_afterLabelChange: function(e) {
},
/**
* @method _afterDisabledChange
* @private
*/
_afterDisabledChange: function(e) {
this._setDisabled(e.newVal);
},
/**
* @method _afterSelectedChange
* @private
*/
_afterSelectedChange: function(e) {
this._setSelected(e.newVal);
}
}, {
// Y.Button static properties
/**
* The identity of the widget.
*
* @property NAME
* @type String
* @default 'button'
* @readOnly
* @protected
* @static
*/
NAME: 'button',
/**
* Static property used to define the default attribute configuration of
* the Widget.
*
* @property ATTRS
* @type {Object}
* @protected
* @static
*/
ATTRS: {
label: {
},
disabled: {
value: false
},
selected: {
value: false
}
},
/**
* @property HTML_PARSER
* @type {Object}
* @protected
* @static
*/
HTML_PARSER: {
return this._getLabel();
},
},
}
},
/**
* List of class names used in the ButtonGroup's DOM
*
* @property CLASS_NAMES
* @type Object
* @static
*/
});
/**
* Creates a ToggleButton
*
* @class ToggleButton
* @extends ButtonWidget
* @param config {Object} Configuration object
* @constructor
*/
function ToggleButton(config) {
}
// TODO: move to ButtonCore subclass to enable toggle plugin, widget, etc.
/* ButtonWidget extends ButtonWidget */
trigger: 'click',
/**
* bindUI implementation
*
* Hooks up events for the widget
* @method bindUI
*/
bindUI: function() {
var button = this;
},
/**
* @method select
* @description
* @public
*/
select: function() {
this.set('selected', true);
},
/**
* @method unselect
* @description
* @public
*/
unselect: function() {
this.set('selected', false);
},
/**
* @method toggle
* @description
* @public
*/
toggle: function() {
var button = this;
}
}, {
NAME: 'toggleButton'
});
// Export
Y.Button = ButtonWidget;
Y.ToggleButton = ToggleButton;