dist/toolkit.js
function(element, options) {
        var sections, tabs, self = this;

        element = this.setElement(element);
        options = this.setOptions(options, element);

        // Determine cookie name
        if (!options.cookie) {
            options.cookie = element.attr('id');
        }

        // Find all the sections and set ARIA attributes
        this.sections = sections = element.find(this.ns('section')).each(function(index, section) {
            section = $(section);
            section
                .attr('role', 'tabpanel')
                .attr('id', section.attr('id') || self.id('section', index))
                .aria('labelledby', self.id('tab', index))
                .conceal();
        });

        // Find the nav and set ARIA attributes
        this.nav = element.find(this.ns('nav'))
            .attr('role', 'tablist');

        // Find the tabs within the nav and set ARIA attributes
        this.tabs = tabs = this.nav.find('a').each(function(index) {
            $(this)
                .data('tab-index', index)
                .attr({
                    role: 'tab',
                    id: self.id('tab', index)
                })
                .aria({
                    controls: sections.eq(index).attr('id'),
                    selected: false,
                    expanded: false
                })
                .removeClass('is-active');
        });

        // Initialize events
        this.addEvent('{mode}', 'element', 'onShow', this.ns('nav') + ' a');

        if (options.mode !== 'click' && options.preventDefault) {
            this.addEvent('click', 'element', function(e) {
                e.preventDefault();
            }, this.ns('nav') + ' a');
        }

        this.initialize();

        // Trigger default tab to display
        var index = null;

        if (options.persistState) {
            if (options.cookie && $.cookie) {
                index = $.cookie('toolkit.tab.' + options.cookie);
            }

            if (index === null && options.loadFragment && location.hash) {
                index = tabs.filter(function() {
                    return ($(this).attr('href') === location.hash);
                }).eq(0).data('tab-index');
            }
        }

        if (!tabs[index]) {
            index = options.defaultIndex;
        }

        this.jump(index);
    }
function(element, options) {
        var sections, tabs, self = this;

        element = this.setElement(element);
        options = this.setOptions(options, element);

        // Determine cookie name
        if (!options.cookie) {
            options.cookie = element.attr('id');
        }

        // Find all the sections and set ARIA attributes
        this.sections = sections = element.find(this.ns('section')).each(function(index, section) {
            section = $(section);
            section
                .attr('role', 'tabpanel')
                .attr('id', section.attr('id') || self.id('section', index))
                .aria('labelledby', self.id('tab', index))
                .conceal();
        });

        // Find the nav and set ARIA attributes
        this.nav = element.find(this.ns('nav'))
            .attr('role', 'tablist');

        // Find the tabs within the nav and set ARIA attributes
        this.tabs = tabs = this.nav.find('a').each(function(index) {
            $(this)
                .data('tab-index', index)
                .attr({
                    role: 'tab',
                    id: self.id('tab', index)
                })
                .aria({
                    controls: sections.eq(index).attr('id'),
                    selected: false,
                    expanded: false
                })
                .removeClass('is-active');
        });

        // Initialize events
        this.addEvent('{mode}', 'element', 'onShow', this.ns('nav') + ' a');

        if (options.mode !== 'click' && options.preventDefault) {
            this.addEvent('click', 'element', function(e) {
                e.preventDefault();
            }, this.ns('nav') + ' a');
        }

        this.initialize();

        // Trigger default tab to display
        var index = null;

        if (options.persistState) {
            if (options.cookie && $.cookie) {
                index = $.cookie('toolkit.tab.' + options.cookie);
            }

            if (index === null && options.loadFragment && location.hash) {
                index = tabs.filter(function() {
                    return ($(this).attr('href') === location.hash);
                }).eq(0).data('tab-index');
            }
        }

        if (!tabs[index]) {
            index = options.defaultIndex;
        }

        this.jump(index);
    }
function ( element , options ) { var sections , tabs , self = this ; element = this . setElement ( element ) ; options = this . setOptions ( options , element ) ; // Determine cookie name if ( ! options . cookie ) { options . cookie = element . attr ( 'id' ) ; } // Find all the sections and set ARIA attributes this . sections = sections = element . find ( this . ns ( 'section' ) ) . each ( function ( index , section ) { section = $ ( section ) ; section . attr ( 'role' , 'tabpanel' ) . attr ( 'id' , section . attr ( 'id' ) || self . id ( 'section' , index ) ) . aria ( 'labelledby' , self . id ( 'tab' , index ) ) . conceal ( ) ; } ) ; // Find the nav and set ARIA attributes this . nav = element . find ( this . ns ( 'nav' ) ) . attr ( 'role' , 'tablist' ) ; // Find the tabs within the nav and set ARIA attributes this . tabs = tabs = this . nav . find ( 'a' ) . each ( function ( index ) { $ ( this ) . data ( 'tab-index' , index ) . attr ( { role : 'tab' , id : self . id ( 'tab' , index ) } ) . aria ( { controls : sections . eq ( index ) . attr ( 'id' ) , selected : false , expanded : false } ) . removeClass ( 'is-active' ) ; } ) ; // Initialize events this . addEvent ( '{mode}' , 'element' , 'onShow' , this . ns ( 'nav' ) + ' a' ) ; if ( options . mode !== 'click' && options . preventDefault ) { this . addEvent ( 'click' , 'element' , function ( e ) { e . preventDefault ( ) ; } , this . ns ( 'nav' ) + ' a' ) ; } this . initialize ( ) ; // Trigger default tab to display var index = null ; if ( options . persistState ) { if ( options . cookie && $ . cookie ) { index = $ . cookie ( 'toolkit.tab.' + options . cookie ) ; } if ( index === null && options . loadFragment && location . hash ) { index = tabs . filter ( function ( ) { return ( $ ( this ) . attr ( 'href' ) === location . hash ) ; } ) . eq ( 0 ) . data ( 'tab-index' ) ; } } if ( ! tabs [ index ] ) { index = options . defaultIndex ; } this . jump ( index ) ; }
Initialize the tab.

@param {jQuery} element
@param {Object} [options]
Initialize the tab .