r109828 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109827‎ | r109828 | r109829 >
Date:16:13, 23 January 2012
Author:jpostlethwaite
Status:ok (Comments)
Tags:
Comment:
Adding the jquery cycle plugin. This is being used by the UnitTest extension. See r109762.
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.cycle.all.js (added) (history)

Diff [purge]

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

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109762Adding UnitTest Extensionjpostlethwaite21:45, 22 January 2012

Comments

#Comment by Jpostlethwaite (talk | contribs)   16:17, 23 January 2012

I spoke to Roan about adding this at the SF Hackathon.

This is the latest version of the script v2.999.

Documentation for the script can be found at: http://jquery.malsup.com/cycle/

This plugin is being used to generate screenshot slideshows which were created by the Selenium with the UnitTest extension.

More documentation will be available at: https://www.mediawiki.org/wiki/Extension:UnitTest

Status & tagging log