Class Index | File Index

Classes


Class MochiKit.Widget.TreeNode


Extends MochiKit.Widget.
The tree node widget class. Used to provide a tree node in a tree, using a number of <div> HTML elements. Note that events should normally not be listened for on individual tree nodes, but rather on the tree as a whole.
Defined in: Widget.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates a new tree node widget.
Fields borrowed from class MochiKit.Widget:
_id, Classes
Method Summary
Method Attributes Method Name and Description
 
_container(create)
Returns and/or creates the child container DOM node.
 
addChildNode(child)
Adds a single child tree node widget to this widget.
 
Collapses this node to hide any child nodes.
 
collapseAll(depth)
Recursively collapses this node and all its children.
 
Expands this node to display any child nodes.
 
expandAll(depth)
Recursively expands this node and all its children.
 
findByPath(path)
Searches for a descendant tree node from the specified path.
 
findChild(name)
Finds a child tree node with the specified name.
 
Returns an array with all child tree node widgets.
 
Checks if this folder node is expanded.
 
Checks if this node is a folder.
 
Checks if this node is selected.
 
Marks all tree nodes as unmodified.
 
Returns the parent tree node widget.
 
path()
Returns the path to this tree node.
 
Removes all tree nodes that are marked as unmodified.
 
Removes a single child tree node widget from this widget.
 
Selects this tree node.
 
setAttrs(attrs)
Updates the widget or HTML DOM node attributes.
 
toggle(evt)
Toggles expand and collapse for this node.
 
tree()
Returns the ancestor tree widget.
 
Unselects this tree node.
Methods borrowed from class MochiKit.Widget:
_animQueueId, _createWidgetTreeElem, _eventHandler, _widgetMixin, addAll, addClass, animate, blurAll, createWidget, createWidgetTree, destroy, destroyWidget, emitSignal, hasClass, hide, isFormField, isHidden, isWidget, removeAll, removeClass, setStyle, show, toggleClass
Class Detail
MochiKit.Widget.TreeNode(attrs)
Creates a new tree node widget.
Parameters:
{Object} attrs
the widget and node attributes
{String} attrs.name
the tree node name
{Boolean} attrs.folder Optional
the folder flag, defaults to false
{String} attrs.icon Optional
the icon reference to use, defaults to "FOLDER" for folders and "DOCUMENT" otherwise
{String} attrs.tooltip Optional
the tooltip text when hovering
{Widget} ... Optional
the child tree node widgets
Returns:
{Widget} the widget DOM node
Method Detail
{Node} _container(create)
Returns and/or creates the child container DOM node. If a child container is created, it will be hidden by default.
Parameters:
{Boolean} create
the optional create flag, defaults to false
Returns:
{Node} the child container DOM node found or created

addChildNode(child)
Adds a single child tree node widget to this widget.
Parameters:
{Widget} child
the tree node widget to add

collapse()
Collapses this node to hide any child nodes.

collapseAll(depth)
Recursively collapses this node and all its children. If a depth is specified, only children below that depth will be collapsed.
Parameters:
{Number} depth Optional
the optional minimum depth

expand()
Expands this node to display any child nodes. If the parent node is not expanded, it will be expanded as well.

expandAll(depth)
Recursively expands this node and all its children. If a depth is specified, expansions will not continue below that depth.
Parameters:
{Number} depth Optional
the optional maximum depth

{Widget} findByPath(path)
Searches for a descendant tree node from the specified path.
Parameters:
{Array} path
the tree node path (array of node names)
Returns:
{Widget} the descendant tree node found, or null if not found

{Widget} findChild(name)
Finds a child tree node with the specified name.
Parameters:
{String} name
the child tree node name
Returns:
{Widget} the child tree node found, or null if not found

{Array} getChildNodes()
Returns an array with all child tree node widgets. Note that the array is a real JavaScript array, not a dynamic NodeList.
Returns:
{Array} the array of child tree node widgets

{Boolean} isExpanded()
Checks if this folder node is expanded.
Returns:
{Boolean} true if this node is expanded, or false otherwise

{Boolean} isFolder()
Checks if this node is a folder.
Returns:
{Boolean} true if this node is a folder, or false otherwise

{Boolean} isSelected()
Checks if this node is selected.
Returns:
{Boolean} true if the node is selected, or false otherwise

markAll()
Marks all tree nodes as unmodified. When adding or updating nodes, they (and their parent nodes) are automatically marked as modified. This function makes tree pruning possible, by initially marking all tree nodes (clearing any previous modified flag), touching all nodes to be kept, and finally calling the removeAllMarked() method to remove the remaining nodes.

{Widget} parent()
Returns the parent tree node widget.
Returns:
{Widget} the parent tree node widget, or null if this is a root node

{Array} path()
Returns the path to this tree node.
Returns:
{Array} the tree node path, i.e an array of node names

removeAllMarked()
Removes all tree nodes that are marked as unmodified. When adding or updating nodes, they (and their parent nodes) are automatically marked as modified. This function makes tree pruning possible, by initially marking all tree nodes as unmodified (clearing any previous modified flag), touching all nodes to be kept, and finally calling this method to remove the remaining nodes.

removeChildNode(child)
Removes a single child tree node widget from this widget.
Parameters:
{Widget} child
the tree node widget to remove

select()
Selects this tree node.

setAttrs(attrs)
Updates the widget or HTML DOM node attributes.
Parameters:
{Object} attrs
the widget and node attributes to set
{String} attrs.name Optional
the tree node name
{Boolean} attrs.folder Optional
the folder flag, cannot be reverted to false once set (implicitly or explicitly)
{Icon/Object/String} attrs.icon Optional
icon the icon to set, or null to remove
{String} attrs.tooltip Optional
the tooltip text when hovering

toggle(evt)
Toggles expand and collapse for this node.
Parameters:
evt

{Widget} tree()
Returns the ancestor tree widget.
Returns:
{Widget} the ancestor tree widget, or null if none was found

unselect()
Unselects this tree node.

Documentation generated by JsDoc Toolkit 2.0.2 on Sun May 24 2009 13:14:17 GMT+0200 (CEST)