NodeFire Library

menu  1.0.6

NodeFire Library > menu > NF.widget.menuManager
Search:
 
Filters

static Class NF.widget.menuManager

Manages multiple menu objects and provides extended features for manipulating menu items, setting breadcrumbs, and more...

Properties

holdSubsUntilInteraction - boolean

If true subs are frozen untill the document is clicked or a menu is interacted with. The property is then set false.

Methods

activateMenuFromStructureNode

object activateMenuFromStructureNode ( Node )
Finds the structure nodes parent menu object and activates / renders the menu. If a subs root node contains the 'nfPure' className then a new menu object is created, activated, and returned.
Parameters:
Node <Node> A node in a menu structure.
Returns: object
An existing or new menu object.

activateMenus

void activateMenus ( )
Activates all menu objects added to the menuManager.
Returns: void

addItem

Object addItem ( refNode , newItem , addWhere )
Adds an item Node to a menu object. Use the addWhere paramter to specify where to add the newItem...
  • "before" - [Default when refNode is an item] Adds the newItem as a sibling before the refNode.
  • "after" - Adds the newItem as a sibling after the refNode.
  • "replace" - Replaces the refNode with the newItem.
  • "first-child" - Add the newItem as the first child of the refNodes sub menu.
  • "last-child" - [Default when refNode is a sub] Add the newItem as the last child of the refNodess sub menu.
  • "replace-child" - Remove all child sub menu items and add the newItem as an only child.

Pass the newItem parameter an object literal with the following optional properties...
  • {html:string} Creates a newItem from an HTML string.
  • {element:Node} A Node or HTMLElement object reference to use as the newItem
  • {link:Object} Object literal with the optional properties defined here, added as a child link for the item.
  • {wrap:HTML string | Node} An HTML string or Node to wrap the newItem or newLink in.
  • {text:string} Create a newItem automatically and inserts the text value as the innerHTML.
  • {tag:string} Optionally specify the tag name for items created using the text property.
  • {[? - AttributeName]:[? - value]} Adds the specified attributeName / value pair to the newItems created with the text property above.

To automatically create a new item with a tag matching your structure type, pass newItem an empty object literal (var myItem = {}). To add a child link to the item, attach a second object literal to the link property, e.g.
  • var myItem = {link:{text:"My Link Content",href:"myLink.html"}};

Optionally use the element, or html properties to create a new item with a child link or sub menu, e.g....
  • var myItem = {html:"<li class='nfItem'><a href='myLink.html' class='nfLink'>My Link Content</a></li>"};
  • var myItem = {element:myNode,link:{element:myNode}};

The menu object to which the item Node is added is automatically activated / rendered and any registered replicators produce clones for the newItems.

Parameters:
refNode <Node> The refNode can be an item, sub, link, or other Node within a menu structure.
newItem <Object | Object Array> Object literals with properties defining the newItem Nodes to add. {html,element,link,wrap,text,tag,(attribute value pair)}
addWhere <string> Optionally specify where to add the item Node... "before", "after", "replace", "first-child", "last-child", "replace-child"
Returns: Object
Object literal containing an array of the added item Nodes and the menu object to which they were added. The object properties are... {node:array, menu:object}.

addLink

Object addLink ( refItem , newLink )
Adds a link to a menu item Node. If the item already contains a link, the link will be replaced with the newLink. The menu object to which the link Node is added is automatically activated / rendered and any registered replicators are applied.

Pass the newLink parameter an object literal with the following optional properties...
  • {html:string} Creates a newLink from an HTML string.
  • {element:Node} A Node or HTMLElement object reference to use as the newLink
  • {wrap:HTML string | Node} An HTML string or Node to wrap the newLink in.
  • {text:string} Create a newLink automatically and inserts the text value as the innerHTML.
  • {tag:string} Optionally specify the tag name for links created using the text property. Default tag is Anchor.
  • {[? - AttributeName]:[? - value]} Adds the specified attributeName / value pair to the newLink created with the text property above.
Parameters:
refItem <Node> Reference Node.
newLink <Object> Object literal with properties defining the newLink to add as a child of refItem. {html,element,wrap,text,tag(attribute value pair)}
Returns: Object
Object literal containing the added link Node and the menu object to which it was added. The object properties are... {node, menu}.

addMenu

void addMenu ( menu )
Add a menu widget object to the menuManager. This method is called automatically be nf.widget.menu.activate.
Parameters:
menu <menu> A menu object.
Returns: void

addReplicator

Array addReplicator ( replicator , menu )
Adds a replicator to a menu object or Array of menu objects.
Parameters:
replicator <repliator> The replicator object to add.
menu <menu | menu Array> A menu object or Array of menu objects.
Returns: Array
Menu object array.

addSub

Object addSub ( refItem , newSub )
Adds a sub menu container to a menu item Node. If the item already contains a sub, the sub will be replaced with the newSub. The menu object to which the sub Node is added is automatically activated / rendered and any registered replicators are applied.

If the subs root Node contains a "nfPure" className a new menu object will be created. A reference to the new object is returned. The newSub may contain any number of items and child sub menus.

Pass the newLink parameter an object literal with the following optional properties...
  • {html:string} Creates a newSub from an HTML string.
  • {element:Node} A Node or HTMLElement object reference to use as the newSub
  • {wrap:HTML string | Node} An HTML string or Node to wrap the newSub in.
  • {text:string} Create a newSub automatically and inserts the text value as the innerHTML.
  • {tag:string} Optionally specify the tag name for subs created using the text property.
  • {[? - AttributeName]:[? - value]} Adds the specified attributeName / value pair to the newSub created with the text property above.
Parameters:
refItem <Node> Reference Node.
newSub <Object> Object literal with properties defining the newSub to add as a child of refItem. {html,element,wrap,text,tag(attribute value pair)}
Returns: Object
Object literal containing the added sub Node and the menu object or new menu object to which it was added. The object properties are... {node, menu}.

collapseActiveMenu

Boolean collapseActiveMenu ( Event , menu )
Collapses the active menu. This function may be called from the active menu to hide the active sub menu after clicking a link.
Parameters:
Event <Event> Pass the DOM fired event which triggered the call (if any). You must pass the event if calling this method from a click event on a menu item or the sub will not close.
menu <menu object || Node || menu id> A menu object, menu node, or menu id.
Returns: Boolean
True if an active sub was closed.

getChildMenus

Array getChildMenus ( root )
Get all child menu objects.
Parameters:
root <node | menu> A root node or menu object.
Returns: Array
Array of menu objects.

getMenuObjectFromNode

Object getMenuObjectFromNode ( Node )
Get a Nodes parent NF.widget.menu object.
Parameters:
Node <Node> The Node to query for a parent menu object.
Returns: Object
The parent menu objects which contains the Node.

getMenuObjects

Object Array getMenuObjects ( )
Get an Array of all active menu objects in the document.
Returns: Object Array
An Array of NF.widget.menu objects.

removeMenu

node removeMenu ( menu )
Removes a menu widget object from the menuManager and then removes the menus root node from the DOM.
Parameters:
menu <menu> A instace of NF.widget.menu.
Returns: node
Returns the root menu node removed from the document.

removeNode

Node removeNode ( Node )
Removes a node.
Parameters:
Node <Node> The Node to remove.
Returns: Node
The removed Node.

setActivePath

Node Array setActivePath ( itemNode , getItemPath )
Set an active path. Starting with the passed itemNode, all items up to the root structure node are activated and child subs are set visible.
Parameters:
itemNode <Node> An item Node to set active.
getItemPath <boolean> Optional - Return a Node Array of all items activated.
Returns: Node Array
Array of Nodes representing the path from the itemNode parameter to the root of the menu structure if the getItemPath parameter is true.

setBreadcrumbs

Node Array setBreadcrumbs ( itemNodes , setActive )
Adds the .nfJSBreadcrumb className to all links within the itemNode Array. The setActive parameter optionally sets the path sub menus visible and triggers any replicator, animation, and othe defined menu features. If setActive is true only the first array item and associated ancestor items and subs will be visibily activated. the setActive parameter sets the holdSubsUntilInteraction property to true.
Parameters:
itemNodes <Node Array> An array of itemNodes to apply .nfJSBreadcrumb styles to.
setActive <boolean> If true the sub menus within the path between the itemNode and root will be set visible (animation, replicators and other features will be triggered).
Returns: Node Array
Array of active menu item Nodes if the setActive param was true.


Copyright © 2012 OpenCube: Inc. All rights reserved.