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