Skip to content

Commit

Permalink
Build
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Mak committed Oct 11, 2014
1 parent 67a7cfc commit 29be76b
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 46 deletions.
4 changes: 2 additions & 2 deletions build/button-core/button-core-coverage.js

Large diffs are not rendered by default.

42 changes: 26 additions & 16 deletions build/button-core/button-core-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ ButtonCore.prototype = {
* @private
*/
_initAttributes: function(config) {
var host = this._host,
node = host.one('.' + ButtonCore.CLASS_NAMES.LABEL) || host;

config.label = config.label || this._getLabel(node);
Y.AttributeCore.call(this, ButtonCore.ATTRS, config);
},

Expand All @@ -91,7 +87,7 @@ ButtonCore.prototype = {

// Set some default node attributes
node.addClass(ButtonCore.CLASS_NAMES.BUTTON);

if (tagName !== 'button' && tagName !== 'input') {
node.set('role', 'button');
}
Expand Down Expand Up @@ -123,31 +119,43 @@ ButtonCore.prototype = {
getNode: function() {
return this._host;
},

/**
* @method _getLabel
* @description Getter for a button's 'label' ATTR
* @private
*/
_getLabel: function () {
var node = this.getNode(),
tagName = node.get('tagName').toLowerCase(),
var node = this.getNode();

return this._getLabelFromNode(node);
},

/**
* @method _getLabelFromNode
* @description Getter for a button's 'label' ATTR
* @param node {Node} The Y.Node instance to obtain the label from
* @return {HTML|String} The label for a given node
* @private
*/
_getLabelFromNode: function (node) {
var tagName = node.get('tagName').toLowerCase(),
label;

if (tagName === 'input') {
label = node.get('value');
}
else {
label = (node.one('.' + ButtonCore.CLASS_NAMES.LABEL) || node).get('text');
label = (node.one('.' + ButtonCore.CLASS_NAMES.LABEL) || node).getHTML();
}

return label;
},

/**
* @method _uiSetLabel
* @description Setter for a button's 'label' ATTR
* @param label {string}
* @param label {HTML|String} The label to set
* @private
*/
_uiSetLabel: function (label) {
Expand All @@ -157,7 +165,7 @@ ButtonCore.prototype = {
if (tagName === 'input') {
node.set('value', label);
} else {
(node.one('.' + ButtonCore.CLASS_NAMES.LABEL) || node).set('text', label);
(node.one('.' + ButtonCore.CLASS_NAMES.LABEL) || node).setHTML(label);
}

return label;
Expand All @@ -171,10 +179,10 @@ ButtonCore.prototype = {
*/
_uiSetDisabled: function(value) {
var node = this.getNode();

node.getDOMNode().disabled = value; // avoid rerunning setter when this === node
node.toggleClass(ButtonCore.CLASS_NAMES.DISABLED, value);

return value;
}
};
Expand All @@ -196,9 +204,10 @@ ButtonCore.ATTRS = {
* The text of the button (the `value` or `text` property)
*
* @attribute label
* @type String
* @type {HTML|String}
*/
label: {
valueFn: '_getLabel',
setter: '_uiSetLabel',
getter: '_getLabel',
lazyAdd: false
Expand Down Expand Up @@ -271,4 +280,5 @@ ButtonCore.ARIA_ROLES = {
// Export Button
Y.ButtonCore = ButtonCore;


}, '@VERSION@', {"requires": ["attribute-core", "classnamemanager", "node-base"]});
2 changes: 1 addition & 1 deletion build/button-core/button-core-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 26 additions & 16 deletions build/button-core/button-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ ButtonCore.prototype = {
* @private
*/
_initAttributes: function(config) {
var host = this._host,
node = host.one('.' + ButtonCore.CLASS_NAMES.LABEL) || host;

config.label = config.label || this._getLabel(node);
Y.AttributeCore.call(this, ButtonCore.ATTRS, config);
},

Expand All @@ -91,7 +87,7 @@ ButtonCore.prototype = {

// Set some default node attributes
node.addClass(ButtonCore.CLASS_NAMES.BUTTON);

if (tagName !== 'button' && tagName !== 'input') {
node.set('role', 'button');
}
Expand Down Expand Up @@ -123,31 +119,43 @@ ButtonCore.prototype = {
getNode: function() {
return this._host;
},

/**
* @method _getLabel
* @description Getter for a button's 'label' ATTR
* @private
*/
_getLabel: function () {
var node = this.getNode(),
tagName = node.get('tagName').toLowerCase(),
var node = this.getNode();

return this._getLabelFromNode(node);
},

/**
* @method _getLabelFromNode
* @description Getter for a button's 'label' ATTR
* @param node {Node} The Y.Node instance to obtain the label from
* @return {HTML|String} The label for a given node
* @private
*/
_getLabelFromNode: function (node) {
var tagName = node.get('tagName').toLowerCase(),
label;

if (tagName === 'input') {
label = node.get('value');
}
else {
label = (node.one('.' + ButtonCore.CLASS_NAMES.LABEL) || node).get('text');
label = (node.one('.' + ButtonCore.CLASS_NAMES.LABEL) || node).getHTML();
}

return label;
},

/**
* @method _uiSetLabel
* @description Setter for a button's 'label' ATTR
* @param label {string}
* @param label {HTML|String} The label to set
* @private
*/
_uiSetLabel: function (label) {
Expand All @@ -157,7 +165,7 @@ ButtonCore.prototype = {
if (tagName === 'input') {
node.set('value', label);
} else {
(node.one('.' + ButtonCore.CLASS_NAMES.LABEL) || node).set('text', label);
(node.one('.' + ButtonCore.CLASS_NAMES.LABEL) || node).setHTML(label);
}

return label;
Expand All @@ -171,10 +179,10 @@ ButtonCore.prototype = {
*/
_uiSetDisabled: function(value) {
var node = this.getNode();

node.getDOMNode().disabled = value; // avoid rerunning setter when this === node
node.toggleClass(ButtonCore.CLASS_NAMES.DISABLED, value);

return value;
}
};
Expand All @@ -196,9 +204,10 @@ ButtonCore.ATTRS = {
* The text of the button (the `value` or `text` property)
*
* @attribute label
* @type String
* @type {HTML|String}
*/
label: {
valueFn: '_getLabel',
setter: '_uiSetLabel',
getter: '_getLabel',
lazyAdd: false
Expand Down Expand Up @@ -271,4 +280,5 @@ ButtonCore.ARIA_ROLES = {
// Export Button
Y.ButtonCore = ButtonCore;


}, '@VERSION@', {"requires": ["attribute-core", "classnamemanager", "node-base"]});
4 changes: 2 additions & 2 deletions build/button/button-coverage.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions build/button/button-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,11 @@ Y.extend(Button, Y.Widget, {
* @static
*/
ATTRS: {

/**
* The text of the button (the `value` or `text` property)
*
* @attribute label
* @type String
* @type {HTML|String}
*/
label: {
value: Y.ButtonCore.ATTRS.label.value
Expand All @@ -149,8 +148,7 @@ Y.extend(Button, Y.Widget, {
*/
HTML_PARSER: {
label: function(node) {
this._host = node; // TODO: remove
return this._getLabel();
return this._getLabelFromNode(node);
},

disabled: function(node) {
Expand Down
2 changes: 1 addition & 1 deletion build/button/button-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions build/button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,11 @@ Y.extend(Button, Y.Widget, {
* @static
*/
ATTRS: {

/**
* The text of the button (the `value` or `text` property)
*
* @attribute label
* @type String
* @type {HTML|String}
*/
label: {
value: Y.ButtonCore.ATTRS.label.value
Expand All @@ -149,8 +148,7 @@ Y.extend(Button, Y.Widget, {
*/
HTML_PARSER: {
label: function(node) {
this._host = node; // TODO: remove
return this._getLabel();
return this._getLabelFromNode(node);
},

disabled: function(node) {
Expand Down

0 comments on commit 29be76b

Please sign in to comment.