node-base-debug.js revision 5770dec23508300b0e77edf1fd63b699b89e4615
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @module node
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @submodule node-base
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Determines whether each node has the given className.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method hasClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to search for
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @return {Boolean} Whether or not the element has the specified class
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Adds a class name to each node.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method addClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to add to the node's class attribute
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Removes a class name from each node.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method removeClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to remove from the node's class attribute
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'removeClass',
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Replace a class with another class for each node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If no oldClassName is present, the newClassName is simply added.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method replaceClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} oldClassName the class name to be replaced
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} newClassName the class name that will be replacing the old class name
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'replaceClass',
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If the className exists on the node it is removed, if it doesn't exist it is added.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method toggleClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to be toggled
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Boolean} force Option to force adding or removing the class.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'toggleClass'
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Determines whether each node has the given className.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method hasClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.hasClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to search for
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @return {Array} An array of booleans for each node bound to the NodeList.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Adds a class name to each node.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method addClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.addClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to add to the node's class attribute
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Removes a class name from each node.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method removeClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.removeClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to remove from the node's class attribute
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Replace a class with another class for each node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If no oldClassName is present, the newClassName is simply added.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method replaceClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.replaceClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} oldClassName the class name to be replaced
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} newClassName the class name that will be replacing the old class name
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If the className exists on the node it is removed, if it doesn't exist it is added.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method toggleClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.toggleClass
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} className the class name to be toggled
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt SweeneyY.NodeList.importMethod(Y.Node.prototype, methods);
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @module node
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @submodule node-base
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Returns a new dom node using the provided markup string.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @method create
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {String} html The markup used to create the element
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {HTMLDocument} doc An optional document context
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @return {Node} A Node instance bound to a DOM node or fragment
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Creates a new Node using the provided markup string.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method create
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} html The markup used to create the element
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {HTMLDocument} doc An optional document context
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @return {Node} A Node instance bound to a DOM node or fragment
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Inserts the content before the reference node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method insert
5770dec23508300b0e77edf1fd63b699b89e4615Luke Smith * @param {String | Node | HTMLElement | NodeList | HTMLCollection} content The content to insert
5770dec23508300b0e77edf1fd63b699b89e4615Luke Smith * @param {Int | Node | HTMLElement | String} where The position to insert at.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Possible "where" arguments
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>Y.Node</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>The Node to insert before</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>HTMLElement</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>The element to insert before</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>Int</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>The index of the child element to insert before</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>"replace"</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>Replaces the existing HTML</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>"before"</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>Inserts before the existing HTML</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>"before"</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>Inserts content before the node</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dt>"after"</dt>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * <dd>Inserts content after the node</dd>
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return this;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney if (content && typeof content != 'string') { // allow Node or NodeList/Array instances
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney content = content._node || content._nodes || content;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Inserts the content as the firstChild of the node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method prepend
5770dec23508300b0e77edf1fd63b699b89e4615Luke Smith * @param {String | Node | HTMLElement} content The content to insert
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Inserts the content as the lastChild of the node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method append
5770dec23508300b0e77edf1fd63b699b89e4615Luke Smith * @param {String | Node | HTMLElement} content The content to insert
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method appendChild
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {String | HTMLElement | Node} node Node to be appended
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @return {Node} The appended node
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method insertBefore
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {String | HTMLElement | Node} newNode Node to be appended
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {HTMLElement | Node} refNode Node to be inserted before
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @return {Node} The inserted node
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return Y.Node.scrubVal(this._insert(newNode, refNode));
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * Appends the node to the given node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method appendTo
5770dec23508300b0e77edf1fd63b699b89e4615Luke Smith * @param {Node | HTMLElement} node The node to append to
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Replaces the node's current content with the content.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method setContent
5770dec23508300b0e77edf1fd63b699b89e4615Luke Smith * @param {String | Node | HTMLElement | NodeList | HTMLCollection} content The content to insert
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * Returns the node's current content (e.g. innerHTML)
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method getContent
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @return {String} The current content
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method append
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.append
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney /** Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method insert
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.insert
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method appendChild
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.appendChild
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'appendChild',
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney /** Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method insertBefore
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.insertBefore
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'insertBefore',
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney /** Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method prepend
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.prepend
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney /** Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method setContent
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.setContent
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'setContent',
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney /** Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method getContent
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.getContent
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'getContent'
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @module node
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @submodule node-base
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Static collection of configuration attributes for special handling
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @property ATTRS
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @type object
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Allows for getting and setting the text of an element.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Formatting is preserved and special characters are treated literally.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @config text
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @type String
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Allows for getting and setting the text of an element.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Formatting is preserved and special characters are treated literally.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @config for
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @type String
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'options': {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return this._node.getElementsByTagName('option');
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Returns a NodeList instance of all HTMLElement children.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @config children
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @type NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'children': {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney for (i = 0, len = childNodes.length; i < len; ++i) {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Allows setting attributes on DOM nodes, normalizing in some cases.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * This passes through to the DOM node, allowing for custom attributes.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method setAttribute
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @chainable
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {string} name The attribute name
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {string} value The value to set
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'setAttribute',
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Allows getting attributes on DOM nodes, normalizing in some cases.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * This passes through to the DOM node, allowing for custom attributes.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method getAttribute
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @for NodeList
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {string} name The attribute name
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @return {string} The attribute value
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'getAttribute'
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @module node
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @submodule node-base
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * List of events that route to DOM events
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @property DOM_EVENTS
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney// Add custom event adaptors to this list. This will make it so
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney// that delegate, key, available, contentready, etc all will
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney// be available through Node.on
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Removes event listeners from the node and (optionally) its subtree
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method purge
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {Boolean} recurse (optional) Whether or not to remove listeners from the
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * node's subtree
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} type (optional) Only remove listeners of the specified type
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney Y.Event.purgeElement(this._node, recurse, type);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // map to Y.on/after signature (type, fn, nodes, context, arg1, arg2, etc)
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (args.length < 2) { // type only (event hash) just add nodes
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass args[3] = context || this; // default to NodeList instance as context
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Applies an event listener to each Node bound to the NodeList.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @method on
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {String} type The event being listened for
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {Function} fn The handler to call when the event fires
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {Object} context The context to call the handler with.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Default is the NodeList instance.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param {Object} context The context to call the handler with.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * param {mixed} arg* 0..n additional arguments to supply to the subscriber
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * when the event fires.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @return {Object} Returns an event handle that can later be use to detach().
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Event.on
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @for NodeList
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return Y.on.apply(Y, this._prepEvtArgs.apply(this, arguments));
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Applies an one-time event listener to each Node bound to the NodeList.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method once
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} type The event being listened for
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {Function} fn The handler to call when the event fires
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {Object} context The context to call the handler with.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Default is the NodeList instance.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @return {Object} Returns an event handle that can later be use to detach().
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Event.on
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return Y.once.apply(Y, this._prepEvtArgs.apply(this, arguments));
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Applies an event listener to each Node bound to the NodeList.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * The handler is called only after all on() handlers are called
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * and the event is not prevented.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method after
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {String} type The event being listened for
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {Function} fn The handler to call when the event fires
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @param {Object} context The context to call the handler with.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Default is the NodeList instance.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @return {Object} Returns an event handle that can later be use to detach().
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Event.on
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return Y.after.apply(Y, this._prepEvtArgs.apply(this, arguments));
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * Applies an one-time event listener to each Node bound to the NodeList
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * that will be called only after all on() handlers are called and the
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * event is not prevented.
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * @method onceAfter
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * @param {String} type The event being listened for
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * @param {Function} fn The handler to call when the event fires
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * @param {Object} context The context to call the handler with.
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * Default is the NodeList instance.
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * @return {Object} Returns an event handle that can later be use to detach().
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith * @see Event.on
74570091844e16d76ff9ff7b8b2ec79fb9c6aa75Luke Smith return Y.onceAfter.apply(Y, this._prepEvtArgs.apply(this, arguments));
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method detach
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.detach
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney /** Called on each Node instance
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method detachAll
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @see Node.detachAll
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney setter: function(h) {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney setter: function(w) {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney getter: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney sizeTo: function(w, h) {
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @module node
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @submodule node-base
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Makes the node visible.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If the "transition" module is loaded, show optionally
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * animates the showing of the node using either the default
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * transition effect ('fadeIn'), or the given named effect.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method show
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {String} name A named Transition effect to use as the show effect.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Object} config Options to use with the transition.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Function} callback An optional function to run after the transition completes.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return this;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * The implementation for showing nodes.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Default is to toggle the style.display property.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method _show
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @protected
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney _show: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return Y.DOM.getStyle(this._node, 'display') === 'none';
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove // base on current state if not forcing
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return this;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Hides the node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If the "transition" module is loaded, hide optionally
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * animates the hiding of the node using either the default
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * transition effect ('fadeOut'), or the given named effect.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method hide
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {String} name A named Transition effect to use as the show effect.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Object} config Options to use with the transition.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Function} callback An optional function to run after the transition completes.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney return this;
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * The implementation for hiding nodes.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Default is to toggle the style.display property.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @method _hide
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @protected
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney _hide: function() {
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Makes each node visible.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If the "transition" module is loaded, show optionally
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * animates the showing of the node using either the default
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * transition effect ('fadeIn'), or the given named effect.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method show
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {String} name A named Transition effect to use as the show effect.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Object} config Options to use with the transition.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Function} callback An optional function to run after the transition completes.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @for NodeList
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * Hides each node.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * If the "transition" module is loaded, hide optionally
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * animates the hiding of the node using either the default
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * transition effect ('fadeOut'), or the given named effect.
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney * @method hide
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {String} name A named Transition effect to use as the show effect.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Object} config Options to use with the transition.
1909339da3105dc509908ff39ecc298f2f94f446Ryan Grove * @param {Function} callback An optional function to run after the transition completes.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @chainable
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney 'toggleView'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glassif (!Y.config.doc.documentElement.hasAttribute) { // IE < 8
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass if (this.get('value') !== "") { // IE < 8 fails to populate specified when set in HTML
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return true;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass// IE throws an error when calling focus() on an element that's invisible, not
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass// displayed, or disabled.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } catch (e) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.log('error focusing node: ' + e.toString(), 'error', 'node');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass// IE throws error when setting input.type = 'hidden',
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass// input.setAttribute('type', 'hidden') and input.attributes.type.value = 'hidden'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } catch(e) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass try { // IE errors when changing the type from "hidden'
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass } catch (e) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass Y.log('error setting type: ' + val, 'info', 'node');
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass getter: function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass _bypassProxy: true // don't update DOM when using with Attribute
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glassif (Y.config.doc.createElement('form').elements.nodeType) {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // IE: elements collection is also FORM node which trips up scrubVal.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass getter: function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return this.all('input, textarea, button, select');
04b64da9f66b8791f4519ebf215ca4ee5771dfe3Matt Sweeney}, '@VERSION@' ,{requires:['dom-base', 'node-core', 'event-base']});