File indexing completed on 2024-12-15 05:16:13
0001 /*! 0002 * jQuery Cycle Plugin (with Transition Definitions) 0003 * Examples and documentation at: http://jquery.malsup.com/cycle/ 0004 * Copyright (c) 2007-2010 M. Alsup 0005 * Version: 2.88 (08-JUN-2010) 0006 * Dual licensed under the MIT and GPL licenses. 0007 * http://jquery.malsup.com/license.html 0008 * Requires: jQuery v1.2.6 or later 0009 */ 0010 ;(function($) { 0011 0012 var ver = '2.88'; 0013 0014 // if $.support is not defined (pre jQuery 1.3) add what I need 0015 if ($.support == undefined) { 0016 $.support = { 0017 opacity: !($.browser.msie) 0018 }; 0019 } 0020 0021 function debug(s) { 0022 if ($.fn.cycle.debug) 0023 log(s); 0024 } 0025 function log() { 0026 if (window.console && window.console.log) 0027 window.console.log('[cycle] ' + Array.prototype.join.call(arguments,' ')); 0028 }; 0029 0030 // the options arg can be... 0031 // a number - indicates an immediate transition should occur to the given slide index 0032 // a string - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc) 0033 // an object - properties to control the slideshow 0034 // 0035 // the arg2 arg can be... 0036 // the name of an fx (only used in conjunction with a numeric value for 'options') 0037 // the value true (only used in first arg == 'resume') and indicates 0038 // that the resume should occur immediately (not wait for next timeout) 0039 0040 $.fn.cycle = function(options, arg2) { 0041 var o = { s: this.selector, c: this.context }; 0042 0043 // in 1.3+ we can fix mistakes with the ready state 0044 if (this.length === 0 && options != 'stop') { 0045 if (!$.isReady && o.s) { 0046 log('DOM not ready, queuing slideshow'); 0047 $(function() { 0048 $(o.s,o.c).cycle(options,arg2); 0049 }); 0050 return this; 0051 } 0052 // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready() 0053 log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); 0054 return this; 0055 } 0056 0057 // iterate the matched nodeset 0058 return this.each(function() { 0059 var opts = handleArguments(this, options, arg2); 0060 if (opts === false) 0061 return; 0062 0063 opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink; 0064 0065 // stop existing slideshow for this container (if there is one) 0066 if (this.cycleTimeout) 0067 clearTimeout(this.cycleTimeout); 0068 this.cycleTimeout = this.cyclePause = 0; 0069 0070 var $cont = $(this); 0071 var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children(); 0072 var els = $slides.get(); 0073 if (els.length < 2) { 0074 log('terminating; too few slides: ' + els.length); 0075 return; 0076 } 0077 0078 var opts2 = buildOptions($cont, $slides, els, opts, o); 0079 if (opts2 === false) 0080 return; 0081 0082 var startTime = opts2.continuous ? 10 : getTimeout(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.rev); 0083 0084 // if it's an auto slideshow, kick it off 0085 if (startTime) { 0086 startTime += (opts2.delay || 0); 0087 if (startTime < 10) 0088 startTime = 10; 0089 debug('first timeout: ' + startTime); 0090 this.cycleTimeout = setTimeout(function(){go(els,opts2,0,(!opts2.rev && !opts.backwards))}, startTime); 0091 } 0092 }); 0093 }; 0094 0095 // process the args that were passed to the plugin fn 0096 function handleArguments(cont, options, arg2) { 0097 if (cont.cycleStop == undefined) 0098 cont.cycleStop = 0; 0099 if (options === undefined || options === null) 0100 options = {}; 0101 if (options.constructor == String) { 0102 switch(options) { 0103 case 'destroy': 0104 case 'stop': 0105 var opts = $(cont).data('cycle.opts'); 0106 if (!opts) 0107 return false; 0108 cont.cycleStop++; // callbacks look for change 0109 if (cont.cycleTimeout) 0110 clearTimeout(cont.cycleTimeout); 0111 cont.cycleTimeout = 0; 0112 $(cont).removeData('cycle.opts'); 0113 if (options == 'destroy') 0114 destroy(opts); 0115 return false; 0116 case 'toggle': 0117 cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1; 0118 checkInstantResume(cont.cyclePause, arg2, cont); 0119 return false; 0120 case 'pause': 0121 cont.cyclePause = 1; 0122 return false; 0123 case 'resume': 0124 cont.cyclePause = 0; 0125 checkInstantResume(false, arg2, cont); 0126 return false; 0127 case 'prev': 0128 case 'next': 0129 var opts = $(cont).data('cycle.opts'); 0130 if (!opts) { 0131 log('options not found, "prev/next" ignored'); 0132 return false; 0133 } 0134 $.fn.cycle[options](opts); 0135 return false; 0136 default: 0137 options = { fx: options }; 0138 }; 0139 return options; 0140 } 0141 else if (options.constructor == Number) { 0142 // go to the requested slide 0143 var num = options; 0144 options = $(cont).data('cycle.opts'); 0145 if (!options) { 0146 log('options not found, can not advance slide'); 0147 return false; 0148 } 0149 if (num < 0 || num >= options.elements.length) { 0150 log('invalid slide index: ' + num); 0151 return false; 0152 } 0153 options.nextSlide = num; 0154 if (cont.cycleTimeout) { 0155 clearTimeout(cont.cycleTimeout); 0156 cont.cycleTimeout = 0; 0157 } 0158 if (typeof arg2 == 'string') 0159 options.oneTimeFx = arg2; 0160 go(options.elements, options, 1, num >= options.currSlide); 0161 return false; 0162 } 0163 return options; 0164 0165 function checkInstantResume(isPaused, arg2, cont) { 0166 if (!isPaused && arg2 === true) { // resume now! 0167 var options = $(cont).data('cycle.opts'); 0168 if (!options) { 0169 log('options not found, can not resume'); 0170 return false; 0171 } 0172 if (cont.cycleTimeout) { 0173 clearTimeout(cont.cycleTimeout); 0174 cont.cycleTimeout = 0; 0175 } 0176 go(options.elements, options, 1, (!opts.rev && !opts.backwards)); 0177 } 0178 } 0179 }; 0180 0181 function removeFilter(el, opts) { 0182 if (!$.support.opacity && opts.cleartype && el.style.filter) { 0183 try { el.style.removeAttribute('filter'); } 0184 catch(smother) {} // handle old opera versions 0185 } 0186 }; 0187 0188 // unbind event handlers 0189 function destroy(opts) { 0190 if (opts.next) 0191 $(opts.next).unbind(opts.prevNextEvent); 0192 if (opts.prev) 0193 $(opts.prev).unbind(opts.prevNextEvent); 0194 0195 if (opts.pager || opts.pagerAnchorBuilder) 0196 $.each(opts.pagerAnchors || [], function() { 0197 this.unbind().remove(); 0198 }); 0199 opts.pagerAnchors = null; 0200 if (opts.destroy) // callback 0201 opts.destroy(opts); 0202 }; 0203 0204 // one-time initialization 0205 function buildOptions($cont, $slides, els, options, o) { 0206 // support metadata plugin (v1.0 and v2.0) 0207 var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {}); 0208 if (opts.autostop) 0209 opts.countdown = opts.autostopCount || els.length; 0210 0211 var cont = $cont[0]; 0212 $cont.data('cycle.opts', opts); 0213 opts.$cont = $cont; 0214 opts.stopCount = cont.cycleStop; 0215 opts.elements = els; 0216 opts.before = opts.before ? [opts.before] : []; 0217 opts.after = opts.after ? [opts.after] : []; 0218 opts.after.unshift(function(){ opts.busy=0; }); 0219 0220 // push some after callbacks 0221 if (!$.support.opacity && opts.cleartype) 0222 opts.after.push(function() { removeFilter(this, opts); }); 0223 if (opts.continuous) 0224 opts.after.push(function() { go(els,opts,0,(!opts.rev && !opts.backwards)); }); 0225 0226 saveOriginalOpts(opts); 0227 0228 // clearType corrections 0229 if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) 0230 clearTypeFix($slides); 0231 0232 // container requires non-static position so that slides can be position within 0233 if ($cont.css('position') == 'static') 0234 $cont.css('position', 'relative'); 0235 if (opts.width) 0236 $cont.width(opts.width); 0237 if (opts.height && opts.height != 'auto') 0238 $cont.height(opts.height); 0239 0240 if (opts.startingSlide) 0241 opts.startingSlide = parseInt(opts.startingSlide); 0242 else if (opts.backwards) 0243 opts.startingSlide = els.length - 1; 0244 0245 // if random, mix up the slide array 0246 if (opts.random) { 0247 opts.randomMap = []; 0248 for (var i = 0; i < els.length; i++) 0249 opts.randomMap.push(i); 0250 opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); 0251 opts.randomIndex = 1; 0252 opts.startingSlide = opts.randomMap[1]; 0253 } 0254 else if (opts.startingSlide >= els.length) 0255 opts.startingSlide = 0; // catch bogus input 0256 opts.currSlide = opts.startingSlide || 0; 0257 var first = opts.startingSlide; 0258 0259 // set position and zIndex on all the slides 0260 $slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) { 0261 var z; 0262 if (opts.backwards) 0263 z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i; 0264 else 0265 z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i; 0266 $(this).css('z-index', z) 0267 }); 0268 0269 // make sure first slide is visible 0270 $(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case 0271 removeFilter(els[first], opts); 0272 0273 // stretch slides 0274 if (opts.fit && opts.width) 0275 $slides.width(opts.width); 0276 if (opts.fit && opts.height && opts.height != 'auto') 0277 $slides.height(opts.height); 0278 0279 // stretch container 0280 var reshape = opts.containerResize && !$cont.innerHeight(); 0281 if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9 0282 var maxw = 0, maxh = 0; 0283 for(var j=0; j < els.length; j++) { 0284 var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight(); 0285 if (!w) w = e.offsetWidth || e.width || $e.attr('width') 0286 if (!h) h = e.offsetHeight || e.height || $e.attr('height'); 0287 maxw = w > maxw ? w : maxw; 0288 maxh = h > maxh ? h : maxh; 0289 } 0290 if (maxw > 0 && maxh > 0) 0291 $cont.css({width:maxw+'px',height:maxh+'px'}); 0292 } 0293 0294 if (opts.pause) 0295 $cont.hover(function(){this.cyclePause++;},function(){this.cyclePause--;}); 0296 0297 if (supportMultiTransitions(opts) === false) 0298 return false; 0299 0300 // apparently a lot of people use image slideshows without height/width attributes on the images. 0301 // Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that. 0302 var requeue = false; 0303 options.requeueAttempts = options.requeueAttempts || 0; 0304 $slides.each(function() { 0305 // try to get height/width of each slide 0306 var $el = $(this); 0307 this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0); 0308 this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0); 0309 0310 if ( $el.is('img') ) { 0311 // sigh.. sniffing, hacking, shrugging... this crappy hack tries to account for what browsers do when 0312 // an image is being downloaded and the markup did not include sizing info (height/width attributes); 0313 // there seems to be some "default" sizes used in this situation 0314 var loadingIE = ($.browser.msie && this.cycleW == 28 && this.cycleH == 30 && !this.complete); 0315 var loadingFF = ($.browser.mozilla && this.cycleW == 34 && this.cycleH == 19 && !this.complete); 0316 var loadingOp = ($.browser.opera && ((this.cycleW == 42 && this.cycleH == 19) || (this.cycleW == 37 && this.cycleH == 17)) && !this.complete); 0317 var loadingOther = (this.cycleH == 0 && this.cycleW == 0 && !this.complete); 0318 // don't requeue for images that are still loading but have a valid size 0319 if (loadingIE || loadingFF || loadingOp || loadingOther) { 0320 if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever 0321 log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH); 0322 setTimeout(function() {$(o.s,o.c).cycle(options)}, opts.requeueTimeout); 0323 requeue = true; 0324 return false; // break each loop 0325 } 0326 else { 0327 log('could not determine size of image: '+this.src, this.cycleW, this.cycleH); 0328 } 0329 } 0330 } 0331 return true; 0332 }); 0333 0334 if (requeue) 0335 return false; 0336 0337 opts.cssBefore = opts.cssBefore || {}; 0338 opts.animIn = opts.animIn || {}; 0339 opts.animOut = opts.animOut || {}; 0340 0341 $slides.not(':eq('+first+')').css(opts.cssBefore); 0342 if (opts.cssFirst) 0343 $($slides[first]).css(opts.cssFirst); 0344 0345 if (opts.timeout) { 0346 opts.timeout = parseInt(opts.timeout); 0347 // ensure that timeout and speed settings are sane 0348 if (opts.speed.constructor == String) 0349 opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed); 0350 if (!opts.sync) 0351 opts.speed = opts.speed / 2; 0352 0353 var buffer = opts.fx == 'shuffle' ? 500 : 250; 0354 while((opts.timeout - opts.speed) < buffer) // sanitize timeout 0355 opts.timeout += opts.speed; 0356 } 0357 if (opts.easing) 0358 opts.easeIn = opts.easeOut = opts.easing; 0359 if (!opts.speedIn) 0360 opts.speedIn = opts.speed; 0361 if (!opts.speedOut) 0362 opts.speedOut = opts.speed; 0363 0364 opts.slideCount = els.length; 0365 opts.currSlide = opts.lastSlide = first; 0366 if (opts.random) { 0367 if (++opts.randomIndex == els.length) 0368 opts.randomIndex = 0; 0369 opts.nextSlide = opts.randomMap[opts.randomIndex]; 0370 } 0371 else if (opts.backwards) 0372 opts.nextSlide = opts.startingSlide == 0 ? (els.length-1) : opts.startingSlide-1; 0373 else 0374 opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1; 0375 0376 // run transition init fn 0377 if (!opts.multiFx) { 0378 var init = $.fn.cycle.transitions[opts.fx]; 0379 if ($.isFunction(init)) 0380 init($cont, $slides, opts); 0381 else if (opts.fx != 'custom' && !opts.multiFx) { 0382 log('unknown transition: ' + opts.fx,'; slideshow terminating'); 0383 return false; 0384 } 0385 } 0386 0387 // fire artificial events 0388 var e0 = $slides[first]; 0389 if (opts.before.length) 0390 opts.before[0].apply(e0, [e0, e0, opts, true]); 0391 if (opts.after.length > 1) 0392 opts.after[1].apply(e0, [e0, e0, opts, true]); 0393 0394 if (opts.next) 0395 $(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?-1:1)}); 0396 if (opts.prev) 0397 $(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?1:-1)}); 0398 if (opts.pager || opts.pagerAnchorBuilder) 0399 buildPager(els,opts); 0400 0401 exposeAddSlide(opts, els); 0402 0403 return opts; 0404 }; 0405 0406 // save off original opts so we can restore after clearing state 0407 function saveOriginalOpts(opts) { 0408 opts.original = { before: [], after: [] }; 0409 opts.original.cssBefore = $.extend({}, opts.cssBefore); 0410 opts.original.cssAfter = $.extend({}, opts.cssAfter); 0411 opts.original.animIn = $.extend({}, opts.animIn); 0412 opts.original.animOut = $.extend({}, opts.animOut); 0413 $.each(opts.before, function() { opts.original.before.push(this); }); 0414 $.each(opts.after, function() { opts.original.after.push(this); }); 0415 }; 0416 0417 function supportMultiTransitions(opts) { 0418 var i, tx, txs = $.fn.cycle.transitions; 0419 // look for multiple effects 0420 if (opts.fx.indexOf(',') > 0) { 0421 opts.multiFx = true; 0422 opts.fxs = opts.fx.replace(/\s*/g,'').split(','); 0423 // discard any bogus effect names 0424 for (i=0; i < opts.fxs.length; i++) { 0425 var fx = opts.fxs[i]; 0426 tx = txs[fx]; 0427 if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) { 0428 log('discarding unknown transition: ',fx); 0429 opts.fxs.splice(i,1); 0430 i--; 0431 } 0432 } 0433 // if we have an empty list then we threw everything away! 0434 if (!opts.fxs.length) { 0435 log('No valid transitions named; slideshow terminating.'); 0436 return false; 0437 } 0438 } 0439 else if (opts.fx == 'all') { // auto-gen the list of transitions 0440 opts.multiFx = true; 0441 opts.fxs = []; 0442 for (p in txs) { 0443 tx = txs[p]; 0444 if (txs.hasOwnProperty(p) && $.isFunction(tx)) 0445 opts.fxs.push(p); 0446 } 0447 } 0448 if (opts.multiFx && opts.randomizeEffects) { 0449 // munge the fxs array to make effect selection random 0450 var r1 = Math.floor(Math.random() * 20) + 30; 0451 for (i = 0; i < r1; i++) { 0452 var r2 = Math.floor(Math.random() * opts.fxs.length); 0453 opts.fxs.push(opts.fxs.splice(r2,1)[0]); 0454 } 0455 debug('randomized fx sequence: ',opts.fxs); 0456 } 0457 return true; 0458 }; 0459 0460 // provide a mechanism for adding slides after the slideshow has started 0461 function exposeAddSlide(opts, els) { 0462 opts.addSlide = function(newSlide, prepend) { 0463 var $s = $(newSlide), s = $s[0]; 0464 if (!opts.autostopCount) 0465 opts.countdown++; 0466 els[prepend?'unshift':'push'](s); 0467 if (opts.els) 0468 opts.els[prepend?'unshift':'push'](s); // shuffle needs this 0469 opts.slideCount = els.length; 0470 0471 $s.css('position','absolute'); 0472 $s[prepend?'prependTo':'appendTo'](opts.$cont); 0473 0474 if (prepend) { 0475 opts.currSlide++; 0476 opts.nextSlide++; 0477 } 0478 0479 if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) 0480 clearTypeFix($s); 0481 0482 if (opts.fit && opts.width) 0483 $s.width(opts.width); 0484 if (opts.fit && opts.height && opts.height != 'auto') 0485 $slides.height(opts.height); 0486 s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height(); 0487 s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width(); 0488 0489 $s.css(opts.cssBefore); 0490 0491 if (opts.pager || opts.pagerAnchorBuilder) 0492 $.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts); 0493 0494 if ($.isFunction(opts.onAddSlide)) 0495 opts.onAddSlide($s); 0496 else 0497 $s.hide(); // default behavior 0498 }; 0499 } 0500 0501 // reset internal state; we do this on every pass in order to support multiple effects 0502 $.fn.cycle.resetState = function(opts, fx) { 0503 fx = fx || opts.fx; 0504 opts.before = []; opts.after = []; 0505 opts.cssBefore = $.extend({}, opts.original.cssBefore); 0506 opts.cssAfter = $.extend({}, opts.original.cssAfter); 0507 opts.animIn = $.extend({}, opts.original.animIn); 0508 opts.animOut = $.extend({}, opts.original.animOut); 0509 opts.fxFn = null; 0510 $.each(opts.original.before, function() { opts.before.push(this); }); 0511 $.each(opts.original.after, function() { opts.after.push(this); }); 0512 0513 // re-init 0514 var init = $.fn.cycle.transitions[fx]; 0515 if ($.isFunction(init)) 0516 init(opts.$cont, $(opts.elements), opts); 0517 }; 0518 0519 // this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt 0520 function go(els, opts, manual, fwd) { 0521 // opts.busy is true if we're in the middle of an animation 0522 if (manual && opts.busy && opts.manualTrump) { 0523 // let manual transitions requests trump active ones 0524 debug('manualTrump in go(), stopping active transition'); 0525 $(els).stop(true,true); 0526 opts.busy = false; 0527 } 0528 // don't begin another timeout-based transition if there is one active 0529 if (opts.busy) { 0530 debug('transition active, ignoring new tx request'); 0531 return; 0532 } 0533 0534 var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide]; 0535 0536 // stop cycling if we have an outstanding stop request 0537 if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual) 0538 return; 0539 0540 // check to see if we should stop cycling based on autostop options 0541 if (!manual && !p.cyclePause && !opts.bounce && 0542 ((opts.autostop && (--opts.countdown <= 0)) || 0543 (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) { 0544 if (opts.end) 0545 opts.end(opts); 0546 return; 0547 } 0548 0549 // if slideshow is paused, only transition on a manual trigger 0550 var changed = false; 0551 if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) { 0552 changed = true; 0553 var fx = opts.fx; 0554 // keep trying to get the slide size if we don't have it yet 0555 curr.cycleH = curr.cycleH || $(curr).height(); 0556 curr.cycleW = curr.cycleW || $(curr).width(); 0557 next.cycleH = next.cycleH || $(next).height(); 0558 next.cycleW = next.cycleW || $(next).width(); 0559 0560 // support multiple transition types 0561 if (opts.multiFx) { 0562 if (opts.lastFx == undefined || ++opts.lastFx >= opts.fxs.length) 0563 opts.lastFx = 0; 0564 fx = opts.fxs[opts.lastFx]; 0565 opts.currFx = fx; 0566 } 0567 0568 // one-time fx overrides apply to: $('div').cycle(3,'zoom'); 0569 if (opts.oneTimeFx) { 0570 fx = opts.oneTimeFx; 0571 opts.oneTimeFx = null; 0572 } 0573 0574 $.fn.cycle.resetState(opts, fx); 0575 0576 // run the before callbacks 0577 if (opts.before.length) 0578 $.each(opts.before, function(i,o) { 0579 if (p.cycleStop != opts.stopCount) return; 0580 o.apply(next, [curr, next, opts, fwd]); 0581 }); 0582 0583 // stage the after callacks 0584 var after = function() { 0585 $.each(opts.after, function(i,o) { 0586 if (p.cycleStop != opts.stopCount) return; 0587 o.apply(next, [curr, next, opts, fwd]); 0588 }); 0589 }; 0590 0591 debug('tx firing; currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide); 0592 0593 // get ready to perform the transition 0594 opts.busy = 1; 0595 if (opts.fxFn) // fx function provided? 0596 opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent); 0597 else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ? 0598 $.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent); 0599 else 0600 $.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent); 0601 } 0602 0603 if (changed || opts.nextSlide == opts.currSlide) { 0604 // calculate the next slide 0605 opts.lastSlide = opts.currSlide; 0606 if (opts.random) { 0607 opts.currSlide = opts.nextSlide; 0608 if (++opts.randomIndex == els.length) 0609 opts.randomIndex = 0; 0610 opts.nextSlide = opts.randomMap[opts.randomIndex]; 0611 if (opts.nextSlide == opts.currSlide) 0612 opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1; 0613 } 0614 else if (opts.backwards) { 0615 var roll = (opts.nextSlide - 1) < 0; 0616 if (roll && opts.bounce) { 0617 opts.backwards = !opts.backwards; 0618 opts.nextSlide = 1; 0619 opts.currSlide = 0; 0620 } 0621 else { 0622 opts.nextSlide = roll ? (els.length-1) : opts.nextSlide-1; 0623 opts.currSlide = roll ? 0 : opts.nextSlide+1; 0624 } 0625 } 0626 else { // sequence 0627 var roll = (opts.nextSlide + 1) == els.length; 0628 if (roll && opts.bounce) { 0629 opts.backwards = !opts.backwards; 0630 opts.nextSlide = els.length-2; 0631 opts.currSlide = els.length-1; 0632 } 0633 else { 0634 opts.nextSlide = roll ? 0 : opts.nextSlide+1; 0635 opts.currSlide = roll ? els.length-1 : opts.nextSlide-1; 0636 } 0637 } 0638 } 0639 if (changed && opts.pager) 0640 opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass); 0641 0642 // stage the next transition 0643 var ms = 0; 0644 if (opts.timeout && !opts.continuous) 0645 ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd); 0646 else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic 0647 ms = 10; 0648 if (ms > 0) 0649 p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, (!opts.rev && !opts.backwards)) }, ms); 0650 }; 0651 0652 // invoked after transition 0653 $.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) { 0654 $(pager).each(function() { 0655 $(this).children().removeClass(clsName).eq(currSlide).addClass(clsName); 0656 }); 0657 }; 0658 0659 // calculate timeout value for current transition 0660 function getTimeout(curr, next, opts, fwd) { 0661 if (opts.timeoutFn) { 0662 // call user provided calc fn 0663 var t = opts.timeoutFn.call(curr,curr,next,opts,fwd); 0664 while ((t - opts.speed) < 250) // sanitize timeout 0665 t += opts.speed; 0666 debug('calculated timeout: ' + t + '; speed: ' + opts.speed); 0667 if (t !== false) 0668 return t; 0669 } 0670 return opts.timeout; 0671 }; 0672 0673 // expose next/prev function, caller must pass in state 0674 $.fn.cycle.next = function(opts) { advance(opts, opts.rev?-1:1); }; 0675 $.fn.cycle.prev = function(opts) { advance(opts, opts.rev?1:-1);}; 0676 0677 // advance slide forward or back 0678 function advance(opts, val) { 0679 var els = opts.elements; 0680 var p = opts.$cont[0], timeout = p.cycleTimeout; 0681 if (timeout) { 0682 clearTimeout(timeout); 0683 p.cycleTimeout = 0; 0684 } 0685 if (opts.random && val < 0) { 0686 // move back to the previously display slide 0687 opts.randomIndex--; 0688 if (--opts.randomIndex == -2) 0689 opts.randomIndex = els.length-2; 0690 else if (opts.randomIndex == -1) 0691 opts.randomIndex = els.length-1; 0692 opts.nextSlide = opts.randomMap[opts.randomIndex]; 0693 } 0694 else if (opts.random) { 0695 opts.nextSlide = opts.randomMap[opts.randomIndex]; 0696 } 0697 else { 0698 opts.nextSlide = opts.currSlide + val; 0699 if (opts.nextSlide < 0) { 0700 if (opts.nowrap) return false; 0701 opts.nextSlide = els.length - 1; 0702 } 0703 else if (opts.nextSlide >= els.length) { 0704 if (opts.nowrap) return false; 0705 opts.nextSlide = 0; 0706 } 0707 } 0708 0709 var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated 0710 if ($.isFunction(cb)) 0711 cb(val > 0, opts.nextSlide, els[opts.nextSlide]); 0712 go(els, opts, 1, val>=0); 0713 return false; 0714 }; 0715 0716 function buildPager(els, opts) { 0717 var $p = $(opts.pager); 0718 $.each(els, function(i,o) { 0719 $.fn.cycle.createPagerAnchor(i,o,$p,els,opts); 0720 }); 0721 opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass); 0722 }; 0723 0724 $.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) { 0725 var a; 0726 if ($.isFunction(opts.pagerAnchorBuilder)) { 0727 a = opts.pagerAnchorBuilder(i,el); 0728 debug('pagerAnchorBuilder('+i+', el) returned: ' + a); 0729 } 0730 else 0731 a = '<a href="#">'+(i+1)+'</a>'; 0732 0733 if (!a) 0734 return; 0735 var $a = $(a); 0736 // don't reparent if anchor is in the dom 0737 if ($a.parents('body').length === 0) { 0738 var arr = []; 0739 if ($p.length > 1) { 0740 $p.each(function() { 0741 var $clone = $a.clone(true); 0742 $(this).append($clone); 0743 arr.push($clone[0]); 0744 }); 0745 $a = $(arr); 0746 } 0747 else { 0748 $a.appendTo($p); 0749 } 0750 } 0751 0752 opts.pagerAnchors = opts.pagerAnchors || []; 0753 opts.pagerAnchors.push($a); 0754 $a.bind(opts.pagerEvent, function(e) { 0755 e.preventDefault(); 0756 opts.nextSlide = i; 0757 var p = opts.$cont[0], timeout = p.cycleTimeout; 0758 if (timeout) { 0759 clearTimeout(timeout); 0760 p.cycleTimeout = 0; 0761 } 0762 var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated 0763 if ($.isFunction(cb)) 0764 cb(opts.nextSlide, els[opts.nextSlide]); 0765 go(els,opts,1,opts.currSlide < i); // trigger the trans 0766 // return false; // <== allow bubble 0767 }); 0768 0769 if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble) 0770 $a.bind('click.cycle', function(){return false;}); // suppress click 0771 0772 if (opts.pauseOnPagerHover) 0773 $a.hover(function() { opts.$cont[0].cyclePause++; }, function() { opts.$cont[0].cyclePause--; } ); 0774 }; 0775 0776 // helper fn to calculate the number of slides between the current and the next 0777 $.fn.cycle.hopsFromLast = function(opts, fwd) { 0778 var hops, l = opts.lastSlide, c = opts.currSlide; 0779 if (fwd) 0780 hops = c > l ? c - l : opts.slideCount - l; 0781 else 0782 hops = c < l ? l - c : l + opts.slideCount - c; 0783 return hops; 0784 }; 0785 0786 // fix clearType problems in ie6 by setting an explicit bg color 0787 // (otherwise text slides look horrible during a fade transition) 0788 function clearTypeFix($slides) { 0789 debug('applying clearType background-color hack'); 0790 function hex(s) { 0791 s = parseInt(s).toString(16); 0792 return s.length < 2 ? '0'+s : s; 0793 }; 0794 function getBg(e) { 0795 for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) { 0796 var v = $.css(e,'background-color'); 0797 if (v.indexOf('rgb') >= 0 ) { 0798 var rgb = v.match(/\d+/g); 0799 return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]); 0800 } 0801 if (v && v != 'transparent') 0802 return v; 0803 } 0804 return '#ffffff'; 0805 }; 0806 $slides.each(function() { $(this).css('background-color', getBg(this)); }); 0807 }; 0808 0809 // reset common props before the next transition 0810 $.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) { 0811 $(opts.elements).not(curr).hide(); 0812 opts.cssBefore.opacity = 1; 0813 opts.cssBefore.display = 'block'; 0814 if (w !== false && next.cycleW > 0) 0815 opts.cssBefore.width = next.cycleW; 0816 if (h !== false && next.cycleH > 0) 0817 opts.cssBefore.height = next.cycleH; 0818 opts.cssAfter = opts.cssAfter || {}; 0819 opts.cssAfter.display = 'none'; 0820 $(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0)); 0821 $(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1)); 0822 }; 0823 0824 // the actual fn for effecting a transition 0825 $.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) { 0826 var $l = $(curr), $n = $(next); 0827 var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut; 0828 $n.css(opts.cssBefore); 0829 if (speedOverride) { 0830 if (typeof speedOverride == 'number') 0831 speedIn = speedOut = speedOverride; 0832 else 0833 speedIn = speedOut = 1; 0834 easeIn = easeOut = null; 0835 } 0836 var fn = function() {$n.animate(opts.animIn, speedIn, easeIn, cb)}; 0837 $l.animate(opts.animOut, speedOut, easeOut, function() { 0838 if (opts.cssAfter) $l.css(opts.cssAfter); 0839 if (!opts.sync) fn(); 0840 }); 0841 if (opts.sync) fn(); 0842 }; 0843 0844 // transition definitions - only fade is defined here, transition pack defines the rest 0845 $.fn.cycle.transitions = { 0846 fade: function($cont, $slides, opts) { 0847 $slides.not(':eq('+opts.currSlide+')').css('opacity',0); 0848 opts.before.push(function(curr,next,opts) { 0849 $.fn.cycle.commonReset(curr,next,opts); 0850 opts.cssBefore.opacity = 0; 0851 }); 0852 opts.animIn = { opacity: 1 }; 0853 opts.animOut = { opacity: 0 }; 0854 opts.cssBefore = { top: 0, left: 0 }; 0855 } 0856 }; 0857 0858 $.fn.cycle.ver = function() { return ver; }; 0859 0860 // override these globally if you like (they are all optional) 0861 $.fn.cycle.defaults = { 0862 fx: 'fade', // name of transition effect (or comma separated names, ex: 'fade,scrollUp,shuffle') 0863 timeout: 4000, // milliseconds between slide transitions (0 to disable auto advance) 0864 timeoutFn: null, // callback for determining per-slide timeout value: function(currSlideElement, nextSlideElement, options, forwardFlag) 0865 continuous: 0, // true to start next transition immediately after current one completes 0866 speed: 1000, // speed of the transition (any valid fx speed value) 0867 speedIn: null, // speed of the 'in' transition 0868 speedOut: null, // speed of the 'out' transition 0869 next: null, // selector for element to use as event trigger for next slide 0870 prev: null, // selector for element to use as event trigger for previous slide 0871 // prevNextClick: null, // @deprecated; please use onPrevNextEvent instead 0872 onPrevNextEvent: null, // callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement) 0873 prevNextEvent:'click.cycle',// event which drives the manual transition to the previous or next slide 0874 pager: null, // selector for element to use as pager container 0875 //pagerClick null, // @deprecated; please use onPagerEvent instead 0876 onPagerEvent: null, // callback fn for pager events: function(zeroBasedSlideIndex, slideElement) 0877 pagerEvent: 'click.cycle', // name of event which drives the pager navigation 0878 allowPagerClickBubble: false, // allows or prevents click event on pager anchors from bubbling 0879 pagerAnchorBuilder: null, // callback fn for building anchor links: function(index, DOMelement) 0880 before: null, // transition callback (scope set to element to be shown): function(currSlideElement, nextSlideElement, options, forwardFlag) 0881 after: null, // transition callback (scope set to element that was shown): function(currSlideElement, nextSlideElement, options, forwardFlag) 0882 end: null, // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options) 0883 easing: null, // easing method for both in and out transitions 0884 easeIn: null, // easing for "in" transition 0885 easeOut: null, // easing for "out" transition 0886 shuffle: null, // coords for shuffle animation, ex: { top:15, left: 200 } 0887 animIn: null, // properties that define how the slide animates in 0888 animOut: null, // properties that define how the slide animates out 0889 cssBefore: null, // properties that define the initial state of the slide before transitioning in 0890 cssAfter: null, // properties that defined the state of the slide after transitioning out 0891 fxFn: null, // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) 0892 height: 'auto', // container height 0893 startingSlide: 0, // zero-based index of the first slide to be displayed 0894 sync: 1, // true if in/out transitions should occur simultaneously 0895 random: 0, // true for random, false for sequence (not applicable to shuffle fx) 0896 fit: 0, // force slides to fit container 0897 containerResize: 1, // resize container to fit largest slide 0898 pause: 0, // true to enable "pause on hover" 0899 pauseOnPagerHover: 0, // true to pause when hovering over pager link 0900 autostop: 0, // true to end slideshow after X transitions (where X == slide count) 0901 autostopCount: 0, // number of transitions (optionally used with autostop to define X) 0902 delay: 0, // additional delay (in ms) for first transition (hint: can be negative) 0903 slideExpr: null, // expression for selecting slides (if something other than all children is required) 0904 cleartype: !$.support.opacity, // true if clearType corrections should be applied (for IE) 0905 cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides) 0906 nowrap: 0, // true to prevent slideshow from wrapping 0907 fastOnEvent: 0, // force fast transitions when triggered manually (via pager or prev/next); value == time in ms 0908 randomizeEffects: 1, // valid when multiple effects are used; true to make the effect sequence random 0909 rev: 0, // causes animations to transition in reverse 0910 manualTrump: true, // causes manual transition to stop an active transition instead of being ignored 0911 requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded 0912 requeueTimeout: 250, // ms delay for requeue 0913 activePagerClass: 'activeSlide', // class name used for the active pager link 0914 updateActivePagerLink: null, // callback fn invoked to update the active pager link (adds/removes activePagerClass style) 0915 backwards: false // true to start slideshow at last slide and move backwards through the stack 0916 }; 0917 0918 })(jQuery); 0919 0920 0921 /*! 0922 * jQuery Cycle Plugin Transition Definitions 0923 * This script is a plugin for the jQuery Cycle Plugin 0924 * Examples and documentation at: http://malsup.com/jquery/cycle/ 0925 * Copyright (c) 2007-2010 M. Alsup 0926 * Version: 2.72 0927 * Dual licensed under the MIT and GPL licenses: 0928 * http://www.opensource.org/licenses/mit-license.php 0929 * http://www.gnu.org/licenses/gpl.html 0930 */ 0931 (function($) { 0932 0933 // 0934 // These functions define one-time slide initialization for the named 0935 // transitions. To save file size feel free to remove any of these that you 0936 // don't need. 0937 // 0938 $.fn.cycle.transitions.none = function($cont, $slides, opts) { 0939 opts.fxFn = function(curr,next,opts,after){ 0940 $(next).show(); 0941 $(curr).hide(); 0942 after(); 0943 }; 0944 } 0945 0946 // scrollUp/Down/Left/Right 0947 $.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) { 0948 $cont.css('overflow','hidden'); 0949 opts.before.push($.fn.cycle.commonReset); 0950 var h = $cont.height(); 0951 opts.cssBefore ={ top: h, left: 0 }; 0952 opts.cssFirst = { top: 0 }; 0953 opts.animIn = { top: 0 }; 0954 opts.animOut = { top: -h }; 0955 }; 0956 $.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) { 0957 $cont.css('overflow','hidden'); 0958 opts.before.push($.fn.cycle.commonReset); 0959 var h = $cont.height(); 0960 opts.cssFirst = { top: 0 }; 0961 opts.cssBefore= { top: -h, left: 0 }; 0962 opts.animIn = { top: 0 }; 0963 opts.animOut = { top: h }; 0964 }; 0965 $.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) { 0966 $cont.css('overflow','hidden'); 0967 opts.before.push($.fn.cycle.commonReset); 0968 var w = $cont.width(); 0969 opts.cssFirst = { left: 0 }; 0970 opts.cssBefore= { left: w, top: 0 }; 0971 opts.animIn = { left: 0 }; 0972 opts.animOut = { left: 0-w }; 0973 }; 0974 $.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) { 0975 $cont.css('overflow','hidden'); 0976 opts.before.push($.fn.cycle.commonReset); 0977 var w = $cont.width(); 0978 opts.cssFirst = { left: 0 }; 0979 opts.cssBefore= { left: -w, top: 0 }; 0980 opts.animIn = { left: 0 }; 0981 opts.animOut = { left: w }; 0982 }; 0983 $.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) { 0984 $cont.css('overflow','hidden').width(); 0985 opts.before.push(function(curr, next, opts, fwd) { 0986 $.fn.cycle.commonReset(curr,next,opts); 0987 opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW); 0988 opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW; 0989 }); 0990 opts.cssFirst = { left: 0 }; 0991 opts.cssBefore= { top: 0 }; 0992 opts.animIn = { left: 0 }; 0993 opts.animOut = { top: 0 }; 0994 }; 0995 $.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) { 0996 $cont.css('overflow','hidden'); 0997 opts.before.push(function(curr, next, opts, fwd) { 0998 $.fn.cycle.commonReset(curr,next,opts); 0999 opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1); 1000 opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH; 1001 }); 1002 opts.cssFirst = { top: 0 }; 1003 opts.cssBefore= { left: 0 }; 1004 opts.animIn = { top: 0 }; 1005 opts.animOut = { left: 0 }; 1006 }; 1007 1008 // slideX/slideY 1009 $.fn.cycle.transitions.slideX = function($cont, $slides, opts) { 1010 opts.before.push(function(curr, next, opts) { 1011 $(opts.elements).not(curr).hide(); 1012 $.fn.cycle.commonReset(curr,next,opts,false,true); 1013 opts.animIn.width = next.cycleW; 1014 }); 1015 opts.cssBefore = { left: 0, top: 0, width: 0 }; 1016 opts.animIn = { width: 'show' }; 1017 opts.animOut = { width: 0 }; 1018 }; 1019 $.fn.cycle.transitions.slideY = function($cont, $slides, opts) { 1020 opts.before.push(function(curr, next, opts) { 1021 $(opts.elements).not(curr).hide(); 1022 $.fn.cycle.commonReset(curr,next,opts,true,false); 1023 opts.animIn.height = next.cycleH; 1024 }); 1025 opts.cssBefore = { left: 0, top: 0, height: 0 }; 1026 opts.animIn = { height: 'show' }; 1027 opts.animOut = { height: 0 }; 1028 }; 1029 1030 // shuffle 1031 $.fn.cycle.transitions.shuffle = function($cont, $slides, opts) { 1032 var i, w = $cont.css('overflow', 'visible').width(); 1033 $slides.css({left: 0, top: 0}); 1034 opts.before.push(function(curr,next,opts) { 1035 $.fn.cycle.commonReset(curr,next,opts,true,true,true); 1036 }); 1037 // only adjust speed once! 1038 if (!opts.speedAdjusted) { 1039 opts.speed = opts.speed / 2; // shuffle has 2 transitions 1040 opts.speedAdjusted = true; 1041 } 1042 opts.random = 0; 1043 opts.shuffle = opts.shuffle || {left:-w, top:15}; 1044 opts.els = []; 1045 for (i=0; i < $slides.length; i++) 1046 opts.els.push($slides[i]); 1047 1048 for (i=0; i < opts.currSlide; i++) 1049 opts.els.push(opts.els.shift()); 1050 1051 // custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!) 1052 opts.fxFn = function(curr, next, opts, cb, fwd) { 1053 var $el = fwd ? $(curr) : $(next); 1054 $(next).css(opts.cssBefore); 1055 var count = opts.slideCount; 1056 $el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() { 1057 var hops = $.fn.cycle.hopsFromLast(opts, fwd); 1058 for (var k=0; k < hops; k++) 1059 fwd ? opts.els.push(opts.els.shift()) : opts.els.unshift(opts.els.pop()); 1060 if (fwd) { 1061 for (var i=0, len=opts.els.length; i < len; i++) 1062 $(opts.els[i]).css('z-index', len-i+count); 1063 } 1064 else { 1065 var z = $(curr).css('z-index'); 1066 $el.css('z-index', parseInt(z)+1+count); 1067 } 1068 $el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() { 1069 $(fwd ? this : curr).hide(); 1070 if (cb) cb(); 1071 }); 1072 }); 1073 }; 1074 opts.cssBefore = { display: 'block', opacity: 1, top: 0, left: 0 }; 1075 }; 1076 1077 // turnUp/Down/Left/Right 1078 $.fn.cycle.transitions.turnUp = function($cont, $slides, opts) { 1079 opts.before.push(function(curr, next, opts) { 1080 $.fn.cycle.commonReset(curr,next,opts,true,false); 1081 opts.cssBefore.top = next.cycleH; 1082 opts.animIn.height = next.cycleH; 1083 }); 1084 opts.cssFirst = { top: 0 }; 1085 opts.cssBefore = { left: 0, height: 0 }; 1086 opts.animIn = { top: 0 }; 1087 opts.animOut = { height: 0 }; 1088 }; 1089 $.fn.cycle.transitions.turnDown = function($cont, $slides, opts) { 1090 opts.before.push(function(curr, next, opts) { 1091 $.fn.cycle.commonReset(curr,next,opts,true,false); 1092 opts.animIn.height = next.cycleH; 1093 opts.animOut.top = curr.cycleH; 1094 }); 1095 opts.cssFirst = { top: 0 }; 1096 opts.cssBefore = { left: 0, top: 0, height: 0 }; 1097 opts.animOut = { height: 0 }; 1098 }; 1099 $.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) { 1100 opts.before.push(function(curr, next, opts) { 1101 $.fn.cycle.commonReset(curr,next,opts,false,true); 1102 opts.cssBefore.left = next.cycleW; 1103 opts.animIn.width = next.cycleW; 1104 }); 1105 opts.cssBefore = { top: 0, width: 0 }; 1106 opts.animIn = { left: 0 }; 1107 opts.animOut = { width: 0 }; 1108 }; 1109 $.fn.cycle.transitions.turnRight = function($cont, $slides, opts) { 1110 opts.before.push(function(curr, next, opts) { 1111 $.fn.cycle.commonReset(curr,next,opts,false,true); 1112 opts.animIn.width = next.cycleW; 1113 opts.animOut.left = curr.cycleW; 1114 }); 1115 opts.cssBefore = { top: 0, left: 0, width: 0 }; 1116 opts.animIn = { left: 0 }; 1117 opts.animOut = { width: 0 }; 1118 }; 1119 1120 // zoom 1121 $.fn.cycle.transitions.zoom = function($cont, $slides, opts) { 1122 opts.before.push(function(curr, next, opts) { 1123 $.fn.cycle.commonReset(curr,next,opts,false,false,true); 1124 opts.cssBefore.top = next.cycleH/2; 1125 opts.cssBefore.left = next.cycleW/2; 1126 opts.animIn = { top: 0, left: 0, width: next.cycleW, height: next.cycleH }; 1127 opts.animOut = { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 }; 1128 }); 1129 opts.cssFirst = { top:0, left: 0 }; 1130 opts.cssBefore = { width: 0, height: 0 }; 1131 }; 1132 1133 // fadeZoom 1134 $.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) { 1135 opts.before.push(function(curr, next, opts) { 1136 $.fn.cycle.commonReset(curr,next,opts,false,false); 1137 opts.cssBefore.left = next.cycleW/2; 1138 opts.cssBefore.top = next.cycleH/2; 1139 opts.animIn = { top: 0, left: 0, width: next.cycleW, height: next.cycleH }; 1140 }); 1141 opts.cssBefore = { width: 0, height: 0 }; 1142 opts.animOut = { opacity: 0 }; 1143 }; 1144 1145 // blindX 1146 $.fn.cycle.transitions.blindX = function($cont, $slides, opts) { 1147 var w = $cont.css('overflow','hidden').width(); 1148 opts.before.push(function(curr, next, opts) { 1149 $.fn.cycle.commonReset(curr,next,opts); 1150 opts.animIn.width = next.cycleW; 1151 opts.animOut.left = curr.cycleW; 1152 }); 1153 opts.cssBefore = { left: w, top: 0 }; 1154 opts.animIn = { left: 0 }; 1155 opts.animOut = { left: w }; 1156 }; 1157 // blindY 1158 $.fn.cycle.transitions.blindY = function($cont, $slides, opts) { 1159 var h = $cont.css('overflow','hidden').height(); 1160 opts.before.push(function(curr, next, opts) { 1161 $.fn.cycle.commonReset(curr,next,opts); 1162 opts.animIn.height = next.cycleH; 1163 opts.animOut.top = curr.cycleH; 1164 }); 1165 opts.cssBefore = { top: h, left: 0 }; 1166 opts.animIn = { top: 0 }; 1167 opts.animOut = { top: h }; 1168 }; 1169 // blindZ 1170 $.fn.cycle.transitions.blindZ = function($cont, $slides, opts) { 1171 var h = $cont.css('overflow','hidden').height(); 1172 var w = $cont.width(); 1173 opts.before.push(function(curr, next, opts) { 1174 $.fn.cycle.commonReset(curr,next,opts); 1175 opts.animIn.height = next.cycleH; 1176 opts.animOut.top = curr.cycleH; 1177 }); 1178 opts.cssBefore = { top: h, left: w }; 1179 opts.animIn = { top: 0, left: 0 }; 1180 opts.animOut = { top: h, left: w }; 1181 }; 1182 1183 // growX - grow horizontally from centered 0 width 1184 $.fn.cycle.transitions.growX = function($cont, $slides, opts) { 1185 opts.before.push(function(curr, next, opts) { 1186 $.fn.cycle.commonReset(curr,next,opts,false,true); 1187 opts.cssBefore.left = this.cycleW/2; 1188 opts.animIn = { left: 0, width: this.cycleW }; 1189 opts.animOut = { left: 0 }; 1190 }); 1191 opts.cssBefore = { width: 0, top: 0 }; 1192 }; 1193 // growY - grow vertically from centered 0 height 1194 $.fn.cycle.transitions.growY = function($cont, $slides, opts) { 1195 opts.before.push(function(curr, next, opts) { 1196 $.fn.cycle.commonReset(curr,next,opts,true,false); 1197 opts.cssBefore.top = this.cycleH/2; 1198 opts.animIn = { top: 0, height: this.cycleH }; 1199 opts.animOut = { top: 0 }; 1200 }); 1201 opts.cssBefore = { height: 0, left: 0 }; 1202 }; 1203 1204 // curtainX - squeeze in both edges horizontally 1205 $.fn.cycle.transitions.curtainX = function($cont, $slides, opts) { 1206 opts.before.push(function(curr, next, opts) { 1207 $.fn.cycle.commonReset(curr,next,opts,false,true,true); 1208 opts.cssBefore.left = next.cycleW/2; 1209 opts.animIn = { left: 0, width: this.cycleW }; 1210 opts.animOut = { left: curr.cycleW/2, width: 0 }; 1211 }); 1212 opts.cssBefore = { top: 0, width: 0 }; 1213 }; 1214 // curtainY - squeeze in both edges vertically 1215 $.fn.cycle.transitions.curtainY = function($cont, $slides, opts) { 1216 opts.before.push(function(curr, next, opts) { 1217 $.fn.cycle.commonReset(curr,next,opts,true,false,true); 1218 opts.cssBefore.top = next.cycleH/2; 1219 opts.animIn = { top: 0, height: next.cycleH }; 1220 opts.animOut = { top: curr.cycleH/2, height: 0 }; 1221 }); 1222 opts.cssBefore = { left: 0, height: 0 }; 1223 }; 1224 1225 // cover - curr slide covered by next slide 1226 $.fn.cycle.transitions.cover = function($cont, $slides, opts) { 1227 var d = opts.direction || 'left'; 1228 var w = $cont.css('overflow','hidden').width(); 1229 var h = $cont.height(); 1230 opts.before.push(function(curr, next, opts) { 1231 $.fn.cycle.commonReset(curr,next,opts); 1232 if (d == 'right') 1233 opts.cssBefore.left = -w; 1234 else if (d == 'up') 1235 opts.cssBefore.top = h; 1236 else if (d == 'down') 1237 opts.cssBefore.top = -h; 1238 else 1239 opts.cssBefore.left = w; 1240 }); 1241 opts.animIn = { left: 0, top: 0}; 1242 opts.animOut = { opacity: 1 }; 1243 opts.cssBefore = { top: 0, left: 0 }; 1244 }; 1245 1246 // uncover - curr slide moves off next slide 1247 $.fn.cycle.transitions.uncover = function($cont, $slides, opts) { 1248 var d = opts.direction || 'left'; 1249 var w = $cont.css('overflow','hidden').width(); 1250 var h = $cont.height(); 1251 opts.before.push(function(curr, next, opts) { 1252 $.fn.cycle.commonReset(curr,next,opts,true,true,true); 1253 if (d == 'right') 1254 opts.animOut.left = w; 1255 else if (d == 'up') 1256 opts.animOut.top = -h; 1257 else if (d == 'down') 1258 opts.animOut.top = h; 1259 else 1260 opts.animOut.left = -w; 1261 }); 1262 opts.animIn = { left: 0, top: 0 }; 1263 opts.animOut = { opacity: 1 }; 1264 opts.cssBefore = { top: 0, left: 0 }; 1265 }; 1266 1267 // toss - move top slide and fade away 1268 $.fn.cycle.transitions.toss = function($cont, $slides, opts) { 1269 var w = $cont.css('overflow','visible').width(); 1270 var h = $cont.height(); 1271 opts.before.push(function(curr, next, opts) { 1272 $.fn.cycle.commonReset(curr,next,opts,true,true,true); 1273 // provide default toss settings if animOut not provided 1274 if (!opts.animOut.left && !opts.animOut.top) 1275 opts.animOut = { left: w*2, top: -h/2, opacity: 0 }; 1276 else 1277 opts.animOut.opacity = 0; 1278 }); 1279 opts.cssBefore = { left: 0, top: 0 }; 1280 opts.animIn = { left: 0 }; 1281 }; 1282 1283 // wipe - clip animation 1284 $.fn.cycle.transitions.wipe = function($cont, $slides, opts) { 1285 var w = $cont.css('overflow','hidden').width(); 1286 var h = $cont.height(); 1287 opts.cssBefore = opts.cssBefore || {}; 1288 var clip; 1289 if (opts.clip) { 1290 if (/l2r/.test(opts.clip)) 1291 clip = 'rect(0px 0px '+h+'px 0px)'; 1292 else if (/r2l/.test(opts.clip)) 1293 clip = 'rect(0px '+w+'px '+h+'px '+w+'px)'; 1294 else if (/t2b/.test(opts.clip)) 1295 clip = 'rect(0px '+w+'px 0px 0px)'; 1296 else if (/b2t/.test(opts.clip)) 1297 clip = 'rect('+h+'px '+w+'px '+h+'px 0px)'; 1298 else if (/zoom/.test(opts.clip)) { 1299 var top = parseInt(h/2); 1300 var left = parseInt(w/2); 1301 clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)'; 1302 } 1303 } 1304 1305 opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)'; 1306 1307 var d = opts.cssBefore.clip.match(/(\d+)/g); 1308 var t = parseInt(d[0]), r = parseInt(d[1]), b = parseInt(d[2]), l = parseInt(d[3]); 1309 1310 opts.before.push(function(curr, next, opts) { 1311 if (curr == next) return; 1312 var $curr = $(curr), $next = $(next); 1313 $.fn.cycle.commonReset(curr,next,opts,true,true,false); 1314 opts.cssAfter.display = 'block'; 1315 1316 var step = 1, count = parseInt((opts.speedIn / 13)) - 1; 1317 (function f() { 1318 var tt = t ? t - parseInt(step * (t/count)) : 0; 1319 var ll = l ? l - parseInt(step * (l/count)) : 0; 1320 var bb = b < h ? b + parseInt(step * ((h-b)/count || 1)) : h; 1321 var rr = r < w ? r + parseInt(step * ((w-r)/count || 1)) : w; 1322 $next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' }); 1323 (step++ <= count) ? setTimeout(f, 13) : $curr.css('display', 'none'); 1324 })(); 1325 }); 1326 opts.cssBefore = { display: 'block', opacity: 1, top: 0, left: 0 }; 1327 opts.animIn = { left: 0 }; 1328 opts.animOut = { left: 0 }; 1329 }; 1330 1331 })(jQuery);