Search:
jgrouse.dom.Element
module jgrouse.dom.Element
Contains utilities for DOM manipulations
Defined in jgrouse/dom/Element.js
Function Summary
Add HTML class on DOM node.
Adds CSS style to DOM node.
Remove attribute from DOM node
clearAttributes(DOMElement element)
Removes all attributes from node
Removes CSS style from DOM node
clearStyles(DOMElement element)
Remove all declared styles from DOM node
Find all nodes matching certain criteria.
disposeDom(DOMElement element)
Dispose DOM node.
Invoke given callback for each child of the node
Get attribute of DOM node
Get all specified attributes pf DOM node.
Retrieves computed CSS style (i.e.
Retrieve CSS styles from DOM node
Check if DOM node has given HTML class
Checks if given DOM node is reacheable from document root and has style.display != 'none'.
Move all children from one DOM node to another DOM node
Remove HTML class from DOM node
Find DOM node matching certain criteria
Add or update node's attribute
Set several attributes on node.
Set HTML class on DOM node.
Set CSS style(s) on DOM node.
Travese the DOM tree for given element, calling callback function for each node.
Function Interface Summary
Function Details
function addClassName
addClassName(DOMElement element, String className)
Add HTML class on DOM node.
Parameters:
element - target nodeclassName - name of class to addfunction addStyle
addStyle(DOMElement element, String style, String value)
addStyle(DOMElement element, Object obj)
Adds CSS style to DOM node.
Parameters:
Add one style
element - target nodestyle - name of CSS stylevalue - value of style Add several styles
element - target nodeobj - object containing name/value pairs of CSS styles and valuesfunction clearAttribute
clearAttribute(DOMElement element, String attr)
Remove attribute from DOM node
Parameters:
element - target nodeattr - name of attribute to remove.function clearAttributes
clearAttributes(DOMElement element)
Removes all attributes from node
Parameters:
element - node to be cleared from attributesfunction clearStyle
clearStyle(DOMElement element, String styleName)
Removes CSS style from DOM node
Parameters:
element - target nodestyleName - name of CSS style to be removed.function clearStyles
clearStyles(DOMElement element)
Remove all declared styles from DOM node
Parameters:
element - target nodefunction collect
DOMNode[] collect(DOMNode element, traverseCallback testCallback)
Find all nodes matching certain criteria.
Parameters:
element - starting pointtestCallback - function that should be called for each node. Should
return true if the element should be added to result set array with matching elements
Defined in jgrouse.dom.Element
function disposeDom
disposeDom(DOMElement element)
Dispose DOM node.
Parameters:
element - element to be disposedfunction forEach
forEach(DOMElement element, jgrouse.arrayIteratorCallback callback, Boolean backwards)
Invoke given callback for each child of the node
Parameters:
element - target nodecallback - function to be called for each child node.backwards - indicator if iteration should start from last child to
first child. Optional, defautl value is falsefunction getAttribute
String getAttribute(DOMElement element, String attrName)
Get attribute of DOM node
Parameters:
element - source elementattrName - name of attribute to read value of read attribute
Defined in jgrouse.dom.Element
function getAttributes
DOMAttribute[] getAttributes(DOMElement domNode)
Get all specified attributes pf DOM node.
Parameters:
domNode
array of DOMAttribute[] objects
Defined in jgrouse.dom.Element
function getComputedStyle
getComputedStyle(DOMElement element, String style)
Retrieves computed CSS style (i.e. inherited from parent nodes, classes, etc) for DOM node.
Parameters:
element - target elementstyle - name of CSS stylefunction getStyles
Object getStyles(DOMElement element)
Retrieve CSS styles from DOM node
Parameters:
element - target node object containing name/value pairs for CSS styles. Names are camelized and
could be browser-specific.
Defined in jgrouse.dom.Element
function hasClass
boolean hasClass(DOMElement element, String className)
Check if DOM node has given HTML class
Parameters:
element - target nodeclassName - class name to check true if the element has given HTML class
Defined in jgrouse.dom.Element
function isShowing
boolean isShowing(DOMElement element)
Checks if given DOM node is reacheable from document root and has style.display != 'none'.
Parameters:
element - target node true if the node is reacheable from document root
Defined in jgrouse.dom.Element
function moveChildrenToNewParent
moveChildrenToNewParent(DOMElement dstParent, DOMElement srcParent)
Move all children from one DOM node to another DOM node
Parameters:
dstParent - destination nodesrcParent - source nodefunction removeClassName
removeClassName(DOMElement element, String className)
Remove HTML class from DOM node
Parameters:
element - target nodeclassName - name of class to removefunction scrollToView
scrollToView(DOMElement domElement, String align)
domElement
align - 'left', 'top' or nullfunction search
DOMElement search(DOMElement element, traverseCallback testCallback)
Find DOM node matching certain criteria
Parameters:
element - starting pointtestCallback - callback function to be called for each node. found node or null if no nodes were found
Defined in jgrouse.dom.Element
function setAttribute
setAttribute(DOMElement element, String attrName, String value)
Add or update node's attribute
Parameters:
element - target nodeattrName - name of attribute to set/updatevalue - data to be setfunction setAttributes
setAttributes(DOMElement element, Object attributes)
Set several attributes on node. Old attributes are being removed first.
Parameters:
element - target nodeattributes - object containing names/values of attributes to setfunction setClass
setClass(DOMElement className, String className)
Set HTML class on DOM node. Replaces any existing classes
Parameters:
className
className - name of class to setfunction setStyles
setStyles(DOMElement element, String style, String value)
setStyles(DOMElement element, Object obj)
setStyles(DOMElement element, String style)
Set CSS style(s) on DOM node. Existing styles are removed.
Parameters:
Set one style
element - target nodestyle - name of CSS stylevalue - value of style Set several styles
element - target nodeobj - object containing name/value pairs of CSS styles and values Set several styles from string
element - target nodestyle - textual representation of stylesfunction walkTree
walkTree(DOMElement element, traverseCallback testCallback)
Travese the DOM tree for given element, calling callback function for each node. If the callback
function returns
Parameters:
true, then traversing is interrupted
element - starting elementtestCallback - callback function to be called for each nodeFunction Interface Details
ifunction traverseCallback
boolean traverseCallback(DOMElement element)
element currently being traversed true if element matches certaint criteria
Defined in jgrouse.dom.Element