- Description:
Keyboard initialization for a given html node.
- Source:
- Copyright:
- 2021 Moodle
- License:
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Keyboard initialization for a given html node.
Methods
(inner) clickErrorHandler(item, fallback) → {HTMLElement}
- Description:
Small helper function to check if a given node is null or not.
- Source:
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)
- Description:
Defined click event handling so we can remove listeners on nodes on resize etc.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
e |
event | The triggering element and key presses etc. |
(inner) dropDownMenuActiveCheck()
- Description:
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.
- Source:
(inner) findUsableLastNode(elementRoot) → {HTMLElement}
- Description:
We need to look within the menu to find a last node we can add focus to.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
elementRoot |
HTMLElement | Menu to find a final child node within. |
Returns:
- Type
- HTMLElement
(inner) keyboardListenerEvents(e)
- Description:
Defined keyboard event handling so we can remove listeners on nodes on resize etc.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
e |
event | The triggering element and key presses etc. |
(inner) menuItemHelper(src)
- Description:
- Source:
Parameters:
Name | Type | Description |
---|---|---|
src |
HTMLElement | The node within the dropdown the user selected. |
(inner) setFocusHomeEnd(node)
- Description:
Focus on either the start or end of a nav list.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
node |
HTMLElement | The element to focus on. |
(inner) setFocusNext(currentNode, firstNode)
- Description:
Handle the focusing to the next element in the dropdown.
- Source:
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)
- Description:
Handle the focusing to the previous element in the dropdown.
- Source:
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. |