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