tool_lp/menubar

Aria menubar functionality. Enhances a simple nested list structure into a full aria widget. Based on the open ajax example: http://oaa-accessibility.org/example/26/

Source:
License:
  • http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Methods

(inner) addAriaAttributes()

Source:

Enhance the dom with aria attributes.

(inner) addEventListeners()

Source:

Bind the event listeners to the DOM

(inner) closeAll()

Source:

Handy function to close all open menus anywhere on the page.

(inner) closeAllSubMenus()

Source:

Close all open submenus anywhere in the page (there should only ever be one open at a time).

(inner) enhance(selector, handler)

Source:

Create a menu bar object for every node matching the selector.

The expected DOM structure is shown below.

    <- This is the target of the selector parameter.
  • <- This is repeated for each top level menu. Text <- This is the text for the top level menu.
      <- This is a list of the entries in this top level menu.
    • <- This is repeated for each menu entry. Choice 1 <- The anchor for the menu.
Parameters:
Name Type Description
selector String

The selector for the outer most menu node.

handler function

Javascript handler for when a menu item was chosen. If the handler returns true (or does not exist), the menu will look for an anchor with a link to follow. For example, if the menu entry has a "data-action" attribute and we want to call a javascript function when that entry is chosen, we could pass a list of handlers like this: { "[data-action='add']" : callAddFunction }

(inner) handleClick(item, e) → {boolean}

Source:

Process click events for the top menus.

Parameters:
Name Type Description
item Object

is the jquery object of the item firing the event

e Event

is the associated event object

Returns:

Returns false

Type
boolean

(inner) moveDown(item, startChr) → {Object}

Source:

Member function to select the next item in a menu. If the active item is the last in the menu, this function will loop to the first menu item.

Parameters:
Name Type Description
item Object

is the active menu item

startChr String

is the character to attempt to match against the beginning of the menu item titles. If found, focus moves to the next menu item beginning with that character.

Returns:

Returns the item to move to. Returns item is no move is possible

Type
Object

(inner) moveToNext(item) → {Object}

Source:

Move to the next menu level. This will be either the next root-level menu or the child of a menu parent. If at the root level and the active item is the last in the menu, this function will loop to the first menu item.

If the menu is a horizontal menu, the first child element of the newly selected menu will be selected

Parameters:
Name Type Description
item Object

is the active menu item

Returns:

Returns the item to move to. Returns item is no move is possible

Type
Object

(inner) moveToPrevious(item) → {Object}

Source:

Member function to move to the previous menu level. This will be either the previous root-level menu or the child of a menu parent. If at the root level and the active item is the first in the menu, this function will loop to the last menu item.

If the menu is a horizontal menu, the first child element of the newly selected menu will be selected

Parameters:
Name Type Description
item Object

is the active menu item

Returns:

Returns the item to move to. Returns item is no move is possible

Type
Object

(inner) moveUp(item) → {Object}

Source:

Function moveUp() is a member function to select the previous item in a menu. If the active item is the first in the menu, this function will loop to the last menu item.

Parameters:
Name Type Description
item Object

is the active menu item

Returns:

Returns the item to move to. Returns item is no move is possible

Type
Object

(inner) openSubMenu(menu)

Source:

Open a submenu, first it closes all other sub-menus and sets the open direction.

Parameters:
Name Type Description
menu Node