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