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