Mixin: Fancytree_Static

Fancytree_Static

Static members in the $.ui.fancytree namespace.
This properties and methods can be accessed without instantiating a concrete
Fancytree instance.

Source:

Example

// Access static members:
var node = $.ui.fancytree.getNode(element);
alert($.ui.fancytree.version);

Members

_FancytreeClass :Fancytree

Expose class object as $.ui.fancytree._FancytreeClass.
Useful to extend $.ui.fancytree._FancytreeClass.prototype.

Type:
Source:

_FancytreeNodeClass :FancytreeNode

Expose class object as $.ui.fancytree._FancytreeNodeClass
Useful to extend $.ui.fancytree._FancytreeNodeClass.prototype.

Type:
Source:

buildType :string

"production" for release builds

Type:
  • string
Source:

debugLevel :int

0: silent .. 5: verbose (default: 3 for release builds).

Type:
  • int
Source:

version :string

Version number "MAJOR.MINOR.PATCH"

Type:
  • string
Source:

Method Summary

Return Type Name and Arguments Details
void assert(cond, msg)

Throw an error if condition fails (debug method).

Details
Fancytree createTree(el, opts)

Create a new Fancytree instance on a target element.

Details
void debounce(timeout, fn, invokeAsap=false, ctx)

Return a function that executes fn at most every timeout ms.

Details
void debug(msg)

Write message to console if debugLevel >= 4

Details
void error(msg)

Write error message to console if debugLevel >= 1.

Details
string escapeHtml(s)

Convert <, >, &, ", ', and / to the equivalent entities.

Details
any evalOption(optionName, node, nodeObject, treeOption, defaultValue)

Return an option value that has a default, but may be overridden by a
callback or a node instance attribute.

Evaluation sequence:

If tree.options.<optionName> is a callback that returns something, use that.
Else if node.<optionName> is defined, use that.
Else if tree.options.<optionName> is a value, use that.
Else use defaultValue.

Details
string eventToString()

Convert a keydown or mouse event to a canonical string like 'ctrl+a',
'ctrl+shift+f2', 'shift+leftdblclick'.

This is especially handy for switch-statements in event handlers.

Details
object fixPositionOptions(opts)

Make jQuery.position() arguments backwards compatible, i.e. if
jQuery UI version <= 1.8, convert
{ my: "left+3 center", at: "left bottom", of: $target }
to
{ my: "left center", at: "left bottom", of: $target, offset: "3 0" }

See http://jqueryui.com/upgrade-guide/1.9/#deprecated-offset-option-merged-into-my-and-at
and http://jsfiddle.net/mar10/6xtu9a4e/

Details
FancytreeNode | null getDragNode()

[ext-dnd5] Return the FancytreeNode that is currently being dragged.

If multiple nodes are dragged, only the first is returned.

Details
Array. getDragNodeList()

[ext-dnd5] Return a Fancytree instance, from element, index, event, or jQueryObject.

Details
object getEventTarget(event)

Return a {node: FancytreeNode, type: TYPE} object for a mouse event.

Details
string getEventTargetType(event)

Return a string describing the affected node region for a mouse event.

Details
FancytreeNode getNode(el)

Return a FancytreeNode instance from element, event, or jQuery object.

Details
Fancytree getTree(el)

Return a Fancytree instance, from element, index, event, or jQueryObject.

Details
void info(msg)

Write message to console if debugLevel >= 3

Details
void overrideMethod(instance, methodName, handler, context)

Return a wrapped handler method, that provides this._super.

Details
Array. parseHtml($ul)

Parse tree data from HTML

    markup

Details
void registerExtension(definition)

Add Fancytree extension definition to the list of globally available extensions.

Details
void setSpanIcon(span, baseClass, icon)

Set expander, checkbox, or node icon, supporting string and object format.

Details
string unescapeHtml(s)

Inverse of escapeHtml().

Details
void warn(msg)

Write warning message to console if debugLevel >= 2.

Details

Method Details

assert(cond, msg)

Throw an error if condition fails (debug method).

Parameters:
Name Type Description
cond boolean
msg string
Source:

createTree(el, optsopt) → {Fancytree}

Create a new Fancytree instance on a target element.

Parameters:
Name Type Attributes Description
el Element | jQueryObject | string

Target DOM element or selector

opts FancytreeOptions <optional>

Fancytree options

Since:
  • 2.25
Source:
Returns:

new tree instance

Type
Fancytree
Example
var tree = $.ui.fancytree.createTree("#tree", {
    source: {url: "my/webservice"}
}); // Create tree for this matching element

debounce(timeout, fn, invokeAsapopt, ctxopt)

Return a function that executes fn at most every timeout ms.

Parameters:
Name Type Attributes Default Description
timeout integer
fn function
invokeAsap boolean <optional>
false
ctx any <optional>
Source:

debug(msg)

Write message to console if debugLevel >= 4

Parameters:
Name Type Description
msg string
Source:

error(msg)

Write error message to console if debugLevel >= 1.

Parameters:
Name Type Description
msg string
Source:

escapeHtml(s) → {string}

Convert <, >, &, ", ', and / to the equivalent entities.

Parameters:
Name Type Description
s string
Source:
Returns:
Type
string

evalOption(optionName, node, nodeObject, treeOption, defaultValueopt) → {any}

Return an option value that has a default, but may be overridden by a
callback or a node instance attribute.

Evaluation sequence:

If tree.options.<optionName> is a callback that returns something, use that.
Else if node.<optionName> is defined, use that.
Else if tree.options.<optionName> is a value, use that.
Else use defaultValue.

Parameters:
Name Type Attributes Description
optionName string

name of the option property (on node and tree)

node FancytreeNode

passed to the callback

nodeObject object

where to look for the local option property, e.g. node or node.data

treeOption object

where to look for the tree option, e.g. tree.options or tree.options.dnd5

defaultValue any <optional>
Since:
  • 2.22
Source:
Returns:
Type
any
Example
// Check for node.foo, tree,options.foo(), and tree.options.foo:
$.ui.fancytree.evalOption("foo", node, node, tree.options);
// Check for node.data.bar, tree,options.qux.bar(), and tree.options.qux.bar:
$.ui.fancytree.evalOption("bar", node, node.data, tree.options.qux);

eventToString() → {string}

Convert a keydown or mouse event to a canonical string like 'ctrl+a',
'ctrl+shift+f2', 'shift+leftdblclick'.

This is especially handy for switch-statements in event handlers.

Parameters:
Type Description
event
Source:
Returns:
Type
string
Example
switch( $.ui.fancytree.eventToString(event) ) {
				case "-":
					tree.nodeSetExpanded(ctx, false);
					break;
				case "shift+return":
					tree.nodeSetActive(ctx, true);
					break;
				case "down":
					res = node.navigate(event.which, activate);
					break;
				default:
					handled = false;
			}
			if( handled ){
				event.preventDefault();
			}

fixPositionOptions(opts) → {object}

Make jQuery.position() arguments backwards compatible, i.e. if
jQuery UI version <= 1.8, convert
{ my: "left+3 center", at: "left bottom", of: $target }
to
{ my: "left center", at: "left bottom", of: $target, offset: "3 0" }

See http://jqueryui.com/upgrade-guide/1.9/#deprecated-offset-option-merged-into-my-and-at
and http://jsfiddle.net/mar10/6xtu9a4e/

Parameters:
Name Type Description
opts object
Source:
Returns:

the (potentially modified) original opts hash object

Type
object

getDragNode() → {FancytreeNode|null}

[ext-dnd5] Return the FancytreeNode that is currently being dragged.

If multiple nodes are dragged, only the first is returned.

Since:
  • 2.31
Source:
Requires:
  • module:jquery.fancytree.dnd5.js
Returns:

dragged nodes or null if no drag operation

Type
FancytreeNode | null
Example
$.ui.fancytree.getDragNode();

getDragNodeList() → {Array.<FancytreeNode>}

[ext-dnd5] Return a Fancytree instance, from element, index, event, or jQueryObject.

Since:
  • 2.31
Source:
Requires:
  • module:jquery.fancytree.dnd5.js
Returns:

List of nodes (empty if no drag operation)

Type
Array.<FancytreeNode>
Example
$.ui.fancytree.getDragNodeList();

getEventTarget(event) → {object}

Return a {node: FancytreeNode, type: TYPE} object for a mouse event.

Parameters:
Name Type Description
event Event

Mouse event, e.g. click, ...

Source:
Returns:

Return a {node: FancytreeNode, type: TYPE} object
TYPE: 'title' | 'prefix' | 'expander' | 'checkbox' | 'icon' | undefined

Type
object

getEventTargetType(event) → {string}

Return a string describing the affected node region for a mouse event.

Parameters:
Name Type Description
event Event

Mouse event, e.g. click, mousemove, ...

Source:
Returns:

'title' | 'prefix' | 'expander' | 'checkbox' | 'icon' | undefined

Type
string

getNode(el) → {FancytreeNode}

Return a FancytreeNode instance from element, event, or jQuery object.

Parameters:
Name Type Description
el Element | jQueryObject | Event
Source:
Returns:

matching node or null

Type
FancytreeNode

getTree(elopt) → {Fancytree}

Return a Fancytree instance, from element, index, event, or jQueryObject.

Parameters:
Name Type Attributes Description
el Element | jQueryObject | Event | integer | string <optional>
Since:
  • 2.13
Source:
Returns:

matching tree or null

Type
Fancytree
Example
$.ui.fancytree.getTree();  // Get first Fancytree instance on page
$.ui.fancytree.getTree(1);  // Get second Fancytree instance on page
$.ui.fancytree.getTree(event);  // Get tree for this mouse- or keyboard event
$.ui.fancytree.getTree("foo");  // Get tree for this `opts.treeId`
$.ui.fancytree.getTree("#tree");  // Get tree for this matching element

info(msg)

Write message to console if debugLevel >= 3

Parameters:
Name Type Description
msg string
Source:

overrideMethod(instance, methodName, handler, contextopt)

Return a wrapped handler method, that provides this._super.

Parameters:
Name Type Attributes Description
instance object
methodName string
handler function
context object <optional>

optional context

Source:
Example
// Implement `opts.createNode` event to add the 'draggable' attribute
				$.ui.fancytree.overrideMethod(ctx.options, "createNode", function(event, data) {
					// Default processing if any
					this._super.apply(this, arguments);
					// Add 'draggable' attribute
					data.node.span.draggable = true;
				});

parseHtml($ul) → {Array.<NodeData>}

Parse tree data from HTML

    markup

Parameters:
Name Type Description
$ul jQueryObject
Source:
Returns:
Type
Array.<NodeData>

registerExtension(definition)

Add Fancytree extension definition to the list of globally available extensions.

Parameters:
Name Type Description
definition object
Source:

setSpanIcon(span, baseClass, icon)

Set expander, checkbox, or node icon, supporting string and object format.

Parameters:
Name Type Description
span Element | jQueryObject
baseClass string
icon string | object
Since:
  • 2.27
Source:

unescapeHtml(s) → {string}

Inverse of escapeHtml().

Parameters:
Name Type Description
s string
Source:
Returns:
Type
string

warn(msg)

Write warning message to console if debugLevel >= 2.

Parameters:
Name Type Description
msg string
Source:

Fork me on GitHub