Untitled diff

Created Diff never expires
12 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
677 lines
10 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
675 lines
/**
/**
* jquery.slitslider.js v1.1.0
* jquery.slitslider.js v1.1.0
* http://www.codrops.com
* http://www.codrops.com
*
*
* Licensed under the MIT license.
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* http://www.opensource.org/licenses/mit-license.php
*
*
* Copyright 2012, Codrops
* Copyright 2012, Codrops
* http://www.codrops.com
* http://www.codrops.com
*/
*/
;( function( $, window, undefined ) {
;( function( $, window, undefined ) {
'use strict';
'use strict';
/*
/*
* debouncedresize: special jQuery event that happens once after a window resize
* debouncedresize: special jQuery event that happens once after a window resize
*
*
* latest version and complete README available on Github:
* latest version and complete README available on Github:
* https://github.com/louisremi/jquery-smartresize/blob/master/jquery.debouncedresize.js
* https://github.com/louisremi/jquery-smartresize/blob/master/jquery.debouncedresize.js
*
*
* Copyright 2011 @louis_remi
* Copyright 2011 @louis_remi
* Licensed under the MIT license.
* Licensed under the MIT license.
*/
*/
var $event = $.event,
var $event = $.event,
$special,
$special,
resizeTimeout;
resizeTimeout;
$special = $event.special.debouncedresize = {
$special = $event.special.debouncedresize = {
setup: function() {
setup: function() {
$( this ).on( "resize", $special.handler );
$( this ).on( "resize", $special.handler );
},
},
teardown: function() {
teardown: function() {
$( this ).off( "resize", $special.handler );
$( this ).off( "resize", $special.handler );
},
},
handler: function( event, execAsap ) {
handler: function( event, execAsap ) {
// Save the context
// Save the context
var context = this,
var context = this,
args = arguments,
args = arguments,
dispatch = function() {
dispatch = function() {
// set correct event type
// set correct event type
event.type = "debouncedresize";
event.type = "debouncedresize";
$event.dispatch.apply( context, args );
$event.dispatch.apply( context, args );
};
};
if ( resizeTimeout ) {
if ( resizeTimeout ) {
clearTimeout( resizeTimeout );
clearTimeout( resizeTimeout );
}
}
execAsap ?
execAsap ?
dispatch() :
dispatch() :
resizeTimeout = setTimeout( dispatch, $special.threshold );
resizeTimeout = setTimeout( dispatch, $special.threshold );
},
},
threshold: 20
threshold: 20
};
};
// global
// global
var $window = $( window ),
var $window = $( window ),
$document = $( document ),
$document = $( document ),
Modernizr = window.Modernizr;
Modernizr = window.Modernizr;
$.Slitslider = function( options, element ) {
$.Slitslider = function( options, element ) {
this.$elWrapper = $( element );
this.$elWrapper = $( element );
this._init( options );
this._init( options );
};
};
$.Slitslider.defaults = {
$.Slitslider.defaults = {
// transitions speed
// transitions speed
speed : 1800,
speed : 1800,
// if true the item's slices will also animate the opacity value
// if true the item's slices will also animate the opacity value
optOpacity : false,
optOpacity : false,
// amount (%) to translate both slices - adjust as necessary
// amount (%) to translate both slices - adjust as necessary
translateFactor : 230,
translateFactor : 230,
// maximum possible angle
// maximum possible angle
maxAngle : 25,
maxAngle : 25,
// maximum possible scale
// maximum possible scale
maxScale : 2,
maxScale : 2,
// slideshow on / off
// slideshow on / off
autoplay : true,
autoplay : true,
// keyboard navigation
// keyboard navigation
keyboard : false,
keyboard : false,
// time between transitions keyboard
// time between transitions keyboard
interval : 5000,
interval : 5000,
// callbacks
// callbacks
onBeforeChange : function( slide, idx ) { return false; },
onBeforeChange : function( slide, idx ) { return false; },
onAfterChange : function( slide, idx ) { return false; }
onAfterChange : function( slide, idx ) { return false; }
};
};
$.Slitslider.prototype = {
$.Slitslider.prototype = {
_init : function( options ) {
_init : function( options ) {
// options
// options
this.options = $.extend( true, {}, $.Slitslider.defaults, options );
this.options = $.extend( true, {}, $.Slitslider.defaults, options );
// https://github.com/twitter/bootstrap/issues/2870
// https://github.com/twitter/bootstrap/issues/2870
this.transEndEventNames = {
this.transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd',
'WebkitTransition' : 'webkitTransitionEnd',
'MozTransition' : 'transitionend',
'MozTransition' : 'transitionend',
'OTransition' : 'oTransitionEnd',
'OTransition' : 'oTransitionEnd',
'msTransition' : 'MSTransitionEnd',
'msTransition' : 'MSTransitionEnd',
'transition' : 'transitionend'
'transition' : 'transitionend'
};
};
this.transEndEventName = this.transEndEventNames[ Modernizr.prefixed( 'transition' ) ];
this.transEndEventName = this.transEndEventNames[ Modernizr.prefixed( 'transition' ) ];
// suport for css 3d transforms and css transitions
// suport for css 3d transforms and css transitions
this.support = Modernizr.csstransitions && Modernizr.csstransforms3d;
this.support = Modernizr.csstransitions && Modernizr.csstransforms3d;
// the slider
// the slider
this.$el = this.$elWrapper.children( '.sl-slider' );
this.$el = this.$elWrapper.children( '.sl-slider' );
// the slides
// the slides
this.$slides = this.$el.children( '.sl-slide' ).hide();
this.$slides = this.$el.children( '.sl-slide' ).hide();
// total slides
// total slides
this.slidesCount = this.$slides.length;
this.slidesCount = this.$slides.length;
// current slide
// current slide
this.current = 0;
this.current = 0;
// control if it's animating
// control if it's animating
this.isAnimating = false;
this.isAnimating = false;
// get container size
// get container size
this._getSize();
this._getSize();
// layout
// layout
this._layout();
this._layout();
// load some events
// load some events
this._loadEvents();
this._loadEvents();
// slideshow
// slideshow
if( this.options.autoplay ) {
if( this.options.autoplay ) {
this._startSlideshow();
this._startSlideshow();
}
}
},
},
// gets the current container width & height
// gets the current container width & height
_getSize : function() {
_getSize : function() {
this.size = {
this.size = {
width : this.$elWrapper.outerWidth( true ),
width : this.$elWrapper.outerWidth( true ),
height : this.$elWrapper.outerHeight( true )
height : this.$elWrapper.outerHeight( true )
};
};
},
},
_layout : function() {
_layout : function() {
this.$slideWrapper = $( '<div class="sl-slides-wrapper" />' );
this.$slideWrapper = $( '<div class="sl-slides-wrapper" />' );
// wrap the slides
// wrap the slides
this.$slides.wrapAll( this.$slideWrapper ).each( function( i ) {
this.$slides.wrapAll( this.$slideWrapper ).each( function( i ) {
var $slide = $( this ),
var $slide = $( this ),
// vertical || horizontal
// vertical || horizontal
orientation = $slide.data( 'orientation' );
orientation = $slide.data( 'orientation' );
$slide.addClass( 'sl-slide-' + orientation )
$slide.addClass( 'sl-slide-' + orientation )
.children()
.children()
.wrapAll( '<div class="sl-content-wrapper" />' )
.wrapAll( '<div class="sl-content-wrapper" />' )
.wrapAll( '<div class="sl-content" />' );
.wrapAll( '<div class="sl-content" />' );
} );
} );
// set the right size of the slider/slides for the current window size
// set the right size of the slider/slides for the current window size
this._setSize();
this._setSize();
// show first slide
// show first slide
this.$slides.eq( this.current ).show();
this.$slides.eq( this.current ).show();
},
},
_navigate : function( dir, pos ) {
_navigate : function( dir, pos ) {
if( this.isAnimating || this.slidesCount < 2 ) {
if( this.isAnimating || this.slidesCount < 2 ) {
return false;
return false;
}
}
this.isAnimating = true;
this.isAnimating = true;
var self = this,
var self = this,
$currentSlide = this.$slides.eq( this.current );
$currentSlide = this.$slides.eq( this.current );
// if position is passed
// if position is passed
if( pos !== undefined ) {
if( pos !== undefined ) {
this.current = pos;
this.current = pos;
}
}
// if not check the boundaries
// if not check the boundaries
else if( dir === 'next' ) {
else if( dir === 'next' ) {
this.current = this.current < this.slidesCount - 1 ? ++this.current : 0;
this.current = this.current < this.slidesCount - 1 ? ++this.current : 0;
}
}
else if( dir === 'prev' ) {
else if( dir === 'prev' ) {
this.current = this.current < 0 ? --this.current : this.slidesCount - 1;
this.current = this.current < this.slidesCount - 1 ? ++this.current : 0;
}
}
this.options.onBeforeChange( $currentSlide, this.current );
this.options.onBeforeChange( $currentSlide, this.current );
// next slide to be shown
// next slide to be shown
var $nextSlide = this.$slides.eq( this.current ),
var $nextSlide = this.$slides.eq( this.current ),
// the slide we want to cut and animate
// the slide we want to cut and animate
$movingSlide = ( dir === 'next' ) ? $currentSlide : $nextSlide,
$movingSlide = ( dir === 'next' ) ? $currentSlide : $nextSlide,
// the following are the data attrs set for each slide
// the following are the data attrs set for each slide
configData = $movingSlide.data(),
configData = $movingSlide.data(),
config = {};
config = {};
config.orientation = configData.orientation || 'horizontal',
config.orientation = configData.orientation || 'horizontal',
config.slice1angle = configData.slice1Rotation || 0,
config.slice1angle = configData.slice1Rotation || 0,
config.slice1scale = configData.slice1Scale || 1,
config.slice1scale = configData.slice1Scale || 1,
config.slice2angle = configData.slice2Rotation || 0,
config.slice2angle = configData.slice2Rotation || 0,
config.slice2scale = configData.slice2Scale || 1;
config.slice2scale = configData.slice2Scale || 1;
this._validateValues( config );
this._validateValues( config );
var cssStyle = config.orientation === 'horizontal' ? {
var cssStyle = config.orientation === 'horizontal' ? {
marginTop : -this.size.height / 2
marginTop : -this.size.height / 2
} : {
} : {
marginLeft : -this.size.width / 2
marginLeft : -this.size.width / 2
},
},
// default slide's slices style
// default slide's slices style
resetStyle = {
resetStyle = {
'transform' : 'translate(0%,0%) rotate(0deg) scale(1)',
'transform' : 'translate(0%,0%) rotate(0deg) scale(1)',
opacity : 1
opacity : 1
},
},
// slice1 style
// slice1 style
slice1Style = config.orientation === 'horizontal' ? {
slice1Style = config.orientation === 'horizontal' ? {
'transform' : 'translateY(-' + this.options.translateFactor + '%) rotate(' + config.slice1angle + 'deg) scale(' + config.slice1scale + ')'
'transform' : 'translateY(-' + this.options.translateFactor + '%) rotate(' + config.slice1angle + 'deg) scale(' + config.slice1scale + ')'
} : {
} : {
'transform' : 'translateX(-' + this.options.translateFactor + '%) rotate(' + config.slice1angle + 'deg) scale(' + config.slice1scale + ')'
'transform' : 'translateX(-' + this.options.translateFactor + '%) rotate(' + config.slice1angle + 'deg) scale(' + config.slice1scale + ')'
},
},
// slice2 style
// slice2 style
slice2Style = config.orientation === 'horizontal' ? {
slice2Style = config.orientation === 'horizontal' ? {
'transform' : 'translateY(' + this.options.translateFactor + '%) rotate(' + config.slice2angle + 'deg) scale(' + config.slice2scale + ')'
'transform' : 'translateY(' + this.options.translateFactor + '%) rotate(' + config.slice2angle + 'deg) scale(' + config.slice2scale + ')'
} : {
} : {
'transform' : 'translateX(' + this.options.translateFactor + '%) rotate(' + config.slice2angle + 'deg) scale(' + config.slice2scale + ')'
'transform' : 'translateX(' + this.options.translateFactor + '%) rotate(' + config.slice2angle + 'deg) scale(' + config.slice2scale + ')'
};
};
if( this.options.optOpacity ) {
if( this.options.optOpacity ) {
slice1Style.opacity = 0;
slice1Style.opacity = 0;
slice2Style.opacity = 0;
slice2Style.opacity = 0;
}
}
// we are adding the classes sl-trans-elems and sl-trans-back-elems to the slide that is either coming "next"
// we are adding the classes sl-trans-elems and sl-trans-back-elems to the slide that is either coming "next"
// or going "prev" according to the direction.
// or going "prev" according to the direction.
// the idea is to make it more interesting by giving some animations to the respective slide's elements
// the idea is to make it more interesting by giving some animations to the respective slide's elements
//( dir === 'next' ) ? $nextSlide.addClass( 'sl-trans-elems' ) : $currentSlide.addClass( 'sl-trans-back-elems' );
// ( dir === 'next' ) ? $nextSlide.addClass( 'sl-trans-elems' ) : $currentSlide.addClass( 'sl-trans-back-elems' );
$currentSlide.removeClass( 'sl-trans-elems' );
$currentSlide.removeClass( 'sl-trans-elems' );
var transitionProp = {
var transitionProp = {
'transition' : 'all ' + this.options.speed + 'ms ease-in-out'
'transition' : 'all ' + this.options.speed + 'ms ease-in-out'
};
};
// add the 2 slices and animate them
// add the 2 slices and animate them
$movingSlide.css( 'z-index', this.slidesCount )
$movingSlide.css( 'z-index', this.slidesCount )
.find( 'div.sl-content-wrapper' )
.find( 'div.sl-content-wrapper' )
.wrap( $( '<div class="sl-content-slice" />' ).css( transitionProp ) )
.wrap( $( '<div class="sl-content-slice" />' ).css( transitionProp ) )
.parent()
.parent()
.cond(
.cond(
dir === 'prev',
dir === 'prev',
function() {
function() {
var slice = this;
var slice = this;
this.css( slice1Style );
this.css( resetStyle );
setTimeout( function() {
setTimeout( function() {
slice.css( resetStyle );
slice.css( slice1Style );
}, 50 );
}, 50 );
},
},
function() {
function() {
var slice = this;
var slice = this;
setTimeout( function() {
setTimeout( function() {
slice.css( slice1Style );
slice.css( slice1Style );
}, 50 );
}, 50 );
}
}
)
)
.clone()
.clone()
.appendTo( $movingSlide )
.appendTo( $movingSlide )
.cond(
.cond(
dir === 'prev',
dir === 'prev',
function() {
function() {
var slice = this;
var slice = this;
this.css( slice2Style );
setTimeout( function() {
setTimeout( function() {
$currentSlide.addClass( 'sl-trans-back-elems' );
$currentSlide.addClass( 'sl-trans-elems' );
if( self.support ) {
if( self.support ) {
slice.css( resetStyle ).on( self.transEndEventName, function() {
slice.css( slice2Style ).on( self.transEndEventName, function() {
self._onEndNavigate( slice, $currentSlide, dir );
self._onEndNavigate( slice, $currentSlide, dir );
} );
} );
}
}
else {
else {
self._onEndNavigate( slice, $currentSlide, dir );
self._onEndNavigate( slice, $currentSlide, dir );
}
}
}, 50 );
}, 50 );
},
},
function() {
function() {
var slice = this;
var slice = this;
setTimeout( function() {
setTimeout( function() {
$nextSlide.addClass( 'sl-trans-elems' );
$nextSlide.addClass( 'sl-trans-elems' );
if( self.support ) {
if( self.support ) {
slice.css( slice2Style ).on( self.transEndEventName, function() {
slice.css( slice2Style ).on( self.transEndEventName, function() {
self._onEndNavigate( slice, $currentSlide, dir );
self._onEndNavigate( slice, $currentSlide, dir );
} );
} );
}
}
else {
else {
self._onEndNavigate( slice, $currentSlide, dir );
self._onEndNavigate( slice, $currentSlide, dir );
}
}
}, 50 );
}, 50 );
}
}
)
)
.find( 'div.sl-content-wrapper' )
.find( 'div.sl-content-wrapper' )
.css( cssStyle );
.css( cssStyle );
$nextSlide.show();
$nextSlide.show();
},
},
_validateValues : function( config ) {
_validateValues : function( config ) {
// OK, so we are restricting the angles and scale values here.
// OK, so we are restricting the angles and scale values here.
// This is to avoid the slices wrong sides to be shown.
// This is to avoid the slices wrong sides to be shown.
// you can adjust these values as you wish but make sure you also ajust the
// you can adjust these values as you wish but make sure you also ajust the
// paddings of the slides and also the options.translateFactor value and scale data attrs
// paddings of the slides and also the options.translateFactor value and scale data attrs
if( config.slice1angle > this.options.maxAngle || config.slice1angle < -this.options.maxAngle ) {
if( config.slice1angle > this.options.maxAngle || config.slice1angle < -this.options.maxAngle ) {
config.slice1angle = this.options.maxAngle;
config.slice1angle = this.options.maxAngle;
}
}
if( config.slice2angle > this.options.maxAngle || config.slice2angle < -this.options.maxAngle ) {
if( config.slice2angle > this.options.maxAngle || config.slice2angle < -this.options.maxAngle ) {
config.slice2angle = this.options.maxAngle;
config.slice2angle = this.options.maxAngle;
}
}
if( config.slice1scale > this.options.maxScale || config.slice1scale <= 0 ) {
if( config.slice1scale > this.options.maxScale || config.slice1scale <= 0 ) {
config.slice1scale = this.options.maxScale;
config.slice1scale = this.options.maxScale;
}
}
if( config.slice2scale > this.options.maxScale || config.slice2scale <= 0 ) {
if( config.slice2scale > this.options.maxScale || config.slice2scale <= 0 ) {
config.slice2scale = this.options.maxScale;
config.slice2scale = this.options.maxScale;
}
}
if( config.orientation !== 'vertical' && config.orientation !== 'horizontal' ) {
if( config.orientation !== 'vertical' && config.orientation !== 'horizontal' ) {
config.orientation = 'horizontal'
config.orientation = 'horizontal'
}
}
},
},
_onEndNavigate : function( $slice, $oldSlide, dir ) {
_onEndNavigate : function( $slice, $oldSlide, dir ) {
// reset previous slide's style after next slide is shown
// reset previous slide's style after next slide is shown
var $slide = $slice.parent(),
var $slide = $slice.parent(),
removeClasses = 'sl-trans-elems sl-trans-back-elems';
removeClasses = 'sl-trans-elems sl-trans-back-elems';
// remove second slide's slice
// remove second slide's slice
$slice.remove();
$slice.remove();
// unwrap..
// unwrap..
$slide.css( 'z-index', 1 )
$slide.css( 'z-index', 1 )
.find( 'div.sl-content-wrapper' )
.find( 'div.sl-content-wrapper' )
.unwrap();
.unwrap();
// hide previous current slide
// hide previous current slide
$oldSlide.hide().removeClass( removeClasses );
$oldSlide.hide().removeClass( removeClasses );
$slide.removeClass( removeClasses );
$slide.removeClass( removeClasses );
// now we can navigate again..
// now we can navigate again..
this.isAnimating = false;
this.isAnimating = false;
this.options.onAfterChange( $slide, this.current );
this.options.onAfterChange( $slide, this.current );
},
},
_setSize : function() {
_setSize : function() {
// the slider and content wrappers will have the window's width and height
// the slider and content wrappers will have the window's width and height
var cssStyle = {
var cssStyle = {
width : this.size.width,
width : this.size.width,
height : this.size.height
height : this.size.height
};
};
this.$el.css( cssStyle ).find( 'div.sl-content-wrapper' ).css( cssStyle );
this.$el.css( cssStyle ).find( 'div.sl-content-wrapper' ).css( cssStyle );
},
},
_loadEvents : function() {
_loadEvents : function() {
var self = this;
var self = this;
$window.on( 'debouncedresize.slitslider', function( event ) {
$window.on( 'debouncedresize.slitslider', function( event ) {
// update size values
// update size values
self._getSize();
self._getSize();
// set the sizes again
// set the sizes again
self._setSize();
self._setSize();
} );
} );
if ( this.options.keyboard ) {
if ( this.options.keyboard ) {
$document.on( 'keydown.slitslider', function(e) {
$document.on( 'keydown.slitslider', function(e) {
var keyCode = e.keyCode || e.which,
var keyCode = e.keyCode || e.which,
arrow = {
arrow = {
left: 37,
left: 37,
up: 38,
up: 38,
right: 39,
right: 39,
down: 40
down: 40
};
};
switch (keyCode) {
switch (keyCode) {
case arrow.left :
case arrow.left :
self._stopSlideshow();
self._stopSlideshow();
self._navigate( 'prev' );
self._navigate( 'prev' );
break;
break;
case arrow.right :
case arrow.right :
self._stopSlideshow();
self._stopSlideshow();
self._navigate( 'next' );
self._navigate( 'next' );
break;
break;
}
}
} );
} );
}
}
},
},
_startSlideshow: function() {
_startSlideshow: function() {
var self = this;
var self = this;
this.slideshow = setTimeout( function() {
this.slideshow = setTimeout( function() {
self._navigate( 'next' );
self._navigate( 'next' );
if ( self.options.autoplay ) {
if ( self.options.autoplay ) {
self._startSlideshow();
self._startSlideshow();
}
}
}, this.options.interval );
}, this.options.interval );
},
},
_stopSlideshow: function() {
_stopSlideshow: function() {
if ( this.options.autoplay ) {
if ( this.options.autoplay ) {
clearTimeout( this.slideshow );
clearTimeout( this.slideshow );
this.isPlaying = false;
this.isPlaying = false;
this.options.autoplay = false;
this.options.autoplay = false;
}
}
},
},
_destroy : function( callback ) {
_destroy : function( callback ) {
this.$el.off( '.slitslider' ).removeData( 'slitslider' );
this.$el.off( '.slitslider' ).removeData( 'slitslider' );
$window.off( '.slitslider' );
$window.off( '.slitslider' );
$document.off( '.slitslider' );
$document.off( '.slitslider' );
this.$slides.each( function( i ) {
this.$slides.each( function( i ) {
var $slide = $( this ),
var $slide = $( this ),
$content = $slide.find( 'div.sl-content' ).children();
$content = $slide.find( 'div.sl-content' ).children();
$content.appendTo( $slide );
$content.appendTo( $slide );
$slide.children( 'div.sl-content-wrapper' ).remove();
$slide.children( 'div.sl-content-wrapper' ).remove();
} );
} );
this.$slides.unwrap( this.$slideWrapper ).hide();
this.$slides.unwrap( this.$slideWrapper ).hide();
this.$slides.eq( 0 ).show();
this.$slides.eq( 0 ).show();
if( callback ) {
if( callback ) {
callback.call();
callback.call();
}
}
},
},
// public methos: adds more slides to the slider
// public methos: adds more slides to the slider
add : function( $slides, callback ) {
add : function( $slides, callback ) {
this.$slides = this.$slides.add( $slides );
this.$slides = this.$slides.add( $slides );
var self = this;
var self = this;
$slides.each( function( i ) {
$slides.each( function( i ) {
var $slide = $( this ),
var $slide = $( this ),
// vertical || horizontal
// vertical || horizontal
orientation = $slide.data( 'orientation' );
orientation = $slide.data( 'orientation' );
$slide.hide().addClass( 'sl-slide-' + orientation )
$slide.hide().addClass( 'sl-slide-' + orientation )
.children()
.children()
.wrapAll( '<div class="sl-content-wrapper" />' )
.wrapAll( '<div class="sl-content-wrapper" />' )
.wrapAll( '<div class="sl-content" />' )
.wrapAll( '<div class="sl-content" />' )
.end()
.end()
.appendTo( self.$el.find( 'div.sl-slides-wrapper' ) );
.appendTo( self.$el.find( 'div.sl-slides-wrapper' ) );
} );
} );
this._setSize();
this._setSize();
this.slidesCount = this.$slides.length;
this.slidesCount = this.$slides.length;
if ( callback ) {
if ( callback ) {
callback.call( $items );
callback.call( $items );
}
}
},
},
// public method: shows next slide
// public method: shows next slide
next : function() {
next : function() {
this._stopSlideshow();
this._stopSlideshow();
this._navigate( 'next' );
this._navigate( 'next' );
},
},
// public method: shows previous slide
// public method: shows previous slide
previous : function() {
previous : function() {
this._stopSlideshow();
this._stopSlideshow();
this._navigate( 'prev' );
this._navigate( 'prev' );
},
},
// public method: goes to a specific slide
// public method: goes to a specific slide
jump : function( pos ) {
jump : function( pos ) {
pos -= 1;
pos -= 1;
if( pos === this.current || pos >= this.slidesCount || pos < 0 ) {
if( pos === this.current || pos >= this.slidesCount || pos < 0 ) {
return false;
return false;
}
}
this._stopSlideshow();
this._stopSlideshow();
this._navigate( pos > this.current ? 'next' : 'prev', pos );
this._navigate( pos > this.current ? 'next' : 'next', pos );
},
},
// public method: starts the slideshow
// public method: starts the slideshow
// any call to next(), previous() or jump() will stop the slideshow
// any call to next(), previous() or jump() will stop the slideshow
play : function() {
play : function() {
if( !this.isPlaying ) {
if( !this.isPlaying ) {
this.isPlaying = true;
this.isPlaying = true;
this._navigate( 'next' );
this._navigate( 'next' );
this.options.autoplay = true;
this.options.autoplay = true;
this._startSlideshow();
this._startSlideshow();
}
}
},
},
// public method: pauses the slideshow
// public method: pauses the slideshow
pause : function() {
pause : function() {
if( this.isPlaying ) {
if( this.isPlaying ) {
this._stopSlideshow();
this._stopSlideshow();
}
}
},
},
// public method: check if isAnimating is true
// public method: check if isAnimating is true
isActive : function() {
isActive : function() {
return this.isAnimating;
return this.isAnimating;
},
},
// publicc methos: destroys the slicebox instance
// publicc methos: destroys the slicebox instance
destroy : function( callback ) {
destroy : function( callback ) {
this._destroy( callback );
this._destroy( callback );
}
}
};
};
var logError = function( message ) {
var logError = function( message ) {
if ( window.console ) {
if ( window.console ) {
window.console.error( message );
window.console.error( message );
}
}
};
};
$.fn.slitslider = function( options ) {
$.fn.slitslider = function( options ) {
var self = $.data( this, 'slitslider' );
var self = $.data( this, 'slitslider' );
if ( typeof options === 'string' ) {
if ( typeof options === 'string' ) {
var args = Array.prototype.slice.call( arguments, 1 );
var args = Array.prototype.slice.call( arguments, 1 );
this.each(function() {
this.each(function() {
if ( !self ) {
if ( !self ) {
logError( "cannot call methods on slitslider prior to initialization; " +
logError( "cannot call methods on slitslider prior to initialization; " +
"attempted to call method '" + options + "'" );
"attempted to call method '" + options + "'" );
return;
return;
}
}
if ( !$.isFunction( self[options] ) || options.charAt(0) === "_" ) {
if ( !$.isFunction( self[options] ) || options.charAt(0) === "_" ) {
logError( "no such method '" + options + "' for slitslider self" );
logError( "no such method '" + options + "' for slitslider self" );
return;
return;
}
}
self[ options ].apply( self, args );
self[ options ].apply( self, args );
});
});
}
}
else {
else {
this.each(function() {
this.each(function() {
if ( self ) {
if ( self ) {
self._init();
self._init();
}
}
else {
else {
self = $.data( this, 'slitslider', new $.Slitslider( options, this ) );
self = $.data( this, 'slitslider', new $.Slitslider( options, this ) );
}
}
});
});
}
}
return self;
return self;
};
};
} )( jQuery, window );
} )( jQuery, window );