Jeegoocontext, a jQuery context menu plugin

Jeegoocontext is a jQuery plugin that allows for multiple custom context menus (pop-up menus) to exist on a single page. The plugin is able to transform any unordered list appended to the body into a multi-level, intelligently positioned styled context menu via a single call.

Features:


Easy to implement

Steps required to implement the plugin:

  1. Include references to the jquery library, and to jquery.jeegoocontext.min.js.
  2. Select a skin (skins cm_default and cm_blue included in the code-download) and include a reference to the skin's stylesheet.
  3. Append an unordered list to the body and give it a unique id and the following class name: "jeegoocontext" and the class name for the skin: "cm_default" or "cm_blue" for example.
  4. Bind any context to the menu with the following call: $('context').jeegoocontext('menu id'); Where 'context' can be any jQuery selector and 'menu id' contains the unique id of the menu, for example: $('.context').jeegoocontext('menu_1');

Both vertical and horizontal intelligent positioning

Normally the context menu opens exactly at the clicked position. However, when opened at the near edges of a webpage, the menu and subsequent submenus are offset to the left/top to avoid overflow to the right/bottom.

Overflow behavior can be customized by adjusting the widthOverflowOffset and heightOverflowOffset properties on the options object.

Customizable time delays to provide easy selection of items

The delay property on the options object provides time-out values to the menu to allow for easy selection of submenu items. Without these delays expanded submenus collapse immediately after a user moves his/her mouse to another list-item, which can be very annoying. The following animations illustrate these conditions:

no delays

No delays

delays

Delays

Multiple context menus on a single page

Each page can contain multiple context menus. All that is required is that each menu contains a unique id and they all share the "jeegoocontext" class (overridable via the options.menuClass property).

Fully css customizable UI

The plugin contains very little presentation script, so the UI can be fully styled via css. The code-download includes a skins folder containing two skins named: "cm_default" and "cm_blue". These skins consist of nothing more than an images folder and a stylesheet.

Customizable behavior via callbacks

The plugin publishes the following four useful events to provide customizable behavior:

  1. onShow
  2. onHover
  3. onSelect
  4. onHide

From within each of these callbacks default behavior can be cancelled by returning false.

Customizable class names to avoid potential naming conflicts

The plugin uses the following class names:

  1. active
  2. hover
  3. jeegoocontext
  4. submenu
  5. separator

All class names are overridable to avoid potential naming conflicts.

Opera compatible

Opera doesn't allow right-click event overrides. When the plugin detects Opera it automatically binds the menu to the doubleclick event. The event-type can be overriden via the operaEvent property on the options object.

Cross-browser support

The plugin was tested in the following browsers: Opera 10, Safari 4, Chrome 3, Firefox 3, Internet Explorer 6, 7 & 8. Although compatible with all these browsers, it is not recommended to use the styled skin in IE 6 due to some (possible) weird caching bug. For some reasen IE 6 decides to re-download all images used in the menu on every mouseover.

Keyboard support

The escape key closes the menu. The enter key selects a menu-item. The arrow keys can be used to move between different menu-items and submenus. Both the up and down arrow keys can be hold down to loop through the menu-items.

Lightweight

The minified version of the script is just under 6 kb in size.

Unobtrusive

No changes to the page html are required except for appending the context menu to the body.

Suggestions? We would like to hear about your experiences with the JeeGoo context menu.

E-mail is not required


Vul code in

30-8-2010 1:33Sean
Hi, it is possible to dynamically populate the menu/submenu items? In my application the submenu items will be retrieved via an AJAX request.
16-8-2010 9:57Erik
@Henrik, i can probably integrate this behavior into the next release. @Malith, the context menu can be disabled permanently for a certain context by calling: $(context).nojeegoocontext(); The best way to temporarily disable the context menu is to (conditionally) return false in the onShow callback like this: $(context).jeegoocontex(myMenu, {onShow: function(e, context){ if(myDialogVisible)return false;}}
10-8-2010 4:19Malith
Hi Erik, this is actually great. i'm using it with my application. in my case i need to disable the context menu when i show a hidden dialog on screen. how can i disable and re-enable the context menu? please help me.
4-8-2010 15:18Henrik
I really dig this menu but I need to position the popup differently than the standard behavior. I want to trigger the popup from a button (with left click) and open the pop up below the button. It would be nice to give an element as a position reference for the popup and also be able to add optional horizontal and vertical offsets from the element position. Do you think you can implement that in a future release?
24-7-2010 20:17rolaca11
I managed, to solve the problem, I forgot to upload the new files :)
24-7-2010 19:49rolaca11
actually, before writing this post, i have tried with exactly the same, and didn't work. I tried it now too, with the same result. :(
24-7-2010 17:45Erik
@rolaca11, icons are purely controlled by css. You can add a custom icon to the menu by prepending a span to the desired menu-item like this: <li class="icon"> <span class="icon MYCUSTOMCLASS"></span> (MENU-ITEM TEXT) </li> Next, copy your icon to the images/icons folder of the skin folder of your choice, for example "jeegoocontext/skins/cm_default/images/icons". Finally, add the following css-rule to your skin's stylesheet("jeegoocontext/skins/cm_default/style.css"): body ul.cm_default span.MYCUSTOMCLASS{background-image:url(images/icons/MYCUSTOMICON.gif)}
24-7-2010 17:42Erik
@Yafeng, MIT Or GPL
24-7-2010 14:56rolaca11
I want to ask you about how can (if it's possible) I give new icons to the context menu? Please e-mail me!
13-7-2010 13:07Yafeng
I'm not sure about dual license mode. Is it licensed under MIT OR GPL,or MIT AND GPL?
Disclaimer | Voorwaarden | Copyright 2005-2006 © PlanIt Works