a jQuery port of our popular TabInterface script
Version: 1.5
Configuration
When instantiating a TabInterface, you have the option of passing in a configuration object to tailor your tabbed interface. This is a list of the options with default values in parentheses:
active_class('enabled') - Theclassused to toggle styles on (activates the interface)tabpanel_el('section') - The container for each content blocktabpanel_class('TabInterface-tabpanel') - Theclassto apply to each tab paneltabpanel_hidden_class('TabInterface-abpanel-hidden') - Theclassto give a tab panel when it is hiddentablist_el('ol') - The element type used for wrapping the tab listtablist_class('TabInterface-tablist') -classto apply to the tab listtablist_position('before') - Source order placement (before or after) for the tab listtab_el('li') - The element type used for each tabtab_class('TabInterface-tab') -classto apply to each tabtab_active_class('TabInterface-active') - Theclassto use for the active tabtab_thumbnail_class('TabInterface-tab-thumbnail') - Theclassto apply to thumbnail previews in tabshide_headers(true) - Hide the headers?heading_hidden_class('TabInterface-heading-hidden') - Theclassto apply to hidden headings
Example:
$('.tabbed-interface').TabInterface({
tablist_position: 'after',
hide_headers: false
});
Callbacks
Calbacks allow you to manipulate the TabInterface at various points in the build process. You can assign handlers for these callback in your configuration object. Note: this in all callbacks refers to the TabInterface container jQuery object
oninit- called when the TabInterface spins uponcomplete- called after the TabInterface is builtonbeforechange- called before a new tab panel is focusedonafterchange- called after a new tab panel is focused
Example:
$('.tabbed-interface').TabInterface({
oninit: function(){ alert('hi'); },
oncomplete: function(){ alert('bye'); }
});
Markup-based Controls (via HTML data-* attributes)
data-tab-hide-headers(boolean) - Attribute on container to control whether headings should be hidden when tabs are createddata-tab-title(string) - Attribute on headings used to provide alternate titlesdata-tab-thumbnail(URI) - Attribute on headings used to provide a thumbnail imagedata-tab-focus(void) - Attribute on headings used to auto-focus a tab other than the first one
Example:
<div class="tabbed-interface" data-tab-hide-headers="false">
<h2 data-tab-title="Short Title">A really long long long long title</h2>
…
<h2 data-tab-focus>This content will be focused on load</h2>
…
</div>
Hash Watching
This script watches for hashchange events and will focus a tab heading within it is targeted.