Keyboard initialization for a given html node.
- Source:
- Copyright:
- 2021 Moodle
- 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) 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:
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. |