Library: treemenu.js
Overview
- source: treemenu.js
Constructors
The Nornix.TreeMenu class creates an explorer-like interface from nested lists.
The menu can use either server-side facilities to create classes for
the styling with CSS to hook on to.
Only set inAllowWhitespace to true when necessary, as it slows down the script.
Usage instructions at http://treemenu.nornix.com/info/usage
version: @version@
parameters
| String | inMenuId | id of the element surrounding the menu |
| boolean | inAllowWhitespace | if true, whitespace is allowed between menu elements in the HTML code |
methods
- openAll()
- closeAll()
- openToNode(node, setFocus, makeCurrent, doClick, e)
- start()
- registerMenuButton(menu, function)
- createNode(text, href, title, the)
- appendChild(node, newNode, showNode, setFocus, move)
- insertBefore(node, newNode, showNode, setFocus, move)
- insertAfter(node, newNode, showNode, setFocus, move)
- remove(node)
Namespaces
Nornix.TreeMenu.config(dynamicClasses, openCloseAll, navigationIcons, markCurrentItem, focusCurrentItem, contentElement, menuLinkElement, preloadImages, imagePath, imageExtension, searchNodeMode)
Configuration of the menu.
To change all instances, use: Nornix.TreeMenu.prototype.config.parameter = value;
To change a particular instance, use: treemenu.config.parameter = value;
parameters
| boolean | dynamicClasses | Turn dynamic class population on/off. |
| boolean | openCloseAll | Add icons for open/close all folders. |
| boolean | navigationIcons | Add icons for navigation. |
| boolean | markCurrentItem | Add an empty span to mark the current element. |
| boolean | focusCurrentItem | Move focus to the current menu item. |
| string, boolean | contentElement | ID of the page content containing element. Set to false to disable. |
| string, boolean | menuLinkElement | ID of a link to the menu. Set to false to disable. |
| string[] | preloadImages | Names of images to preload. Be careful with the order of the images! |
| string | imagePath | Path to the images used in the menu. Used for preloading. |
| string | imageExtension | Extension for image files. A dot is not automatically prepended! |
| integer | searchNodeMode | How to resolve nodes when searching for them: 0: try text search first, then try href attributes 1: try href attributes first, then try text 2: try only text search 3: try only href attribute search |
Nornix.TreeMenu.hooks(dynamicDocumentLinks, dynamicFolderLinks)
Extension points to add your own hooks inside the tree menu.
The functions used will receive the clicked HTMLAnchorElement as
a parameter. To prevent any further event handling, let the function
return false, otherwise let it return true.
To change all instances, use: Nornix.TreeMenu.prototype.hooks.parameter = value;
To change a particular instance, use: treemenu.hooks.parameter = value;
parameters
| Function, boolean | dynamicDocumentLinks | Function to handle document node clicks (or set to false). |
| Function, boolean | dynamicFolderLinks | Function to handle folder node clicks (or set to false). |
Nornix.TreeMenu.texts(closeTreeTitle, openTreeTitle, closeFolderTitle, openFolderTitle, goFirstTitle, goLastTitle, goNextTitle, goPrevTitle)
Texts used by the tree menu.
To change all instances, use: Nornix.TreeMenu.prototype.texts.parameter = value;
To change a particular instance, use: treemenu.texts.parameter = value;
To change all texts use: Nornix.TreeMenu.prototype.texts = {...}; or
treemenu.prototype.texts = {...}; (see source code!)
parameters
| string | closeTreeTitle | Text for "close all" title attribute |
| string | openTreeTitle | Text for "open all" title attribute. |
| string | closeFolderTitle | Text for "close folder" title attribute. |
| string | openFolderTitle | Text for "open folder" title attribute. |
| string | goFirstTitle | Text for "go to first" title attribute. |
| string | goLastTitle | Text for "go to last" title attribute. |
| string | goNextTitle | Text for "go to next" title attribute. |
| string | goPrevTitle | Text for "go to previous" title attribute. |
Functions
Nornix.TreeMenu.openAll()
Open all folders in the menu.
Nornix.TreeMenu.closeAll()
Close all folders in the menu.
Open tree to the specified node.
The node can be given as a DOM node or as a string.
The string will be interpreted as a href value
or node text value.
When used in event handlers, the return value can be useful.
parameters
| HTMLAnchorElement, HTMLLIElement, string | node | node to open to, either A och LI element or string |
| boolean | setFocus? | set to true to move focus to node |
| boolean | makeCurrent? | make node the current node |
| boolean | doClick? | set to true to "click" the link |
| Event | e? | event object |
returns
| boolean | true if the event action should continue. |
Nornix.TreeMenu.start()
Start the tree menu.
Initialization will be called as soon as the menu object is available in the DOM.
Images will be preloaded while the DOM is built.
Nornix.TreeMenu.preventStatusSave()
Prevent the tree state from being saved when leaving the page.
Register a menu button an its action.
parameters
| HTMLAnchorElement | menu | button element |
| Function | function | to call when button is pressed |
Create a new menu (document) node.
If child nodes are added the node will automatically
become a folder node, once it's inside of the menu.
To add more attributes or whatever, use the returned LI
element or the A element at LI.firstChild.
parameters
| string | text | link text for node |
| string | href? | link address to use for A element (or null) |
| string | title? | text to show on hovering the A element |
| HTMLLIElement | the | LI element that was created |
Add child node to a menu item.
parameters
| HTMLAnchorElement, string | node | menu item |
| HTMLLIElement, string | newNode | child node to add |
| boolean | showNode? | make new node visible |
| boolean | setFocus? | set focus to the child node |
| boolean | move? | set to true when moving a node |
Add menu item before another menu item.
parameters
| HTMLAnchorElement, string | node | menu item |
| HTMLLIElement, string | newNode | child node to add |
| boolean | showNode? | make new node visible |
| boolean | setFocus? | set focus to the child node |
| boolean | move? | set to true when moving a node |
Add menu item after another menu item.
parameters
| HTMLAnchorElement, string | node | menu item |
| HTMLLIElement, string | newNode | child node to add |
| boolean | showNode? | make new node visible |
| boolean | setFocus? | set focus to the child node |
| boolean | move? | set to true when moving a node |
Remove item from menu.
parameters
| HTMLAnchorElement, string | node | menu item |
Nornix.TreeMenu.goToFirstNode()
Go to and click first link in menu.
Nornix.TreeMenu.goToLastNode()
Go to and click last link in menu.
Nornix.TreeMenu.goToNextNode()
Go to and click next link in menu.
Nornix.TreeMenu.goToPrevNode()
Go to and click previous link in menu.
Objects
Generated by JsDoc Toolkit 1.4.1b on Wed, 14 May 2008 21:00:44 GMT.