core/menu_navigation

Keyboard initialization for a given html node.

Source:
Author:
  • Mathew May <mathew.solutions>
License:
  • http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

(require("core/menu_navigation"))(elementRoot)

Source:

The initial entry point that a given module can pass a HTMLElement.

Parameters:
Name Type Description
elementRoot HTMLElement

The menu to add handlers upon.

Methods

(inner) clickErrorHandler(item, fallback) → {HTMLElement}

Source:

Small helper function to check if a given node is null or not.

Parameters:
Name Type Description
item HTMLElement | null

The node that we want to compare.

fallback HTMLElement

Either the first node or final node that can be focused on.

Returns:
Type
HTMLElement

(inner) clickListenerEvents(e)

Source:

Defined click event handling so we can remove listeners on nodes on resize etc.

Parameters:
Name Type Description
e event

The triggering element and key presses etc.

(inner) dropDownMenuActiveCheck()

Source:

Check if there are sub items in a dropdown menu. There can be one element active only. That is usually controlled by the server. However, when you click, the newly clicked item gets the active state as well. This is no problem because the user leaves the page and a new page load happens. When the user hits the back button, the old page dom is restored from the cache, with both menu items active. If there is such a case, we need to uncheck the item that was clicked when leaving this page. Make sure that this function is applied in the main menu only. The gradebook may contain drop down menus as well were more than one item can be flagged as active.

(inner) findUsableLastNode(elementRoot) → {HTMLElement}

Source:

We need to look within the menu to find a last node we can add focus to.

Parameters:
Name Type Description
elementRoot HTMLElement

Menu to find a final child node within.

Returns:
Type
HTMLElement

(inner) keyboardListenerEvents(e)

Source:

Defined keyboard event handling so we can remove listeners on nodes on resize etc.

Parameters:
Name Type Description
e event

The triggering element and key presses etc.

(inner) menuItemHelper(src)

Source:

Control classes etc of the selected dropdown item and its' parent

Parameters:
Name Type Description
src HTMLElement

The node within the dropdown the user selected.

(inner) setFocusHomeEnd(node)

Source:

Focus on either the start or end of a nav list.

Parameters:
Name Type Description
node HTMLElement

The element to focus on.

(inner) setFocusNext(currentNode, firstNode)

Source:

Handle the focusing to the next element in the dropdown.

Parameters:
Name Type Description
currentNode HTMLElement | null

The node that we want to take action on.

firstNode HTMLElement

The backup node to focus as a last resort.

(inner) setFocusPrev(currentNode, lastNode)

Source:

Handle the focusing to the previous element in the dropdown.

Parameters:
Name Type Description
currentNode HTMLElement | null

The node that we want to take action on.

lastNode HTMLElement

The backup node to focus as a last resort.