1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
;(function($, undefined) {
|
11
|
"use strict";
|
12
|
|
13
|
var ver = '3.0.3';
|
14
|
|
15
|
function debug(s) {
|
16
|
if ($.fn.cycle.debug)
|
17
|
log(s);
|
18
|
}
|
19
|
function log() {
|
20
|
|
21
|
if (window.console && console.log)
|
22
|
console.log('[cycle] ' + Array.prototype.join.call(arguments,' '));
|
23
|
}
|
24
|
$.expr[':'].paused = function(el) {
|
25
|
return el.cyclePause;
|
26
|
};
|
27
|
|
28
|
|
29
|
|
30
|
|
31
|
|
32
|
|
33
|
|
34
|
|
35
|
|
36
|
|
37
|
|
38
|
|
39
|
$.fn.cycle = function(options, arg2) {
|
40
|
var o = { s: this.selector, c: this.context };
|
41
|
|
42
|
|
43
|
if (this.length === 0 && options != 'stop') {
|
44
|
if (!$.isReady && o.s) {
|
45
|
log('DOM not ready, queuing slideshow');
|
46
|
$(function() {
|
47
|
$(o.s,o.c).cycle(options,arg2);
|
48
|
});
|
49
|
return this;
|
50
|
}
|
51
|
|
52
|
log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
|
53
|
return this;
|
54
|
}
|
55
|
|
56
|
|
57
|
return this.each(function() {
|
58
|
var opts = handleArguments(this, options, arg2);
|
59
|
if (opts === false)
|
60
|
return;
|
61
|
|
62
|
opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink;
|
63
|
|
64
|
|
65
|
if (this.cycleTimeout)
|
66
|
clearTimeout(this.cycleTimeout);
|
67
|
this.cycleTimeout = this.cyclePause = 0;
|
68
|
this.cycleStop = 0;
|
69
|
|
70
|
var $cont = $(this);
|
71
|
var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children();
|
72
|
var els = $slides.get();
|
73
|
|
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(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.backwards);
|
84
|
|
85
|
|
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,!opts.backwards);}, startTime);
|
92
|
}
|
93
|
});
|
94
|
};
|
95
|
|
96
|
function triggerPause(cont, byHover, onPager) {
|
97
|
var opts = $(cont).data('cycle.opts');
|
98
|
if (!opts)
|
99
|
return;
|
100
|
var paused = !!cont.cyclePause;
|
101
|
if (paused && opts.paused)
|
102
|
opts.paused(cont, opts, byHover, onPager);
|
103
|
else if (!paused && opts.resumed)
|
104
|
opts.resumed(cont, opts, byHover, onPager);
|
105
|
}
|
106
|
|
107
|
|
108
|
function handleArguments(cont, options, arg2) {
|
109
|
if (cont.cycleStop === undefined)
|
110
|
cont.cycleStop = 0;
|
111
|
if (options === undefined || options === null)
|
112
|
options = {};
|
113
|
if (options.constructor == String) {
|
114
|
switch(options) {
|
115
|
case 'destroy':
|
116
|
case 'stop':
|
117
|
var opts = $(cont).data('cycle.opts');
|
118
|
if (!opts)
|
119
|
return false;
|
120
|
cont.cycleStop++;
|
121
|
if (cont.cycleTimeout)
|
122
|
clearTimeout(cont.cycleTimeout);
|
123
|
cont.cycleTimeout = 0;
|
124
|
if (opts.elements)
|
125
|
$(opts.elements).stop();
|
126
|
$(cont).removeData('cycle.opts');
|
127
|
if (options == 'destroy')
|
128
|
destroy(cont, 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
|
opts = $(cont).data('cycle.opts');
|
147
|
if (!opts) {
|
148
|
log('options not found, "prev/next" ignored');
|
149
|
return false;
|
150
|
}
|
151
|
if (typeof arg2 == 'string')
|
152
|
opts.oneTimeFx = arg2;
|
153
|
$.fn.cycle[options](opts);
|
154
|
return false;
|
155
|
default:
|
156
|
options = { fx: options };
|
157
|
}
|
158
|
return options;
|
159
|
}
|
160
|
else if (options.constructor == Number) {
|
161
|
|
162
|
var num = options;
|
163
|
options = $(cont).data('cycle.opts');
|
164
|
if (!options) {
|
165
|
log('options not found, can not advance slide');
|
166
|
return false;
|
167
|
}
|
168
|
if (num < 0 || num >= options.elements.length) {
|
169
|
log('invalid slide index: ' + num);
|
170
|
return false;
|
171
|
}
|
172
|
options.nextSlide = num;
|
173
|
if (cont.cycleTimeout) {
|
174
|
clearTimeout(cont.cycleTimeout);
|
175
|
cont.cycleTimeout = 0;
|
176
|
}
|
177
|
if (typeof arg2 == 'string')
|
178
|
options.oneTimeFx = arg2;
|
179
|
go(options.elements, options, 1, num >= options.currSlide);
|
180
|
return false;
|
181
|
}
|
182
|
return options;
|
183
|
|
184
|
function checkInstantResume(isPaused, arg2, cont) {
|
185
|
if (!isPaused && arg2 === true) {
|
186
|
var options = $(cont).data('cycle.opts');
|
187
|
if (!options) {
|
188
|
log('options not found, can not resume');
|
189
|
return false;
|
190
|
}
|
191
|
if (cont.cycleTimeout) {
|
192
|
clearTimeout(cont.cycleTimeout);
|
193
|
cont.cycleTimeout = 0;
|
194
|
}
|
195
|
go(options.elements, options, 1, !options.backwards);
|
196
|
}
|
197
|
}
|
198
|
}
|
199
|
|
200
|
function removeFilter(el, opts) {
|
201
|
if (!$.support.opacity && opts.cleartype && el.style.filter) {
|
202
|
try { el.style.removeAttribute('filter'); }
|
203
|
catch(smother) {}
|
204
|
}
|
205
|
}
|
206
|
|
207
|
|
208
|
function destroy(cont, opts) {
|
209
|
if (opts.next)
|
210
|
$(opts.next).unbind(opts.prevNextEvent);
|
211
|
if (opts.prev)
|
212
|
$(opts.prev).unbind(opts.prevNextEvent);
|
213
|
|
214
|
if (opts.pager || opts.pagerAnchorBuilder)
|
215
|
$.each(opts.pagerAnchors || [], function() {
|
216
|
this.unbind().remove();
|
217
|
});
|
218
|
opts.pagerAnchors = null;
|
219
|
$(cont).unbind('mouseenter.cycle mouseleave.cycle');
|
220
|
if (opts.destroy)
|
221
|
opts.destroy(opts);
|
222
|
}
|
223
|
|
224
|
|
225
|
function buildOptions($cont, $slides, els, options, o) {
|
226
|
var startingSlideSpecified;
|
227
|
|
228
|
var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
|
229
|
var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
|
230
|
if (meta)
|
231
|
opts = $.extend(opts, meta);
|
232
|
if (opts.autostop)
|
233
|
opts.countdown = opts.autostopCount || els.length;
|
234
|
|
235
|
var cont = $cont[0];
|
236
|
$cont.data('cycle.opts', opts);
|
237
|
opts.$cont = $cont;
|
238
|
opts.stopCount = cont.cycleStop;
|
239
|
opts.elements = els;
|
240
|
opts.before = opts.before ? [opts.before] : [];
|
241
|
opts.after = opts.after ? [opts.after] : [];
|
242
|
|
243
|
|
244
|
if (!$.support.opacity && opts.cleartype)
|
245
|
opts.after.push(function() { removeFilter(this, opts); });
|
246
|
if (opts.continuous)
|
247
|
opts.after.push(function() { go(els,opts,0,!opts.backwards); });
|
248
|
|
249
|
saveOriginalOpts(opts);
|
250
|
|
251
|
|
252
|
if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
|
253
|
clearTypeFix($slides);
|
254
|
|
255
|
|
256
|
if ($cont.css('position') == 'static')
|
257
|
$cont.css('position', 'relative');
|
258
|
if (opts.width)
|
259
|
$cont.width(opts.width);
|
260
|
if (opts.height && opts.height != 'auto')
|
261
|
$cont.height(opts.height);
|
262
|
|
263
|
if (opts.startingSlide !== undefined) {
|
264
|
opts.startingSlide = parseInt(opts.startingSlide,10);
|
265
|
if (opts.startingSlide >= els.length || opts.startSlide < 0)
|
266
|
opts.startingSlide = 0;
|
267
|
else
|
268
|
startingSlideSpecified = true;
|
269
|
}
|
270
|
else if (opts.backwards)
|
271
|
opts.startingSlide = els.length - 1;
|
272
|
else
|
273
|
opts.startingSlide = 0;
|
274
|
|
275
|
|
276
|
if (opts.random) {
|
277
|
opts.randomMap = [];
|
278
|
for (var i = 0; i < els.length; i++)
|
279
|
opts.randomMap.push(i);
|
280
|
opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
|
281
|
if (startingSlideSpecified) {
|
282
|
|
283
|
for ( var cnt = 0; cnt < els.length; cnt++ ) {
|
284
|
if ( opts.startingSlide == opts.randomMap[cnt] ) {
|
285
|
opts.randomIndex = cnt;
|
286
|
}
|
287
|
}
|
288
|
}
|
289
|
else {
|
290
|
opts.randomIndex = 1;
|
291
|
opts.startingSlide = opts.randomMap[1];
|
292
|
}
|
293
|
}
|
294
|
else if (opts.startingSlide >= els.length)
|
295
|
opts.startingSlide = 0;
|
296
|
opts.currSlide = opts.startingSlide || 0;
|
297
|
var first = opts.startingSlide;
|
298
|
|
299
|
|
300
|
$slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) {
|
301
|
var z;
|
302
|
if (opts.backwards)
|
303
|
z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i;
|
304
|
else
|
305
|
z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i;
|
306
|
$(this).css('z-index', z);
|
307
|
});
|
308
|
|
309
|
|
310
|
$(els[first]).css('opacity',1).show();
|
311
|
removeFilter(els[first], opts);
|
312
|
|
313
|
|
314
|
if (opts.fit) {
|
315
|
if (!opts.aspect) {
|
316
|
if (opts.width)
|
317
|
$slides.width(opts.width);
|
318
|
if (opts.height && opts.height != 'auto')
|
319
|
$slides.height(opts.height);
|
320
|
} else {
|
321
|
$slides.each(function(){
|
322
|
var $slide = $(this);
|
323
|
var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect;
|
324
|
if( opts.width && $slide.width() != opts.width ) {
|
325
|
$slide.width( opts.width );
|
326
|
$slide.height( opts.width / ratio );
|
327
|
}
|
328
|
|
329
|
if( opts.height && $slide.height() < opts.height ) {
|
330
|
$slide.height( opts.height );
|
331
|
$slide.width( opts.height * ratio );
|
332
|
}
|
333
|
});
|
334
|
}
|
335
|
}
|
336
|
|
337
|
if (opts.center && ((!opts.fit) || opts.aspect)) {
|
338
|
$slides.each(function(){
|
339
|
var $slide = $(this);
|
340
|
$slide.css({
|
341
|
"margin-left": opts.width ?
|
342
|
((opts.width - $slide.width()) / 2) + "px" :
|
343
|
0,
|
344
|
"margin-top": opts.height ?
|
345
|
((opts.height - $slide.height()) / 2) + "px" :
|
346
|
0
|
347
|
});
|
348
|
});
|
349
|
}
|
350
|
|
351
|
if (opts.center && !opts.fit && !opts.slideResize) {
|
352
|
$slides.each(function(){
|
353
|
var $slide = $(this);
|
354
|
$slide.css({
|
355
|
"margin-left": opts.width ? ((opts.width - $slide.width()) / 2) + "px" : 0,
|
356
|
"margin-top": opts.height ? ((opts.height - $slide.height()) / 2) + "px" : 0
|
357
|
});
|
358
|
});
|
359
|
}
|
360
|
|
361
|
|
362
|
var reshape = (opts.containerResize || opts.containerResizeHeight) && $cont.innerHeight() < 1;
|
363
|
if (reshape) {
|
364
|
var maxw = 0, maxh = 0;
|
365
|
for(var j=0; j < els.length; j++) {
|
366
|
var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight();
|
367
|
if (!w) w = e.offsetWidth || e.width || $e.attr('width');
|
368
|
if (!h) h = e.offsetHeight || e.height || $e.attr('height');
|
369
|
maxw = w > maxw ? w : maxw;
|
370
|
maxh = h > maxh ? h : maxh;
|
371
|
}
|
372
|
if (opts.containerResize && maxw > 0 && maxh > 0)
|
373
|
$cont.css({width:maxw+'px',height:maxh+'px'});
|
374
|
if (opts.containerResizeHeight && maxh > 0)
|
375
|
$cont.css({height:maxh+'px'});
|
376
|
}
|
377
|
|
378
|
var pauseFlag = false;
|
379
|
if (opts.pause)
|
380
|
$cont.bind('mouseenter.cycle', function(){
|
381
|
pauseFlag = true;
|
382
|
this.cyclePause++;
|
383
|
triggerPause(cont, true);
|
384
|
}).bind('mouseleave.cycle', function(){
|
385
|
if (pauseFlag)
|
386
|
this.cyclePause--;
|
387
|
triggerPause(cont, true);
|
388
|
});
|
389
|
|
390
|
if (supportMultiTransitions(opts) === false)
|
391
|
return false;
|
392
|
|
393
|
|
394
|
|
395
|
var requeue = false;
|
396
|
options.requeueAttempts = options.requeueAttempts || 0;
|
397
|
$slides.each(function() {
|
398
|
|
399
|
var $el = $(this);
|
400
|
this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0);
|
401
|
this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0);
|
402
|
|
403
|
if ( $el.is('img') ) {
|
404
|
var loading = (this.cycleH === 0 && this.cycleW === 0 && !this.complete);
|
405
|
|
406
|
if (loading) {
|
407
|
if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) {
|
408
|
log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
|
409
|
setTimeout(function() {$(o.s,o.c).cycle(options);}, opts.requeueTimeout);
|
410
|
requeue = true;
|
411
|
return false;
|
412
|
}
|
413
|
else {
|
414
|
log('could not determine size of image: '+this.src, this.cycleW, this.cycleH);
|
415
|
}
|
416
|
}
|
417
|
}
|
418
|
return true;
|
419
|
});
|
420
|
|
421
|
if (requeue)
|
422
|
return false;
|
423
|
|
424
|
opts.cssBefore = opts.cssBefore || {};
|
425
|
opts.cssAfter = opts.cssAfter || {};
|
426
|
opts.cssFirst = opts.cssFirst || {};
|
427
|
opts.animIn = opts.animIn || {};
|
428
|
opts.animOut = opts.animOut || {};
|
429
|
|
430
|
$slides.not(':eq('+first+')').css(opts.cssBefore);
|
431
|
$($slides[first]).css(opts.cssFirst);
|
432
|
|
433
|
if (opts.timeout) {
|
434
|
opts.timeout = parseInt(opts.timeout,10);
|
435
|
|
436
|
if (opts.speed.constructor == String)
|
437
|
opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed,10);
|
438
|
if (!opts.sync)
|
439
|
opts.speed = opts.speed / 2;
|
440
|
|
441
|
var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250;
|
442
|
while((opts.timeout - opts.speed) < buffer)
|
443
|
opts.timeout += opts.speed;
|
444
|
}
|
445
|
if (opts.easing)
|
446
|
opts.easeIn = opts.easeOut = opts.easing;
|
447
|
if (!opts.speedIn)
|
448
|
opts.speedIn = opts.speed;
|
449
|
if (!opts.speedOut)
|
450
|
opts.speedOut = opts.speed;
|
451
|
|
452
|
opts.slideCount = els.length;
|
453
|
opts.currSlide = opts.lastSlide = first;
|
454
|
if (opts.random) {
|
455
|
if (++opts.randomIndex == els.length)
|
456
|
opts.randomIndex = 0;
|
457
|
opts.nextSlide = opts.randomMap[opts.randomIndex];
|
458
|
}
|
459
|
else if (opts.backwards)
|
460
|
opts.nextSlide = opts.startingSlide === 0 ? (els.length-1) : opts.startingSlide-1;
|
461
|
else
|
462
|
opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1;
|
463
|
|
464
|
|
465
|
if (!opts.multiFx) {
|
466
|
var init = $.fn.cycle.transitions[opts.fx];
|
467
|
if ($.isFunction(init))
|
468
|
init($cont, $slides, opts);
|
469
|
else if (opts.fx != 'custom' && !opts.multiFx) {
|
470
|
log('unknown transition: ' + opts.fx,'; slideshow terminating');
|
471
|
return false;
|
472
|
}
|
473
|
}
|
474
|
|
475
|
|
476
|
var e0 = $slides[first];
|
477
|
if (!opts.skipInitializationCallbacks) {
|
478
|
if (opts.before.length)
|
479
|
opts.before[0].apply(e0, [e0, e0, opts, true]);
|
480
|
if (opts.after.length)
|
481
|
opts.after[0].apply(e0, [e0, e0, opts, true]);
|
482
|
}
|
483
|
if (opts.next)
|
484
|
$(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,1);});
|
485
|
if (opts.prev)
|
486
|
$(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,0);});
|
487
|
if (opts.pager || opts.pagerAnchorBuilder)
|
488
|
buildPager(els,opts);
|
489
|
|
490
|
exposeAddSlide(opts, els);
|
491
|
|
492
|
return opts;
|
493
|
}
|
494
|
|
495
|
|
496
|
function saveOriginalOpts(opts) {
|
497
|
opts.original = { before: [], after: [] };
|
498
|
opts.original.cssBefore = $.extend({}, opts.cssBefore);
|
499
|
opts.original.cssAfter = $.extend({}, opts.cssAfter);
|
500
|
opts.original.animIn = $.extend({}, opts.animIn);
|
501
|
opts.original.animOut = $.extend({}, opts.animOut);
|
502
|
$.each(opts.before, function() { opts.original.before.push(this); });
|
503
|
$.each(opts.after, function() { opts.original.after.push(this); });
|
504
|
}
|
505
|
|
506
|
function supportMultiTransitions(opts) {
|
507
|
var i, tx, txs = $.fn.cycle.transitions;
|
508
|
|
509
|
if (opts.fx.indexOf(',') > 0) {
|
510
|
opts.multiFx = true;
|
511
|
opts.fxs = opts.fx.replace(/\s*/g,'').split(',');
|
512
|
|
513
|
for (i=0; i < opts.fxs.length; i++) {
|
514
|
var fx = opts.fxs[i];
|
515
|
tx = txs[fx];
|
516
|
if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) {
|
517
|
log('discarding unknown transition: ',fx);
|
518
|
opts.fxs.splice(i,1);
|
519
|
i--;
|
520
|
}
|
521
|
}
|
522
|
|
523
|
if (!opts.fxs.length) {
|
524
|
log('No valid transitions named; slideshow terminating.');
|
525
|
return false;
|
526
|
}
|
527
|
}
|
528
|
else if (opts.fx == 'all') {
|
529
|
opts.multiFx = true;
|
530
|
opts.fxs = [];
|
531
|
for (var p in txs) {
|
532
|
if (txs.hasOwnProperty(p)) {
|
533
|
tx = txs[p];
|
534
|
if (txs.hasOwnProperty(p) && $.isFunction(tx))
|
535
|
opts.fxs.push(p);
|
536
|
}
|
537
|
}
|
538
|
}
|
539
|
if (opts.multiFx && opts.randomizeEffects) {
|
540
|
|
541
|
var r1 = Math.floor(Math.random() * 20) + 30;
|
542
|
for (i = 0; i < r1; i++) {
|
543
|
var r2 = Math.floor(Math.random() * opts.fxs.length);
|
544
|
opts.fxs.push(opts.fxs.splice(r2,1)[0]);
|
545
|
}
|
546
|
debug('randomized fx sequence: ',opts.fxs);
|
547
|
}
|
548
|
return true;
|
549
|
}
|
550
|
|
551
|
|
552
|
function exposeAddSlide(opts, els) {
|
553
|
opts.addSlide = function(newSlide, prepend) {
|
554
|
var $s = $(newSlide), s = $s[0];
|
555
|
if (!opts.autostopCount)
|
556
|
opts.countdown++;
|
557
|
els[prepend?'unshift':'push'](s);
|
558
|
if (opts.els)
|
559
|
opts.els[prepend?'unshift':'push'](s);
|
560
|
opts.slideCount = els.length;
|
561
|
|
562
|
|
563
|
if (opts.random) {
|
564
|
opts.randomMap.push(opts.slideCount-1);
|
565
|
opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
|
566
|
}
|
567
|
|
568
|
$s.css('position','absolute');
|
569
|
$s[prepend?'prependTo':'appendTo'](opts.$cont);
|
570
|
|
571
|
if (prepend) {
|
572
|
opts.currSlide++;
|
573
|
opts.nextSlide++;
|
574
|
}
|
575
|
|
576
|
if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
|
577
|
clearTypeFix($s);
|
578
|
|
579
|
if (opts.fit && opts.width)
|
580
|
$s.width(opts.width);
|
581
|
if (opts.fit && opts.height && opts.height != 'auto')
|
582
|
$s.height(opts.height);
|
583
|
s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height();
|
584
|
s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width();
|
585
|
|
586
|
$s.css(opts.cssBefore);
|
587
|
|
588
|
if (opts.pager || opts.pagerAnchorBuilder)
|
589
|
$.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts);
|
590
|
|
591
|
if ($.isFunction(opts.onAddSlide))
|
592
|
opts.onAddSlide($s);
|
593
|
else
|
594
|
$s.hide();
|
595
|
};
|
596
|
}
|
597
|
|
598
|
|
599
|
$.fn.cycle.resetState = function(opts, fx) {
|
600
|
fx = fx || opts.fx;
|
601
|
opts.before = []; opts.after = [];
|
602
|
opts.cssBefore = $.extend({}, opts.original.cssBefore);
|
603
|
opts.cssAfter = $.extend({}, opts.original.cssAfter);
|
604
|
opts.animIn = $.extend({}, opts.original.animIn);
|
605
|
opts.animOut = $.extend({}, opts.original.animOut);
|
606
|
opts.fxFn = null;
|
607
|
$.each(opts.original.before, function() { opts.before.push(this); });
|
608
|
$.each(opts.original.after, function() { opts.after.push(this); });
|
609
|
|
610
|
|
611
|
var init = $.fn.cycle.transitions[fx];
|
612
|
if ($.isFunction(init))
|
613
|
init(opts.$cont, $(opts.elements), opts);
|
614
|
};
|
615
|
|
616
|
|
617
|
function go(els, opts, manual, fwd) {
|
618
|
var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide];
|
619
|
|
620
|
|
621
|
if (manual && opts.busy && opts.manualTrump) {
|
622
|
|
623
|
debug('manualTrump in go(), stopping active transition');
|
624
|
$(els).stop(true,true);
|
625
|
opts.busy = 0;
|
626
|
clearTimeout(p.cycleTimeout);
|
627
|
}
|
628
|
|
629
|
|
630
|
if (opts.busy) {
|
631
|
debug('transition active, ignoring new tx request');
|
632
|
return;
|
633
|
}
|
634
|
|
635
|
|
636
|
|
637
|
if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual)
|
638
|
return;
|
639
|
|
640
|
|
641
|
if (!manual && !p.cyclePause && !opts.bounce &&
|
642
|
((opts.autostop && (--opts.countdown <= 0)) ||
|
643
|
(opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) {
|
644
|
if (opts.end)
|
645
|
opts.end(opts);
|
646
|
return;
|
647
|
}
|
648
|
|
649
|
|
650
|
var changed = false;
|
651
|
if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) {
|
652
|
changed = true;
|
653
|
var fx = opts.fx;
|
654
|
|
655
|
curr.cycleH = curr.cycleH || $(curr).height();
|
656
|
curr.cycleW = curr.cycleW || $(curr).width();
|
657
|
next.cycleH = next.cycleH || $(next).height();
|
658
|
next.cycleW = next.cycleW || $(next).width();
|
659
|
|
660
|
|
661
|
if (opts.multiFx) {
|
662
|
if (fwd && (opts.lastFx === undefined || ++opts.lastFx >= opts.fxs.length))
|
663
|
opts.lastFx = 0;
|
664
|
else if (!fwd && (opts.lastFx === undefined || --opts.lastFx < 0))
|
665
|
opts.lastFx = opts.fxs.length - 1;
|
666
|
fx = opts.fxs[opts.lastFx];
|
667
|
}
|
668
|
|
669
|
|
670
|
if (opts.oneTimeFx) {
|
671
|
fx = opts.oneTimeFx;
|
672
|
opts.oneTimeFx = null;
|
673
|
}
|
674
|
|
675
|
$.fn.cycle.resetState(opts, fx);
|
676
|
|
677
|
|
678
|
if (opts.before.length)
|
679
|
$.each(opts.before, function(i,o) {
|
680
|
if (p.cycleStop != opts.stopCount) return;
|
681
|
o.apply(next, [curr, next, opts, fwd]);
|
682
|
});
|
683
|
|
684
|
|
685
|
var after = function() {
|
686
|
opts.busy = 0;
|
687
|
$.each(opts.after, function(i,o) {
|
688
|
if (p.cycleStop != opts.stopCount) return;
|
689
|
o.apply(next, [curr, next, opts, fwd]);
|
690
|
});
|
691
|
if (!p.cycleStop) {
|
692
|
|
693
|
queueNext();
|
694
|
}
|
695
|
};
|
696
|
|
697
|
debug('tx firing('+fx+'); currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide);
|
698
|
|
699
|
|
700
|
opts.busy = 1;
|
701
|
if (opts.fxFn)
|
702
|
opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
|
703
|
else if ($.isFunction($.fn.cycle[opts.fx]))
|
704
|
$.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent);
|
705
|
else
|
706
|
$.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
|
707
|
}
|
708
|
else {
|
709
|
queueNext();
|
710
|
}
|
711
|
|
712
|
if (changed || opts.nextSlide == opts.currSlide) {
|
713
|
|
714
|
var roll;
|
715
|
opts.lastSlide = opts.currSlide;
|
716
|
if (opts.random) {
|
717
|
opts.currSlide = opts.nextSlide;
|
718
|
if (++opts.randomIndex == els.length) {
|
719
|
opts.randomIndex = 0;
|
720
|
opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
|
721
|
}
|
722
|
opts.nextSlide = opts.randomMap[opts.randomIndex];
|
723
|
if (opts.nextSlide == opts.currSlide)
|
724
|
opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1;
|
725
|
}
|
726
|
else if (opts.backwards) {
|
727
|
roll = (opts.nextSlide - 1) < 0;
|
728
|
if (roll && opts.bounce) {
|
729
|
opts.backwards = !opts.backwards;
|
730
|
opts.nextSlide = 1;
|
731
|
opts.currSlide = 0;
|
732
|
}
|
733
|
else {
|
734
|
opts.nextSlide = roll ? (els.length-1) : opts.nextSlide-1;
|
735
|
opts.currSlide = roll ? 0 : opts.nextSlide+1;
|
736
|
}
|
737
|
}
|
738
|
else {
|
739
|
roll = (opts.nextSlide + 1) == els.length;
|
740
|
if (roll && opts.bounce) {
|
741
|
opts.backwards = !opts.backwards;
|
742
|
opts.nextSlide = els.length-2;
|
743
|
opts.currSlide = els.length-1;
|
744
|
}
|
745
|
else {
|
746
|
opts.nextSlide = roll ? 0 : opts.nextSlide+1;
|
747
|
opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
|
748
|
}
|
749
|
}
|
750
|
}
|
751
|
if (changed && opts.pager)
|
752
|
opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass);
|
753
|
|
754
|
function queueNext() {
|
755
|
|
756
|
var ms = 0, timeout = opts.timeout;
|
757
|
if (opts.timeout && !opts.continuous) {
|
758
|
ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd);
|
759
|
if (opts.fx == 'shuffle')
|
760
|
ms -= opts.speedOut;
|
761
|
}
|
762
|
else if (opts.continuous && p.cyclePause)
|
763
|
ms = 10;
|
764
|
if (ms > 0)
|
765
|
p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.backwards); }, ms);
|
766
|
}
|
767
|
}
|
768
|
|
769
|
|
770
|
$.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) {
|
771
|
$(pager).each(function() {
|
772
|
$(this).children().removeClass(clsName).eq(currSlide).addClass(clsName);
|
773
|
});
|
774
|
};
|
775
|
|
776
|
|
777
|
function getTimeout(curr, next, opts, fwd) {
|
778
|
if (opts.timeoutFn) {
|
779
|
|
780
|
var t = opts.timeoutFn.call(curr,curr,next,opts,fwd);
|
781
|
while (opts.fx != 'none' && (t - opts.speed) < 250)
|
782
|
t += opts.speed;
|
783
|
debug('calculated timeout: ' + t + '; speed: ' + opts.speed);
|
784
|
if (t !== false)
|
785
|
return t;
|
786
|
}
|
787
|
return opts.timeout;
|
788
|
}
|
789
|
|
790
|
|
791
|
$.fn.cycle.next = function(opts) { advance(opts,1); };
|
792
|
$.fn.cycle.prev = function(opts) { advance(opts,0);};
|
793
|
|
794
|
|
795
|
function advance(opts, moveForward) {
|
796
|
var val = moveForward ? 1 : -1;
|
797
|
var els = opts.elements;
|
798
|
var p = opts.$cont[0], timeout = p.cycleTimeout;
|
799
|
if (timeout) {
|
800
|
clearTimeout(timeout);
|
801
|
p.cycleTimeout = 0;
|
802
|
}
|
803
|
if (opts.random && val < 0) {
|
804
|
|
805
|
opts.randomIndex--;
|
806
|
if (--opts.randomIndex == -2)
|
807
|
opts.randomIndex = els.length-2;
|
808
|
else if (opts.randomIndex == -1)
|
809
|
opts.randomIndex = els.length-1;
|
810
|
opts.nextSlide = opts.randomMap[opts.randomIndex];
|
811
|
}
|
812
|
else if (opts.random) {
|
813
|
opts.nextSlide = opts.randomMap[opts.randomIndex];
|
814
|
}
|
815
|
else {
|
816
|
opts.nextSlide = opts.currSlide + val;
|
817
|
if (opts.nextSlide < 0) {
|
818
|
if (opts.nowrap) return false;
|
819
|
opts.nextSlide = els.length - 1;
|
820
|
}
|
821
|
else if (opts.nextSlide >= els.length) {
|
822
|
if (opts.nowrap) return false;
|
823
|
opts.nextSlide = 0;
|
824
|
}
|
825
|
}
|
826
|
|
827
|
var cb = opts.onPrevNextEvent || opts.prevNextClick;
|
828
|
if ($.isFunction(cb))
|
829
|
cb(val > 0, opts.nextSlide, els[opts.nextSlide]);
|
830
|
go(els, opts, 1, moveForward);
|
831
|
return false;
|
832
|
}
|
833
|
|
834
|
function buildPager(els, opts) {
|
835
|
var $p = $(opts.pager);
|
836
|
$.each(els, function(i,o) {
|
837
|
$.fn.cycle.createPagerAnchor(i,o,$p,els,opts);
|
838
|
});
|
839
|
opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass);
|
840
|
}
|
841
|
|
842
|
$.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) {
|
843
|
var a;
|
844
|
if ($.isFunction(opts.pagerAnchorBuilder)) {
|
845
|
a = opts.pagerAnchorBuilder(i,el);
|
846
|
debug('pagerAnchorBuilder('+i+', el) returned: ' + a);
|
847
|
}
|
848
|
else
|
849
|
a = '<a href="#">'+(i+1)+'</a>';
|
850
|
|
851
|
if (!a)
|
852
|
return;
|
853
|
var $a = $(a);
|
854
|
|
855
|
if ($a.parents('body').length === 0) {
|
856
|
var arr = [];
|
857
|
if ($p.length > 1) {
|
858
|
$p.each(function() {
|
859
|
var $clone = $a.clone(true);
|
860
|
$(this).append($clone);
|
861
|
arr.push($clone[0]);
|
862
|
});
|
863
|
$a = $(arr);
|
864
|
}
|
865
|
else {
|
866
|
$a.appendTo($p);
|
867
|
}
|
868
|
}
|
869
|
|
870
|
opts.pagerAnchors = opts.pagerAnchors || [];
|
871
|
opts.pagerAnchors.push($a);
|
872
|
|
873
|
var pagerFn = function(e) {
|
874
|
e.preventDefault();
|
875
|
opts.nextSlide = i;
|
876
|
var p = opts.$cont[0], timeout = p.cycleTimeout;
|
877
|
if (timeout) {
|
878
|
clearTimeout(timeout);
|
879
|
p.cycleTimeout = 0;
|
880
|
}
|
881
|
var cb = opts.onPagerEvent || opts.pagerClick;
|
882
|
if ($.isFunction(cb))
|
883
|
cb(opts.nextSlide, els[opts.nextSlide]);
|
884
|
go(els,opts,1,opts.currSlide < i);
|
885
|
|
886
|
};
|
887
|
|
888
|
if ( /mouseenter|mouseover/i.test(opts.pagerEvent) ) {
|
889
|
$a.hover(pagerFn, function(){} );
|
890
|
}
|
891
|
else {
|
892
|
$a.bind(opts.pagerEvent, pagerFn);
|
893
|
}
|
894
|
|
895
|
if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble)
|
896
|
$a.bind('click.cycle', function(){return false;});
|
897
|
|
898
|
var cont = opts.$cont[0];
|
899
|
var pauseFlag = false;
|
900
|
if (opts.pauseOnPagerHover) {
|
901
|
$a.hover(
|
902
|
function() {
|
903
|
pauseFlag = true;
|
904
|
cont.cyclePause++;
|
905
|
triggerPause(cont,true,true);
|
906
|
}, function() {
|
907
|
if (pauseFlag)
|
908
|
cont.cyclePause--;
|
909
|
triggerPause(cont,true,true);
|
910
|
}
|
911
|
);
|
912
|
}
|
913
|
};
|
914
|
|
915
|
|
916
|
$.fn.cycle.hopsFromLast = function(opts, fwd) {
|
917
|
var hops, l = opts.lastSlide, c = opts.currSlide;
|
918
|
if (fwd)
|
919
|
hops = c > l ? c - l : opts.slideCount - l;
|
920
|
else
|
921
|
hops = c < l ? l - c : l + opts.slideCount - c;
|
922
|
return hops;
|
923
|
};
|
924
|
|
925
|
|
926
|
|
927
|
function clearTypeFix($slides) {
|
928
|
debug('applying clearType background-color hack');
|
929
|
function hex(s) {
|
930
|
s = parseInt(s,10).toString(16);
|
931
|
return s.length < 2 ? '0'+s : s;
|
932
|
}
|
933
|
function getBg(e) {
|
934
|
for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) {
|
935
|
var v = $.css(e,'background-color');
|
936
|
if (v && v.indexOf('rgb') >= 0 ) {
|
937
|
var rgb = v.match(/\d+/g);
|
938
|
return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
|
939
|
}
|
940
|
if (v && v != 'transparent')
|
941
|
return v;
|
942
|
}
|
943
|
return '#ffffff';
|
944
|
}
|
945
|
$slides.each(function() { $(this).css('background-color', getBg(this)); });
|
946
|
}
|
947
|
|
948
|
|
949
|
$.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) {
|
950
|
$(opts.elements).not(curr).hide();
|
951
|
if (typeof opts.cssBefore.opacity == 'undefined')
|
952
|
opts.cssBefore.opacity = 1;
|
953
|
opts.cssBefore.display = 'block';
|
954
|
if (opts.slideResize && w !== false && next.cycleW > 0)
|
955
|
opts.cssBefore.width = next.cycleW;
|
956
|
if (opts.slideResize && h !== false && next.cycleH > 0)
|
957
|
opts.cssBefore.height = next.cycleH;
|
958
|
opts.cssAfter = opts.cssAfter || {};
|
959
|
opts.cssAfter.display = 'none';
|
960
|
$(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0));
|
961
|
$(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1));
|
962
|
};
|
963
|
|
964
|
|
965
|
$.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) {
|
966
|
var $l = $(curr), $n = $(next);
|
967
|
var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut, animInDelay = opts.animInDelay, animOutDelay = opts.animOutDelay;
|
968
|
$n.css(opts.cssBefore);
|
969
|
if (speedOverride) {
|
970
|
if (typeof speedOverride == 'number')
|
971
|
speedIn = speedOut = speedOverride;
|
972
|
else
|
973
|
speedIn = speedOut = 1;
|
974
|
easeIn = easeOut = null;
|
975
|
}
|
976
|
var fn = function() {
|
977
|
$n.delay(animInDelay).animate(opts.animIn, speedIn, easeIn, function() {
|
978
|
cb();
|
979
|
});
|
980
|
};
|
981
|
$l.delay(animOutDelay).animate(opts.animOut, speedOut, easeOut, function() {
|
982
|
$l.css(opts.cssAfter);
|
983
|
if (!opts.sync)
|
984
|
fn();
|
985
|
});
|
986
|
if (opts.sync) fn();
|
987
|
};
|
988
|
|
989
|
|
990
|
$.fn.cycle.transitions = {
|
991
|
fade: function($cont, $slides, opts) {
|
992
|
$slides.not(':eq('+opts.currSlide+')').css('opacity',0);
|
993
|
opts.before.push(function(curr,next,opts) {
|
994
|
$.fn.cycle.commonReset(curr,next,opts);
|
995
|
opts.cssBefore.opacity = 0;
|
996
|
});
|
997
|
opts.animIn = { opacity: 1 };
|
998
|
opts.animOut = { opacity: 0 };
|
999
|
opts.cssBefore = { top: 0, left: 0 };
|
1000
|
}
|
1001
|
};
|
1002
|
|
1003
|
$.fn.cycle.ver = function() { return ver; };
|
1004
|
|
1005
|
|
1006
|
$.fn.cycle.defaults = {
|
1007
|
activePagerClass: 'activeSlide',
|
1008
|
after: null,
|
1009
|
allowPagerClickBubble: false,
|
1010
|
animIn: null,
|
1011
|
animInDelay: 0,
|
1012
|
animOut: null,
|
1013
|
animOutDelay: 0,
|
1014
|
aspect: false,
|
1015
|
autostop: 0,
|
1016
|
autostopCount: 0,
|
1017
|
backwards: false,
|
1018
|
before: null,
|
1019
|
center: null,
|
1020
|
cleartype: !$.support.opacity,
|
1021
|
cleartypeNoBg: false,
|
1022
|
containerResize: 1,
|
1023
|
containerResizeHeight: 0,
|
1024
|
continuous: 0,
|
1025
|
cssAfter: null,
|
1026
|
cssBefore: null,
|
1027
|
delay: 0,
|
1028
|
easeIn: null,
|
1029
|
easeOut: null,
|
1030
|
easing: null,
|
1031
|
end: null,
|
1032
|
fastOnEvent: 0,
|
1033
|
fit: 0,
|
1034
|
fx: 'fade',
|
1035
|
fxFn: null,
|
1036
|
height: 'auto',
|
1037
|
manualTrump: true,
|
1038
|
metaAttr: 'cycle',
|
1039
|
next: null,
|
1040
|
nowrap: 0,
|
1041
|
onPagerEvent: null,
|
1042
|
onPrevNextEvent: null,
|
1043
|
pager: null,
|
1044
|
pagerAnchorBuilder: null,
|
1045
|
pagerEvent: 'click.cycle',
|
1046
|
pause: 0,
|
1047
|
pauseOnPagerHover: 0,
|
1048
|
prev: null,
|
1049
|
prevNextEvent: 'click.cycle',
|
1050
|
random: 0,
|
1051
|
randomizeEffects: 1,
|
1052
|
requeueOnImageNotLoaded: true,
|
1053
|
requeueTimeout: 250,
|
1054
|
rev: 0,
|
1055
|
shuffle: null,
|
1056
|
skipInitializationCallbacks: false,
|
1057
|
slideExpr: null,
|
1058
|
slideResize: 1,
|
1059
|
speed: 1000,
|
1060
|
speedIn: null,
|
1061
|
speedOut: null,
|
1062
|
startingSlide: undefined,
|
1063
|
sync: 1,
|
1064
|
timeout: 4000,
|
1065
|
timeoutFn: null,
|
1066
|
updateActivePagerLink: null,
|
1067
|
width: null
|
1068
|
};
|
1069
|
|
1070
|
})(jQuery);
|
1071
|
|
1072
|
|
1073
|
|
1074
|
|
1075
|
|
1076
|
|
1077
|
|
1078
|
|
1079
|
|
1080
|
|
1081
|
|
1082
|
|
1083
|
(function($) {
|
1084
|
"use strict";
|
1085
|
|
1086
|
|
1087
|
|
1088
|
|
1089
|
|
1090
|
|
1091
|
$.fn.cycle.transitions.none = function($cont, $slides, opts) {
|
1092
|
opts.fxFn = function(curr,next,opts,after){
|
1093
|
$(next).show();
|
1094
|
$(curr).hide();
|
1095
|
after();
|
1096
|
};
|
1097
|
};
|
1098
|
|
1099
|
|
1100
|
$.fn.cycle.transitions.fadeout = function($cont, $slides, opts) {
|
1101
|
$slides.not(':eq('+opts.currSlide+')').css({ display: 'block', 'opacity': 1 });
|
1102
|
opts.before.push(function(curr,next,opts,w,h,rev) {
|
1103
|
$(curr).css('zIndex',opts.slideCount + (rev !== true ? 1 : 0));
|
1104
|
$(next).css('zIndex',opts.slideCount + (rev !== true ? 0 : 1));
|
1105
|
});
|
1106
|
opts.animIn.opacity = 1;
|
1107
|
opts.animOut.opacity = 0;
|
1108
|
opts.cssBefore.opacity = 1;
|
1109
|
opts.cssBefore.display = 'block';
|
1110
|
opts.cssAfter.zIndex = 0;
|
1111
|
};
|
1112
|
|
1113
|
|
1114
|
$.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) {
|
1115
|
$cont.css('overflow','hidden');
|
1116
|
opts.before.push($.fn.cycle.commonReset);
|
1117
|
var h = $cont.height();
|
1118
|
opts.cssBefore.top = h;
|
1119
|
opts.cssBefore.left = 0;
|
1120
|
opts.cssFirst.top = 0;
|
1121
|
opts.animIn.top = 0;
|
1122
|
opts.animOut.top = -h;
|
1123
|
};
|
1124
|
$.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) {
|
1125
|
$cont.css('overflow','hidden');
|
1126
|
opts.before.push($.fn.cycle.commonReset);
|
1127
|
var h = $cont.height();
|
1128
|
opts.cssFirst.top = 0;
|
1129
|
opts.cssBefore.top = -h;
|
1130
|
opts.cssBefore.left = 0;
|
1131
|
opts.animIn.top = 0;
|
1132
|
opts.animOut.top = h;
|
1133
|
};
|
1134
|
$.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) {
|
1135
|
$cont.css('overflow','hidden');
|
1136
|
opts.before.push($.fn.cycle.commonReset);
|
1137
|
var w = $cont.width();
|
1138
|
opts.cssFirst.left = 0;
|
1139
|
opts.cssBefore.left = w;
|
1140
|
opts.cssBefore.top = 0;
|
1141
|
opts.animIn.left = 0;
|
1142
|
opts.animOut.left = 0-w;
|
1143
|
};
|
1144
|
$.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) {
|
1145
|
$cont.css('overflow','hidden');
|
1146
|
opts.before.push($.fn.cycle.commonReset);
|
1147
|
var w = $cont.width();
|
1148
|
opts.cssFirst.left = 0;
|
1149
|
opts.cssBefore.left = -w;
|
1150
|
opts.cssBefore.top = 0;
|
1151
|
opts.animIn.left = 0;
|
1152
|
opts.animOut.left = w;
|
1153
|
};
|
1154
|
$.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) {
|
1155
|
$cont.css('overflow','hidden').width();
|
1156
|
opts.before.push(function(curr, next, opts, fwd) {
|
1157
|
if (opts.rev)
|
1158
|
fwd = !fwd;
|
1159
|
$.fn.cycle.commonReset(curr,next,opts);
|
1160
|
opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW);
|
1161
|
opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW;
|
1162
|
});
|
1163
|
opts.cssFirst.left = 0;
|
1164
|
opts.cssBefore.top = 0;
|
1165
|
opts.animIn.left = 0;
|
1166
|
opts.animOut.top = 0;
|
1167
|
};
|
1168
|
$.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) {
|
1169
|
$cont.css('overflow','hidden');
|
1170
|
opts.before.push(function(curr, next, opts, fwd) {
|
1171
|
if (opts.rev)
|
1172
|
fwd = !fwd;
|
1173
|
$.fn.cycle.commonReset(curr,next,opts);
|
1174
|
opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1);
|
1175
|
opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH;
|
1176
|
});
|
1177
|
opts.cssFirst.top = 0;
|
1178
|
opts.cssBefore.left = 0;
|
1179
|
opts.animIn.top = 0;
|
1180
|
opts.animOut.left = 0;
|
1181
|
};
|
1182
|
|
1183
|
|
1184
|
$.fn.cycle.transitions.slideX = function($cont, $slides, opts) {
|
1185
|
opts.before.push(function(curr, next, opts) {
|
1186
|
$(opts.elements).not(curr).hide();
|
1187
|
$.fn.cycle.commonReset(curr,next,opts,false,true);
|
1188
|
opts.animIn.width = next.cycleW;
|
1189
|
});
|
1190
|
opts.cssBefore.left = 0;
|
1191
|
opts.cssBefore.top = 0;
|
1192
|
opts.cssBefore.width = 0;
|
1193
|
opts.animIn.width = 'show';
|
1194
|
opts.animOut.width = 0;
|
1195
|
};
|
1196
|
$.fn.cycle.transitions.slideY = function($cont, $slides, opts) {
|
1197
|
opts.before.push(function(curr, next, opts) {
|
1198
|
$(opts.elements).not(curr).hide();
|
1199
|
$.fn.cycle.commonReset(curr,next,opts,true,false);
|
1200
|
opts.animIn.height = next.cycleH;
|
1201
|
});
|
1202
|
opts.cssBefore.left = 0;
|
1203
|
opts.cssBefore.top = 0;
|
1204
|
opts.cssBefore.height = 0;
|
1205
|
opts.animIn.height = 'show';
|
1206
|
opts.animOut.height = 0;
|
1207
|
};
|
1208
|
|
1209
|
|
1210
|
$.fn.cycle.transitions.shuffle = function($cont, $slides, opts) {
|
1211
|
var i, w = $cont.css('overflow', 'visible').width();
|
1212
|
$slides.css({left: 0, top: 0});
|
1213
|
opts.before.push(function(curr,next,opts) {
|
1214
|
$.fn.cycle.commonReset(curr,next,opts,true,true,true);
|
1215
|
});
|
1216
|
|
1217
|
if (!opts.speedAdjusted) {
|
1218
|
opts.speed = opts.speed / 2;
|
1219
|
opts.speedAdjusted = true;
|
1220
|
}
|
1221
|
opts.random = 0;
|
1222
|
opts.shuffle = opts.shuffle || {left:-w, top:15};
|
1223
|
opts.els = [];
|
1224
|
for (i=0; i < $slides.length; i++)
|
1225
|
opts.els.push($slides[i]);
|
1226
|
|
1227
|
for (i=0; i < opts.currSlide; i++)
|
1228
|
opts.els.push(opts.els.shift());
|
1229
|
|
1230
|
|
1231
|
opts.fxFn = function(curr, next, opts, cb, fwd) {
|
1232
|
if (opts.rev)
|
1233
|
fwd = !fwd;
|
1234
|
var $el = fwd ? $(curr) : $(next);
|
1235
|
$(next).css(opts.cssBefore);
|
1236
|
var count = opts.slideCount;
|
1237
|
$el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() {
|
1238
|
var hops = $.fn.cycle.hopsFromLast(opts, fwd);
|
1239
|
for (var k=0; k < hops; k++) {
|
1240
|
if (fwd)
|
1241
|
opts.els.push(opts.els.shift());
|
1242
|
else
|
1243
|
opts.els.unshift(opts.els.pop());
|
1244
|
}
|
1245
|
if (fwd) {
|
1246
|
for (var i=0, len=opts.els.length; i < len; i++)
|
1247
|
$(opts.els[i]).css('z-index', len-i+count);
|
1248
|
}
|
1249
|
else {
|
1250
|
var z = $(curr).css('z-index');
|
1251
|
$el.css('z-index', parseInt(z,10)+1+count);
|
1252
|
}
|
1253
|
$el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() {
|
1254
|
$(fwd ? this : curr).hide();
|
1255
|
if (cb) cb();
|
1256
|
});
|
1257
|
});
|
1258
|
};
|
1259
|
$.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 });
|
1260
|
};
|
1261
|
|
1262
|
|
1263
|
$.fn.cycle.transitions.turnUp = function($cont, $slides, opts) {
|
1264
|
opts.before.push(function(curr, next, opts) {
|
1265
|
$.fn.cycle.commonReset(curr,next,opts,true,false);
|
1266
|
opts.cssBefore.top = next.cycleH;
|
1267
|
opts.animIn.height = next.cycleH;
|
1268
|
opts.animOut.width = next.cycleW;
|
1269
|
});
|
1270
|
opts.cssFirst.top = 0;
|
1271
|
opts.cssBefore.left = 0;
|
1272
|
opts.cssBefore.height = 0;
|
1273
|
opts.animIn.top = 0;
|
1274
|
opts.animOut.height = 0;
|
1275
|
};
|
1276
|
$.fn.cycle.transitions.turnDown = function($cont, $slides, opts) {
|
1277
|
opts.before.push(function(curr, next, opts) {
|
1278
|
$.fn.cycle.commonReset(curr,next,opts,true,false);
|
1279
|
opts.animIn.height = next.cycleH;
|
1280
|
opts.animOut.top = curr.cycleH;
|
1281
|
});
|
1282
|
opts.cssFirst.top = 0;
|
1283
|
opts.cssBefore.left = 0;
|
1284
|
opts.cssBefore.top = 0;
|
1285
|
opts.cssBefore.height = 0;
|
1286
|
opts.animOut.height = 0;
|
1287
|
};
|
1288
|
$.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) {
|
1289
|
opts.before.push(function(curr, next, opts) {
|
1290
|
$.fn.cycle.commonReset(curr,next,opts,false,true);
|
1291
|
opts.cssBefore.left = next.cycleW;
|
1292
|
opts.animIn.width = next.cycleW;
|
1293
|
});
|
1294
|
opts.cssBefore.top = 0;
|
1295
|
opts.cssBefore.width = 0;
|
1296
|
opts.animIn.left = 0;
|
1297
|
opts.animOut.width = 0;
|
1298
|
};
|
1299
|
$.fn.cycle.transitions.turnRight = function($cont, $slides, opts) {
|
1300
|
opts.before.push(function(curr, next, opts) {
|
1301
|
$.fn.cycle.commonReset(curr,next,opts,false,true);
|
1302
|
opts.animIn.width = next.cycleW;
|
1303
|
opts.animOut.left = curr.cycleW;
|
1304
|
});
|
1305
|
$.extend(opts.cssBefore, { top: 0, left: 0, width: 0 });
|
1306
|
opts.animIn.left = 0;
|
1307
|
opts.animOut.width = 0;
|
1308
|
};
|
1309
|
|
1310
|
|
1311
|
$.fn.cycle.transitions.zoom = function($cont, $slides, opts) {
|
1312
|
opts.before.push(function(curr, next, opts) {
|
1313
|
$.fn.cycle.commonReset(curr,next,opts,false,false,true);
|
1314
|
opts.cssBefore.top = next.cycleH/2;
|
1315
|
opts.cssBefore.left = next.cycleW/2;
|
1316
|
$.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH });
|
1317
|
$.extend(opts.animOut, { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 });
|
1318
|
});
|
1319
|
opts.cssFirst.top = 0;
|
1320
|
opts.cssFirst.left = 0;
|
1321
|
opts.cssBefore.width = 0;
|
1322
|
opts.cssBefore.height = 0;
|
1323
|
};
|
1324
|
|
1325
|
|
1326
|
$.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) {
|
1327
|
opts.before.push(function(curr, next, opts) {
|
1328
|
$.fn.cycle.commonReset(curr,next,opts,false,false);
|
1329
|
opts.cssBefore.left = next.cycleW/2;
|
1330
|
opts.cssBefore.top = next.cycleH/2;
|
1331
|
$.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH });
|
1332
|
});
|
1333
|
opts.cssBefore.width = 0;
|
1334
|
opts.cssBefore.height = 0;
|
1335
|
opts.animOut.opacity = 0;
|
1336
|
};
|
1337
|
|
1338
|
|
1339
|
$.fn.cycle.transitions.blindX = function($cont, $slides, opts) {
|
1340
|
var w = $cont.css('overflow','hidden').width();
|
1341
|
opts.before.push(function(curr, next, opts) {
|
1342
|
$.fn.cycle.commonReset(curr,next,opts);
|
1343
|
opts.animIn.width = next.cycleW;
|
1344
|
opts.animOut.left = curr.cycleW;
|
1345
|
});
|
1346
|
opts.cssBefore.left = w;
|
1347
|
opts.cssBefore.top = 0;
|
1348
|
opts.animIn.left = 0;
|
1349
|
opts.animOut.left = w;
|
1350
|
};
|
1351
|
|
1352
|
$.fn.cycle.transitions.blindY = function($cont, $slides, opts) {
|
1353
|
var h = $cont.css('overflow','hidden').height();
|
1354
|
opts.before.push(function(curr, next, opts) {
|
1355
|
$.fn.cycle.commonReset(curr,next,opts);
|
1356
|
opts.animIn.height = next.cycleH;
|
1357
|
opts.animOut.top = curr.cycleH;
|
1358
|
});
|
1359
|
opts.cssBefore.top = h;
|
1360
|
opts.cssBefore.left = 0;
|
1361
|
opts.animIn.top = 0;
|
1362
|
opts.animOut.top = h;
|
1363
|
};
|
1364
|
|
1365
|
$.fn.cycle.transitions.blindZ = function($cont, $slides, opts) {
|
1366
|
var h = $cont.css('overflow','hidden').height();
|
1367
|
var w = $cont.width();
|
1368
|
opts.before.push(function(curr, next, opts) {
|
1369
|
$.fn.cycle.commonReset(curr,next,opts);
|
1370
|
opts.animIn.height = next.cycleH;
|
1371
|
opts.animOut.top = curr.cycleH;
|
1372
|
});
|
1373
|
opts.cssBefore.top = h;
|
1374
|
opts.cssBefore.left = w;
|
1375
|
opts.animIn.top = 0;
|
1376
|
opts.animIn.left = 0;
|
1377
|
opts.animOut.top = h;
|
1378
|
opts.animOut.left = w;
|
1379
|
};
|
1380
|
|
1381
|
|
1382
|
$.fn.cycle.transitions.growX = function($cont, $slides, opts) {
|
1383
|
opts.before.push(function(curr, next, opts) {
|
1384
|
$.fn.cycle.commonReset(curr,next,opts,false,true);
|
1385
|
opts.cssBefore.left = this.cycleW/2;
|
1386
|
opts.animIn.left = 0;
|
1387
|
opts.animIn.width = this.cycleW;
|
1388
|
opts.animOut.left = 0;
|
1389
|
});
|
1390
|
opts.cssBefore.top = 0;
|
1391
|
opts.cssBefore.width = 0;
|
1392
|
};
|
1393
|
|
1394
|
$.fn.cycle.transitions.growY = function($cont, $slides, opts) {
|
1395
|
opts.before.push(function(curr, next, opts) {
|
1396
|
$.fn.cycle.commonReset(curr,next,opts,true,false);
|
1397
|
opts.cssBefore.top = this.cycleH/2;
|
1398
|
opts.animIn.top = 0;
|
1399
|
opts.animIn.height = this.cycleH;
|
1400
|
opts.animOut.top = 0;
|
1401
|
});
|
1402
|
opts.cssBefore.height = 0;
|
1403
|
opts.cssBefore.left = 0;
|
1404
|
};
|
1405
|
|
1406
|
|
1407
|
$.fn.cycle.transitions.curtainX = function($cont, $slides, opts) {
|
1408
|
opts.before.push(function(curr, next, opts) {
|
1409
|
$.fn.cycle.commonReset(curr,next,opts,false,true,true);
|
1410
|
opts.cssBefore.left = next.cycleW/2;
|
1411
|
opts.animIn.left = 0;
|
1412
|
opts.animIn.width = this.cycleW;
|
1413
|
opts.animOut.left = curr.cycleW/2;
|
1414
|
opts.animOut.width = 0;
|
1415
|
});
|
1416
|
opts.cssBefore.top = 0;
|
1417
|
opts.cssBefore.width = 0;
|
1418
|
};
|
1419
|
|
1420
|
$.fn.cycle.transitions.curtainY = function($cont, $slides, opts) {
|
1421
|
opts.before.push(function(curr, next, opts) {
|
1422
|
$.fn.cycle.commonReset(curr,next,opts,true,false,true);
|
1423
|
opts.cssBefore.top = next.cycleH/2;
|
1424
|
opts.animIn.top = 0;
|
1425
|
opts.animIn.height = next.cycleH;
|
1426
|
opts.animOut.top = curr.cycleH/2;
|
1427
|
opts.animOut.height = 0;
|
1428
|
});
|
1429
|
opts.cssBefore.height = 0;
|
1430
|
opts.cssBefore.left = 0;
|
1431
|
};
|
1432
|
|
1433
|
|
1434
|
$.fn.cycle.transitions.cover = function($cont, $slides, opts) {
|
1435
|
var d = opts.direction || 'left';
|
1436
|
var w = $cont.css('overflow','hidden').width();
|
1437
|
var h = $cont.height();
|
1438
|
opts.before.push(function(curr, next, opts) {
|
1439
|
$.fn.cycle.commonReset(curr,next,opts);
|
1440
|
opts.cssAfter.display = '';
|
1441
|
if (d == 'right')
|
1442
|
opts.cssBefore.left = -w;
|
1443
|
else if (d == 'up')
|
1444
|
opts.cssBefore.top = h;
|
1445
|
else if (d == 'down')
|
1446
|
opts.cssBefore.top = -h;
|
1447
|
else
|
1448
|
opts.cssBefore.left = w;
|
1449
|
});
|
1450
|
opts.animIn.left = 0;
|
1451
|
opts.animIn.top = 0;
|
1452
|
opts.cssBefore.top = 0;
|
1453
|
opts.cssBefore.left = 0;
|
1454
|
};
|
1455
|
|
1456
|
|
1457
|
$.fn.cycle.transitions.uncover = function($cont, $slides, opts) {
|
1458
|
var d = opts.direction || 'left';
|
1459
|
var w = $cont.css('overflow','hidden').width();
|
1460
|
var h = $cont.height();
|
1461
|
opts.before.push(function(curr, next, opts) {
|
1462
|
$.fn.cycle.commonReset(curr,next,opts,true,true,true);
|
1463
|
if (d == 'right')
|
1464
|
opts.animOut.left = w;
|
1465
|
else if (d == 'up')
|
1466
|
opts.animOut.top = -h;
|
1467
|
else if (d == 'down')
|
1468
|
opts.animOut.top = h;
|
1469
|
else
|
1470
|
opts.animOut.left = -w;
|
1471
|
});
|
1472
|
opts.animIn.left = 0;
|
1473
|
opts.animIn.top = 0;
|
1474
|
opts.cssBefore.top = 0;
|
1475
|
opts.cssBefore.left = 0;
|
1476
|
};
|
1477
|
|
1478
|
|
1479
|
$.fn.cycle.transitions.toss = function($cont, $slides, opts) {
|
1480
|
var w = $cont.css('overflow','visible').width();
|
1481
|
var h = $cont.height();
|
1482
|
opts.before.push(function(curr, next, opts) {
|
1483
|
$.fn.cycle.commonReset(curr,next,opts,true,true,true);
|
1484
|
|
1485
|
if (!opts.animOut.left && !opts.animOut.top)
|
1486
|
$.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 });
|
1487
|
else
|
1488
|
opts.animOut.opacity = 0;
|
1489
|
});
|
1490
|
opts.cssBefore.left = 0;
|
1491
|
opts.cssBefore.top = 0;
|
1492
|
opts.animIn.left = 0;
|
1493
|
};
|
1494
|
|
1495
|
|
1496
|
$.fn.cycle.transitions.wipe = function($cont, $slides, opts) {
|
1497
|
var w = $cont.css('overflow','hidden').width();
|
1498
|
var h = $cont.height();
|
1499
|
opts.cssBefore = opts.cssBefore || {};
|
1500
|
var clip;
|
1501
|
if (opts.clip) {
|
1502
|
if (/l2r/.test(opts.clip))
|
1503
|
clip = 'rect(0px 0px '+h+'px 0px)';
|
1504
|
else if (/r2l/.test(opts.clip))
|
1505
|
clip = 'rect(0px '+w+'px '+h+'px '+w+'px)';
|
1506
|
else if (/t2b/.test(opts.clip))
|
1507
|
clip = 'rect(0px '+w+'px 0px 0px)';
|
1508
|
else if (/b2t/.test(opts.clip))
|
1509
|
clip = 'rect('+h+'px '+w+'px '+h+'px 0px)';
|
1510
|
else if (/zoom/.test(opts.clip)) {
|
1511
|
var top = parseInt(h/2,10);
|
1512
|
var left = parseInt(w/2,10);
|
1513
|
clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)';
|
1514
|
}
|
1515
|
}
|
1516
|
|
1517
|
opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)';
|
1518
|
|
1519
|
var d = opts.cssBefore.clip.match(/(\d+)/g);
|
1520
|
var t = parseInt(d[0],10), r = parseInt(d[1],10), b = parseInt(d[2],10), l = parseInt(d[3],10);
|
1521
|
|
1522
|
opts.before.push(function(curr, next, opts) {
|
1523
|
if (curr == next) return;
|
1524
|
var $curr = $(curr), $next = $(next);
|
1525
|
$.fn.cycle.commonReset(curr,next,opts,true,true,false);
|
1526
|
opts.cssAfter.display = 'block';
|
1527
|
|
1528
|
var step = 1, count = parseInt((opts.speedIn / 13),10) - 1;
|
1529
|
(function f() {
|
1530
|
var tt = t ? t - parseInt(step * (t/count),10) : 0;
|
1531
|
var ll = l ? l - parseInt(step * (l/count),10) : 0;
|
1532
|
var bb = b < h ? b + parseInt(step * ((h-b)/count || 1),10) : h;
|
1533
|
var rr = r < w ? r + parseInt(step * ((w-r)/count || 1),10) : w;
|
1534
|
$next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' });
|
1535
|
(step++ <= count) ? setTimeout(f, 13) : $curr.css('display', 'none');
|
1536
|
})();
|
1537
|
});
|
1538
|
$.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 });
|
1539
|
opts.animIn = { left: 0 };
|
1540
|
opts.animOut = { left: 0 };
|
1541
|
};
|
1542
|
|
1543
|
})(jQuery);
|