Class Index | File Index

Classes


Class glow.NodeList


Defined in: core.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
glow.NodeList(contents)
An array-like collection of DOM Nodes It is recommended to create a NodeList using the shortcut function glow.
Field Summary
Field Attributes Field Name and Description
 
Number of nodes in the NodeList
Method Summary
Method Attributes Method Name and Description
 
addClass(name)
Adds a class to each node.
 
after(nodes)
Insert node(s) after each node in this NodeList.
 
ancestors(filter)
Gets the unique ancestor nodes of each node as a new NodeList.
 
anim(duration, properties, opts)
Animate properties of elements All elements in the NodeList are animated All CSS values which are simple numbers (with optional unit) are supported.
 
append(nodes)
Appends node to each node in this NodeList.
 
appendTo(node)
Appends nodes in this NodeList to given node(s) If appending to more than one node, the NodeList is appended to the first node and clones are appended to the others.
 
attr(name, value)
Gets or sets attributes.
 
before(nodes)
Insert node(s) before each node in this NodeList.
 
Gets the child elements of each node as a new NodeList.
 
Clones each node in the NodeList, along with data & event listeners
 
contains(Single)
Find if this NodeList contains the given element
 
copy()
Copies each node in the NodeList, excluding data & event listeners
 
css(property, value)
Get / set a CSS property value
 
Get the currently playing animation added via {@link glow.NodeList#queueAnim queueAnim} for this element If no animation is currently playing, an empty animation is returned.
 
data(key, val)
Use this to safely attach arbitrary data to any DOM Element.
 
delegate(eventName, selector, callback, thisVal)
Listen for an event occurring on child elements matching a selector.
 
Removes each element from the document The element, attached listeners & attached data will be destroyed to free up memory.
 
detach(eventName, callback)
detach a listener from elements This will detach the listener from each dom node in the NodeList.
 
detachDelegate(eventName, selector, callback)
detach a delegated listener from elements This will detach the listener from each dom node in the NodeList.
 
each(callback)
Calls a function for each node in the list.
 
Removes the nodes' contents
 
eq(nodeList)
Compares this NodeList to another Returns true if both NodeLists contain the same items in the same order
 
fadeIn(duration, opts)
Fade elements in If the element is currently fading out, the fadeOut animation will be automatically stopped.
 
fadeOut(duration, opts)
Fade elements out If the element is currently fading in, the fadeIn animation will be automatically stopped.
 
fadeToggle(duration, opts)
Fade elements in/out If the element is currently fading in/out, the fadeIn/fadeOut animation will be automatically stopped.
 
filter(test)
Filter the NodeList
 
fire(eventName, event)
Fire an event on dom nodes within the NodeList Note, this will only trigger event listeners to be called, it won't for example, move the mouse or click a link on the page.
<static>  
glow.NodeList.focusable(opts)
Manage a focusable element, or group of elements This method is a shortcut to glow.ui.Focusable and requires the 'ui' package to be loaded.
 
get(selector)
Gets decendents of nodes that match a CSS selector.
 
hasAttr(name)
Does the node have a particular attribute? The first node in this NodeList is tested.
 
hasClass(name)
Does the node have a particular class? The first node in this NodeList is tested.
 
height(height)
Gets / set element height Return value does not include the padding or border of the element in browsers supporting the correct box model.
 
hide()
Hides all items in the NodeList.
 
html(htmlString)
Gets / sets HTML content Either gets content of the first element, or sets the content for all elements in the list
 
insertAfter(nodes)
Insert this NodeList after the given nodes If inserting after more than one node, the NodeList is inserted after the first node and clones are inserted after the others.
 
insertBefore(nodes)
Insert this NodeList before the given nodes If inserting before more than one node, the NodeList is inserted before the first node and clones are inserted before the others.
 
is(selector)
Tests if the first element matches a CSS selector
 
item(index)
Get a single item from the list as an NodeList Negative numbers can be used to get items from the end of the list.
 
Get the last animation added via {@link glow.NodeList#queueAnim queueAnim} for this element If no animation has been added, an empty animation is returned.
 
next(search)
Gets the next sibling element for each node in the ElementList.
 
Gets the offset from the top left of the document.
 
on(eventName, callback, thisVal)
Listen for an event.
 
parent(search)
Gets the unique parent nodes of each node as a new NodeList.
 
Get the top & left position of an element relative to its positioned parent This is useful if you want to make a position:static element position:absolute and retain the original position of the element
 
prepend(nodes)
Prepends nodes to each node in this NodeList.
 
prependTo(node)
Prepends nodes in this NodeList to given node(s) If prepending to more than one node, the NodeList is prepended to the first node and clones are prepended to the others.
 
prev(search)
Gets the previous sibling element for each node in the ElementList.
 
prop(name, value)
Gets or sets node properties.
 
push(nodes)
Adds nodes to the NodeList
 
queueAnim(duration, Properties, opts)
Queue an animation to run after the current animation All elements in the NodeList are animated This supports the same CSS properties as glow.NodeList#anim, but the animation is not started until the previous animation (added via {@link glow.NodeList#queueAnim queueAnim}) on that element ends.
 
Removes each element from the document If you no longer need the elements, consider using {@link glow.NodeList#destroy destroy}
 
removeAttr(name)
Removes an attribute from each node.
 
Removes a class from each node.
 
Removes data previously added by glow.NodeList#data from each node in this NodeList.
 
replaceWith(elements)
Replace elements with another
 
Gets/sets the number of pixels the element has scrolled horizontally To get/set the scroll position of the window, use this method on a nodelist containing the window object.
 
scrollTop(val)
Gets/sets the number of pixels the element has scrolled vertically To get/set the scroll position of the window, use this method on a nodelist containing the window object.
 
show()
Shows all hidden items in the NodeList.
 
slice(start, end)
Get a section of an NodeList Operates in the same way as an Array's slice method
 
slideOpen(duration, opts)
Slide elements open This animates an element's height from its current height to its full auto-height size.
 
slideShut(duration, opts)
Slide elements shut This animates an element's height from its current height to zero.
 
slideToggle(duration, opts)
Slide elements open/shut If the element is currently sliding open/shut, the slideOpen/slideShut animation will be automatically stopped.
 
sort(func)
Sort the elements in the list.
 
text(text)
Gets / set the text content Either gets content of the first element, or sets the content for all elements in the list
 
Toggles a class on each node.
 
Removes the parent of each item in the list
 
val(value)
Gets or sets form values for the first node.
 
width(width)
Gets / set element width Return value does not include the padding or border of the element in browsers supporting the correct box model.
 
wrap(wrapper)
Wraps the given NodeList with the specified element(s).
Event Summary
Event Attributes Event Name and Description
 
keydown(event)
Fires when the user presses a key Only fires if the element has focus, listen for this event on the document to catch all keydowns.
 
keypress(event)
Fires when a key's command executes.
 
keyup(event)
Fires when the user releases a key Only fires if the element has focus, listen for this event on the document to catch all keyups.
 
mouseenter(event)
Fires when the mouse enters the element specifically, does not bubble
 
mouseleave(event)
Fires when the mouse leaves the element specifically, does not bubble
Class Detail
glow.NodeList(contents)
An array-like collection of DOM Nodes It is recommended to create a NodeList using the shortcut function glow.
			// empty NodeList
			var myNodeList = glow();
			// using glow to return a NodeList then chaining methods
			glow('p').addClass('eg').append('
Hello!
');
			// creating an element from a string
			glow('
Hello!
').appendTo('body');
Parameters:
{string | glow.NodeList | Node | Node[] | Window} contents
Items to populate the NodeList with. This parameter will be passed to glow.NodeList#push. Strings will be treated as CSS selectors unless they start with '<', in which case they'll be treated as an HTML string.
See:
Supported CSS selectors
Field Detail
{Number} length
Number of nodes in the NodeList
			// get the number of paragraphs on the page
			glow('p').length;
Method Detail
{glow.NodeList} addClass(name)
Adds a class to each node.
		glow("#login a").addClass("highlight");
Parameters:
{string} name
The name of the class to add.
Returns:
{glow.NodeList}

{glow.NodeList} after(nodes)
Insert node(s) after each node in this NodeList. If there is more than one node in this NodeList, 'nodes' will be inserted after the first element and clones will be inserted after each subsequent element.
			// adds a paragraph after each heading
			glow('h1, h2, h3').after('

That was a nice heading.

');
Parameters:
{string | HTMLElement | HTMLElement[] | glow.NodeList} nodes
Node(s) to insert Strings will be treated as HTML strings.
Returns:
{glow.NodeList} Original NodeList

{glow.dom.NodeList} ancestors(filter)
Gets the unique ancestor nodes of each node as a new NodeList.
		// get ancestor elements for anchor elements 
		var ancestors = glow.dom.get("a").ancestors();
Parameters:
{Function|string} filter Optional
Filter test If a string is provided, it is used in a call to {@link glow.ElementList#is ElementList#is}. If a function is provided it will be passed 2 arguments, the index of the current item, and the ElementList being itterated over. Inside the function 'this' refers to the HTMLElement. Return true to keep the node, or false to remove it.
Returns:
{glow.dom.NodeList} Returns NodeList

{glow.anim.Anim} anim(duration, properties, opts)
Animate properties of elements All elements in the NodeList are animated All CSS values which are simple numbers (with optional unit) are supported. Eg: width, margin-top, left All CSS values which are space-separated values are supported (eg background-position, margin, padding), although a 'from' value must be provided for short-hand properties like 'margin'. All CSS colour values are supported. Eg: color, background-color. 'scrollLeft' and 'scrollTop' can be animated for elements and the window object. Other properties, including CSS properties with limited support, can be animated using glow.anim.Anim#prop.
			// change the nav's background colour to white and the top position
			// to 20px over a duration of 3 seconds
			glow('#nav').anim(3, {
				'background-color': '#fff',
				'top': 20
			});
			// Fade an element out and alert 'done' when complete
			glow('#nav').anim(3, {
				'opacity': 0
			}).on('complete', function() {
				alert('done!');
			});
			// Scroll the window to the top
			glow(window).anim(2, {
				scrollTop: 0
			});
Parameters:
{number} duration
Length of the animation in seconds.
{Object} properties
Properties to animate. This is an object where the key is the CSS property and the value is the value to animate to. The value can also be an array, where the first item is the value to animate from, and the second is the value to animate to. Numerical values will be treated as 'px' if the property requires units.
{Object} opts Optional
Options object
{function|string} opts.tween Optional, Default: 'easeBoth'
The motion of the animation. Strings are treated as properties of glow.tweens, although a tween function can be provided.
{boolean} opts.destroyOnComplete Optional, Default: true
Destroy the animation once it completes (unless it loops). This will free any DOM references the animation may have created. Once the animation is destroyed, it cannot be started again.
{boolean} opts.loop Optional, Default: true
Loop the animation.
{boolean} opts.startNow Optional, Default: true
Start the animation straight away? Animations can be started by calling glow.anim.Anim#start
Returns:
{glow.anim.Anim}
See:
- Queue an animation to run after the current anim
- Shortcut to fade elements in
- Shortcut to fade elements out
- Shortcut to toggle the fade of an element
- Shortcut to slide an element open
- Shortcut to slide an element shut
- Shortcut to toggle an element open / shut

{glow.NodeList} append(nodes)
Appends node to each node in this NodeList. If there is more than one node in this NodeList, then the given nodes are appended to the first node and clones are appended to the other nodes.
			// ends every paragraph with '...'
			glow('p').append('...');
Parameters:
{string | HTMLElement | HTMLElement[] | glow.NodeList} nodes
Nodes(s) to append Strings will be treated as HTML strings.
Returns:
{glow.NodeList} Original NodeList

{glow.NodeList} appendTo(node)
Appends nodes in this NodeList to given node(s) If appending to more than one node, the NodeList is appended to the first node and clones are appended to the others.
			// appends '...' to every paragraph
			glow('...').appendTo('p');
Parameters:
{string | HTMLElement | HTMLElement[] | glow.NodeList} node
Node(s) to append to. Strings will be treated as CSS selectors or HTML strings.
Returns:
{glow.NodeList} The appended nodes.

{string | undefined | glow.NodeList} attr(name, value)
Gets or sets attributes. When getting an attribute, it is retrieved from the first node in this NodeList. Setting attributes applies the change to each element in this NodeList. To set an attribute, pass in the name as the first parameter and the value as a second parameter. To set multiple attributes in one call, pass in an object of name/value pairs as a single parameter. For browsers that don't support manipulating attributes using the DOM, this method will try to do the right thing (i.e. don't expect the semantics of this method to be consistent across browsers as this is not possible with currently supported browsers).
		var myNodeList = glow(".myImgClass");

		// get an attribute
		myNodeList.attr("class");

		// set an attribute
		myNodeList.attr("class", "anotherImgClass");

		// set multiple attributes
		myNodeList.attr({
		  src: "a.png",
		  alt: "Cat jumping through a field"
		});
Parameters:
{string | Object} name
The name of the attribute, or an object of name/value pairs
{string} value Optional
The value to set the attribute to.
Returns:
{string | undefined | glow.NodeList} When setting attributes this method returns its own NodeList, otherwise returns the attribute value. The attribute name is always treated as case-insensitive. When getting, the returned value will be of type string unless that particular attribute was never set and there is no default value, in which case the returned value will be an empty string.

{glow.NodeList} before(nodes)
Insert node(s) before each node in this NodeList. If there is more than one node in this NodeList, 'nodes' will be inserted before the first element and clones will be inserted before each subsequent element.
			// adds a div before each paragraph
			glow('p').before('
Here comes a paragraph!
');
Parameters:
{string | HTMLElement | HTMLElement[] | glow.NodeList} nodes
Node(s) to insert Strings will be treated as HTML strings.
Returns:
{glow.NodeList} Original NodeList

{glow.dom.NodeList} children()
Gets the child elements of each node as a new NodeList.
		// get all list items
		var items = glow.dom.get("ul, ol").children();
Returns:
{glow.dom.NodeList} Returns a new NodeList containing all the child nodes

{glow.NodeList} clone()
Clones each node in the NodeList, along with data & event listeners
			// get a copy of all heading elements
			var myClones = glow.get("h1, h2, h3, h4, h5, h6").clone();
Returns:
{glow.NodeList} Returns a new NodeList containing clones of all the nodes in the NodeList

{boolean} contains(Single)
Find if this NodeList contains the given element
Parameters:
{string | HTMLELement | NodeList} Single
element to check for
Returns:
{boolean} myElementList.contains(elm) // Returns true if an element in myElementList contains elm, or IS elm.

{glow.NodeList} copy()
Copies each node in the NodeList, excluding data & event listeners
			// get a copy of all heading elements
			var myCopies = glow.get("h1, h2, h3, h4, h5, h6").copy();
Returns:
{glow.NodeList} Returns a new NodeList containing copies of all the nodes in the NodeList

{glow.NodeList | string} css(property, value)
Get / set a CSS property value
		// get value from first node
		glow('#subNav').css('display');
		// set left padding to 10px on all nodes
		glow('#subNav li').css('padding-left', '2em');
		// where appropriate, px is assumed when no unit is passed
		glow('#mainPromo').css('margin-top', 300);
		// set multiple CSS values at once
		// NOTE: Property names containing a hyphen such as font-weight must be quoted
		glow('#myDiv').css({
			'font-weight': 'bold',
			'padding'	 : '10px',
			'color'		 : '#00cc99'
		});
Parameters:
{string | Object} property
The CSS property name, or object of property-value pairs to set
{string | number} value Optional
The value to apply Number values will be treated as 'px' unless the CSS property accepts a unitless value. If value is omitted, the value for the given property will be returned
Returns:
{glow.NodeList | string} Returns the NodeList when setting value, or the CSS value when getting values. CSS values are strings. For instance, "height" will return "25px" for an element 25 pixels high. You can use parseInt to convert these values.

{glow.anim.Anim} currentAnim()
Get the currently playing animation added via {@link glow.NodeList#queueAnim queueAnim} for this element If no animation is currently playing, an empty animation is returned. This means you don't need to check to see if the item is defined before calling methods on it. This method acts on the first item in the NodeList.
			// stopping and clearing current animation queue.
			// The next animation created via queueAnim will start
			// immediately
			glow('#elementToAnimate').curentAnim().stop();
			// Is the element animating as part of queueAnim?
			glow('#elementToAnimate').curentAnim().playing; // true/false
Returns:
{glow.anim.Anim}

{Object} data(key, val)
Use this to safely attach arbitrary data to any DOM Element. This method is useful when you wish to avoid memory leaks that are possible when adding your own data directly to DOM Elements. When called with no arguments, will return glow's entire data store for the first node in this NodeList. Otherwise, when given a name, will return the associated value from the first node in this NodeList. When given both a name and a value, will store that data on every node in this NodeList. Optionally you can pass in a single object composed of multiple name, value pairs.
	
	glow("p").data("tea", "milky");
	var colour = glow("p").data("tea"); // milky
Parameters:
{string|Object} key Optional
The name of the value in glow's data store.
{Object} val Optional
The value you wish to associate with the given name.
Returns:
{Object} When setting a value this method can be chained, as in that case it will return itself.
See:
glow.NodeList#removeData
glow.NodeList#removeData

delegate(eventName, selector, callback, thisVal)
Listen for an event occurring on child elements matching a selector. 'delegate' will catch events which occur on matching items created after the listener was added.
			// Using 'on' to catch clicks on links in a list
			glow.get('#nav a').on('click', function() {
				// do stuff
			});
			
			// The above adds a listener to each link, any links created later
			// will not have this listener, so we won't hear about them.
			
			// Using 'delegate' to catch clicks on links in a list
			glow.get('#nav').delegate('click', 'a', function() {
				// do stuff
			});
			
			// The above only adds one listener to #nav which tracks clicks
			// to any links within. This includes elements created after 'delegate'
			// was called.
			// Using delegate to change class names on table rows so :hover
			// behaviour can be emulated in IE6
			glow.get('#contactData').delegate('mouseover', 'tr', function() {
				glow.get(this).addClass('hover');
			});
			
			glow.get('#contactData').delegate('mouseout', 'tr', function() {
				glow.get(this).removeClass('hover');
			});
Parameters:
{String} eventName
Name of the event to listen for. This can be any regular DOM event ('click', 'mouseover' etc) or a special event of NodeList.
{String} selector
CSS selector of child elements to listen for events on For example, if you were wanting to hear events from links, this would be 'a'.
{Function} callback
Function to call when the event fires. The callback is passed a single event object. The type of this object is glow.DomEvent unless otherwise stated.
{Object} thisVal Optional
Value of 'this' within the callback. By default, this is the dom node matched by 'selector'.
Returns:
this

destroy()
Removes each element from the document The element, attached listeners & attached data will be destroyed to free up memory. Detroyed elements may not be reused in some browsers.
			// destroy all links in the document
			glow("a").destroy();
Returns:
undefined

detach(eventName, callback)
detach a listener from elements This will detach the listener from each dom node in the NodeList.
			function clickListener(domEvent) {
				// ...
			}
			
			// adding listeners
			glow.get('a').on('click', clickListener);
			
			// removing listeners
			glow.get('a').detach('click', clickListener);
Parameters:
{String} eventName
Name of the event to detach the listener from
{Function} callback
Listener callback to detach
Returns:
this

detachDelegate(eventName, selector, callback)
detach a delegated listener from elements This will detach the listener from each dom node in the NodeList.
			function clickListener(domEvent) {
				// ...
			}
			
			// adding listeners
			glow.get('#nav').delegate('click', 'a', clickListener);
			
			// removing listeners
			glow.get('#nav').detachDelegate('click', 'a', clickListener);
Parameters:
{String} eventName
Name of the event to detach the listener from
{String} selector
CSS selector of child elements the listener is listening to
{Function} callback
Listener callback to detach
Returns:
this

{glow.NodeList} each(callback)
Calls a function for each node in the list.
			// add "link number: x" to each link, where x is the index of the link
			glow("a").each(function(i, nodeList) {
				glow(this).append(' link number: ' + i);
			});
			// breaking out of an each loop
			glow("a").each(function(i, nodeList) {
				// do stuff
				if ( glow(this).hasClass('whatever') ) {
					// we don't want to process any more links
					return false;
				}
			});
Parameters:
{Function} callback
The function to call for each node. The function will be passed 2 arguments, the index of the current item, and the NodeList being iterated over. Inside the function 'this' refers to the Node. Returning false from this function stops further iterations
Returns:
{glow.NodeList}

{glow.NodeList} empty()
Removes the nodes' contents
			// remove the contents of all textareas
			glow("textarea").empty();
Returns:
{glow.NodeList} Original nodes

{boolean} eq(nodeList)
Compares this NodeList to another Returns true if both NodeLists contain the same items in the same order
			// the following returns true
			glow('#blah').eq( document.getElementById('blah') );
Parameters:
{Node | Node[] | glow.NodeList} nodeList
The NodeList to compare to.
Returns:
{boolean}
See:
for testing if a NodeList item matches a selector

{glow.NodeList} fadeIn(duration, opts)
Fade elements in If the element is currently fading out, the fadeOut animation will be automatically stopped.
			// make a tooltip fade in & out
			var tooltip = glow('#emailTooltip');
			
			glow('#emailInput').on('focus', function() {
				tooltip.fadeIn();
			}).on('blur', function() {
				tooltip.fadeOut();
			});
Parameters:
{number} duration Optional, Default: 1
Duration in seconds
{Object} opts Optional
Options object
{function|string} opts.tween Optional, Default: 'easeOut'
The motion of the animation. Strings are treated as properties of glow.tweens, although a tween function can be provided.
Returns:
{glow.NodeList}

{glow.NodeList} fadeOut(duration, opts)
Fade elements out If the element is currently fading in, the fadeIn animation will be automatically stopped.
			// make a tooltip fade in & out
			var tooltip = glow('#emailTooltip');
			
			glow('#emailInput').on('focus', function() {
				tooltip.fadeIn();
			}).on('blur', function() {
				tooltip.fadeOut();
			});
Parameters:
{number} duration Optional, Default: 1
Duration in seconds
{Object} opts Optional
Options object
{function|string} opts.tween Optional, Default: 'easeIn'
The motion of the animation. Strings are treated as properties of glow.tweens, although a tween function can be provided.
Returns:
{glow.NodeList}

{glow.NodeList} fadeToggle(duration, opts)
Fade elements in/out If the element is currently fading in/out, the fadeIn/fadeOut animation will be automatically stopped. // Implementation note: (delete me later) If the element has an opactity of 0, then fade in, otherwise fade out. UNLESS there's fadeOut animation currently happening on this element, then fade in.
			// make a tooltip fade in & out
			var tooltip = glow('#emailTooltip');
			
			glow('#toggleTooltip').on('click', function() {
				tooltip.fadeToggle();
			});
Parameters:
{number} duration Optional, Default: 1
Duration in seconds
{Object} opts Optional
Options object
{function|string} opts.tween Optional
The motion of the animation. Strings are treated as properties of glow.tweens, although a tween function can be provided. By default, 'easeIn' is used for fading out, and 'easeOut' is used for fading in.
Returns:
{glow.NodeList}

{glow.NodeList} filter(test)
Filter the NodeList
			// return images with a width greater than 320
			glow("img").filter(function () {
				return glow(this).width() > 320;
			});
			// Get items that don't have an alt attribute
			myElementList.filter(':not([alt])');
Parameters:
{Function|string} test
Filter test If a string is provided it's treated as a CSS selector. Elements which match the CSS selector are added to the new NodeList. If 'test' is a function, it will be called per node in the NodeList. The function is passed 2 arguments, the index of the current item, and the ElementList being itterated over. Inside the function 'this' refers to the node. Return true to add the element to the new NodeList.
Returns:
{glow.NodeList} A new NodeList containing the filtered nodes

fire(eventName, event)
Fire an event on dom nodes within the NodeList Note, this will only trigger event listeners to be called, it won't for example, move the mouse or click a link on the page.
		   glow.get('#testLink').on('click', function() {
			   alert('Link clicked!');
		   });
		   
		   // The following causes 'Link clicked!' to be alerted, but doesn't
		   // cause the browser to follow the link
		   glow.get('#testLink').fire('click');
Parameters:
{String} eventName
Name of the event to fire
{glow.events.Event} event Optional
Event object to pass into listeners. You can provide a simple object of key / value pairs which will be added as properties of a glow.events.Event instance.
Returns:
glow.events.Event

<static> {glow.ui.Focusable} glow.NodeList.focusable(opts)
Manage a focusable element, or group of elements This method is a shortcut to glow.ui.Focusable and requires the 'ui' package to be loaded. The first item in the NodeList is treated as the focusable's container. An error is thrown if the first item in the NodeList is not an element. This can be used to create a single focus point for a set of focusable elements. Eg, a menu can have a single tab stop, and the arrow keys can be used to cycle through menu items. This means the user doesn't have to tab through every item in the menu to get to the next set of focusable items. The FocusManager can also be used to make a element 'modal', ensuring focus doesn't go to elements outside it.
Defined in: ui.js.
Parameters:
{object} opts Optional
Options The same options as the glow.ui.Focusable constructor
Returns:
{glow.ui.Focusable}

{glow.NodeList} get(selector)
Gets decendents of nodes that match a CSS selector.
		// create a new NodeList
		var myNodeList = glow.dom.create("
Link
"); // get 'a' tags that are decendants of the NodeList nodes myNewNodeList = myNodeList.get("a");
Parameters:
{String} selector
CSS selector
Returns:
{glow.NodeList} Returns a new NodeList containing matched elements

{boolean|undefined} hasAttr(name)
Does the node have a particular attribute? The first node in this NodeList is tested.
		if ( glow("#myImg").hasAttr("alt") ){
			// ...
		}
Parameters:
{string} name
The name of the attribute to test for.
Returns:
{boolean|undefined} Returns undefined if the first node is not an element, or if the NodeList is empty, otherwise returns true/false to indicate if that attribute exists on the first element.

{boolean} hasClass(name)
Does the node have a particular class? The first node in this NodeList is tested.
		if ( glow("#myInput").hasClass("errored") ){
			// ...
		}
Parameters:
{string} name
The name of the class to test for.
Returns:
{boolean}

{glow.NodeList | number} height(height)
Gets / set element height Return value does not include the padding or border of the element in browsers supporting the correct box model. You can use this to easily get the height of the document or window, see example below.
		// get the height of #myDiv
		glow("#myDiv").height();
		// set the height of list items in #myList to 200 pixels
		glow("#myList > li").height(200);
		// get the height of the document
		glow(document).height();
		// get the height of the window
		glow(win).height();
Parameters:
{Number} height Optional
New height in pixels for each element in the list If ommited, the height of the first element is returned
Returns:
{glow.NodeList | number} Height of first element, or original NodeList when setting heights.

{glow.NodeList} hide()
Hides all items in the NodeList.
		// Hides all list items within #myList
		glow("#myList li").hide();
Returns:
{glow.NodeList}

{glow.NodeList | string} html(htmlString)
Gets / sets HTML content Either gets content of the first element, or sets the content for all elements in the list
			// get the html in #footer
			var footerContents = glow("#footer").html();
			// set a new footer
			glow("#footer").html("Hello World!");
Parameters:
{String} htmlString Optional
String to set as the HTML of elements If omitted, the html for the first element in the list is returned.
Returns:
{glow.NodeList | string} Returns the original NodeList when setting, or the HTML content when getting.

{glow.NodeList} insertAfter(nodes)
Insert this NodeList after the given nodes If inserting after more than one node, the NodeList is inserted after the first node and clones are inserted after the others.
			// adds a paragraph after each heading
			glow('

HAI!

').insertAfter('h1, h2, h3');
Parameters:
{string | HTMLElement | HTMLElement[] | glow.NodeList} nodes
Node(s) to insert after Strings will be treated as CSS selectors.
Returns:
{glow.NodeList} Inserted nodes.

{glow.NodeList} insertBefore(nodes)
Insert this NodeList before the given nodes If inserting before more than one node, the NodeList is inserted before the first node and clones are inserted before the others.
			// adds a div before each paragraph
			glow('
Here comes a paragraph!
').insertBefore('p');
Parameters:
{string | HTMLElement | HTMLElement[] | glow.NodeList} nodes
Node(s) to insert before Strings will be treated as CSS selectors.
Returns:
{glow.NodeList} Inserted nodes.

{boolean} is(selector)
Tests if the first element matches a CSS selector
			if ( myNodeList.is(':visible') ) {
				// ...
			}
Parameters:
{string} selector
CSS selector
Returns:
{boolean}

{glow.NodeList} item(index)
Get a single item from the list as an NodeList Negative numbers can be used to get items from the end of the list.
			// get the html from the fourth element
			myNodeList.item(3).html();
			// add a class name to the last item
			myNodeList.item(-1).addClass('last');
Parameters:
{number} index
The numeric index of the node to return.
Returns:
{glow.NodeList} A new NodeList containing a single item

{glow.anim.Anim} lastQueuedAnim()
Get the last animation added via {@link glow.NodeList#queueAnim queueAnim} for this element If no animation has been added, an empty animation is returned. This means you don't need to check to see if the item is defined before calling methods on it. This method acts on the first item in the NodeList.
Returns:
{glow.anim.Anim}

{glow.ElementList} next(search)
Gets the next sibling element for each node in the ElementList. If a filter is provided, the next item that matches the filter is returned, or none if no match is found.
		// gets the element following #myLink (if there is one)
		var next = glow.get("#myLink").next();
		// get the next sibling link element after #skipLink
		glow.get('#skipLink').next('a')
Parameters:
{string | HTMLElement | NodeList} search Optional
Search value If provided, will seek the next sibling element until a match is found
Returns:
{glow.ElementList} A new ElementList containing the next sibling elements that match the (optional) filter.

{Object} offset()
Gets the offset from the top left of the document. If the NodeList contains multiple items, the offset of the first item is returned.
		glow("#myDiv").offset().top
Returns:
{Object} Returns an object with "top" & "left" properties in pixels

on(eventName, callback, thisVal)
Listen for an event. This will listen for a particular event on each dom node in the NodeList. If you're listening to many children of a particular item, you may get better performance from glow.NodeList#delegate.
		   glow.get('#testLink').on('click', function(domEvent) {
			   // do stuff
			   
			   // if you want to cancel the default action (following the link)...
			   return false;
		   });
Parameters:
{String} eventName
Name of the event to listen for. This can be any regular DOM event ('click', 'mouseover' etc) or a special event of NodeList.
{Function} callback
Function to call when the event fires. The callback is passed a single event object. The type of this object is glow.DomEvent unless otherwise stated.
{Object} thisVal Optional
Value of 'this' within the callback. By default, this is the dom node being listened to.
Returns:
this

{glow.NodeList} parent(search)
Gets the unique parent nodes of each node as a new NodeList.
		// elements which contain links
		var parents = glow.dom.get("a").parent();
Parameters:
{string | HTMLElement | NodeList} search Optional
Search value If provided, will seek the next parent element until a match is found
Returns:
{glow.NodeList} Returns a new NodeList containing the parent nodes, with duplicates removed

{Object} position()
Get the top & left position of an element relative to its positioned parent This is useful if you want to make a position:static element position:absolute and retain the original position of the element
		// get the top distance from the positioned parent
		glow("#elm").position().top
Returns:
{Object} An object with 'top' and 'left' number properties

{glow.NodeList} prepend(nodes)
Prepends nodes to each node in this NodeList. If there is more than one node in this NodeList, then the given nodes are prepended to the first node and clones are prepended to the other nodes.
			// prepends every paragraph with 'Paragraph: '
			glow('p').prepend('Paragraph: ');
Parameters:
{string | HTMLElement | HTMLElement[] | glow.NodeList} nodes
Nodes(s) to prepend Strings will be treated as HTML strings.
Returns:
{glow.NodeList} Original NodeList

{glow.NodeList} prependTo(node)
Prepends nodes in this NodeList to given node(s) If prepending to more than one node, the NodeList is prepended to the first node and clones are prepended to the others.
			// prepends 'Paragraph: ' to every paragraph
			glow('Paragraph: ').prependTo('p');
Parameters:
{string | HTMLElement | HTMLElement[] | glow.NodeList} node
Node(s) to prepend to Strings will be treated as CSS selectors or HTML strings.
Returns:
{glow.NodeList} The prepended nodes.

{glow.ElementList} prev(search)
Gets the previous sibling element for each node in the ElementList. If a filter is provided, the previous item that matches the filter is returned, or none if no match is found.
		// gets the element before #myLink (if there is one)
		var next = glow.get("#myLink").prev();
		// get the previous sibling link element before #skipLink
		glow.get('#skipLink').prev('a')
Parameters:
{string | HTMLElement | NodeList} search Optional
Search value If provided, will seek the previous sibling element until a match is found
Returns:
{glow.ElementList} A new ElementList containing the previous sibling elements that match the (optional) filter.

{string | glow.NodeList} prop(name, value)
Gets or sets node properties. This function gets / sets node properties, to get attributes, see {@link glow.NodeList#attr NodeList#attr}. When getting a property, it is retrieved from the first node in this NodeList. Setting properties to each element in this NodeList. To set multiple properties in one call, pass in an object of name/value pairs.
		var myNodeList = glow("#formElement");

		// get the node name
		myNodeList.prop("nodeName");

		// set a property
		myNodeList.prop("_secretValue", 10);

		// set multiple properties
		myNodeList.prop({
			checked: true,
			_secretValue: 10
		});
Parameters:
{string | Object} name
The name of the property, or an object of name/value pairs
{string} value Optional
The value to set the property to.
Returns:
{string | glow.NodeList} When setting properties it returns the NodeList, otherwise returns the property value.

{glow.NodeList} push(nodes)
Adds nodes to the NodeList
			myNodeList.push('
Foo
').push('h1');
Parameters:
{string | Node | Node[] | glow.NodeList} nodes
Node(s) to add to the NodeList Strings will be treated as CSS selectors or HTML strings.
Returns:
{glow.NodeList}

{glow.NodeList} queueAnim(duration, Properties, opts)
Queue an animation to run after the current animation All elements in the NodeList are animated This supports the same CSS properties as glow.NodeList#anim, but the animation is not started until the previous animation (added via {@link glow.NodeList#queueAnim queueAnim}) on that element ends. If there are no queued animations on the element, the animation starts straight away.
			// change a nav item's background colour from white to yellow
			// when the mouse is over it, and back again when the mouse
			// exits.
			glow('#nav').delegate('mouseenter', 'li', function() {
				glow(this).queueAnim(0.5, {
					'background-color': 'yellow'
				});
			}).delegate('mouseleave', 'li', function() {
				glow(this).queueAnim(0.5, {
					'background-color': 'white'
				});
			});
			// adding listeners to a queued anim
			glow('#elementToAnimate').queueAnim(0.5, {
				height: 0
			}).lastQueuedAnim().on('complete', function() {
				alert('Animation complete!');
			});
			// stopping and clearing current animation queue.
			// The next animation created via queueAnim will start
			// immediately
			glow('#elementToAnimate').curentAnim().stop();
Parameters:
{number} duration
Length of the animation in seconds.
{Object} Properties
to animate. This is an object where the key is the CSS property and the value is the value to animate to. The value can also be an array, where the first item is the value to animate from, and the second is the value to animate to. Numerical values will be treated as 'px' if the property requires units.
{Object} opts Optional
Options object
{function|string} opts.tween Optional, Default: 'easeBoth'
The motion of the animation. Strings are treated as properties of glow.tweens, although a tween function can be provided.
{boolean} opts.destroyOnComplete Optional, Default: true
Destroy the animation once it completes (unless it loops). This will free any DOM references the animation may have created. Once the animation is destroyed, it cannot be started again.
Returns:
{glow.NodeList}
See:
- Shortcut to fade elements in
- Shortcut to fade elements out
- Shortcut to toggle the fade of an element
- Shortcut to slide an element open
- Shortcut to slide an element shut
- Shortcut to toggle an element open / shut

{glow.NodeList} remove()
Removes each element from the document If you no longer need the elements, consider using {@link glow.NodeList#destroy destroy}
			// take all the links out of a document
			glow("a").remove();
Returns:
{glow.NodeList} The removed elements

{glow.NodeList} removeAttr(name)
Removes an attribute from each node.
		glow("a").removeAttr("target");
Parameters:
{string} name
The name of the attribute to remove.
Returns:
{glow.NodeList}

{glow.NodeList} removeClass(name)
Removes a class from each node.
		glow("#footer #login a").removeClass("highlight");
Parameters:
{string} name
The name of the class to remove.
Returns:
{glow.NodeList}

removeData(key)
Removes data previously added by glow.NodeList#data from each node in this NodeList. When called with no arguments, will delete glow's entire data store for each node in this NodeList. Otherwise, when given a name, will delete the associated value from each node in this NodeList.
Parameters:
{string} key Optional
The name of the value in glow's data store.
See:
glow.NodeList#data

{glow.NodeList} replaceWith(elements)
Replace elements with another
Parameters:
{string | HTMLElement | HTMLElement[] | glow.NodeList} elements
Element(s) to insert into the document If there is more than one element in the NodeList, then the given elements replace the first element, clones are appended to the other elements.
Returns:
{glow.NodeList} The replaced elements Call {@link glow.NodeList#destroy destroy} on these if you no longer need them.

{glow.NodeList | number} scrollLeft(val)
Gets/sets the number of pixels the element has scrolled horizontally To get/set the scroll position of the window, use this method on a nodelist containing the window object.
		// get the scroll left value of #myDiv
		var scrollPos = glow('#myDiv').scrollLeft();
		// scrollPos is a number, eg: 45
		// set the scroll left value of #myDiv to 20
		glow('#myDiv').scrollLeft(20);
		// get the scrollLeft of the window
		glow(window).scrollLeft();
		// scrollPos is a number, eg: 45
Parameters:
{Number} val Optional
New left scroll position Omit this to get the current scroll position
Returns:
{glow.NodeList | number} Current scrollLeft value, or NodeList when setting scroll position.

{glow.NodeList | number} scrollTop(val)
Gets/sets the number of pixels the element has scrolled vertically To get/set the scroll position of the window, use this method on a nodelist containing the window object.
		// get the scroll top value of #myDiv
		var scrollPos = glow("#myDiv").scrollTop();
		// scrollPos is a number, eg: 45
		// set the scroll top value of #myDiv to 20
		glow("#myDiv").scrollTop(20);
		// get the scrollTop of the window
		glow(window).scrollTop();
		// scrollPos is a number, eg: 45
Parameters:
{Number} val Optional
New top scroll position Omit this to get the current scroll position
Returns:
{glow.NodeList | number} Current scrollTop value, or NodeList when setting scroll position.

{glow.NodeList} show()
Shows all hidden items in the NodeList.
		// Show element with ID myDiv
		glow("#myDiv").show();
		// Show all list items within #myList
		glow("#myList li").show();
Returns:
{glow.NodeList}

{glow.NodeList} slice(start, end)
Get a section of an NodeList Operates in the same way as an Array's slice method
		var myNodeList = glow("

"); myNodeList.slice(1, 2); // selects the paragraph myNodeList.slice(-1); // same thing, selects the paragraph
Parameters:
{number} start
Start index If negative, it specifies a position measured from the end of the list
{number} end Optional
End index By default, this is the end of the list. A negative end specifies a position measured from the end of the list.
Returns:
{glow.NodeList} A new sliced NodeList

{glow.NodeList} slideOpen(duration, opts)
Slide elements open This animates an element's height from its current height to its full auto-height size. If the element is currently sliding shut, the slideShut animation will be automatically stopped.
			var menuContent = glow('#menu div.content');
			
			glow('#menu').on('mouseenter', function() {
				menuContent.slideOpen();
			}).on('mouseleave', function() {
				menuContent.slideShut();
			});
			glow('#furtherInfoHeading').on('click', function() {
				glow('#furtherInfoContent').slideOpen();
			});
			// add content onto an element, and slide to reveal the new content
			glow('
' + newContent + '
').appendTo('#content').height(0).slideOpen();
Parameters:
{number} duration Optional, Default: 1
Duration in seconds
{Object} opts Optional
Options object
{function|string} opts.tween Optional, Default: 'easeBoth'
The motion of the animation. Strings are treated as properties of glow.tweens, although a tween function can be provided.
{boolean} opts.lockToBottom Optional, Default: false
Lock the bottom of the content to the bottom of the element. This means the bottom of the content is shown first, rather than the top.
Returns:
{glow.NodeList}

{glow.NodeList} slideShut(duration, opts)
Slide elements shut This animates an element's height from its current height to zero. If the element is currently sliding open, the slideOpen animation will be automatically stopped.
			var menuContent = glow('#menu div.content');
			
			glow('#menu').on('mouseenter', function() {
				menuContent.slideOpen();
			}).on('mouseleave', function() {
				menuContent.slideShut();
			});
Parameters:
{number} duration Optional, Default: 1
Duration in seconds
{Object} opts Optional
Options object
{function|string} opts.tween Optional, Default: 'easeBoth'
The motion of the animation. Strings are treated as properties of glow.tweens, although a tween function can be provided.
{boolean} opts.lockToBottom Optional, Default: false
Lock the bottom of the content to the bottom of the element. This means the top of the content is hidden first, rather than the bottom.
Returns:
{glow.NodeList}

{glow.NodeList} slideToggle(duration, opts)
Slide elements open/shut If the element is currently sliding open/shut, the slideOpen/slideShut animation will be automatically stopped. // Implementation note: (delete me later) If the element has a height of 0, then slide open, otherwise slide shut. UNLESS there's slideShut animation currently happening on this element, then slide open.
			var menuContent = glow('#menuContent');
			
			glow('#toggleMenu').on('click', function() {
				menuContent.slideToggle();
			});
Parameters:
{number} duration Optional, Default: 1
Duration in seconds
{Object} opts Optional
Options object
{function|string} opts.tween Optional, Default: 'easeBoth'
The motion of the animation. Strings are treated as properties of glow.tweens, although a tween function can be provided.
{boolean} opts.lockToBottom Optional, Default: false
Lock the bottom of the content to the bottom of the element. This means the top of the content is hidden first & shown last.
Returns:
{glow.NodeList}

{glow.NodeList} sort(func)
Sort the elements in the list. Items will already be in document order if a CSS selector was used to fetch them.
			//get links in alphabetical (well, lexicographical) order
			var links = glow("a").sort(function(elementA, elementB) {
				return glow(elementA).text() < glow(elementB).text() ? -1 : 1;
			})
Parameters:
{Function} func Optional
Function to determine sort order This function will be passed 2 elements (elementA, elementB). The function should return a number less than 0 to sort elementA lower than elementB and greater than 0 to sort elementA higher than elementB. If no function is provided, elements will be sorted in document order.
Returns:
{glow.NodeList} A new sorted NodeList

{glow.NodeList | String} text(text)
Gets / set the text content Either gets content of the first element, or sets the content for all elements in the list
			// set text
			var div = glow("
").text("Fun & games!"); //
Func & games!
			// get text
			var mainHeading = glow('#mainHeading').text();
Parameters:
{String} text Optional
String to set as the text of elements If omitted, the test for the first element in the list is returned.
Returns:
{glow.NodeList | String} Returns the original NodeList when setting, or the text content when getting.

{glow.NodeList} toggleClass(name)
Toggles a class on each node.
		glow(".onOffSwitch").toggleClass("on");
Parameters:
{string} name
The name of the class to toggle.
Returns:
{glow.NodeList}

{glow.NodeList} unwrap()
Removes the parent of each item in the list
			// Before: 

Hello

// unwrap the given element glow("#mySpan").unwrap(); // After:
Hello
Returns:
{glow.NodeList} The now unwrapped elements

{glow.NodeList | string | Object} val(value)
Gets or sets form values for the first node. The returned value depends on the type of element, see below:
Radio button or checkbox
If checked, then the contents of the value property, otherwise an empty string.
Select
The contents of value property of the selected option
Select (multiple)
An array of selected option values.
Other form elements
The value of the input.
Getting values from a form: If the first element in the NodeList is a form, then an object is returned containing the form data. Each item property of the object is a value as above, apart from when multiple elements of the same name exist, in which case the it will contain an array of values. Setting values for form elements: If a value is passed and the first element of the NodeList is a form element, then the form element is given that value. For select elements, this means that the first option that matches the value will be selected. For selects that allow multiple selection, the options which have a value that exists in the array of values/match the value will be selected and others will be deselected. Checkboxes and radio buttons will be checked only if the value is the same as the one you provide. Setting values for forms: If the first element in the NodeList is a form and the value is an object, then each element of the form has its value set to the corresponding property of the object, using the method described above.
		// get a value from an input with the id 'username'
		var username = glow("#username").val();
		
		// get values from a form
		var userDetails = glow("form").val();
		// set a value
		glow("#username").val("example username");
		// set values in a form
		glow("form").val({
			username : "another",
			name     : "A N Other"
		});
Parameters:
{string | Object} value Optional
The value to set the form element/elements to.
Returns:
{glow.NodeList | string | Object} When used to set a value it returns the NodeList, otherwise returns the value as described above.

{glow.NodeList | number} width(width)
Gets / set element width Return value does not include the padding or border of the element in browsers supporting the correct box model. You can use this to easily get the width of the document or window, see example below.
		// get the width of #myDiv
		glow("#myDiv").width();
		// set the width of list items in #myList to 200 pixels
		glow("#myList > li").width(200);
		// get the width of the document
		glow(document).width();
		// get the width of the window
		glow(window).width();
Parameters:
{Number} width Optional
New width in pixels for each element in the list If ommited, the width of the first element is returned
Returns:
{glow.NodeList | number} width of first element, or original NodeList when setting widths.

{glow.NodeList} wrap(wrapper)
Wraps the given NodeList with the specified element(s). The given NodeList items will always be placed in the first child element that contains no further elements. Each item in a given NodeList will be wrapped individually.
			// Hello
			glow("#mySpan").wrap("

"); // Makes: //
//

// Hello //

//
Parameters:
{string | HTMLElement | HTMLElement[] | glow.NodeList} wrapper
Element to use as a wrapper Strings will be treated as HTML strings if they begin with <, else they'll be treated as a CSS selector.
Returns:
{glow.NodeList} The NodeList with new wrapper parents
Event Detail
keydown(event)
Fires when the user presses a key Only fires if the element has focus, listen for this event on the document to catch all keydowns. This event related to the user pressing a key on the keyboard, if you're more concerned about the character entered, see the {@link glow.NodeList#event:keypress keypress} event. keydown will only fire once, when the user presses the key. The order of events is keydown, keypress*, keyup. keypress may fire many times if the user holds the key down.
Parameters:
{glow.events.KeyboardEvent} event
Event Object

keypress(event)
Fires when a key's command executes. For instance, if you hold down a key, it's action will occur many times. This event will fire on each action. This event is useful when you want to react to keyboard repeating, or to detect when a character is entered into a field. The order of events is keydown, keypress*, keyup. keypress may fire many times if the user holds the key down.
Parameters:
{glow.events.KeyboardEvent} event
Event Object

keyup(event)
Fires when the user releases a key Only fires if the element has focus, listen for this event on the document to catch all keyups. This event related to the user pressing a key on the keyboard, if you're more concerned about the character entered, see the {@link glow.NodeList#event:keypress keypress} event. The order of events is keydown, keypress*, keyup. keypress may fire many times if the user holds the key down.
Parameters:
{glow.events.KeyboardEvent} event
Event Object

mouseenter(event)
Fires when the mouse enters the element specifically, does not bubble
Parameters:
{glow.events.DomEvent} event
Event Object

mouseleave(event)
Fires when the mouse leaves the element specifically, does not bubble
Parameters:
{glow.events.DomEvent} event
Event Object

Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jun 14 2010 14:24:10 GMT+0100 (BST)