This class is meant to be used as a set of methods that are applied to the prototype of a Record to decorate it with a Node API. This means that models used in conjunction with a tree will have all of the tree related methods available on the model. In general this class will not be used directly by the developer.
Insert node(s) as the last child node of this node.
If the node was previously a child node of another parent node, it will be removed from that node first.
The node or Array of nodes to append
The appended node if single append, or null if an array was passed
Bubbles up the tree from this node, calling the specified function with each node. The arguments to the function will be the args provided or the current node. If the function returns false at any point, the bubble is stopped.
The function to call
(optional) The scope (this
reference) in which the function is executed. Defaults to the current Node.
(optional) The args to call the function with (default to passing the current Node)
Cascades down the tree from this node, calling the specified function with each node. The arguments to the function will be the args provided or the current node. If the function returns false at any point, the cascade is stopped on that branch.
The function to call
(optional) The scope (this
reference) in which the function is executed. Defaults to the current Node.
(optional) The args to call the function with (default to passing the current Node)
Collapse this node.
Collapse this node.
(Optional) True to recursively collapse all the children
(Optional) The function to execute once the collapse completes
(Optional) The scope to run the callback in
Collapse all the children of this node.
Collapse all the children of this node.
(Optional) True to recursively collapse all the children
(Optional) The function to execute once all the children are collapsed
(Optional) The scope to run the callback in
Returns true if this node is an ancestor (at any point) of the passed node.
Returns true if this node is an ancestor (at any point) of the passed node.
Creates a copy (clone) of this Node.
Creates a copy (clone) of this Node.
(optional) A new id, defaults to this Node's id. See id
.
(optional)
If passed as true
, all child Nodes are recursively copied into the new Node.
If omitted or false, the copy will have no child Nodes.
A copy of this Node.
Ensures that the passed object is an instance of a Record with the NodeInterface applied
Ensures that the passed object is an instance of a Record with the NodeInterface applied
This method allows you to decorate a Record's prototype to implement the NodeInterface. This adds a set of methods, new events, new properties and new fields on every Record with the same Model as the passed Record.
The Record you want to decorate the prototype of.
Interates the child nodes of this node, calling the specified function with each node. The arguments to the function will be the args provided or the current node. If the function returns false at any point, the iteration stops.
The function to call
(optional) The scope (this
reference) in which the function is executed. Defaults to the current Node in the iteration.
(optional) The args to call the function with (default to passing the current Node)
Expand this node.
Expand this node.
(Optional) True to recursively expand all the children
(Optional) The function to execute once the expand completes
(Optional) The scope to run the callback in
Expand all the children of this node.
Expand all the children of this node.
(Optional) True to recursively expand all the children
(Optional) The function to execute once all the children are expanded
(Optional) The scope to run the callback in
Finds the first child that has the attribute with the specified value.
Finds the first child that has the attribute with the specified value.
The attribute name
The value to search for
(Optional) True to search through nodes deeper than the immediate children
The found child or null if none was found
Finds the first child by a custom function. The child matches if the function passed returns true
.
Finds the first child by a custom function. The child matches if the function passed returns true
.
A function which must return true
if the passed Node is the required Node.
(optional) The scope (this
reference) in which the function is executed. Defaults to the Node being tested.
(Optional) True to search through nodes deeper than the immediate children
The found child or null if none was found
Returns the child node at the specified index.
Returns the child node at the specified index.
Returns depth of this node (the root node has a depth of 0)
Returns depth of this node (the root node has a depth of 0)
Returns true if this node has one or more child nodes, else false.
Returns true if this node has one or more child nodes, else false.
Returns the index of a child node
Returns the index of a child node
The index of the node or -1 if it was not found
Inserts the first node before the second node in this nodes childNodes collection.
Inserts the first node before the second node in this nodes childNodes collection.
The node to insert
The node to insert before (if null the node is appended)
The inserted node
Insert a node into this node
Insert a node into this node
The zero-based index to insert the node at
The node to insert
The record you just inserted
Returns true if the passed node is an ancestor (at any point) of this node.
Returns true if the passed node is an ancestor (at any point) of this node.
Returns true if this node has one or more child nodes, or if the expandable node attribute is explicitly specified as true (see attributes), otherwise returns false.
Returns true if this node is the first child of its parent
Returns true if this node is the first child of its parent
Returns true if this node is the last child of its parent
Returns true if this node is the last child of its parent
Returns true if this node is the root node
Returns true if this node is the root node
Removes this node from its parent
Removes this node from its parent
true to destroy the node upon removal. Defaults to false.
this
Removes all child nodes from this node.
Removes all child nodes from this node.
true to destroy the node upon removal. Defaults to false.
this
Removes a child node from this node.
Removes a child node from this node.
The node to remove
true to destroy the node upon removal. Defaults to false.
The removed node
Replaces one child node in this node with another.
Replaces one child node in this node with another.
The replacement node
The node to replace
The replaced node
Sorts this nodes children using the supplied sort function.
Sorts this nodes children using the supplied sort function.
A function which, when passed two Nodes, returns -1, 0 or 1 depending upon required sort order.
Whether or not to apply this sort recursively
Set to true to not fire a sort event.
Updates general data of this node like isFirst, isLast, depth. This method is internally called after a node is moved. This shouldn't have to be called by the developer unless they are creating custom Tree plugins.
Fires when a new child node is appended
Fires when a new child node is appended
This node
The newly appended node
The index of the newly appended node
Fires before a new child is appended, return false to cancel the append.
Fires before a new child is appended, return false to cancel the append.
This node
The child node to be appended
Fires before this node is collapsed.
Fires before this node is collapsed.
The collapsing node
Fires before this node is expanded.
Fires before this node is expanded.
The expanding node
Fires before a new child is inserted, return false to cancel the insert.
Fires before a new child is inserted, return false to cancel the insert.
This node
The child node to be inserted
The child node the node is being inserted before
Fires before this node is moved to a new location in the tree. Return false to cancel the move.
Fires before this node is moved to a new location in the tree. Return false to cancel the move.
This node
The parent of this node
The new parent this node is moving to
The index it is being moved to
Fires before a child is removed, return false to cancel the remove.
Fires before a child is removed, return false to cancel the remove.
This node
The child node to be removed
Fires when this node is collapsed.
Fires when this node is collapsed.
The collapsing node
Fires when this node is expanded.
Fires when this node is expanded.
The expanding node
Fires when a new child node is inserted.
Fires when a new child node is inserted.
This node
The child node inserted
The child node the node was inserted before
Fires when this node is moved to a new location in the tree
Fires when this node is moved to a new location in the tree
This node
The old parent of this node
The new parent of this node
The index it was moved to