Provides helper methods for DOM elements.
This class has no public properties.
|
addClass(String | , String className ) : void |
Dom |
Adds a class name to a given element or collection of elements. |
|
batch([String | ], Function method , [Any o ], [Boolean override ]) : HTMLElement |
Dom |
Returns an array of elements that have had the supplied method applied.
The method is called with the element(s) as t... |
|
generateId([String | ], [String prefix ]) : String |
Dom |
Generates a unique ID |
|
get(String | ) : HTMLElement |
Dom |
Returns an HTMLElement reference. |
|
getClientHeight() : Int |
Dom |
Deprecated. Returns the height of the client (viewport). |
|
getClientWidth() : Int |
Dom |
Deprecated. Returns the width of the client (viewport). |
|
getDocumentHeight() : Int |
Dom |
Returns the height of the document. |
|
getDocumentWidth() : Int |
Dom |
Returns the width of the document. |
|
getElementsBy(Function method , [String tag ], [String | ]) : void |
Dom |
Returns a array of HTMLElements that pass the test applied by supplied boolean method.
For optimized performance, inc... |
|
getElementsByClassName(String className , [String tag ], [String | ]) : Array |
Dom |
Returns a array of HTMLElements with the given class.
For optimized performance, include a tag and/or root node when ... |
|
getRegion(String | ) : Region |
Dom |
Returns the region position of the given element.
The element must be part of the DOM tree to have a region (display:... |
|
getStyle(String | , String property ) : String |
Dom |
Normalizes currentStyle and ComputedStyle. |
|
getViewportHeight() : Int |
Dom |
Returns the current height of the viewport. |
|
getViewportWidth() : Int |
Dom |
Returns the current width of the viewport. |
|
getX(String | ) : String |
Dom |
Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to hav... |
|
getXY(String | ) : Array |
Dom |
Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page... |
|
getY(String | ) : String |
Dom |
Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have pa... |
|
hasClass(String | , String className ) : Boolean |
Dom |
Determines whether an HTMLElement has the given className. |
|
inDocument(String | ) : Boolean |
Dom |
Determines whether an HTMLElement is present in the current document. |
|
isAncestor(String | , String | ) : Boolean |
Dom |
Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy. |
|
removeClass(String | , String className ) : void |
Dom |
Removes a class name from a given element or collection of elements. |
|
replaceClass(String | , String oldClassName , String newClassName ) : void |
Dom |
Replace a class with another class for a given element or collection of elements.
If no oldClassName is present, the ... |
|
setStyle(String | , String property , String val ) : void |
Dom |
Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers. |
|
setX(String | , Int x ) : void |
Dom |
Set the X position of an html element in page coordinates, regardless of how the element is positioned.
The element m... |
|
setXY(String | , Array pos , Boolean noRetry ) : void |
Dom |
Set the position of an html element in page coordinates, regardless of how the element is positioned.
The element(s) ... |
|
setY(String | , Int x ) : void |
Dom |
Set the Y position of an html element in page coordinates, regardless of how the element is positioned.
The element m... |
This class has no public events.
addClass
public function addClass(String |
, String className
)
Adds a class name to a given element or collection of elements.
This method is defined by Dom.
batch
public function batch([String |
], Function method
, [Any o
], [Boolean override
])
Returns an array of elements that have had the supplied method applied.
The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ).
Parameters:
|
: StringHTMLElement | Array} el (optional) An element or array of elements to apply the method to
method
: FunctionThe method to apply to the element(s)
o
: Any(optional) An optional arg that is passed to the supplied method
override
: Boolean(optional) Whether or not to override the scope of "method" with "o"
Returns:
This method is defined by Dom.
generateId
public function generateId([String |
], [String prefix
])
This method is defined by Dom.
get
public function get(String |
)
Returns an HTMLElement reference.
This method is defined by Dom.
getClientHeight
public function getClientHeight()
Deprecated. Returns the height of the client (viewport).
This method is defined by Dom.
getClientWidth
public function getClientWidth()
Deprecated. Returns the width of the client (viewport).
This method is defined by Dom.
getDocumentHeight
public function getDocumentHeight()
Returns the height of the document.
This method is defined by Dom.
getDocumentWidth
public function getDocumentWidth()
Returns the width of the document.
This method is defined by Dom.
getElementsBy
public function getElementsBy(Function method
, [String tag
], [String |
])
Returns a array of HTMLElements that pass the test applied by supplied boolean method.
For optimized performance, include a tag and/or root node when possible.
Parameters:
method
: Function- A boolean method for testing elements which receives the element as its only argument.
tag
: String(optional) The tag name of the elements being collected
|
: StringHTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
Returns:
This method is defined by Dom.
getElementsByClassName
public function getElementsByClassName(String className
, [String tag
], [String |
])
Returns a array of HTMLElements with the given class.
For optimized performance, include a tag and/or root node when possible.
Parameters:
className
: StringThe class name to match against
tag
: String(optional) The tag name of the elements being collected
|
: StringHTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
Returns:
This method is defined by Dom.
getRegion
public function getRegion(String |
)
Returns the region position of the given element.
The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
This method is defined by Dom.
getStyle
public function getStyle(String |
, String property
)
Normalizes currentStyle and ComputedStyle.
Parameters:
|
: StringHTMLElement |Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
property
: StringThe style property whose value is returned.
Returns:
This method is defined by Dom.
getViewportHeight
public function getViewportHeight()
Returns the current height of the viewport.
This method is defined by Dom.
getViewportWidth
public function getViewportWidth()
Returns the current width of the viewport.
This method is defined by Dom.
getX
public function getX(String |
)
Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
This method is defined by Dom.
getXY
public function getXY(String |
)
Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
This method is defined by Dom.
getY
public function getY(String |
)
Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
This method is defined by Dom.
hasClass
public function hasClass(String |
, String className
)
Determines whether an HTMLElement has the given className.
This method is defined by Dom.
inDocument
public function inDocument(String |
)
Determines whether an HTMLElement is present in the current document.
This method is defined by Dom.
isAncestor
public function isAncestor(String |
, String |
)
Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy.
This method is defined by Dom.
removeClass
public function removeClass(String |
, String className
)
Removes a class name from a given element or collection of elements.
This method is defined by Dom.
replaceClass
public function replaceClass(String |
, String oldClassName
, String newClassName
)
Replace a class with another class for a given element or collection of elements.
If no oldClassName is present, the newClassName is simply added.
Parameters:
|
: StringHTMLElement | Array} el The element or collection to remove the class from
oldClassName
: Stringthe class name to be replaced
newClassName
: Stringthe class name that will be replacing the old class name
Returns:
This method is defined by Dom.
setStyle
public function setStyle(String |
, String property
, String val
)
Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers.
Parameters:
|
: StringHTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
property
: StringThe style property to be set.
val
: StringThe value to apply to the given property.
Returns:
This method is defined by Dom.
setX
public function setX(String |
, Int x
)
Set the X position of an html element in page coordinates, regardless of how the element is positioned.
The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
Parameters:
|
: StringHTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
x
: IntThe value to use as the X coordinate for the element(s).
Returns:
This method is defined by Dom.
setXY
public function setXY(String |
, Array pos
, Boolean noRetry
)
Set the position of an html element in page coordinates, regardless of how the element is positioned.
The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
Parameters:
|
: StringHTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
pos
: ArrayContains X & Y values for new position (coordinates are page-based)
noRetry
: BooleanBy default we try and set the position a second time if the first fails
Returns:
This method is defined by Dom.
setY
public function setY(String |
, Int x
)
Set the Y position of an html element in page coordinates, regardless of how the element is positioned.
The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
Parameters:
|
: StringHTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
x
: IntTo use as the Y coordinate for the element(s).
Returns:
This method is defined by Dom.