Advertisement
Guest User

jquery cycle swf fixed

a guest
Apr 16th, 2011
829
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*!
  2.  * jQuery Cycle Plugin (with Transition Definitions)
  3.  * Examples and documentation at: http://jquery.malsup.com/cycle/
  4.  * Copyright (c) 2007-2010 M. Alsup
  5.  * Version: 2.99 (12-MAR-2011)
  6.  * Dual licensed under the MIT and GPL licenses.
  7.  * http://jquery.malsup.com/license.html
  8.  * Requires: jQuery v1.3.2 or later
  9.  */
  10. ;(function($) {
  11.  
  12. var ver = '2.99';
  13.  
  14. // if $.support is not defined (pre jQuery 1.3) add what I need
  15. if ($.support == undefined) {
  16.     $.support = {
  17.         opacity: !($.browser.msie)
  18.     };
  19. }
  20.  
  21. function debug(s) {
  22.     $.fn.cycle.debug && log(s);
  23. }
  24. function log() {
  25.     window.console && console.log && console.log('[cycle] ' + Array.prototype.join.call(arguments,' '));
  26. }
  27. $.expr[':'].paused = function(el) {
  28.     return el.cyclePause;
  29. }
  30.  
  31.  
  32. // the options arg can be...
  33. //   a number  - indicates an immediate transition should occur to the given slide index
  34. //   a string  - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc)
  35. //   an object - properties to control the slideshow
  36. //
  37. // the arg2 arg can be...
  38. //   the name of an fx (only used in conjunction with a numeric value for 'options')
  39. //   the value true (only used in first arg == 'resume') and indicates
  40. //   that the resume should occur immediately (not wait for next timeout)
  41.  
  42. $.fn.cycle = function(options, arg2) {
  43.     var o = { s: this.selector, c: this.context };
  44.  
  45.     // in 1.3+ we can fix mistakes with the ready state
  46.     if (this.length === 0 && options != 'stop') {
  47.         if (!$.isReady && o.s) {
  48.             log('DOM not ready, queuing slideshow');
  49.             $(function() {
  50.                 $(o.s,o.c).cycle(options,arg2);
  51.             });
  52.             return this;
  53.         }
  54.         // is your DOM ready?  http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
  55.         log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
  56.         return this;
  57.     }
  58.  
  59.     // iterate the matched nodeset
  60.     return this.each(function() {
  61.         var opts = handleArguments(this, options, arg2);
  62.         if (opts === false)
  63.             return;
  64.  
  65.         opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink;
  66.  
  67.         // stop existing slideshow for this container (if there is one)
  68.         if (this.cycleTimeout)
  69.             clearTimeout(this.cycleTimeout);
  70.         this.cycleTimeout = this.cyclePause = 0;
  71.  
  72.         var $cont = $(this);
  73.         var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children();
  74.         var els = $slides.get();
  75.         if (els.length < 2) {
  76.             log('terminating; too few slides: ' + els.length);
  77.             return;
  78.         }
  79.  
  80.         var opts2 = buildOptions($cont, $slides, els, opts, o);
  81.         if (opts2 === false)
  82.             return;
  83.  
  84.         var startTime = opts2.continuous ? 10 : getTimeout(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.backwards);
  85.  
  86.         // if it's an auto slideshow, kick it off
  87.         if (startTime) {
  88.             startTime += (opts2.delay || 0);
  89.             if (startTime < 10)
  90.                 startTime = 10;
  91.             debug('first timeout: ' + startTime);
  92.             this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts.backwards)}, startTime);
  93.         }
  94.     });
  95. };
  96.  
  97. // process the args that were passed to the plugin fn
  98. function handleArguments(cont, options, arg2) {
  99.     if (cont.cycleStop == undefined)
  100.         cont.cycleStop = 0;
  101.     if (options === undefined || options === null)
  102.         options = {};
  103.     if (options.constructor == String) {
  104.         switch(options) {
  105.         case 'destroy':
  106.         case 'stop':
  107.             var opts = $(cont).data('cycle.opts');
  108.             if (!opts)
  109.                 return false;
  110.             cont.cycleStop++; // callbacks look for change
  111.             if (cont.cycleTimeout)
  112.                 clearTimeout(cont.cycleTimeout);
  113.             cont.cycleTimeout = 0;
  114.             $(cont).removeData('cycle.opts');
  115.             if (options == 'destroy')
  116.                 destroy(opts);
  117.             return false;
  118.         case 'toggle':
  119.             cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1;
  120.             checkInstantResume(cont.cyclePause, arg2, cont);
  121.             return false;
  122.         case 'pause':
  123.             cont.cyclePause = 1;
  124.             return false;
  125.         case 'resume':
  126.             cont.cyclePause = 0;
  127.             checkInstantResume(false, arg2, cont);
  128.             return false;
  129.         case 'prev':
  130.         case 'next':
  131.             var opts = $(cont).data('cycle.opts');
  132.             if (!opts) {
  133.                 log('options not found, "prev/next" ignored');
  134.                 return false;
  135.             }
  136.             $.fn.cycle[options](opts);
  137.             return false;
  138.         default:
  139.             options = { fx: options };
  140.         };
  141.         return options;
  142.     }
  143.     else if (options.constructor == Number) {
  144.         // go to the requested slide
  145.         var num = options;
  146.         options = $(cont).data('cycle.opts');
  147.         if (!options) {
  148.             log('options not found, can not advance slide');
  149.             return false;
  150.         }
  151.         if (num < 0 || num >= options.elements.length) {
  152.             log('invalid slide index: ' + num);
  153.             return false;
  154.         }
  155.         options.nextSlide = num;
  156.         if (cont.cycleTimeout) {
  157.             clearTimeout(cont.cycleTimeout);
  158.             cont.cycleTimeout = 0;
  159.         }
  160.         if (typeof arg2 == 'string')
  161.             options.oneTimeFx = arg2;
  162.         go(options.elements, options, 1, num >= options.currSlide);
  163.         return false;
  164.     }
  165.     return options;
  166.  
  167.     function checkInstantResume(isPaused, arg2, cont) {
  168.         if (!isPaused && arg2 === true) { // resume now!
  169.             var options = $(cont).data('cycle.opts');
  170.             if (!options) {
  171.                 log('options not found, can not resume');
  172.                 return false;
  173.             }
  174.             if (cont.cycleTimeout) {
  175.                 clearTimeout(cont.cycleTimeout);
  176.                 cont.cycleTimeout = 0;
  177.             }
  178.             go(options.elements, options, 1, !options.backwards);
  179.         }
  180.     }
  181. };
  182.  
  183. function removeFilter(el, opts) {
  184.     if (!$.support.opacity && opts.cleartype && el.style.filter) {
  185.         try { el.style.removeAttribute('filter'); }
  186.         catch(smother) {} // handle old opera versions
  187.     }
  188. };
  189.  
  190. // unbind event handlers
  191. function destroy(opts) {
  192.     if (opts.next)
  193.         $(opts.next).unbind(opts.prevNextEvent);
  194.     if (opts.prev)
  195.         $(opts.prev).unbind(opts.prevNextEvent);
  196.  
  197.     if (opts.pager || opts.pagerAnchorBuilder)
  198.         $.each(opts.pagerAnchors || [], function() {
  199.             this.unbind().remove();
  200.         });
  201.     opts.pagerAnchors = null;
  202.     if (opts.destroy) // callback
  203.         opts.destroy(opts);
  204. };
  205.  
  206. // one-time initialization
  207. function buildOptions($cont, $slides, els, options, o) {
  208.     // support metadata plugin (v1.0 and v2.0)
  209.     var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
  210.     if (opts.autostop)
  211.         opts.countdown = opts.autostopCount || els.length;
  212.  
  213.     var cont = $cont[0];
  214.     $cont.data('cycle.opts', opts);
  215.     opts.$cont = $cont;
  216.     opts.stopCount = cont.cycleStop;
  217.     opts.elements = els;
  218.     opts.before = opts.before ? [opts.before] : [];
  219.     opts.after = opts.after ? [opts.after] : [];
  220.  
  221.     // push some after callbacks
  222.     if (!$.support.opacity && opts.cleartype)
  223.         opts.after.push(function() { removeFilter(this, opts); });
  224.     if (opts.continuous)
  225.         opts.after.push(function() { go(els,opts,0,!opts.backwards); });
  226.  
  227.     saveOriginalOpts(opts);
  228.  
  229.     // clearType corrections
  230.     if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
  231.         clearTypeFix($slides);
  232.  
  233.     // container requires non-static position so that slides can be position within
  234.     if ($cont.css('position') == 'static')
  235.         $cont.css('position', 'relative');
  236.     if (opts.width)
  237.         $cont.width(opts.width);
  238.     if (opts.height && opts.height != 'auto')
  239.         $cont.height(opts.height);
  240.  
  241.     if (opts.startingSlide)
  242.         opts.startingSlide = parseInt(opts.startingSlide);
  243.     else if (opts.backwards)
  244.         opts.startingSlide = els.length - 1;
  245.  
  246.     // if random, mix up the slide array
  247.     if (opts.random) {
  248.         opts.randomMap = [];
  249.         for (var i = 0; i < els.length; i++)
  250.             opts.randomMap.push(i);
  251.         opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
  252.         opts.randomIndex = 1;
  253.         opts.startingSlide = opts.randomMap[1];
  254.     }
  255.     else if (opts.startingSlide >= els.length)
  256.         opts.startingSlide = 0; // catch bogus input
  257.     opts.currSlide = opts.startingSlide || 0;
  258.     var first = opts.startingSlide;
  259.  
  260.     // set position and zIndex on all the slides
  261.     $slides.css({position: 'absolute', top:0, left:0}).css('visibility', 'hidden').each(function(i) {
  262.         var z;
  263.         if (opts.backwards)
  264.             z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i;
  265.         else
  266.             z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i;
  267.         $(this).css('z-index', z)
  268.     });
  269.  
  270.     // make sure first slide is visible
  271.     $(els[first]).css('opacity',1).css('visibility', 'visible'); // opacity bit needed to handle restart use case
  272.     removeFilter(els[first], opts);
  273.  
  274.     // stretch slides
  275.     if (opts.fit && opts.width)
  276.         $slides.width(opts.width);
  277.     if (opts.fit && opts.height && opts.height != 'auto')
  278.         $slides.height(opts.height);
  279.  
  280.     // stretch container
  281.     var reshape = opts.containerResize && !$cont.innerHeight();
  282.     if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9
  283.         var maxw = 0, maxh = 0;
  284.         for(var j=0; j < els.length; j++) {
  285.             var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight();
  286.             if (!w) w = e.offsetWidth || e.width || $e.attr('width');
  287.             if (!h) h = e.offsetHeight || e.height || $e.attr('height');
  288.             maxw = w > maxw ? w : maxw;
  289.             maxh = h > maxh ? h : maxh;
  290.         }
  291.         if (maxw > 0 && maxh > 0)
  292.             $cont.css({width:maxw+'px',height:maxh+'px'});
  293.     }
  294.  
  295.     if (opts.pause)
  296.         $cont.hover(function(){this.cyclePause++;},function(){this.cyclePause--;});
  297.  
  298.     if (supportMultiTransitions(opts) === false)
  299.         return false;
  300.  
  301.     // apparently a lot of people use image slideshows without height/width attributes on the images.
  302.     // Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that.
  303.     var requeue = false;
  304.     options.requeueAttempts = options.requeueAttempts || 0;
  305.     $slides.each(function() {
  306.         // try to get height/width of each slide
  307.         var $el = $(this);
  308.         this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0);
  309.         this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0);
  310.  
  311.         if ( $el.is('img') ) {
  312.             // sigh..  sniffing, hacking, shrugging...  this crappy hack tries to account for what browsers do when
  313.             // an image is being downloaded and the markup did not include sizing info (height/width attributes);
  314.             // there seems to be some "default" sizes used in this situation
  315.             var loadingIE   = ($.browser.msie  && this.cycleW == 28 && this.cycleH == 30 && !this.complete);
  316.             var loadingFF   = ($.browser.mozilla && this.cycleW == 34 && this.cycleH == 19 && !this.complete);
  317.             var loadingOp   = ($.browser.opera && ((this.cycleW == 42 && this.cycleH == 19) || (this.cycleW == 37 && this.cycleH == 17)) && !this.complete);
  318.             var loadingOther = (this.cycleH == 0 && this.cycleW == 0 && !this.complete);
  319.             // don't requeue for images that are still loading but have a valid size
  320.             if (loadingIE || loadingFF || loadingOp || loadingOther) {
  321.                 if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever
  322.                     log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
  323.                     setTimeout(function() {$(o.s,o.c).cycle(options)}, opts.requeueTimeout);
  324.                     requeue = true;
  325.                     return false; // break each loop
  326.                 }
  327.                 else {
  328.                     log('could not determine size of image: '+this.src, this.cycleW, this.cycleH);
  329.                 }
  330.             }
  331.         }
  332.         return true;
  333.     });
  334.  
  335.     if (requeue)
  336.         return false;
  337.  
  338.     opts.cssBefore = opts.cssBefore || {};
  339.     opts.cssAfter = opts.cssAfter || {};
  340.     opts.cssFirst = opts.cssFirst || {};
  341.     opts.animIn = opts.animIn || {};
  342.     opts.animOut = opts.animOut || {};
  343.  
  344.     $slides.not(':eq('+first+')').css(opts.cssBefore);
  345.     $($slides[first]).css(opts.cssFirst);
  346.  
  347.     if (opts.timeout) {
  348.         opts.timeout = parseInt(opts.timeout);
  349.         // ensure that timeout and speed settings are sane
  350.         if (opts.speed.constructor == String)
  351.             opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed);
  352.         if (!opts.sync)
  353.             opts.speed = opts.speed / 2;
  354.  
  355.         var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250;
  356.         while((opts.timeout - opts.speed) < buffer) // sanitize timeout
  357.             opts.timeout += opts.speed;
  358.     }
  359.     if (opts.easing)
  360.         opts.easeIn = opts.easeOut = opts.easing;
  361.     if (!opts.speedIn)
  362.         opts.speedIn = opts.speed;
  363.     if (!opts.speedOut)
  364.         opts.speedOut = opts.speed;
  365.  
  366.     opts.slideCount = els.length;
  367.     opts.currSlide = opts.lastSlide = first;
  368.     if (opts.random) {
  369.         if (++opts.randomIndex == els.length)
  370.             opts.randomIndex = 0;
  371.         opts.nextSlide = opts.randomMap[opts.randomIndex];
  372.     }
  373.     else if (opts.backwards)
  374.         opts.nextSlide = opts.startingSlide == 0 ? (els.length-1) : opts.startingSlide-1;
  375.     else
  376.         opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1;
  377.  
  378.     // run transition init fn
  379.     if (!opts.multiFx) {
  380.         var init = $.fn.cycle.transitions[opts.fx];
  381.         if ($.isFunction(init))
  382.             init($cont, $slides, opts);
  383.         else if (opts.fx != 'custom' && !opts.multiFx) {
  384.             log('unknown transition: ' + opts.fx,'; slideshow terminating');
  385.             return false;
  386.         }
  387.     }
  388.  
  389.     // fire artificial events
  390.     var e0 = $slides[first];
  391.     if (opts.before.length)
  392.         opts.before[0].apply(e0, [e0, e0, opts, true]);
  393.     if (opts.after.length)
  394.         opts.after[0].apply(e0, [e0, e0, opts, true]);
  395.  
  396.     if (opts.next)
  397.         $(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,1)});
  398.     if (opts.prev)
  399.         $(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,0)});
  400.     if (opts.pager || opts.pagerAnchorBuilder)
  401.         buildPager(els,opts);
  402.  
  403.     exposeAddSlide(opts, els);
  404.  
  405.     return opts;
  406. };
  407.  
  408. // save off original opts so we can restore after clearing state
  409. function saveOriginalOpts(opts) {
  410.     opts.original = { before: [], after: [] };
  411.     opts.original.cssBefore = $.extend({}, opts.cssBefore);
  412.     opts.original.cssAfter  = $.extend({}, opts.cssAfter);
  413.     opts.original.animIn    = $.extend({}, opts.animIn);
  414.     opts.original.animOut   = $.extend({}, opts.animOut);
  415.     $.each(opts.before, function() { opts.original.before.push(this); });
  416.     $.each(opts.after,  function() { opts.original.after.push(this); });
  417. };
  418.  
  419. function supportMultiTransitions(opts) {
  420.     var i, tx, txs = $.fn.cycle.transitions;
  421.     // look for multiple effects
  422.     if (opts.fx.indexOf(',') > 0) {
  423.         opts.multiFx = true;
  424.         opts.fxs = opts.fx.replace(/\s*/g,'').split(',');
  425.         // discard any bogus effect names
  426.         for (i=0; i < opts.fxs.length; i++) {
  427.             var fx = opts.fxs[i];
  428.             tx = txs[fx];
  429.             if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) {
  430.                 log('discarding unknown transition: ',fx);
  431.                 opts.fxs.splice(i,1);
  432.                 i--;
  433.             }
  434.         }
  435.         // if we have an empty list then we threw everything away!
  436.         if (!opts.fxs.length) {
  437.             log('No valid transitions named; slideshow terminating.');
  438.             return false;
  439.         }
  440.     }
  441.     else if (opts.fx == 'all') {  // auto-gen the list of transitions
  442.         opts.multiFx = true;
  443.         opts.fxs = [];
  444.         for (p in txs) {
  445.             tx = txs[p];
  446.             if (txs.hasOwnProperty(p) && $.isFunction(tx))
  447.                 opts.fxs.push(p);
  448.         }
  449.     }
  450.     if (opts.multiFx && opts.randomizeEffects) {
  451.         // munge the fxs array to make effect selection random
  452.         var r1 = Math.floor(Math.random() * 20) + 30;
  453.         for (i = 0; i < r1; i++) {
  454.             var r2 = Math.floor(Math.random() * opts.fxs.length);
  455.             opts.fxs.push(opts.fxs.splice(r2,1)[0]);
  456.         }
  457.         debug('randomized fx sequence: ',opts.fxs);
  458.     }
  459.     return true;
  460. };
  461.  
  462. // provide a mechanism for adding slides after the slideshow has started
  463. function exposeAddSlide(opts, els) {
  464.     opts.addSlide = function(newSlide, prepend) {
  465.         var $s = $(newSlide), s = $s[0];
  466.         if (!opts.autostopCount)
  467.             opts.countdown++;
  468.         els[prepend?'unshift':'push'](s);
  469.         if (opts.els)
  470.             opts.els[prepend?'unshift':'push'](s); // shuffle needs this
  471.         opts.slideCount = els.length;
  472.  
  473.         $s.css('position','absolute');
  474.         $s[prepend?'prependTo':'appendTo'](opts.$cont);
  475.  
  476.         if (prepend) {
  477.             opts.currSlide++;
  478.             opts.nextSlide++;
  479.         }
  480.  
  481.         if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
  482.             clearTypeFix($s);
  483.  
  484.         if (opts.fit && opts.width)
  485.             $s.width(opts.width);
  486.         if (opts.fit && opts.height && opts.height != 'auto')
  487.             $s.height(opts.height);
  488.         s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height();
  489.         s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width();
  490.  
  491.         $s.css(opts.cssBefore);
  492.  
  493.         if (opts.pager || opts.pagerAnchorBuilder)
  494.             $.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts);
  495.  
  496.         if ($.isFunction(opts.onAddSlide))
  497.             opts.onAddSlide($s);
  498.         else
  499.             $s.css('visibility', 'hidden'); // default behavior
  500.     };
  501. }
  502.  
  503. // reset internal state; we do this on every pass in order to support multiple effects
  504. $.fn.cycle.resetState = function(opts, fx) {
  505.     fx = fx || opts.fx;
  506.     opts.before = []; opts.after = [];
  507.     opts.cssBefore = $.extend({}, opts.original.cssBefore);
  508.     opts.cssAfter  = $.extend({}, opts.original.cssAfter);
  509.     opts.animIn = $.extend({}, opts.original.animIn);
  510.     opts.animOut   = $.extend({}, opts.original.animOut);
  511.     opts.fxFn = null;
  512.     $.each(opts.original.before, function() { opts.before.push(this); });
  513.     $.each(opts.original.after,  function() { opts.after.push(this); });
  514.  
  515.     // re-init
  516.     var init = $.fn.cycle.transitions[fx];
  517.     if ($.isFunction(init))
  518.         init(opts.$cont, $(opts.elements), opts);
  519. };
  520.  
  521. // this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt
  522. function go(els, opts, manual, fwd) {
  523.     // opts.busy is true if we're in the middle of an animation
  524.     if (manual && opts.busy && opts.manualTrump) {
  525.         // let manual transitions requests trump active ones
  526.         debug('manualTrump in go(), stopping active transition');
  527.         $(els).stop(true,true);
  528.         opts.busy = 0;
  529.     }
  530.     // don't begin another timeout-based transition if there is one active
  531.     if (opts.busy) {
  532.         debug('transition active, ignoring new tx request');
  533.         return;
  534.     }
  535.  
  536.     var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide];
  537.  
  538.     // stop cycling if we have an outstanding stop request
  539.     if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual)
  540.         return;
  541.  
  542.     // check to see if we should stop cycling based on autostop options
  543.     if (!manual && !p.cyclePause && !opts.bounce &&
  544.         ((opts.autostop && (--opts.countdown <= 0)) ||
  545.         (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) {
  546.         if (opts.end)
  547.             opts.end(opts);
  548.         return;
  549.     }
  550.  
  551.     // if slideshow is paused, only transition on a manual trigger
  552.     var changed = false;
  553.     if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) {
  554.         changed = true;
  555.         var fx = opts.fx;
  556.         // keep trying to get the slide size if we don't have it yet
  557.         curr.cycleH = curr.cycleH || $(curr).height();
  558.         curr.cycleW = curr.cycleW || $(curr).width();
  559.         next.cycleH = next.cycleH || $(next).height();
  560.         next.cycleW = next.cycleW || $(next).width();
  561.  
  562.         // support multiple transition types
  563.         if (opts.multiFx) {
  564.             if (opts.lastFx == undefined || ++opts.lastFx >= opts.fxs.length)
  565.                 opts.lastFx = 0;
  566.             fx = opts.fxs[opts.lastFx];
  567.             opts.currFx = fx;
  568.         }
  569.  
  570.         // one-time fx overrides apply to:  $('div').cycle(3,'zoom');
  571.         if (opts.oneTimeFx) {
  572.             fx = opts.oneTimeFx;
  573.             opts.oneTimeFx = null;
  574.         }
  575.  
  576.         $.fn.cycle.resetState(opts, fx);
  577.  
  578.         // run the before callbacks
  579.         if (opts.before.length)
  580.             $.each(opts.before, function(i,o) {
  581.                 if (p.cycleStop != opts.stopCount) return;
  582.                 o.apply(next, [curr, next, opts, fwd]);
  583.             });
  584.  
  585.         // stage the after callacks
  586.         var after = function() {
  587.             opts.busy = 0;
  588.             $.each(opts.after, function(i,o) {
  589.                 if (p.cycleStop != opts.stopCount) return;
  590.                 o.apply(next, [curr, next, opts, fwd]);
  591.             });
  592.         };
  593.  
  594.         debug('tx firing('+fx+'); currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide);
  595.  
  596.         // get ready to perform the transition
  597.         opts.busy = 1;
  598.         if (opts.fxFn) // fx function provided?
  599.             opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
  600.         else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ?
  601.             $.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent);
  602.         else
  603.             $.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
  604.     }
  605.  
  606.     if (changed || opts.nextSlide == opts.currSlide) {
  607.         // calculate the next slide
  608.         opts.lastSlide = opts.currSlide;
  609.         if (opts.random) {
  610.             opts.currSlide = opts.nextSlide;
  611.             if (++opts.randomIndex == els.length)
  612.                 opts.randomIndex = 0;
  613.             opts.nextSlide = opts.randomMap[opts.randomIndex];
  614.             if (opts.nextSlide == opts.currSlide)
  615.                 opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1;
  616.         }
  617.         else if (opts.backwards) {
  618.             var roll = (opts.nextSlide - 1) < 0;
  619.             if (roll && opts.bounce) {
  620.                 opts.backwards = !opts.backwards;
  621.                 opts.nextSlide = 1;
  622.                 opts.currSlide = 0;
  623.             }
  624.             else {
  625.                 opts.nextSlide = roll ? (els.length-1) : opts.nextSlide-1;
  626.                 opts.currSlide = roll ? 0 : opts.nextSlide+1;
  627.             }
  628.         }
  629.         else { // sequence
  630.             var roll = (opts.nextSlide + 1) == els.length;
  631.             if (roll && opts.bounce) {
  632.                 opts.backwards = !opts.backwards;
  633.                 opts.nextSlide = els.length-2;
  634.                 opts.currSlide = els.length-1;
  635.             }
  636.             else {
  637.                 opts.nextSlide = roll ? 0 : opts.nextSlide+1;
  638.                 opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
  639.             }
  640.         }
  641.     }
  642.     if (changed && opts.pager)
  643.         opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass);
  644.  
  645.     // stage the next transition
  646.     var ms = 0;
  647.     if (opts.timeout && !opts.continuous)
  648.         ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd);
  649.     else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic
  650.         ms = 10;
  651.     if (ms > 0)
  652.         p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.backwards) }, ms);
  653. };
  654.  
  655. // invoked after transition
  656. $.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) {
  657.    $(pager).each(function() {
  658.        $(this).children().removeClass(clsName).eq(currSlide).addClass(clsName);
  659.    });
  660. };
  661.  
  662. // calculate timeout value for current transition
  663. function getTimeout(curr, next, opts, fwd) {
  664.     if (opts.timeoutFn) {
  665.         // call user provided calc fn
  666.         var t = opts.timeoutFn.call(curr,curr,next,opts,fwd);
  667.         while (opts.fx != 'none' && (t - opts.speed) < 250) // sanitize timeout
  668.             t += opts.speed;
  669.         debug('calculated timeout: ' + t + '; speed: ' + opts.speed);
  670.         if (t !== false)
  671.             return t;
  672.     }
  673.     return opts.timeout;
  674. };
  675.  
  676. // expose next/prev function, caller must pass in state
  677. $.fn.cycle.next = function(opts) { advance(opts,1); };
  678. $.fn.cycle.prev = function(opts) { advance(opts,0);};
  679.  
  680. // advance slide forward or back
  681. function advance(opts, moveForward) {
  682.     var val = moveForward ? 1 : -1;
  683.     var els = opts.elements;
  684.     var p = opts.$cont[0], timeout = p.cycleTimeout;
  685.     if (timeout) {
  686.         clearTimeout(timeout);
  687.         p.cycleTimeout = 0;
  688.     }
  689.     if (opts.random && val < 0) {
  690.         // move back to the previously display slide
  691.         opts.randomIndex--;
  692.         if (--opts.randomIndex == -2)
  693.             opts.randomIndex = els.length-2;
  694.         else if (opts.randomIndex == -1)
  695.             opts.randomIndex = els.length-1;
  696.         opts.nextSlide = opts.randomMap[opts.randomIndex];
  697.     }
  698.     else if (opts.random) {
  699.         opts.nextSlide = opts.randomMap[opts.randomIndex];
  700.     }
  701.     else {
  702.         opts.nextSlide = opts.currSlide + val;
  703.         if (opts.nextSlide < 0) {
  704.             if (opts.nowrap) return false;
  705.             opts.nextSlide = els.length - 1;
  706.         }
  707.         else if (opts.nextSlide >= els.length) {
  708.             if (opts.nowrap) return false;
  709.             opts.nextSlide = 0;
  710.         }
  711.     }
  712.  
  713.     var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated
  714.     if ($.isFunction(cb))
  715.         cb(val > 0, opts.nextSlide, els[opts.nextSlide]);
  716.     go(els, opts, 1, moveForward);
  717.     return false;
  718. };
  719.  
  720. function buildPager(els, opts) {
  721.     var $p = $(opts.pager);
  722.     $.each(els, function(i,o) {
  723.         $.fn.cycle.createPagerAnchor(i,o,$p,els,opts);
  724.     });
  725.     opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass);
  726. };
  727.  
  728. $.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) {
  729.     var a;
  730.     if ($.isFunction(opts.pagerAnchorBuilder)) {
  731.         a = opts.pagerAnchorBuilder(i,el);
  732.         debug('pagerAnchorBuilder('+i+', el) returned: ' + a);
  733.     }
  734.     else
  735.         a = '<a href="#">'+(i+1)+'</a>';
  736.  
  737.     if (!a)
  738.         return;
  739.     var $a = $(a);
  740.     // don't reparent if anchor is in the dom
  741.     if ($a.parents('body').length === 0) {
  742.         var arr = [];
  743.         if ($p.length > 1) {
  744.             $p.each(function() {
  745.                 var $clone = $a.clone(true);
  746.                 $(this).append($clone);
  747.                 arr.push($clone[0]);
  748.             });
  749.             $a = $(arr);
  750.         }
  751.         else {
  752.             $a.appendTo($p);
  753.         }
  754.     }
  755.  
  756.     opts.pagerAnchors =  opts.pagerAnchors || [];
  757.     opts.pagerAnchors.push($a);
  758.     $a.bind(opts.pagerEvent, function(e) {
  759.         e.preventDefault();
  760.         opts.nextSlide = i;
  761.         var p = opts.$cont[0], timeout = p.cycleTimeout;
  762.         if (timeout) {
  763.             clearTimeout(timeout);
  764.             p.cycleTimeout = 0;
  765.         }
  766.         var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated
  767.         if ($.isFunction(cb))
  768.             cb(opts.nextSlide, els[opts.nextSlide]);
  769.         go(els,opts,1,opts.currSlide < i); // trigger the trans
  770. //      return false; // <== allow bubble
  771.     });
  772.  
  773.     if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble)
  774.         $a.bind('click.cycle', function(){return false;}); // suppress click
  775.  
  776.     if (opts.pauseOnPagerHover)
  777.         $a.hover(function() { opts.$cont[0].cyclePause++; }, function() { opts.$cont[0].cyclePause--; } );
  778. };
  779.  
  780. // helper fn to calculate the number of slides between the current and the next
  781. $.fn.cycle.hopsFromLast = function(opts, fwd) {
  782.     var hops, l = opts.lastSlide, c = opts.currSlide;
  783.     if (fwd)
  784.         hops = c > l ? c - l : opts.slideCount - l;
  785.     else
  786.         hops = c < l ? l - c : l + opts.slideCount - c;
  787.     return hops;
  788. };
  789.  
  790. // fix clearType problems in ie6 by setting an explicit bg color
  791. // (otherwise text slides look horrible during a fade transition)
  792. function clearTypeFix($slides) {
  793.     debug('applying clearType background-color hack');
  794.     function hex(s) {
  795.         s = parseInt(s).toString(16);
  796.         return s.length < 2 ? '0'+s : s;
  797.     };
  798.     function getBg(e) {
  799.         for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) {
  800.             var v = $.css(e,'background-color');
  801.             if (v && v.indexOf('rgb') >= 0 ) {
  802.                 var rgb = v.match(/\d+/g);
  803.                 return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
  804.             }
  805.             if (v && v != 'transparent')
  806.                 return v;
  807.         }
  808.         return '#ffffff';
  809.     };
  810.     $slides.each(function() { $(this).css('background-color', getBg(this)); });
  811. };
  812.  
  813. // reset common props before the next transition
  814. $.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) {
  815.     $(opts.elements).not(curr).css('visibility', 'hidden');
  816.     if (typeof opts.cssBefore.opacity == 'undefined')
  817.         opts.cssBefore.opacity = 1;
  818.     opts.cssBefore.visibility = 'visible';
  819.     if (opts.slideResize && w !== false && next.cycleW > 0)
  820.         opts.cssBefore.width = next.cycleW;
  821.     if (opts.slideResize && h !== false && next.cycleH > 0)
  822.         opts.cssBefore.height = next.cycleH;
  823.     opts.cssAfter = opts.cssAfter || {};
  824.     opts.cssAfter.visibility = 'hidden';
  825.     $(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0));
  826.     $(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1));
  827. };
  828.  
  829. // the actual fn for effecting a transition
  830. $.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) {
  831.     var $l = $(curr), $n = $(next);
  832.     var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut;
  833.     $n.css(opts.cssBefore);
  834.     if (speedOverride) {
  835.         if (typeof speedOverride == 'number')
  836.             speedIn = speedOut = speedOverride;
  837.         else
  838.             speedIn = speedOut = 1;
  839.         easeIn = easeOut = null;
  840.     }
  841.     var fn = function() {
  842.         $n.animate(opts.animIn, speedIn, easeIn, function() {
  843.             cb();
  844.         });
  845.     };
  846.     $l.animate(opts.animOut, speedOut, easeOut, function() {
  847.         $l.css(opts.cssAfter);
  848.         if (!opts.sync)
  849.             fn();
  850.     });
  851.     if (opts.sync) fn();
  852. };
  853.  
  854. // transition definitions - only fade is defined here, transition pack defines the rest
  855. $.fn.cycle.transitions = {
  856.     fade: function($cont, $slides, opts) {
  857.         $slides.not(':eq('+opts.currSlide+')').css('opacity',0);
  858.         opts.before.push(function(curr,next,opts) {
  859.             $.fn.cycle.commonReset(curr,next,opts);
  860.             opts.cssBefore.opacity = 0;
  861.         });
  862.         opts.animIn    = { opacity: 1 };
  863.         opts.animOut   = { opacity: 0 };
  864.         opts.cssBefore = { top: 0, left: 0 };
  865.     }
  866. };
  867.  
  868. $.fn.cycle.ver = function() { return ver; };
  869.  
  870. // override these globally if you like (they are all optional)
  871. $.fn.cycle.defaults = {
  872.     activePagerClass: 'activeSlide', // class name used for the active pager link
  873.     after:         null,  // transition callback (scope set to element that was shown):  function(currSlideElement, nextSlideElement, options, forwardFlag)
  874.     allowPagerClickBubble: false, // allows or prevents click event on pager anchors from bubbling
  875.     animIn:        null,  // properties that define how the slide animates in
  876.     animOut:       null,  // properties that define how the slide animates out
  877.     autostop:      0,     // true to end slideshow after X transitions (where X == slide count)
  878.     autostopCount: 0,     // number of transitions (optionally used with autostop to define X)
  879.     backwards:     false, // true to start slideshow at last slide and move backwards through the stack
  880.     before:        null,  // transition callback (scope set to element to be shown):     function(currSlideElement, nextSlideElement, options, forwardFlag)
  881.     cleartype:     !$.support.opacity,  // true if clearType corrections should be applied (for IE)
  882.     cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
  883.     containerResize: 1,   // resize container to fit largest slide
  884.     continuous:    0,     // true to start next transition immediately after current one completes
  885.     cssAfter:      null,  // properties that defined the state of the slide after transitioning out
  886.     cssBefore:     null,  // properties that define the initial state of the slide before transitioning in
  887.     delay:         0,     // additional delay (in ms) for first transition (hint: can be negative)
  888.     easeIn:        null,  // easing for "in" transition
  889.     easeOut:       null,  // easing for "out" transition
  890.     easing:        null,  // easing method for both in and out transitions
  891.     end:           null,  // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options)
  892.     fastOnEvent:   0,     // force fast transitions when triggered manually (via pager or prev/next); value == time in ms
  893.     fit:           0,     // force slides to fit container
  894.     fx:           'fade', // name of transition effect (or comma separated names, ex: 'fade,scrollUp,shuffle')
  895.     fxFn:          null,  // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag)
  896.     height:       'auto', // container height
  897.     manualTrump:   true,  // causes manual transition to stop an active transition instead of being ignored
  898.     next:          null,  // selector for element to use as event trigger for next slide
  899.     nowrap:        0,     // true to prevent slideshow from wrapping
  900.     onPagerEvent:  null,  // callback fn for pager events: function(zeroBasedSlideIndex, slideElement)
  901.     onPrevNextEvent: null,  // callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement)
  902.     pager:         null,  // selector for element to use as pager container
  903.     pagerAnchorBuilder: null, // callback fn for building anchor links:  function(index, DOMelement)
  904.     pagerEvent:   'click.cycle', // name of event which drives the pager navigation
  905.     pause:         0,     // true to enable "pause on hover"
  906.     pauseOnPagerHover: 0, // true to pause when hovering over pager link
  907.     prev:          null,  // selector for element to use as event trigger for previous slide
  908.     prevNextEvent:'click.cycle',// event which drives the manual transition to the previous or next slide
  909.     random:        0,     // true for random, false for sequence (not applicable to shuffle fx)
  910.     randomizeEffects: 1,  // valid when multiple effects are used; true to make the effect sequence random
  911.     requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded
  912.     requeueTimeout: 250,  // ms delay for requeue
  913.     rev:           0,     // causes animations to transition in reverse (for effects that support it such as scrollHorz/scrollVert/shuffle)
  914.     shuffle:       null,  // coords for shuffle animation, ex: { top:15, left: 200 }
  915.     slideExpr:     null,  // expression for selecting slides (if something other than all children is required)
  916.     slideResize:   1,     // force slide width/height to fixed size before every transition
  917.     speed:         1000,  // speed of the transition (any valid fx speed value)
  918.     speedIn:       null,  // speed of the 'in' transition
  919.     speedOut:      null,  // speed of the 'out' transition
  920.     startingSlide: 0,     // zero-based index of the first slide to be displayed
  921.     sync:          1,     // true if in/out transitions should occur simultaneously
  922.     timeout:       4000,  // milliseconds between slide transitions (0 to disable auto advance)
  923.     timeoutFn:     null,  // callback for determining per-slide timeout value:  function(currSlideElement, nextSlideElement, options, forwardFlag)
  924.     updateActivePagerLink: null // callback fn invoked to update the active pager link (adds/removes activePagerClass style)
  925. };
  926.  
  927. })(jQuery);
  928.  
  929.  
  930. /*!
  931.  * jQuery Cycle Plugin Transition Definitions
  932.  * This script is a plugin for the jQuery Cycle Plugin
  933.  * Examples and documentation at: http://malsup.com/jquery/cycle/
  934.  * Copyright (c) 2007-2010 M. Alsup
  935.  * Version:  2.73
  936.  * Dual licensed under the MIT and GPL licenses:
  937.  * http://www.opensource.org/licenses/mit-license.php
  938.  * http://www.gnu.org/licenses/gpl.html
  939.  */
  940. (function($) {
  941.  
  942. //
  943. // These functions define slide initialization and properties for the named
  944. // transitions. To save file size feel free to remove any of these that you
  945. // don't need.
  946. //
  947. $.fn.cycle.transitions.none = function($cont, $slides, opts) {
  948.     opts.fxFn = function(curr,next,opts,after){
  949.         $(next).css('visibility', 'visible');
  950.         $(curr).css('visibility', 'hidden');
  951.         after();
  952.     };
  953. };
  954.  
  955. // not a cross-fade, fadeout only fades out the top slide
  956. $.fn.cycle.transitions.fadeout = function($cont, $slides, opts) {
  957.     $slides.not(':eq('+opts.currSlide+')').css({ visibility: 'visible', 'opacity': 1 });
  958.     opts.before.push(function(curr,next,opts,w,h,rev) {
  959.         $(curr).css('zIndex',opts.slideCount + (!rev === true ? 1 : 0));
  960.         $(next).css('zIndex',opts.slideCount + (!rev === true ? 0 : 1));
  961.     });
  962.     opts.animIn.opacity = 1;
  963.     opts.animOut.opacity = 0;
  964.     opts.cssBefore.opacity = 1;
  965.     opts.cssBefore.visibility = 'visible';
  966.     opts.cssAfter.zIndex = 0;
  967. };
  968.  
  969. // scrollUp/Down/Left/Right
  970. $.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) {
  971.     $cont.css('overflow','hidden');
  972.     opts.before.push($.fn.cycle.commonReset);
  973.     var h = $cont.height();
  974.     opts.cssBefore.top = h;
  975.     opts.cssBefore.left = 0;
  976.     opts.cssFirst.top = 0;
  977.     opts.animIn.top = 0;
  978.     opts.animOut.top = -h;
  979. };
  980. $.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) {
  981.     $cont.css('overflow','hidden');
  982.     opts.before.push($.fn.cycle.commonReset);
  983.     var h = $cont.height();
  984.     opts.cssFirst.top = 0;
  985.     opts.cssBefore.top = -h;
  986.     opts.cssBefore.left = 0;
  987.     opts.animIn.top = 0;
  988.     opts.animOut.top = h;
  989. };
  990. $.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) {
  991.     $cont.css('overflow','hidden');
  992.     opts.before.push($.fn.cycle.commonReset);
  993.     var w = $cont.width();
  994.     opts.cssFirst.left = 0;
  995.     opts.cssBefore.left = w;
  996.     opts.cssBefore.top = 0;
  997.     opts.animIn.left = 0;
  998.     opts.animOut.left = 0-w;
  999. };
  1000. $.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) {
  1001.     $cont.css('overflow','hidden');
  1002.     opts.before.push($.fn.cycle.commonReset);
  1003.     var w = $cont.width();
  1004.     opts.cssFirst.left = 0;
  1005.     opts.cssBefore.left = -w;
  1006.     opts.cssBefore.top = 0;
  1007.     opts.animIn.left = 0;
  1008.     opts.animOut.left = w;
  1009. };
  1010. $.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) {
  1011.     $cont.css('overflow','hidden').width();
  1012.     opts.before.push(function(curr, next, opts, fwd) {
  1013.         if (opts.rev)
  1014.             fwd = !fwd;
  1015.         $.fn.cycle.commonReset(curr,next,opts);
  1016.         opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW);
  1017.         opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW;
  1018.     });
  1019.     opts.cssFirst.left = 0;
  1020.     opts.cssBefore.top = 0;
  1021.     opts.animIn.left = 0;
  1022.     opts.animOut.top = 0;
  1023. };
  1024. $.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) {
  1025.     $cont.css('overflow','hidden');
  1026.     opts.before.push(function(curr, next, opts, fwd) {
  1027.         if (opts.rev)
  1028.             fwd = !fwd;
  1029.         $.fn.cycle.commonReset(curr,next,opts);
  1030.         opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1);
  1031.         opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH;
  1032.     });
  1033.     opts.cssFirst.top = 0;
  1034.     opts.cssBefore.left = 0;
  1035.     opts.animIn.top = 0;
  1036.     opts.animOut.left = 0;
  1037. };
  1038.  
  1039. // slideX/slideY
  1040. $.fn.cycle.transitions.slideX = function($cont, $slides, opts) {
  1041.     opts.before.push(function(curr, next, opts) {
  1042.         $(opts.elements).not(curr).css('visibility', 'hidden');
  1043.         $.fn.cycle.commonReset(curr,next,opts,false,true);
  1044.         opts.animIn.width = next.cycleW;
  1045.     });
  1046.     opts.cssBefore.left = 0;
  1047.     opts.cssBefore.top = 0;
  1048.     opts.cssBefore.width = 0;
  1049.     opts.animIn.width = 'show';
  1050.     opts.animOut.width = 0;
  1051. };
  1052. $.fn.cycle.transitions.slideY = function($cont, $slides, opts) {
  1053.     opts.before.push(function(curr, next, opts) {
  1054.         $(opts.elements).not(curr).css('visibility', 'hidden');
  1055.         $.fn.cycle.commonReset(curr,next,opts,true,false);
  1056.         opts.animIn.height = next.cycleH;
  1057.     });
  1058.     opts.cssBefore.left = 0;
  1059.     opts.cssBefore.top = 0;
  1060.     opts.cssBefore.height = 0;
  1061.     opts.animIn.height = 'show';
  1062.     opts.animOut.height = 0;
  1063. };
  1064.  
  1065. // shuffle
  1066. $.fn.cycle.transitions.shuffle = function($cont, $slides, opts) {
  1067.     var i, w = $cont.css('overflow', 'visible').width();
  1068.     $slides.css({left: 0, top: 0});
  1069.     opts.before.push(function(curr,next,opts) {
  1070.         $.fn.cycle.commonReset(curr,next,opts,true,true,true);
  1071.     });
  1072.     // only adjust speed once!
  1073.     if (!opts.speedAdjusted) {
  1074.         opts.speed = opts.speed / 2; // shuffle has 2 transitions
  1075.         opts.speedAdjusted = true;
  1076.     }
  1077.     opts.random = 0;
  1078.     opts.shuffle = opts.shuffle || {left:-w, top:15};
  1079.     opts.els = [];
  1080.     for (i=0; i < $slides.length; i++)
  1081.         opts.els.push($slides[i]);
  1082.  
  1083.     for (i=0; i < opts.currSlide; i++)
  1084.         opts.els.push(opts.els.shift());
  1085.  
  1086.     // custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!)
  1087.     opts.fxFn = function(curr, next, opts, cb, fwd) {
  1088.         if (opts.rev)
  1089.             fwd = !fwd;
  1090.         var $el = fwd ? $(curr) : $(next);
  1091.         $(next).css(opts.cssBefore);
  1092.         var count = opts.slideCount;
  1093.         $el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() {
  1094.             var hops = $.fn.cycle.hopsFromLast(opts, fwd);
  1095.             for (var k=0; k < hops; k++)
  1096.                 fwd ? opts.els.push(opts.els.shift()) : opts.els.unshift(opts.els.pop());
  1097.             if (fwd) {
  1098.                 for (var i=0, len=opts.els.length; i < len; i++)
  1099.                     $(opts.els[i]).css('z-index', len-i+count);
  1100.             }
  1101.             else {
  1102.                 var z = $(curr).css('z-index');
  1103.                 $el.css('z-index', parseInt(z)+1+count);
  1104.             }
  1105.             $el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() {
  1106.                 $(fwd ? this : curr).css('visibility', 'hidden');
  1107.                 if (cb) cb();
  1108.             });
  1109.         });
  1110.     };
  1111.     $.extend(opts.cssBefore, { visibility: 'visible', opacity: 1, top: 0, left: 0 });
  1112. };
  1113.  
  1114. // turnUp/Down/Left/Right
  1115. $.fn.cycle.transitions.turnUp = function($cont, $slides, opts) {
  1116.     opts.before.push(function(curr, next, opts) {
  1117.         $.fn.cycle.commonReset(curr,next,opts,true,false);
  1118.         opts.cssBefore.top = next.cycleH;
  1119.         opts.animIn.height = next.cycleH;
  1120.         opts.animOut.width = next.cycleW;
  1121.     });
  1122.     opts.cssFirst.top = 0;
  1123.     opts.cssBefore.left = 0;
  1124.     opts.cssBefore.height = 0;
  1125.     opts.animIn.top = 0;
  1126.     opts.animOut.height = 0;
  1127. };
  1128. $.fn.cycle.transitions.turnDown = function($cont, $slides, opts) {
  1129.     opts.before.push(function(curr, next, opts) {
  1130.         $.fn.cycle.commonReset(curr,next,opts,true,false);
  1131.         opts.animIn.height = next.cycleH;
  1132.         opts.animOut.top   = curr.cycleH;
  1133.     });
  1134.     opts.cssFirst.top = 0;
  1135.     opts.cssBefore.left = 0;
  1136.     opts.cssBefore.top = 0;
  1137.     opts.cssBefore.height = 0;
  1138.     opts.animOut.height = 0;
  1139. };
  1140. $.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) {
  1141.     opts.before.push(function(curr, next, opts) {
  1142.         $.fn.cycle.commonReset(curr,next,opts,false,true);
  1143.         opts.cssBefore.left = next.cycleW;
  1144.         opts.animIn.width = next.cycleW;
  1145.     });
  1146.     opts.cssBefore.top = 0;
  1147.     opts.cssBefore.width = 0;
  1148.     opts.animIn.left = 0;
  1149.     opts.animOut.width = 0;
  1150. };
  1151. $.fn.cycle.transitions.turnRight = function($cont, $slides, opts) {
  1152.     opts.before.push(function(curr, next, opts) {
  1153.         $.fn.cycle.commonReset(curr,next,opts,false,true);
  1154.         opts.animIn.width = next.cycleW;
  1155.         opts.animOut.left = curr.cycleW;
  1156.     });
  1157.     $.extend(opts.cssBefore, { top: 0, left: 0, width: 0 });
  1158.     opts.animIn.left = 0;
  1159.     opts.animOut.width = 0;
  1160. };
  1161.  
  1162. // zoom
  1163. $.fn.cycle.transitions.zoom = function($cont, $slides, opts) {
  1164.     opts.before.push(function(curr, next, opts) {
  1165.         $.fn.cycle.commonReset(curr,next,opts,false,false,true);
  1166.         opts.cssBefore.top = next.cycleH/2;
  1167.         opts.cssBefore.left = next.cycleW/2;
  1168.         $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH });
  1169.         $.extend(opts.animOut, { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 });
  1170.     });
  1171.     opts.cssFirst.top = 0;
  1172.     opts.cssFirst.left = 0;
  1173.     opts.cssBefore.width = 0;
  1174.     opts.cssBefore.height = 0;
  1175. };
  1176.  
  1177. // fadeZoom
  1178. $.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) {
  1179.     opts.before.push(function(curr, next, opts) {
  1180.         $.fn.cycle.commonReset(curr,next,opts,false,false);
  1181.         opts.cssBefore.left = next.cycleW/2;
  1182.         opts.cssBefore.top = next.cycleH/2;
  1183.         $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH });
  1184.     });
  1185.     opts.cssBefore.width = 0;
  1186.     opts.cssBefore.height = 0;
  1187.     opts.animOut.opacity = 0;
  1188. };
  1189.  
  1190. // blindX
  1191. $.fn.cycle.transitions.blindX = function($cont, $slides, opts) {
  1192.     var w = $cont.css('overflow','hidden').width();
  1193.     opts.before.push(function(curr, next, opts) {
  1194.         $.fn.cycle.commonReset(curr,next,opts);
  1195.         opts.animIn.width = next.cycleW;
  1196.         opts.animOut.left   = curr.cycleW;
  1197.     });
  1198.     opts.cssBefore.left = w;
  1199.     opts.cssBefore.top = 0;
  1200.     opts.animIn.left = 0;
  1201.     opts.animOut.left = w;
  1202. };
  1203. // blindY
  1204. $.fn.cycle.transitions.blindY = function($cont, $slides, opts) {
  1205.     var h = $cont.css('overflow','hidden').height();
  1206.     opts.before.push(function(curr, next, opts) {
  1207.         $.fn.cycle.commonReset(curr,next,opts);
  1208.         opts.animIn.height = next.cycleH;
  1209.         opts.animOut.top   = curr.cycleH;
  1210.     });
  1211.     opts.cssBefore.top = h;
  1212.     opts.cssBefore.left = 0;
  1213.     opts.animIn.top = 0;
  1214.     opts.animOut.top = h;
  1215. };
  1216. // blindZ
  1217. $.fn.cycle.transitions.blindZ = function($cont, $slides, opts) {
  1218.     var h = $cont.css('overflow','hidden').height();
  1219.     var w = $cont.width();
  1220.     opts.before.push(function(curr, next, opts) {
  1221.         $.fn.cycle.commonReset(curr,next,opts);
  1222.         opts.animIn.height = next.cycleH;
  1223.         opts.animOut.top   = curr.cycleH;
  1224.     });
  1225.     opts.cssBefore.top = h;
  1226.     opts.cssBefore.left = w;
  1227.     opts.animIn.top = 0;
  1228.     opts.animIn.left = 0;
  1229.     opts.animOut.top = h;
  1230.     opts.animOut.left = w;
  1231. };
  1232.  
  1233. // growX - grow horizontally from centered 0 width
  1234. $.fn.cycle.transitions.growX = function($cont, $slides, opts) {
  1235.     opts.before.push(function(curr, next, opts) {
  1236.         $.fn.cycle.commonReset(curr,next,opts,false,true);
  1237.         opts.cssBefore.left = this.cycleW/2;
  1238.         opts.animIn.left = 0;
  1239.         opts.animIn.width = this.cycleW;
  1240.         opts.animOut.left = 0;
  1241.     });
  1242.     opts.cssBefore.top = 0;
  1243.     opts.cssBefore.width = 0;
  1244. };
  1245. // growY - grow vertically from centered 0 height
  1246. $.fn.cycle.transitions.growY = function($cont, $slides, opts) {
  1247.     opts.before.push(function(curr, next, opts) {
  1248.         $.fn.cycle.commonReset(curr,next,opts,true,false);
  1249.         opts.cssBefore.top = this.cycleH/2;
  1250.         opts.animIn.top = 0;
  1251.         opts.animIn.height = this.cycleH;
  1252.         opts.animOut.top = 0;
  1253.     });
  1254.     opts.cssBefore.height = 0;
  1255.     opts.cssBefore.left = 0;
  1256. };
  1257.  
  1258. // curtainX - squeeze in both edges horizontally
  1259. $.fn.cycle.transitions.curtainX = function($cont, $slides, opts) {
  1260.     opts.before.push(function(curr, next, opts) {
  1261.         $.fn.cycle.commonReset(curr,next,opts,false,true,true);
  1262.         opts.cssBefore.left = next.cycleW/2;
  1263.         opts.animIn.left = 0;
  1264.         opts.animIn.width = this.cycleW;
  1265.         opts.animOut.left = curr.cycleW/2;
  1266.         opts.animOut.width = 0;
  1267.     });
  1268.     opts.cssBefore.top = 0;
  1269.     opts.cssBefore.width = 0;
  1270. };
  1271. // curtainY - squeeze in both edges vertically
  1272. $.fn.cycle.transitions.curtainY = function($cont, $slides, opts) {
  1273.     opts.before.push(function(curr, next, opts) {
  1274.         $.fn.cycle.commonReset(curr,next,opts,true,false,true);
  1275.         opts.cssBefore.top = next.cycleH/2;
  1276.         opts.animIn.top = 0;
  1277.         opts.animIn.height = next.cycleH;
  1278.         opts.animOut.top = curr.cycleH/2;
  1279.         opts.animOut.height = 0;
  1280.     });
  1281.     opts.cssBefore.height = 0;
  1282.     opts.cssBefore.left = 0;
  1283. };
  1284.  
  1285. // cover - curr slide covered by next slide
  1286. $.fn.cycle.transitions.cover = function($cont, $slides, opts) {
  1287.     var d = opts.direction || 'left';
  1288.     var w = $cont.css('overflow','hidden').width();
  1289.     var h = $cont.height();
  1290.     opts.before.push(function(curr, next, opts) {
  1291.         $.fn.cycle.commonReset(curr,next,opts);
  1292.         if (d == 'right')
  1293.             opts.cssBefore.left = -w;
  1294.         else if (d == 'up')
  1295.             opts.cssBefore.top = h;
  1296.         else if (d == 'down')
  1297.             opts.cssBefore.top = -h;
  1298.         else
  1299.             opts.cssBefore.left = w;
  1300.     });
  1301.     opts.animIn.left = 0;
  1302.     opts.animIn.top = 0;
  1303.     opts.cssBefore.top = 0;
  1304.     opts.cssBefore.left = 0;
  1305. };
  1306.  
  1307. // uncover - curr slide moves off next slide
  1308. $.fn.cycle.transitions.uncover = function($cont, $slides, opts) {
  1309.     var d = opts.direction || 'left';
  1310.     var w = $cont.css('overflow','hidden').width();
  1311.     var h = $cont.height();
  1312.     opts.before.push(function(curr, next, opts) {
  1313.         $.fn.cycle.commonReset(curr,next,opts,true,true,true);
  1314.         if (d == 'right')
  1315.             opts.animOut.left = w;
  1316.         else if (d == 'up')
  1317.             opts.animOut.top = -h;
  1318.         else if (d == 'down')
  1319.             opts.animOut.top = h;
  1320.         else
  1321.             opts.animOut.left = -w;
  1322.     });
  1323.     opts.animIn.left = 0;
  1324.     opts.animIn.top = 0;
  1325.     opts.cssBefore.top = 0;
  1326.     opts.cssBefore.left = 0;
  1327. };
  1328.  
  1329. // toss - move top slide and fade away
  1330. $.fn.cycle.transitions.toss = function($cont, $slides, opts) {
  1331.     var w = $cont.css('overflow','visible').width();
  1332.     var h = $cont.height();
  1333.     opts.before.push(function(curr, next, opts) {
  1334.         $.fn.cycle.commonReset(curr,next,opts,true,true,true);
  1335.         // provide default toss settings if animOut not provided
  1336.         if (!opts.animOut.left && !opts.animOut.top)
  1337.             $.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 });
  1338.         else
  1339.             opts.animOut.opacity = 0;
  1340.     });
  1341.     opts.cssBefore.left = 0;
  1342.     opts.cssBefore.top = 0;
  1343.     opts.animIn.left = 0;
  1344. };
  1345.  
  1346. // wipe - clip animation
  1347. $.fn.cycle.transitions.wipe = function($cont, $slides, opts) {
  1348.     var w = $cont.css('overflow','hidden').width();
  1349.     var h = $cont.height();
  1350.     opts.cssBefore = opts.cssBefore || {};
  1351.     var clip;
  1352.     if (opts.clip) {
  1353.         if (/l2r/.test(opts.clip))
  1354.             clip = 'rect(0px 0px '+h+'px 0px)';
  1355.         else if (/r2l/.test(opts.clip))
  1356.             clip = 'rect(0px '+w+'px '+h+'px '+w+'px)';
  1357.         else if (/t2b/.test(opts.clip))
  1358.             clip = 'rect(0px '+w+'px 0px 0px)';
  1359.         else if (/b2t/.test(opts.clip))
  1360.             clip = 'rect('+h+'px '+w+'px '+h+'px 0px)';
  1361.         else if (/zoom/.test(opts.clip)) {
  1362.             var top = parseInt(h/2);
  1363.             var left = parseInt(w/2);
  1364.             clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)';
  1365.         }
  1366.     }
  1367.  
  1368.     opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)';
  1369.  
  1370.     var d = opts.cssBefore.clip.match(/(\d+)/g);
  1371.     var t = parseInt(d[0]), r = parseInt(d[1]), b = parseInt(d[2]), l = parseInt(d[3]);
  1372.  
  1373.     opts.before.push(function(curr, next, opts) {
  1374.         if (curr == next) return;
  1375.         var $curr = $(curr), $next = $(next);
  1376.         $.fn.cycle.commonReset(curr,next,opts,true,true,false);
  1377.         opts.cssAfter.visibility = 'visible';
  1378.  
  1379.         var step = 1, count = parseInt((opts.speedIn / 13)) - 1;
  1380.         (function f() {
  1381.             var tt = t ? t - parseInt(step * (t/count)) : 0;
  1382.             var ll = l ? l - parseInt(step * (l/count)) : 0;
  1383.             var bb = b < h ? b + parseInt(step * ((h-b)/count || 1)) : h;
  1384.             var rr = r < w ? r + parseInt(step * ((w-r)/count || 1)) : w;
  1385.             $next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' });
  1386.             (step++ <= count) ? setTimeout(f, 13) : $curr.css('visibility', 'hidden');
  1387.         })();
  1388.     });
  1389.     $.extend(opts.cssBefore, { visibility: 'visible', opacity: 1, top: 0, left: 0 });
  1390.     opts.animIn    = { left: 0 };
  1391.     opts.animOut   = { left: 0 };
  1392. };
  1393.  
  1394. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement