1// JavaScript Document 2/*! 3 * jQuery Cycle Plugin (with Transition Definitions) 4 * Examples and documentation at: http://jquery.malsup.com/cycle/ 5 * Copyright (c) 2007-2009 M. Alsup 6 * Version: 2.74 (03-FEB-2010) 7 * Dual licensed under the MIT and GPL licenses: 8 * http://www.opensource.org/licenses/mit-license.php 9 * http://www.gnu.org/licenses/gpl.html 10 * Requires: jQuery v1.2.6 or later 11 */ 12;(function($) { 13 14var ver = '2.74'; 15 16// if $.support is not defined (pre jQuery 1.3) add what I need 17if ($.support == undefined) { 18 $.support = { 19 opacity: !($.browser.msie) 20 }; 21} 22 23function debug(s) { 24 if ($.fn.cycle.debug) 25 log(s); 26} 27function log() { 28 if (window.console && window.console.log) 29 window.console.log('[cycle] ' + Array.prototype.join.call(arguments,' ')); 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 - 'stop', 'pause', 'resume', 'next', 'prev', 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 // stop existing slideshow for this container (if there is one) 66 if (this.cycleTimeout) 67 clearTimeout(this.cycleTimeout); 68 this.cycleTimeout = this.cyclePause = 0; 69 70 var $cont = $(this); 71 var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children(); 72 var els = $slides.get(); 73 if (els.length < 2) { 74 log('terminating; too few slides: ' + els.length); 75 return; 76 } 77 78 var opts2 = buildOptions($cont, $slides, els, opts, o); 79 if (opts2 === false) 80 return; 81 82 var startTime = opts2.continuous ? 10 : getTimeout(opts2.currSlide, opts2.nextSlide, opts2, !opts2.rev); 83 84 // if it's an auto slideshow, kick it off 85 if (startTime) { 86 startTime += (opts2.delay || 0); 87 if (startTime < 10) 88 startTime = 10; 89 debug('first timeout: ' + startTime); 90 this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts2.rev)}, startTime); 91 } 92 }); 93}; 94 95// process the args that were passed to the plugin fn 96function handleArguments(cont, options, arg2) { 97 if (cont.cycleStop == undefined) 98 cont.cycleStop = 0; 99 if (options === undefined || options === null) 100 options = {}; 101 if (options.constructor == String) { 102 switch(options) { 103 case 'stop': 104 cont.cycleStop++; // callbacks look for change 105 if (cont.cycleTimeout) 106 clearTimeout(cont.cycleTimeout); 107 cont.cycleTimeout = 0; 108 $(cont).removeData('cycle.opts'); 109 return false; 110 case 'toggle': 111 cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1; 112 return false; 113 case 'pause': 114 cont.cyclePause = 1; 115 return false; 116 case 'resume': 117 cont.cyclePause = 0; 118 if (arg2 === true) { // resume now! 119 options = $(cont).data('cycle.opts'); 120 if (!options) { 121 log('options not found, can not resume'); 122 return false; 123 } 124 if (cont.cycleTimeout) { 125 clearTimeout(cont.cycleTimeout); 126 cont.cycleTimeout = 0; 127 } 128 go(options.elements, options, 1, 1); 129 } 130 return false; 131 case 'prev': 132 case 'next': 133 var opts = $(cont).data('cycle.opts'); 134 if (!opts) { 135 log('options not found, "prev/next" ignored'); 136 return false; 137 } 138 $.fn.cycle[options](opts); 139 return false; 140 default: 141 options = { fx: options }; 142 }; 143 return options; 144 } 145 else if (options.constructor == Number) { 146 // go to the requested slide 147 var num = options; 148 options = $(cont).data('cycle.opts'); 149 if (!options) { 150 log('options not found, can not advance slide'); 151 return false; 152 } 153 if (num < 0 || num >= options.elements.length) { 154 log('invalid slide index: ' + num); 155 return false; 156 } 157 options.nextSlide = num; 158 if (cont.cycleTimeout) { 159 clearTimeout(cont.cycleTimeout);
160 cont.cycleTimeout = 0; 161 } 162 if (typeof arg2 == 'string') 163 options.oneTimeFx = arg2; 164 go(options.elements, options, 1, num >= options.currSlide); 165 return false; 166 } 167 return options; 168}; 169 170function removeFilter(el, opts) { 171 if (!$.support.opacity && opts.cleartype && el.style.filter) { 172 try { el.style.removeAttribute('filter'); } 173 catch(smother) {} // handle old opera versions 174 } 175}; 176 177// one-time initialization 178function buildOptions($cont, $slides, els, options, o) { 179 // support metadata plugin (v1.0 and v2.0) 180 var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {}); 181 if (opts.autostop) 182 opts.countdown = opts.autostopCount || els.length; 183 184 var cont = $cont[0]; 185 $cont.data('cycle.opts', opts); 186 opts.$cont = $cont; 187 opts.stopCount = cont.cycleStop; 188 opts.elements = els; 189 opts.before = opts.before ? [opts.before] : []; 190 opts.after = opts.after ? [opts.after] : []; 191 opts.after.unshift(function(){ opts.busy=0; }); 192 193 // push some after callbacks 194 if (!$.support.opacity && opts.cleartype) 195 opts.after.push(function() { removeFilter(this, opts); }); 196 if (opts.continuous) 197 opts.after.push(function() { go(els,opts,0,!opts.rev); }); 198 199 saveOriginalOpts(opts); 200 201 // clearType corrections 202 if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) 203 clearTypeFix($slides); 204 205 // container requires non-static position so that slides can be position within 206 if ($cont.css('position') == 'static') 207 $cont.css('position', 'relative'); 208 if (opts.width) 209 $cont.width(opts.width); 210 if (opts.height && opts.height != 'auto') 211 $cont.height(opts.height); 212 213 if (opts.startingSlide) 214 opts.startingSlide = parseInt(opts.startingSlide); 215 216 // if random, mix up the slide array 217 if (opts.random) { 218 opts.randomMap = []; 219 for (var i = 0; i < els.length; i++) 220 opts.randomMap.push(i); 221 opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); 222 opts.randomIndex = 0; 223 opts.startingSlide = opts.randomMap[0]; 224 } 225 else if (opts.startingSlide >= els.length) 226 opts.startingSlide = 0; // catch bogus input 227 opts.currSlide = opts.startingSlide = opts.startingSlide || 0; 228 var first = opts.startingSlide; 229 230 // set position and zIndex on all the slides 231 $slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) { 232 var z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i; 233 $(this).css('z-index', z) 234 }); 235 236 // make sure first slide is visible 237 $(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case 238 removeFilter(els[first], opts); 239 240 // stretch slides 241 if (opts.fit && opts.width) 242 $slides.width(opts.width); 243 if (opts.fit && opts.height && opts.height != 'auto') 244 $slides.height(opts.height); 245 246 // stretch container 247 var reshape = opts.containerResize && !$cont.innerHeight(); 248 if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9 249 var maxw = 0, maxh = 0; 250 for(var j=0; j < els.length; j++) { 251 var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight(); 252 if (!w) w = e.offsetWidth; 253 if (!h) h = e.offsetHeight; 254 maxw = w > maxw ? w : maxw; 255 maxh = h > maxh ? h : maxh; 256 } 257 if (maxw > 0 && maxh > 0) 258 $cont.css({width:maxw+'px',height:maxh+'px'}); 259 } 260 261 if (opts.pause) 262 $cont.hover(function(){this.cyclePause++;},function(){this.cyclePause--;}); 263 264 if (supportMultiTransitions(opts) === false) 265 return false; 266 267 // apparently a lot of people use image slideshows without height/width attributes on the images. 268 // Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that. 269 var requeue = false; 270 options.requeueAttempts = options.requeueAttempts || 0; 271 $slides.each(function() { 272 // try to get height/width of each slide 273 var $el = $(this); 274 this.cycleH = (opts.fit && opts.height) ? opts.height : $el.height(); 275 this.cycleW = (opts.fit && opts.width) ? opts.width : $el.width(); 276 277 if ( $el.is('img') ) { 278 // sigh.. sniffing, hacking, shrugging... this crappy hack tries to account for what browsers do when 279 // an image is being downloaded and the markup did not include sizing info (height/width attributes); 280 // there seems to be some "default" sizes used in this situation 281 var loadingIE = ($.browser.msie && this.cycleW == 28 && this.cycleH == 30 && !this.complete); 282 var loadingFF = ($.browser.mozilla && this.cycleW == 34 && this.cycleH == 19 && !this.complete); 283 var loadingOp = ($.browser.opera && ((this.cycleW == 42 && this.cycleH == 19) || (this.cycleW == 37 && this.cycleH == 17)) && !this.complete); 284 var loadingOther = (this.cycleH == 0 && this.cycleW == 0 && !this.complete); 285 // don't requeue for images that are still loading but have a valid size 286 if (loadingIE || loadingFF || loadingOp || loadingOther) { 287 if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever 288 log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
289 setTimeout(function() {$(o.s,o.c).cycle(options)}, opts.requeueTimeout); 290 requeue = true; 291 return false; // break each loop 292 } 293 else { 294 log('could not determine size of image: '+this.src, this.cycleW, this.cycleH); 295 } 296 } 297 } 298 return true; 299 }); 300 301 if (requeue) 302 return false; 303 304 opts.cssBefore = opts.cssBefore || {}; 305 opts.animIn = opts.animIn || {}; 306 opts.animOut = opts.animOut || {}; 307 308 $slides.not(':eq('+first+')').css(opts.cssBefore); 309 if (opts.cssFirst) 310 $($slides[first]).css(opts.cssFirst); 311 312 if (opts.timeout) { 313 opts.timeout = parseInt(opts.timeout); 314 // ensure that timeout and speed settings are sane 315 if (opts.speed.constructor == String) 316 opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed); 317 if (!opts.sync) 318 opts.speed = opts.speed / 2; 319 while((opts.timeout - opts.speed) < 250) // sanitize timeout 320 opts.timeout += opts.speed; 321 } 322 if (opts.easing) 323 opts.easeIn = opts.easeOut = opts.easing; 324 if (!opts.speedIn) 325 opts.speedIn = opts.speed; 326 if (!opts.speedOut) 327 opts.speedOut = opts.speed; 328 329 opts.slideCount = els.length; 330 opts.currSlide = opts.lastSlide = first; 331 if (opts.random) { 332 opts.nextSlide = opts.currSlide; 333 if (++opts.randomIndex == els.length) 334 opts.randomIndex = 0; 335 opts.nextSlide = opts.randomMap[opts.randomIndex]; 336 } 337 else 338 opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1; 339 340 // run transition init fn 341 if (!opts.multiFx) { 342 var init = $.fn.cycle.transitions[opts.fx]; 343 if ($.isFunction(init)) 344 init($cont, $slides, opts); 345 else if (opts.fx != 'custom' && !opts.multiFx) { 346 log('unknown transition: ' + opts.fx,'; slideshow terminating'); 347 return false; 348 } 349 } 350 351 // fire artificial events 352 var e0 = $slides[first]; 353 if (opts.before.length) 354 opts.before[0].apply(e0, [e0, e0, opts, true]); 355 if (opts.after.length > 1) 356 opts.after[1].apply(e0, [e0, e0, opts, true]); 357 358 if (opts.next) 359 $(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?-1:1)}); 360 if (opts.prev) 361 $(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?1:-1)}); 362 if (opts.pager) 363 buildPager(els,opts); 364 365 exposeAddSlide(opts, els); 366 367 return opts; 368}; 369 370// save off original opts so we can restore after clearing state 371function saveOriginalOpts(opts) { 372 opts.original = { before: [], after: [] }; 373 opts.original.cssBefore = $.extend({}, opts.cssBefore); 374 opts.original.cssAfter = $.extend({}, opts.cssAfter); 375 opts.original.animIn = $.extend({}, opts.animIn); 376 opts.original.animOut = $.extend({}, opts.animOut); 377 $.each(opts.before, function() { opts.original.before.push(this); }); 378 $.each(opts.after, function() { opts.original.after.push(this); }); 379}; 380 381function supportMultiTransitions(opts) { 382 var i, tx, txs = $.fn.cycle.transitions; 383 // look for multiple effects 384 if (opts.fx.indexOf(',') > 0) { 385 opts.multiFx = true; 386 opts.fxs = opts.fx.replace(/\s*/g,'').split(','); 387 // discard any bogus effect names 388 for (i=0; i < opts.fxs.length; i++) { 389 var fx = opts.fxs[i]; 390 tx = txs[fx]; 391 if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) { 392 log('discarding unknown transition: ',fx); 393 opts.fxs.splice(i,1); 394 i--; 395 } 396 } 397 // if we have an empty list then we threw everything away! 398 if (!opts.fxs.length) { 399 log('No valid transitions named; slideshow terminating.'); 400 return false; 401 } 402 } 403 else if (opts.fx == 'all') { // auto-gen the list of transitions 404 opts.multiFx = true; 405 opts.fxs = []; 406 for (p in txs) { 407 tx = txs[p]; 408 if (txs.hasOwnProperty(p) && $.isFunction(tx)) 409 opts.fxs.push(p); 410 } 411 } 412 if (opts.multiFx && opts.randomizeEffects) { 413 // munge the fxs array to make effect selection random 414 var r1 = Math.floor(Math.random() * 20) + 30; 415 for (i = 0; i < r1; i++) { 416 var r2 = Math.floor(Math.random() * opts.fxs.length); 417 opts.fxs.push(opts.fxs.splice(r2,1)[0]); 418 } 419 debug('randomized fx sequence: ',opts.fxs); 420 } 421 return true; 422}; 423 424// provide a mechanism for adding slides after the slideshow has started 425function exposeAddSlide(opts, els) { 426 opts.addSlide = function(newSlide, prepend) {
427 var $s = $(newSlide), s = $s[0]; 428 if (!opts.autostopCount) 429 opts.countdown++; 430 els[prepend?'unshift':'push'](s); 431 if (opts.els) 432 opts.els[prepend?'unshift':'push'](s); // shuffle needs this 433 opts.slideCount = els.length; 434 435 $s.css('position','absolute'); 436 $s[prepend?'prependTo':'appendTo'](opts.$cont); 437 438 if (prepend) { 439 opts.currSlide++; 440 opts.nextSlide++; 441 } 442 443 if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) 444 clearTypeFix($s); 445 446 if (opts.fit && opts.width) 447 $s.width(opts.width); 448 if (opts.fit && opts.height && opts.height != 'auto') 449 $slides.height(opts.height); 450 s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height(); 451 s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width(); 452 453 $s.css(opts.cssBefore); 454 455 if (opts.pager) 456 $.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts); 457 458 if ($.isFunction(opts.onAddSlide)) 459 opts.onAddSlide($s); 460 else 461 $s.hide(); // default behavior 462 }; 463} 464 465// reset internal state; we do this on every pass in order to support multiple effects 466$.fn.cycle.resetState = function(opts, fx) { 467 fx = fx || opts.fx; 468 opts.before = []; opts.after = []; 469 opts.cssBefore = $.extend({}, opts.original.cssBefore); 470 opts.cssAfter = $.extend({}, opts.original.cssAfter); 471 opts.animIn = $.extend({}, opts.original.animIn); 472 opts.animOut = $.extend({}, opts.original.animOut); 473 opts.fxFn = null; 474 $.each(opts.original.before, function() { opts.before.push(this); }); 475 $.each(opts.original.after, function() { opts.after.push(this); }); 476 477 // re-init 478 var init = $.fn.cycle.transitions[fx]; 479 if ($.isFunction(init)) 480 init(opts.$cont, $(opts.elements), opts); 481}; 482 483// this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt 484function go(els, opts, manual, fwd) { 485 // opts.busy is true if we're in the middle of an animation 486 if (manual && opts.busy && opts.manualTrump) { 487 // let manual transitions requests trump active ones 488 $(els).stop(true,true); 489 opts.busy = false; 490 } 491 // don't begin another timeout-based transition if there is one active 492 if (opts.busy) 493 return; 494 495 var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide]; 496 497 // stop cycling if we have an outstanding stop request 498 if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual) 499 return; 500 501 // check to see if we should stop cycling based on autostop options 502 if (!manual && !p.cyclePause && 503 ((opts.autostop && (--opts.countdown <= 0)) || 504 (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) { 505 if (opts.end) 506 opts.end(opts); 507 return; 508 } 509 510 // if slideshow is paused, only transition on a manual trigger 511 if (manual || !p.cyclePause) { 512 var fx = opts.fx; 513 // keep trying to get the slide size if we don't have it yet 514 curr.cycleH = curr.cycleH || $(curr).height(); 515 curr.cycleW = curr.cycleW || $(curr).width(); 516 next.cycleH = next.cycleH || $(next).height(); 517 next.cycleW = next.cycleW || $(next).width(); 518 519 // support multiple transition types 520 if (opts.multiFx) { 521 if (opts.lastFx == undefined || ++opts.lastFx >= opts.fxs.length) 522 opts.lastFx = 0; 523 fx = opts.fxs[opts.lastFx]; 524 opts.currFx = fx; 525 } 526 527 // one-time fx overrides apply to: $('div').cycle(3,'zoom'); 528 if (opts.oneTimeFx) { 529 fx = opts.oneTimeFx; 530 opts.oneTimeFx = null; 531 } 532 533 $.fn.cycle.resetState(opts, fx); 534 535 // run the before callbacks 536 if (opts.before.length) 537 $.each(opts.before, function(i,o) { 538 if (p.cycleStop != opts.stopCount) return; 539 o.apply(next, [curr, next, opts, fwd]); 540 }); 541 542 // stage the after callacks 543 var after = function() { 544 $.each(opts.after, function(i,o) { 545 if (p.cycleStop != opts.stopCount) return; 546 o.apply(next, [curr, next, opts, fwd]); 547 }); 548 }; 549 550 if (opts.nextSlide != opts.currSlide) { 551 // get ready to perform the transition 552 opts.busy = 1; 553 if (opts.fxFn) // fx function provided? 554 opts.fxFn(curr, next, opts, after, fwd); 555 else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ? 556 $.fn.cycle[opts.fx](curr, next, opts, after); 557 else 558 $.fn.cycle.custom(curr, next, opts, after, manual && opts.fastOnEvent); 559 } 560 561 // calculate the next slide 562 opts.lastSlide = opts.currSlide; 563 if (opts.random) { 564 opts.currSlide = opts.nextSlide; 565 if (++opts.randomIndex == els.length) 566 opts.randomIndex = 0; 567 opts.nextSlide = opts.randomMap[opts.randomIndex]; 568 } 569 else { // sequence 570 var roll = (opts.nextSlide + 1) == els.length; 571 opts.nextSlide = roll ? 0 : opts.nextSlide+1; 572 opts.currSlide = roll ? els.length-1 : opts.nextSlide-1; 573 } 574 575 if (opts.pager) 576 $.fn.cycle.updateActivePagerLink(opts.pager, opts.currSlide); 577 } 578 579 // stage the next transition 580 var ms = 0; 581 if (opts.timeout && !opts.continuous) 582 ms = getTimeout(curr, next, opts, fwd); 583 else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic 584 ms = 10; 585 if (ms > 0) 586 p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.rev) }, ms); 587}; 588 589// invoked after transition 590$.fn.cycle.updateActivePagerLink = function(pager, currSlide) { 591 $(pager).each(function() { 592 $(this).find('a').removeClass('activeSlide').filter('a:eq('+currSlide+')').addClass('activeSlide'); 593 }); 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[0]); 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.