Simple tabs and accordion interface.
npm install kist-tabifySimple tabs and accordion interface.
``sh
npm install kist-tabify --save
bower install kist-tabify --save
`
Returns: jQuery
Element is container for tabs and corresponding panes. If panes can’t be found inside element, plugin will search for them outside container, beginning with body element.
#### options
Type: Object|String
##### Options defined as Object
###### type
Type: String tab
Default:
Type of tabbing interface. It can be either tab or accordion.
###### initial
See placement.
###### multiSelect
Type: Boolean false
Default:
If it’s accordion interface, determines if multi tab selection is allowed.
###### tab
Type: String > ul > li > a, > ul > li > button
Default:
Selector used to collect all tab toggler elements.
###### pane
Type: String > div > div
Default:
Selector used to collect all tab pane elements.
###### changeURL
Type: Boolean false
Default:
If tab toggler elements are anchor elements, determines if URL should be update with href value.
###### select
Type: Function tabifyselect
Arguments: [Tab], [Pane]
Event:
Callback to run on tab selection.
###### deselect
Type: Function tabifydeselect
Arguments: [Tab], [Pane]
Event:
Callback to run on tab deselection.
###### create
Type: Function tabifycreate
Arguments: [Tab], [Pane]
Event:
Callback to run on tab instance creation.
##### Options defined as String
Type: String
###### destroy
Destroy plugin instance.
###### next
Move to next tab element.
###### prev
Move to previous tab element.
###### move
Move to tab element determined by second argument. Second argument accepts values like options → initial.
#### placement
Type: Integer|String|Function|Boolean 1
Default:
Initial element to select.
If defined as:
| Type | Description |
| --- | --- |
| Integer | Index of tab element to activate. |String
| | Value of id attribute, data-tab-id attribute or href attribute value of tab element to activate. |Function
| | Should return either index or string which correspond to integer and string values for this property. |Boolean
| | If true, it will active first tab element, else it won’t activate anything. |
Default structure for tab interface.
`html`
Setup tab instance.
`js`
$('.Tab').tabify({
type: 'tab',
initial: 1,
tab: '.Tab-toggler',
pane: '.Tab-pane',
namespace: 'Foobar',
select: function ( tab, pane ) {
// I’m selected!
},
deselect: function ( tab, pane ) {
// I’m deselected!
},
create: function ( tab, pane ) {
// I’m created!
}
});
Move to next/previous tab.
`js`
$('.Tab').tabify('prev');
$('.Tab').tabify('next');
Move to arbitrary tab.
`js`
$('.Tab').tabify('move', 1);
$('.Tab').tabify('move', 'foo');
Destroy plugin instance.
`js``
$('.Tab').tabify('destroy');
Tested in IE8+ and all modern browsers.
MIT © Ivan Nikolić