/*!
* jquery cycle plugin (with transition definitions)
* examples and documentation at: http://jquery.malsup.com/cycle/
* copyright (c) 2007-2013 m. alsup
* version: 3.0.3 (11-jul-2013)
* dual licensed under the mit and gpl licenses.
* http://jquery.malsup.com/license.html
* requires: jquery v1.7.1 or later
*/
;(function($, undefined) {
"use strict";
var ver = '3.0.3';
function debug(s) {
if ($.fn.cycle.debug)
log(s);
}
function log() {
/*global console */
if (window.console && console.log)
console.log('[cycle] ' + array.prototype.join.call(arguments,' '));
}
$.expr[':'].paused = function(el) {
return el.cyclepause;
};
// the options arg can be...
// a number - indicates an immediate transition should occur to the given slide index
// a string - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc)
// an object - properties to control the slideshow
//
// the arg2 arg can be...
// the name of an fx (only used in conjunction with a numeric value for 'options')
// the value true (only used in first arg == 'resume') and indicates
// that the resume should occur immediately (not wait for next timeout)
$.fn.cycle = function(options, arg2) {
var o = { s: this.selector, c: this.context };
// in 1.3+ we can fix mistakes with the ready state
if (this.length === 0 && options != 'stop') {
if (!$.isready && o.s) {
log('dom not ready, queuing slideshow');
$(function() {
$(o.s,o.c).cycle(options,arg2);
});
return this;
}
// is your dom ready? http://docs.jquery.com/tutorials:introducing_$(document).ready()
log('terminating; zero elements found by selector' + ($.isready ? '' : ' (dom not ready)'));
return this;
}
// iterate the matched nodeset
return this.each(function() {
var opts = handlearguments(this, options, arg2);
if (opts === false)
return;
opts.updateactivepagerlink = opts.updateactivepagerlink || $.fn.cycle.updateactivepagerlink;
// stop existing slideshow for this container (if there is one)
if (this.cycletimeout)
cleartimeout(this.cycletimeout);
this.cycletimeout = this.cyclepause = 0;
this.cyclestop = 0; // issue #108
var $cont = $(this);
var $slides = opts.slideexpr ? $(opts.slideexpr, this) : $cont.children();
var els = $slides.get();
if (els.length < 2) {
log('terminating; too few slides: ' + els.length);
return;
}
var opts2 = buildoptions($cont, $slides, els, opts, o);
if (opts2 === false)
return;
var starttime = opts2.continuous ? 10 : gettimeout(els[opts2.currslide], els[opts2.nextslide], opts2, !opts2.backwards);
// if it's an auto slideshow, kick it off
if (starttime) {
starttime += (opts2.delay || 0);
if (starttime < 10)
starttime = 10;
debug('first timeout: ' + starttime);
this.cycletimeout = settimeout(function(){go(els,opts2,0,!opts.backwards);}, starttime);
}
});
};
function triggerpause(cont, byhover, onpager) {
var opts = $(cont).data('cycle.opts');
if (!opts)
return;
var paused = !!cont.cyclepause;
if (paused && opts.paused)
opts.paused(cont, opts, byhover, onpager);
else if (!paused && opts.resumed)
opts.resumed(cont, opts, byhover, onpager);
}
// process the args that were passed to the plugin fn
function handlearguments(cont, options, arg2) {
if (cont.cyclestop === undefined)
cont.cyclestop = 0;
if (options === undefined || options === null)
options = {};
if (options.constructor == string) {
switch(options) {
case 'destroy':
case 'stop':
var opts = $(cont).data('cycle.opts');
if (!opts)
return false;
cont.cyclestop++; // callbacks look for change
if (cont.cycletimeout)
cleartimeout(cont.cycletimeout);
cont.cycletimeout = 0;
if (opts.elements)
$(opts.elements).stop();
$(cont).removedata('cycle.opts');
if (options == 'destroy')
destroy(cont, opts);
return false;
case 'toggle':
cont.cyclepause = (cont.cyclepause === 1) ? 0 : 1;
checkinstantresume(cont.cyclepause, arg2, cont);
triggerpause(cont);
return false;
case 'pause':
cont.cyclepause = 1;
triggerpause(cont);
return false;
case 'resume':
cont.cyclepause = 0;
checkinstantresume(false, arg2, cont);
triggerpause(cont);
return false;
case 'prev':
case 'next':
opts = $(cont).data('cycle.opts');
if (!opts) {
log('options not found, "prev/next" ignored');
return false;
}
if (typeof arg2 == 'string')
opts.onetimefx = arg2;
$.fn.cycle[options](opts);
return false;
default:
options = { fx: options };
}
return options;
}
else if (options.constructor == number) {
// go to the requested slide
var num = options;
options = $(cont).data('cycle.opts');
if (!options) {
log('options not found, can not advance slide');
return false;
}
if (num < 0 || num >= options.elements.length) {
log('invalid slide index: ' + num);
return false;
}
options.nextslide = num;
if (cont.cycletimeout) {
cleartimeout(cont.cycletimeout);
cont.cycletimeout = 0;
}
if (typeof arg2 == 'string')
options.onetimefx = arg2;
go(options.elements, options, 1, num >= options.currslide);
return false;
}
return options;
function checkinstantresume(ispaused, arg2, cont) {
if (!ispaused && arg2 === true) { // resume now!
var options = $(cont).data('cycle.opts');
if (!options) {
log('options not found, can not resume');
return false;
}
if (cont.cycletimeout) {
cleartimeout(cont.cycletimeout);
cont.cycletimeout = 0;
}
go(options.elements, options, 1, !options.backwards);
}
}
}
function removefilter(el, opts) {
if (!$.support.opacity && opts.cleartype && el.style.filter) {
try { el.style.removeattribute('filter'); }
catch(smother) {} // handle old opera versions
}
}
// unbind event handlers
function destroy(cont, opts) {
if (opts.next)
$(opts.next).unbind(opts.prevnextevent);
if (opts.prev)
$(opts.prev).unbind(opts.prevnextevent);
if (opts.pager || opts.pageranchorbuilder)
$.each(opts.pageranchors || [], function() {
this.unbind().remove();
});
opts.pageranchors = null;
$(cont).unbind('mouseenter.cycle mouseleave.cycle');
if (opts.destroy) // callback
opts.destroy(opts);
}
// one-time initialization
function buildoptions($cont, $slides, els, options, o) {
var startingslidespecified;
// support metadata plugin (v1.0 and v2.0)
var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
var meta = $.isfunction($cont.data) ? $cont.data(opts.metaattr) : null;
if (meta)
opts = $.extend(opts, meta);
if (opts.autostop)
opts.countdown = opts.autostopcount || els.length;
var cont = $cont[0];
$cont.data('cycle.opts', opts);
opts.$cont = $cont;
opts.stopcount = cont.cyclestop;
opts.elements = els;
opts.before = opts.before ? [opts.before] : [];
opts.after = opts.after ? [opts.after] : [];
// push some after callbacks
if (!$.support.opacity && opts.cleartype)
opts.after.push(function() { removefilter(this, opts); });
if (opts.continuous)
opts.after.push(function() { go(els,opts,0,!opts.backwards); });
saveoriginalopts(opts);
// cleartype corrections
if (!$.support.opacity && opts.cleartype && !opts.cleartypenobg)
cleartypefix($slides);
// container requires non-static position so that slides can be position within
if ($cont.css('position') == 'static')
$cont.css('position', 'relative');
if (opts.width)
$cont.width(opts.width);
if (opts.height && opts.height != 'auto')
$cont.height(opts.height);
if (opts.startingslide !== undefined) {
opts.startingslide = parseint(opts.startingslide,10);
if (opts.startingslide >= els.length || opts.startslide < 0)
opts.startingslide = 0; // catch bogus input
else
startingslidespecified = true;
}
else if (opts.backwards)
opts.startingslide = els.length - 1;
else
opts.startingslide = 0;
// if random, mix up the slide array
if (opts.random) {
opts.randommap = [];
for (var i = 0; i < els.length; i++)
opts.randommap.push(i);
opts.randommap.sort(function(a,b) {return math.random() - 0.5;});
if (startingslidespecified) {
// try to find the specified starting slide and if found set start slide index in the map accordingly
for ( var cnt = 0; cnt < els.length; cnt++ ) {
if ( opts.startingslide == opts.randommap[cnt] ) {
opts.randomindex = cnt;
}
}
}
else {
opts.randomindex = 1;
opts.startingslide = opts.randommap[1];
}
}
else if (opts.startingslide >= els.length)
opts.startingslide = 0; // catch bogus input
opts.currslide = opts.startingslide || 0;
var first = opts.startingslide;
// set position and zindex on all the slides
$slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) {
var z;
if (opts.backwards)
z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i;
else
z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i;
$(this).css('z-index', z);
});
// make sure first slide is visible
$(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case
removefilter(els[first], opts);
// stretch slides
if (opts.fit) {
if (!opts.aspect) {
if (opts.width)
$slides.width(opts.width);
if (opts.height && opts.height != 'auto')
$slides.height(opts.height);
} else {
$slides.each(function(){
var $slide = $(this);
var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect;
if( opts.width && $slide.width() != opts.width ) {
$slide.width( opts.width );
$slide.height( opts.width / ratio );
}
if( opts.height && $slide.height() < opts.height ) {
$slide.height( opts.height );
$slide.width( opts.height * ratio );
}
});
}
}
if (opts.center && ((!opts.fit) || opts.aspect)) {
$slides.each(function(){
var $slide = $(this);
$slide.css({
"margin-left": opts.width ?
((opts.width - $slide.width()) / 2) + "px" :
0,
"margin-top": opts.height ?
((opts.height - $slide.height()) / 2) + "px" :
0
});
});
}
if (opts.center && !opts.fit && !opts.slideresize) {
$slides.each(function(){
var $slide = $(this);
$slide.css({
"margin-left": opts.width ? ((opts.width - $slide.width()) / 2) + "px" : 0,
"margin-top": opts.height ? ((opts.height - $slide.height()) / 2) + "px" : 0
});
});
}
// stretch container
var reshape = (opts.containerresize || opts.containerresizeheight) && $cont.innerheight() < 1;
if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9
var maxw = 0, maxh = 0;
for(var j=0; j < els.length; j++) {
var $e = $(els[j]), e = $e[0], w = $e.outerwidth(), h = $e.outerheight();
if (!w) w = e.offsetwidth || e.width || $e.attr('width');
if (!h) h = e.offsetheight || e.height || $e.attr('height');
maxw = w > maxw ? w : maxw;
maxh = h > maxh ? h : maxh;
}
if (opts.containerresize && maxw > 0 && maxh > 0)
$cont.css({width:maxw+'px',height:maxh+'px'});
if (opts.containerresizeheight && maxh > 0)
$cont.css({height:maxh+'px'});
}
var pauseflag = false; // https://github.com/malsup/cycle/issues/44
if (opts.pause)
$cont.bind('mouseenter.cycle', function(){
pauseflag = true;
this.cyclepause++;
triggerpause(cont, true);
}).bind('mouseleave.cycle', function(){
if (pauseflag)
this.cyclepause--;
triggerpause(cont, true);
});
if (supportmultitransitions(opts) === false)
return false;
// apparently a lot of people use image slideshows without height/width attributes on the images.
// cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that.
var requeue = false;
options.requeueattempts = options.requeueattempts || 0;
$slides.each(function() {
// try to get height/width of each slide
var $el = $(this);
this.cycleh = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetheight || this.height || $el.attr('height') || 0);
this.cyclew = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetwidth || this.width || $el.attr('width') || 0);
if ( $el.is('img') ) {
var loading = (this.cycleh === 0 && this.cyclew === 0 && !this.complete);
// don't requeue for images that are still loading but have a valid size
if (loading) {
if (o.s && opts.requeueonimagenotloaded && ++options.requeueattempts < 100) { // track retry count so we don't loop forever
log(options.requeueattempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cyclew, this.cycleh);
settimeout(function() {$(o.s,o.c).cycle(options);}, opts.requeuetimeout);
requeue = true;
return false; // break each loop
}
else {
log('could not determine size of image: '+this.src, this.cyclew, this.cycleh);
}
}
}
return true;
});
if (requeue)
return false;
opts.cssbefore = opts.cssbefore || {};
opts.cssafter = opts.cssafter || {};
opts.cssfirst = opts.cssfirst || {};
opts.animin = opts.animin || {};
opts.animout = opts.animout || {};
$slides.not(':eq('+first+')').css(opts.cssbefore);
$($slides[first]).css(opts.cssfirst);
if (opts.timeout) {
opts.timeout = parseint(opts.timeout,10);
// ensure that timeout and speed settings are sane
if (opts.speed.constructor == string)
opts.speed = $.fx.speeds[opts.speed] || parseint(opts.speed,10);
if (!opts.sync)
opts.speed = opts.speed / 2;
var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250;
while((opts.timeout - opts.speed) < buffer) // sanitize timeout
opts.timeout += opts.speed;
}
if (opts.easing)
opts.easein = opts.easeout = opts.easing;
if (!opts.speedin)
opts.speedin = opts.speed;
if (!opts.speedout)
opts.speedout = opts.speed;
opts.slidecount = els.length;
opts.currslide = opts.lastslide = first;
if (opts.random) {
if (++opts.randomindex == els.length)
opts.randomindex = 0;
opts.nextslide = opts.randommap[opts.randomindex];
}
else if (opts.backwards)
opts.nextslide = opts.startingslide === 0 ? (els.length-1) : opts.startingslide-1;
else
opts.nextslide = opts.startingslide >= (els.length-1) ? 0 : opts.startingslide+1;
// run transition init fn
if (!opts.multifx) {
var init = $.fn.cycle.transitions[opts.fx];
if ($.isfunction(init))
init($cont, $slides, opts);
else if (opts.fx != 'custom' && !opts.multifx) {
log('unknown transition: ' + opts.fx,'; slideshow terminating');
return false;
}
}
// fire artificial events
var e0 = $slides[first];
if (!opts.skipinitializationcallbacks) {
if (opts.before.length)
opts.before[0].apply(e0, [e0, e0, opts, true]);
if (opts.after.length)
opts.after[0].apply(e0, [e0, e0, opts, true]);
}
if (opts.next)
$(opts.next).bind(opts.prevnextevent,function(){return advance(opts,1);});
if (opts.prev)
$(opts.prev).bind(opts.prevnextevent,function(){return advance(opts,0);});
if (opts.pager || opts.pageranchorbuilder)
buildpager(els,opts);
exposeaddslide(opts, els);
return opts;
}
// save off original opts so we can restore after clearing state
function saveoriginalopts(opts) {
opts.original = { before: [], after: [] };
opts.original.cssbefore = $.extend({}, opts.cssbefore);
opts.original.cssafter = $.extend({}, opts.cssafter);
opts.original.animin = $.extend({}, opts.animin);
opts.original.animout = $.extend({}, opts.animout);
$.each(opts.before, function() { opts.original.before.push(this); });
$.each(opts.after, function() { opts.original.after.push(this); });
}
function supportmultitransitions(opts) {
var i, tx, txs = $.fn.cycle.transitions;
// look for multiple effects
if (opts.fx.indexof(',') > 0) {
opts.multifx = true;
opts.fxs = opts.fx.replace(/\s*/g,'').split(',');
// discard any bogus effect names
for (i=0; i < opts.fxs.length; i++) {
var fx = opts.fxs[i];
tx = txs[fx];
if (!tx || !txs.hasownproperty(fx) || !$.isfunction(tx)) {
log('discarding unknown transition: ',fx);
opts.fxs.splice(i,1);
i--;
}
}
// if we have an empty list then we threw everything away!
if (!opts.fxs.length) {
log('no valid transitions named; slideshow terminating.');
return false;
}
}
else if (opts.fx == 'all') { // auto-gen the list of transitions
opts.multifx = true;
opts.fxs = [];
for (var p in txs) {
if (txs.hasownproperty(p)) {
tx = txs[p];
if (txs.hasownproperty(p) && $.isfunction(tx))
opts.fxs.push(p);
}
}
}
if (opts.multifx && opts.randomizeeffects) {
// munge the fxs array to make effect selection random
var r1 = math.floor(math.random() * 20) + 30;
for (i = 0; i < r1; i++) {
var r2 = math.floor(math.random() * opts.fxs.length);
opts.fxs.push(opts.fxs.splice(r2,1)[0]);
}
debug('randomized fx sequence: ',opts.fxs);
}
return true;
}
// provide a mechanism for adding slides after the slideshow has started
function exposeaddslide(opts, els) {
opts.addslide = function(newslide, prepend) {
var $s = $(newslide), s = $s[0];
if (!opts.autostopcount)
opts.countdown++;
els[prepend?'unshift':'push'](s);
if (opts.els)
opts.els[prepend?'unshift':'push'](s); // shuffle needs this
opts.slidecount = els.length;
// add the slide to the random map and resort
if (opts.random) {
opts.randommap.push(opts.slidecount-1);
opts.randommap.sort(function(a,b) {return math.random() - 0.5;});
}
$s.css('position','absolute');
$s[prepend?'prependto':'appendto'](opts.$cont);
if (prepend) {
opts.currslide++;
opts.nextslide++;
}
if (!$.support.opacity && opts.cleartype && !opts.cleartypenobg)
cleartypefix($s);
if (opts.fit && opts.width)
$s.width(opts.width);
if (opts.fit && opts.height && opts.height != 'auto')
$s.height(opts.height);
s.cycleh = (opts.fit && opts.height) ? opts.height : $s.height();
s.cyclew = (opts.fit && opts.width) ? opts.width : $s.width();
$s.css(opts.cssbefore);
if (opts.pager || opts.pageranchorbuilder)
$.fn.cycle.createpageranchor(els.length-1, s, $(opts.pager), els, opts);
if ($.isfunction(opts.onaddslide))
opts.onaddslide($s);
else
$s.hide(); // default behavior
};
}
// reset internal state; we do this on every pass in order to support multiple effects
$.fn.cycle.resetstate = function(opts, fx) {
fx = fx || opts.fx;
opts.before = []; opts.after = [];
opts.cssbefore = $.extend({}, opts.original.cssbefore);
opts.cssafter = $.extend({}, opts.original.cssafter);
opts.animin = $.extend({}, opts.original.animin);
opts.animout = $.extend({}, opts.original.animout);
opts.fxfn = null;
$.each(opts.original.before, function() { opts.before.push(this); });
$.each(opts.original.after, function() { opts.after.push(this); });
// re-init
var init = $.fn.cycle.transitions[fx];
if ($.isfunction(init))
init(opts.$cont, $(opts.elements), opts);
};
// this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt
function go(els, opts, manual, fwd) {
var p = opts.$cont[0], curr = els[opts.currslide], next = els[opts.nextslide];
// opts.busy is true if we're in the middle of an animation
if (manual && opts.busy && opts.manualtrump) {
// let manual transitions requests trump active ones
debug('manualtrump in go(), stopping active transition');
$(els).stop(true,true);
opts.busy = 0;
cleartimeout(p.cycletimeout);
}
// don't begin another timeout-based transition if there is one active
if (opts.busy) {
debug('transition active, ignoring new tx request');
return;
}
// stop cycling if we have an outstanding stop request
if (p.cyclestop != opts.stopcount || p.cycletimeout === 0 && !manual)
return;
// check to see if we should stop cycling based on autostop options
if (!manual && !p.cyclepause && !opts.bounce &&
((opts.autostop && (--opts.countdown <= 0)) ||
(opts.nowrap && !opts.random && opts.nextslide < opts.currslide))) {
if (opts.end)
opts.end(opts);
return;
}
// if slideshow is paused, only transition on a manual trigger
var changed = false;
if ((manual || !p.cyclepause) && (opts.nextslide != opts.currslide)) {
changed = true;
var fx = opts.fx;
// keep trying to get the slide size if we don't have it yet
curr.cycleh = curr.cycleh || $(curr).height();
curr.cyclew = curr.cyclew || $(curr).width();
next.cycleh = next.cycleh || $(next).height();
next.cyclew = next.cyclew || $(next).width();
// support multiple transition types
if (opts.multifx) {
if (fwd && (opts.lastfx === undefined || ++opts.lastfx >= opts.fxs.length))
opts.lastfx = 0;
else if (!fwd && (opts.lastfx === undefined || --opts.lastfx < 0))
opts.lastfx = opts.fxs.length - 1;
fx = opts.fxs[opts.lastfx];
}
// one-time fx overrides apply to: $('div').cycle(3,'zoom');
if (opts.onetimefx) {
fx = opts.onetimefx;
opts.onetimefx = null;
}
$.fn.cycle.resetstate(opts, fx);
// run the before callbacks
if (opts.before.length)
$.each(opts.before, function(i,o) {
if (p.cyclestop != opts.stopcount) return;
o.apply(next, [curr, next, opts, fwd]);
});
// stage the after callacks
var after = function() {
opts.busy = 0;
$.each(opts.after, function(i,o) {
if (p.cyclestop != opts.stopcount) return;
o.apply(next, [curr, next, opts, fwd]);
});
if (!p.cyclestop) {
// queue next transition
queuenext();
}
};
debug('tx firing('+fx+'); currslide: ' + opts.currslide + '; nextslide: ' + opts.nextslide);
// get ready to perform the transition
opts.busy = 1;
if (opts.fxfn) // fx function provided?
opts.fxfn(curr, next, opts, after, fwd, manual && opts.fastonevent);
else if ($.isfunction($.fn.cycle[opts.fx])) // fx plugin ?
$.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastonevent);
else
$.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastonevent);
}
else {
queuenext();
}
if (changed || opts.nextslide == opts.currslide) {
// calculate the next slide
var roll;
opts.lastslide = opts.currslide;
if (opts.random) {
opts.currslide = opts.nextslide;
if (++opts.randomindex == els.length) {
opts.randomindex = 0;
opts.randommap.sort(function(a,b) {return math.random() - 0.5;});
}
opts.nextslide = opts.randommap[opts.randomindex];
if (opts.nextslide == opts.currslide)
opts.nextslide = (opts.currslide == opts.slidecount - 1) ? 0 : opts.currslide + 1;
}
else if (opts.backwards) {
roll = (opts.nextslide - 1) < 0;
if (roll && opts.bounce) {
opts.backwards = !opts.backwards;
opts.nextslide = 1;
opts.currslide = 0;
}
else {
opts.nextslide = roll ? (els.length-1) : opts.nextslide-1;
opts.currslide = roll ? 0 : opts.nextslide+1;
}
}
else { // sequence
roll = (opts.nextslide + 1) == els.length;
if (roll && opts.bounce) {
opts.backwards = !opts.backwards;
opts.nextslide = els.length-2;
opts.currslide = els.length-1;
}
else {
opts.nextslide = roll ? 0 : opts.nextslide+1;
opts.currslide = roll ? els.length-1 : opts.nextslide-1;
}
}
}
if (changed && opts.pager)
opts.updateactivepagerlink(opts.pager, opts.currslide, opts.activepagerclass);
function queuenext() {
// stage the next transition
var ms = 0, timeout = opts.timeout;
if (opts.timeout && !opts.continuous) {
ms = gettimeout(els[opts.currslide], els[opts.nextslide], opts, fwd);
if (opts.fx == 'shuffle')
ms -= opts.speedout;
}
else if (opts.continuous && p.cyclepause) // continuous shows work off an after callback, not this timer logic
ms = 10;
if (ms > 0)
p.cycletimeout = settimeout(function(){ go(els, opts, 0, !opts.backwards); }, ms);
}
}
// invoked after transition
$.fn.cycle.updateactivepagerlink = function(pager, currslide, clsname) {
$(pager).each(function() {
$(this).children().removeclass(clsname).eq(currslide).addclass(clsname);
});
};
// calculate timeout value for current transition
function gettimeout(curr, next, opts, fwd) {
if (opts.timeoutfn) {
// call user provided calc fn
var t = opts.timeoutfn.call(curr,curr,next,opts,fwd);
while (opts.fx != 'none' && (t - opts.speed) < 250) // sanitize timeout
t += opts.speed;
debug('calculated timeout: ' + t + '; speed: ' + opts.speed);
if (t !== false)
return t;
}
return opts.timeout;
}
// expose next/prev function, caller must pass in state
$.fn.cycle.next = function(opts) { advance(opts,1); };
$.fn.cycle.prev = function(opts) { advance(opts,0);};
// advance slide forward or back
function advance(opts, moveforward) {
var val = moveforward ? 1 : -1;
var els = opts.elements;
var p = opts.$cont[0], timeout = p.cycletimeout;
if (timeout) {
cleartimeout(timeout);
p.cycletimeout = 0;
}
if (opts.random && val < 0) {
// move back to the previously display slide
opts.randomindex--;
if (--opts.randomindex == -2)
opts.randomindex = els.length-2;
else if (opts.randomindex == -1)
opts.randomindex = els.length-1;
opts.nextslide = opts.randommap[opts.randomindex];
}
else if (opts.random) {
opts.nextslide = opts.randommap[opts.randomindex];
}
else {
opts.nextslide = opts.currslide + val;
if (opts.nextslide < 0) {
if (opts.nowrap) return false;
opts.nextslide = els.length - 1;
}
else if (opts.nextslide >= els.length) {
if (opts.nowrap) return false;
opts.nextslide = 0;
}
}
var cb = opts.onprevnextevent || opts.prevnextclick; // prevnextclick is deprecated
if ($.isfunction(cb))
cb(val > 0, opts.nextslide, els[opts.nextslide]);
go(els, opts, 1, moveforward);
return false;
}
function buildpager(els, opts) {
var $p = $(opts.pager);
$.each(els, function(i,o) {
$.fn.cycle.createpageranchor(i,o,$p,els,opts);
});
opts.updateactivepagerlink(opts.pager, opts.startingslide, opts.activepagerclass);
}
$.fn.cycle.createpageranchor = function(i, el, $p, els, opts) {
var a;
if ($.isfunction(opts.pageranchorbuilder)) {
a = opts.pageranchorbuilder(i,el);
debug('pageranchorbuilder('+i+', el) returned: ' + a);
}
else
a = ''+(i+1)+'';
if (!a)
return;
var $a = $(a);
// don't reparent if anchor is in the dom
if ($a.parents('body').length === 0) {
var arr = [];
if ($p.length > 1) {
$p.each(function() {
var $clone = $a.clone(true);
$(this).append($clone);
arr.push($clone[0]);
});
$a = $(arr);
}
else {
$a.appendto($p);
}
}
opts.pageranchors = opts.pageranchors || [];
opts.pageranchors.push($a);
var pagerfn = function(e) {
e.preventdefault();
opts.nextslide = i;
var p = opts.$cont[0], timeout = p.cycletimeout;
if (timeout) {
cleartimeout(timeout);
p.cycletimeout = 0;
}
var cb = opts.onpagerevent || opts.pagerclick; // pagerclick is deprecated
if ($.isfunction(cb))
cb(opts.nextslide, els[opts.nextslide]);
go(els,opts,1,opts.currslide < i); // trigger the trans
// return false; // <== allow bubble
};
if ( /mouseenter|mouseover/i.test(opts.pagerevent) ) {
$a.hover(pagerfn, function(){/* no-op */} );
}
else {
$a.bind(opts.pagerevent, pagerfn);
}
if ( ! /^click/.test(opts.pagerevent) && !opts.allowpagerclickbubble)
$a.bind('click.cycle', function(){return false;}); // suppress click
var cont = opts.$cont[0];
var pauseflag = false; // https://github.com/malsup/cycle/issues/44
if (opts.pauseonpagerhover) {
$a.hover(
function() {
pauseflag = true;
cont.cyclepause++;
triggerpause(cont,true,true);
}, function() {
if (pauseflag)
cont.cyclepause--;
triggerpause(cont,true,true);
}
);
}
};
// helper fn to calculate the number of slides between the current and the next
$.fn.cycle.hopsfromlast = function(opts, fwd) {
var hops, l = opts.lastslide, c = opts.currslide;
if (fwd)
hops = c > l ? c - l : opts.slidecount - l;
else
hops = c < l ? l - c : l + opts.slidecount - c;
return hops;
};
// fix cleartype problems in ie6 by setting an explicit bg color
// (otherwise text slides look horrible during a fade transition)
function cleartypefix($slides) {
debug('applying cleartype background-color hack');
function hex(s) {
s = parseint(s,10).tostring(16);
return s.length < 2 ? '0'+s : s;
}
function getbg(e) {
for ( ; e && e.nodename.tolowercase() != 'html'; e = e.parentnode) {
var v = $.css(e,'background-color');
if (v && v.indexof('rgb') >= 0 ) {
var rgb = v.match(/\d+/g);
return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
}
if (v && v != 'transparent')
return v;
}
return '#ffffff';
}
$slides.each(function() { $(this).css('background-color', getbg(this)); });
}
// reset common props before the next transition
$.fn.cycle.commonreset = function(curr,next,opts,w,h,rev) {
$(opts.elements).not(curr).hide();
if (typeof opts.cssbefore.opacity == 'undefined')
opts.cssbefore.opacity = 1;
opts.cssbefore.display = 'block';
if (opts.slideresize && w !== false && next.cyclew > 0)
opts.cssbefore.width = next.cyclew;
if (opts.slideresize && h !== false && next.cycleh > 0)
opts.cssbefore.height = next.cycleh;
opts.cssafter = opts.cssafter || {};
opts.cssafter.display = 'none';
$(curr).css('zindex',opts.slidecount + (rev === true ? 1 : 0));
$(next).css('zindex',opts.slidecount + (rev === true ? 0 : 1));
};
// the actual fn for effecting a transition
$.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedoverride) {
var $l = $(curr), $n = $(next);
var speedin = opts.speedin, speedout = opts.speedout, easein = opts.easein, easeout = opts.easeout, animindelay = opts.animindelay, animoutdelay = opts.animoutdelay;
$n.css(opts.cssbefore);
if (speedoverride) {
if (typeof speedoverride == 'number')
speedin = speedout = speedoverride;
else
speedin = speedout = 1;
easein = easeout = null;
}
var fn = function() {
$n.delay(animindelay).animate(opts.animin, speedin, easein, function() {
cb();
});
};
$l.delay(animoutdelay).animate(opts.animout, speedout, easeout, function() {
$l.css(opts.cssafter);
if (!opts.sync)
fn();
});
if (opts.sync) fn();
};
// transition definitions - only fade is defined here, transition pack defines the rest
$.fn.cycle.transitions = {
fade: function($cont, $slides, opts) {
$slides.not(':eq('+opts.currslide+')').css('opacity',0);
opts.before.push(function(curr,next,opts) {
$.fn.cycle.commonreset(curr,next,opts);
opts.cssbefore.opacity = 0;
});
opts.animin = { opacity: 1 };
opts.animout = { opacity: 0 };
opts.cssbefore = { top: 0, left: 0 };
}
};
$.fn.cycle.ver = function() { return ver; };
// override these globally if you like (they are all optional)
$.fn.cycle.defaults = {
activepagerclass: 'activeslide', // class name used for the active pager link
after: null, // transition callback (scope set to element that was shown): function(currslideelement, nextslideelement, options, forwardflag)
allowpagerclickbubble: false, // allows or prevents click event on pager anchors from bubbling
animin: null, // properties that define how the slide animates in
animindelay: 0, // allows delay before next slide transitions in
animout: null, // properties that define how the slide animates out
animoutdelay: 0, // allows delay before current slide transitions out
aspect: false, // preserve aspect ratio during fit resizing, cropping if necessary (must be used with fit option)
autostop: 0, // true to end slideshow after x transitions (where x == slide count)
autostopcount: 0, // number of transitions (optionally used with autostop to define x)
backwards: false, // true to start slideshow at last slide and move backwards through the stack
before: null, // transition callback (scope set to element to be shown): function(currslideelement, nextslideelement, options, forwardflag)
center: null, // set to true to have cycle add top/left margin to each slide (use with width and height options)
cleartype: !$.support.opacity, // true if cleartype corrections should be applied (for ie)
cleartypenobg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
containerresize: 1, // resize container to fit largest slide
containerresizeheight: 0, // resize containers height to fit the largest slide but leave the width dynamic
continuous: 0, // true to start next transition immediately after current one completes
cssafter: null, // properties that defined the state of the slide after transitioning out
cssbefore: null, // properties that define the initial state of the slide before transitioning in
delay: 0, // additional delay (in ms) for first transition (hint: can be negative)
easein: null, // easing for "in" transition
easeout: null, // easing for "out" transition
easing: null, // easing method for both in and out transitions
end: null, // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options)
fastonevent: 0, // force fast transitions when triggered manually (via pager or prev/next); value == time in ms
fit: 0, // force slides to fit container
fx: 'fade', // name of transition effect (or comma separated names, ex: 'fade,scrollup,shuffle')
fxfn: null, // function used to control the transition: function(currslideelement, nextslideelement, options, aftercalback, forwardflag)
height: 'auto', // container height (if the 'fit' option is true, the slides will be set to this height as well)
manualtrump: true, // causes manual transition to stop an active transition instead of being ignored
metaattr: 'cycle', // data- attribute that holds the option data for the slideshow
next: null, // element, jquery object, or jquery selector string for the element to use as event trigger for next slide
nowrap: 0, // true to prevent slideshow from wrapping
onpagerevent: null, // callback fn for pager events: function(zerobasedslideindex, slideelement)
onprevnextevent: null, // callback fn for prev/next events: function(isnext, zerobasedslideindex, slideelement)
pager: null, // element, jquery object, or jquery selector string for the element to use as pager container
pageranchorbuilder: null, // callback fn for building anchor links: function(index, domelement)
pagerevent: 'click.cycle', // name of event which drives the pager navigation
pause: 0, // true to enable "pause on hover"
pauseonpagerhover: 0, // true to pause when hovering over pager link
prev: null, // element, jquery object, or jquery selector string for the element to use as event trigger for previous slide
prevnextevent: 'click.cycle',// event which drives the manual transition to the previous or next slide
random: 0, // true for random, false for sequence (not applicable to shuffle fx)
randomizeeffects: 1, // valid when multiple effects are used; true to make the effect sequence random
requeueonimagenotloaded: true, // requeue the slideshow if any image slides are not yet loaded
requeuetimeout: 250, // ms delay for requeue
rev: 0, // causes animations to transition in reverse (for effects that support it such as scrollhorz/scrollvert/shuffle)
shuffle: null, // coords for shuffle animation, ex: { top:15, left: 200 }
skipinitializationcallbacks: false, // set to true to disable the first before/after callback that occurs prior to any transition
slideexpr: null, // expression for selecting slides (if something other than all children is required)
slideresize: 1, // force slide width/height to fixed size before every transition
speed: 1000, // speed of the transition (any valid fx speed value)
speedin: null, // speed of the 'in' transition
speedout: null, // speed of the 'out' transition
startingslide: undefined,// zero-based index of the first slide to be displayed
sync: 1, // true if in/out transitions should occur simultaneously
timeout: 4000, // milliseconds between slide transitions (0 to disable auto advance)
timeoutfn: null, // callback for determining per-slide timeout value: function(currslideelement, nextslideelement, options, forwardflag)
updateactivepagerlink: null,// callback fn invoked to update the active pager link (adds/removes activepagerclass style)
width: null // container width (if the 'fit' option is true, the slides will be set to this width as well)
};
})(jquery);
/*!
* jquery cycle plugin transition definitions
* this script is a plugin for the jquery cycle plugin
* examples and documentation at: http://malsup.com/jquery/cycle/
* copyright (c) 2007-2010 m. alsup
* version: 2.73
* dual licensed under the mit and gpl licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function($) {
"use strict";
//
// these functions define slide initialization and properties for the named
// transitions. to save file size feel free to remove any of these that you
// don't need.
//
$.fn.cycle.transitions.none = function($cont, $slides, opts) {
opts.fxfn = function(curr,next,opts,after){
$(next).show();
$(curr).hide();
after();
};
};
// not a cross-fade, fadeout only fades out the top slide
$.fn.cycle.transitions.fadeout = function($cont, $slides, opts) {
$slides.not(':eq('+opts.currslide+')').css({ display: 'block', 'opacity': 1 });
opts.before.push(function(curr,next,opts,w,h,rev) {
$(curr).css('zindex',opts.slidecount + (rev !== true ? 1 : 0));
$(next).css('zindex',opts.slidecount + (rev !== true ? 0 : 1));
});
opts.animin.opacity = 1;
opts.animout.opacity = 0;
opts.cssbefore.opacity = 1;
opts.cssbefore.display = 'block';
opts.cssafter.zindex = 0;
};
// scrollup/down/left/right
$.fn.cycle.transitions.scrollup = function($cont, $slides, opts) {
$cont.css('overflow','hidden');
opts.before.push($.fn.cycle.commonreset);
var h = $cont.height();
opts.cssbefore.top = h;
opts.cssbefore.left = 0;
opts.cssfirst.top = 0;
opts.animin.top = 0;
opts.animout.top = -h;
};
$.fn.cycle.transitions.scrolldown = function($cont, $slides, opts) {
$cont.css('overflow','hidden');
opts.before.push($.fn.cycle.commonreset);
var h = $cont.height();
opts.cssfirst.top = 0;
opts.cssbefore.top = -h;
opts.cssbefore.left = 0;
opts.animin.top = 0;
opts.animout.top = h;
};
$.fn.cycle.transitions.scrollleft = function($cont, $slides, opts) {
$cont.css('overflow','hidden');
opts.before.push($.fn.cycle.commonreset);
var w = $cont.width();
opts.cssfirst.left = 0;
opts.cssbefore.left = w;
opts.cssbefore.top = 0;
opts.animin.left = 0;
opts.animout.left = 0-w;
};
$.fn.cycle.transitions.scrollright = function($cont, $slides, opts) {
$cont.css('overflow','hidden');
opts.before.push($.fn.cycle.commonreset);
var w = $cont.width();
opts.cssfirst.left = 0;
opts.cssbefore.left = -w;
opts.cssbefore.top = 0;
opts.animin.left = 0;
opts.animout.left = w;
};
$.fn.cycle.transitions.scrollhorz = function($cont, $slides, opts) {
$cont.css('overflow','hidden').width();
opts.before.push(function(curr, next, opts, fwd) {
if (opts.rev)
fwd = !fwd;
$.fn.cycle.commonreset(curr,next,opts);
opts.cssbefore.left = fwd ? (next.cyclew-1) : (1-next.cyclew);
opts.animout.left = fwd ? -curr.cyclew : curr.cyclew;
});
opts.cssfirst.left = 0;
opts.cssbefore.top = 0;
opts.animin.left = 0;
opts.animout.top = 0;
};
$.fn.cycle.transitions.scrollvert = function($cont, $slides, opts) {
$cont.css('overflow','hidden');
opts.before.push(function(curr, next, opts, fwd) {
if (opts.rev)
fwd = !fwd;
$.fn.cycle.commonreset(curr,next,opts);
opts.cssbefore.top = fwd ? (1-next.cycleh) : (next.cycleh-1);
opts.animout.top = fwd ? curr.cycleh : -curr.cycleh;
});
opts.cssfirst.top = 0;
opts.cssbefore.left = 0;
opts.animin.top = 0;
opts.animout.left = 0;
};
// slidex/slidey
$.fn.cycle.transitions.slidex = function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts) {
$(opts.elements).not(curr).hide();
$.fn.cycle.commonreset(curr,next,opts,false,true);
opts.animin.width = next.cyclew;
});
opts.cssbefore.left = 0;
opts.cssbefore.top = 0;
opts.cssbefore.width = 0;
opts.animin.width = 'show';
opts.animout.width = 0;
};
$.fn.cycle.transitions.slidey = function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts) {
$(opts.elements).not(curr).hide();
$.fn.cycle.commonreset(curr,next,opts,true,false);
opts.animin.height = next.cycleh;
});
opts.cssbefore.left = 0;
opts.cssbefore.top = 0;
opts.cssbefore.height = 0;
opts.animin.height = 'show';
opts.animout.height = 0;
};
// shuffle
$.fn.cycle.transitions.shuffle = function($cont, $slides, opts) {
var i, w = $cont.css('overflow', 'visible').width();
$slides.css({left: 0, top: 0});
opts.before.push(function(curr,next,opts) {
$.fn.cycle.commonreset(curr,next,opts,true,true,true);
});
// only adjust speed once!
if (!opts.speedadjusted) {
opts.speed = opts.speed / 2; // shuffle has 2 transitions
opts.speedadjusted = true;
}
opts.random = 0;
opts.shuffle = opts.shuffle || {left:-w, top:15};
opts.els = [];
for (i=0; i < $slides.length; i++)
opts.els.push($slides[i]);
for (i=0; i < opts.currslide; i++)
opts.els.push(opts.els.shift());
// custom transition fn (hat tip to benjamin sterling for this bit of sweetness!)
opts.fxfn = function(curr, next, opts, cb, fwd) {
if (opts.rev)
fwd = !fwd;
var $el = fwd ? $(curr) : $(next);
$(next).css(opts.cssbefore);
var count = opts.slidecount;
$el.animate(opts.shuffle, opts.speedin, opts.easein, function() {
var hops = $.fn.cycle.hopsfromlast(opts, fwd);
for (var k=0; k < hops; k++) {
if (fwd)
opts.els.push(opts.els.shift());
else
opts.els.unshift(opts.els.pop());
}
if (fwd) {
for (var i=0, len=opts.els.length; i < len; i++)
$(opts.els[i]).css('z-index', len-i+count);
}
else {
var z = $(curr).css('z-index');
$el.css('z-index', parseint(z,10)+1+count);
}
$el.animate({left:0, top:0}, opts.speedout, opts.easeout, function() {
$(fwd ? this : curr).hide();
if (cb) cb();
});
});
};
$.extend(opts.cssbefore, { display: 'block', opacity: 1, top: 0, left: 0 });
};
// turnup/down/left/right
$.fn.cycle.transitions.turnup = function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts,true,false);
opts.cssbefore.top = next.cycleh;
opts.animin.height = next.cycleh;
opts.animout.width = next.cyclew;
});
opts.cssfirst.top = 0;
opts.cssbefore.left = 0;
opts.cssbefore.height = 0;
opts.animin.top = 0;
opts.animout.height = 0;
};
$.fn.cycle.transitions.turndown = function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts,true,false);
opts.animin.height = next.cycleh;
opts.animout.top = curr.cycleh;
});
opts.cssfirst.top = 0;
opts.cssbefore.left = 0;
opts.cssbefore.top = 0;
opts.cssbefore.height = 0;
opts.animout.height = 0;
};
$.fn.cycle.transitions.turnleft = function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts,false,true);
opts.cssbefore.left = next.cyclew;
opts.animin.width = next.cyclew;
});
opts.cssbefore.top = 0;
opts.cssbefore.width = 0;
opts.animin.left = 0;
opts.animout.width = 0;
};
$.fn.cycle.transitions.turnright = function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts,false,true);
opts.animin.width = next.cyclew;
opts.animout.left = curr.cyclew;
});
$.extend(opts.cssbefore, { top: 0, left: 0, width: 0 });
opts.animin.left = 0;
opts.animout.width = 0;
};
// zoom
$.fn.cycle.transitions.zoom = function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts,false,false,true);
opts.cssbefore.top = next.cycleh/2;
opts.cssbefore.left = next.cyclew/2;
$.extend(opts.animin, { top: 0, left: 0, width: next.cyclew, height: next.cycleh });
$.extend(opts.animout, { width: 0, height: 0, top: curr.cycleh/2, left: curr.cyclew/2 });
});
opts.cssfirst.top = 0;
opts.cssfirst.left = 0;
opts.cssbefore.width = 0;
opts.cssbefore.height = 0;
};
// fadezoom
$.fn.cycle.transitions.fadezoom = function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts,false,false);
opts.cssbefore.left = next.cyclew/2;
opts.cssbefore.top = next.cycleh/2;
$.extend(opts.animin, { top: 0, left: 0, width: next.cyclew, height: next.cycleh });
});
opts.cssbefore.width = 0;
opts.cssbefore.height = 0;
opts.animout.opacity = 0;
};
// blindx
$.fn.cycle.transitions.blindx = function($cont, $slides, opts) {
var w = $cont.css('overflow','hidden').width();
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts);
opts.animin.width = next.cyclew;
opts.animout.left = curr.cyclew;
});
opts.cssbefore.left = w;
opts.cssbefore.top = 0;
opts.animin.left = 0;
opts.animout.left = w;
};
// blindy
$.fn.cycle.transitions.blindy = function($cont, $slides, opts) {
var h = $cont.css('overflow','hidden').height();
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts);
opts.animin.height = next.cycleh;
opts.animout.top = curr.cycleh;
});
opts.cssbefore.top = h;
opts.cssbefore.left = 0;
opts.animin.top = 0;
opts.animout.top = h;
};
// blindz
$.fn.cycle.transitions.blindz = function($cont, $slides, opts) {
var h = $cont.css('overflow','hidden').height();
var w = $cont.width();
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts);
opts.animin.height = next.cycleh;
opts.animout.top = curr.cycleh;
});
opts.cssbefore.top = h;
opts.cssbefore.left = w;
opts.animin.top = 0;
opts.animin.left = 0;
opts.animout.top = h;
opts.animout.left = w;
};
// growx - grow horizontally from centered 0 width
$.fn.cycle.transitions.growx = function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts,false,true);
opts.cssbefore.left = this.cyclew/2;
opts.animin.left = 0;
opts.animin.width = this.cyclew;
opts.animout.left = 0;
});
opts.cssbefore.top = 0;
opts.cssbefore.width = 0;
};
// growy - grow vertically from centered 0 height
$.fn.cycle.transitions.growy = function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts,true,false);
opts.cssbefore.top = this.cycleh/2;
opts.animin.top = 0;
opts.animin.height = this.cycleh;
opts.animout.top = 0;
});
opts.cssbefore.height = 0;
opts.cssbefore.left = 0;
};
// curtainx - squeeze in both edges horizontally
$.fn.cycle.transitions.curtainx = function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts,false,true,true);
opts.cssbefore.left = next.cyclew/2;
opts.animin.left = 0;
opts.animin.width = this.cyclew;
opts.animout.left = curr.cyclew/2;
opts.animout.width = 0;
});
opts.cssbefore.top = 0;
opts.cssbefore.width = 0;
};
// curtainy - squeeze in both edges vertically
$.fn.cycle.transitions.curtainy = function($cont, $slides, opts) {
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts,true,false,true);
opts.cssbefore.top = next.cycleh/2;
opts.animin.top = 0;
opts.animin.height = next.cycleh;
opts.animout.top = curr.cycleh/2;
opts.animout.height = 0;
});
opts.cssbefore.height = 0;
opts.cssbefore.left = 0;
};
// cover - curr slide covered by next slide
$.fn.cycle.transitions.cover = function($cont, $slides, opts) {
var d = opts.direction || 'left';
var w = $cont.css('overflow','hidden').width();
var h = $cont.height();
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts);
opts.cssafter.display = '';
if (d == 'right')
opts.cssbefore.left = -w;
else if (d == 'up')
opts.cssbefore.top = h;
else if (d == 'down')
opts.cssbefore.top = -h;
else
opts.cssbefore.left = w;
});
opts.animin.left = 0;
opts.animin.top = 0;
opts.cssbefore.top = 0;
opts.cssbefore.left = 0;
};
// uncover - curr slide moves off next slide
$.fn.cycle.transitions.uncover = function($cont, $slides, opts) {
var d = opts.direction || 'left';
var w = $cont.css('overflow','hidden').width();
var h = $cont.height();
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts,true,true,true);
if (d == 'right')
opts.animout.left = w;
else if (d == 'up')
opts.animout.top = -h;
else if (d == 'down')
opts.animout.top = h;
else
opts.animout.left = -w;
});
opts.animin.left = 0;
opts.animin.top = 0;
opts.cssbefore.top = 0;
opts.cssbefore.left = 0;
};
// toss - move top slide and fade away
$.fn.cycle.transitions.toss = function($cont, $slides, opts) {
var w = $cont.css('overflow','visible').width();
var h = $cont.height();
opts.before.push(function(curr, next, opts) {
$.fn.cycle.commonreset(curr,next,opts,true,true,true);
// provide default toss settings if animout not provided
if (!opts.animout.left && !opts.animout.top)
$.extend(opts.animout, { left: w*2, top: -h/2, opacity: 0 });
else
opts.animout.opacity = 0;
});
opts.cssbefore.left = 0;
opts.cssbefore.top = 0;
opts.animin.left = 0;
};
// wipe - clip animation
$.fn.cycle.transitions.wipe = function($cont, $slides, opts) {
var w = $cont.css('overflow','hidden').width();
var h = $cont.height();
opts.cssbefore = opts.cssbefore || {};
var clip;
if (opts.clip) {
if (/l2r/.test(opts.clip))
clip = 'rect(0px 0px '+h+'px 0px)';
else if (/r2l/.test(opts.clip))
clip = 'rect(0px '+w+'px '+h+'px '+w+'px)';
else if (/t2b/.test(opts.clip))
clip = 'rect(0px '+w+'px 0px 0px)';
else if (/b2t/.test(opts.clip))
clip = 'rect('+h+'px '+w+'px '+h+'px 0px)';
else if (/zoom/.test(opts.clip)) {
var top = parseint(h/2,10);
var left = parseint(w/2,10);
clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)';
}
}
opts.cssbefore.clip = opts.cssbefore.clip || clip || 'rect(0px 0px 0px 0px)';
var d = opts.cssbefore.clip.match(/(\d+)/g);
var t = parseint(d[0],10), r = parseint(d[1],10), b = parseint(d[2],10), l = parseint(d[3],10);
opts.before.push(function(curr, next, opts) {
if (curr == next) return;
var $curr = $(curr), $next = $(next);
$.fn.cycle.commonreset(curr,next,opts,true,true,false);
opts.cssafter.display = 'block';
var step = 1, count = parseint((opts.speedin / 13),10) - 1;
(function f() {
var tt = t ? t - parseint(step * (t/count),10) : 0;
var ll = l ? l - parseint(step * (l/count),10) : 0;
var bb = b < h ? b + parseint(step * ((h-b)/count || 1),10) : h;
var rr = r < w ? r + parseint(step * ((w-r)/count || 1),10) : w;
$next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' });
(step++ <= count) ? settimeout(f, 13) : $curr.css('display', 'none');
})();
});
$.extend(opts.cssbefore, { display: 'block', opacity: 1, top: 0, left: 0 });
opts.animin = { left: 0 };
opts.animout = { left: 0 };
};
})(jquery);