|
OverviewThere are three steps in creating a tree.
Finally, there is a section that does trouble shooting menu display problems 1. Creating a TreeYou can use the same Menu Builder for JSCookMenu to to build the tree for JSCookTree since their formats are the same. Or you could use the following format to add nodes to the tree. <SCRIPT LANGUAGE="JavaScript"><!-- var myMenu = [ ['icon', 'title', 'url', 'target', 'description'], // a menu item ['icon', 'title', 'url', 'target', 'description'], // a menu item ['icon', 'title', 'url', 'target', 'description', // a folder item ['icon', 'title', 'url', 'target', 'description'], // a menu item ['icon', 'title', 'url', 'target', 'description'], // a menu item ['icon', 'title', 'url', 'target', 'description', // a folder item ['icon', 'title', 'url', 'target', 'description'], // a menu item ['icon', 'title', 'url', 'target', 'description'] // a menu item ] ] ]; --></SCRIPT> Note: JSCookTree cannot handle _cmSplit used in JSCookMenu since there are no menu splits in trees. A folder item contains sub trees. Note that sub trees can be nested. Also, JSCookTree allows a folder item to contain links. Be careful of the commas. If you missed one between two sibling nodes, both IE and Netscape simply quit parsing the rest. So, if you do not see the menu, this is one place to check. 2. Pick a ThemeIn order to use JSCookTree, one needs to define a set of styles for HTML components. Usually, this task is not easy to do from scratch. Fortunately, some themes were provided and can be used as a template. Currently, I designed 4 themes:
The guide line for definiting new themes will be described separately. Right now, you can just pick a theme, for instance, Windows XP. To load a theme, one needs to do the following: <SCRIPT LANGUAGE="JavaScript" SRC="/JSCookTree/JSCookTree.js"></SCRIPT> Then <LINK REL="stylesheet" HREF="/JSCookTree/ThemeXP/theme.css" TYPE="text/css"> <SCRIPT LANGUAGE="JavaScript" SRC="/JSCookTree/ThemeXP/theme.js"></SCRIPT> It is very important that
JSCookTree.js
is loaded before themes and the menu you created.3. Display the TreeFirst, one needs to find the place to put the tree. JSCookTree can be assigned to
TD, SPAN, DIV as well as other type of HTML elements that have <DIV ID=myMenuID></DIV> Then, add a java script command that tells the web browser to display the menu in that element: <SCRIPT LANGUAGE="JavaScript"><!-- ctDraw ('myMenuID', myMenu, ctThemeXP1, 'ThemeXP', 0, 0); --></SCRIPT> The first parameter is the HTML element id, the second one is the menu tree. ctThemeXP1 is the theme property, 'ThemeXP' is Windows XP theme's prefix. The fifth parameter indicates branch control (0: no branch control; 1: only one branched is opened for the tree; 2: only one branch is opened in the global group). The sixth parameter indicate the default expansion level. Here is what the menu looks like: Congratulations, you just built the first tree. It does not look very pretty at present since no real interesting stuff has been inserted. Check the demo page for some fancier examples. Although JSCookTree is a tree builder, it does not mean that it cannot be used to create menus. Navy theme is a such demonstration. 4. Trouble ShootingThere are many reasons for not showing the menus.
|
|