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

16-3-2010 0:29Tom
Well of course as soon as I posted that, I found the information about licensing in the code itself. Thanks again!
16-3-2010 0:26Tom
This is an amazing plugin - was so simple to get it up and running... great work! I couldn't find any information about licensing?
12-3-2010 19:33Erik
You can view an example via "Examples, onShow callback alternative".
12-3-2010 17:41Erik
Hi Catalin, If i understand you correctly, you want to view different menu-options depending on the clicked context. To achieve this you can either use multiple contextmenus, one for each context. Or you can use the onShow callback to show/hide menu items on the fly, depending on the context, for example like this: onShow: function(e, context){ // Show or hide menu-items based on context id. switch($(context).attr('id')) { case 'context1': $('#[MENU_ID] li.context2, #[MENU_ID] li.context3').hide(); $('#[MENU_ID] li.context1').show(); break; case 'context2': $('#[MENU_ID] li.context1, #[MENU_ID] li.context3').hide(); $('#[MENU_ID] li.context2').show(); break; case 'context3': $('#[MENU_ID] li.context1, #[MENU_ID] li.context2').hide(); $('#[MENU_ID] li.context3').show(); break; } } For this to work, you need to append just one contextmenu to the body consisting of all possible menu-options. I hope this helps.
11-3-2010 1:32Catalin David
Hello! I've been trying out the context menu for a few days now and I am decided to use it in an academic project I am working on. Still, I have one question / request regarding dynamically generated menu entries: is this possible (and if yes, how?)? For example, I would create just an empty ul (with proper class attributes) element at the end of the body that I would fill later on, depending on where the user clicks with options available for that context. I've tried to add li elements from JavaScript, they appear on the menu, but the events do not get triggered (which rather defeats the purpose of a context menu). I would really appreciate if you could implement/fix this and, if not, at least give me some hints on how to implement it (though, I am rather novice with JS and jQuery). Thanks for this tool, Catalin
25-1-2010 22:48roger
Hey Erik, You are right about the obvious solution is to use the element's id. Thanks!
17-1-2010 13:28Erik
Keyboard support will probably be integrated into the next release
17-1-2010 13:20Erik
Roger, why would you want to use another selector instead of an id? The menu selector should only return a single menu because multiple contexts can be mapped to a single menu, but a single context cannot be mapped to multiple menus. Hence the obvious solution would be to select a menu by id.
12-1-2010 22:52roger
And FYI, me too would like to have the Escape key close the menu just like normal Windows UI (it is not working for me on FF3.5/IE8/Chrome 4 - also does not works in the examples).
12-1-2010 22:39roger
Thanks a lot by this great plugin! I would like to have the ability to use a CSS selector instead of just restrict the usage of the menu's id. Thanks again.
Disclaimer | Voorwaarden | Copyright 2005-2006 © PlanIt Works