bgneal@693: /*! bgneal@693: * jQuery Cycle Plugin (with Transition Definitions) bgneal@693: * Examples and documentation at: http://jquery.malsup.com/cycle/ bgneal@693: * Copyright (c) 2007-2013 M. Alsup bgneal@693: * Version: 3.0.3 (11-JUL-2013) bgneal@693: * Dual licensed under the MIT and GPL licenses. bgneal@693: * http://jquery.malsup.com/license.html bgneal@693: * Requires: jQuery v1.7.1 or later bgneal@693: */ bgneal@693: ;(function($, undefined) { bgneal@693: "use strict"; bgneal@693: bgneal@693: var ver = '3.0.3'; bgneal@693: bgneal@693: function debug(s) { bgneal@693: if ($.fn.cycle.debug) bgneal@693: log(s); bgneal@693: } bgneal@693: function log() { bgneal@693: /*global console */ bgneal@693: if (window.console && console.log) bgneal@693: console.log('[cycle] ' + Array.prototype.join.call(arguments,' ')); bgneal@693: } bgneal@693: $.expr[':'].paused = function(el) { bgneal@693: return el.cyclePause; bgneal@693: }; bgneal@693: bgneal@693: bgneal@693: // the options arg can be... bgneal@693: // a number - indicates an immediate transition should occur to the given slide index bgneal@693: // a string - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc) bgneal@693: // an object - properties to control the slideshow bgneal@693: // bgneal@693: // the arg2 arg can be... bgneal@693: // the name of an fx (only used in conjunction with a numeric value for 'options') bgneal@693: // the value true (only used in first arg == 'resume') and indicates bgneal@693: // that the resume should occur immediately (not wait for next timeout) bgneal@693: bgneal@693: $.fn.cycle = function(options, arg2) { bgneal@693: var o = { s: this.selector, c: this.context }; bgneal@693: bgneal@693: // in 1.3+ we can fix mistakes with the ready state bgneal@693: if (this.length === 0 && options != 'stop') { bgneal@693: if (!$.isReady && o.s) { bgneal@693: log('DOM not ready, queuing slideshow'); bgneal@693: $(function() { bgneal@693: $(o.s,o.c).cycle(options,arg2); bgneal@693: }); bgneal@693: return this; bgneal@693: } bgneal@693: // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready() bgneal@693: log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); bgneal@693: return this; bgneal@693: } bgneal@693: bgneal@693: // iterate the matched nodeset bgneal@693: return this.each(function() { bgneal@693: var opts = handleArguments(this, options, arg2); bgneal@693: if (opts === false) bgneal@693: return; bgneal@693: bgneal@693: opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink; bgneal@693: bgneal@693: // stop existing slideshow for this container (if there is one) bgneal@693: if (this.cycleTimeout) bgneal@693: clearTimeout(this.cycleTimeout); bgneal@693: this.cycleTimeout = this.cyclePause = 0; bgneal@693: this.cycleStop = 0; // issue #108 bgneal@693: bgneal@693: var $cont = $(this); bgneal@693: var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children(); bgneal@693: var els = $slides.get(); bgneal@693: bgneal@693: if (els.length < 2) { bgneal@693: log('terminating; too few slides: ' + els.length); bgneal@693: return; bgneal@693: } bgneal@693: bgneal@693: var opts2 = buildOptions($cont, $slides, els, opts, o); bgneal@693: if (opts2 === false) bgneal@693: return; bgneal@693: bgneal@693: var startTime = opts2.continuous ? 10 : getTimeout(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.backwards); bgneal@693: bgneal@693: // if it's an auto slideshow, kick it off bgneal@693: if (startTime) { bgneal@693: startTime += (opts2.delay || 0); bgneal@693: if (startTime < 10) bgneal@693: startTime = 10; bgneal@693: debug('first timeout: ' + startTime); bgneal@693: this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts.backwards);}, startTime); bgneal@693: } bgneal@693: }); bgneal@693: }; bgneal@693: bgneal@693: function triggerPause(cont, byHover, onPager) { bgneal@693: var opts = $(cont).data('cycle.opts'); bgneal@693: if (!opts) bgneal@693: return; bgneal@693: var paused = !!cont.cyclePause; bgneal@693: if (paused && opts.paused) bgneal@693: opts.paused(cont, opts, byHover, onPager); bgneal@693: else if (!paused && opts.resumed) bgneal@693: opts.resumed(cont, opts, byHover, onPager); bgneal@693: } bgneal@693: bgneal@693: // process the args that were passed to the plugin fn bgneal@693: function handleArguments(cont, options, arg2) { bgneal@693: if (cont.cycleStop === undefined) bgneal@693: cont.cycleStop = 0; bgneal@693: if (options === undefined || options === null) bgneal@693: options = {}; bgneal@693: if (options.constructor == String) { bgneal@693: switch(options) { bgneal@693: case 'destroy': bgneal@693: case 'stop': bgneal@693: var opts = $(cont).data('cycle.opts'); bgneal@693: if (!opts) bgneal@693: return false; bgneal@693: cont.cycleStop++; // callbacks look for change bgneal@693: if (cont.cycleTimeout) bgneal@693: clearTimeout(cont.cycleTimeout); bgneal@693: cont.cycleTimeout = 0; bgneal@693: if (opts.elements) bgneal@693: $(opts.elements).stop(); bgneal@693: $(cont).removeData('cycle.opts'); bgneal@693: if (options == 'destroy') bgneal@693: destroy(cont, opts); bgneal@693: return false; bgneal@693: case 'toggle': bgneal@693: cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1; bgneal@693: checkInstantResume(cont.cyclePause, arg2, cont); bgneal@693: triggerPause(cont); bgneal@693: return false; bgneal@693: case 'pause': bgneal@693: cont.cyclePause = 1; bgneal@693: triggerPause(cont); bgneal@693: return false; bgneal@693: case 'resume': bgneal@693: cont.cyclePause = 0; bgneal@693: checkInstantResume(false, arg2, cont); bgneal@693: triggerPause(cont); bgneal@693: return false; bgneal@693: case 'prev': bgneal@693: case 'next': bgneal@693: opts = $(cont).data('cycle.opts'); bgneal@693: if (!opts) { bgneal@693: log('options not found, "prev/next" ignored'); bgneal@693: return false; bgneal@693: } bgneal@693: if (typeof arg2 == 'string') bgneal@693: opts.oneTimeFx = arg2; bgneal@693: $.fn.cycle[options](opts); bgneal@693: return false; bgneal@693: default: bgneal@693: options = { fx: options }; bgneal@693: } bgneal@693: return options; bgneal@693: } bgneal@693: else if (options.constructor == Number) { bgneal@693: // go to the requested slide bgneal@693: var num = options; bgneal@693: options = $(cont).data('cycle.opts'); bgneal@693: if (!options) { bgneal@693: log('options not found, can not advance slide'); bgneal@693: return false; bgneal@693: } bgneal@693: if (num < 0 || num >= options.elements.length) { bgneal@693: log('invalid slide index: ' + num); bgneal@693: return false; bgneal@693: } bgneal@693: options.nextSlide = num; bgneal@693: if (cont.cycleTimeout) { bgneal@693: clearTimeout(cont.cycleTimeout); bgneal@693: cont.cycleTimeout = 0; bgneal@693: } bgneal@693: if (typeof arg2 == 'string') bgneal@693: options.oneTimeFx = arg2; bgneal@693: go(options.elements, options, 1, num >= options.currSlide); bgneal@693: return false; bgneal@693: } bgneal@693: return options; bgneal@693: bgneal@693: function checkInstantResume(isPaused, arg2, cont) { bgneal@693: if (!isPaused && arg2 === true) { // resume now! bgneal@693: var options = $(cont).data('cycle.opts'); bgneal@693: if (!options) { bgneal@693: log('options not found, can not resume'); bgneal@693: return false; bgneal@693: } bgneal@693: if (cont.cycleTimeout) { bgneal@693: clearTimeout(cont.cycleTimeout); bgneal@693: cont.cycleTimeout = 0; bgneal@693: } bgneal@693: go(options.elements, options, 1, !options.backwards); bgneal@693: } bgneal@693: } bgneal@693: } bgneal@693: bgneal@693: function removeFilter(el, opts) { bgneal@693: if (!$.support.opacity && opts.cleartype && el.style.filter) { bgneal@693: try { el.style.removeAttribute('filter'); } bgneal@693: catch(smother) {} // handle old opera versions bgneal@693: } bgneal@693: } bgneal@693: bgneal@693: // unbind event handlers bgneal@693: function destroy(cont, opts) { bgneal@693: if (opts.next) bgneal@693: $(opts.next).unbind(opts.prevNextEvent); bgneal@693: if (opts.prev) bgneal@693: $(opts.prev).unbind(opts.prevNextEvent); bgneal@693: bgneal@693: if (opts.pager || opts.pagerAnchorBuilder) bgneal@693: $.each(opts.pagerAnchors || [], function() { bgneal@693: this.unbind().remove(); bgneal@693: }); bgneal@693: opts.pagerAnchors = null; bgneal@693: $(cont).unbind('mouseenter.cycle mouseleave.cycle'); bgneal@693: if (opts.destroy) // callback bgneal@693: opts.destroy(opts); bgneal@693: } bgneal@693: bgneal@693: // one-time initialization bgneal@693: function buildOptions($cont, $slides, els, options, o) { bgneal@693: var startingSlideSpecified; bgneal@693: // support metadata plugin (v1.0 and v2.0) bgneal@693: var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {}); bgneal@693: var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null; bgneal@693: if (meta) bgneal@693: opts = $.extend(opts, meta); bgneal@693: if (opts.autostop) bgneal@693: opts.countdown = opts.autostopCount || els.length; bgneal@693: bgneal@693: var cont = $cont[0]; bgneal@693: $cont.data('cycle.opts', opts); bgneal@693: opts.$cont = $cont; bgneal@693: opts.stopCount = cont.cycleStop; bgneal@693: opts.elements = els; bgneal@693: opts.before = opts.before ? [opts.before] : []; bgneal@693: opts.after = opts.after ? [opts.after] : []; bgneal@693: bgneal@693: // push some after callbacks bgneal@693: if (!$.support.opacity && opts.cleartype) bgneal@693: opts.after.push(function() { removeFilter(this, opts); }); bgneal@693: if (opts.continuous) bgneal@693: opts.after.push(function() { go(els,opts,0,!opts.backwards); }); bgneal@693: bgneal@693: saveOriginalOpts(opts); bgneal@693: bgneal@693: // clearType corrections bgneal@693: if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) bgneal@693: clearTypeFix($slides); bgneal@693: bgneal@693: // container requires non-static position so that slides can be position within bgneal@693: if ($cont.css('position') == 'static') bgneal@693: $cont.css('position', 'relative'); bgneal@693: if (opts.width) bgneal@693: $cont.width(opts.width); bgneal@693: if (opts.height && opts.height != 'auto') bgneal@693: $cont.height(opts.height); bgneal@693: bgneal@693: if (opts.startingSlide !== undefined) { bgneal@693: opts.startingSlide = parseInt(opts.startingSlide,10); bgneal@693: if (opts.startingSlide >= els.length || opts.startSlide < 0) bgneal@693: opts.startingSlide = 0; // catch bogus input bgneal@693: else bgneal@693: startingSlideSpecified = true; bgneal@693: } bgneal@693: else if (opts.backwards) bgneal@693: opts.startingSlide = els.length - 1; bgneal@693: else bgneal@693: opts.startingSlide = 0; bgneal@693: bgneal@693: // if random, mix up the slide array bgneal@693: if (opts.random) { bgneal@693: opts.randomMap = []; bgneal@693: for (var i = 0; i < els.length; i++) bgneal@693: opts.randomMap.push(i); bgneal@693: opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); bgneal@693: if (startingSlideSpecified) { bgneal@693: // try to find the specified starting slide and if found set start slide index in the map accordingly bgneal@693: for ( var cnt = 0; cnt < els.length; cnt++ ) { bgneal@693: if ( opts.startingSlide == opts.randomMap[cnt] ) { bgneal@693: opts.randomIndex = cnt; bgneal@693: } bgneal@693: } bgneal@693: } bgneal@693: else { bgneal@693: opts.randomIndex = 1; bgneal@693: opts.startingSlide = opts.randomMap[1]; bgneal@693: } bgneal@693: } bgneal@693: else if (opts.startingSlide >= els.length) bgneal@693: opts.startingSlide = 0; // catch bogus input bgneal@693: opts.currSlide = opts.startingSlide || 0; bgneal@693: var first = opts.startingSlide; bgneal@693: bgneal@693: // set position and zIndex on all the slides bgneal@693: $slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) { bgneal@693: var z; bgneal@693: if (opts.backwards) bgneal@693: z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i; bgneal@693: else bgneal@693: z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i; bgneal@693: $(this).css('z-index', z); bgneal@693: }); bgneal@693: bgneal@693: // make sure first slide is visible bgneal@693: $(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case bgneal@693: removeFilter(els[first], opts); bgneal@693: bgneal@693: // stretch slides bgneal@693: if (opts.fit) { bgneal@693: if (!opts.aspect) { bgneal@693: if (opts.width) bgneal@693: $slides.width(opts.width); bgneal@693: if (opts.height && opts.height != 'auto') bgneal@693: $slides.height(opts.height); bgneal@693: } else { bgneal@693: $slides.each(function(){ bgneal@693: var $slide = $(this); bgneal@693: var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect; bgneal@693: if( opts.width && $slide.width() != opts.width ) { bgneal@693: $slide.width( opts.width ); bgneal@693: $slide.height( opts.width / ratio ); bgneal@693: } bgneal@693: bgneal@693: if( opts.height && $slide.height() < opts.height ) { bgneal@693: $slide.height( opts.height ); bgneal@693: $slide.width( opts.height * ratio ); bgneal@693: } bgneal@693: }); bgneal@693: } bgneal@693: } bgneal@693: bgneal@693: if (opts.center && ((!opts.fit) || opts.aspect)) { bgneal@693: $slides.each(function(){ bgneal@693: var $slide = $(this); bgneal@693: $slide.css({ bgneal@693: "margin-left": opts.width ? bgneal@693: ((opts.width - $slide.width()) / 2) + "px" : bgneal@693: 0, bgneal@693: "margin-top": opts.height ? bgneal@693: ((opts.height - $slide.height()) / 2) + "px" : bgneal@693: 0 bgneal@693: }); bgneal@693: }); bgneal@693: } bgneal@693: bgneal@693: if (opts.center && !opts.fit && !opts.slideResize) { bgneal@693: $slides.each(function(){ bgneal@693: var $slide = $(this); bgneal@693: $slide.css({ bgneal@693: "margin-left": opts.width ? ((opts.width - $slide.width()) / 2) + "px" : 0, bgneal@693: "margin-top": opts.height ? ((opts.height - $slide.height()) / 2) + "px" : 0 bgneal@693: }); bgneal@693: }); bgneal@693: } bgneal@693: bgneal@693: // stretch container bgneal@693: var reshape = (opts.containerResize || opts.containerResizeHeight) && $cont.innerHeight() < 1; bgneal@693: if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9 bgneal@693: var maxw = 0, maxh = 0; bgneal@693: for(var j=0; j < els.length; j++) { bgneal@693: var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight(); bgneal@693: if (!w) w = e.offsetWidth || e.width || $e.attr('width'); bgneal@693: if (!h) h = e.offsetHeight || e.height || $e.attr('height'); bgneal@693: maxw = w > maxw ? w : maxw; bgneal@693: maxh = h > maxh ? h : maxh; bgneal@693: } bgneal@693: if (opts.containerResize && maxw > 0 && maxh > 0) bgneal@693: $cont.css({width:maxw+'px',height:maxh+'px'}); bgneal@693: if (opts.containerResizeHeight && maxh > 0) bgneal@693: $cont.css({height:maxh+'px'}); bgneal@693: } bgneal@693: bgneal@693: var pauseFlag = false; // https://github.com/malsup/cycle/issues/44 bgneal@693: if (opts.pause) bgneal@693: $cont.bind('mouseenter.cycle', function(){ bgneal@693: pauseFlag = true; bgneal@693: this.cyclePause++; bgneal@693: triggerPause(cont, true); bgneal@693: }).bind('mouseleave.cycle', function(){ bgneal@693: if (pauseFlag) bgneal@693: this.cyclePause--; bgneal@693: triggerPause(cont, true); bgneal@693: }); bgneal@693: bgneal@693: if (supportMultiTransitions(opts) === false) bgneal@693: return false; bgneal@693: bgneal@693: // apparently a lot of people use image slideshows without height/width attributes on the images. bgneal@693: // Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that. bgneal@693: var requeue = false; bgneal@693: options.requeueAttempts = options.requeueAttempts || 0; bgneal@693: $slides.each(function() { bgneal@693: // try to get height/width of each slide bgneal@693: var $el = $(this); bgneal@693: this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0); bgneal@693: this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0); bgneal@693: bgneal@693: if ( $el.is('img') ) { bgneal@693: var loading = (this.cycleH === 0 && this.cycleW === 0 && !this.complete); bgneal@693: // don't requeue for images that are still loading but have a valid size bgneal@693: if (loading) { bgneal@693: if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever bgneal@693: log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH); bgneal@693: setTimeout(function() {$(o.s,o.c).cycle(options);}, opts.requeueTimeout); bgneal@693: requeue = true; bgneal@693: return false; // break each loop bgneal@693: } bgneal@693: else { bgneal@693: log('could not determine size of image: '+this.src, this.cycleW, this.cycleH); bgneal@693: } bgneal@693: } bgneal@693: } bgneal@693: return true; bgneal@693: }); bgneal@693: bgneal@693: if (requeue) bgneal@693: return false; bgneal@693: bgneal@693: opts.cssBefore = opts.cssBefore || {}; bgneal@693: opts.cssAfter = opts.cssAfter || {}; bgneal@693: opts.cssFirst = opts.cssFirst || {}; bgneal@693: opts.animIn = opts.animIn || {}; bgneal@693: opts.animOut = opts.animOut || {}; bgneal@693: bgneal@693: $slides.not(':eq('+first+')').css(opts.cssBefore); bgneal@693: $($slides[first]).css(opts.cssFirst); bgneal@693: bgneal@693: if (opts.timeout) { bgneal@693: opts.timeout = parseInt(opts.timeout,10); bgneal@693: // ensure that timeout and speed settings are sane bgneal@693: if (opts.speed.constructor == String) bgneal@693: opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed,10); bgneal@693: if (!opts.sync) bgneal@693: opts.speed = opts.speed / 2; bgneal@693: bgneal@693: var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250; bgneal@693: while((opts.timeout - opts.speed) < buffer) // sanitize timeout bgneal@693: opts.timeout += opts.speed; bgneal@693: } bgneal@693: if (opts.easing) bgneal@693: opts.easeIn = opts.easeOut = opts.easing; bgneal@693: if (!opts.speedIn) bgneal@693: opts.speedIn = opts.speed; bgneal@693: if (!opts.speedOut) bgneal@693: opts.speedOut = opts.speed; bgneal@693: bgneal@693: opts.slideCount = els.length; bgneal@693: opts.currSlide = opts.lastSlide = first; bgneal@693: if (opts.random) { bgneal@693: if (++opts.randomIndex == els.length) bgneal@693: opts.randomIndex = 0; bgneal@693: opts.nextSlide = opts.randomMap[opts.randomIndex]; bgneal@693: } bgneal@693: else if (opts.backwards) bgneal@693: opts.nextSlide = opts.startingSlide === 0 ? (els.length-1) : opts.startingSlide-1; bgneal@693: else bgneal@693: opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1; bgneal@693: bgneal@693: // run transition init fn bgneal@693: if (!opts.multiFx) { bgneal@693: var init = $.fn.cycle.transitions[opts.fx]; bgneal@693: if ($.isFunction(init)) bgneal@693: init($cont, $slides, opts); bgneal@693: else if (opts.fx != 'custom' && !opts.multiFx) { bgneal@693: log('unknown transition: ' + opts.fx,'; slideshow terminating'); bgneal@693: return false; bgneal@693: } bgneal@693: } bgneal@693: bgneal@693: // fire artificial events bgneal@693: var e0 = $slides[first]; bgneal@693: if (!opts.skipInitializationCallbacks) { bgneal@693: if (opts.before.length) bgneal@693: opts.before[0].apply(e0, [e0, e0, opts, true]); bgneal@693: if (opts.after.length) bgneal@693: opts.after[0].apply(e0, [e0, e0, opts, true]); bgneal@693: } bgneal@693: if (opts.next) bgneal@693: $(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,1);}); bgneal@693: if (opts.prev) bgneal@693: $(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,0);}); bgneal@693: if (opts.pager || opts.pagerAnchorBuilder) bgneal@693: buildPager(els,opts); bgneal@693: bgneal@693: exposeAddSlide(opts, els); bgneal@693: bgneal@693: return opts; bgneal@693: } bgneal@693: bgneal@693: // save off original opts so we can restore after clearing state bgneal@693: function saveOriginalOpts(opts) { bgneal@693: opts.original = { before: [], after: [] }; bgneal@693: opts.original.cssBefore = $.extend({}, opts.cssBefore); bgneal@693: opts.original.cssAfter = $.extend({}, opts.cssAfter); bgneal@693: opts.original.animIn = $.extend({}, opts.animIn); bgneal@693: opts.original.animOut = $.extend({}, opts.animOut); bgneal@693: $.each(opts.before, function() { opts.original.before.push(this); }); bgneal@693: $.each(opts.after, function() { opts.original.after.push(this); }); bgneal@693: } bgneal@693: bgneal@693: function supportMultiTransitions(opts) { bgneal@693: var i, tx, txs = $.fn.cycle.transitions; bgneal@693: // look for multiple effects bgneal@693: if (opts.fx.indexOf(',') > 0) { bgneal@693: opts.multiFx = true; bgneal@693: opts.fxs = opts.fx.replace(/\s*/g,'').split(','); bgneal@693: // discard any bogus effect names bgneal@693: for (i=0; i < opts.fxs.length; i++) { bgneal@693: var fx = opts.fxs[i]; bgneal@693: tx = txs[fx]; bgneal@693: if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) { bgneal@693: log('discarding unknown transition: ',fx); bgneal@693: opts.fxs.splice(i,1); bgneal@693: i--; bgneal@693: } bgneal@693: } bgneal@693: // if we have an empty list then we threw everything away! bgneal@693: if (!opts.fxs.length) { bgneal@693: log('No valid transitions named; slideshow terminating.'); bgneal@693: return false; bgneal@693: } bgneal@693: } bgneal@693: else if (opts.fx == 'all') { // auto-gen the list of transitions bgneal@693: opts.multiFx = true; bgneal@693: opts.fxs = []; bgneal@693: for (var p in txs) { bgneal@693: if (txs.hasOwnProperty(p)) { bgneal@693: tx = txs[p]; bgneal@693: if (txs.hasOwnProperty(p) && $.isFunction(tx)) bgneal@693: opts.fxs.push(p); bgneal@693: } bgneal@693: } bgneal@693: } bgneal@693: if (opts.multiFx && opts.randomizeEffects) { bgneal@693: // munge the fxs array to make effect selection random bgneal@693: var r1 = Math.floor(Math.random() * 20) + 30; bgneal@693: for (i = 0; i < r1; i++) { bgneal@693: var r2 = Math.floor(Math.random() * opts.fxs.length); bgneal@693: opts.fxs.push(opts.fxs.splice(r2,1)[0]); bgneal@693: } bgneal@693: debug('randomized fx sequence: ',opts.fxs); bgneal@693: } bgneal@693: return true; bgneal@693: } bgneal@693: bgneal@693: // provide a mechanism for adding slides after the slideshow has started bgneal@693: function exposeAddSlide(opts, els) { bgneal@693: opts.addSlide = function(newSlide, prepend) { bgneal@693: var $s = $(newSlide), s = $s[0]; bgneal@693: if (!opts.autostopCount) bgneal@693: opts.countdown++; bgneal@693: els[prepend?'unshift':'push'](s); bgneal@693: if (opts.els) bgneal@693: opts.els[prepend?'unshift':'push'](s); // shuffle needs this bgneal@693: opts.slideCount = els.length; bgneal@693: bgneal@693: // add the slide to the random map and resort bgneal@693: if (opts.random) { bgneal@693: opts.randomMap.push(opts.slideCount-1); bgneal@693: opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); bgneal@693: } bgneal@693: bgneal@693: $s.css('position','absolute'); bgneal@693: $s[prepend?'prependTo':'appendTo'](opts.$cont); bgneal@693: bgneal@693: if (prepend) { bgneal@693: opts.currSlide++; bgneal@693: opts.nextSlide++; bgneal@693: } bgneal@693: bgneal@693: if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) bgneal@693: clearTypeFix($s); bgneal@693: bgneal@693: if (opts.fit && opts.width) bgneal@693: $s.width(opts.width); bgneal@693: if (opts.fit && opts.height && opts.height != 'auto') bgneal@693: $s.height(opts.height); bgneal@693: s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height(); bgneal@693: s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width(); bgneal@693: bgneal@693: $s.css(opts.cssBefore); bgneal@693: bgneal@693: if (opts.pager || opts.pagerAnchorBuilder) bgneal@693: $.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts); bgneal@693: bgneal@693: if ($.isFunction(opts.onAddSlide)) bgneal@693: opts.onAddSlide($s); bgneal@693: else bgneal@693: $s.hide(); // default behavior bgneal@693: }; bgneal@693: } bgneal@693: bgneal@693: // reset internal state; we do this on every pass in order to support multiple effects bgneal@693: $.fn.cycle.resetState = function(opts, fx) { bgneal@693: fx = fx || opts.fx; bgneal@693: opts.before = []; opts.after = []; bgneal@693: opts.cssBefore = $.extend({}, opts.original.cssBefore); bgneal@693: opts.cssAfter = $.extend({}, opts.original.cssAfter); bgneal@693: opts.animIn = $.extend({}, opts.original.animIn); bgneal@693: opts.animOut = $.extend({}, opts.original.animOut); bgneal@693: opts.fxFn = null; bgneal@693: $.each(opts.original.before, function() { opts.before.push(this); }); bgneal@693: $.each(opts.original.after, function() { opts.after.push(this); }); bgneal@693: bgneal@693: // re-init bgneal@693: var init = $.fn.cycle.transitions[fx]; bgneal@693: if ($.isFunction(init)) bgneal@693: init(opts.$cont, $(opts.elements), opts); bgneal@693: }; bgneal@693: bgneal@693: // this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt bgneal@693: function go(els, opts, manual, fwd) { bgneal@693: var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide]; bgneal@693: bgneal@693: // opts.busy is true if we're in the middle of an animation bgneal@693: if (manual && opts.busy && opts.manualTrump) { bgneal@693: // let manual transitions requests trump active ones bgneal@693: debug('manualTrump in go(), stopping active transition'); bgneal@693: $(els).stop(true,true); bgneal@693: opts.busy = 0; bgneal@693: clearTimeout(p.cycleTimeout); bgneal@693: } bgneal@693: bgneal@693: // don't begin another timeout-based transition if there is one active bgneal@693: if (opts.busy) { bgneal@693: debug('transition active, ignoring new tx request'); bgneal@693: return; bgneal@693: } bgneal@693: bgneal@693: bgneal@693: // stop cycling if we have an outstanding stop request bgneal@693: if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual) bgneal@693: return; bgneal@693: bgneal@693: // check to see if we should stop cycling based on autostop options bgneal@693: if (!manual && !p.cyclePause && !opts.bounce && bgneal@693: ((opts.autostop && (--opts.countdown <= 0)) || bgneal@693: (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) { bgneal@693: if (opts.end) bgneal@693: opts.end(opts); bgneal@693: return; bgneal@693: } bgneal@693: bgneal@693: // if slideshow is paused, only transition on a manual trigger bgneal@693: var changed = false; bgneal@693: if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) { bgneal@693: changed = true; bgneal@693: var fx = opts.fx; bgneal@693: // keep trying to get the slide size if we don't have it yet bgneal@693: curr.cycleH = curr.cycleH || $(curr).height(); bgneal@693: curr.cycleW = curr.cycleW || $(curr).width(); bgneal@693: next.cycleH = next.cycleH || $(next).height(); bgneal@693: next.cycleW = next.cycleW || $(next).width(); bgneal@693: bgneal@693: // support multiple transition types bgneal@693: if (opts.multiFx) { bgneal@693: if (fwd && (opts.lastFx === undefined || ++opts.lastFx >= opts.fxs.length)) bgneal@693: opts.lastFx = 0; bgneal@693: else if (!fwd && (opts.lastFx === undefined || --opts.lastFx < 0)) bgneal@693: opts.lastFx = opts.fxs.length - 1; bgneal@693: fx = opts.fxs[opts.lastFx]; bgneal@693: } bgneal@693: bgneal@693: // one-time fx overrides apply to: $('div').cycle(3,'zoom'); bgneal@693: if (opts.oneTimeFx) { bgneal@693: fx = opts.oneTimeFx; bgneal@693: opts.oneTimeFx = null; bgneal@693: } bgneal@693: bgneal@693: $.fn.cycle.resetState(opts, fx); bgneal@693: bgneal@693: // run the before callbacks bgneal@693: if (opts.before.length) bgneal@693: $.each(opts.before, function(i,o) { bgneal@693: if (p.cycleStop != opts.stopCount) return; bgneal@693: o.apply(next, [curr, next, opts, fwd]); bgneal@693: }); bgneal@693: bgneal@693: // stage the after callacks bgneal@693: var after = function() { bgneal@693: opts.busy = 0; bgneal@693: $.each(opts.after, function(i,o) { bgneal@693: if (p.cycleStop != opts.stopCount) return; bgneal@693: o.apply(next, [curr, next, opts, fwd]); bgneal@693: }); bgneal@693: if (!p.cycleStop) { bgneal@693: // queue next transition bgneal@693: queueNext(); bgneal@693: } bgneal@693: }; bgneal@693: bgneal@693: debug('tx firing('+fx+'); currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide); bgneal@693: bgneal@693: // get ready to perform the transition bgneal@693: opts.busy = 1; bgneal@693: if (opts.fxFn) // fx function provided? bgneal@693: opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent); bgneal@693: else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ? bgneal@693: $.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent); bgneal@693: else bgneal@693: $.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent); bgneal@693: } bgneal@693: else { bgneal@693: queueNext(); bgneal@693: } bgneal@693: bgneal@693: if (changed || opts.nextSlide == opts.currSlide) { bgneal@693: // calculate the next slide bgneal@693: var roll; bgneal@693: opts.lastSlide = opts.currSlide; bgneal@693: if (opts.random) { bgneal@693: opts.currSlide = opts.nextSlide; bgneal@693: if (++opts.randomIndex == els.length) { bgneal@693: opts.randomIndex = 0; bgneal@693: opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); bgneal@693: } bgneal@693: opts.nextSlide = opts.randomMap[opts.randomIndex]; bgneal@693: if (opts.nextSlide == opts.currSlide) bgneal@693: opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1; bgneal@693: } bgneal@693: else if (opts.backwards) { bgneal@693: roll = (opts.nextSlide - 1) < 0; bgneal@693: if (roll && opts.bounce) { bgneal@693: opts.backwards = !opts.backwards; bgneal@693: opts.nextSlide = 1; bgneal@693: opts.currSlide = 0; bgneal@693: } bgneal@693: else { bgneal@693: opts.nextSlide = roll ? (els.length-1) : opts.nextSlide-1; bgneal@693: opts.currSlide = roll ? 0 : opts.nextSlide+1; bgneal@693: } bgneal@693: } bgneal@693: else { // sequence bgneal@693: roll = (opts.nextSlide + 1) == els.length; bgneal@693: if (roll && opts.bounce) { bgneal@693: opts.backwards = !opts.backwards; bgneal@693: opts.nextSlide = els.length-2; bgneal@693: opts.currSlide = els.length-1; bgneal@693: } bgneal@693: else { bgneal@693: opts.nextSlide = roll ? 0 : opts.nextSlide+1; bgneal@693: opts.currSlide = roll ? els.length-1 : opts.nextSlide-1; bgneal@693: } bgneal@693: } bgneal@693: } bgneal@693: if (changed && opts.pager) bgneal@693: opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass); bgneal@693: bgneal@693: function queueNext() { bgneal@693: // stage the next transition bgneal@693: var ms = 0, timeout = opts.timeout; bgneal@693: if (opts.timeout && !opts.continuous) { bgneal@693: ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd); bgneal@693: if (opts.fx == 'shuffle') bgneal@693: ms -= opts.speedOut; bgneal@693: } bgneal@693: else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic bgneal@693: ms = 10; bgneal@693: if (ms > 0) bgneal@693: p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.backwards); }, ms); bgneal@693: } bgneal@693: } bgneal@693: bgneal@693: // invoked after transition bgneal@693: $.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) { bgneal@693: $(pager).each(function() { bgneal@693: $(this).children().removeClass(clsName).eq(currSlide).addClass(clsName); bgneal@693: }); bgneal@693: }; bgneal@693: bgneal@693: // calculate timeout value for current transition bgneal@693: function getTimeout(curr, next, opts, fwd) { bgneal@693: if (opts.timeoutFn) { bgneal@693: // call user provided calc fn bgneal@693: var t = opts.timeoutFn.call(curr,curr,next,opts,fwd); bgneal@693: while (opts.fx != 'none' && (t - opts.speed) < 250) // sanitize timeout bgneal@693: t += opts.speed; bgneal@693: debug('calculated timeout: ' + t + '; speed: ' + opts.speed); bgneal@693: if (t !== false) bgneal@693: return t; bgneal@693: } bgneal@693: return opts.timeout; bgneal@693: } bgneal@693: bgneal@693: // expose next/prev function, caller must pass in state bgneal@693: $.fn.cycle.next = function(opts) { advance(opts,1); }; bgneal@693: $.fn.cycle.prev = function(opts) { advance(opts,0);}; bgneal@693: bgneal@693: // advance slide forward or back bgneal@693: function advance(opts, moveForward) { bgneal@693: var val = moveForward ? 1 : -1; bgneal@693: var els = opts.elements; bgneal@693: var p = opts.$cont[0], timeout = p.cycleTimeout; bgneal@693: if (timeout) { bgneal@693: clearTimeout(timeout); bgneal@693: p.cycleTimeout = 0; bgneal@693: } bgneal@693: if (opts.random && val < 0) { bgneal@693: // move back to the previously display slide bgneal@693: opts.randomIndex--; bgneal@693: if (--opts.randomIndex == -2) bgneal@693: opts.randomIndex = els.length-2; bgneal@693: else if (opts.randomIndex == -1) bgneal@693: opts.randomIndex = els.length-1; bgneal@693: opts.nextSlide = opts.randomMap[opts.randomIndex]; bgneal@693: } bgneal@693: else if (opts.random) { bgneal@693: opts.nextSlide = opts.randomMap[opts.randomIndex]; bgneal@693: } bgneal@693: else { bgneal@693: opts.nextSlide = opts.currSlide + val; bgneal@693: if (opts.nextSlide < 0) { bgneal@693: if (opts.nowrap) return false; bgneal@693: opts.nextSlide = els.length - 1; bgneal@693: } bgneal@693: else if (opts.nextSlide >= els.length) { bgneal@693: if (opts.nowrap) return false; bgneal@693: opts.nextSlide = 0; bgneal@693: } bgneal@693: } bgneal@693: bgneal@693: var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated bgneal@693: if ($.isFunction(cb)) bgneal@693: cb(val > 0, opts.nextSlide, els[opts.nextSlide]); bgneal@693: go(els, opts, 1, moveForward); bgneal@693: return false; bgneal@693: } bgneal@693: bgneal@693: function buildPager(els, opts) { bgneal@693: var $p = $(opts.pager); bgneal@693: $.each(els, function(i,o) { bgneal@693: $.fn.cycle.createPagerAnchor(i,o,$p,els,opts); bgneal@693: }); bgneal@693: opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass); bgneal@693: } bgneal@693: bgneal@693: $.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) { bgneal@693: var a; bgneal@693: if ($.isFunction(opts.pagerAnchorBuilder)) { bgneal@693: a = opts.pagerAnchorBuilder(i,el); bgneal@693: debug('pagerAnchorBuilder('+i+', el) returned: ' + a); bgneal@693: } bgneal@693: else bgneal@693: a = ''+(i+1)+''; bgneal@693: bgneal@693: if (!a) bgneal@693: return; bgneal@693: var $a = $(a); bgneal@693: // don't reparent if anchor is in the dom bgneal@693: if ($a.parents('body').length === 0) { bgneal@693: var arr = []; bgneal@693: if ($p.length > 1) { bgneal@693: $p.each(function() { bgneal@693: var $clone = $a.clone(true); bgneal@693: $(this).append($clone); bgneal@693: arr.push($clone[0]); bgneal@693: }); bgneal@693: $a = $(arr); bgneal@693: } bgneal@693: else { bgneal@693: $a.appendTo($p); bgneal@693: } bgneal@693: } bgneal@693: bgneal@693: opts.pagerAnchors = opts.pagerAnchors || []; bgneal@693: opts.pagerAnchors.push($a); bgneal@693: bgneal@693: var pagerFn = function(e) { bgneal@693: e.preventDefault(); bgneal@693: opts.nextSlide = i; bgneal@693: var p = opts.$cont[0], timeout = p.cycleTimeout; bgneal@693: if (timeout) { bgneal@693: clearTimeout(timeout); bgneal@693: p.cycleTimeout = 0; bgneal@693: } bgneal@693: var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated bgneal@693: if ($.isFunction(cb)) bgneal@693: cb(opts.nextSlide, els[opts.nextSlide]); bgneal@693: go(els,opts,1,opts.currSlide < i); // trigger the trans bgneal@693: // return false; // <== allow bubble bgneal@693: }; bgneal@693: bgneal@693: if ( /mouseenter|mouseover/i.test(opts.pagerEvent) ) { bgneal@693: $a.hover(pagerFn, function(){/* no-op */} ); bgneal@693: } bgneal@693: else { bgneal@693: $a.bind(opts.pagerEvent, pagerFn); bgneal@693: } bgneal@693: bgneal@693: if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble) bgneal@693: $a.bind('click.cycle', function(){return false;}); // suppress click bgneal@693: bgneal@693: var cont = opts.$cont[0]; bgneal@693: var pauseFlag = false; // https://github.com/malsup/cycle/issues/44 bgneal@693: if (opts.pauseOnPagerHover) { bgneal@693: $a.hover( bgneal@693: function() { bgneal@693: pauseFlag = true; bgneal@693: cont.cyclePause++; bgneal@693: triggerPause(cont,true,true); bgneal@693: }, function() { bgneal@693: if (pauseFlag) bgneal@693: cont.cyclePause--; bgneal@693: triggerPause(cont,true,true); bgneal@693: } bgneal@693: ); bgneal@693: } bgneal@693: }; bgneal@693: bgneal@693: // helper fn to calculate the number of slides between the current and the next bgneal@693: $.fn.cycle.hopsFromLast = function(opts, fwd) { bgneal@693: var hops, l = opts.lastSlide, c = opts.currSlide; bgneal@693: if (fwd) bgneal@693: hops = c > l ? c - l : opts.slideCount - l; bgneal@693: else bgneal@693: hops = c < l ? l - c : l + opts.slideCount - c; bgneal@693: return hops; bgneal@693: }; bgneal@693: bgneal@693: // fix clearType problems in ie6 by setting an explicit bg color bgneal@693: // (otherwise text slides look horrible during a fade transition) bgneal@693: function clearTypeFix($slides) { bgneal@693: debug('applying clearType background-color hack'); bgneal@693: function hex(s) { bgneal@693: s = parseInt(s,10).toString(16); bgneal@693: return s.length < 2 ? '0'+s : s; bgneal@693: } bgneal@693: function getBg(e) { bgneal@693: for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) { bgneal@693: var v = $.css(e,'background-color'); bgneal@693: if (v && v.indexOf('rgb') >= 0 ) { bgneal@693: var rgb = v.match(/\d+/g); bgneal@693: return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]); bgneal@693: } bgneal@693: if (v && v != 'transparent') bgneal@693: return v; bgneal@693: } bgneal@693: return '#ffffff'; bgneal@693: } bgneal@693: $slides.each(function() { $(this).css('background-color', getBg(this)); }); bgneal@693: } bgneal@693: bgneal@693: // reset common props before the next transition bgneal@693: $.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) { bgneal@693: $(opts.elements).not(curr).hide(); bgneal@693: if (typeof opts.cssBefore.opacity == 'undefined') bgneal@693: opts.cssBefore.opacity = 1; bgneal@693: opts.cssBefore.display = 'block'; bgneal@693: if (opts.slideResize && w !== false && next.cycleW > 0) bgneal@693: opts.cssBefore.width = next.cycleW; bgneal@693: if (opts.slideResize && h !== false && next.cycleH > 0) bgneal@693: opts.cssBefore.height = next.cycleH; bgneal@693: opts.cssAfter = opts.cssAfter || {}; bgneal@693: opts.cssAfter.display = 'none'; bgneal@693: $(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0)); bgneal@693: $(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1)); bgneal@693: }; bgneal@693: bgneal@693: // the actual fn for effecting a transition bgneal@693: $.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) { bgneal@693: var $l = $(curr), $n = $(next); bgneal@693: var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut, animInDelay = opts.animInDelay, animOutDelay = opts.animOutDelay; bgneal@693: $n.css(opts.cssBefore); bgneal@693: if (speedOverride) { bgneal@693: if (typeof speedOverride == 'number') bgneal@693: speedIn = speedOut = speedOverride; bgneal@693: else bgneal@693: speedIn = speedOut = 1; bgneal@693: easeIn = easeOut = null; bgneal@693: } bgneal@693: var fn = function() { bgneal@693: $n.delay(animInDelay).animate(opts.animIn, speedIn, easeIn, function() { bgneal@693: cb(); bgneal@693: }); bgneal@693: }; bgneal@693: $l.delay(animOutDelay).animate(opts.animOut, speedOut, easeOut, function() { bgneal@693: $l.css(opts.cssAfter); bgneal@693: if (!opts.sync) bgneal@693: fn(); bgneal@693: }); bgneal@693: if (opts.sync) fn(); bgneal@693: }; bgneal@693: bgneal@693: // transition definitions - only fade is defined here, transition pack defines the rest bgneal@693: $.fn.cycle.transitions = { bgneal@693: fade: function($cont, $slides, opts) { bgneal@693: $slides.not(':eq('+opts.currSlide+')').css('opacity',0); bgneal@693: opts.before.push(function(curr,next,opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts); bgneal@693: opts.cssBefore.opacity = 0; bgneal@693: }); bgneal@693: opts.animIn = { opacity: 1 }; bgneal@693: opts.animOut = { opacity: 0 }; bgneal@693: opts.cssBefore = { top: 0, left: 0 }; bgneal@693: } bgneal@693: }; bgneal@693: bgneal@693: $.fn.cycle.ver = function() { return ver; }; bgneal@693: bgneal@693: // override these globally if you like (they are all optional) bgneal@693: $.fn.cycle.defaults = { bgneal@693: activePagerClass: 'activeSlide', // class name used for the active pager link bgneal@693: after: null, // transition callback (scope set to element that was shown): function(currSlideElement, nextSlideElement, options, forwardFlag) bgneal@693: allowPagerClickBubble: false, // allows or prevents click event on pager anchors from bubbling bgneal@693: animIn: null, // properties that define how the slide animates in bgneal@693: animInDelay: 0, // allows delay before next slide transitions in bgneal@693: animOut: null, // properties that define how the slide animates out bgneal@693: animOutDelay: 0, // allows delay before current slide transitions out bgneal@693: aspect: false, // preserve aspect ratio during fit resizing, cropping if necessary (must be used with fit option) bgneal@693: autostop: 0, // true to end slideshow after X transitions (where X == slide count) bgneal@693: autostopCount: 0, // number of transitions (optionally used with autostop to define X) bgneal@693: backwards: false, // true to start slideshow at last slide and move backwards through the stack bgneal@693: before: null, // transition callback (scope set to element to be shown): function(currSlideElement, nextSlideElement, options, forwardFlag) bgneal@693: center: null, // set to true to have cycle add top/left margin to each slide (use with width and height options) bgneal@693: cleartype: !$.support.opacity, // true if clearType corrections should be applied (for IE) bgneal@693: cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides) bgneal@693: containerResize: 1, // resize container to fit largest slide bgneal@693: containerResizeHeight: 0, // resize containers height to fit the largest slide but leave the width dynamic bgneal@693: continuous: 0, // true to start next transition immediately after current one completes bgneal@693: cssAfter: null, // properties that defined the state of the slide after transitioning out bgneal@693: cssBefore: null, // properties that define the initial state of the slide before transitioning in bgneal@693: delay: 0, // additional delay (in ms) for first transition (hint: can be negative) bgneal@693: easeIn: null, // easing for "in" transition bgneal@693: easeOut: null, // easing for "out" transition bgneal@693: easing: null, // easing method for both in and out transitions bgneal@693: end: null, // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options) bgneal@693: fastOnEvent: 0, // force fast transitions when triggered manually (via pager or prev/next); value == time in ms bgneal@693: fit: 0, // force slides to fit container bgneal@693: fx: 'fade', // name of transition effect (or comma separated names, ex: 'fade,scrollUp,shuffle') bgneal@693: fxFn: null, // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) bgneal@693: height: 'auto', // container height (if the 'fit' option is true, the slides will be set to this height as well) bgneal@693: manualTrump: true, // causes manual transition to stop an active transition instead of being ignored bgneal@693: metaAttr: 'cycle', // data- attribute that holds the option data for the slideshow bgneal@693: next: null, // element, jQuery object, or jQuery selector string for the element to use as event trigger for next slide bgneal@693: nowrap: 0, // true to prevent slideshow from wrapping bgneal@693: onPagerEvent: null, // callback fn for pager events: function(zeroBasedSlideIndex, slideElement) bgneal@693: onPrevNextEvent: null, // callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement) bgneal@693: pager: null, // element, jQuery object, or jQuery selector string for the element to use as pager container bgneal@693: pagerAnchorBuilder: null, // callback fn for building anchor links: function(index, DOMelement) bgneal@693: pagerEvent: 'click.cycle', // name of event which drives the pager navigation bgneal@693: pause: 0, // true to enable "pause on hover" bgneal@693: pauseOnPagerHover: 0, // true to pause when hovering over pager link bgneal@693: prev: null, // element, jQuery object, or jQuery selector string for the element to use as event trigger for previous slide bgneal@693: prevNextEvent: 'click.cycle',// event which drives the manual transition to the previous or next slide bgneal@693: random: 0, // true for random, false for sequence (not applicable to shuffle fx) bgneal@693: randomizeEffects: 1, // valid when multiple effects are used; true to make the effect sequence random bgneal@693: requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded bgneal@693: requeueTimeout: 250, // ms delay for requeue bgneal@693: rev: 0, // causes animations to transition in reverse (for effects that support it such as scrollHorz/scrollVert/shuffle) bgneal@693: shuffle: null, // coords for shuffle animation, ex: { top:15, left: 200 } bgneal@693: skipInitializationCallbacks: false, // set to true to disable the first before/after callback that occurs prior to any transition bgneal@693: slideExpr: null, // expression for selecting slides (if something other than all children is required) bgneal@693: slideResize: 1, // force slide width/height to fixed size before every transition bgneal@693: speed: 1000, // speed of the transition (any valid fx speed value) bgneal@693: speedIn: null, // speed of the 'in' transition bgneal@693: speedOut: null, // speed of the 'out' transition bgneal@693: startingSlide: undefined,// zero-based index of the first slide to be displayed bgneal@693: sync: 1, // true if in/out transitions should occur simultaneously bgneal@693: timeout: 4000, // milliseconds between slide transitions (0 to disable auto advance) bgneal@693: timeoutFn: null, // callback for determining per-slide timeout value: function(currSlideElement, nextSlideElement, options, forwardFlag) bgneal@693: updateActivePagerLink: null,// callback fn invoked to update the active pager link (adds/removes activePagerClass style) bgneal@693: width: null // container width (if the 'fit' option is true, the slides will be set to this width as well) bgneal@693: }; bgneal@693: bgneal@693: })(jQuery); bgneal@693: bgneal@693: bgneal@693: /*! bgneal@693: * jQuery Cycle Plugin Transition Definitions bgneal@693: * This script is a plugin for the jQuery Cycle Plugin bgneal@693: * Examples and documentation at: http://malsup.com/jquery/cycle/ bgneal@693: * Copyright (c) 2007-2010 M. Alsup bgneal@693: * Version: 2.73 bgneal@693: * Dual licensed under the MIT and GPL licenses: bgneal@693: * http://www.opensource.org/licenses/mit-license.php bgneal@693: * http://www.gnu.org/licenses/gpl.html bgneal@693: */ bgneal@693: (function($) { bgneal@693: "use strict"; bgneal@693: bgneal@693: // bgneal@693: // These functions define slide initialization and properties for the named bgneal@693: // transitions. To save file size feel free to remove any of these that you bgneal@693: // don't need. bgneal@693: // bgneal@693: $.fn.cycle.transitions.none = function($cont, $slides, opts) { bgneal@693: opts.fxFn = function(curr,next,opts,after){ bgneal@693: $(next).show(); bgneal@693: $(curr).hide(); bgneal@693: after(); bgneal@693: }; bgneal@693: }; bgneal@693: bgneal@693: // not a cross-fade, fadeout only fades out the top slide bgneal@693: $.fn.cycle.transitions.fadeout = function($cont, $slides, opts) { bgneal@693: $slides.not(':eq('+opts.currSlide+')').css({ display: 'block', 'opacity': 1 }); bgneal@693: opts.before.push(function(curr,next,opts,w,h,rev) { bgneal@693: $(curr).css('zIndex',opts.slideCount + (rev !== true ? 1 : 0)); bgneal@693: $(next).css('zIndex',opts.slideCount + (rev !== true ? 0 : 1)); bgneal@693: }); bgneal@693: opts.animIn.opacity = 1; bgneal@693: opts.animOut.opacity = 0; bgneal@693: opts.cssBefore.opacity = 1; bgneal@693: opts.cssBefore.display = 'block'; bgneal@693: opts.cssAfter.zIndex = 0; bgneal@693: }; bgneal@693: bgneal@693: // scrollUp/Down/Left/Right bgneal@693: $.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) { bgneal@693: $cont.css('overflow','hidden'); bgneal@693: opts.before.push($.fn.cycle.commonReset); bgneal@693: var h = $cont.height(); bgneal@693: opts.cssBefore.top = h; bgneal@693: opts.cssBefore.left = 0; bgneal@693: opts.cssFirst.top = 0; bgneal@693: opts.animIn.top = 0; bgneal@693: opts.animOut.top = -h; bgneal@693: }; bgneal@693: $.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) { bgneal@693: $cont.css('overflow','hidden'); bgneal@693: opts.before.push($.fn.cycle.commonReset); bgneal@693: var h = $cont.height(); bgneal@693: opts.cssFirst.top = 0; bgneal@693: opts.cssBefore.top = -h; bgneal@693: opts.cssBefore.left = 0; bgneal@693: opts.animIn.top = 0; bgneal@693: opts.animOut.top = h; bgneal@693: }; bgneal@693: $.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) { bgneal@693: $cont.css('overflow','hidden'); bgneal@693: opts.before.push($.fn.cycle.commonReset); bgneal@693: var w = $cont.width(); bgneal@693: opts.cssFirst.left = 0; bgneal@693: opts.cssBefore.left = w; bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.animIn.left = 0; bgneal@693: opts.animOut.left = 0-w; bgneal@693: }; bgneal@693: $.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) { bgneal@693: $cont.css('overflow','hidden'); bgneal@693: opts.before.push($.fn.cycle.commonReset); bgneal@693: var w = $cont.width(); bgneal@693: opts.cssFirst.left = 0; bgneal@693: opts.cssBefore.left = -w; bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.animIn.left = 0; bgneal@693: opts.animOut.left = w; bgneal@693: }; bgneal@693: $.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) { bgneal@693: $cont.css('overflow','hidden').width(); bgneal@693: opts.before.push(function(curr, next, opts, fwd) { bgneal@693: if (opts.rev) bgneal@693: fwd = !fwd; bgneal@693: $.fn.cycle.commonReset(curr,next,opts); bgneal@693: opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW); bgneal@693: opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW; bgneal@693: }); bgneal@693: opts.cssFirst.left = 0; bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.animIn.left = 0; bgneal@693: opts.animOut.top = 0; bgneal@693: }; bgneal@693: $.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) { bgneal@693: $cont.css('overflow','hidden'); bgneal@693: opts.before.push(function(curr, next, opts, fwd) { bgneal@693: if (opts.rev) bgneal@693: fwd = !fwd; bgneal@693: $.fn.cycle.commonReset(curr,next,opts); bgneal@693: opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1); bgneal@693: opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH; bgneal@693: }); bgneal@693: opts.cssFirst.top = 0; bgneal@693: opts.cssBefore.left = 0; bgneal@693: opts.animIn.top = 0; bgneal@693: opts.animOut.left = 0; bgneal@693: }; bgneal@693: bgneal@693: // slideX/slideY bgneal@693: $.fn.cycle.transitions.slideX = function($cont, $slides, opts) { bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $(opts.elements).not(curr).hide(); bgneal@693: $.fn.cycle.commonReset(curr,next,opts,false,true); bgneal@693: opts.animIn.width = next.cycleW; bgneal@693: }); bgneal@693: opts.cssBefore.left = 0; bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.cssBefore.width = 0; bgneal@693: opts.animIn.width = 'show'; bgneal@693: opts.animOut.width = 0; bgneal@693: }; bgneal@693: $.fn.cycle.transitions.slideY = function($cont, $slides, opts) { bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $(opts.elements).not(curr).hide(); bgneal@693: $.fn.cycle.commonReset(curr,next,opts,true,false); bgneal@693: opts.animIn.height = next.cycleH; bgneal@693: }); bgneal@693: opts.cssBefore.left = 0; bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.cssBefore.height = 0; bgneal@693: opts.animIn.height = 'show'; bgneal@693: opts.animOut.height = 0; bgneal@693: }; bgneal@693: bgneal@693: // shuffle bgneal@693: $.fn.cycle.transitions.shuffle = function($cont, $slides, opts) { bgneal@693: var i, w = $cont.css('overflow', 'visible').width(); bgneal@693: $slides.css({left: 0, top: 0}); bgneal@693: opts.before.push(function(curr,next,opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,true,true,true); bgneal@693: }); bgneal@693: // only adjust speed once! bgneal@693: if (!opts.speedAdjusted) { bgneal@693: opts.speed = opts.speed / 2; // shuffle has 2 transitions bgneal@693: opts.speedAdjusted = true; bgneal@693: } bgneal@693: opts.random = 0; bgneal@693: opts.shuffle = opts.shuffle || {left:-w, top:15}; bgneal@693: opts.els = []; bgneal@693: for (i=0; i < $slides.length; i++) bgneal@693: opts.els.push($slides[i]); bgneal@693: bgneal@693: for (i=0; i < opts.currSlide; i++) bgneal@693: opts.els.push(opts.els.shift()); bgneal@693: bgneal@693: // custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!) bgneal@693: opts.fxFn = function(curr, next, opts, cb, fwd) { bgneal@693: if (opts.rev) bgneal@693: fwd = !fwd; bgneal@693: var $el = fwd ? $(curr) : $(next); bgneal@693: $(next).css(opts.cssBefore); bgneal@693: var count = opts.slideCount; bgneal@693: $el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() { bgneal@693: var hops = $.fn.cycle.hopsFromLast(opts, fwd); bgneal@693: for (var k=0; k < hops; k++) { bgneal@693: if (fwd) bgneal@693: opts.els.push(opts.els.shift()); bgneal@693: else bgneal@693: opts.els.unshift(opts.els.pop()); bgneal@693: } bgneal@693: if (fwd) { bgneal@693: for (var i=0, len=opts.els.length; i < len; i++) bgneal@693: $(opts.els[i]).css('z-index', len-i+count); bgneal@693: } bgneal@693: else { bgneal@693: var z = $(curr).css('z-index'); bgneal@693: $el.css('z-index', parseInt(z,10)+1+count); bgneal@693: } bgneal@693: $el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() { bgneal@693: $(fwd ? this : curr).hide(); bgneal@693: if (cb) cb(); bgneal@693: }); bgneal@693: }); bgneal@693: }; bgneal@693: $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 }); bgneal@693: }; bgneal@693: bgneal@693: // turnUp/Down/Left/Right bgneal@693: $.fn.cycle.transitions.turnUp = function($cont, $slides, opts) { bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,true,false); bgneal@693: opts.cssBefore.top = next.cycleH; bgneal@693: opts.animIn.height = next.cycleH; bgneal@693: opts.animOut.width = next.cycleW; bgneal@693: }); bgneal@693: opts.cssFirst.top = 0; bgneal@693: opts.cssBefore.left = 0; bgneal@693: opts.cssBefore.height = 0; bgneal@693: opts.animIn.top = 0; bgneal@693: opts.animOut.height = 0; bgneal@693: }; bgneal@693: $.fn.cycle.transitions.turnDown = function($cont, $slides, opts) { bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,true,false); bgneal@693: opts.animIn.height = next.cycleH; bgneal@693: opts.animOut.top = curr.cycleH; bgneal@693: }); bgneal@693: opts.cssFirst.top = 0; bgneal@693: opts.cssBefore.left = 0; bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.cssBefore.height = 0; bgneal@693: opts.animOut.height = 0; bgneal@693: }; bgneal@693: $.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) { bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,false,true); bgneal@693: opts.cssBefore.left = next.cycleW; bgneal@693: opts.animIn.width = next.cycleW; bgneal@693: }); bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.cssBefore.width = 0; bgneal@693: opts.animIn.left = 0; bgneal@693: opts.animOut.width = 0; bgneal@693: }; bgneal@693: $.fn.cycle.transitions.turnRight = function($cont, $slides, opts) { bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,false,true); bgneal@693: opts.animIn.width = next.cycleW; bgneal@693: opts.animOut.left = curr.cycleW; bgneal@693: }); bgneal@693: $.extend(opts.cssBefore, { top: 0, left: 0, width: 0 }); bgneal@693: opts.animIn.left = 0; bgneal@693: opts.animOut.width = 0; bgneal@693: }; bgneal@693: bgneal@693: // zoom bgneal@693: $.fn.cycle.transitions.zoom = function($cont, $slides, opts) { bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,false,false,true); bgneal@693: opts.cssBefore.top = next.cycleH/2; bgneal@693: opts.cssBefore.left = next.cycleW/2; bgneal@693: $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH }); bgneal@693: $.extend(opts.animOut, { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 }); bgneal@693: }); bgneal@693: opts.cssFirst.top = 0; bgneal@693: opts.cssFirst.left = 0; bgneal@693: opts.cssBefore.width = 0; bgneal@693: opts.cssBefore.height = 0; bgneal@693: }; bgneal@693: bgneal@693: // fadeZoom bgneal@693: $.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) { bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,false,false); bgneal@693: opts.cssBefore.left = next.cycleW/2; bgneal@693: opts.cssBefore.top = next.cycleH/2; bgneal@693: $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH }); bgneal@693: }); bgneal@693: opts.cssBefore.width = 0; bgneal@693: opts.cssBefore.height = 0; bgneal@693: opts.animOut.opacity = 0; bgneal@693: }; bgneal@693: bgneal@693: // blindX bgneal@693: $.fn.cycle.transitions.blindX = function($cont, $slides, opts) { bgneal@693: var w = $cont.css('overflow','hidden').width(); bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts); bgneal@693: opts.animIn.width = next.cycleW; bgneal@693: opts.animOut.left = curr.cycleW; bgneal@693: }); bgneal@693: opts.cssBefore.left = w; bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.animIn.left = 0; bgneal@693: opts.animOut.left = w; bgneal@693: }; bgneal@693: // blindY bgneal@693: $.fn.cycle.transitions.blindY = function($cont, $slides, opts) { bgneal@693: var h = $cont.css('overflow','hidden').height(); bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts); bgneal@693: opts.animIn.height = next.cycleH; bgneal@693: opts.animOut.top = curr.cycleH; bgneal@693: }); bgneal@693: opts.cssBefore.top = h; bgneal@693: opts.cssBefore.left = 0; bgneal@693: opts.animIn.top = 0; bgneal@693: opts.animOut.top = h; bgneal@693: }; bgneal@693: // blindZ bgneal@693: $.fn.cycle.transitions.blindZ = function($cont, $slides, opts) { bgneal@693: var h = $cont.css('overflow','hidden').height(); bgneal@693: var w = $cont.width(); bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts); bgneal@693: opts.animIn.height = next.cycleH; bgneal@693: opts.animOut.top = curr.cycleH; bgneal@693: }); bgneal@693: opts.cssBefore.top = h; bgneal@693: opts.cssBefore.left = w; bgneal@693: opts.animIn.top = 0; bgneal@693: opts.animIn.left = 0; bgneal@693: opts.animOut.top = h; bgneal@693: opts.animOut.left = w; bgneal@693: }; bgneal@693: bgneal@693: // growX - grow horizontally from centered 0 width bgneal@693: $.fn.cycle.transitions.growX = function($cont, $slides, opts) { bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,false,true); bgneal@693: opts.cssBefore.left = this.cycleW/2; bgneal@693: opts.animIn.left = 0; bgneal@693: opts.animIn.width = this.cycleW; bgneal@693: opts.animOut.left = 0; bgneal@693: }); bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.cssBefore.width = 0; bgneal@693: }; bgneal@693: // growY - grow vertically from centered 0 height bgneal@693: $.fn.cycle.transitions.growY = function($cont, $slides, opts) { bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,true,false); bgneal@693: opts.cssBefore.top = this.cycleH/2; bgneal@693: opts.animIn.top = 0; bgneal@693: opts.animIn.height = this.cycleH; bgneal@693: opts.animOut.top = 0; bgneal@693: }); bgneal@693: opts.cssBefore.height = 0; bgneal@693: opts.cssBefore.left = 0; bgneal@693: }; bgneal@693: bgneal@693: // curtainX - squeeze in both edges horizontally bgneal@693: $.fn.cycle.transitions.curtainX = function($cont, $slides, opts) { bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,false,true,true); bgneal@693: opts.cssBefore.left = next.cycleW/2; bgneal@693: opts.animIn.left = 0; bgneal@693: opts.animIn.width = this.cycleW; bgneal@693: opts.animOut.left = curr.cycleW/2; bgneal@693: opts.animOut.width = 0; bgneal@693: }); bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.cssBefore.width = 0; bgneal@693: }; bgneal@693: // curtainY - squeeze in both edges vertically bgneal@693: $.fn.cycle.transitions.curtainY = function($cont, $slides, opts) { bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,true,false,true); bgneal@693: opts.cssBefore.top = next.cycleH/2; bgneal@693: opts.animIn.top = 0; bgneal@693: opts.animIn.height = next.cycleH; bgneal@693: opts.animOut.top = curr.cycleH/2; bgneal@693: opts.animOut.height = 0; bgneal@693: }); bgneal@693: opts.cssBefore.height = 0; bgneal@693: opts.cssBefore.left = 0; bgneal@693: }; bgneal@693: bgneal@693: // cover - curr slide covered by next slide bgneal@693: $.fn.cycle.transitions.cover = function($cont, $slides, opts) { bgneal@693: var d = opts.direction || 'left'; bgneal@693: var w = $cont.css('overflow','hidden').width(); bgneal@693: var h = $cont.height(); bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts); bgneal@693: opts.cssAfter.display = ''; bgneal@693: if (d == 'right') bgneal@693: opts.cssBefore.left = -w; bgneal@693: else if (d == 'up') bgneal@693: opts.cssBefore.top = h; bgneal@693: else if (d == 'down') bgneal@693: opts.cssBefore.top = -h; bgneal@693: else bgneal@693: opts.cssBefore.left = w; bgneal@693: }); bgneal@693: opts.animIn.left = 0; bgneal@693: opts.animIn.top = 0; bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.cssBefore.left = 0; bgneal@693: }; bgneal@693: bgneal@693: // uncover - curr slide moves off next slide bgneal@693: $.fn.cycle.transitions.uncover = function($cont, $slides, opts) { bgneal@693: var d = opts.direction || 'left'; bgneal@693: var w = $cont.css('overflow','hidden').width(); bgneal@693: var h = $cont.height(); bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,true,true,true); bgneal@693: if (d == 'right') bgneal@693: opts.animOut.left = w; bgneal@693: else if (d == 'up') bgneal@693: opts.animOut.top = -h; bgneal@693: else if (d == 'down') bgneal@693: opts.animOut.top = h; bgneal@693: else bgneal@693: opts.animOut.left = -w; bgneal@693: }); bgneal@693: opts.animIn.left = 0; bgneal@693: opts.animIn.top = 0; bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.cssBefore.left = 0; bgneal@693: }; bgneal@693: bgneal@693: // toss - move top slide and fade away bgneal@693: $.fn.cycle.transitions.toss = function($cont, $slides, opts) { bgneal@693: var w = $cont.css('overflow','visible').width(); bgneal@693: var h = $cont.height(); bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: $.fn.cycle.commonReset(curr,next,opts,true,true,true); bgneal@693: // provide default toss settings if animOut not provided bgneal@693: if (!opts.animOut.left && !opts.animOut.top) bgneal@693: $.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 }); bgneal@693: else bgneal@693: opts.animOut.opacity = 0; bgneal@693: }); bgneal@693: opts.cssBefore.left = 0; bgneal@693: opts.cssBefore.top = 0; bgneal@693: opts.animIn.left = 0; bgneal@693: }; bgneal@693: bgneal@693: // wipe - clip animation bgneal@693: $.fn.cycle.transitions.wipe = function($cont, $slides, opts) { bgneal@693: var w = $cont.css('overflow','hidden').width(); bgneal@693: var h = $cont.height(); bgneal@693: opts.cssBefore = opts.cssBefore || {}; bgneal@693: var clip; bgneal@693: if (opts.clip) { bgneal@693: if (/l2r/.test(opts.clip)) bgneal@693: clip = 'rect(0px 0px '+h+'px 0px)'; bgneal@693: else if (/r2l/.test(opts.clip)) bgneal@693: clip = 'rect(0px '+w+'px '+h+'px '+w+'px)'; bgneal@693: else if (/t2b/.test(opts.clip)) bgneal@693: clip = 'rect(0px '+w+'px 0px 0px)'; bgneal@693: else if (/b2t/.test(opts.clip)) bgneal@693: clip = 'rect('+h+'px '+w+'px '+h+'px 0px)'; bgneal@693: else if (/zoom/.test(opts.clip)) { bgneal@693: var top = parseInt(h/2,10); bgneal@693: var left = parseInt(w/2,10); bgneal@693: clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)'; bgneal@693: } bgneal@693: } bgneal@693: bgneal@693: opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)'; bgneal@693: bgneal@693: var d = opts.cssBefore.clip.match(/(\d+)/g); bgneal@693: var t = parseInt(d[0],10), r = parseInt(d[1],10), b = parseInt(d[2],10), l = parseInt(d[3],10); bgneal@693: bgneal@693: opts.before.push(function(curr, next, opts) { bgneal@693: if (curr == next) return; bgneal@693: var $curr = $(curr), $next = $(next); bgneal@693: $.fn.cycle.commonReset(curr,next,opts,true,true,false); bgneal@693: opts.cssAfter.display = 'block'; bgneal@693: bgneal@693: var step = 1, count = parseInt((opts.speedIn / 13),10) - 1; bgneal@693: (function f() { bgneal@693: var tt = t ? t - parseInt(step * (t/count),10) : 0; bgneal@693: var ll = l ? l - parseInt(step * (l/count),10) : 0; bgneal@693: var bb = b < h ? b + parseInt(step * ((h-b)/count || 1),10) : h; bgneal@693: var rr = r < w ? r + parseInt(step * ((w-r)/count || 1),10) : w; bgneal@693: $next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' }); bgneal@693: (step++ <= count) ? setTimeout(f, 13) : $curr.css('display', 'none'); bgneal@693: })(); bgneal@693: }); bgneal@693: $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 }); bgneal@693: opts.animIn = { left: 0 }; bgneal@693: opts.animOut = { left: 0 }; bgneal@693: }; bgneal@693: bgneal@693: })(jQuery);