Jeegoocontext documentation

Version 1.3

A context menu can be initialized in two ways:

  1. $('selector').jeegoocontext('menu id');
  2. $('selector').jeegoocontext('menu id', 'options');
'selector' contains the context to be bound to the menu and can be any jQuery selector.
'menu id' contains the id of the context menu (without the "#").
'options' is an object which can be configured with both properties and callbacks

Any context can be unbound from it's menu by calling $ ('context').nojeegoocontext();

Options properties

NameTypeDefault valueScopeFunction
livequeryBooleanundefinedMenuIf set to true, both context and menu items are bound via livequery, enabling dynamically added content and menu items to be automatically bound to the menu without reinitializing the menu.
hoverClassString'hover'MenuThis class is set to hovered menu-items and their direct children.
activeClassString'active'GlobalThis class is set to the current active context (the area that was right-clicked to open the context menu). Because this variable is global (applies to all context on a page) it only needs to be set once when using multiple context menus. If set more than once, the last supplied value counts.
menuClassString'jeegoocontext'GlobalThis class must be included by all context menus on a page and is used to show one menu at a time when using multiple menus. Because this variable is global (applies to all context menus on a page) it only needs to be set once when using multiple context menus. If set more than once, the last supplied value counts.
autoAddSubmenuArrowsBooleantrueMenuIf set to true, arrows are automatically added to menu items containing submenus. These arrows take the form of span elements prepended to the menu items.
submenuClassString'submenu'MenuIf options.autoAddSubmenuArrows is true, this class is set to the span elements forming the submenu arrows.
separatorClassString'separator'MenuMenu items with this class are skipped during the loop through the menu items when holding down the up or down arrow key.
fadeInNumber200MenuThe time it takes in milliseconds for the menu and any submenus to fade-in.
delayNumber300MenuThe time it takes in milliseconds for unhovered menu item’s submenus to hide. This enables users to select submenu items by moving over other items or the document without immediately closing the submenu.
keyDelayNumber100MenuThe time between two menu item hovers when holding down the up or down arrow key. Determines the loop speed.
widthOverflowOffsetNumber0MenuThis value can be used to influence width-overflow behavior. When set to 20 for example the context menu and any submenus will always position themselves at least 20 pixels from the right-margin of the window.
heightOverflowOffsetNumber0MenuThis value can be used to influence height-overflow behavior. When set to 20 for example the context menu and any submenus will always position themselves at least 20 pixels from the bottom-margin of the window.
submenuLeftOffsetNumber0MenuThis value can be used to horizontally offset submenus relatively to their parent menus. If set to -3 for example, each submenu overlaps it’s parent by 3 pixels.
submenuTopOffsetNumber0MenuThis value can be used to vertically offset submenus relatively to their parent menus. If set to -3 for example, each submenu is placed 3 pixels above it’s parent. However, on height-overflow conditions this value is ignored.
operaEventString'ctrl+click'MenuThe event used by older versions of Opera to open the menu.
eventStringundefinedMenuWhen set, this event (instead of the right-click event) is used to open the menu. This event also overrides the operaEvent property. Can be set to 'shift+click' or 'click' for example, to open the menu on a shift-click or left-click event.
openBelowContextBooleanundefinedMenuWhen set to true, instead of opening at the clicked position the contextmenu opens at the lowerleft corner of the context. The first level of the menu automatically maintains its vertical position regardless of height overflow and window resizes. This feature can be used to create a contextmenu opened by a button, or to create multilevel dropdown menus.
ignoreWidthOverflowBooleanundefinedMenuWhen set to true, width overflow is ignored which causes the menu to expand across the right boundary of the window.
ignoreHeightOverflowBooleanundefinedMenuWhen set to true, height overflow is ignored which causes the menu to expand across the bottom boundary of the window.
startLeftOffsetNumber0MenuThis value is added to the left position where the menu is about to show/fade-in.
startTopOffsetNumber0MenuThis value is added to the top position where the menu is about to show/fade-in.
keyboardBooleantrueMenuWhen set to false, the menu doesn't respond to keyboard events.
autoHideBooleanundefinedMenuWhen set to true, the whole menu hides after the mouse pointer exits the menu. The delay property controls the time between exiting the menu and hiding the menu.

Options callbacks

The options object can be configured with the following four callbacks:

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

Each of these callbacks receives two parameters: e and context, where e refers to the original event object and context refers to the area on which the menu was invoked. From within these callbacks the menu’s default behavior can be cancelled by returning false. The onShow callback receives two additional parameters: startLeft and startTop. These parameters contain the location where the menu is about to show/fade-in.

Name"this" refers toInvoked onDefault behavior
onShowmenuRight-click on bound context.
  1. Hide all menus on page.
  2. Remove active class from all context on a page.
  3. Add active class to the clicked context.
  4. Fade-in menu.
onHovermenu itemMouseover on menu item.Position and fade-in submenus.
onSelectmenu itemClick on menu item.
  1. Remove active class from the current active context.
  2. Hide menu.
onHidemenuClick on document.
  1. Remove active class from all context on a page.
  2. Hide menu.

<< JeeGoo Context