Constructor
new MenuBar(config)
Construct a menu bar. The opener and closer elements are added first followed by the children.
The structure generated by the code is effectively
- div: className hcje-menu-bar-container
- config.opener element
- div className hcje-menu-bar
- config.closer
- config.children
Listeners are automatically added to the opener and closer to set the class of the menu bar container to 'open' when open. It is expected that the the display of these elements will be controlled by CSS.
There is no need to add the menu bar as this is done automatically in the constructor. It is either added to the
config.parentElement or the document.body.
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object |
Properties
|
- Source:
Members
onClose :function
Function called when menu closed.
Type:
- function
- Source:
onOpen :function
Function called when menu opened.
Type:
- function
- Source:
Methods
close()
Close the menu bar.
- Source:
disable()
Disable the menu. The container has the disabled class set and all clicks are ignored.
- Source:
enable()
Enabled the menu. The container has the disabled class removed and all clicks are activated.
- Source:
remove()
Remove the menu.
- Source:
setEnabledState(enabled)
Set the enabled state of the menu. If the state is false, all buttons are disabled and the menu is closed.
Parameters:
| Name | Type | Description |
|---|---|---|
enabled |
boolean | Required state. |
- Source: