Class: InspireTree

InspireTree() → {InspireTree}

Represents a singe tree instance.

Constructor

new InspireTree() → {InspireTree}

Source:
Returns:
Tree instance.
Type
InspireTree

Methods

(static) isTreeNode(obj) → {boolean}

Check if an object is a TreeNode.
Parameters:
Name Type Description
obj object Object
Source:
Returns:
If object is a TreeNode.
Type
boolean

(static) isTreeNodes(obj) → {boolean}

Check if an object is a TreeNodes array.
Parameters:
Name Type Description
obj object Object
Source:
Returns:
If object is a TreeNodes array.
Type
boolean

addNode(node) → {TreeNode}

Adds a new node. If a sort method is configured, the node will be added in the appropriate order.
Parameters:
Name Type Description
node object Node
Source:
Returns:
Node object.
Type
TreeNode

addNodes(nodes) → {TreeNodes}

Add nodes.
Parameters:
Name Type Description
nodes array Array of node objects.
Source:
Returns:
Added node objects.
Type
TreeNodes

available(full) → {TreeNodes}

Query for all available nodes.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

blur() → {TreeNodes}

Blur children in this collection.
Source:
Returns:
Array of node objects.
Type
TreeNodes

blurDeep() → {TreeNodes}

Blur (deeply) all nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

boundingNodes() → {array}

Compares any number of TreeNode objects and returns the minimum and maximum (starting/ending) nodes.
Source:
Returns:
Array with two TreeNode objects.
Type
array

canAutoDeselect() → {boolean}

Check if the tree will auto-deselect currently selected nodes when a new selection is made.
Source:
Returns:
If tree will auto-deselect nodes.
Type
boolean

checked(full) → {TreeNodes}

Query for all checked nodes.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

clean() → {TreeNodes}

Clean nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

clearSearch() → {Tree}

Clear nodes matched by previous search, restore all nodes and collapse parents.
Source:
Returns:
Tree instance.
Type
Tree

clone() → {TreeNodes}

Clones (deeply) the array of nodes. Note: Cloning will *not* clone the context pointer.
Source:
Returns:
Array of cloned nodes.
Type
TreeNodes

collapse() → {TreeNodes}

Collapse nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

collapsed(full) → {TreeNodes}

Query for all collapsed nodes.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

collapseDeep() → {TreeNodes}

Collapse (deeply) all children.
Source:
Returns:
Array of node objects.
Type
TreeNodes

concat(nodes) → {TreeNodes}

Concat multiple TreeNodes arrays.
Parameters:
Name Type Description
nodes TreeNodes Array of nodes.
Source:
Returns:
Resulting node array.
Type
TreeNodes

copy(hierarchy) → {object}

Copy nodes to another tree instance.
Parameters:
Name Type Description
hierarchy boolean Include necessary ancestors to match hierarchy.
Source:
Returns:
Methods to perform action on copied nodes.
Type
object

createNode(obj) → {TreeNode}

Creates a TreeNode without adding it. If the obj is already a TreeNode it's returned without modification.
Parameters:
Name Type Description
obj object Source node object.
Source:
Returns:
Node object.
Type
TreeNode

deepest() → {TreeNodes}

Return deepest nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

deselect() → {TreeNodes}

Deselect nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

deselectDeep() → {TreeNodes}

Deselect (deeply) all nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

disableDeselection() → {Tree}

Disable auto-deselection of currently selected nodes.
Source:
Returns:
Tree instance.
Type
Tree

each(iteratee) → {TreeNodes}

Iterate each TreeNode.
Parameters:
Name Type Description
iteratee function Iteratee invoke for each node.
Source:
Returns:
Array of node objects.
Type
TreeNodes

editable(full) → {TreeNodes}

Query for all editable nodes.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

editing(full) → {TreeNodes}

Query for all nodes in editing mode.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

enableDeselection() → {Tree}

Enable auto-deselection of currently selected nodes.
Source:
Returns:
Tree instance.
Type
Tree

every(tester) → {boolean}

Check if every node passes the given test.
Parameters:
Name Type Description
tester function Test each node in this collection,
Source:
Returns:
True if every node passes the test.
Type
boolean

expand() → {TreeNodes}

Expand children.
Source:
Returns:
Array of node objects.
Type
TreeNodes

expandDeep() → {Promise.<TreeNodes>}

Expand (deeply) all nodes.
Source:
Returns:
Promise resolved when all children have loaded and expanded.
Type
Promise.<TreeNodes>

expanded() → {TreeNodes}

Query for all expanded nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

extract(predicate) → {TreeNodes}

Clone a hierarchy of all nodes matching a predicate. Because it filters deeply, we must clone all nodes so that we don't affect the actual node array.
Parameters:
Name Type Description
predicate string | function State flag or custom function.
Source:
Returns:
Array of node objects.
Type
TreeNodes

filter(predicate) → {TreeNodes}

Filter all nodes matching the given predicate.
Parameters:
Name Type Description
predicate function Test function.
Source:
Returns:
Array of node objects.
Type
TreeNodes

filterBy(predicate) → {TreeNodes}

Filter all nodes matching the given predicate.
Parameters:
Name Type Description
predicate string | function State flag or custom function.
Source:
Returns:
Array of node objects.
Type
TreeNodes

find(predicate) → {TreeNode}

Returns the first node matching predicate.
Parameters:
Name Type Description
predicate function Predicate functions, accepts a single node and returns a boolean.
Source:
Returns:
First matching TreeNode, or undefined.
Type
TreeNode

flatten(predicate) → {TreeNodes}

Flatten and get only node(s) matching the expected state or predicate function.
Parameters:
Name Type Description
predicate string | function State property or custom function.
Source:
Returns:
Flat array of matching nodes.
Type
TreeNodes

focused(full) → {TreeNodes}

Query for all focused nodes.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

forEach(iteratee) → {TreeNodes}

Iterate each TreeNode.
Parameters:
Name Type Description
iteratee function Iteratee invoke for each node.
Source:
Returns:
Array of node objects.
Type
TreeNodes

get(index) → {TreeNode}

Get a specific node by its index, or undefined if it doesn't exist.
Parameters:
Name Type Description
index int Numeric index of requested node.
Source:
Returns:
Node object. Undefined if invalid index.
Type
TreeNode

hidden(full) → {TreeNodes}

Query for all hidden nodes.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

hide() → {TreeNodes}

Hide nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

hideDeep() → {TreeNodes}

Hide (deeply) all nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

indeterminate(full) → {TreeNodes}

Query for all indeterminate nodes.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

indexOf(node) → {int}

Get the index of the given node.
Parameters:
Name Type Description
node TreeNode Root tree node.
Source:
Returns:
Index of the node.
Type
int

insertAt(index, object) → {TreeNode}

Insert a new node at the given position.
Parameters:
Name Type Description
index integer Index at which to insert the node.
object object Raw node object or TreeNode.
Source:
Returns:
Node object.
Type
TreeNode

invoke(methods) → {TreeNodes}

Invoke method(s) on each node.
Parameters:
Name Type Description
methods string | array Method name(s).
Source:
Returns:
Array of node objects.
Type
TreeNodes

invokeDeep(methods) → {TreeNodes}

Invoke method(s) deeply.
Parameters:
Name Type Description
methods string | array Method name(s).
Source:
Returns:
Array of node objects.
Type
TreeNodes

isEventMuted(eventName) → {boolean}

Check if an event is currently muted.
Parameters:
Name Type Description
eventName string Event name.
Source:
Returns:
If event is muted.
Type
boolean

isTree(object) → {boolean}

Check if an object is a Tree.
Parameters:
Name Type Description
object object Object
Source:
Returns:
If object is a Tree.
Type
boolean

join(separator) → {string}

Join nodes into a resulting string.
Parameters:
Name Type Description
separator string Separator, defaults to a comma
Source:
Returns:
Strings from root node objects.
Type
string

lastSelectedNode() → {TreeNode}

Get the most recently selected node, if any.
Source:
Returns:
Last selected node, or undefined.
Type
TreeNode

load(loader) → {Promise.<TreeNodes>}

Load data. Accepts an array, function, or promise.
Parameters:
Name Type Description
loader array | function | Promise Array of nodes, function, or promise resolving an array of nodes.
Source:
Returns:
Promise resolved upon successful load, rejected on error.
Type
Promise.<TreeNodes>
Example
tree.load($.getJSON('nodes.json'));

loading(full) → {TreeNodes}

Query for all nodes currently loading children.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

loadMore(event) → {Promise.<TreeNodes>}

Load additional nodes for the root context.
Parameters:
Name Type Description
event Event Click or scroll event if DOM interaction triggered this call.
Source:
Returns:
Resolves with request results.
Type
Promise.<TreeNodes>

map(iteratee) → {TreeNodes}

Create a new collection after passing every node through iteratee.
Parameters:
Name Type Description
iteratee function Node iteratee.
Source:
Returns:
New array of node objects.
Type
TreeNodes

matched(full) → {TreeNodes}

Query for all nodes matched in the last search.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

move(index, newIndex, target) → {TreeNode}

Move node at a given index to a new index.
Parameters:
Name Type Description
index int Current index.
newIndex int New index.
target TreeNodes Target TreeNodes array. Defaults to this.
Source:
Returns:
Node object.
Type
TreeNode

mute(events) → {Tree}

Pause events.
Parameters:
Name Type Description
events array Event names to mute.
Source:
Returns:
Tree instance.
Type
Tree

muted() → {boolean|array}

Get current mute settings.
Source:
Returns:
Muted events. If all, true.
Type
boolean | array

node(id) → {TreeNode}

Get a node.
Parameters:
Name Type Description
id string | number ID of node.
Source:
Returns:
Node object.
Type
TreeNode

nodes(refs) → {TreeNodes}

Get all nodes in a tree, or nodes for an array of IDs.
Parameters:
Name Type Description
refs array Array of ID references.
Source:
Returns:
Array of node objects.
Type
TreeNodes
Example
let all = tree.nodes()
let some = tree.nodes([1, 2, 3])

pagination() → {object}

Get the root TreeNodes pagination.
Source:
Returns:
Pagination configuration object.
Type
object

pop() → {TreeNode}

Pop node in the final index position.
Source:
Returns:
Node object.
Type
TreeNode

push(node) → {int}

Add a TreeNode to the end of the root collection.
Parameters:
Name Type Description
node TreeNode Node object.
Source:
Returns:
The new length
Type
int

reduce(iteratee) → {any}

Reduce nodes.
Parameters:
Name Type Description
iteratee function Iteratee function
Source:
Returns:
Resulting data.
Type
any

reduceRight(iteratee) → {any}

Right-reduce root nodes.
Parameters:
Name Type Description
iteratee function Iteratee function
Source:
Returns:
Resulting data.
Type
any

reload() → {Promise.<TreeNodes>}

Reload/re-execute the original data loader.
Source:
Returns:
Load method promise.
Type
Promise.<TreeNodes>

remove(node) → {TreeNodes}

Remove a node.
Parameters:
Name Type Description
node TreeNode Node object.
Source:
Returns:
Array of node objects.
Type
TreeNodes

removeAll() → {Tree}

Remove all nodes.
Source:
Returns:
Tree instance.
Type
Tree

removed(full) → {TreeNodes}

Query for all soft-removed nodes.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

restore() → {TreeNodes}

Restore nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

restoreDeep() → {TreeNodes}

Restore (deeply) all nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

reverse() → {TreeNodes}

Reverse node order.
Source:
Returns:
Reversed array of node objects.
Type
TreeNodes
Search nodes, showing only those that match and the necessary hierarchy.
Parameters:
Name Type Description
query * Search string, RegExp, or function.
Source:
Returns:
Promise resolved with an array of matching node objects.
Type
Promise.<TreeNodes>

select() → {TreeNodes}

Select nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

selectable(full) → {TreeNodes}

Query for all selectable nodes.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

selectBetween(startNode, endNode) → {Tree}

Select all nodes between a start and end node. Starting node must have a higher index path so we can work down to endNode.
Parameters:
Name Type Description
startNode TreeNode Starting node
endNode TreeNode Ending node
Source:
Returns:
Tree instance.
Type
Tree

selectDeep() → {TreeNodes}

Select (deeply) all nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

selected(full) → {TreeNodes}

Query for all selected nodes.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes

selectFirstAvailableNode() → {TreeNode}

Select the first available node.
Source:
Returns:
Selected node object.
Type
TreeNode

shift() → {TreeNode}

Shift node in the first index position.
Source:
Returns:
Node object.
Type
TreeNode

show() → {TreeNodes}

Show nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

showDeep() → {TreeNodes}

Show (deeply) all nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

slice(begin, end) → {Array}

Get a shallow copy of a portion of nodes.
Parameters:
Name Type Description
begin int Starting index.
end int End index.
Source:
Returns:
Array of selected subset.
Type
Array

softRemove() → {TreeNodes}

Soft-remove nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

some(tester) → {boolean}

Check if at least one node passes the given test.
Parameters:
Name Type Description
tester function Test each node in this collection,
Source:
Returns:
True if at least one node passes the test.
Type
boolean

sort(compareFn) → {TreeNodes}

Sort nodes using a function.
Parameters:
Name Type Description
compareFn function Comparison function.
Source:
Returns:
Root array of node objects.
Type
TreeNodes

sortBy(sorter) → {TreeNodes}

Sort nodes using a function or key name. If no custom sorter given, the configured "sort" value will be used.
Parameters:
Name Type Description
sorter string | function Sort function or property name.
Source:
Returns:
Array of node obejcts.
Type
TreeNodes

sortDeep(compareFn) → {TreeNodes}

Deeply sort nodes.
Parameters:
Name Type Description
compareFn function Comparison function.
Source:
Returns:
Root array of node objects.
Type
TreeNodes

splice(start, deleteCount, node) → {Array}

Remove and/or add new TreeNodes into the root collection.
Parameters:
Name Type Description
start int Starting index.
deleteCount int Count of nodes to delete.
node TreeNode Node(s) to insert.
Source:
Returns:
Array of selected subset.
Type
Array

state(name, newVal) → {TreeNodes}

Set nodes' state values.
Parameters:
Name Type Description
name string Property name.
newVal boolean New value, if setting.
Source:
Returns:
Array of node objects.
Type
TreeNodes

stateDeep(name, newVal) → {TreeNodes}

Set (deeply) nodes' state values.
Parameters:
Name Type Description
name string Property name.
newVal boolean New value, if setting.
Source:
Returns:
Array of node objects.
Type
TreeNodes

swap(node1, node2) → {TreeNodes}

Swap two node positions.
Parameters:
Name Type Description
node1 TreeNode Node 1.
node2 TreeNode Node 2.
Source:
Returns:
Array of node objects.
Type
TreeNodes

toArray() → {array}

Get a native node Array.
Source:
Returns:
Array of node objects.
Type
array

toString() → {string}

Get a string representation of node objects.
Source:
Returns:
Strings from root node objects.
Type
string

unmute(events) → {Tree}

Resume events.
Parameters:
Name Type Description
events array Events to unmute.
Source:
Returns:
Tree instance.
Type
Tree

unshift() → {number}

Add a TreeNode in the first index position.
Source:
Returns:
The new length
Type
number

visible(full) → {TreeNodes}

Query for all visible nodes.
Parameters:
Name Type Description
full boolean Retain full hiearchy.
Source:
Returns:
Array of node objects.
Type
TreeNodes