multilevel tree menu jQuery

This is a powerful jQuery component to build easily a multilevel tree menu or a contextual menu (right click) in an intuitive way!

 

 

JS call for the menu:

$(".myMenu").buildMenu({
template:"yourMenuVoiceTemplate",
additionalData:"",
menuSelector:".menuContainer",
menuWidth:150,
openOnRight:false,
containment:"window",
iconPath:"ico/",
hasImages:true,
fadeInTime:100,
fadeOutTime:200,
menuTop:0,
menuLeft:0,
submenuTop:0,
submenuLeft:4,
opacity:1,
shadow:false,
shadowColor:"black",
shadowOpacity:.2,
openOnClick:true,
closeOnMouseOut:false,
closeAfter:500,
minZindex:"auto",
hoverIntent:0, //if you use jquery.hoverIntent.js set this to time in milliseconds; 0= false;
submenuHoverIntent:0, //if you use jquery.hoverIntent.js set this to time in milliseconds; 0= false;
});

JS call for the contextualmenu:

$(document).buildContextualMenu({
template:"yourMenuVoiceTemplate",
additionalData:"",
menuSelector:".menuContainer",
menuWidth:150,
openOnRight:false,
containment:"window",
iconPath:"ico/",
hasImages:true,
fadeInTime:100,
fadeOutTime:200,
menuTop:0,
menuLeft:0,
submenuTop:0,
submenuLeft:4,
opacity:1,
shadow:false,
shadowColor:"black",
shadowOpacity:.2,
openOnClick:true,
closeOnMouseOut:false,
closeAfter:500,
minZindex:"auto",
hoverIntent:0, //if you use jquery.hoverIntent.js set this to time in milliseconds; 0= false;
submenuHoverIntent:0, //if you use jquery.hoverIntent.js set this to time in milliseconds; 0= false;
onContextualMenu:function(o,e){} //it pass 'o' (the menu you clicked on) and 'e' (the event)
});

HTML constructor for the header:

ajax menu 12 menu 2 menu 3 menu 4 empty

 

HTML constructor for menus:

 

Parameters:

Those are the general attribute for all the menues you are initializing with a single call:

  • template: (string) – is the ajax page that build this level menu structure; If the menu you are calling is not on the page, the component automatically will try to build it calling via Ajax the “template” page, passing the ID of the menu you call in the request (“menuId”). The temlate page should be a dinamic page (php, jsp, aspx, …) that will build the menu from the ID param passed in the request.
  • additionalData: (string) – are additional data needed to build the menu, by default it send the actual menuline id; If you need some other params to be passed to the template page to build your menu you can set them here, writing them like: “pippo=1&pluto=false”;
  • containment: (string) – the ID of a containment parent element;
  • openOnRight: (boolean) – let the menus open on the right side instead bottom;
  • openOnClick: (boolean) – define if the menu is opened by a mouse click or by a mouseover event;
  • hasImages: (boolean) – define if the menu voices have images or not on its left;
  • menuSelector: (string) – is the css class applied to each menu container of this menu context;
  • closeOnMouseOut: (boolean) – the menu can be close either onclik on the window or just when your mouse exit the menu
  • closeAfter: (int) – the time to whait befor close the menu (works just if closeOnMouseOut is set to true)
  • fadeInTime / fadeOutTime: (int) – those params control the speed of the opening and closing fade effect.
  • hoverIntent: (int) – this param sets the delay for the hover event; if set to 0 the hoverIntent function is not used. To use this feature you have to include the jquery.hoverIntent plug in in your page!
  • submenuHoverIntent: (int) – this param sets the delay for the hover event on submenu calls; if set to 0 the hoverIntent function is not used. To use this feature you have to include the jquery.hoverIntent plug in in your page!
  • onContextualMenu: (function) – A function invoked once each contextualMenu is called; the function has either the dom element you clicked on (o), either the event (e).
  • menuWidth: (int) – define the min-width of each menu.
  • iconPath: (string) – set thebaseUrl for icons.
  • hasImages: (boolean) – define if the menu has icons or not.
  • menuTop / menuLeft / submenuTop / submenuLeft: (int) – set the corresponding margin from the opener.
  • opacity: (int) – define the opacity of the menu.
  • shadow: (boolean) – define if the menu has a shadow. (doesn’t work in IE)
  • shadowColor: (string) – define the color of the shadow. (doesn’t work in IE)
  • shadowOpacity: (int) – define the opacity of the shadow. (doesn’t work in IE)
  • minZindex: (int or “auto”) – set the min z-index of the menu.

 

header constructor:

The header constructor doesn’t need to be a table; it needs to be grouped with a block element (like a DIV) that define the whole component.

...

 

How to define which is the submenu that has to be opened:

with jquery.metadata.plugin: Add a class attribute where to pass the “menu” as JSON parameter with the ID of the menu element.

...
[menuTitle]
...

without jquery.metadata.plugin: Add an attribute “menu” with the ID of the menu element:

...
[menuTitle]
...

Setting “empty” as value of the “menu” attribute no submenu’ll be shown:

...
[menuTitle]
...

menu constructor:

The menu constructor must have a containment DIV element with the ID to be refferred by the opener element and as many A tags as the voices are.

 

P.S.: if you set both href and action the action will override the href.

The containment DIV element can also contain custom HTML just adding “box_menu” as class:

 

In this case no manipulation of the content is applied and no metadata is reached.

If you are not using jquery.metadata.plugin intead of declaring params inside the class you should create single attribute for each pram:
for Ex:

[label]

Be Sociable, Share!

Leave a comment