node-class.js revision 78ba6117a752d35df6f2d354cf167c7368026bff
202N/A(function(Y) {
202N/A/**
202N/A * Extended Node interface for managing classNames.
202N/A * @module node
202N/A * @submodule node
202N/A * @for Node
202N/A */
202N/A
202N/A var methods = [
202N/A /**
202N/A * Determines whether each node has the given className.
202N/A * @method hasClass
202N/A * @for Node
202N/A * @param {String} className the class name to search for
202N/A * @return {Array} An array of booleans for each node bound to the NodeList.
202N/A */
202N/A 'hasClass',
202N/A
202N/A /**
202N/A * Adds a class name to each node.
202N/A * @method addClass
202N/A * @param {String} className the class name to add to the node's class attribute
202N/A * @chainable
202N/A */
202N/A 'addClass',
202N/A
202N/A /**
202N/A * Removes a class name from each node.
202N/A * @method removeClass
202N/A * @param {String} className the class name to remove from the node's class attribute
202N/A * @chainable
202N/A */
202N/A 'removeClass',
202N/A
202N/A /**
202N/A * Replace a class with another class for each node.
483N/A * If no oldClassName is present, the newClassName is simply added.
202N/A * @method replaceClass
202N/A * @param {String} oldClassName the class name to be replaced
202N/A * @param {String} newClassName the class name that will be replacing the old class name
202N/A * @chainable
202N/A */
202N/A 'replaceClass',
202N/A
/**
* If the className exists on the node it is removed, if it doesn't exist it is added.
* @method toggleClass
* @param {String} className the class name to be toggled
* @chainable
*/
'toggleClass'
];
Y.Node.importMethod(Y.DOM, methods);
/**
* Determines whether each node has the given className.
* @method hasClass
* @see Node.hasClass
* @for NodeList
* @param {String} className the class name to search for
* @return {Array} An array of booleans for each node bound to the NodeList.
*/
/**
* Adds a class name to each node.
* @method addClass
* @see Node.addClass
* @param {String} className the class name to add to the node's class attribute
* @chainable
*/
/**
* Removes a class name from each node.
* @method removeClass
* @see Node.removeClass
* @param {String} className the class name to remove from the node's class attribute
* @chainable
*/
/**
* Replace a class with another class for each node.
* If no oldClassName is present, the newClassName is simply added.
* @method replaceClass
* @see Node.replaceClass
* @param {String} oldClassName the class name to be replaced
* @param {String} newClassName the class name that will be replacing the old class name
* @chainable
*/
/**
* If the className exists on the node it is removed, if it doesn't exist it is added.
* @method toggleClass
* @see Node.toggleClass
* @param {String} className the class name to be toggled
* @chainable
*/
Y.NodeList.importMethod(Y.Node.prototype, methods);
})(Y);