Global

Members

(constant) KEYS

List of keys used for moving elements with the keyboard.
Source:

(constant) NEST_THRESHOLD

Constant indicating how much a menuItem element should be moved to the right in order to consider it nested to it's parent.
Source:

Methods

getChildren(menuItem) → {Array.<HTMLElement>}

Returns the menu item element's children.
Parameters:
Name Type Description
menuItem HTMLElement The menu item to return children for.
Source:
Returns:
Type
Array.<HTMLElement>

getFromContentElement(menuItemContent) → {HTMLElement|null}

Returns the parent menu item element of the menu item content.
Parameters:
Name Type Description
menuItemContent HTMLElement The menu item content to return the parent menu item for.
Source:
Returns:
Type
HTMLElement | null

getFromId(menuItemId) → {HTMLElement|null}

Returns the menu item element with the given ID.
Parameters:
Name Type Description
menuItemId number | string The menu item's ID.
Source:
Returns:
Type
HTMLElement | null

getId(menuItem) → {number}

Returns the given menu item element's ID.
Parameters:
Name Type Description
menuItem HTMLElement The menu item
Source:
Returns:
Type
number

getNearestMenuItem(originMenuItem, placeholder) → {HTMLElement}

Gets the nearest menuItem element for the given originMenuItem and placeholder. The placeholder is used for retrieving the reference position, and the originMenuItem for checking that child elements are being avoided.
Parameters:
Name Type Description
originMenuItem HTMLElement
placeholder HTMLElement
Source:
Returns:
Type
HTMLElement

getNextSibling(menuItem) → {HTMLElement|null}

Returns the next menu item sibling of the given menu item element.
Parameters:
Name Type Description
menuItem HTMLElement The menu item.
Source:
Returns:
Type
HTMLElement | null

getParent(menuItem) → {HTMLElement|null}

Returns the menu item element's parent.
Parameters:
Name Type Description
menuItem HTMLElement The menu item.
Source:
Returns:
Type
HTMLElement | null

getSiblings(menuItem) → {Array.<HTMLElement>}

Returns the menu item element's siblings.
Parameters:
Name Type Description
menuItem HTMLElement The menu item.
Source:
Returns:
Type
Array.<HTMLElement>

insertAtPosition(parentMenuItem, menuItem, position)

Inserts the given menuItem as child of given parentMenuItem at the given position.
Parameters:
Name Type Description
parentMenuItem HTMLElement
menuItem HTMLElement
position number
Source:

insertAtTop(menuItem)

Insert the given menuItem at the top of the navigation tree
Parameters:
Name Type Description
menuItem HTMLElement
Source:

isChildOf(menuItem, parentMenuItem) → {boolean}

Returns true if the menu item is a child of the parent menu item.
Parameters:
Name Type Description
menuItem HTMLElement The menu item to check.
parentMenuItem HTMLElement The parent menu item.
Source:
Returns:
Whether the menu item is a child of the parent menu item.
Type
boolean

isMenuItem(htmlElement) → {boolean}

Returns true if the given HTML element is a menu item.
Parameters:
Name Type Description
htmlElement HTMLElement The HTML element to check.
Source:
Returns:
Whether the HTML element is a menu item.
Type
boolean

isOver(menuItemA, menuItemB) → {boolean}

Returns true if the first menuItem element is over the second menuItem element.
Parameters:
Name Type Description
menuItemA HTMLElement
menuItemB HTMLElement
Source:
Returns:
Type
boolean

isSelected(menuItem) → {boolean}

Returns true if the given menu item element is selected.
Parameters:
Name Type Description
menuItem HTMLElement The menu item to check.
Source:
Returns:
Whether the menu item is selected.
Type
boolean

setDragging(menuItem)

Mutates the given menu item element by changing it's status to dragging or not dragging.
Parameters:
Name Type Description
menuItem HTMLElement The menu item.
Source:

setSelected(menuItemnon-null)

Mutates the given menu item by changing it's status to selected. Only a single menu item can be selected, so any other selected menu item will be unselected.
Parameters:
Name Type Description
menuItem HTMLElement The menu item.
Source:

shouldBeNested(menuItem, parentMenuItem) → {boolean}

Returns true if the given menuItem element should be nested inside the given parentMenuItem element by checking their positions.
Parameters:
Name Type Description
menuItem HTMLElement
parentMenuItem HTMLElement
Source:
Returns:
Type
boolean

unselectAll()

Mutates all selected menu items and sets their status to unselected.
Source: