HTZ A11Y TABS
JavaScript scaffolding for accessible tab interfaces
(require("htz-a11y-tabs"))(container, rtl, tablistSelectoropt, tabpanelSelectoropt, activeTabopt) → {module:htz-a11y-tabs#API}
Initialize a tab interface.
Depends on semantic markup, in which the tablist is a ul
element, and each
tab contains an clickable tag pointing to its respective tabpanel.
Parameters
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
container |
HTMLElement | The wrapper element around the tabs and tab panels |
||
rtl |
Boolean | Determine if the tab interface should be right-to-left |
||
tablistSelector |
String |
<optional> |
'ul' | The tablist's selector. |
tabpanelSelector |
String |
<optional> |
'section' | The tabpanels' selector. |
activeTab |
Integer |
<optional> |
0 | The tab number to have initially activated. Zero based. |
Fires:
- module:htz-a11y-tabs~a11y-tabs:init - Fired from `container` after a tab interface has been initializedevent:
- module:htz-a11y-tabs~a11y-tabs:destroy - Fired from `container` after a tab interface has been destroyedevent:
- module:htz-a11y-tabs~a11y-tabs:before-select - Fired from `container` before a tab selection is applied. If the event handler executes `event.preventDefault()`, the selection will not be applied.event:
- module:htz-a11y-tabs~a11y-tabs:after-select - Fired from `container` after a tab selection is applied.event:
Returns
Type Definitions
API
Instance API
Properties:
Name | Type | Description |
---|---|---|
isInitialized |
Method | Returns true if the instance is initialized |
visibleTab |
Method | Returns the number of the active tab. Zero based. |
init |
module:htz-a11y-tabs#init | Initialize an instance. |
destroy |
module:htz-a11y-tabs#destroy | Destroy an instance. |
goto |
module:htz-a11y-tabs#goto | Go to a specific tab |
next |
module:htz-a11y-tabs#next | Go to the next tab |
previous |
module:htz-a11y-tabs#prev | Go to the next tab |
destroy(removeAttrsopt)
Destroy an instance. Removes event listeners and, optionally, accessibility attributes from the DOM.
goto(index, focusopt)
Go to a tab
init(activateopt)
Initialize an instance
next(focusopt)
Go to the next tab
prev(focusopt)
Go to the previous tab
Events
a11y-tabs:after-select
Fired from container
after a tab selection is applied.
Type:
- Object
Properties:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
detail |
Object |
Properties
|
a11y-tabs:before-select
Fired from container
before a tab selection is applied. If the event
handler executes event.preventDefault()
, the selection will not be applied.
Type:
- Object
Properties:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
detail |
Object |
Properties
|
a11y-tabs:destroy
Fired from container
after a tab interface has been destroyed.
a11y-tabs:init
Fired from container
when a tab interface is initialized