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