3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
7 YUI.add('node-style', function (Y, NAME) {
11 * Extended Node interface for managing node styles.
13 * @submodule node-style
16 Y.mix(Y.Node.prototype, {
18 * Sets a style property of the node.
19 * Use camelCase (e.g. 'backgroundColor') for multi-word properties.
21 * @param {String} attr The style attribute to set.
22 * @param {String|Number} val The value.
25 setStyle: function(attr, val) {
26 Y.DOM.setStyle(this._node, attr, val);
31 * Sets multiple style properties on the node.
32 * Use camelCase (e.g. 'backgroundColor') for multi-word properties.
34 * @param {Object} hash An object literal of property:value pairs.
37 setStyles: function(hash) {
38 Y.DOM.setStyles(this._node, hash);
43 * Returns the style's current value.
44 * Use camelCase (e.g. 'backgroundColor') for multi-word properties.
47 * @param {String} attr The style attribute to retrieve.
48 * @return {String} The current value of the style property for the element.
51 getStyle: function(attr) {
52 return Y.DOM.getStyle(this._node, attr);
56 * Returns the computed value for the given style property.
57 * Use camelCase (e.g. 'backgroundColor') for multi-word properties.
58 * @method getComputedStyle
59 * @param {String} attr The style attribute to retrieve.
60 * @return {String} The computed value of the style property for the element.
62 getComputedStyle: function(attr) {
63 return Y.DOM.getComputedStyle(this._node, attr);
68 * Returns an array of values for each node.
69 * Use camelCase (e.g. 'backgroundColor') for multi-word properties.
73 * @param {String} attr The style attribute to retrieve.
74 * @return {Array} The current values of the style property for the element.
78 * Returns an array of the computed value for each node.
79 * Use camelCase (e.g. 'backgroundColor') for multi-word properties.
80 * @method getComputedStyle
81 * @see Node.getComputedStyle
82 * @param {String} attr The style attribute to retrieve.
83 * @return {Array} The computed values for each node.
87 * Sets a style property on each node.
88 * Use camelCase (e.g. 'backgroundColor') for multi-word properties.
91 * @param {String} attr The style attribute to set.
92 * @param {String|Number} val The value.
97 * Sets multiple style properties on each node.
98 * Use camelCase (e.g. 'backgroundColor') for multi-word properties.
100 * @see Node.setStyles
101 * @param {Object} hash An object literal of property:value pairs.
105 // These are broken out to handle undefined return (avoid false positive for
108 Y.NodeList.importMethod(Y.Node.prototype, ['getStyle', 'getComputedStyle', 'setStyle', 'setStyles']);
112 }, '3.7.2', {"requires": ["dom-style", "node-base"]});