Constructor
new (require("theme_boost/drawers"))()
- Source:
Examples
// The module just needs to be included to add drawer support.
import 'theme_boost/drawers';
import Drawers from 'theme_boost/drawers';
const myDrawer = Drawers.getDrawerInstanceForNode(document.querySelector('.myDrawerNode');
myDrawer.closeDrawer();
import Drawers from 'theme_boost/drawers';
document.addEventListener(Drawers.eventTypes.drawerShow, e => {
// The drawer which will be shown.
window.console.log(e.target);
// The instance of the Drawers class for this drawer.
window.console.log(e.detail.drawerInstance);
// Prevent this drawer from being shown.
e.preventDefault();
});
document.addEventListener(Drawers.eventTypes.drawerShown, e => {
// The drawer which was shown.
window.console.log(e.target);
// The instance of the Drawers class for this drawer.
window.console.log(e.detail.drawerInstance);
});
Members
closeOnResize
- Source:
Whether the drawer should close when the window is resized
drawerNode
- Source:
The underlying HTMLElement which is controlled.
eventTypes
- Source:
Properties:
Name | Type | Description |
---|---|---|
drawerShow |
String | |
drawerShown |
String | |
drawerHide |
String | |
drawerHidden |
String |
The list of event types.
isOpen
- Source:
Whether the drawer is open.
Methods
(static) closeAllDrawers()
- Source:
Close all drawers.
(static) closeOtherDrawers(comparisonInstance)
- Source:
Close all drawers except for the specified drawer.
Parameters:
Name | Type | Description |
---|---|---|
comparisonInstance |
module:theme_boost/drawers |
(static) getDrawerInstanceForNode(drawerNode) → {module:theme_boost/drawers}
- Source:
Get the drawer instance for the specified node
Parameters:
Name | Type | Description |
---|---|---|
drawerNode |
HTMLElement |
Returns:
closeDrawer(args)
- Source:
Close the drawer.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
object |
Properties
|
openDrawer(args)
- Source:
Open the drawer.
By default, openDrawer sets the page focus to the close drawer button. However, when a drawer is open at page load, this represents an accessibility problem as the initial focus changes without any user interaction. The focusOnCloseButton parameter can be set to false to prevent this behaviour.
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
object |
Properties
|
toggleVisibility()
- Source:
Toggle visibility of the drawer.
(inner) focusLastUsedToggle(target)
- Source:
Set the focus to the last used button to open this drawer.
Parameters:
Name | Type | Description |
---|---|---|
target |
string | The drawer target. |
(inner) setLastUsedToggle(toggleButton)
- Source:
Set the last used attribute for the last used toggle button for a drawer.
Parameters:
Name | Type | Description |
---|---|---|
toggleButton |
object | The clicked button. |
Events
theme_boost/drawers:hidden
- Source:
Properties:
Name | Type | Description |
---|---|---|
target |
HTMLElement | The drawer that was be hidden. |
An event triggered after a drawer is hidden.
Type:
- CustomEvent
theme_boost/drawers:hide
- Source:
Properties:
Name | Type | Description |
---|---|---|
target |
HTMLElement | The drawer that will be hidden. |
An event triggered before a drawer is hidden.
Type:
- CustomEvent
theme_boost/drawers:show
- Source:
Properties:
Name | Type | Description |
---|---|---|
target |
HTMLElement | The drawer that will be opened. |
An event triggered before a drawer is shown.
Type:
- CustomEvent
theme_boost/drawers:shown
- Source:
Properties:
Name | Type | Description |
---|---|---|
target |
HTMLElement | The drawer that was be opened. |
An event triggered after a drawer is shown.
Type:
- CustomEvent