Index | OAT homepage | OpenLink Software

tree.js

tree.js

Converts Unordered List (ul element) into interactive tree.

Objects

OAT.Tree(options)

Options may contain any of the following:

Methods

OAT.Tree.assign(listElement, collapse)

This converts a list into an interactive tree.listElement specifies an

element in which your list lives. Argument collapse toggles initial collapsing of whole tree.

Tree data structure can be accessed and modified. See Example for usage.

HTML Enhancement

Add attributes branchImg,toggle OpenImg and toggleClosedImg, which would be appended to the <li>tag. This way we can have any desired name AND file format for the tree decoration.

Example


var t1 = new OAT.Tree({imagePath:"images",    // will take images from
         imagePrefix:"", ext:"gif"});         // images/Tree_*.gif
var t2 = new OAT.Tree({imagePath:"images",    // will take images from
         imagePrefix:"prefix", ext:"png"});   // images/Tree_prefix_*.png
t1.assign("myUL1", true);   // collapsed
t2.assign("myUL2", false);  // expanded

var node1 = t1.tree.children[0];
var node2 = t2.tree.children[1];

node2.appendChild(node1);
node1.setLabel("newLabel");
node2.expand();
node1.createChild("newLabel", true);  // second argument means that new 
                                      // child is a node rather than leaf
node2.deleteChild(node1);


Copyright (C) 2005-2009 OpenLink Software