Class o2.Dom


static class o2.Dom
A cross-browser DOM manipulation helper.
Defined in dom.constants

Function Summary

Activates the alternate stylesheet with the given title.

Usage example:

 o2.Dom.activateAlternateStylesheet('alternateTheme');
 
static addClass (DomNode el, String c)

Add a class to the given node.

Usage example:

 o2.Dom.addClass('container', 'active');
 
static addCssRules()

Adds the CSS rules given in the cssText parameter to the document.

Usage example:

 o2.Dom.addCssRules(
      'div.warning { background-color:#c00; color:#fff };'
 );
 
static addStyle (Object obj, Object style)

Adds style attributes to a DOM node.

Note that adding and removing style attributes to a DOM not is considered "bad practice". Do not use inline styles to modify the view; assign className's instead of style values.

Usage example:

 o2.Dom.addStyle('container', {color : '#bada55'})
 
static append (Object elmChild, Object elmParent)

Appends the element to the bottom of its parent.

Usage example:

 var child = o2.$('childNode');
 var parent = o2.$('parentNode');
 o2.Dom.append(child, parent);
 
static compactField (Object field)

Trims a given field, and returns the compacted value.

Usage example:

 o2.Dom.compactField('txtInput');
 
static create()

An alias to o2.Dom.createElement.

Creates a regular expression that will match a given CSS class name.

Usage example:

 var reg = o2.Dom.createClassNameRegExp('testClass');
 

Creates a Document Fragment from an HTML String.

Usage example:

 var frag = o2.Dom.createDocumentFragment('[div]test[/div]');
 
static createElement (String name, Object attributes)

Creates an element with given name and attributes.

Usage example:

 var el = o2.Dom.createElement(
      'div',
      {className : 'active', style : 'font-weight : bold'}
 );
 
static empty (Object elm)

An alias to o2.Dom.removeChildren.

static getAttribute (Object elm, String attribute)

Gets the attribute of a given node.

Usage example:

 var uid = o2.Dom.getAttribute('container', 'data-user-id');
 
static getChildrenByAttributeUntil (Object elm, String attribute, String value, Object until, String name)

Gets the children of the element until a given node (exclusive).

Usage example:

 var items = o2.Dom.getChildrenByAttributeUntil('container',
      'data-user-id', '42', o2.$('stopper'), 'li');
 
static getChildrenByClass (Object elm, String className, String name)

Gets the children of the element having a specific class.

Usage example:

 var items = o2.Dom.getChildrenByClass('container', 'active', 'li');
 
static getChildrenByClassUntil (Object elm, String className, Object until, String name)

Gets the children of the element having a specific class, and until (but not included to) a given element.

Usage example:

 var items = o2.Dom.getChildrenByClassUntil('container', 'active',
      o2.$('stopper'), 'li');
 
static getChildrenUntil (Object elm, Object until, String name)

Gets the children of the element until (but not included to) a given element.

Usage example:

 var items = o2.Dom.getChildrenUntil('container', o2.$('stopper'), 'li');
 
static getChildrenWithAttribute (Object elm, String attribute, String name)

Gets the children of the element having a given attribute defined.

Usage example:

 var items = o2.Dom.getChildrenWithAttribute('container', 'data-user-id',
 'li');
 
static getChildrenWithAttributeUntil (Object elm, String attribute, Object until, String name)

Gets the children of the element with a given attribute defined, and until (but not included to) a given element.

Usage example:

 var items = o2.Dom.getChildrenWithAttributeUntil('content',
      'data-user-id', o2.$('stopper'), 'li');
 
static getChildrenWithClass (Object elm, String name)

Gets the children of the element with a "class" attribute defined.

Usage example:

 var items = o2.Dom.getChildrenWithClass('content', 'selected', 'li');
 
static getChildrenWithClassUntil (Object elm, Object until, String name)

Gets the children of the element with a "class" attribute defined, and until (but not included to) a given element.

Usage example:

 var items = o2.Dom.getChildrenWithClassUntil('content', 'stopper', 'li');
 
static getChildrenWithId (Object elm, String name)

Gets the children of the element with an "id" attribute defined.

Usage example:

 var items = o2.Dom.getChildrenWithId('content', 'li');
 
static getChildrenWithIdUntil (Object elm, Object until, String name)

Gets the children of the element with an "id" attribute defined, and until (but not included to) a given element.

Usage example:

 var items = o2.Dom.getChildrenWithIdUntil('content', 'stopper', 'li');
 
static getCss()

An alias to o2.Dom.getStyle.

static getDimension (Object obj)

Gets the dimension of the given element in the form {width: w, height: h}, where w and h are in pixels.

Usage example:

 var dimensions = o2.Dom.getDimension('container');
 

Gets the dimension of the document in the form {width: w, height: h}. If the visible (i.e. clientHeight) is greater than the document's height returns the height of the visible area as the height portion.

Usage example:

 var viewportInfo = o2.Dom.getDocumentDimension();
 

Gets the total height of the document in pixels.

Usage example:

 var viewportHeight = o2.Dom.getDocumentHeight();
 
static getDocumentWidth()

Gets the total width of the document in pixels.

Usage example:

 var viewportWidth = o2.Dom.getDocumentWidth();
 
static getElements (Object elm, String name)

Gets all of the elements of the node elm.

Usage example:

 var items = o2.Dom.getElements('content', 'li');
 
static getElementsByAttribute (Object elm, String attribute, String value, String name)

Gets all of the elements of the node elm, filtering the nodes having a given attribute equals to a given value.

Usage example:

 var items = o2.Dom.getElementsByAttribute('content', 'data-id', '42');
 
static getElementsByClass (Object elm, String className, String name)

Gets all of the elements of the node elm, having a given CSS class name.

Usage example:

 var items = o2.Dom.getElementsByClass('content', 'selected', 'li');
 
static getElementsWithAttribute (Object elm, String attribute, String name)

Gets all of the elements of the node elm, having a given attribute defined.

Usage example:

 var items = o2.Dom.getElementsWithAttribute('content', 'data-id', 'li');
 
static getElementsWithClass (Object elm, String name)

Gets all of the elements of the node elm, having a 'class" attribute defined.

Usage example:

 var items = o2.Dom.getElementsWithClass('content', 'li');
 
static getElementsWithId (Object elm, String name)

Gets all of the elements of the node elm, having an 'id" attribute defined.

Usage example:

 var items = o2.Dom.getElementsWithId('content', 'li');
 
static getFirst (Object elm, String name)

Gets the first sibling of the element that's not a text node.

Usage example:

 var item = o2.Dom.getFirst('content', 'li');
 
static getFirstByAttribute (Object elm, String attribute, String value, String name)

Gets the first sibling of the element that's not a text node, and having an attibute with a given value.

Usage example:

 var item = o2.Dom.getFirstByAttribute('content', 'data-id', '42');
 
static getFirstByClass (Object elm, String className, String name)

Gets the first sibling of the element that's not a text node, and having a given CSS class name.

Usage example:

 var item = o2.Dom.getFirstByClass('content', 'selected', 'li');
 
static getFirstChild (Object elm, String name)

Gets the first child of the element that's not a text node.

Usage example:

 var item = o2.Dom.getFirstChild('content', 'li');
 
static getFirstChildByAttribute (Object elm, String attribute, String value, String name)

Gets the first child of the element that's not a text node, and having an attribute with a given value.

Usage example:

 var item = o2.Dom.getFirstChildByAttribute('content', 'data-id', '42');
 
static getFirstChildByClass (Object elm, String className, String name)

Gets the first child of the element that's not a text node, and having a given class name.

Usage example:

 var item = o2.Dom.getFirstChildByClass('content', 'selected', 'li');
 
static getFirstChildWithAttribute (Object elm, String attribute, String name)

Gets the first child of the element that's not a text node, and having a given attribute defined.

Usage example:

 var item = o2.Dom.getFirstChildWithAttribute('content', 'data-id', 'li');
 
static getFirstChildWithClass (Object elm, String name)

Gets the first child of the element that's not a text node, and having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getFirstChildWithClass('content', 'li');
 
static getFirstChildWithId (Object elm, String name)

Gets the first child of the element that's not a text node, and having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getFirstChildWithId('content', 'li');
 
static getFirstWithAttribute (Object elm, String attribute, String name)

Gets the first sibling of the element that's not a text node, and having a given attribute defined.

Usage example:

 var item = o2.Dom.getFirstWithAttribute('content', 'data-id', 'li');
 
static getFirstWithClass (Object elm, String name)

Gets the first sibling of the element that's not a text node, and having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getFirstWithClass('content', 'li');
 
static getFirstWithId (Object elm, String name)

Gets the first sibling of the element that's not a text node, and having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getFirstWithId('content', 'li');
 
static getHeight (Object obj)

Gets the height of the given element, in pixels.

Usage example:

 var containerHeight = o2.Dom.getHeight('container');
 
static getHtml (Object elm)

Gets the HTML of a given element.

Usage example:

 var html = o2.Dom.getHtml('container');
 
static getLast (Object elm, String name)

Gets the last sibling of the element that's not a text node.

Usage example:

 var item = o2.Dom.getLast('content', 'li');
 
static getLastByAttribute (Object elm, String attribute, String value, String name)

Gets the last sibling of the element that's not a text node, and has an attribute with a given value.

Usage example:

 var item = o2.Dom.getLastByAttribute('content', 'data-id', '42');
 
static getLastByClass (Object elm, String className, String name)

Gets the last sibling of the element that's not a text node, and has a given class name.

Usage example:

 var item = o2.Dom.getLastByClass('content', 'selected', 'li');
 
static getLastChild (Object elm, String name)

Gets the last child of the element that's not a text node.

Usage example:

 var item = o2.Dom.getLastChild('content', 'li');
 
static getLastChildByAttribute (Object elm, String attribute, String value, String name)

Gets the last child of the element that's not a text node, and having an attribute with a given value.

Usage example:

 var item = o2.Dom.getLastChildByAttribute('content', 'data-id', '42');
 
static getLastChildByClass (Object elm, String className, String name)

Gets the last child of the element that's not a text node, and having a given CSS class name.

Usage example:

 var item = o2.Dom.getLastChildByClass('content', 'selected', 'li');
 
static getLastChildWithAttribute (Object elm, String attribute, String name)

Gets the last child of the element that's not a text node, and having a given attribute defined.

Usage example:

 var item = o2.Dom.getLastChildWithAttribute('content', 'data-id', 'li');
 
static getLastChildWithClass (Object elm, String className, String name)

Gets the last child of the element that's not a text node, and having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getLastChildWithClass('content', 'selected', 'li');
 
static getLastChildWithId (Object elm, String name)

Gets the last child of the element that's not a text node, and having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getLastChildWithId('content', 'li');
 
static getLastWithAttribute (Object elm, String attribute, String name)

Gets the last sibling of the element that's not a text node, and has a given attribute defined.

Usage example:

 var item = o2.Dom.getLastWithAttribute('content', 'data-id', 'li');
 
static getLastWithClass (Object elm, String className, String name)

Gets the last sibling of the element that's not a text node, and has a "class" attribute defined.

Usage example:

 var item = o2.Dom.getLastWithClass('content', 'selected', 'li');
 
static getLastWithId (Object elm, String name)

Gets the last sibling of the element that's not a text node, and has an "id" attribute defined.

Usage example:

 var item = o2.Dom.getLastWithId('content', 'li');
 
static getNext (Object elm, String name)

Gets the next sibling of the element, that's not a text node.

Usage example:

 var item = o2.Dom.getNext('content', 'li');
 
static getNextAll (Object elm, String name)

Gets all the following siblings of the element that are not text nodes.

Usage example:

 var item = o2.Dom.getNextAll('content', 'li');
 
static getNextAllByAttribute (Object elm, String attribute, String value, String name)

Gets all the following siblings of the element that are not text nodes, having an attribute with a given value.

Usage example:

 var item = o2.Dom.getNextAllByAttribute('content', 'data-id', '42');
 
static getNextAllByAttributeUntil (Object elm, String attribute, String value, Object until, String name)

Gets all the following siblings of the element that are not text nodes, having an attribute with a given value, until (but not included to) a given DOM node.

Usage example:

 var item = o2.Dom.getNextAllByAttributeUntil('content', 'data-id', '42',
      'stopper', 'li');
 
static getNextAllByClass (Object elm, String className, String name)

Gets all the following siblings of the element that are not text nodes, having a given CSS class name.

Usage example:

 var item = o2.Dom.getNextAllByClass('content', 'selected', 'li');
 
static getNextAllByClassUntil (Object elm, String className, Object until, String name)

Gets all the following siblings of the element that are not text nodes, having a given CSS class name, until (but not included to) a given DOM node.

Usage example:

 var item = o2.Dom.getNextAllByClassUntil('content', 'selected',
      'stopper', 'li');
 
static getNextAllUntil (Object elm, Object until, String name)

Gets all the following siblings of the element that are not text nodes, until (but not included to) a given DOM node.

Usage example:

 var item = o2.Dom.getNextAllUntil('content', 'stopper', 'li');
 
static getNextAllWithAttribute (Object elm, String attribute, String name)

Gets all the following siblings of the element that are not text nodes, having a given attribute defined.

Usage example:

 var item = o2.Dom.getNextAllWithAttribute('content', 'data-id', 'li');
 
static getNextAllWithAttributeUntil (Object elm, String attribute, Object until, String name)

Gets all the following siblings of the element that are not text nodes, having a given attribute defined, until (but not included to) a given DOM node.

Usage example:

 var item = o2.Dom.getNextAllWithAttributeUntil('content', 'data-id',
      'stopper', 'li');
 
static getNextAllWithClass (Object elm, String name)

Gets all the following siblings of the element that are not text nodes, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNextAllWithClass('content', 'li');
 
static getNextAllWithClassUntil (Object elm, Object until, String name)

Gets all the following siblings of the element that are not text nodes, having a "class" attribute defined, until (but not included to) a given DOM node.

Usage example:

 var item = o2.Dom.getNextAllWithClassUntil('content', 'stopper', 'li');
 
static getNextAllWithId (Object elm, String name)

Gets all the following siblings of the element that are not text nodes, having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getNextAllWithId('content', 'li');
 
static getNextAllWithIdUntil (Object elm, Object until, String name)

Gets all the following siblings of the element that are not text nodes, having an "id" attribute defined, until (but not included to) a given DOM node.

Usage example:

 var item = o2.Dom.getNextAllWithIdUntil('content', 'stopper', 'li');
 
static getNextByAttribute (Object elm, String attribute, String value, String name)

Gets the next sibling of the element, that's not a text node, and having an attribute with a given value.

Usage example:

 var item = o2.Dom.getNextByAttribute('content', 'data-id', '42', 'li');
 
static getNextByClass (Object elm, String className, String name)

Usage example:

 var item = o2.Dom.getNextByClass('content', 'selected', 'li');
 

Gets the next sibling of the element, that's not a text node, and having a given CSS class name.

static getNextWithAttribute (Object elm, String attribute, String name)

Gets the next sibling of the element, that's not a text node, and having a given attribute defined.

Usage example:

 var item = o2.Dom.getNextWithAttribute('content', 'data-id', 'li');
 
static getNextWithClass (Object elm, String name)

Gets the next sibling of the element, that's not a text node, and having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNextWithClass('content', 'li');
 
static getNextWithId (Object elm, String name)

Gets the next sibling of the element, that's not a text node, and having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getNextWithId('content', 'li');
 
static getNth (Object elm, Integer n, String name)

Gets nth non-text-node sibling of an element, starting from the first sibling.

Usage example:

 var item = o2.Dom.getNth('content', 42, 'li');
 
static getNthByAttribute (Object elm, String attribute, String value, Integer n, String name)

Gets nth non-text-node sibling of an element, starting from the first sibling, having a given attribute with a given value.

Usage example:

 var item = o2.Dom.getNthByAttribute('content', 'data-id', '42', 42);
 
static getNthByClass (Object elm, String className, Integer n, String name)

Gets nth non-text-node sibling of an element, starting from the first sibling, having a given CSS class name.

Usage example:

 var item = o2.Dom.getNthByAttribute('content', 'selected', 42, 'li');
 
static getNthChild (Object elm, Integer n, String name)

Gets nth non-text-node child of an element.

Usage example:

 var item = o2.Dom.getNthChild('content', 42, 'li');
 
static getNthChildByAttribute (Object elm, String attribute, String value, Integer n, String name)

Gets nth non-text-node child of an element, having a given attribute with a given value.

Usage example:

 var item = o2.Dom.getNthChildByAttribute('content', 'data-id', '42', 42);
 
static getNthChildByClass (Object elm, String className, Integer n, String name)

Gets nth non-text-node child of an element, having a given attribute with a given CSS class name.

Usage example:

 var item = o2.Dom.getNthChildByClass('content', 'selected', 42, 'li');
 
static getNthChildWithAttribute (Object elm, String attribute, Integer n, String name)

Gets nth non-text-node child of an element, with a given attribute defined.

Usage example:

 var item = o2.Dom.getNthChildWithAttribute('content', 'data-id', 42);
 
static getNthChildWithClass (Object elm, Integer n, String name)

Gets nth non-text-node child of an element, with a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNthChildWithClass('content', 42, 'li');
 
static getNthChildWithId (Object elm, Integer n, String name)

Gets nth non-text-node child of an element, with a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNthChildWithId('content', 42, 'li');
 
static getNthNext (Object elm, Integer n, String name)

Gets nth non-text-node next sibling of an element.

Usage example:

 var item = o2.Dom.getNthNext('content', 42, 'li');
 
static getNthNextByAttribute (Object elm, String attribute, String value, Integer n, String name)

Gets nth non-text-node next sibling of an element, having a given attribute with a given value.

Usage example:

 var item = o2.Dom.getNthNextByAttribute('content', 'data-id', '42', 42);
 
static getNthNextByClass (Object elm, String className, Integer n, String name)

Gets nth non-text-node next sibling of an element, having a given CSS class name.

Usage example:

 var item = o2.Dom.getNthNextByClass('content', 'selected', 42, 'li');
 
static getNthNextWithAttribute (Object elm, String attribute, Integer n, String name)

Gets nth non-text-node next sibling of an element, having a given attribute defined.

Usage example:

 var item = o2.Dom.getNthNextWithAttribute('content', 'data-id', 42);
 
static getNthNextWithClass (Object elm, Integer n, String name)

Gets nth non-text-node next sibling of an element, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNthNextWithClass('content', 42, 'li');
 
static getNthNextWithId (Object elm, Integer n, String name)

Usage example:

 var item = o2.Dom.getNthNextWithId('content', 42, 'li');
 

Gets nth non-text-node next sibling of an element, having an "id" attribute defined.

static getNthParent (Object elm, Integer n, String name)

Gets nth parent node of an element.

Usage example:

 var item = o2.Dom.getNthParent('content', 42, 'li');
 
static getNthParentByAttribute (Object elm, String attribute, String value, Integer n, String name)

Usage example:

 var item = o2.Dom.getNthParentByAttribute('content', 'data-id', '42',
      42, 'li');
 

Gets nth parent node of an element, having a given attribute with a given value.

static getNthParentByClass (Object elm, String className, Integer n, String name)

Gets nth parent node of an element, having a given class name.

Usage example:

 var item = o2.Dom.getNthParentByClass('content', 'selected', 42, 'li');
 
static getNthParentWithAttribute (Object elm, String attribute, Integer n, String name)

Gets nth parent node of an element, having a given attribute defined.

Usage example:

 var item = o2.Dom.getNthParentWithAttribute('content', 'data-id', 42);
 
static getNthParentWithClass (Object elm, Integer n, String name)

Gets nth parent node of an element, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNthParentWithClass('content', 42, 'li');
 
static getNthParentWithId (Object elm, Integer n, String name)

Gets nth parent node of an element, having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getNthParentWithId('content', 42, 'li');
 
static getNthPrev (Object elm, Integer n, String name)

Gets nth previous sibling of an element that's not a text node.

Usage example:

 var item = o2.Dom.getNthPrev('content', 42, 'li');
 
static getNthPrevByAttribute (Object elm, String attribute, String value, Integer n, String name)

Gets nth previous sibling of an element that's not a text node, having a given attribute with a given value.

Usage example:

 var item = o2.Dom.getNthPrevByAttribute('content', 'data-id', '42',
      42, 'li');
 
static getNthPrevByClass (Object elm, String className, Integer n, String name)

Gets nth previous sibling of an element that's not a text node, having a given CSS class name.

Usage example:

 var item = o2.Dom.getNthPrevByClass('content', 'selected', 42, 'li');
 
static getNthPrevWithAttribute (Object elm, String attribute, Integer n, String name)

Gets nth previous sibling of an element that's not a text node, having a given attribute defined.

Usage example:

 var item = o2.Dom.getNthPrevWithAttribute('content', 'data-id', 42);
 
static getNthPrevWithClass (Object elm, Integer n, String name)

Gets nth previous sibling of an element that's not a text node, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNthPrevWithClass('content', 42, 'li');
 
static getNthPrevWithId (Object elm, Integer n, String name)

Gets nth previous sibling of an element that's not a text node, having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getNthPrevWithId('content', 42, 'li');
 
static getNthWithAttribute (Object elm, String attribute, Integer n, String name)

Usage example:

 var item = o2.Dom.getNthWithAttribute('content', 'data-id', 42, 'li');
 

Gets nth non-text-node sibling of an element, starting from the first sibling, having a given attribute defined.

static getNthWithClass (Object elm, Integer n, String name)

Gets nth non-text-node sibling of an element, starting from the first sibling, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNthWithClass('content', 42, 'li');
 
static getNthWithId (Object elm, Integer n, String name)

Usage example:

 var item = o2.Dom.getNthWithId('content', 42, 'li');
 

Gets nth non-text-node sibling of an element, starting from the first sibling, having an "id" attribute defined.

Gets the DOM object's scroll offset.

Usage example:

 var offsets = o2.Dom.getObjectScrollOfset('container');
 
static getOffset (Object e)
// * // *

Gets the left and top offset of a given element.

// * // *
static getOffsetLeft()
// * // *

An alias to o2.Dom.getOffset(obj).left.

// * // *
static getOffsetTop()
// * // *

An alias to o2.Dom.getOffset(obj).top.

// * // *
static getParent (Object elm, String name)

Gets the parent node of an element.

Usage example:

 var item = o2.Dom.getParent('content', 'li');
 
static getParentByAttribute (Object elm, String attribute, String value, String name)

Gets the parent node of an element, having an attribute with a given value.

Usage example:

 var item = o2.Dom.getParentByAttribute('content', 'data-id', '42', 'li');
 
static getParentByClass (Object elm, String className, String name)

Gets the parent node of an element, having a given CSS class name.

Usage example:

 var item = o2.Dom.getParentByClass('content', 'selected', 'li');
 
static getParentWithAttribute (Object elm, String attribute, String name)

Gets the parent node of an element, having a given attribute defined.

Usage example:

 var item = o2.Dom.getParentWithAttribute('content', 'selected', 'li');
 
static getParentWithClass (Object elm, String name)

Gets the parent node of an element, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getParentWithClass('content', 'li');
 
static getParentWithId (Object elm, String name)

Gets the parent node of an element, having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getParentWithId('content', 'li');
 
static getParents (Object elm, String name)

Gets all the parent nodes of an element.

Usage example:

 var items = o2.Dom.getParents('content', 'li');
 
static getParentsByAttribute (Object elm, String attribute, String value, String name)

Gets all the parent nodes of an element, having a given attribute with a given value.

Usage example:

 var items = o2.Dom.getParentsByAttribute('content', 'data-id', '42');
 
static getParentsByAttributeUntil (Object elm, String attribute, String value, Object until, String name)

Gets all the parent nodes of an element, having a given attribute with a given value, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getParentsByAttributeUntil('content', 'data-id', '42',
      'stopper', 'li');
 
static getParentsByClass (Object elm, String className, String name)

Gets all the parent nodes of an element, having a given CSS class name.

Usage example:

 var items = o2.Dom.getParentsByClass('content', 'selected', 'li');
 
static getParentsByClassUntil (Object elm, String className, Object until, String name)

Gets all the parent nodes of an element, having a given CSS class name, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getParentsByClassUntil('content', 'selected',
      'stopper', 'li');
 
static getParentsUntil (Object elm, Object until, String name)

Gets all the parent nodes of an element, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getParentsUntil('content', 'stopper', 'li');
 
static getParentsWithAttribute (Object elm, String attribute, String name)

Gets all the parent nodes of an element, having a given attribute defined.

Usage example:

 var items = o2.Dom.getParentsWithAttribute('content', 'data-id', 'li');
 
static getParentsWithAttributeUntil (Object elm, String attribute, Object until, String name)

Gets all the parent nodes of an element, having a given attribute defined, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getParentsWithAttributeUntil('content', 'data-id',
      'stopper', 'li');
 
static getParentsWithClass (Object elm, String name)

Gets all the parent nodes of an element, having a "class" attribute defined.

Usage example:

 var items = o2.Dom.getParentsWithClass('content', 'li');
 
static getParentsWithClassUntil (Object elm, Object until, String name)

Gets all the parent nodes of an element, having a "class" attribute defined, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getParentsWithClass('content', 'stopper', 'li');
 
static getParentsWithId (Object elm, String name)

Gets all the parent nodes of an element, having an "id" attribute defined.

Usage example:

 var items = o2.Dom.getParentsWithId('content', 'li');
 
static getParentsWithIdUntil (Object elm, Object until, String name)

Gets all the parent nodes of an element, having an "id" attribute defined, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getParentsWithIdUntil('content', 'stopper', 'li');
 
static getPrev (Object elm, String name)

Gets the previous sibling of an element that's not a text node.

Usage example:

 var item = o2.Dom.getPrev('content', 'li');
 
static getPrevAll (Object elm, String name)

Gets all previous sibling of an element, that are not text nodes.

Usage example:

 var items = o2.Dom.getPrevAll('content', 'li');
 
static getPrevAllByAttribute (Object elm, String attribute, String value, String name)

Gets all previous sibling of an element, that are not text nodes, having a given attribute with a given value.

Usage example:

 var items = o2.Dom.getPrevAllByAttribute('content', 'data-id', '42');
 
static getPrevAllByAttributeUntil (Object elm, String attribute, String value, Object until, String name)

Gets all previous sibling of an element, that are not text nodes, having a given attribute with a given value, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getPrevAllByAttributeUntil('content', 'data-id',
      '42', 'stopper', 'li');
 
static getPrevAllByClass (Object elm, String className, String name)

Gets all previous sibling of an element, that are not text nodes, having a given CSS class name.

Usage example:

 var items = o2.Dom.getPrevAllByClass('content', 'selected', 'li');
 
static getPrevAllByClassUntil (Object elm, String className, Object until, String name)

Gets all previous sibling of an element, that are not text nodes, having a given CSS class name, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getPrevAllByClassUntil('content', 'selected',
      'stopper', 'li');
 
static getPrevAllUntil (Object elm, Object until, String name)

Gets all previous sibling of an element, that are not text nodes, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getPrevAllUntil('content', 'stopper', 'li');
 
static getPrevAllWithAttribute (Object elm, String attribute, String name)

Gets all previous sibling of an element, that are not text nodes, having a given attribute defined.

Usage example:

 var items = o2.Dom.getPrevAllWithAttribute('content', 'data-id', 'li');
 
static getPrevAllWithAttributeUntil (Object elm, String attribute, Object until, String name)

Gets all previous sibling of an element, that are not text nodes, having a given attribute defined, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getPrevAllWithAttributeUntil('content', 'data-id',
      'stopper', 'li');
 
static getPrevAllWithClass (Object elm, String name)

Gets all previous sibling of an element, that are not text nodes, having a "class" attribute defined.

Usage example:

 var items = o2.Dom.getPrevAllWithClass('content', 'li');
 
static getPrevAllWithClassUntil (Object elm, Object until, String name)

Gets all previous sibling of an element, that are not text nodes, having a "class" attribute defined, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getPrevAllWithClassUntil('content', 'stopper', 'li');
 
static getPrevAllWithId (Object elm, String name)

Gets all previous sibling of an element, that are not text nodes, having an "id" attribute defined.

Usage example:

 var items = o2.Dom.getPrevAllWithId('content', 'li');
 
static getPrevAllWithIdUntil (Object elm, Object until, String name)

Gets all previous sibling of an element, that are not text nodes, having an "id" attribute defined, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getPrevAllWithIdUntil('content', 'stopper', 'li');
 
static getPrevByAttribute (Object elm, String attribute, String value, String name)

Gets the previous sibling of an element that's not a text node, having an attribute with a given value.

Usage example:

 var item = o2.Dom.getPrevByAttribute('content', 'data-id', '42', 'li');
 
static getPrevByClass (Object elm, String className, String name)

Gets the previous sibling of an element that's not a text node, having a given CSS class name.

Usage example:

 var item = o2.Dom.getPrevByClass('content', 'selected', 'li');
 
static getPrevWithAttribute (Object elm, String attribute, String name)

Gets the previous sibling of an element that's not a text node, having a given attribute defined.

Usage example:

 var item = o2.Dom.getPrevWithAttribute('content', 'data-id', 'li');
 
static getPrevWithClass (Object elm, String name)

Gets the previous sibling of an element that's not a text node, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getPrevWithClass('content', 'selected', 'li');
 
static getPrevWithId (Object elm, String name)

Gets the previous sibling of an element that's not a text node, having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getPrevWithId('content', 'selected', 'li');
 
static getScrollOffset()

An alias to o2.Dom.getObjectStrollOffset.

static getSiblings (Object elm, String name)

Gets the siblings of the element.

Usage example:

 var items = o2.Dom.getSiblings('content', 'li');
 
static getSiblingsByAttribute (Object elm, String attribute, String value, String name)

Gets the siblings of the element, having a given attribute equals a given value.

Usage example:

 var items = o2.Dom.getSiblingsByAttribute('content', 'data-id', '42');
 
static getSiblingsByAttributeUntil (Object elm, String attribute, String value, Object until, String name)

Gets the siblings of the element, having a given attribute equals a given value, until (but not included to) a specific node.

Usage example:

 var items = o2.Dom.getSiblingsByAttributeUntil('content', 'data-id',
      '42', 'stopper', 'li');
 
static getSiblingsByClass (Object elm, String name)

Gets the siblings of the element, having a given class name.

Usage example:

 var items = o2.Dom.getSiblingsByClass('content', 'selected', 'li');
 
static getSiblingsByClassUntil (Object elm, Object until, String name)

Gets the siblings of the element, having a given class name, until (but not included to) a specific node.

Usage example:

 var items = o2.Dom.getSiblingsByClassUntil('content', 'selected',
      'stopper', 'li');
 
static getSiblingsUntil (Object elm, Object until, String name)

Gets the siblings of the element until (but not included to) a specific node.

Usage example:

 var items = o2.Dom.getSiblingsUntil('content', 'stopper', 'li');
 
static getSiblingsWithAttribute (Object elm, String attribute, String name)

Gets the siblings of the element, having a given attribute defined.

Usage example:

 var items = o2.Dom.getSiblingsWithAttribute('content', 'dada-id', 'li');
 
static getSiblingsWithAttributeUntil (Object elm, String attribute, Object until, String name)

Gets the siblings of the element, having a given attribute defined, until (but not included to) a specific node.

Usage example:

 var items = o2.Dom.getSiblingsWithAttributeUntil('content', 'data-id',
      'stopper', 'li');
 
static getSiblingsWithClass (Object elm, String name)

Gets the siblings of the element, having "class" attribute defined.

Usage example:

 var items = o2.Dom.getSiblingsWithClass('content', 'li');
 
static getSiblingsWithClassUntil (Object elm, Object until, String name)

Gets the siblings of the element, having a "class" attribute defined, until (but not included to) a specific node.

Usage example:

 var items = o2.Dom.getSiblingsWithClassUntil('content', 'stopper', 'li');
 
static getSiblingsWithId (Object elm, String name)

Gets the siblings of the element, having an "id" attribute defined.

Usage example:

 var items = o2.Dom.getSiblingsWithId('content', 'li');
 
static getSiblingsWithIdUntil (Object elm, Object until, String name)

Usage example:

 var items = o2.Dom.getSiblingsWithIdUntil('content', 'stopper', 'li');
 

Gets the siblings of the element, having an "id" attribute defined, until (but not included to) a specific node.

static getStyle (Object elm, String cssProperty, Boolean isNoForce)

Gets the style of a given property of the element.

Tries to parse the currentStyle, if available; otherwise tries to calculate the style using window.getComputedStyle; gets obj.style if everything else fails.

Note that adding and removing style attributes to a DOM not is considered "bad practice". Do not use inline styles to modify the view; assign className's instead of style values.

Usage example:

 var color = o2.Dom.getStyle('container', 'color');
 
static getText (Object elm)

Gets the textual content of the given node, replacing entities like & amp; with it's corresponding character counterpart (& in this example).

Usage example:

 var txt = o2.Dom.getText('container');
 
static getViewportInfo()

Gets the viewport information in the form {scrollTop : #, scrollLeft: #, width: #, height: #}.

Usage example:

 var details = o2.Dom.getViewportInfo();
 
static getWidth (Object obj)

Gets the width of the given element, in pixels.

Gets the dimension of the visible area of the browser in the form {width: w, height: h}.

Usage example:

 var windowDimensions = o2.Dom.getWindowInnerDimension();
 

Gets the inner height of the visible area.

Usage example:

 var innerHeight = o2.Dom.getWindow.innerHeight();
 

Gets the inner width of the visible area.

Usage example:

 var innerWidth = o2.Dom.getWindowInnerWidth();
 

Gets the window's scroll offset.

Usage example:

 var offsets = o2.Dom.getWindowScrollOffset();
 
static hasClass (DomNode el, String c)

Checks whether an element has the given className.

Usage example:

 if (o2.Dom.hasClass('container', 'active')) {
      doStuff();
 }
 
static hide (Object obj)

Hides the given object.

Usage example:

 o2.Dom.hide('container');
 
static insertAfter (Object elmNewNode, Object elmRefNode)

Adds the node after the reference node.

Usage example:

 var ref = o2.$('ref');
 var new = o2.$('new');
 o2.Dom.insertAfter(new, ref);
 
static insertBefore (Object elmNewNode, Object elmRefNode)

Adds the node before the reference node.

Usage example:

 var ref = o2.$('ref');
 var new = o2.$('new');
 o2.Dom.insertBefore(new, ref);
 
static isChild (Object elm, Object ref)

Checks whether elm is the child of ref.

Usage example:

 var isChild = o2.Dom.isChild('child', 'parent');
 
static isDocument (DOMNode obj)

Checks whether the given node is a document node.

Usage example:

 var isDocument = o2.Dom.isDocument(currentNode);
 
static isElement (DOMNode obj)

Checks whether the given node is an element node.

Usage example:

 var isElement = o2.Dom.isElement(currentNode);
 
static isNext (Object elm, Object ref)

Checks whether elm is a sibling after ref.

Usage example:

 var isNext = o2.Dom.isNext('itemId', 'refId');
 
static isParent (Object elm, Object ref)

Checks whether elm is a parent of ref.

Usage example:

 var isParent = o2.Dom.isParent('itemId', 'refId');
 
static isParentOrSelf (Object elm, Object ref)

Checks whether elm is parent of ref, or it's the ref itself.

Usage example:

 var isParent = o2.Dom.isParentOrSelf('itemId', 'refId');
 
static isPrev (Object elm, Object ref)

Checks whether elm is a sibling before ref.

Usage example:

 var isParent = o2.Dom.isPrev('itemId', 'refId');
 
static isSibling (Object elm, Object ref)

Checks whether elm is a sibling of ref.

Usage example:

 var isSibling = o2.Dom.isSibling('itemId', 'refId');
 
static isVisible (Object obj)

Checks whether the DOM node is visible.

Note that being visible does not necessarily mean being available inside the viewport.

If a DOM node has display == 'none' or visibility == 'hidden' CSS properties, then it's regarded as "invisible", otherwise it is considered to be "visible".

Usage example:

 var isContainerVisible = o2.Dom.isVisible('container');
 
static loadCss (String src, Function successCallback)

Asynchronously loads a css file with a given src.

Cross-domain loading is also okay: The css file does not have to be in the same domain as the web page.

The success and failure callbacks is a somewhat hacky way of handling CSS load events. In deed, detecting CSS load is not an easy task, and it's not necessary most of the time.

Though it may get handy to prevent the Flash of Unstyled Content (FOUC) issues.

A more robust way of handling load callbacks is polling the property of a test element (such as the background color), that you know that the loaded CSS will change for sure.

Usage example:

 o2.Dom.loadCss('http://cdn.example/com/theme.css', function() {
      handleSuccess();
 });
 
static loadImage (String url, Function successCallback)

Tries to load the image into a JavaScript Image object; then triggers successCallback or failureCallback depending on the result of the load attempt.

This function can be used for pre-loading or post-loading images.

Usage example:

 o2.Dom.loadImage('http//asset.example.com/spinner.png', function() {
      handleSuccess();
 });
 
static loadScript (String src, Function callback)

Asynchronously loads a script with a given src.

Cross-domain loading is also okay: The script does not have to be in the same domain as the web page.

Usage example:

 o2.Dom.loadImage('http//asset.example.com/script.js', function() {
      handleSuccess();
 });
 
static prepend (Object elmChild, Object elmParent)

Prepends the element to the top of its parent.

Usage example:

 var child = o2.$('ChildContainer');
 var parent = o2.$('MasterContainer');
 o2.Dom.prepend(child, parent);
 

Prevents the form to re-submit itself when the submit button is pressed more than once.

Usage example:

 o2.Dom.preventMultipleSubmit('actionForm');
 
static ready (Function delegate)

Fires when the HTML DOM is ready.

Usage example:

 o2.Dom.ready(function() {
      doInitializaton();
 });
 
static remove (Object e)

Removes the element from the DOM flow.

Usage example:

 o2.Dom.remove('nagivation');
 
static removeChildren (Object e)

Removes all the children of the element.

Usage example:

 o2.Dom.removeChildren('container');
 
static removeClass (DomNode el, String c)

Removes a class name from the given node.

Usage example:

 o2.Dom.removeClass('container', 'active');
 

Removes empty text nodes from the element.

Note that this removal is not recursive; only the first-level empty child nodes of the element will be removed.

Usage example:

 o2.Dom.removeEmptyTextNodes('container');
 
static removeNode()

An alias to o2.Dom.remove.

static replace ( elmTarget, elmToReplace)

Replaces one node with another.

Usage example:

 o2.Dom.replace('firstContainer', 'secondContainer');
 

Scrolls an element to bottom.

Usage example:

 o2.Dom.scrollObjectToBottom('container');
 
static scrollObjectToTop (Object obj)

Scrolls an element to top.

Usage example:

 o2.Dom.scrollObjectToTop('container');
 
static scrollTo()

Usage example:

 o2.Dom.scrollWindowToBottom();
 

Scrolls window to bottom.

Usage example:

 o2.Dom.scrollWindowToTop();
 

Scrolls window to top.

static setAttribute (Object elm, String attribute, String value)

Sets the attribute of the given object.

Usage example:

 o2.Dom.setAttribute('container', 'data-user-id', '123');
 
static setCss()

An alias to o2.Dom.addStyle.

static setDimension (Object obj, Object dimension)

Sets the dimension of the given element.

Usage example:

 o2.Dom.setDimension('container', {width: 400, height: 200});
 
static setHeight (Object obj, Integer height)

Sets the height of the given element.

Usage example:

 o2.Dom.setHeight('container', 300);
 
static setHtml (Object elm)

Simply sets the innerHTML of the element.

Usage example:

 o2.Dom.setHtml('container', '[h1]hello[/h1]');
 
static setStyle()

An alias to o2.Dom.addStyle.

static setWidth (Object obj, Integer width)

Sets the width of the given element.

Usage example:

 o2.Dom.setWidth('container', 500);
 
static show (Object elm)

Shows the given object.

Usage example:

 o2.Dom.show('container');
 
static toggleClass (Object el, String c, Boolean state)

Toggles the CSS className of a given element.

Usage example:

 o2.Dom.toggleClass('container', 'active');
 
static toggleVisibility (Object elm, Boolean state)

Toggles the visibility of the given element.

Usage example:

 o2.Dom.toggleVisibility('container');
 
static trimField (Object field)

Trims a given field, and returns the trimmed value.

Usage example:

 o2.Dom.trimField('txtInput');
 
static unwrap (Object elmTarget)

This is like o2.Dom.wrap in reverse.

Moves all the elements inside the container to the container's position and removes the container from the DOM.

Usage example:

 o2.Dom.unwrap('container');
 
public static wrap (Object elmTarget, Object elmWrapper)

Puts the target element into the wrapper element.

Usage example:

 var wrapper = o2.$('wrapper');
 var target = o2.$('content');
 o2.Dom.wrap(target, wrapper);
 

Function Details

function activateAlternateStylesheet

static activateAlternateStylesheet(String title)

Activates the alternate stylesheet with the given title.

Usage example:

 o2.Dom.activateAlternateStylesheet('alternateTheme');
 
Parameters:
title - the title of the alternate stylesheet to activate.

function addClass

static addClass(DomNode el, String c)

Add a class to the given node.

Usage example:

 o2.Dom.addClass('container', 'active');
 
Parameters:
el - either the element, or the id of it.
c - the className to add.

function addCssRules

static addCssRules()

Adds the CSS rules given in the cssText parameter to the document.

Usage example:

 o2.Dom.addCssRules(
      'div.warning { background-color:#c00; color:#fff };'
 );
 

function addStyle

static addStyle(Object obj, Object style)

Adds style attributes to a DOM node.

Note that adding and removing style attributes to a DOM not is considered "bad practice". Do not use inline styles to modify the view; assign className's instead of style values.

Usage example:

 o2.Dom.addStyle('container', {color : '#bada55'})
 
Parameters:
obj - the current DOM node, or the id of that node, to add styles to.
style - styles in the form {style1:value1, style2:value2}.

function append

static append(Object elmChild, Object elmParent)

Appends the element to the bottom of its parent.

Usage example:

 var child = o2.$('childNode');
 var parent = o2.$('parentNode');
 o2.Dom.append(child, parent);
 
Parameters:
elmChild - the child node, or the id of the node to append.
elmParent - the parent container, or the id of the container.

function compactField

static compactField(Object field)

Trims a given field, and returns the compacted value.

Usage example:

 o2.Dom.compactField('txtInput');
 
Parameters:
field - the field to be compacted, or its id.
Returns:
field's compacted value; or null if the field does not exist.
See also:

function create

static create()

An alias to o2.Dom.createElement.


function createClassNameRegExp

static createClassNameRegExp(String c)

Creates a regular expression that will match a given CSS class name.

Usage example:

 var reg = o2.Dom.createClassNameRegExp('testClass');
 
Parameters:
c - The name of the class.
Returns:
a RegExp that matches the given class name.

function createDocumentFragment

static createDocumentFragment(String html)

Creates a Document Fragment from an HTML String.

Usage example:

 var frag = o2.Dom.createDocumentFragment('[div]test[/div]');
 
Parameters:
html - the HTML to create a fragment from.
Returns:
{HTMLDocumentFragment} - the generated document fragment.

function createElement

static createElement(String name, Object attributes)

Creates an element with given name and attributes.

Usage example:

 var el = o2.Dom.createElement(
      'div',
      {className : 'active', style : 'font-weight : bold'}
 );
 
Parameters:
name - the node name of the element (i.e. 'div', 'a').
attributes - an associative array in the form {att1:value1, att2:value2}.
Returns:
the created element.

function empty

static empty(Object elm)

An alias to o2.Dom.removeChildren.

Parameters:
elm - either the element, or the id of it to process.

function getAttribute

static getAttribute(Object elm, String attribute)

Gets the attribute of a given node.

Usage example:

 var uid = o2.Dom.getAttribute('container', 'data-user-id');
 
Parameters:
elm - the node, or the id of the node, to get the attribute of.
attribute - the attribute to gather.
Returns:
the value of the attribute if found; null otherwise.

function getChildrenByAttributeUntil

static getChildrenByAttributeUntil(Object elm, String attribute, String value, Object until, String name)

Gets the children of the element until a given node (exclusive).

Usage example:

 var items = o2.Dom.getChildrenByAttributeUntil('container',
      'data-user-id', '42', o2.$('stopper'), 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getChildrenByClass

static getChildrenByClass(Object elm, String className, String name)

Gets the children of the element having a specific class.

Usage example:

 var items = o2.Dom.getChildrenByClass('container', 'active', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getChildrenByClassUntil

static getChildrenByClassUntil(Object elm, String className, Object until, String name)

Gets the children of the element having a specific class, and until (but not included to) a given element.

Usage example:

 var items = o2.Dom.getChildrenByClassUntil('container', 'active',
      o2.$('stopper'), 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getChildrenUntil

static getChildrenUntil(Object elm, Object until, String name)

Gets the children of the element until (but not included to) a given element.

Usage example:

 var items = o2.Dom.getChildrenUntil('container', o2.$('stopper'), 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getChildrenWithAttribute

static getChildrenWithAttribute(Object elm, String attribute, String name)

Gets the children of the element having a given attribute defined.

Usage example:

 var items = o2.Dom.getChildrenWithAttribute('container', 'data-user-id',
 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getChildrenWithAttributeUntil

static getChildrenWithAttributeUntil(Object elm, String attribute, Object until, String name)

Gets the children of the element with a given attribute defined, and until (but not included to) a given element.

Usage example:

 var items = o2.Dom.getChildrenWithAttributeUntil('content',
      'data-user-id', o2.$('stopper'), 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getChildrenWithClass

static getChildrenWithClass(Object elm, String name)

Gets the children of the element with a "class" attribute defined.

Usage example:

 var items = o2.Dom.getChildrenWithClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getChildrenWithClassUntil

static getChildrenWithClassUntil(Object elm, Object until, String name)

Gets the children of the element with a "class" attribute defined, and until (but not included to) a given element.

Usage example:

 var items = o2.Dom.getChildrenWithClassUntil('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getChildrenWithId

static getChildrenWithId(Object elm, String name)

Gets the children of the element with an "id" attribute defined.

Usage example:

 var items = o2.Dom.getChildrenWithId('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getChildrenWithIdUntil

static getChildrenWithIdUntil(Object elm, Object until, String name)

Gets the children of the element with an "id" attribute defined, and until (but not included to) a given element.

Usage example:

 var items = o2.Dom.getChildrenWithIdUntil('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getCss

static getCss()

An alias to o2.Dom.getStyle.

See also:

function getDimension

static getDimension(Object obj)

Gets the dimension of the given element in the form {width: w, height: h}, where w and h are in pixels.

Usage example:

 var dimensions = o2.Dom.getDimension('container');
 
Parameters:
obj - the DOMNode to get the dimension of, or the String id of it.
Returns:
the dimension of the DOMNode in the form {width: w, height: h}.

function getDocumentDimension

static getDocumentDimension()

Gets the dimension of the document in the form {width: w, height: h}. If the visible (i.e. clientHeight) is greater than the document's height returns the height of the visible area as the height portion.

Usage example:

 var viewportInfo = o2.Dom.getDocumentDimension();
 
Returns:
the dimension of the document in the form {width: w, height: h}.

function getDocumentHeight

static getDocumentHeight()

Gets the total height of the document in pixels.

Usage example:

 var viewportHeight = o2.Dom.getDocumentHeight();
 
Returns:
the document's height.

function getDocumentWidth

static getDocumentWidth()

Gets the total width of the document in pixels.

Usage example:

 var viewportWidth = o2.Dom.getDocumentWidth();
 
Returns:
the document's width.

function getElements

static getElements(Object elm, String name)

Gets all of the elements of the node elm.

Usage example:

 var items = o2.Dom.getElements('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getElementsByAttribute

static getElementsByAttribute(Object elm, String attribute, String value, String name)

Gets all of the elements of the node elm, filtering the nodes having a given attribute equals to a given value.

Usage example:

 var items = o2.Dom.getElementsByAttribute('content', 'data-id', '42');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getElementsByClass

static getElementsByClass(Object elm, String className, String name)

Gets all of the elements of the node elm, having a given CSS class name.

Usage example:

 var items = o2.Dom.getElementsByClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getElementsWithAttribute

static getElementsWithAttribute(Object elm, String attribute, String name)

Gets all of the elements of the node elm, having a given attribute defined.

Usage example:

 var items = o2.Dom.getElementsWithAttribute('content', 'data-id', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getElementsWithClass

static getElementsWithClass(Object elm, String name)

Gets all of the elements of the node elm, having a 'class" attribute defined.

Usage example:

 var items = o2.Dom.getElementsWithClass('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getElementsWithId

static getElementsWithId(Object elm, String name)

Gets all of the elements of the node elm, having an 'id" attribute defined.

Usage example:

 var items = o2.Dom.getElementsWithId('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getFirst

static getFirst(Object elm, String name)

Gets the first sibling of the element that's not a text node.

Usage example:

 var item = o2.Dom.getFirst('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first sibling available with the given criteria, if found; null otherwise.

function getFirstByAttribute

static getFirstByAttribute(Object elm, String attribute, String value, String name)

Gets the first sibling of the element that's not a text node, and having an attibute with a given value.

Usage example:

 var item = o2.Dom.getFirstByAttribute('content', 'data-id', '42');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first sibling available with the given criteria, if found; null otherwise.

function getFirstByClass

static getFirstByClass(Object elm, String className, String name)

Gets the first sibling of the element that's not a text node, and having a given CSS class name.

Usage example:

 var item = o2.Dom.getFirstByClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first sibling available with the given criteria, if found; null otherwise.

function getFirstChild

static getFirstChild(Object elm, String name)

Gets the first child of the element that's not a text node.

Usage example:

 var item = o2.Dom.getFirstChild('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first child available with the given criteria, if found; null otherwise.

function getFirstChildByAttribute

static getFirstChildByAttribute(Object elm, String attribute, String value, String name)

Gets the first child of the element that's not a text node, and having an attribute with a given value.

Usage example:

 var item = o2.Dom.getFirstChildByAttribute('content', 'data-id', '42');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first child available with the given criteria, if found; null otherwise.

function getFirstChildByClass

static getFirstChildByClass(Object elm, String className, String name)

Gets the first child of the element that's not a text node, and having a given class name.

Usage example:

 var item = o2.Dom.getFirstChildByClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first child available with the given criteria, if found; null otherwise.

function getFirstChildWithAttribute

static getFirstChildWithAttribute(Object elm, String attribute, String name)

Gets the first child of the element that's not a text node, and having a given attribute defined.

Usage example:

 var item = o2.Dom.getFirstChildWithAttribute('content', 'data-id', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first child available with the given criteria, if found; null otherwise.

function getFirstChildWithClass

static getFirstChildWithClass(Object elm, String name)

Gets the first child of the element that's not a text node, and having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getFirstChildWithClass('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first child available with the given criteria, if found; null otherwise.

function getFirstChildWithId

static getFirstChildWithId(Object elm, String name)

Gets the first child of the element that's not a text node, and having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getFirstChildWithId('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first child available with the given criteria, if found; null otherwise.

function getFirstWithAttribute

static getFirstWithAttribute(Object elm, String attribute, String name)

Gets the first sibling of the element that's not a text node, and having a given attribute defined.

Usage example:

 var item = o2.Dom.getFirstWithAttribute('content', 'data-id', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first sibling available with the given criteria, if found; null otherwise.

function getFirstWithClass

static getFirstWithClass(Object elm, String name)

Gets the first sibling of the element that's not a text node, and having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getFirstWithClass('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first sibling available with the given criteria, if found; null otherwise.

function getFirstWithId

static getFirstWithId(Object elm, String name)

Gets the first sibling of the element that's not a text node, and having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getFirstWithId('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first sibling available with the given criteria, if found; null otherwise.

function getHeight

static getHeight(Object obj)

Gets the height of the given element, in pixels.

Usage example:

 var containerHeight = o2.Dom.getHeight('container');
 
Parameters:
obj - the DOMNode to get the dimension of, or the String id of it.
Returns:
the height of the element, in pixels.

function getHtml

static getHtml(Object elm)

Gets the HTML of a given element.

Usage example:

 var html = o2.Dom.getHtml('container');
 
Parameters:
elm - the DOM node or its String id.
Returns:
the innerHTML of the given node, if it exists; null otherwise.

function getLast

static getLast(Object elm, String name)

Gets the last sibling of the element that's not a text node.

Usage example:

 var item = o2.Dom.getLast('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the last sibling available with the given criteria, if found; null otherwise.

function getLastByAttribute

static getLastByAttribute(Object elm, String attribute, String value, String name)

Gets the last sibling of the element that's not a text node, and has an attribute with a given value.

Usage example:

 var item = o2.Dom.getLastByAttribute('content', 'data-id', '42');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the last sibling available with the given criteria, if found; null otherwise.

function getLastByClass

static getLastByClass(Object elm, String className, String name)

Gets the last sibling of the element that's not a text node, and has a given class name.

Usage example:

 var item = o2.Dom.getLastByClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the last sibling available with the given criteria, if found; null otherwise.

function getLastChild

static getLastChild(Object elm, String name)

Gets the last child of the element that's not a text node.

Usage example:

 var item = o2.Dom.getLastChild('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the last child available with the given criteria, if found; null otherwise.

function getLastChildByAttribute

static getLastChildByAttribute(Object elm, String attribute, String value, String name)

Gets the last child of the element that's not a text node, and having an attribute with a given value.

Usage example:

 var item = o2.Dom.getLastChildByAttribute('content', 'data-id', '42');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the last child available with the given criteria, if found; null otherwise.

function getLastChildByClass

static getLastChildByClass(Object elm, String className, String name)

Gets the last child of the element that's not a text node, and having a given CSS class name.

Usage example:

 var item = o2.Dom.getLastChildByClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the last child available with the given criteria, if found; null otherwise.

function getLastChildWithAttribute

static getLastChildWithAttribute(Object elm, String attribute, String name)

Gets the last child of the element that's not a text node, and having a given attribute defined.

Usage example:

 var item = o2.Dom.getLastChildWithAttribute('content', 'data-id', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the last child available with the given criteria, if found; null otherwise.

function getLastChildWithClass

static getLastChildWithClass(Object elm, String className, String name)

Gets the last child of the element that's not a text node, and having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getLastChildWithClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the last child available with the given criteria, if found; null otherwise.

function getLastChildWithId

static getLastChildWithId(Object elm, String name)

Gets the last child of the element that's not a text node, and having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getLastChildWithId('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the last child available with the given criteria, if found; null otherwise.

function getLastWithAttribute

static getLastWithAttribute(Object elm, String attribute, String name)

Gets the last sibling of the element that's not a text node, and has a given attribute defined.

Usage example:

 var item = o2.Dom.getLastWithAttribute('content', 'data-id', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the last sibling available with the given criteria, if found; null otherwise.

function getLastWithClass

static getLastWithClass(Object elm, String className, String name)

Gets the last sibling of the element that's not a text node, and has a "class" attribute defined.

Usage example:

 var item = o2.Dom.getLastWithClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the last sibling available with the given criteria, if found; null otherwise.

function getLastWithId

static getLastWithId(Object elm, String name)

Gets the last sibling of the element that's not a text node, and has an "id" attribute defined.

Usage example:

 var item = o2.Dom.getLastWithId('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the last sibling available with the given criteria, if found; null otherwise.

function getNext

static getNext(Object elm, String name)

Gets the next sibling of the element, that's not a text node.

Usage example:

 var item = o2.Dom.getNext('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the next sibling available with the given criteria, if found; null otherwise.

function getNextAll

static getNextAll(Object elm, String name)

Gets all the following siblings of the element that are not text nodes.

Usage example:

 var item = o2.Dom.getNextAll('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getNextAllByAttribute

static getNextAllByAttribute(Object elm, String attribute, String value, String name)

Gets all the following siblings of the element that are not text nodes, having an attribute with a given value.

Usage example:

 var item = o2.Dom.getNextAllByAttribute('content', 'data-id', '42');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getNextAllByAttributeUntil

static getNextAllByAttributeUntil(Object elm, String attribute, String value, Object until, String name)

Gets all the following siblings of the element that are not text nodes, having an attribute with a given value, until (but not included to) a given DOM node.

Usage example:

 var item = o2.Dom.getNextAllByAttributeUntil('content', 'data-id', '42',
      'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getNextAllByClass

static getNextAllByClass(Object elm, String className, String name)

Gets all the following siblings of the element that are not text nodes, having a given CSS class name.

Usage example:

 var item = o2.Dom.getNextAllByClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getNextAllByClassUntil

static getNextAllByClassUntil(Object elm, String className, Object until, String name)

Gets all the following siblings of the element that are not text nodes, having a given CSS class name, until (but not included to) a given DOM node.

Usage example:

 var item = o2.Dom.getNextAllByClassUntil('content', 'selected',
      'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getNextAllUntil

static getNextAllUntil(Object elm, Object until, String name)

Gets all the following siblings of the element that are not text nodes, until (but not included to) a given DOM node.

Usage example:

 var item = o2.Dom.getNextAllUntil('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getNextAllWithAttribute

static getNextAllWithAttribute(Object elm, String attribute, String name)

Gets all the following siblings of the element that are not text nodes, having a given attribute defined.

Usage example:

 var item = o2.Dom.getNextAllWithAttribute('content', 'data-id', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getNextAllWithAttributeUntil

static getNextAllWithAttributeUntil(Object elm, String attribute, Object until, String name)

Gets all the following siblings of the element that are not text nodes, having a given attribute defined, until (but not included to) a given DOM node.

Usage example:

 var item = o2.Dom.getNextAllWithAttributeUntil('content', 'data-id',
      'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getNextAllWithClass

static getNextAllWithClass(Object elm, String name)

Gets all the following siblings of the element that are not text nodes, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNextAllWithClass('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getNextAllWithClassUntil

static getNextAllWithClassUntil(Object elm, Object until, String name)

Gets all the following siblings of the element that are not text nodes, having a "class" attribute defined, until (but not included to) a given DOM node.

Usage example:

 var item = o2.Dom.getNextAllWithClassUntil('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getNextAllWithId

static getNextAllWithId(Object elm, String name)

Gets all the following siblings of the element that are not text nodes, having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getNextAllWithId('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getNextAllWithIdUntil

static getNextAllWithIdUntil(Object elm, Object until, String name)

Gets all the following siblings of the element that are not text nodes, having an "id" attribute defined, until (but not included to) a given DOM node.

Usage example:

 var item = o2.Dom.getNextAllWithIdUntil('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getNextByAttribute

static getNextByAttribute(Object elm, String attribute, String value, String name)

Gets the next sibling of the element, that's not a text node, and having an attribute with a given value.

Usage example:

 var item = o2.Dom.getNextByAttribute('content', 'data-id', '42', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the next sibling available with the given criteria, if found; null otherwise.

function getNextByClass

static getNextByClass(Object elm, String className, String name)

Usage example:

 var item = o2.Dom.getNextByClass('content', 'selected', 'li');
 

Gets the next sibling of the element, that's not a text node, and having a given CSS class name.

Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the next sibling available with the given criteria, if found; null otherwise.

function getNextWithAttribute

static getNextWithAttribute(Object elm, String attribute, String name)

Gets the next sibling of the element, that's not a text node, and having a given attribute defined.

Usage example:

 var item = o2.Dom.getNextWithAttribute('content', 'data-id', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the next sibling available with the given criteria, if found; null otherwise.

function getNextWithClass

static getNextWithClass(Object elm, String name)

Gets the next sibling of the element, that's not a text node, and having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNextWithClass('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the next sibling available with the given criteria, if found; null otherwise.

function getNextWithId

static getNextWithId(Object elm, String name)

Gets the next sibling of the element, that's not a text node, and having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getNextWithId('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the next sibling available with the given criteria, if found; null otherwise.

function getNth

static getNth(Object elm, Integer n, String name)

Gets nth non-text-node sibling of an element, starting from the first sibling.

Usage example:

 var item = o2.Dom.getNth('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth sibling available with the given criteria, if found; null otherwise.

function getNthByAttribute

static getNthByAttribute(Object elm, String attribute, String value, Integer n, String name)

Gets nth non-text-node sibling of an element, starting from the first sibling, having a given attribute with a given value.

Usage example:

 var item = o2.Dom.getNthByAttribute('content', 'data-id', '42', 42);
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth sibling available with the given criteria, if found; null otherwise.

function getNthByClass

static getNthByClass(Object elm, String className, Integer n, String name)

Gets nth non-text-node sibling of an element, starting from the first sibling, having a given CSS class name.

Usage example:

 var item = o2.Dom.getNthByAttribute('content', 'selected', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth sibling available with the given criteria, if found; null otherwise.

function getNthChild

static getNthChild(Object elm, Integer n, String name)

Gets nth non-text-node child of an element.

Usage example:

 var item = o2.Dom.getNthChild('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth child available with the given criteria, if found; null otherwise.

function getNthChildByAttribute

static getNthChildByAttribute(Object elm, String attribute, String value, Integer n, String name)

Gets nth non-text-node child of an element, having a given attribute with a given value.

Usage example:

 var item = o2.Dom.getNthChildByAttribute('content', 'data-id', '42', 42);
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth child available with the given criteria, if found; null otherwise.

function getNthChildByClass

static getNthChildByClass(Object elm, String className, Integer n, String name)

Gets nth non-text-node child of an element, having a given attribute with a given CSS class name.

Usage example:

 var item = o2.Dom.getNthChildByClass('content', 'selected', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth child available with the given criteria, if found; null otherwise.

function getNthChildWithAttribute

static getNthChildWithAttribute(Object elm, String attribute, Integer n, String name)

Gets nth non-text-node child of an element, with a given attribute defined.

Usage example:

 var item = o2.Dom.getNthChildWithAttribute('content', 'data-id', 42);
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth child available with the given criteria, if found; null otherwise.

function getNthChildWithClass

static getNthChildWithClass(Object elm, Integer n, String name)

Gets nth non-text-node child of an element, with a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNthChildWithClass('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth child available with the given criteria, if found; null otherwise.

function getNthChildWithId

static getNthChildWithId(Object elm, Integer n, String name)

Gets nth non-text-node child of an element, with a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNthChildWithId('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth child available with the given criteria, if found; null otherwise.

function getNthNext

static getNthNext(Object elm, Integer n, String name)

Gets nth non-text-node next sibling of an element.

Usage example:

 var item = o2.Dom.getNthNext('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth next sibling available with the given criteria, if found; null otherwise.

function getNthNextByAttribute

static getNthNextByAttribute(Object elm, String attribute, String value, Integer n, String name)

Gets nth non-text-node next sibling of an element, having a given attribute with a given value.

Usage example:

 var item = o2.Dom.getNthNextByAttribute('content', 'data-id', '42', 42);
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth next sibling available with the given criteria, if found; null otherwise.

function getNthNextByClass

static getNthNextByClass(Object elm, String className, Integer n, String name)

Gets nth non-text-node next sibling of an element, having a given CSS class name.

Usage example:

 var item = o2.Dom.getNthNextByClass('content', 'selected', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth next sibling available with the given criteria, if found; null otherwise.

function getNthNextWithAttribute

static getNthNextWithAttribute(Object elm, String attribute, Integer n, String name)

Gets nth non-text-node next sibling of an element, having a given attribute defined.

Usage example:

 var item = o2.Dom.getNthNextWithAttribute('content', 'data-id', 42);
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth next sibling available with the given criteria, if found; null otherwise.

function getNthNextWithClass

static getNthNextWithClass(Object elm, Integer n, String name)

Gets nth non-text-node next sibling of an element, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNthNextWithClass('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth next sibling available with the given criteria, if found; null otherwise.

function getNthNextWithId

static getNthNextWithId(Object elm, Integer n, String name)

Usage example:

 var item = o2.Dom.getNthNextWithId('content', 42, 'li');
 

Gets nth non-text-node next sibling of an element, having an "id" attribute defined.

Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth next sibling available with the given criteria, if found; null otherwise.

function getNthParent

static getNthParent(Object elm, Integer n, String name)

Gets nth parent node of an element.

Usage example:

 var item = o2.Dom.getNthParent('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth parent available with the given criteria, if found; null otherwise.

function getNthParentByAttribute

static getNthParentByAttribute(Object elm, String attribute, String value, Integer n, String name)

Usage example:

 var item = o2.Dom.getNthParentByAttribute('content', 'data-id', '42',
      42, 'li');
 

Gets nth parent node of an element, having a given attribute with a given value.

Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth parent available with the given criteria, if found; null otherwise.

function getNthParentByClass

static getNthParentByClass(Object elm, String className, Integer n, String name)

Gets nth parent node of an element, having a given class name.

Usage example:

 var item = o2.Dom.getNthParentByClass('content', 'selected', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth parent available with the given criteria, if found; null otherwise.

function getNthParentWithAttribute

static getNthParentWithAttribute(Object elm, String attribute, Integer n, String name)

Gets nth parent node of an element, having a given attribute defined.

Usage example:

 var item = o2.Dom.getNthParentWithAttribute('content', 'data-id', 42);
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth parent available with the given criteria, if found; null otherwise.

function getNthParentWithClass

static getNthParentWithClass(Object elm, Integer n, String name)

Gets nth parent node of an element, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNthParentWithClass('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth parent available with the given criteria, if found; null otherwise.

function getNthParentWithId

static getNthParentWithId(Object elm, Integer n, String name)

Gets nth parent node of an element, having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getNthParentWithId('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth parent available with the given criteria, if found; null otherwise.

function getNthPrev

static getNthPrev(Object elm, Integer n, String name)

Gets nth previous sibling of an element that's not a text node.

Usage example:

 var item = o2.Dom.getNthPrev('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth previous sibling available with the given criteria, if found; null otherwise.

function getNthPrevByAttribute

static getNthPrevByAttribute(Object elm, String attribute, String value, Integer n, String name)

Gets nth previous sibling of an element that's not a text node, having a given attribute with a given value.

Usage example:

 var item = o2.Dom.getNthPrevByAttribute('content', 'data-id', '42',
      42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth previous sibling available with the given criteria, if found; null otherwise.

function getNthPrevByClass

static getNthPrevByClass(Object elm, String className, Integer n, String name)

Gets nth previous sibling of an element that's not a text node, having a given CSS class name.

Usage example:

 var item = o2.Dom.getNthPrevByClass('content', 'selected', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth previous sibling available with the given criteria, if found; null otherwise.

function getNthPrevWithAttribute

static getNthPrevWithAttribute(Object elm, String attribute, Integer n, String name)

Gets nth previous sibling of an element that's not a text node, having a given attribute defined.

Usage example:

 var item = o2.Dom.getNthPrevWithAttribute('content', 'data-id', 42);
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth previous sibling available with the given criteria, if found; null otherwise.

function getNthPrevWithClass

static getNthPrevWithClass(Object elm, Integer n, String name)

Gets nth previous sibling of an element that's not a text node, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNthPrevWithClass('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth previous sibling available with the given criteria, if found; null otherwise.

function getNthPrevWithId

static getNthPrevWithId(Object elm, Integer n, String name)

Gets nth previous sibling of an element that's not a text node, having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getNthPrevWithId('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth previous sibling available with the given criteria, if found; null otherwise.

function getNthWithAttribute

static getNthWithAttribute(Object elm, String attribute, Integer n, String name)

Usage example:

 var item = o2.Dom.getNthWithAttribute('content', 'data-id', 42, 'li');
 

Gets nth non-text-node sibling of an element, starting from the first sibling, having a given attribute defined.

Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth sibling available with the given criteria, if found; null otherwise.

function getNthWithClass

static getNthWithClass(Object elm, Integer n, String name)

Gets nth non-text-node sibling of an element, starting from the first sibling, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getNthWithClass('content', 42, 'li');
 
Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth sibling available with the given criteria, if found; null otherwise.

function getNthWithId

static getNthWithId(Object elm, Integer n, String name)

Usage example:

 var item = o2.Dom.getNthWithId('content', 42, 'li');
 

Gets nth non-text-node sibling of an element, starting from the first sibling, having an "id" attribute defined.

Parameters:
elm - the element reference, or a String id of it.
n - the element index.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the nth sibling available with the given criteria, if found; null otherwise.

function getObjectScrollOffset

static getObjectScrollOffset(Object obj)

Gets the DOM object's scroll offset.

Usage example:

 var offsets = o2.Dom.getObjectScrollOfset('container');
 
Parameters:
obj - the DOM node to check, or its String id.
Returns:
the the DOM object's scroll offset in the form {left: l, top: t}.

function getOffset

static getOffset(Object e)
// * // *

Gets the left and top offset of a given element.

// * // * // *
Parameters:
e - the element, or the id of the element, to get // * the offsets of. // * // *
Returns:
the offset from the top-left corner of the viewport, in the // * form {left: l, top: t}. //

function getOffsetLeft

static getOffsetLeft()
// * // *

An alias to o2.Dom.getOffset(obj).left.

// * // * // *
See also:

function getOffsetTop

static getOffsetTop()
// * // *

An alias to o2.Dom.getOffset(obj).top.

// * // * // *
See also:

function getParent

static getParent(Object elm, String name)

Gets the parent node of an element.

Usage example:

 var item = o2.Dom.getParent('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first parent available with the given criteria, if found; null otherwise.

function getParentByAttribute

static getParentByAttribute(Object elm, String attribute, String value, String name)

Gets the parent node of an element, having an attribute with a given value.

Usage example:

 var item = o2.Dom.getParentByAttribute('content', 'data-id', '42', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first parent available with the given criteria, if found; null otherwise.

function getParentByClass

static getParentByClass(Object elm, String className, String name)

Gets the parent node of an element, having a given CSS class name.

Usage example:

 var item = o2.Dom.getParentByClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first parent available with the given criteria, if found; null otherwise.

function getParentWithAttribute

static getParentWithAttribute(Object elm, String attribute, String name)

Gets the parent node of an element, having a given attribute defined.

Usage example:

 var item = o2.Dom.getParentWithAttribute('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first parent available with the given criteria, if found; null otherwise.

function getParentWithClass

static getParentWithClass(Object elm, String name)

Gets the parent node of an element, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getParentWithClass('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first parent available with the given criteria, if found; null otherwise.

function getParentWithId

static getParentWithId(Object elm, String name)

Gets the parent node of an element, having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getParentWithId('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first parent available with the given criteria, if found; null otherwise.

function getParents

static getParents(Object elm, String name)

Gets all the parent nodes of an element.

Usage example:

 var items = o2.Dom.getParents('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getParentsByAttribute

static getParentsByAttribute(Object elm, String attribute, String value, String name)

Gets all the parent nodes of an element, having a given attribute with a given value.

Usage example:

 var items = o2.Dom.getParentsByAttribute('content', 'data-id', '42');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getParentsByAttributeUntil

static getParentsByAttributeUntil(Object elm, String attribute, String value, Object until, String name)

Gets all the parent nodes of an element, having a given attribute with a given value, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getParentsByAttributeUntil('content', 'data-id', '42',
      'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
until - the DOM node that the traversal will be made until, or its String id,
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getParentsByClass

static getParentsByClass(Object elm, String className, String name)

Gets all the parent nodes of an element, having a given CSS class name.

Usage example:

 var items = o2.Dom.getParentsByClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getParentsByClassUntil

static getParentsByClassUntil(Object elm, String className, Object until, String name)

Gets all the parent nodes of an element, having a given CSS class name, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getParentsByClassUntil('content', 'selected',
      'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getParentsUntil

static getParentsUntil(Object elm, Object until, String name)

Gets all the parent nodes of an element, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getParentsUntil('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getParentsWithAttribute

static getParentsWithAttribute(Object elm, String attribute, String name)

Gets all the parent nodes of an element, having a given attribute defined.

Usage example:

 var items = o2.Dom.getParentsWithAttribute('content', 'data-id', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getParentsWithAttributeUntil

static getParentsWithAttributeUntil(Object elm, String attribute, Object until, String name)

Gets all the parent nodes of an element, having a given attribute defined, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getParentsWithAttributeUntil('content', 'data-id',
      'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getParentsWithClass

static getParentsWithClass(Object elm, String name)

Gets all the parent nodes of an element, having a "class" attribute defined.

Usage example:

 var items = o2.Dom.getParentsWithClass('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getParentsWithClassUntil

static getParentsWithClassUntil(Object elm, Object until, String name)

Gets all the parent nodes of an element, having a "class" attribute defined, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getParentsWithClass('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getParentsWithId

static getParentsWithId(Object elm, String name)

Gets all the parent nodes of an element, having an "id" attribute defined.

Usage example:

 var items = o2.Dom.getParentsWithId('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getParentsWithIdUntil

static getParentsWithIdUntil(Object elm, Object until, String name)

Gets all the parent nodes of an element, having an "id" attribute defined, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getParentsWithIdUntil('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrev

static getPrev(Object elm, String name)

Gets the previous sibling of an element that's not a text node.

Usage example:

 var item = o2.Dom.getPrev('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first previous sibling available with the given criteria, if found; null otherwise.

function getPrevAll

static getPrevAll(Object elm, String name)

Gets all previous sibling of an element, that are not text nodes.

Usage example:

 var items = o2.Dom.getPrevAll('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrevAllByAttribute

static getPrevAllByAttribute(Object elm, String attribute, String value, String name)

Gets all previous sibling of an element, that are not text nodes, having a given attribute with a given value.

Usage example:

 var items = o2.Dom.getPrevAllByAttribute('content', 'data-id', '42');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrevAllByAttributeUntil

static getPrevAllByAttributeUntil(Object elm, String attribute, String value, Object until, String name)

Gets all previous sibling of an element, that are not text nodes, having a given attribute with a given value, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getPrevAllByAttributeUntil('content', 'data-id',
      '42', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrevAllByClass

static getPrevAllByClass(Object elm, String className, String name)

Gets all previous sibling of an element, that are not text nodes, having a given CSS class name.

Usage example:

 var items = o2.Dom.getPrevAllByClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrevAllByClassUntil

static getPrevAllByClassUntil(Object elm, String className, Object until, String name)

Gets all previous sibling of an element, that are not text nodes, having a given CSS class name, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getPrevAllByClassUntil('content', 'selected',
      'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrevAllUntil

static getPrevAllUntil(Object elm, Object until, String name)

Gets all previous sibling of an element, that are not text nodes, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getPrevAllUntil('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrevAllWithAttribute

static getPrevAllWithAttribute(Object elm, String attribute, String name)

Gets all previous sibling of an element, that are not text nodes, having a given attribute defined.

Usage example:

 var items = o2.Dom.getPrevAllWithAttribute('content', 'data-id', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrevAllWithAttributeUntil

static getPrevAllWithAttributeUntil(Object elm, String attribute, Object until, String name)

Gets all previous sibling of an element, that are not text nodes, having a given attribute defined, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getPrevAllWithAttributeUntil('content', 'data-id',
      'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrevAllWithClass

static getPrevAllWithClass(Object elm, String name)

Gets all previous sibling of an element, that are not text nodes, having a "class" attribute defined.

Usage example:

 var items = o2.Dom.getPrevAllWithClass('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrevAllWithClassUntil

static getPrevAllWithClassUntil(Object elm, Object until, String name)

Gets all previous sibling of an element, that are not text nodes, having a "class" attribute defined, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getPrevAllWithClassUntil('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrevAllWithId

static getPrevAllWithId(Object elm, String name)

Gets all previous sibling of an element, that are not text nodes, having an "id" attribute defined.

Usage example:

 var items = o2.Dom.getPrevAllWithId('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrevAllWithIdUntil

static getPrevAllWithIdUntil(Object elm, Object until, String name)

Gets all previous sibling of an element, that are not text nodes, having an "id" attribute defined, until (but not included to) a given node.

Usage example:

 var items = o2.Dom.getPrevAllWithIdUntil('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getPrevByAttribute

static getPrevByAttribute(Object elm, String attribute, String value, String name)

Gets the previous sibling of an element that's not a text node, having an attribute with a given value.

Usage example:

 var item = o2.Dom.getPrevByAttribute('content', 'data-id', '42', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - i the value of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first previous sibling available with the given criteria, if found; null otherwise.

function getPrevByClass

static getPrevByClass(Object elm, String className, String name)

Gets the previous sibling of an element that's not a text node, having a given CSS class name.

Usage example:

 var item = o2.Dom.getPrevByClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
className - the CSS class name.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first previous sibling available with the given criteria, if found; null otherwise.

function getPrevWithAttribute

static getPrevWithAttribute(Object elm, String attribute, String name)

Gets the previous sibling of an element that's not a text node, having a given attribute defined.

Usage example:

 var item = o2.Dom.getPrevWithAttribute('content', 'data-id', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first previous sibling available with the given criteria, if found; null otherwise.

function getPrevWithClass

static getPrevWithClass(Object elm, String name)

Gets the previous sibling of an element that's not a text node, having a "class" attribute defined.

Usage example:

 var item = o2.Dom.getPrevWithClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first previous sibling available with the given criteria, if found; null otherwise.

function getPrevWithId

static getPrevWithId(Object elm, String name)

Gets the previous sibling of an element that's not a text node, having an "id" attribute defined.

Usage example:

 var item = o2.Dom.getPrevWithId('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
the first previous sibling available with the given criteria, if found; null otherwise.

function getScrollOffset

static getScrollOffset()

An alias to o2.Dom.getObjectStrollOffset.


function getSiblings

static getSiblings(Object elm, String name)

Gets the siblings of the element.

Usage example:

 var items = o2.Dom.getSiblings('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getSiblingsByAttribute

static getSiblingsByAttribute(Object elm, String attribute, String value, String name)

Gets the siblings of the element, having a given attribute equals a given value.

Usage example:

 var items = o2.Dom.getSiblingsByAttribute('content', 'data-id', '42');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getSiblingsByAttributeUntil

static getSiblingsByAttributeUntil(Object elm, String attribute, String value, Object until, String name)

Gets the siblings of the element, having a given attribute equals a given value, until (but not included to) a specific node.

Usage example:

 var items = o2.Dom.getSiblingsByAttributeUntil('content', 'data-id',
      '42', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
value - the value of the attribute.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getSiblingsByClass

static getSiblingsByClass(Object elm, String name)

Gets the siblings of the element, having a given class name.

Usage example:

 var items = o2.Dom.getSiblingsByClass('content', 'selected', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getSiblingsByClassUntil

static getSiblingsByClassUntil(Object elm, Object until, String name)

Gets the siblings of the element, having a given class name, until (but not included to) a specific node.

Usage example:

 var items = o2.Dom.getSiblingsByClassUntil('content', 'selected',
      'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getSiblingsUntil

static getSiblingsUntil(Object elm, Object until, String name)

Gets the siblings of the element until (but not included to) a specific node.

Usage example:

 var items = o2.Dom.getSiblingsUntil('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getSiblingsWithAttribute

static getSiblingsWithAttribute(Object elm, String attribute, String name)

Gets the siblings of the element, having a given attribute defined.

Usage example:

 var items = o2.Dom.getSiblingsWithAttribute('content', 'dada-id', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getSiblingsWithAttributeUntil

static getSiblingsWithAttributeUntil(Object elm, String attribute, Object until, String name)

Gets the siblings of the element, having a given attribute defined, until (but not included to) a specific node.

Usage example:

 var items = o2.Dom.getSiblingsWithAttributeUntil('content', 'data-id',
      'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
attribute - the name of the attribute to filter.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getSiblingsWithClass

static getSiblingsWithClass(Object elm, String name)

Gets the siblings of the element, having "class" attribute defined.

Usage example:

 var items = o2.Dom.getSiblingsWithClass('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getSiblingsWithClassUntil

static getSiblingsWithClassUntil(Object elm, Object until, String name)

Gets the siblings of the element, having a "class" attribute defined, until (but not included to) a specific node.

Usage example:

 var items = o2.Dom.getSiblingsWithClassUntil('content', 'stopper', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getSiblingsWithId

static getSiblingsWithId(Object elm, String name)

Gets the siblings of the element, having an "id" attribute defined.

Usage example:

 var items = o2.Dom.getSiblingsWithId('content', 'li');
 
Parameters:
elm - the element reference, or a String id of it.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getSiblingsWithIdUntil

static getSiblingsWithIdUntil(Object elm, Object until, String name)

Usage example:

 var items = o2.Dom.getSiblingsWithIdUntil('content', 'stopper', 'li');
 

Gets the siblings of the element, having an "id" attribute defined, until (but not included to) a specific node.

Parameters:
elm - the element reference, or a String id of it.
until - the DOM to search until (but not included to), or its String id.
name - (Optional; defaults to undefined), if true, only the results with that node name (i.e. HTML Tag Name) are selected.
Returns:
an Array of nodes, if found; and empty Array if nothing is found.

function getStyle

static getStyle(Object elm, String cssProperty, Boolean isNoForce)

Gets the style of a given property of the element.

Tries to parse the currentStyle, if available; otherwise tries to calculate the style using window.getComputedStyle; gets obj.style if everything else fails.

Note that adding and removing style attributes to a DOM not is considered "bad practice". Do not use inline styles to modify the view; assign className's instead of style values.

Usage example:

 var color = o2.Dom.getStyle('container', 'color');
 
Parameters:
elm - the element, or the id of it, to check.
cssProperty - the css property either dash-separated or camelCased (i.e.: 'border-color' or 'borderColor')
isNoForce - (optional; defaults to false) if true inherited values from the CSS files will also be parsed, otherwise, only inline styles will be parsed.
Returns:
the calculated style value.

function getText

static getText(Object elm)

Gets the textual content of the given node, replacing entities like & amp; with it's corresponding character counterpart (& in this example).

Usage example:

 var txt = o2.Dom.getText('container');
 
Parameters:
elm - the DOM node or its String id.
Returns:
the textual content of the given node.

function getViewportInfo

static getViewportInfo()

Gets the viewport information in the form {scrollTop : #, scrollLeft: #, width: #, height: #}.

Usage example:

 var details = o2.Dom.getViewportInfo();
 
Returns:
the viewport information.

function getWidth

static getWidth(Object obj)

Gets the width of the given element, in pixels.

Parameters:
obj - the DOMNode to get the dimension of, or the String id of it.

Usage example:

 var elementWidth = o2.Dom.getWidth('container');
 
Returns:
the width of the element, in pixels.

function getWindowInnerDimension

static getWindowInnerDimension()

Gets the dimension of the visible area of the browser in the form {width: w, height: h}.

Usage example:

 var windowDimensions = o2.Dom.getWindowInnerDimension();
 
Returns:
the dimension of the visible area of the browser in the form {width: w, height: h}.

function getWindowInnerHeight

static getWindowInnerHeight()

Gets the inner height of the visible area.

Usage example:

 var innerHeight = o2.Dom.getWindow.innerHeight();
 
Returns:
the inner height of the window in pixels.

function getWindowInnerWidth

static getWindowInnerWidth()

Gets the inner width of the visible area.

Usage example:

 var innerWidth = o2.Dom.getWindowInnerWidth();
 
Returns:
the inner width of the window in pixels.

function getWindowScrollOffset

static getWindowScrollOffset()

Gets the window's scroll offset.

Usage example:

 var offsets = o2.Dom.getWindowScrollOffset();
 
Returns:
the the window's scroll offset in the form {left: l, top: t}.

function hasClass

static hasClass(DomNode el, String c)

Checks whether an element has the given className.

Usage example:

 if (o2.Dom.hasClass('container', 'active')) {
      doStuff();
 }
 
Parameters:
el - either the element, or the id of it.
c - the className to test.
Returns:
true if el has the className c, false otherwise.

function hide

static hide(Object obj)

Hides the given object.

Usage example:

 o2.Dom.hide('container');
 
Parameters:
obj - the DOM node, or the id to hide.

function insertAfter

static insertAfter(Object elmNewNode, Object elmRefNode)

Adds the node after the reference node.

Usage example:

 var ref = o2.$('ref');
 var new = o2.$('new');
 o2.Dom.insertAfter(new, ref);
 
Parameters:
elmNewNode - the DOM node, or the id of the node, to insert after.
elmRefNode - the reference node, or the id of the node.

function insertBefore

static insertBefore(Object elmNewNode, Object elmRefNode)

Adds the node before the reference node.

Usage example:

 var ref = o2.$('ref');
 var new = o2.$('new');
 o2.Dom.insertBefore(new, ref);
 
Parameters:
elmNewNode - the node, or the id of the node, to insert before.
elmRefNode - the reference, or the id of the node.

function isChild

static isChild(Object elm, Object ref)

Checks whether elm is the child of ref.

Usage example:

 var isChild = o2.Dom.isChild('child', 'parent');
 
Parameters:
elm - the source element, or a String id of it.
ref - the reference element, or a String id of it.
Returns:
true if elm is a child of ref; false otherwise.

function isDocument

static isDocument(DOMNode obj)

Checks whether the given node is a document node.

Usage example:

 var isDocument = o2.Dom.isDocument(currentNode);
 
Parameters:
obj - the node to test.
Returns:
true if the node is the document element; false otherwise.

function isElement

static isElement(DOMNode obj)

Checks whether the given node is an element node.

Usage example:

 var isElement = o2.Dom.isElement(currentNode);
 
Parameters:
obj - the node to test.
Returns:
true if the node is an element node; false otherwise.

function isNext

static isNext(Object elm, Object ref)

Checks whether elm is a sibling after ref.

Usage example:

 var isNext = o2.Dom.isNext('itemId', 'refId');
 
Parameters:
elm - the source element, or a String id of it.
ref - the reference element, or a String id of it.
Returns:
true if elm is a sibling after ref; false otherwise.

function isParent

static isParent(Object elm, Object ref)

Checks whether elm is a parent of ref.

Usage example:

 var isParent = o2.Dom.isParent('itemId', 'refId');
 
Parameters:
elm - the source element, or a String id of it.
ref - the reference element, or a String id of it.
Returns:
true if elm is a parent of ref; false otherwise.

function isParentOrSelf

static isParentOrSelf(Object elm, Object ref)

Checks whether elm is parent of ref, or it's the ref itself.

Usage example:

 var isParent = o2.Dom.isParentOrSelf('itemId', 'refId');
 
Parameters:
elm - the source element, or a String id of it.
ref - the reference element, or a String id of it.
Returns:
true if elm is a parent of ref, or the node itself; false otherwise.

function isPrev

static isPrev(Object elm, Object ref)

Checks whether elm is a sibling before ref.

Usage example:

 var isParent = o2.Dom.isPrev('itemId', 'refId');
 
Parameters:
elm - the source element, or a String id of it.
ref - the reference element, or a String id of it.
Returns:
true if elm is a sibling before ref; false otherwise.

function isSibling

static isSibling(Object elm, Object ref)

Checks whether elm is a sibling of ref.

Usage example:

 var isSibling = o2.Dom.isSibling('itemId', 'refId');
 
Parameters:
elm - the source element, or a String id of it.
ref - the reference element, or a String id of it.
Returns:
true if elm is a sibling of ref; false otherwise.

function isVisible

static isVisible(Object obj)

Checks whether the DOM node is visible.

Note that being visible does not necessarily mean being available inside the viewport.

If a DOM node has display == 'none' or visibility == 'hidden' CSS properties, then it's regarded as "invisible", otherwise it is considered to be "visible".

Usage example:

 var isContainerVisible = o2.Dom.isVisible('container');
 
Parameters:
obj - the DOM element, or the id of it, to test.
Returns:
true if the element is visible, false otherwise.

function loadCss

static loadCss(String src, Function successCallback)

Asynchronously loads a css file with a given src.

Cross-domain loading is also okay: The css file does not have to be in the same domain as the web page.

The success and failure callbacks is a somewhat hacky way of handling CSS load events. In deed, detecting CSS load is not an easy task, and it's not necessary most of the time.

Though it may get handy to prevent the Flash of Unstyled Content (FOUC) issues.

A more robust way of handling load callbacks is polling the property of a test element (such as the background color), that you know that the loaded CSS will change for sure.

Usage example:

 o2.Dom.loadCss('http://cdn.example/com/theme.css', function() {
      handleSuccess();
 });
 
Parameters:
src - the source URL of the css file.
successCallback - the callback to execute when the load operation completes.

function loadImage

static loadImage(String url, Function successCallback)

Tries to load the image into a JavaScript Image object; then triggers successCallback or failureCallback depending on the result of the load attempt.

This function can be used for pre-loading or post-loading images.

Usage example:

 o2.Dom.loadImage('http//asset.example.com/spinner.png', function() {
      handleSuccess();
 });
 
Parameters:
url - the URL of the image.
successCallback - gets called when the image is loaded successfully.

function loadScript

static loadScript(String src, Function callback)

Asynchronously loads a script with a given src.

Cross-domain loading is also okay: The script does not have to be in the same domain as the web page.

Usage example:

 o2.Dom.loadImage('http//asset.example.com/script.js', function() {
      handleSuccess();
 });
 
Parameters:
src - the source URL of the script.
callback - the callback to execute when the load operation completes.

function prepend

static prepend(Object elmChild, Object elmParent)

Prepends the element to the top of its parent.

Usage example:

 var child = o2.$('ChildContainer');
 var parent = o2.$('MasterContainer');
 o2.Dom.prepend(child, parent);
 
Parameters:
elmChild - the child node, or the id of the node to prepend.
elmParent - the parent container, or the id of the container.

function preventMultipleSubmit

static preventMultipleSubmit(Object form)

Prevents the form to re-submit itself when the submit button is pressed more than once.

Usage example:

 o2.Dom.preventMultipleSubmit('actionForm');
 
Parameters:
form - A DOM reference to the form object or its String id.

function ready

static ready(Function delegate)

Fires when the HTML DOM is ready.

Usage example:

 o2.Dom.ready(function() {
      doInitializaton();
 });
 
Parameters:
delegate - the callback that's called when the DOM is ready.

function remove

static remove(Object e)

Removes the element from the DOM flow.

Usage example:

 o2.Dom.remove('nagivation');
 
Parameters:
e - either the element, or the id of it, to remove.
Returns:
the removed node.

function removeChildren

static removeChildren(Object e)

Removes all the children of the element.

Usage example:

 o2.Dom.removeChildren('container');
 
Parameters:
e - either the element, or the id of it to process.

function removeClass

static removeClass(DomNode el, String c)

Removes a class name from the given node.

Usage example:

 o2.Dom.removeClass('container', 'active');
 
Parameters:
el - either the element, or the id of it.
c - the className to remove.

function removeEmpty

static removeEmpty()

function removeEmptyTextNodes

static removeEmptyTextNodes(Object e)

Removes empty text nodes from the element.

Note that this removal is not recursive; only the first-level empty child nodes of the element will be removed.

Usage example:

 o2.Dom.removeEmptyTextNodes('container');
 
Parameters:
e - either the element, or the id of it to process.

function removeNode

static removeNode()

An alias to o2.Dom.remove.

See also:

function replace

static replace( elmTarget, elmToReplace)

Replaces one node with another.

Usage example:

 o2.Dom.replace('firstContainer', 'secondContainer');
 
Parameters:
elmTarget - the target node or its String id.
elmToReplace - the replacement node or its String id.

function scrollObjectToBottom

static scrollObjectToBottom(Object obj)

Scrolls an element to bottom.

Usage example:

 o2.Dom.scrollObjectToBottom('container');
 
Parameters:
obj - the element, or the id of it, to scroll.

function scrollObjectToTop

static scrollObjectToTop(Object obj)

Scrolls an element to top.

Usage example:

 o2.Dom.scrollObjectToTop('container');
 
Parameters:
obj - the element, or the id of the element, to scroll.

function scrollTo

static scrollTo()

function scrollToObject

static scrollToObject()

function scrollWindowToBottom

static scrollWindowToBottom()

Usage example:

 o2.Dom.scrollWindowToBottom();
 

Scrolls window to bottom.


function scrollWindowToObject

static scrollWindowToObject()

function scrollWindowToTop

static scrollWindowToTop()

Usage example:

 o2.Dom.scrollWindowToTop();
 

Scrolls window to top.


function setAttribute

static setAttribute(Object elm, String attribute, String value)

Sets the attribute of the given object.

Usage example:

 o2.Dom.setAttribute('container', 'data-user-id', '123');
 
Parameters:
elm - the object or the String id of it.
attribute - the name of the attribute.
value - the value of the attribute.

function setCss

static setCss()

An alias to o2.Dom.addStyle.

See also:

function setDimension

static setDimension(Object obj, Object dimension)

Sets the dimension of the given element.

Usage example:

 o2.Dom.setDimension('container', {width: 400, height: 200});
 
Parameters:
obj - the DOMNode to get the dimension of, or the String id of it.
dimension - the new dimension in the form {width: w, height: h}.

function setHeight

static setHeight(Object obj, Integer height)

Sets the height of the given element.

Usage example:

 o2.Dom.setHeight('container', 300);
 
Parameters:
obj - the DOMNode to get the dimension of, or the String id of it.
height - the new height in pixels.

function setHtml

static setHtml(Object elm)

Simply sets the innerHTML of the element.

Usage example:

 o2.Dom.setHtml('container', '[h1]hello[/h1]');
 
Parameters:
elm - The DOM element to set the HTML of, or its String id.

function setStyle

static setStyle()

An alias to o2.Dom.addStyle.

See also:

function setWidth

static setWidth(Object obj, Integer width)

Sets the width of the given element.

Usage example:

 o2.Dom.setWidth('container', 500);
 
Parameters:
obj - the DOMNode to get the dimension of, or the String id of it.
width - the new width in pixels.

function show

static show(Object elm)

Shows the given object.

Usage example:

 o2.Dom.show('container');
 
Parameters:
elm - the DOM node, or the id of it, to show.

function toggleClass

static toggleClass(Object el, String c, Boolean state)

Toggles the CSS className of a given element.

Usage example:

 o2.Dom.toggleClass('container', 'active');
 
Parameters:
el - the DOM element to toggle or its String id.
c - the class name to toggle.
state - (Optional, defaults to undefined), if true add class c to el, if true removes class c from el. If the parameter is not given, the class is toggled (i.e. added if the class does not exist, and removed if the class exists).

function toggleVisibility

static toggleVisibility(Object elm, Boolean state)

Toggles the visibility of the given element.

Usage example:

 o2.Dom.toggleVisibility('container');
 
Parameters:
elm - a DOM reference or its String id.
state - (Optional, defaults to undefined) if true, show the item; if false hides the item; if undefined simply toggles the visibility of the item.

function trimField

static trimField(Object field)

Trims a given field, and returns the trimmed value.

Usage example:

 o2.Dom.trimField('txtInput');
 
Parameters:
field - the field to be trimmed, or its id.
Returns:
field's trimmed value; or null if the field does not exist.
See also:

function unwrap

static unwrap(Object elmTarget)

This is like o2.Dom.wrap in reverse.

Moves all the elements inside the container to the container's position and removes the container from the DOM.

Usage example:

 o2.Dom.unwrap('container');
 
Parameters:
elmTarget - the target node or its String id to unwrap.

function wrap

public static wrap(Object elmTarget, Object elmWrapper)

Puts the target element into the wrapper element.

Usage example:

 var wrapper = o2.$('wrapper');
 var target = o2.$('content');
 o2.Dom.wrap(target, wrapper);
 
Parameters:
elmTarget - the node to wrap or its String id.
elmWrapper - the wrapper node ot its String id.
Returns:
the wrapped node.