js/components/carousel.js
function(element, options) {
        var items, self = this;

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

        // Set animation and ARIA
        element
            .aria('live', options.autoCycle ? 'assertive' : 'off')
            .addClass(options.animation);

        // Find the item container and disable transitions for initial load
        this.container = element.find(this.ns('items'))
            .addClass('no-transition');

        // Find all the items and set ARIA attributes
        this.items = items = this.container.find('> li').each(function(index) {
            $(this)
                .attr({
                    role: 'tabpanel',
                    id: self.id('item', index)
                })
                .data('carousel-index', index)
                .aria('hidden', (index > 0));
        });

        // Find all tabs and set ARIA attributes
        this.tabs = element.find(this.ns('tabs'))
            .attr('role', 'tablist')
            .find('a').each(function(index) {
                $(this)
                    .data('carousel-index', index)
                    .attr({
                        role: 'tab',
                        id: self.id('tab', index)
                    })
                    .aria({
                        controls: self.id('item', index),
                        selected: false,
                        expanded: false
                    });
            });

        // Set events
        this.addEvents([
            ['resize', 'window', $.throttle(this.calculate.bind(this), 50)],
            ['keydown', 'window', 'onKeydown'],
            ['click', 'element', 'onJump', this.ns('tabs') + ' a'],
            ['click', 'element', 'next', this.ns('next')],
            ['click', 'element', 'prev', this.ns('prev')],
            ['click', 'element', 'start', this.ns('start')],
            ['click', 'element', 'stop', this.ns('stop')]
        ]);

        if (options.swipe) {
            this.addEvents([
                ['swipeleft', 'element', 'next'],
                ['swipeup', 'element', 'next'],
                ['swiperight', 'element', 'prev'],
                ['swipedown', 'element', 'prev']
            ]);
        }

        if (options.stopOnHover) {
            this.addEvents([
                ['mouseenter', 'element', 'stop'],
                ['mouseleave', 'element', 'start']
            ]);
        }

        // Initialize
        this.initialize();

        // Prepare the carousel
        this._setupState();
        this._buildClones();

        // Start the carousel
        this.calculate();
        this.start();
        this.jump(options.defaultIndex);
    }
function(element, options) {
        var items, self = this;

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

        // Set animation and ARIA
        element
            .aria('live', options.autoCycle ? 'assertive' : 'off')
            .addClass(options.animation);

        // Find the item container and disable transitions for initial load
        this.container = element.find(this.ns('items'))
            .addClass('no-transition');

        // Find all the items and set ARIA attributes
        this.items = items = this.container.find('> li').each(function(index) {
            $(this)
                .attr({
                    role: 'tabpanel',
                    id: self.id('item', index)
                })
                .data('carousel-index', index)
                .aria('hidden', (index > 0));
        });

        // Find all tabs and set ARIA attributes
        this.tabs = element.find(this.ns('tabs'))
            .attr('role', 'tablist')
            .find('a').each(function(index) {
                $(this)
                    .data('carousel-index', index)
                    .attr({
                        role: 'tab',
                        id: self.id('tab', index)
                    })
                    .aria({
                        controls: self.id('item', index),
                        selected: false,
                        expanded: false
                    });
            });

        // Set events
        this.addEvents([
            ['resize', 'window', $.throttle(this.calculate.bind(this), 50)],
            ['keydown', 'window', 'onKeydown'],
            ['click', 'element', 'onJump', this.ns('tabs') + ' a'],
            ['click', 'element', 'next', this.ns('next')],
            ['click', 'element', 'prev', this.ns('prev')],
            ['click', 'element', 'start', this.ns('start')],
            ['click', 'element', 'stop', this.ns('stop')]
        ]);

        if (options.swipe) {
            this.addEvents([
                ['swipeleft', 'element', 'next'],
                ['swipeup', 'element', 'next'],
                ['swiperight', 'element', 'prev'],
                ['swipedown', 'element', 'prev']
            ]);
        }

        if (options.stopOnHover) {
            this.addEvents([
                ['mouseenter', 'element', 'stop'],
                ['mouseleave', 'element', 'start']
            ]);
        }

        // Initialize
        this.initialize();

        // Prepare the carousel
        this._setupState();
        this._buildClones();

        // Start the carousel
        this.calculate();
        this.start();
        this.jump(options.defaultIndex);
    }
function ( element , options ) { var items , self = this ; element = this . setElement ( element ) ; options = this . setOptions ( options , element ) ; // Set animation and ARIA element . aria ( 'live' , options . autoCycle ? 'assertive' : 'off' ) . addClass ( options . animation ) ; // Find the item container and disable transitions for initial load this . container = element . find ( this . ns ( 'items' ) ) . addClass ( 'no-transition' ) ; // Find all the items and set ARIA attributes this . items = items = this . container . find ( '> li' ) . each ( function ( index ) { $ ( this ) . attr ( { role : 'tabpanel' , id : self . id ( 'item' , index ) } ) . data ( 'carousel-index' , index ) . aria ( 'hidden' , ( index > 0 ) ) ; } ) ; // Find all tabs and set ARIA attributes this . tabs = element . find ( this . ns ( 'tabs' ) ) . attr ( 'role' , 'tablist' ) . find ( 'a' ) . each ( function ( index ) { $ ( this ) . data ( 'carousel-index' , index ) . attr ( { role : 'tab' , id : self . id ( 'tab' , index ) } ) . aria ( { controls : self . id ( 'item' , index ) , selected : false , expanded : false } ) ; } ) ; // Set events this . addEvents ( [ [ 'resize' , 'window' , $ . throttle ( this . calculate . bind ( this ) , 50 ) ] , [ 'keydown' , 'window' , 'onKeydown' ] , [ 'click' , 'element' , 'onJump' , this . ns ( 'tabs' ) + ' a' ] , [ 'click' , 'element' , 'next' , this . ns ( 'next' ) ] , [ 'click' , 'element' , 'prev' , this . ns ( 'prev' ) ] , [ 'click' , 'element' , 'start' , this . ns ( 'start' ) ] , [ 'click' , 'element' , 'stop' , this . ns ( 'stop' ) ] ] ) ; if ( options . swipe ) { this . addEvents ( [ [ 'swipeleft' , 'element' , 'next' ] , [ 'swipeup' , 'element' , 'next' ] , [ 'swiperight' , 'element' , 'prev' ] , [ 'swipedown' , 'element' , 'prev' ] ] ) ; } if ( options . stopOnHover ) { this . addEvents ( [ [ 'mouseenter' , 'element' , 'stop' ] , [ 'mouseleave' , 'element' , 'start' ] ] ) ; } // Initialize this . initialize ( ) ; // Prepare the carousel this . _setupState ( ) ; this . _buildClones ( ) ; // Start the carousel this . calculate ( ) ; this . start ( ) ; this . jump ( options . defaultIndex ) ; }
Initialize the carousel.

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