nodelist.js revision 8346e283ad797ef549be70335d3961f4324901ba
2223N/A * The NodeList module provides support for managing collections of Nodes. 2223N/A * The NodeList class provides a wrapper for manipulating DOM NodeLists. 2223N/A * NodeList properties can be accessed via the set/get methods. 2223N/A * Use Y.all() to retrieve NodeList instances. * The underlying array of DOM nodes bound to the Y.NodeList instance * Retrieves the DOM nodes bound to a NodeList instance * @param {Y.NodeList} nodelist The NodeList instance * @return {Array} The array of DOM nodes bound to the NodeList Y.
log(
'no nodes bound to ' +
this,
'warn',
'NodeList');
// TODO: remove tmp pointer Y.
log(
'unable to add method: ' +
name +
' to NodeList',
'warn',
'node');
if (
typeof name ===
'string') {
* Retrieves the Node instance at the given index. * @param {Number} index The index of the target Node. * @return {Node} The Node instance at the given index. * Applies the given function to each Node in the NodeList. * @param {Function} fn The function to apply. It receives 3 arguments: * the current node instance, the node's index, and the NodeList instance * @param {Object} context optional An optional context to apply the function with * Default context is the current Node instance * Executes the function once for each node until a true value is returned. * @param {Function} fn The function to apply. It receives 3 arguments: * the current node instance, the node's index, and the NodeList instance * @param {Object} context optional An optional context to execute the function from. * Default context is the current Node instance * @return {Boolean} Whether or not the function returned true for any node. * Creates a documenFragment from the nodes bound to the NodeList instance * @return Node a Node instance bound to the documentFragment * Returns the index of the node in the NodeList instance * or -1 if the node isn't found. * @param {Y.Node || DOMNode} node the node to search for * @return {Int} the index of the node value or -1 if not found * Filters the NodeList instance down to only nodes matching the given selector. * @param {String} selector The selector to filter against * @return {NodeList} NodeList containing the updated collection * Creates a new NodeList containing all nodes at every n indices, where * remainder n % index equals r. * @param {Int} n The offset to use (return every nth node) * @param {Int} r An optional remainder to use with the modulus operation (defaults to zero) * @return {NodeList} NodeList containing the updated collection * Creates a new NodeList containing all nodes at odd indices * @return {NodeList} NodeList containing the updated collection * Creates a new NodeList containing all nodes at even indices * (zero-based index), including zero. * @return {NodeList} NodeList containing the updated collection * Reruns the initial query, when created using a selector query // map to Y.on/after signature (type, fn, nodes, context, arg1, arg2, etc) if (
args.
length <
2) {
// type only (event hash) just add nodes args[
3] =
context ||
this;
// default to NodeList instance as context * Applies an event listener to each Node bound to the NodeList. * @param {String} type The event being listened for * @param {Function} fn The handler to call when the event fires * @param {Object} context The context to call the handler with. * Default is the NodeList instance. * @param {Object} context The context to call the handler with. * param {mixed} arg* 0..n additional arguments to supply to the subscriber * @return {Object} Returns an event handle that can later be use to detach(). * Applies an one-time event listener to each Node bound to the NodeList. * @param {String} type The event being listened for * @param {Function} fn The handler to call when the event fires * @param {Object} context The context to call the handler with. * Default is the NodeList instance. * @return {Object} Returns an event handle that can later be use to detach(). * Applies an event listener to each Node bound to the NodeList. * The handler is called only after all on() handlers are called * and the event is not prevented. * @param {String} type The event being listened for * @param {Function} fn The handler to call when the event fires * @param {Object} context The context to call the handler with. * Default is the NodeList instance. * @return {Object} Returns an event handle that can later be use to detach(). * Returns the current number of items in the NodeList. * @return {Int} The number of items in the NodeList. * Determines if the instance is bound to any nodes * @return {Boolean} Whether or not the NodeList is bound to any nodes * Returns the DOM node bound to the Node instance * Called on each Node instance /** Called on each Node instance * Called on each Node instance /** Called on each Node instance /** Called on each Node instance /** Called on each Node instance /** Called on each Node instance /** Called on each Node instance /** Called on each Node instance /** Called on each Node instance * Makes each node visible. * If the "transition" module is loaded, show optionally * animates the showing of the node using either the default * transition effect ('fadeIn'), or the given named effect. * @param {String} name A named Transition effect to use as the show effect. * @param {Object} config Options to use with the transition. * @param {Function} callback An optional function to run after the transition completes. * If the "transition" module is loaded, hide optionally * animates the hiding of the node using either the default * transition effect ('fadeOut'), or the given named effect. * @param {String} name A named Transition effect to use as the show effect. * @param {Object} config Options to use with the transition. * @param {Function} callback An optional function to run after the transition completes. // one-off implementation to convert array of Nodes to NodeList // e.g. Y.all('input').get('parentNode'); /** Called on each Node instance if (!
isNodeList) {
// convert array of Nodes to NodeList