namespace
SAPO.Dom.Element
Function Summary
childElementCount
(String|DomElement
elm)
fallback to elem.childElementCount
Tells if descendant is descendant of node
elementDimensions
(element
element)
{Number}
elementHeight
(DOMElement|string
element)
elementLeft
(DOMElement|string
element)
elementTop
(DOMElement|string
element)
elementWidth
(DOMElement|string
element)
DomElement
fillChecks
(DomElement|String
insertAfterEl, String
name, Number[]|String[]|Array[]
data, [Boolean
skipEmpty], [String|Number
defaultValue], [String
splitEl])
creates set of checkbox buttons, returns wrapper
DomElement
fillRadios
(DomElement|String
insertAfterEl, String
name, Number[]|String[]|Array[]
data, [Boolean
skipEmpty], [String|Number
defaultValue], [String
splitEl])
creates set of radio buttons, returns wrapper
fillSelect
(DomElement|String
container, Number[]|String[]|Array[]
data, [Boolean
skipEmpty], [String|Number
defaultValue])
fills select element with choices
select element on steroids - allows the creation of new values
searches up the DOM tree for an element of specified class name
searches up the DOM tree for an element of specified id
searches up the DOM tree for an element of specified class name
firstElementChild
(DOMNode
parent)
Get first child in document order of node type 1
Shortcut for document.getElementById
returns trimmed text content of descendants
possible values
Verifies the existence of an attribute
Inserts a element immediately after a target element
Inserts a element at the top of the childNodes of a target element
Tells if ancestor is ancestor of node
isLink
(DOMNode
node)
Tells if element is a clickable link
lastElementChild
(DOMNode
parent)
Get last child in document order of node type 1
nextElementSibling
(DOMNode
current)
Get the first element sibling after the node
returns the top left position of the element on the page
Gets the left cumulative offset for an element
Gets the top cumulative offset for an element
returns index of element from parent, -1 if not child of parent...
gets the element offset relative to its closest positioned ancestor
previousElementSibling
(DOMNode
current)
Get the first element sibling before the node
remove
(DOMElement
el)
removes DOM Element from DOM
scrollTo
(DOMElement|String
elm)
Scrolls to an element
setTextContent
(DOMNode
node)
Removes all nodes children and adds the text
textContent
(DOMNode
node)
Retreives textContent from node
Function Details
function childElementCount
childElementCount(String|DomElement
elm)
fallback to elem.childElementCount
Parameters:
elm
element 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, Object
properties)
Creates a DOM element
Parameters:
tag
- tag name
properties
- object with properties to be set on the element function descendantOf
descendantOf(DOMNode
node, DOMNode
descendant)
Tells if descendant is descendant of node
Parameters:
node
the ancestor
descendant
the descendant
Returns:
{Boolean} true if 'descendant' is descendant of 'node'
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 fillChecks
DomElement
fillChecks(DomElement|String
insertAfterEl, String
name, Number[]|String[]|Array[]
data, [Boolean
skipEmpty], [String|Number
defaultValue], [String
splitEl])
creates set of checkbox buttons, returns wrapper
Parameters:
insertAfterEl
element which will precede the input elements
name
name to give to the form field ([] is added if not as suffix already)
data
data which will populate the component
[skipEmpty]
true to skip empty option
[defaultValue]
primitive value to select at beginning
[splitEl]
name of element to add after each input element (example: 'br') function fillRadios
DomElement
fillRadios(DomElement|String
insertAfterEl, String
name, Number[]|String[]|Array[]
data, [Boolean
skipEmpty], [String|Number
defaultValue], [String
splitEl])
creates set of radio buttons, returns wrapper
Parameters:
insertAfterEl
element which will precede the input elements
name
name to give to the form field ([] is added if not as suffix already)
data
data which will populate the component
[skipEmpty]
true to skip empty option
[defaultValue]
primitive value to select at beginning
[splitEl]
name of element to add after each input element (example: 'br') function fillSelect
fillSelect(DomElement|String
container, Number[]|String[]|Array[]
data, [Boolean
skipEmpty], [String|Number
defaultValue])
fills select element with choices
Parameters:
container
select element which will get filled
data
data which will populate the component
[skipEmpty]
true to skip empty option
[defaultValue]
primitive value to select at beginning function fillSelect2
fillSelect2(DomElement|String
ctn, Object
opts)
select element on steroids - allows the creation of new values
Parameters:
ctn
select element which will get filled
opts
-
Number[]|String[]|Array[] data
data which will populate the component -
[ Boolean skipEmpty ]
if true empty option is not created (defaults to false) -
[ String emptyLabel ]
label to display on empty option -
[ String createLabel ]
label to display on create option -
[ String optionsGroupLabel ]
text to display on group surrounding value options -
[ String defaultValue ]
option to select initially -
[ Function(selEl, addOptFn) onCreate ]
callback that gets called once user selects the create option
function findUpwardsByClass
HtmlElement|false
findUpwardsByClass(HtmlElement
element, String
className)
searches up the DOM tree for an element of specified class name
Parameters:
element
className
function findUpwardsById
HtmlElement|false
findUpwardsById(HtmlElement
element, String
id)
searches up the DOM tree for an element of specified id
Parameters:
element
id
function findUpwardsByTag
HtmlElement|false
findUpwardsByTag(HtmlElement
element, String
className)
searches up the DOM tree for an element of specified class name
Parameters:
element
className
function firstElementChild
firstElementChild(DOMNode
parent)
Get first child in document order of node type 1
Parameters:
parent
node
Returns:
{DOMNode} the element child
function get
DOMElement|Array
get(string|Array
elm)
Shortcut for document.getElementById
Parameters:
elm
- 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 getChildrenText
String
getChildrenText(DOMElement
el, [Boolean
removeIt])
returns trimmed text content of descendants
Parameters:
el
- element being seeked
[removeIt]
- whether to remove the found text nodes or not
Returns:
text found
function getSelectValues
Array
getSelectValues(DomElement|String
select)
possible values
Parameters:
select
element 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 isAncestorOf
isAncestorOf(DOMNode
ancestor, DOMNode
descendant)
Tells if ancestor is ancestor of node
Parameters:
ancestor
node
descendant
node
Returns:
{Boolean}
function isLink
isLink(DOMNode
node)
Tells if element is a clickable link
Parameters:
node
to check if it's link
Returns:
{Boolean}
function lastElementChild
lastElementChild(DOMNode
parent)
Get last child in document order of node type 1
Parameters:
parent
node
Returns:
{DOMNode} the element child
function nextElementSibling
nextElementSibling(DOMNode
current)
Get the first element sibling after the node
Parameters:
current
node
Returns:
{DOMNode|Null} the first element sibling after node or null if none is found
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 offset2
Number[2]
offset2(String|DOMElement
el)
returns the top left position of the element on the page
Parameters:
el
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 parentIndexOf
parentIndexOf(DOMElement
parentEl, DOMElement
childEl)
returns index of element from parent, -1 if not child of parent...
Parameters:
parentEl
Element to parse
childEl
Child Element to look for 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 previousElementSibling
previousElementSibling(DOMNode
current)
Get the first element sibling before the node
Parameters:
current
node
Returns:
{DOMNode|Null} the first element sibling before node or null if none is found
function remove
remove(DOMElement
el)
removes DOM Element from DOM
Parameters:
el
function scroll
Array
scroll([DOMElement|String
elm])
Gets the scroll of the element
Parameters:
[elm]
- target element or document.body function scrollTo
scrollTo(DOMElement|String
elm)
Scrolls to an element
Parameters:
elm
- Element where to scroll function setTextContent
setTextContent(DOMNode
node)
Removes all nodes children and adds the text
Parameters:
node
from which to retreive text from.
Can be any node type.
Returns:
{String} the text
function textContent
textContent(DOMNode
node)
Retreives textContent from node
Parameters:
node
from which to retreive text from.
Can be any node type.
Returns:
{String} the text