/* ======================================================================================================================================================
avia slideshow
====================================================================================================================================================== */
(function($)
{
"use strict";
$.aviaslider = function(options, slider)
{
var self = this;
this.$win = $( window );
this.$slider = $( slider );
this.ismobile = $.avia_utilities.ismobile;
this._prepareslides(options);
//default preload images then init slideshow
$.avia_utilities.preload({container: this.$slider , single_callback: function(){ self._init( options ); }});
}
$.aviaslider.defaults = {
//interval between autorotation switches
interval:5,
//autorotation active or not
autoplay:false,
//set if the loop will stop at the last/first slide or if the slides will loop infinite
//set to false for infinite loop, "last" to stop at the last slide or "first" to stop at the first slide
stopinfiniteloop: false,
//fade or slide animation
animation:'slide',
//transition speed when switching slide
transitionspeed:900,
//easing method for the transition
easing:'easeinoutquart',
//slide wrapper
wrapelement: '>ul',
//slide element
slideelement: '>li',
//pause if mouse cursor is above item
hoverpause: false,
//attach images as background
bg_slider: false,
//delay of miliseconds to wait before showing the next slide
show_slide_delay: 0,
//if slider animation is set to "fade" the fullfade property sets the crossfade behaviour
fullfade: false,
//enable carousel mode with multiple visible slides
carousel: 'no',
// how many slides are displayed at once in the carousel
carouselslidestoshow: 3,
// todo: how many slides are scrolled in the carousel
carouselslidestoscroll: 1,
// responsive carousel
carouselresponsive : new array(),
};
$.aviaslider.prototype =
{
_init: function( options )
{
// set slider options
this.options = this._setoptions(options);
//slidewrap
this.$sliderul = this.$slider.find(this.options.wrapelement);
// slide elements
this.$slides = this.$sliderul.find(this.options.slideelement);
// goto dots
this.gotobuttons = this.$slider.find('.avia-slideshow-dots a');
//perma caption
this.permacaption = this.$slider.find('>.av-slideshow-caption');
// slide count
this.itemscount = this.$slides.length;
// current image index
this.current = 0;
// current carousel index
this.currentcarousel = 0;
// carousel slide width
this.slidewidthcarousel = '240';
//loop count
this.loopcount = 0;
// control if the slicebox is animating
this.isanimating = false;
// css browser prefix like -webkit-, -moz-
this.browserprefix = $.avia_utilities.supports('transition');
// css3 animation?
this.cssactive = this.browserprefix !== false ? true : false;
// css3d animation?
this.css3dactive = document.documentelement.classname.indexof('avia_transform3d') !== -1 ? true : false;
//if we have a bg slider no images were preloaded yet. in that case start preloading and attaching images
if(this.options.bg_slider == true)
{
//create array that holds all image urls to preload
this.imageurls = [];
//create a preloader icon to indicate loading
this.loader = $.avia_utilities.loading(this.$slider);
//preload the images ony by one
this._bgpreloadimages();
}
else //if it was a default slider all images are already loaded and we can start showing the slider
{
//kickoff the slider: bind functions, show first slide, if active start the autorotation timer
this._kickoff();
}
if(this.options.carousel === 'yes'){
this.options.animation = 'carouselslide';
}
},
//set the slider options by first merging the efault options and the passed options, then checking the slider element if any data attributes overwrite the option set
_setoptions: function(options)
{
var newoptions = $.extend( true, {}, $.aviaslider.defaults, options ),
htmldata = this.$slider.data(),
i = "";
//overwritte passed option set with any data properties on the html element
for (i in htmldata)
{
if (htmldata.hasownproperty(i))
{
if(typeof htmldata[i] === "string" || typeof htmldata[i] === "number" || typeof htmldata[i] === "boolean")
{
newoptions[i] = htmldata[i];
}
}
}
return newoptions;
},
_prepareslides: function(options)
{
//if its a mobile device find all video slides that need to be altered
if(this.ismobile)
{
var alter = this.$slider.find('.av-mobile-fallback-image');
alter.each(function()
{
var current = $(this).removeclass('av-video-slide').data({'avia_video_events': true, 'video-ratio':0}),
fallback = current.data('mobile-img'),
fallback_link = current.data('fallback-link'),
appendto = current.find('.avia-slide-wrap');
current.find('.av-click-overlay, .mejs-mediaelement, .mejs-container').remove();
if(!fallback)
{
$('
to an
if(fallback_link != "")
{
if(appendto.is('a'))
{
appendto.attr('href', fallback_link);
}
else
{
appendto.find('a').remove();
appendto.replacewith(function(){
var cur_slide = $(this);
return $("").attr({'data-rel': cur_slide.data('rel'), 'class': cur_slide.attr('class'), 'href': fallback_link} ).append( $(this).contents() );
});
appendto = current.find('.avia-slide-wrap');
}
if($.fn.avia_activate_lightbox)
{
current.parents('#main').avia_activate_lightbox();
}
}
}
else
{
var image = '';
var lightbox = false;
if( 'string' == typeof fallback_link && fallback_link.trim() != '' )
{
if( appendto.is('a') )
{
appendto.attr('href', fallback_link);
}
else
{
var rel = fallback_link.match(/\.(jpg|jpeg|gif|png)$/i) != null ? ' rel="lightbox" ' : '';
image = '' + image + '';
}
lightbox = true;
}
current.find('.avia-slide-wrap').append(image);
if( lightbox && $.fn.avia_activate_lightbox)
{
current.parents('#main').avia_activate_lightbox();
}
}
});
}
},
//start preloading the background images
_bgpreloadimages : function(callback)
{
this._getimageurls();
this._preloadsingle(0, function()
{
this._kickoff();
this._preloadnext(1);
});
},
//if we are using a background image slider, fetch the images from a data attribute and preload them one by one
_getimageurls: function()
{
var _self = this;
//collect url strings of the images to preload
this.$slides.each(function(i)
{
_self.imageurls[i] = [];
_self.imageurls[i]['url'] = $(this).data("img-url");
//if no image is passed we can set the slide to loaded
if(typeof _self.imageurls[i]['url'] == 'string')
{
_self.imageurls[i]['status'] = false;
}
else
{
_self.imageurls[i]['status'] = true;
}
});
},
_preloadsingle: function(key, callback)
{
var _self = this,
objimage = new image();
if(typeof _self.imageurls[key]['url'] == 'string')
{
$(objimage).on('load error', function()
{
_self.imageurls[key]['status'] = true;
_self.$slides.eq(key).css('background-image','url(' + _self.imageurls[key]['url'] + ')');
if(typeof callback == 'function') callback.apply( _self, [objimage, key] );
});
if(_self.imageurls[key]['url'] != "")
{
objimage.src = _self.imageurls[key]['url'];
}
else
{
$(objimage).trigger('error');
}
}
else
{
if(typeof callback == 'function') callback.apply( _self, [objimage, key] );
}
},
_preloadnext: function(key)
{
if(typeof this.imageurls[key] != "undefined")
{
this._preloadsingle(key, function()
{
this._preloadnext(key + 1);
});
}
},
//bind click events of slide controlls to the public functions
_bindevents: function()
{
var self = this,
win = $( window );
this.$slider.on('click','.next-slide', $.proxy( this.next, this) );
this.$slider.on('click','.prev-slide', $.proxy( this.previous, this) );
this.$slider.on('click','.goto-slide', $.proxy( this.go2, this) );
if(this.options.hoverpause)
{
this.$slider.on('mouseenter', $.proxy( this.pause, this) );
this.$slider.on('mouseleave', $.proxy( this.resume, this) );
}
if(this.options.stopinfiniteloop && this.options.autoplay)
{
if(this.options.stopinfiniteloop == 'last')
{
this.$slider.on('avia_slider_last_slide', $.proxy(this._stopslideshow, this) );
}
else if(this.options.stopinfiniteloop == 'first')
{
this.$slider.on('avia_slider_first_slide', $.proxy(this._stopslideshow, this) );
}
}
if (this.options.carousel === 'yes'){
// recalculate carousel dimensions on viewport size change
win.on( 'debouncedresize', $.proxy( this._buildcarousel, this) );
}
else{
win.on( 'debouncedresize.aviaslider', $.proxy( this._setsize, this) );
}
//if its a desktop browser add arrow navigation, otherwise add touch nav
if(!this.ismobile)
{
this.$slider.avia_keyboard_controls();
}
else
{
this.$slider.avia_swipe_trigger();
}
self._attach_video_events();
},
//kickoff the slider by binding all functions to slides and buttons, show the first slide and start autoplay
_kickoff: function()
{
var self = this,
first_slide = self.$slides.eq(0),
video = first_slide.data('video-ratio');
// bind events to to the controll buttons
self._bindevents();
this.$slider.removeclass('av-default-height-applied');
//show the first slide. if its a video set the correct size, otherwise make sure to remove the % padding
if(video)
{
self._setsize(true);
}
else
{
if(this.options.keep_pading != true)
{
self.$sliderul.css('padding',0);
self.$win.trigger('av-height-change');
}
}
self._setcenter();
if ( this.options.carousel === 'no' ) {
first_slide.css({visibility:'visible', opacity:0}).avia_animate({opacity:1}, function()
{
var current = $(this).addclass('active-slide');
if(self.permacaption.length)
{
self.permacaption.addclass('active-slide');
}
});
}
// start autoplay if active
if( self.options.autoplay )
{
self._startslideshow();
}
// prepare carousel if active
if (self.options.carousel === 'yes') {
self._buildcarousel();
}
self.$slider.trigger('_kickoff');
},
_buildcarousel : function(){
var self = this,
stagewidth = this.$slider.outerwidth(),
slideswidth = parseint(stagewidth / this.options.carouselslidestoshow),
windowwidth = window.innerwidth || $(window).width();
// responsive carousel
if ( this.options.carouselresponsive &&
this.options.carouselresponsive.length &&
this.options.carouselresponsive !== null) {
for (var breakpoint in this.options.carouselresponsive){
var breakpointvalue = this.options.carouselresponsive[breakpoint]['breakpoint'];
var newslidestoshow = this.options.carouselresponsive[breakpoint]['settings']['carouselslidestoshow'];
if (breakpointvalue >= windowwidth) {
slideswidth = parseint(stagewidth / newslidestoshow);
this.options.carouselslidestoshow = newslidestoshow;
}
}
}
// set width and height for each slide
this.slidewidthcarousel = slideswidth;
this.$slides.each(function(i){
$(this).width(slideswidth);
});
// set width for the ul
var slidetrackwidth = slideswidth * this.itemscount;
this.$sliderul.width(slidetrackwidth).css('transform', 'translatex(0px)');
// hide nav if not needed
if (this.options.carouselslidestoshow >= this.itemscount){
this.$slider.find('.av-timeline-nav').hide();
}
},
//calculate which slide should be displayed next and call the executing transition function
_navigate : function( dir, pos ) {
if( this.isanimating || this.itemscount < 2 || !this.$slider.is(":visible") )
{
return false;
}
this.isanimating = true;
// current item's index
this.prev = this.current;
// if position is passed
if( pos !== undefined )
{
this.current = pos;
dir = this.current > this.prev ? 'next' : 'prev';
}
// if not check the boundaries
else if( dir === 'next' )
{
this.current = this.current < this.itemscount - 1 ? this.current + 1 : 0;
if( this.current === 0 && this.options.autoplay_stopper == 1 && this.options.autoplay )
{
this.isanimating = false;
this.current = this.prev;
this._stopslideshow();
return false;
}
}
else if( dir === 'prev' )
{
this.current = this.current > 0 ? this.current - 1 : this.itemscount - 1;
}
//set goto button
this.gotobuttons.removeclass('active').eq(this.current).addclass('active');
//set slideshow size if carousel not in use
if( this.options.carousel === 'no') {
this._setsize();
}
//if we are using a background slider make sure that the image is loaded. if not preload it, then show the slide
if(this.options.bg_slider == true)
{
if(this.imageurls[this.current]['status'] == true )
{
this['_' + this.options.animation].call(this, dir);
}
else
{
this.loader.show();
this._preloadsingle(this.current, function()
{
this['_' + this.options.animation].call(this, dir);
this.loader.hide();
});
}
}
else //no background loader -> images are already loaded
{
//call the executing function. for example _slide, or _fade. since the function call is absed on a var we can easily extend the slider with new animations
this['_' + this.options.animation].call(this, dir);
}
if(this.current == 0)
{
this.loopcount++;
this.$slider.trigger('avia_slider_first_slide');
}
else if(this.current == this.itemscount - 1)
{
this.$slider.trigger('avia_slider_last_slide');
}
else
{
this.$slider.trigger('avia_slider_navigate_slide');
}
},
//if the next slide has a different height than the current change the slideshow height
_setsize: function(instant)
{
//if images are attached as bg images the slider has a fixed height
if(this.options.bg_slider == true) return;
var self = this,
slide = this.$slides.eq(this.current),
img = slide.find('img'),
current = math.floor(this.$sliderul.height()),
ratio = slide.data('video-ratio'),
setto = ratio ? this.$sliderul.width() / ratio : math.floor(slide.height()),
video_height = slide.data('video-height'), //forced video height %. needs to be set only once
video_toppos = slide.data('video-toppos'); //forced video top position
this.$sliderul.height(current).css('padding',0); //make sure to set the slideheight to an actual value
if(setto != current)
{
if(instant == true)
{
this.$sliderul.css({height:setto});
this.$win.trigger('av-height-change');
}
else
{
this.$sliderul.avia_animate({height:setto}, function()
{
self.$win.trigger('av-height-change');
});
}
}
this._setcenter();
if(video_height && video_height!= "set")
{
slide.find('iframe, embed, video, object, .av_youtube_frame').css({height: video_height + '%', top: video_toppos + '%'});
slide.data('video-height','set');
}
},
_setcenter: function()
{
//if the image has a min width and is larger than the slider center it
//positon img based on caption. right caption->left pos, left caption -> right pos
var slide = this.$slides.eq(this.current),
img = slide.find('img'),
min_width = parseint(img.css('min-width'),10),
slide_width = slide.width(),
caption = slide.find('.av-slideshow-caption'),
css_left = ((slide_width - min_width) / 2);
if(caption.length)
{
if(caption.is('.caption_left'))
{
css_left = ((slide_width - min_width) / 1.5);
}
else if(caption.is('.caption_right'))
{
css_left = ((slide_width - min_width) / 2.5);
}
}
if(slide_width >= min_width)
{
css_left = 0;
}
img.css({left:css_left});
},
_carouselmove : function(){
// var offset = (this.options.carouselslidestoscroll*this.slidewidthcarousel)*this.currentcarousel;
var offset = this.slidewidthcarousel*this.currentcarousel;
this.$sliderul.css('transform', 'translatex(-'+offset+'px)');
},
_carouselslide: function(dir){
if (dir === 'next') {
if (this.options.carouselslidestoshow + this.currentcarousel < this.itemscount){
this.currentcarousel++;
this._carouselmove();
}
}
else if (dir === 'prev'){
if (this.currentcarousel > 0) {
this.currentcarousel--;
this._carouselmove();
}
}
this.isanimating = false;
},
_slide: function(dir)
{
var dynamic = false, //todo: pass by option if a slider is dynamic
modifier = dynamic == true ? 2 : 1,
sliderwidth = this.$slider.width(),
direction = dir === 'next' ? -1 : 1,
property = this.browserprefix + 'transform',
reset = {}, transition = {}, transition2 = {},
trans_val = ( sliderwidth * direction * -1),
trans_val2 = ( sliderwidth * direction) / modifier;
//do a css3 animation
if(this.cssactive)
{
property = this.browserprefix + 'transform';
//do a translate 3d transformation if available, since it uses hardware acceleration
if(this.css3dactive)
{
reset[property] = "translate3d(" + trans_val + "px, 0, 0)";
transition[property] = "translate3d(" + trans_val2 + "px, 0, 0)";
transition2[property] = "translate3d(0,0,0)";
}
else //do a 2d transform. still faster than a position "left" change
{
reset[property] = "translate(" + trans_val + "px,0)";
transition[property] = "translate(" + trans_val2 + "px,0)";
transition2[property] = "translate(0,0)";
}
}
else
{
reset.left = trans_val;
transition.left = trans_val2;
transition2.left = 0;
}
if(dynamic)
{
transition['z-index'] = "1";
transition2['z-index'] = "2";
}
this._slide_animate(reset, transition, transition2);
},
_slide_up: function(dir)
{
var dynamic = true, //todo: pass by option if a slider is dynamic
modifier = dynamic == true ? 2 : 1,
sliderheight = this.$slider.height(),
direction = dir === 'next' ? -1 : 1,
property = this.browserprefix + 'transform',
reset = {}, transition = {}, transition2 = {},
trans_val = ( sliderheight * direction * -1),
trans_val2 = ( sliderheight * direction) / modifier;
//do a css3 animation
if(this.cssactive)
{
property = this.browserprefix + 'transform';
//do a translate 3d transformation if available, since it uses hardware acceleration
if(this.css3dactive)
{
reset[property] = "translate3d( 0," + trans_val + "px, 0)";
transition[property] = "translate3d( 0," + trans_val2 + "px, 0)";
transition2[property] = "translate3d(0,0,0)";
}
else //do a 2d transform. still faster than a position "left" change
{
reset[property] = "translate( 0," + trans_val + "px)";
transition[property] = "translate( 0," + trans_val2 + "px)";
transition2[property] = "translate(0,0)"; }
}
else
{
reset.top = trans_val;
transition.top = trans_val2;
transition2.top = 0;
}
if(dynamic)
{
transition['z-index'] = "1";
transition2['z-index'] = "2";
}
this._slide_animate(reset, transition, transition2);
},
//slide animation: do a slide transition by css3 transform if possible. if not simply do a position left transition
_slide_animate: function( reset , transition , transition2 )
{
var self = this,
displayslide = this.$slides.eq(this.current),
hideslide = this.$slides.eq(this.prev);
hideslide.trigger('pause');
if( !displayslide.data('disableautoplay') ) {
if(displayslide.hasclass('av-video-lazyload') && !displayslide.hasclass('av-video-lazyload-complete'))
{
displayslide.find('.av-click-to-play-overlay').trigger('click');
}
else
{
displayslide.trigger('play');
}
}
displayslide.css({visibility:'visible', zindex:4, opacity:1, left:0, top:0});
displayslide.css(reset);
hideslide.avia_animate(transition, this.options.transitionspeed, this.options.easing);
var after_slide = function()
{
self.isanimating = false;
displayslide.addclass('active-slide');
hideslide.css({visibility:'hidden'}).removeclass('active-slide');
self.$slider.trigger('avia-transition-done');
}
if(self.options.show_slide_delay > 0)
{
settimeout(function() { displayslide.avia_animate(transition2, self.options.transitionspeed, self.options.easing, after_slide); },self.options.show_slide_delay);
}
else
{
displayslide.avia_animate(transition2, self.options.transitionspeed, self.options.easing, after_slide);
}
},
//simple fade transition of the slideshow
_fade: function()
{
var self = this,
displayslide = this.$slides.eq(this.current),
hideslide = this.$slides.eq(this.prev),
properties = {visibility:'visible', zindex:3, opacity:0},
fadecallback = function()
{
self.isanimating = false;
displayslide.addclass('active-slide');
hideslide.css({visibility:'hidden', zindex:2}).removeclass('active-slide');
self.$slider.trigger('avia-transition-done');
};
hideslide.trigger('pause');
if( !displayslide.data('disableautoplay') ) {
if(displayslide.hasclass('av-video-lazyload') && !displayslide.hasclass('av-video-lazyload-complete'))
{
displayslide.find('.av-click-to-play-overlay').trigger('click');
}
else
{
displayslide.trigger('play');
}
}
if(self.options.fullfade == true)
{
hideslide.avia_animate({opacity:0}, 200, 'linear', function()
{
displayslide.css(properties).avia_animate({opacity:1}, self.options.transitionspeed, 'linear',fadecallback);
});
}
else
{
displayslide.css(properties).avia_animate({opacity:1}, self.options.transitionspeed/2, 'linear', function()
{
hideslide.avia_animate({opacity:0}, 200, 'linear', fadecallback);
});
}
},
/************************************************************************
video functions
*************************************************************************/
//bind events to the video that tell the slider to autorotate once a video has been played
_attach_video_events: function()
{
var self = this, $html = $('html');
self.$slides.each(function(i)
{
var currentslide = $(this),
caption = currentslide.find('.caption_fullwidth, .av-click-overlay'),
mejs = currentslide.find('.mejs-mediaelement'),
lazyload = currentslide.hasclass('av-video-lazyload') ? true : false;
if(currentslide.data('avia_video_events') != true)
{
currentslide.data('avia_video_events', true);
currentslide.on('av-video-events-bound', { slide: currentslide, wrap: mejs , iteration: i , self: self, lazyload: lazyload }, onready);
currentslide.on('av-video-ended', { slide: currentslide , self: self}, onfinish);
currentslide.on('av-video-play-executed', function(){ settimeout(function(){ self.pause() }, 100); });
caption.on('click', { slide: currentslide }, toggle);
// also if the player was loaded before the _bindevents function was bound trigger it manually
if(currentslide.is('.av-video-events-bound')) currentslide.trigger('av-video-events-bound');
//if we are on the first slide and autoplay is enabled and lazy loading is enabled we need to simulate a click event to the lazy load container
if(lazyload && i === 0 && !currentslide.data('disableautoplay'))
{
currentslide.find('.av-click-to-play-overlay').trigger('click');
}
}
});
//function that takes care of events once the video is loaded for the first time.
//needs to take into account 2 different scenarios: normally embedded videos or lazyloaded videos that start on user interaction/autoplay
function onready( event )
{
//autostart for first slide
if(event.data.iteration === 0)
{
event.data.wrap.css('opacity',0);
if(!event.data.self.ismobile && !event.data.slide.data('disableautoplay'))
{
event.data.slide.trigger('play');
}
settimeout(function(){ event.data.wrap.avia_animate({opacity:1}, 400); }, 50);
}
else if ($html.is('.avia-msie') && !event.data.slide.is('.av-video-service-html5'))
{
/*
* internet explorer fires the ready event for external videos once they become visible
* as oposed to other browsers which always fire immediately.
*/
if( !event.data.slide.data('disableautoplay') ) event.data.slide.trigger('play');
}
//make sure that the html5 element does not play if autoply is enabled but its not the first slide.
//the autoplay attribute on the video element might cause this
if(event.data.slide.is('.av-video-service-html5') && event.data.iteration !== 0 )
{
event.data.slide.trigger('pause');
}
//make sure that lazyloaded videos always get started once a user clicks them
if(event.data.lazyload)
{
event.data.slide.addclass('av-video-lazyload-complete');
event.data.slide.trigger('play');
}
}
function onfinish( event )
{
//if the video is not looped resume the slideshow
if(!event.data.slide.is('.av-single-slide') && !event.data.slide.is('.av-loop-video'))
{
event.data.slide.trigger('reset');
self._navigate( 'next' );
self.resume();
}
//safari 8 workaround for self hosted videos which wont loop by default
if(event.data.slide.is('.av-loop-video') && event.data.slide.is('.av-video-service-html5'))
{
if($html.is('.avia-safari-8'))
{
settimeout(function(){ event.data.slide.trigger('play'); },1);
}
}
}
function toggle( event )
{
if(event.target.tagname != "a")
{
event.data.slide.trigger('toggle');
}
}
},
/************************************************************************
slideshow control functions
*************************************************************************/
_timer: function(callback, delay, first)
{
var self = this, start, remaining = delay;
self.timerid = 0;
this.pause = function() {
window.cleartimeout(self.timerid);
remaining -= new date() - start;
};
this.resume = function() {
start = new date();
self.timerid = window.settimeout(callback, remaining);
};
this.destroy = function()
{
window.cleartimeout(self.timerid);
};
this.resume(true);
},
//start autorotation
_startslideshow: function()
{
var self = this;
this.isplaying = true;
this.slideshow = new this._timer( function()
{
self._navigate( 'next' );
if ( self.options.autoplay )
{
self._startslideshow();
}
}, (this.options.interval * 1000));
},
//stop autorotation
_stopslideshow: function()
{
if ( this.options.autoplay ) {
this.slideshow.destroy();
this.isplaying = false;
this.options.autoplay = false;
}
},
// public method: shows next image
next : function(e)
{
e.preventdefault();
this._stopslideshow();
this._navigate( 'next' );
},
// public method: shows previous image
previous : function(e)
{
e.preventdefault();
this._stopslideshow();
this._navigate( 'prev' );
},
// public method: goes to a specific image
go2 : function( pos )
{
//if we didnt pass a number directly lets asume someone clicked on a link that triggered the goto transition
if(isnan(pos))
{
//in that case prevent the default link behavior and set the slide number to the links hash
pos.preventdefault();
pos = pos.currenttarget.hash.replace('#','');
}
pos -= 1;
if( pos === this.current || pos >= this.itemscount || pos < 0 )
{
return false;
}
this._stopslideshow();
this._navigate( false, pos );
},
// public method: starts the slideshow
// any call to next(), previous() or goto() will stop the slideshow autoplay
play : function()
{
if( !this.isplaying )
{
this.isplaying = true;
this._navigate( 'next' );
this.options.autoplay = true;
this._startslideshow();
}
},
// public methos: pauses the slideshow
pause : function()
{
if( this.isplaying )
{
this.slideshow.pause();
}
},
// publiccmethos: resumes the slideshow
resume : function()
{
if( this.isplaying )
{
this.slideshow.resume();
}
},
// public methos: destroys the instance
destroy : function( callback )
{
this.slideshow.destroy( callback );
}
}
//simple wrapper to call the slideshow. makes sure that the slide data is not applied twice
$.fn.aviaslider = function( options )
{
return this.each(function()
{
var self = $.data( this, 'aviaslider' );
if(!self)
{
self = $.data( this, 'aviaslider', new $.aviaslider( options, this ) );
}
});
}
})( jquery );