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