mxui.dom
Methods
copyChildren(source, target)
Removes the children of the source, and adds them to the target.
Parameters
Name |
Type |
Description |
source |
DOMNode |
The node to get the children from. |
target |
DOMNode |
The node to add the children to. |
insertBefore(node, target)
Inserts the node before the given target in de DOM Tree.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to insert. |
target |
DOMNode |
The node to insert before. |
insertAfter(node, target)
Inserts the node after the given target in de DOM Tree.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to insert. |
target |
DOMNode |
The node to insert after. |
Returns
Type |
Description |
Boolean |
true if successfull. |
walkTree(root, action)
Walks trough all descendents of the given node, and executes the action on all nodes.
Parameters
Name |
Type |
Description |
root |
DOMNode |
The node through which children to walk. |
action |
Function |
The action (which has one parameter of type DOMNode) to execute on every node. |
getNodeByDepth(root, depth)
Returns the node corresponding with the depth given by walkNode.
Parameters
Name |
Type |
Description |
root |
DOMNode |
The node passed to walkNode. |
depth |
Array |
The path to the node, given by walkNode. |
Returns
Type |
Description |
DOMNode |
The found node, or null . |
nextNode(start, current)
Tests if walkNode passed the node already at some depth.
Parameters
Name |
Type |
Description |
start |
Array |
The depth from which is started. |
current |
Array |
The current depth path, given by walkNode. |
Returns
Type |
Description |
Boolean |
true if the node is passed already. |
walkNode(root, action, scope)
Walks recursivily through the descendants of the root node, executing the action on every node, in the given scope.
Parameters
Name |
Type |
Description |
root |
DOMNode |
The node through which children to walk. |
action |
Function |
The action (which has one parameter of type DOMNode) to execute on every node. |
scope |
Object |
The scope in which the action is executed. |
getFirstElement(node)
Returns the first child which is not a text node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to search for a child. |
Returns
Type |
Description |
DOMNode |
The first child, or null. |
getAncestorClass(node, class, depth)
Gets the first ancestor node which has the given class.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to get the ancestor of. |
class |
String |
The class which the ancestor must have. |
depth |
Number |
The range in which to search for an ancestor. |
Returns
Type |
Description |
DOMNode |
The found ancestor, or false. |
getAncestorNode(node, name, depth)
Gets the first ancestor node which nodeName is equal to name.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to get the ancestor of. |
name |
String |
The nodeName of the desired ancestor. |
depth |
Number |
The range in which to search for an ancestor. |
Returns
Type |
Description |
DOMNode |
The found ancestor, or false. |
getFirstChild(node, names)
Gets first child which nodeName is equal to or in names.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to get the first child of. |
names |
Array |
The node names. |
Returns
Type |
Description |
DOMNode |
The found child, or false. |
getElementsByTagNames(node, name)
Returns all children of node which nodeName is equal to the given name.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to get the children from. |
name |
Array |
The nodeNames of the children to get. |
Returns
Type |
Description |
Array |
The child nodes which meets the criteria. |
removeElement(node)
Removes a node from the DOM.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to remove. |
Returns
Type |
Description |
Boolean |
false if failed. |
removeChildNodes(node)
Removes all child nodes from the given node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node from which to remove its child nodes. |
getAncestorNodeWithAttribute(node, name, attribute, depth)
Gets the first ancestor node which nodeName is equal to name and which has the given attribute.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to get the ancestor of. |
name |
String |
The nodeName of the desired ancestor. |
attribute |
String |
The attribute the ancestor should have. |
depth |
Number |
The range in which to search for an ancestor. |
Returns
Type |
Description |
DOMNode |
The found ancestor, or null. |
escapeHTML(html)
Returns the escaped html string.
Parameters
Name |
Type |
Description |
html |
String |
The html string to escape. |
Returns
Type |
Description |
String |
The escaped html. |
setHTML(node, html)
Escapes the html, and puts the text in the node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node. |
html |
String |
The html string to put in the node. |
textContent(node, text)
If the text parameter is given, it sets the text content of the node, else it returns the text content.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to set or get the text content from. |
text |
String |
The text value to set (optional, see description). |
Returns
Type |
Description |
String |
The text content of the node (optional, see description). |
clearSelectOptions(node)
Removes all option nodes from the given select node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The select node. |
setSelectOptions(node, list, defaults)
Sets the given list of options to the select node, and selects the default value(s).
Parameters
Name |
Type |
Description |
node |
DOMNode |
The select node. |
list |
Object |
Value-text pairs of the options to add. |
defaults |
Object |
The options which should be selected. |
Returns
Type |
Description |
Boolean |
true if successfull. |
getSelectOptions(node)
Returns the value of all options.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The select node. |
Returns
Type |
Description |
Array |
All option values. |
getSelectedValue(node)
Returns the value of the selected option.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The select node. |
Returns
Type |
Description |
String |
The value of the selected option. |
getSelectedText(node)
Returns the text value of the selected option.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The select node. |
Returns
Type |
Description |
String |
The text value of the selected option. |
selectOption(node, value)
Selects the option of a select box which value is equal to the given value.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The select node. |
text |
String |
The value of the option to select. |
selectOptionByText(node, text)
Selects the option of a select box which text value is equal to the given text.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The select node. |
text |
String |
The text value of the option to select. |
hasClass(node, class)
Checks whether a node has a class.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to check. |
class |
String |
Name of the class to check for. |
Returns
Type |
Description |
Boolean |
true if the node has the class. |
getClass(node)
Returns the class attribute of a node, multiple classes separated by a space.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to get the classes from. |
Returns
Type |
Description |
String |
The class attribute. |
addClass(node, class)
Adds a class to a node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to add the class to. |
class |
String |
Name of the class to add. |
addClasses(node, classes)
Adds a number of classes to a node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to add the classes to. |
class |
String |
Names of the classes to add, separated by a space. |
removeClass(node, class)
Removes a class from a node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to remove the class from. |
class |
String |
Name of the class to be removed. |
hide(node)
Hides a node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to show. |
show(node)
Shows a node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to show. |
enableNode(node)
Enables a form node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to enable. |
disableNode(node)
Disables a form node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to disable. |
setReadOnly(node)
Cross-browser way to make a node read-only.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to set read-only. |
unsetReadOnly(node)
Cross-browser way to remove a nodes readOnly property.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to to remove the readOnly property from. |
applyDisableStyle(node)
Disables a form node without making text unselectable, and adds the ‘MxClient_formDisabled’ class to a node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to disable. |
applyEnableStyle(node)
Enables a form node, and removes the ‘MxClient_formDisabled’ class from a node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to enable. |
setClass(node, class)
Sets the class attribute of a node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node on which to set the class. |
class |
String |
Name of the class (multiple classes separated by a space). |
setOpacity(node, opacity)
Sets the opacity of a node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node on which to set the opacity. |
opacity |
Float |
The opacity. |
insertCSS(filepath)
Adds a css file to the document.
Parameters
Name |
Type |
Description |
filepath |
String |
The path to the css file. |
removeCss(filepath)
Removes a linked css file from the document.
Parameters
Name |
Type |
Description |
filepath |
String |
The path to the css file. |
Returns
Type |
Description |
Boolean |
true if successfull. |
strip(node, attribute)
Strips the attribute from the node and its descendants.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to strip an attribute from. |
attribute |
String |
The attribute to be stripped. |
Returns
Type |
Description |
DOMNode |
The input parameter. |
getFormElementText(node)
Gets the text of an input or select.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node to get the value from. |
Returns
Type |
Description |
String |
The value of the element. |
disableSelection(node)
Disables the selection of a particular node.
Parameters
Name |
Type |
Description |
node |
DOMNode |
The node which should be unselectable. |
getStringSize(text)
Gets the real width of a string in pixels.
Parameters
Name |
Type |
Description |
text |
String |
Text to get the width of. |
Returns
Type |
Description |
Number |
The real width of the string in pixels. |
Selects a range in an input field.
Parameters
Name |
Type |
Description |
input |
DOMNode |
The input node. |
start |
Number |
The begin position of the selection. |
end |
Number |
The end position of the selection. |
getCursorPosition(input)
Returns the position of the cursor in an input field.
Parameters
Name |
Type |
Description |
input |
DOMNode |
The input node. |
Returns
Type |
Description |
Number |
The position of the cursor. |
clone(anything)
Alias of dojo.clone: clones anything objects and/or nodes, returning a new anything.
Parameters
Name |
Type |
Description |
anything |
Any |
Thing to clone. |
Returns
Type |
Description |
Any |
A clone of the argument. |
getSelection(input)
Returns the start and endpoint of the selection in an input field.
Parameters
Name |
Type |
Description |
input |
DOMNode |
The input node. |
Returns
Type |
Description |
Object |
Object with Number valued attributes start and end . |