' ) )
.prop( 'outerHTML' ) ];
}
this._controls.$absolute = ( settings.dotsContainer ? $( settings.dotsContainer )
: $( '' ).addClass( settings.dotsClass ).appendTo( this.$element ) ).addClass( 'disabled' );
this._controls.$absolute.on( 'click', 'div', $.proxy( function ( e )
{
var index = $( e.target ).parent().is( this._controls.$absolute )
? $( e.target ).index() : $( e.target ).parent().index();
e.preventDefault();
this.to( index, settings.dotsSpeed );
}, this ) );
// override public methods of the carousel
for ( override in this._overrides ) {
this._core[ override ] = $.proxy( this[ override ], this );
}
};
/**
* Destroys the plugin.
* @protected
*/
Navigation.prototype.destroy = function ()
{
var handler, control, property, override;
for ( handler in this._handlers ) {
this.$element.off( handler, this._handlers[ handler ] );
}
for ( control in this._controls ) {
this._controls[ control ].remove();
}
for ( override in this.overides ) {
this._core[ override ] = this._overrides[ override ];
}
for ( property in Object.getOwnPropertyNames( this ) ) {
typeof this[ property ] != 'function' && ( this[ property ] = null );
}
};
/**
* Updates the internal state.
* @protected
*/
Navigation.prototype.update = function ()
{
var i, j, k,
lower = this._core.clones().length / 2,
upper = lower + this._core.items().length,
maximum = this._core.maximum( true ),
settings = this._core.settings,
size = settings.center || settings.autoWidth || settings.dotsData
? 1 : settings.dotsEach || settings.items;
if ( settings.slideBy !== 'page' ) {
settings.slideBy = Math.min( settings.slideBy, settings.items );
}
if ( settings.dots || settings.slideBy == 'page' ) {
this._pages = [];
for ( i = lower, j = 0, k = 0; i < upper; i++ ) {
if ( j >= size || j === 0 ) {
this._pages.push( {
start: Math.min( maximum, i - lower ),
end: i - lower + size - 1
} );
if ( Math.min( maximum, i - lower ) === maximum ) {
break;
}
j = 0, ++k;
}
j += this._core.mergers( this._core.relative( i ) );
}
}
};
/**
* Draws the user interface.
* @todo The option `dotsData` wont work.
* @protected
*/
Navigation.prototype.draw = function ()
{
var difference,
settings = this._core.settings,
disabled = this._core.items().length <= settings.items,
index = this._core.relative( this._core.current() ),
loop = settings.loop || settings.rewind;
this._controls.$relative.toggleClass( 'disabled', !settings.nav || disabled );
if ( settings.nav ) {
this._controls.$previous.toggleClass( 'disabled', !loop && index <= this._core.minimum( true ) );
this._controls.$next.toggleClass( 'disabled', !loop && index >= this._core.maximum( true ) );
}
this._controls.$absolute.toggleClass( 'disabled', !settings.dots || disabled );
if ( settings.dots ) {
difference = this._pages.length - this._controls.$absolute.children().length;
if ( settings.dotsData && difference !== 0 ) {
this._controls.$absolute.html( this._templates.join( '' ) );
} else if ( difference > 0 ) {
this._controls.$absolute.append( new Array( difference + 1 ).join( this._templates[ 0 ] ) );
} else if ( difference < 0 ) {
this._controls.$absolute.children().slice( difference ).remove();
}
this._controls.$absolute.find( '.active' ).removeClass( 'active' );
this._controls.$absolute.children().eq( $.inArray( this.current(), this._pages ) ).addClass( 'active' );
}
};
/**
* Extends event data.
* @protected
* @param {Event} event - The event object which gets thrown.
*/
Navigation.prototype.onTrigger = function ( event )
{
var settings = this._core.settings;
event.page = {
index: $.inArray( this.current(), this._pages ),
count: this._pages.length,
size: settings && ( settings.center || settings.autoWidth || settings.dotsData
? 1 : settings.dotsEach || settings.items )
};
};
/**
* Gets the current page position of the carousel.
* @protected
* @returns {Number}
*/
Navigation.prototype.current = function ()
{
var current = this._core.relative( this._core.current() );
return $.grep( this._pages, $.proxy( function ( page, index )
{
return page.start <= current && page.end >= current;
}, this ) ).pop();
};
/**
* Gets the current succesor/predecessor position.
* @protected
* @returns {Number}
*/
Navigation.prototype.getPosition = function ( successor )
{
var position, length,
settings = this._core.settings;
if ( settings.slideBy == 'page' ) {
position = $.inArray( this.current(), this._pages );
length = this._pages.length;
successor ? ++position : --position;
position = this._pages[ ( ( position % length ) + length ) % length ].start;
} else {
position = this._core.relative( this._core.current() );
length = this._core.items().length;
successor ? position += settings.slideBy : position -= settings.slideBy;
}
return position;
};
/**
* Slides to the next item or page.
* @public
* @param {Number} [speed=false] - The time in milliseconds for the transition.
*/
Navigation.prototype.next = function ( speed )
{
$.proxy( this._overrides.to, this._core )( this.getPosition( true ), speed );
};
/**
* Slides to the previous item or page.
* @public
* @param {Number} [speed=false] - The time in milliseconds for the transition.
*/
Navigation.prototype.prev = function ( speed )
{
$.proxy( this._overrides.to, this._core )( this.getPosition( false ), speed );
};
/**
* Slides to the specified item or page.
* @public
* @param {Number} position - The position of the item or page.
* @param {Number} [speed] - The time in milliseconds for the transition.
* @param {Boolean} [standard=false] - Whether to use the standard behaviour or not.
*/
Navigation.prototype.to = function ( position, speed, standard )
{
var length;
if ( !standard && this._pages.length ) {
length = this._pages.length;
$.proxy( this._overrides.to, this._core )( this._pages[ ( ( position % length ) + length ) % length ].start, speed );
} else {
$.proxy( this._overrides.to, this._core )( position, speed );
}
};
$.fn.owlCarousel.Constructor.Plugins.Navigation = Navigation;
} )( window.Zepto || window.jQuery, window, document );
/**
* Hash Plugin
* @version 2.1.0
* @author Artus Kolanowski
* @author David Deutsch
* @license The MIT License (MIT)
*/
; ( function ( $, window, document, undefined )
{
'use strict';
/**
* Creates the hash plugin.
* @class The Hash Plugin
* @param {Owl} carousel - The Owl Carousel
*/
var Hash = function ( carousel )
{
/**
* Reference to the core.
* @protected
* @type {Owl}
*/
this._core = carousel;
/**
* Hash index for the items.
* @protected
* @type {Object}
*/
this._hashes = {};
/**
* The carousel element.
* @type {jQuery}
*/
this.$element = this._core.$element;
/**
* All event handlers.
* @protected
* @type {Object}
*/
this._handlers = {
'initialized.owl.carousel': $.proxy( function ( e )
{
if ( e.namespace && this._core.settings.startPosition === 'URLHash' ) {
$( window ).trigger( 'hashchange.owl.navigation' );
}
}, this ),
'prepared.owl.carousel': $.proxy( function ( e )
{
if ( e.namespace ) {
var hash = $( e.content ).find( '[data-hash]' ).addBack( '[data-hash]' ).attr( 'data-hash' );
if ( !hash ) {
return;
}
this._hashes[ hash ] = e.content;
}
}, this ),
'changed.owl.carousel': $.proxy( function ( e )
{
if ( e.namespace && e.property.name === 'position' ) {
var current = this._core.items( this._core.relative( this._core.current() ) ),
hash = $.map( this._hashes, function ( item, hash )
{
return item === current ? hash : null;
} ).join();
if ( !hash || window.location.hash.slice( 1 ) === hash ) {
return;
}
window.location.hash = hash;
}
}, this )
};
// set default options
this._core.options = $.extend( {}, Hash.Defaults, this._core.options );
// register the event handlers
this.$element.on( this._handlers );
// register event listener for hash navigation
$( window ).on( 'hashchange.owl.navigation', $.proxy( function ( e )
{
var hash = window.location.hash.substring( 1 ),
items = this._core.$stage.children(),
position = this._hashes[ hash ] && items.index( this._hashes[ hash ] );
if ( position === undefined || position === this._core.current() ) {
return;
}
this._core.to( this._core.relative( position ), false, true );
}, this ) );
};
/**
* Default options.
* @public
*/
Hash.Defaults = {
URLhashListener: false
};
/**
* Destroys the plugin.
* @public
*/
Hash.prototype.destroy = function ()
{
var handler, property;
$( window ).off( 'hashchange.owl.navigation' );
for ( handler in this._handlers ) {
this._core.$element.off( handler, this._handlers[ handler ] );
}
for ( property in Object.getOwnPropertyNames( this ) ) {
typeof this[ property ] != 'function' && ( this[ property ] = null );
}
};
$.fn.owlCarousel.Constructor.Plugins.Hash = Hash;
} )( window.Zepto || window.jQuery, window, document );
/**
* Support Plugin
*
* @version 2.1.0
* @author Vivid Planet Software GmbH
* @author Artus Kolanowski
* @author David Deutsch
* @license The MIT License (MIT)
*/
; ( function ( $, window, document, undefined )
{
var style = $( '' ).get( 0 ).style,
prefixes = 'Webkit Moz O ms'.split( ' ' ),
events = {
transition: {
end: {
WebkitTransition: 'webkitTransitionEnd',
MozTransition: 'transitionend',
OTransition: 'oTransitionEnd',
transition: 'transitionend'
}
},
animation: {
end: {
WebkitAnimation: 'webkitAnimationEnd',
MozAnimation: 'animationend',
OAnimation: 'oAnimationEnd',
animation: 'animationend'
}
}
},
tests = {
csstransforms: function ()
{
return !!test( 'transform' );
},
csstransforms3d: function ()
{
return !!test( 'perspective' );
},
csstransitions: function ()
{
return !!test( 'transition' );
},
cssanimations: function ()
{
return !!test( 'animation' );
}
};
function test ( property, prefixed )
{
var result = false,
upper = property.charAt( 0 ).toUpperCase() + property.slice( 1 );
$.each( ( property + ' ' + prefixes.join( upper + ' ' ) + upper ).split( ' ' ), function ( i, property )
{
if ( style[ property ] !== undefined ) {
result = prefixed ? property : true;
return false;
}
} );
return result;
}
function prefixed ( property )
{
return test( property, true );
}
if ( tests.csstransitions() ) {
/* jshint -W053 */
$.support.transition = new String( prefixed( 'transition' ) )
$.support.transition.end = events.transition.end[ $.support.transition ];
}
if ( tests.cssanimations() ) {
/* jshint -W053 */
$.support.animation = new String( prefixed( 'animation' ) )
$.support.animation.end = events.animation.end[ $.support.animation ];
}
if ( tests.csstransforms() ) {
/* jshint -W053 */
$.support.transform = new String( prefixed( 'transform' ) );
$.support.transform3d = tests.csstransforms3d();
}
} )( window.Zepto || window.jQuery, window, document );