API/libsapojs/SAPO/Dom/Element

[Elements] are optional

Class SAPO.Dom.Element


class SAPO.Dom.Element
Defined in Dom/Element/0.1/lib.js

Function Summary
clonePosition (DOMElement element, DOMElement element)
DOMElement create (String tag)
Creates a DOM element
descendantOf (DOMElement parent, DOMElement child)
{Number}
elementHeight (DOMElement|string element)
elementLeft (DOMElement|string element)
elementTop (DOMElement|string element)
elementWidth (DOMElement|string element)
DOMElement|Array get (string|Array elementID|ArrayOfIDs)
Shortcut for document.getElementById
Boolean hasAttribute (Object elm, String attr)
Verifies the existence of an attribute
insertAfter (DOMElement newElm, DOMElement|String targetElm)
Inserts a element immediately after a target element
insertTop (DOMElement newElm, DOMElement|String targetElm)
Inserts a element at the top of the childNodes of a target element
Array offset (DOMElement|String elm)
Gets the cumulative offset for an element
Number offsetLeft (DOMElement|String elm)
Gets the left cumulative offset for an element
Number offsetTop (DOMElement|String elm)
Gets the top cumulative offset for an element
Array positionedOffset (DOMElement|String elm)
gets the element offset relative to its closest positioned ancestor
scrollTo (DOMElement|String elm)
Scrolls to an element

Function Details

function clonePosition

clonePosition(DOMElement element, DOMElement element)
Parameters:
element to be position cloned
element to get the cloned position
Returns:
{DOMElement} the element with positionClone

function create

DOMElement create(String tag)
Creates a DOM element
Parameters:
tag - tag name

function descendantOf

descendantOf(DOMElement parent, DOMElement child)
Parameters:
parent element DOM element
child element DOM element
Returns:
{Boolean} true if childElm is child of parentElm

function elementDimensions

elementDimensions(element element)
{Number}
Parameters:
element target element
Returns:
{Array} array with element's width and height

function elementHeight

elementHeight(DOMElement|string element)
Parameters:
element target DOM element or target ID
Returns:
{Number} element height

function elementLeft

elementLeft(DOMElement|string element)
Parameters:
element target DOM element or target ID
Returns:
{Number} element left position

function elementTop

elementTop(DOMElement|string element)
Parameters:
element target DOM element or target ID
Returns:
{Number} element top position

function elementWidth

elementWidth(DOMElement|string element)
Parameters:
element target DOM element or target ID
Returns:
{Number} element width

function get

DOMElement|Array get(string|Array elementID|ArrayOfIDs)
Shortcut for document.getElementById
Parameters:
elementID|ArrayOfIDs Receives either an id or an Array of id's
Returns:
Either the DOM element for the given id or an array of elements for the given ids

function hasAttribute

Boolean hasAttribute(Object elm, String attr)
Verifies the existence of an attribute
Parameters:
elm - target element
attr - attribute name
Returns:
Boolean based on existance of attribute

function insertAfter

insertAfter(DOMElement newElm, DOMElement|String targetElm)
Inserts a element immediately after a target element
Parameters:
newElm - element to be inserted
targetElm - key element

function insertTop

insertTop(DOMElement newElm, DOMElement|String targetElm)
Inserts a element at the top of the childNodes of a target element
Parameters:
newElm - element to be inserted
targetElm - key element

function offset

Array offset(DOMElement|String elm)
Gets the cumulative offset for an element
Parameters:
elm - target element
Returns:
Array with offset from the target element to the top/left of the document

function offsetLeft

Number offsetLeft(DOMElement|String elm)
Gets the left cumulative offset for an element
Parameters:
elm - target element
Returns:
Offset from the target element to the left of the document

function offsetTop

Number offsetTop(DOMElement|String elm)
Gets the top cumulative offset for an element
Parameters:
elm - target element
Returns:
Offset from the target element to the top of the document

function positionedOffset

Array positionedOffset(DOMElement|String elm)
gets the element offset relative to its closest positioned ancestor
Parameters:
elm - target element
Returns:
Array with the element offsetleft and offsettop relative to the closest positioned ancestor

function scrollTo

scrollTo(DOMElement|String elm)
Scrolls to an element
Parameters:
elm - Element where to scroll