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