Go to the source code of this file.
Variables | |
| Zapatec | Tree |
| Zapatec Tree | all = {} |
| Zapatec Tree prototype | createTree |
| Zapatec Tree prototype | createItem |
| Zapatec Tree prototype | makeNode |
| Zapatec Tree prototype | insertBefore |
| Zapatec Tree prototype | removeChild |
| Zapatec Tree prototype | item_addDefaultIcon |
| Zapatec Tree prototype | item_addIcon |
| Zapatec Tree prototype | itemClicked |
| Zapatec Tree prototype | toggleItem |
| Zapatec Tree prototype | collapseAll |
| Zapatec Tree prototype | expandAll |
| Zapatec Tree prototype | toggleAll |
| Zapatec Tree prototype | sync |
| Zapatec Tree prototype | destroy |
| Zapatec Tree prototype | _getTree |
| Zapatec Tree prototype | onItemSelect = function() {} |
| Zapatec Tree | onItemToggle |
|
|
The Zapatec.Tree object constructor. Pass to it the ID of an UL element (or a reference to the element should you have it already) and an optional configuration object. This function creates and initializes the tree widget according to data existent in the nested list, and applies the configuration specified. The configuration object may contain the following options (the following shows default values):
{
hiliteSelectedNode : true, // boolean
compact : false, // boolean
dynamic : false, // boolean
initLevel : false, // false or number
defaultIcons : null // null or string
}
|
|
|
This global variable keeps a "hash table" (that is, a plain JavaScript object) mapping ID-s to references to Zapatec.Tree objects. It's helpful if you want to operate on a tree but you don't want to keep a reference to it. Example:
// the following makes a tree for the <ul id="tree-id"> element var tree = new Zapatec.Tree("tree-id"); // ... later var existing_tree = Zapatec.Tree.all("tree-id"); // and now we can use \b existing_tree the same as we can use \b tree // the following displays \b true alert(existing_tree == tree); So in short, this variable remembers values returned by "new Zapatec.Tree(...)" in case you didn't. |
|
|
For internal use only. Function that creates a (sub)tree. This function walks the UL element, computes and assigns CSS class names and creates HTML elements for a subtree. Each time a LI element is encountered, createItem() is called which effectively creates the item. Beware that createItem() might call back this function in order to create the item's subtree. (so createTree and createItem form an indirect recursion).
|
|
|
For internal use only. This function walks through a LI element and creates the HTML elements associated with that tree item. When it encounters an UL element it calls createTree() in order to create the item's subtree. This function may also call item_addIcon() in order to add the +/- buttons or icons present in the item definition as IMG tags, or item_addDefaultIcon() if the tree configuration specifies "defaultIcons" and no IMG tag was present.
|
|
|
Call this function to create a html element with the optional element type specified. By default, it is a element.
|
|
|
A new child can be inserted between two nodes/children or before one node /children at the same tree level. Inserting the new child before the first node of a tree is allowed but not allowed after the last node of the tree, i.e. end of the tree, except before the last node.
|
|
|
An old child node in the tree can be removed at any level. If the old child node happens to be the root of a subtree, then the entire subtree including child node(s) under the root node will be removed. If the old child node is just an item node without any child node under it as children, then the only node removed is the old child node. Once an item node or a subtree is removed, the node/subtree before and/or after the old node will be joined together, sometimes with tree lines redrawn. The only limitations are that the root node of the top tree is not permitted for removal; the first child node found will be removed if there are more than one tree node with the same id.
|
|
|
For internal use only. This function adds a TD element having a certain class attribute which helps having a tree containing icons without defining IMG tags for each item. The class name will be "tgb icon className" (where "className" is the specified parameter). Further, in order to customize the icons, one should add some CSS lines like this:
div.tree-item td.customIcon {
background: url("themes/img/fs/document2.png") no-repeat 0 50%;
}
div.tree-item-expanded td.customIcon {
background: url("themes/img/fs/folder-open.png") no-repeat 0 50%;
}
div.tree-item-collapsed td.customIcon {
background: url("themes/img/fs/folder.png") no-repeat 0 50%;
}
As you can see, it's very easy to customize the default icons for a normal tree item (that has no subtrees) or for expanded or collapsed items. For the above example to work, one has to pass { defaultIcons: "customIcon" } in the tree configuration object. This function does nothing if the className parameter has a false logical value (i.e. is null).
|
|
|
For internal use only. This function does different things, depending on whether the img parameter is passed or not. If the img is passed, then this function adds it as an icon for the given item. If not passed, this function creates a "+/-" button for the given item.
|
|
|
This function gets called from a global event handler when some item was clicked. It selects the item and toggles it if it has a subtree (expands or collapses it).
|
|
|
This function toggles an item if the state parameter is not specified. If state is true then it expands the item, and if state is false then it collapses the item.
|
|
| Call this function to collapse all items in the tree. |
|
| Call this function to expand all items in the tree. |
|
| Call this function to toggle all items in the tree. |
|
|
Call this function to synchronize the tree to a given item. This means that all items will be collapsed, except that item and the full path to it.
|
|
| Destroys the tree. Removes all elements. Does not destroy the Zapatec.Tree object itself (actually there's no proper way in JavaScript to do that). |
|
|
For internal use only. This function is used when "dynamic initialization" is on. It retrieves a reference to a subtree if already created, or creates it if it wasn't yet and dont_call is false (returns null in that case).
|
|
|
Third party code can override this member in order to add an event handler that gets called each time a tree item is selected. It receives a single string parameter containing the item ID. |
|
|
For internal use only. This is a global event handler that gets called when a tree item is clicked. Don't override! ;-) |