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