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