showoff 0.1.0 → 0.1.1

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