Namespace pulp.node
Defined in: pulp.node.js.
Field Summary
Method Summary
^ top
select(selector)
Return an array of descendent nodes that match the given selector If pulp.nodeList is available, return the results in a pulp.nodeList object
_setCache()
Save a reference to this object on the node itself see below for circular reference decupling for IE6
html(html)
(chainable)
Get or set the innerHTML (sets when argument is present, gets when argument is absent)
removeClass(className)
(chainable)
Remove a css class name from the node (aliased as removeClassName)
cloneNode(withChildren)
Return a copy of the pulp.node being sure to remove the clone's id attribute.
hasAttribute(attr)
Field Detail
Method Detail
^ top
select(selector)
-> Array|pulp.nodeList
Return an array of descendent nodes that match the given selector
If pulp.nodeList is available, return the results in a pulp.nodeList object
Defined in: pulp.cssQuery.js.
Parameters:
| {String} | selector | The CSS query to use |
Returns:
| {Array|pulp.nodeList} |
match(selector)
-> Boolean
Return true if the node matches the given CSS selector
Defined in: pulp.cssQuery.js.
Parameters:
| {String} | selector | The CSS query to use |
Returns:
| {Boolean} |
_setCache()
Save a reference to this object on the node itself
see below for circular reference decupling for IE6
Returns:
| undefined |
setStyle(attr, value)
-> pulp.node
Set the css style of a node. Attribute names can be hyphenated (e.g. "z-index")
or camelized (e.g. "zIndex"). Optionally an Object with attribute-value pairs may be passed.
var $ = pulp.node.getInstance;
$('fruit').setStyle('backgroundColor', 'red');
$('fruit').setStyle({
color: 'white',
'font-weight': 'bold'
});
Parameters:
| {String} | attr | The attribute name |
| {String} | value | The value to set |
Returns:
| {pulp.node} |
getStyle(attr)
-> String
Set the css style of a node. Attribute names can be hyphenated (e.g. "z-index")
or camelized (e.g. "zIndex"). Optionally an Object with attribute-value pairs may be passed.
Parameters:
| {String} | attr | The attribute name |
Returns:
| {String} |
setOpacity(A)
-> pulp.node
Set the opacity style
Parameters:
| {String|Number} | A | number between 0 and 1. 1 for fully visible, 0.5 for 50% opacity, 0 for invisible |
Returns:
| {pulp.node} |
getOpacity()
-> Number
Get the opacity style
Returns:
| {Number} | A number between 0 and 1. 1 for fully visible, 0.5 for 50% opacity, 0 for invisible |
get(property)
-> Mixed
Get the raw value of any given property (e.g. innerHTML, style, title, value, parentNode, etc.)
Parameters:
| {String} | property |
Returns:
| {Mixed} |
set(property, value)
-> pulp.node
Set the raw value of any given property (e.g. innerHTML, style, title, value, parentNode, etc.)
Parameters:
| {String} | property | |
| {Mixed} | value |
Returns:
| {pulp.node} |
html(html)
-> pulp.node
Get or set the innerHTML (sets when argument is present, gets when argument is absent)
Parameters:
| {String|HTMLElement} | html | An html string or an html node |
Returns:
| {pulp.node} |
hasClass(className)
-> Boolean
Return true if the node has the given css class name (aliased as hasClassName)
Parameters:
| {String} | className |
Returns:
| {Boolean} |
addClass(className)
-> pulp.node
Add a css class name to the node (aliased as addClassName)
Parameters:
| {String} | className |
Returns:
| {pulp.node} |
removeClass(className)
-> this
Remove a css class name from the node (aliased as removeClassName)
Parameters:
| {String} | className |
Returns:
| {this} |
toggleClass(className, onOff)
Remove a css class if present or add if not pressent
Parameters:
| {String} | className | The name of the css class |
| {Object} | onOff | If undefined, do a regular toggle. If true add class, if false remove it |
replace(node)
-> this
Replace a DOM node
Parameters:
| {HTMLElement|pulp.node} | node | Node to add instead of this one |
Returns:
| {this} | The replaced node |
prependChild(child)
-> pulp.node
Add a new child to this node as the first child
Parameters:
| child |
Returns:
| {pulp.node} |
appendChild(child)
-> pulp.node
Add a new child to this node as the last child
Parameters:
| child |
Returns:
| {pulp.node} |
replaceChild(newEl, oldEl)
-> pulp.node
Replace child with another element
Parameters:
| {HTMLElement|pulp.node} | newEl | |
| {HTMLElement|pulp.node} | oldEl |
Returns:
| {pulp.node} | The newly inserted node |
insertBefore(child)
-> pulp.node
Add a node immediately before this one
Parameters:
| child |
Returns:
| {pulp.node} |
insertAfter(child)
-> pulp.node
Add a node immediately after this one
Parameters:
| child |
Returns:
| {pulp.node} |
wrap(wrapper [, deepest=true])
-> pulp.node
Wrap a node in HTML or another node
Parameters:
| {String|HTMLElement|pulp.node} | wrapper | The HTML or node to wrap around this node |
| {Boolean} | deepest?, Default: true | If true, append to the deepest child of the wrapper |
Returns:
| {pulp.node} | The new wrapper |
wrapInner(wrapper [, deepest=true])
-> pulp.node
Move all child nodes into a new wrapper
Parameters:
| {String|HTMLElement|pulp.node} | wrapper | The HTML or node to wrap around this node's children |
| {Boolean} | deepest?, Default: true | If true, append to the deepest child of the wrapper |
Returns:
| {pulp.node} | The new wrapper |
getChildren()
-> pulp.node[]
Get an array of child nodes as pulp.node objects
Returns:
| {pulp.node[]} |
getPrevSibling()
-> Boolean|pulp.node
Get the sibling that comes immediately before this one
Returns:
| {Boolean|pulp.node} |
getNextSibling()
-> Boolean|pulp.node
Get the sibling that comes immediately after this one
Returns:
| {Boolean|pulp.node} |
getSiblings()
-> pulp.node[]
Get an array of all siblings as pulp.node objects (don't include this node)
Returns:
| {pulp.node[]} |
getNextSiblings()
-> pulp.node[]
Get an array of siblings as pulp.node objects that come after this node
Returns:
| {pulp.node[]} |
getPreviousSiblings()
-> pulp.node[]
Get an array of siblings as pulp.node objects that come before this node
Returns:
| {pulp.node[]} |
getAncestors()
-> pulp.node[]
Get an array of ancestors of this node as pulp.node objects
Returns:
| {pulp.node[]} |
up([selector=""])
-> pulp.node
Get the first ancestor matching the given tag name, index, or css selector
Parameters:
| {String|Number} | selector?, Default: "" | A tag name, index or a css selector (pulp.cssQuery is required to use css selectors) - When a tag name is given, it returns the first ancestor with that tag name - When a number is given, it returns the ancestor with that index (1 for parent, 2 for grandparent, etc.) - When a selector is given, the first ancestor matching the selector is given (assuming pulp.cssQuery is present) |
Returns:
| {pulp.node} |
down([idx=""])
-> pulp.node
Get the first descendant matching the given tag name, index, or css selector
Parameters:
| {String|Number} | idx?, Default: "" | A tag name, index or a css selector (pulp.cssQuery is required to use css selectors) - When a tag name is given, it returns the first descendant with that tag name - When a number is given, it returns the descendant with that index (1 for first child, 2 for first child's first child, etc.) - When a selector is given, the first descendant matching the selector is given (assuming pulp.cssQuery is present) |
Returns:
| {pulp.node} |
isDescendantOf(parent)
-> Boolean
Return true if the node is a descendent of the given node
Parameters:
| {pulp.node|HTMLElement} | parent | The parent to test against |
Returns:
| {Boolean} |
identify()
-> String
Get the id attribute of a node. If id is not set, set it.
Account for situations where id property is not a string such as a form with an input named "id"
Returns:
| {String} |
getDimensions()
-> Object
Get the height and width of the node in px
Returns:
| {Object} | Object with properties "width" and "height" |
cloneNode(withChildren)
-> pulp.node
Return a copy of the pulp.node being sure to remove the clone's id attribute.
If a deep copy, remove the id attribute from children as well.
Remember that the copy is not attached to the DOM tree.
TODO: delete the event handlers that IE erroneously adds to the copied node
Parameters:
| {Boolean} | withChildren | If true, perform a deep copy |
Returns:
| {pulp.node} |
setAttribute(attr, The)
-> undefined
Set an attribute on a node
Parameters:
| {String} | attr | The attribute to set |
| {String|undefined|false|null} | The | value of the attribute. If not given, the attribute will be set to the atribute name. e.g. $(el).setAttribute('checked') will set checked="checked" If false or null, the attribute is removed |
Returns:
| {undefined} |
getAttribute(attr)
-> String|Number
Return the value of the specified attribute (special treatment for IE)
Parameters:
| {String} | attr | The attribute to get |
Returns:
| {String|Number} |
removeAttribute(attribute)
-> pulp.node
Remove the given attribute
Parameters:
| {String} | attribute | The name of the attribute to remove |
Returns:
| {pulp.node} |
offsetParent()
-> pulp.node
Return the first ancestor with offset of static (or body if none ar found)
Returns:
| {pulp.node} |
pulp.node.getInstance(The)
-> pulp.node|undefined
Return a new pulp.node by node id or node handle
Parameters:
| {String|HTMLElement|pulp.node} | The | id or node handle to get |
Returns:
| {pulp.node|undefined} | Returns undefined if the node cannot be found |
pulp.node.htmlToNodeList(html, doc)
-> HTMLNodeList
Convert an html string to an HTMLNodelist object
Parameters:
| {String} | html | |
| doc |
Returns:
| {HTMLNodeList} |
pulp.node._camelize(Thes)
-> String
Convert a hyphen-delimited string to a camelCase string
Parameters:
| {String} | Thes | string to convert |
Returns:
| {String} |