base.js revision c9871cbdfcd26b5d20932513df38a0f231ddc33f
/**
* Provides an interface for working with button-like DOM nodes
*
* @module button
* @main button
* @since 3.5.0
*/
/**
* Creates a button
*
* @class Button
* @extends Base
* @param config {Object} Configuration object
* @constructor
*/
this._eventsToAssign = {};
}
// -- Private Methods ----------------------------------------------------------
/**
* returns a properly formed yui class name
*
* @method
* @param str {String} string to be appended at the end of class name
* @return
* @private
*/
function makeClassName(str) {
if (str) {
}
else {
}
}
/* Button extends the Base class */
/**
* @method initializer
* @description Internal init() handler.
* @param config {Object} Config object.
* @private
*/
initializer: function(config){
this.renderUI();
this.bindUI();
this.on(this._eventsToAssign);
},
/**
* @method renderUI
* @private
*/
renderUI: function() {
},
/**
* @method bindUI
* @description Assigns any events listeners to Button instances
* @private
*/
bindUI: function() {
var button = this;
if (e.propagate === false) {
}
});
},
/**
* @method getNode
* @description Returns the Button instance's Y.Node instance
* @return {Object} A node instance
*/
getNode: function() {
return this.get('srcNode');
},
/**
* @method select
* @description Sets a Button's 'selected' attribute to true
*/
select: function() {
this.set('selected', true);
},
/**
* @method unselect
* @description Sets a Button's 'selected' attribute to false
*/
unselect: function() {
this.set('selected', false);
},
/**
* @method enable
* @description Sets a Button's 'disabled' attribute to false
*/
enable: function() {
this.set('disabled', false);
},
/**
* @method disable
* @description Sets a Button's 'disabled' attribute to true
*/
disable: function() {
this.set('disabled', true);
},
/**
* @method on
* @description Determines whether to dispatch events to Y.Node (for DOM events) or Y.EventTarget (for everything else)
* @param {String} type The name of the event
* @param {Function} fn The callback to execute in response to the event
* @param {Object} [context] Override this object in callback
* @param {Any} [arg*] 0..n additional arguments to supply to the subscriber
* @return {EventHandle} A subscription handle capable of detaching that subscription
*/
// Loop through each event, recursively calling this.on() with the pair
}, this);
// TODO: This should return a batch of events
}
else {
var button = this;
// Dispatch DOM events to Y.Node, everything else to EventTarget
if (node) {
}
else { // srcNode is not available yet, so store for later assignment
}
}
else {
}
}
},
/**
* @method _labelSetter
* @description A setter method for the label attribute
* @protected
*/
_labelSetter: function (value) {
},
/**
* @method _disabledSetter
* @description A setter method for the disabled attribute
* @protected
*/
_disabledSetter: function (value) {
},
/**
* @method _selectedSetter
* @description A setter method for the selected attribute
* @protected
*/
_selectedSetter: function(value) {
},
/**
* @method _typeSetter
* @description A setter method for the type attribute
* @protected
*/
_typeSetter: function(value) {
var button = this;
if (value === "toggle") {
}, button);
}
else {
if (button._clickHandler) {
button._clickHandler = false;
}
}
}
}, {
/**
* Array of attributes
*
* @property ATTRS
* @type {Array}
* @private
* @static
*/
ATTRS: {
srcNode: {
writeOnce: 'initOnly',
valueFn: function () {
}
},
label: {
lazyAdd: false,
setter: '_labelSetter'
},
type: {
value: 'push',
lazyAdd: false,
setter: '_typeSetter'
},
disabled: {
value: false,
lazyAdd: false,
setter: '_disabledSetter'
},
selected: {
value: false,
lazyAdd: false,
setter: '_selectedSetter'
}
}
});
// -- Static Properties ----------------------------------------------------------
/**
* Name of this component.
*
* @property NAME
* @type String
* @static
*/
/**
* Array of static constants used to identify the classnames applied to the Button DOM objects
*
* @property CLASS_NAMES
* @type {Array}
* @static
*/
Button.CLASS_NAMES = {
button : makeClassName(),
}
// -- Protected Methods ----------------------------------------------------------
/**
* @method _onBlur
* @description An event handler for 'blur' events
* @param e {DOMEvent} the event object
* @protected
*/
};
/**
* @method _onFocus
* @description An event handler for 'focus' events
* @param e {DOMEvent} the event object
* @protected
*/
};
/**
* @method _onMouseUp
* @description An event handler for 'mouseup' events
* @param e {DOMEvent} the event object
* @protected
*/
};
/**
* @method _onMouseDown
* @description An event handler for 'mousedown' events
* @param e {DOMEvent} the event object
* @protected
*/
};
// Export Button