cycle2-rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cycle2-rails.gemspec
4
+ gemspec
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cycle2-rails (1.0.0)
5
+ jquery-rails (~> 2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (3.2.8)
11
+ activemodel (= 3.2.8)
12
+ activesupport (= 3.2.8)
13
+ builder (~> 3.0.0)
14
+ erubis (~> 2.7.0)
15
+ journey (~> 1.0.4)
16
+ rack (~> 1.4.0)
17
+ rack-cache (~> 1.2)
18
+ rack-test (~> 0.6.1)
19
+ sprockets (~> 2.1.3)
20
+ activemodel (3.2.8)
21
+ activesupport (= 3.2.8)
22
+ builder (~> 3.0.0)
23
+ activesupport (3.2.8)
24
+ i18n (~> 0.6)
25
+ multi_json (~> 1.0)
26
+ builder (3.0.4)
27
+ erubis (2.7.0)
28
+ hike (1.2.2)
29
+ i18n (0.6.4)
30
+ journey (1.0.4)
31
+ jquery-rails (2.2.1)
32
+ railties (>= 3.0, < 5.0)
33
+ thor (>= 0.14, < 2.0)
34
+ json (1.7.7)
35
+ multi_json (1.7.3)
36
+ rack (1.4.5)
37
+ rack-cache (1.2)
38
+ rack (>= 0.4)
39
+ rack-ssl (1.3.3)
40
+ rack
41
+ rack-test (0.6.2)
42
+ rack (>= 1.0)
43
+ railties (3.2.8)
44
+ actionpack (= 3.2.8)
45
+ activesupport (= 3.2.8)
46
+ rack-ssl (~> 1.3.2)
47
+ rake (>= 0.8.7)
48
+ rdoc (~> 3.4)
49
+ thor (>= 0.14.6, < 2.0)
50
+ rake (10.0.4)
51
+ rdoc (3.12.2)
52
+ json (~> 1.4)
53
+ sprockets (2.1.3)
54
+ hike (~> 1.2)
55
+ rack (~> 1.0)
56
+ tilt (~> 1.1, != 1.3.0)
57
+ thor (0.18.1)
58
+ tilt (1.4.0)
59
+
60
+ PLATFORMS
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ cycle2-rails!
65
+ rake
data/LICENSE ADDED
@@ -0,0 +1 @@
1
+ Public domain
@@ -0,0 +1,33 @@
1
+ # Cycle2-Rails
2
+
3
+ Integrates [jquery.cycle2.js](http://jquery.malsup.com/cycle2) with the Rails asset pipeline.
4
+
5
+ Cycle2 is a versatile slideshow plugin for jQuery built around ease-of-use. It supports a declarative initialization style that allows full customization without any scripting. Simply include the plugin, declare your markup, and Cycle2 does the rest.
6
+
7
+ Cycle2 was written by Mike Alsup.
8
+
9
+ # For Rails 3.1+ only
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'cycle2-rails'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ ## Usage
22
+
23
+ In your application.js
24
+
25
+ //= require cycle2-rails
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'open-uri'
4
+
5
+ desc "Download the latest cycle2.js"
6
+ task :update do
7
+ url = "http://malsup.github.com/jquery.cycle2.js"
8
+ outputfile = "vendor/assets/javascripts/cycle2-rails/jquery.cycle2.js"
9
+
10
+ open(outputfile, 'wb') do |file|
11
+ file << open(url).read
12
+ end
13
+
14
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/cycle2-rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Mike Alsup", "Tomas Celizna"]
6
+ gem.email = ["tomas.celizna@gmail.com"]
7
+ gem.description = %q{Cycle2 is a versatile slideshow plugin for jQuery built around ease-of-use.}
8
+ gem.summary = %q{Cycle2 is a versatile slideshow plugin for jQuery built around ease-of-use. It supports a declarative initialization style that allows full customization without any scripting. Simply include the plugin, declare your markup, and Cycle2 does the rest.}
9
+ gem.homepage = "https://github.com/tomasc/cycle2-rails"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "cycle2-rails"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Cycle2::Rails::VERSION
17
+
18
+ gem.add_dependency "jquery-rails", "~> 2.0"
19
+
20
+ gem.add_development_dependency "rake"
21
+ end
@@ -0,0 +1,8 @@
1
+ require "cycle2-rails/version"
2
+ require "cycle2-rails/engine"
3
+
4
+ module Cycle2
5
+ module Rails
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ module Cycle2
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Cycle2
2
+ module Rails
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,1490 @@
1
+ /*!
2
+ * jQuery Cycle2 - Version: 20130502
3
+ * http://malsup.com/jquery/cycle2/
4
+ * Copyright (c) 2012 M. Alsup; Dual licensed: MIT/GPL
5
+ * Requires: jQuery v1.7 or later
6
+ */
7
+ ;(function($) {
8
+ "use strict";
9
+
10
+ var version = '20130409';
11
+
12
+ $.fn.cycle = function( options ) {
13
+ // fix mistakes with the ready state
14
+ var o;
15
+ if ( this.length === 0 && !$.isReady ) {
16
+ o = { s: this.selector, c: this.context };
17
+ $.fn.cycle.log('requeuing slideshow (dom not ready)');
18
+ $(function() {
19
+ $( o.s, o.c ).cycle(options);
20
+ });
21
+ return this;
22
+ }
23
+
24
+ return this.each(function() {
25
+ var data, opts, shortName, val;
26
+ var container = $(this);
27
+ var log = $.fn.cycle.log;
28
+
29
+ if ( container.data('cycle.opts') )
30
+ return; // already initialized
31
+
32
+ if ( container.data('cycle-log') === false ||
33
+ ( options && options.log === false ) ||
34
+ ( opts && opts.log === false) ) {
35
+ log = $.noop;
36
+ }
37
+
38
+ log('--c2 init--');
39
+ data = container.data();
40
+ for (var p in data) {
41
+ // allow props to be accessed sans 'cycle' prefix and log the overrides
42
+ if (data.hasOwnProperty(p) && /^cycle[A-Z]+/.test(p) ) {
43
+ val = data[p];
44
+ shortName = p.match(/^cycle(.*)/)[1].replace(/^[A-Z]/, lowerCase);
45
+ log(shortName+':', val, '('+typeof val +')');
46
+ data[shortName] = val;
47
+ }
48
+ }
49
+
50
+ opts = $.extend( {}, $.fn.cycle.defaults, data, options || {});
51
+
52
+ opts.timeoutId = 0;
53
+ opts.paused = opts.paused || false; // #57
54
+ opts.container = container;
55
+ opts._maxZ = opts.maxZ;
56
+
57
+ opts.API = $.extend ( { _container: container }, $.fn.cycle.API );
58
+ opts.API.log = log;
59
+ opts.API.trigger = function( eventName, args ) {
60
+ opts.container.trigger( eventName, args );
61
+ return opts.API;
62
+ };
63
+
64
+ container.data( 'cycle.opts', opts );
65
+ container.data( 'cycle.API', opts.API );
66
+
67
+ // opportunity for plugins to modify opts and API
68
+ opts.API.trigger('cycle-bootstrap', [ opts, opts.API ]);
69
+
70
+ opts.API.addInitialSlides();
71
+ opts.API.preInitSlideshow();
72
+
73
+ if ( opts.slides.length )
74
+ opts.API.initSlideshow();
75
+ });
76
+ };
77
+
78
+ $.fn.cycle.API = {
79
+ opts: function() {
80
+ return this._container.data( 'cycle.opts' );
81
+ },
82
+ addInitialSlides: function() {
83
+ var opts = this.opts();
84
+ var slides = opts.slides;
85
+ opts.slideCount = 0;
86
+ opts.slides = $(); // empty set
87
+
88
+ // add slides that already exist
89
+ slides = slides.jquery ? slides : opts.container.find( slides );
90
+
91
+ if ( opts.random ) {
92
+ slides.sort(function() {return Math.random() - 0.5;});
93
+ }
94
+
95
+ opts.API.add( slides );
96
+ },
97
+
98
+ preInitSlideshow: function() {
99
+ var opts = this.opts();
100
+ opts.API.trigger('cycle-pre-initialize', [ opts ]);
101
+ var tx = $.fn.cycle.transitions[opts.fx];
102
+ if (tx && $.isFunction(tx.preInit))
103
+ tx.preInit( opts );
104
+ opts._preInitialized = true;
105
+ },
106
+
107
+ postInitSlideshow: function() {
108
+ var opts = this.opts();
109
+ opts.API.trigger('cycle-post-initialize', [ opts ]);
110
+ var tx = $.fn.cycle.transitions[opts.fx];
111
+ if (tx && $.isFunction(tx.postInit))
112
+ tx.postInit( opts );
113
+ },
114
+
115
+ initSlideshow: function() {
116
+ var opts = this.opts();
117
+ var pauseObj = opts.container;
118
+ var slideOpts;
119
+ opts.API.calcFirstSlide();
120
+
121
+ if ( opts.container.css('position') == 'static' )
122
+ opts.container.css('position', 'relative');
123
+
124
+ $(opts.slides[opts.currSlide]).css('opacity',1).show();
125
+ opts.API.stackSlides( opts.slides[opts.currSlide], opts.slides[opts.nextSlide], !opts.reverse );
126
+
127
+ if ( opts.pauseOnHover ) {
128
+ // allow pauseOnHover to specify an element
129
+ if ( opts.pauseOnHover !== true )
130
+ pauseObj = $( opts.pauseOnHover );
131
+
132
+ pauseObj.hover(
133
+ function(){ opts.API.pause( true ); },
134
+ function(){ opts.API.resume( true ); }
135
+ );
136
+ }
137
+
138
+ // stage initial transition
139
+ if ( opts.timeout ) {
140
+ slideOpts = opts.API.getSlideOpts( opts.nextSlide );
141
+ opts.API.queueTransition( slideOpts, opts.timeout + opts.delay );
142
+ }
143
+
144
+ opts._initialized = true;
145
+ opts.API.updateView( true );
146
+ opts.API.trigger('cycle-initialized', [ opts ]);
147
+ opts.API.postInitSlideshow();
148
+ },
149
+
150
+ pause: function( hover ) {
151
+ var opts = this.opts(),
152
+ slideOpts = opts.API.getSlideOpts(),
153
+ alreadyPaused = opts.hoverPaused || opts.paused;
154
+
155
+ if ( hover )
156
+ opts.hoverPaused = true;
157
+ else
158
+ opts.paused = true;
159
+
160
+ if ( ! alreadyPaused ) {
161
+ opts.container.addClass('cycle-paused');
162
+ opts.API.trigger('cycle-paused', [ opts ]).log('cycle-paused');
163
+
164
+ if ( slideOpts.timeout ) {
165
+ clearTimeout( opts.timeoutId );
166
+ opts.timeoutId = 0;
167
+
168
+ // determine how much time is left for the current slide
169
+ opts._remainingTimeout -= ( $.now() - opts._lastQueue );
170
+ if ( opts._remainingTimeout < 0 || isNaN(opts._remainingTimeout) )
171
+ opts._remainingTimeout = undefined;
172
+ }
173
+ }
174
+ },
175
+
176
+ resume: function( hover ) {
177
+ var opts = this.opts(),
178
+ alreadyResumed = !opts.hoverPaused && !opts.paused,
179
+ remaining;
180
+
181
+ if ( hover )
182
+ opts.hoverPaused = false;
183
+ else
184
+ opts.paused = false;
185
+
186
+ if ( ! alreadyResumed ) {
187
+ opts.container.removeClass('cycle-paused');
188
+ opts.API.queueTransition( opts.API.getSlideOpts(), opts._remainingTimeout );
189
+ opts.API.trigger('cycle-resumed', [ opts, opts._remainingTimeout ] ).log('cycle-resumed');
190
+ }
191
+ },
192
+
193
+ add: function( slides, prepend ) {
194
+ var opts = this.opts();
195
+ var oldSlideCount = opts.slideCount;
196
+ var startSlideshow = false;
197
+ var len;
198
+
199
+ if ( $.type(slides) == 'string')
200
+ slides = $.trim( slides );
201
+
202
+ $( slides ).each(function(i) {
203
+ var slideOpts;
204
+ var slide = $(this);
205
+
206
+ if ( prepend )
207
+ opts.container.prepend( slide );
208
+ else
209
+ opts.container.append( slide );
210
+
211
+ opts.slideCount++;
212
+ slideOpts = opts.API.buildSlideOpts( slide );
213
+
214
+ if ( prepend )
215
+ opts.slides = $( slide ).add( opts.slides );
216
+ else
217
+ opts.slides = opts.slides.add( slide );
218
+
219
+ opts.API.initSlide( slideOpts, slide, --opts._maxZ );
220
+
221
+ slide.data('cycle.opts', slideOpts);
222
+ opts.API.trigger('cycle-slide-added', [ opts, slideOpts, slide ]);
223
+ });
224
+
225
+ opts.API.updateView( true );
226
+
227
+ startSlideshow = opts._preInitialized && (oldSlideCount < 2 && opts.slideCount >= 1);
228
+ if ( startSlideshow ) {
229
+ if ( !opts._initialized )
230
+ opts.API.initSlideshow();
231
+ else if ( opts.timeout ) {
232
+ len = opts.slides.length;
233
+ opts.nextSlide = opts.reverse ? len - 1 : 1;
234
+ if ( !opts.timeoutId ) {
235
+ opts.API.queueTransition( opts );
236
+ }
237
+ }
238
+ }
239
+ },
240
+
241
+ calcFirstSlide: function() {
242
+ var opts = this.opts();
243
+ var firstSlideIndex;
244
+ firstSlideIndex = parseInt( opts.startingSlide || 0, 10 );
245
+ if (firstSlideIndex >= opts.slides.length || firstSlideIndex < 0)
246
+ firstSlideIndex = 0;
247
+
248
+ opts.currSlide = firstSlideIndex;
249
+ if ( opts.reverse ) {
250
+ opts.nextSlide = firstSlideIndex - 1;
251
+ if (opts.nextSlide < 0)
252
+ opts.nextSlide = opts.slides.length - 1;
253
+ }
254
+ else {
255
+ opts.nextSlide = firstSlideIndex + 1;
256
+ if (opts.nextSlide == opts.slides.length)
257
+ opts.nextSlide = 0;
258
+ }
259
+ },
260
+
261
+ calcNextSlide: function() {
262
+ var opts = this.opts();
263
+ var roll;
264
+ if ( opts.reverse ) {
265
+ roll = (opts.nextSlide - 1) < 0;
266
+ opts.nextSlide = roll ? opts.slideCount - 1 : opts.nextSlide-1;
267
+ opts.currSlide = roll ? 0 : opts.nextSlide+1;
268
+ }
269
+ else {
270
+ roll = (opts.nextSlide + 1) == opts.slides.length;
271
+ opts.nextSlide = roll ? 0 : opts.nextSlide+1;
272
+ opts.currSlide = roll ? opts.slides.length-1 : opts.nextSlide-1;
273
+ }
274
+ },
275
+
276
+ calcTx: function( slideOpts, manual ) {
277
+ var opts = slideOpts;
278
+ var tx;
279
+ if ( manual && opts.manualFx )
280
+ tx = $.fn.cycle.transitions[opts.manualFx];
281
+ if ( !tx )
282
+ tx = $.fn.cycle.transitions[opts.fx];
283
+
284
+ if (!tx) {
285
+ tx = $.fn.cycle.transitions.fade;
286
+ opts.API.log('Transition "' + opts.fx + '" not found. Using fade.');
287
+ }
288
+ return tx;
289
+ },
290
+
291
+ prepareTx: function( manual, fwd ) {
292
+ var opts = this.opts();
293
+ var after, curr, next, slideOpts, tx;
294
+
295
+ if ( opts.slideCount < 2 ) {
296
+ opts.timeoutId = 0;
297
+ return;
298
+ }
299
+ if ( manual && ( !opts.busy || opts.manualTrump ) ) {
300
+ opts.API.stopTransition();
301
+ opts.busy = false;
302
+ clearTimeout(opts.timeoutId);
303
+ opts.timeoutId = 0;
304
+ }
305
+ if ( opts.busy )
306
+ return;
307
+ if ( opts.timeoutId === 0 && !manual )
308
+ return;
309
+
310
+ curr = opts.slides[opts.currSlide];
311
+ next = opts.slides[opts.nextSlide];
312
+ slideOpts = opts.API.getSlideOpts( opts.nextSlide );
313
+ tx = opts.API.calcTx( slideOpts, manual );
314
+
315
+ opts._tx = tx;
316
+
317
+ if ( manual && slideOpts.manualSpeed !== undefined )
318
+ slideOpts.speed = slideOpts.manualSpeed;
319
+
320
+ // if ( opts.nextSlide === opts.currSlide )
321
+ // opts.API.calcNextSlide();
322
+
323
+ // ensure that:
324
+ // 1. advancing to a different slide
325
+ // 2. this is either a manual event (prev/next, pager, cmd) or
326
+ // a timer event and slideshow is not paused
327
+ if ( opts.nextSlide != opts.currSlide &&
328
+ (manual || (!opts.paused && !opts.hoverPaused && opts.timeout) )) { // #62
329
+
330
+ opts.API.trigger('cycle-before', [ slideOpts, curr, next, fwd ]);
331
+ if ( tx.before )
332
+ tx.before( slideOpts, curr, next, fwd );
333
+
334
+ after = function() {
335
+ opts.busy = false;
336
+ // #76; bail if slideshow has been destroyed
337
+ if (! opts.container.data( 'cycle.opts' ) )
338
+ return;
339
+
340
+ if (tx.after)
341
+ tx.after( slideOpts, curr, next, fwd );
342
+ opts.API.trigger('cycle-after', [ slideOpts, curr, next, fwd ]);
343
+ opts.API.queueTransition( slideOpts);
344
+ opts.API.updateView( true );
345
+ };
346
+
347
+ opts.busy = true;
348
+ if (tx.transition)
349
+ tx.transition(slideOpts, curr, next, fwd, after);
350
+ else
351
+ opts.API.doTransition( slideOpts, curr, next, fwd, after);
352
+
353
+ opts.API.calcNextSlide();
354
+ opts.API.updateView();
355
+ } else {
356
+ opts.API.queueTransition( slideOpts );
357
+ }
358
+ },
359
+
360
+ // perform the actual animation
361
+ doTransition: function( slideOpts, currEl, nextEl, fwd, callback) {
362
+ var opts = slideOpts;
363
+ var curr = $(currEl), next = $(nextEl);
364
+ var fn = function() {
365
+ // make sure animIn has something so that callback doesn't trigger immediately
366
+ next.animate(opts.animIn || { opacity: 1}, opts.speed, opts.easeIn || opts.easing, callback);
367
+ };
368
+
369
+ next.css(opts.cssBefore || {});
370
+ curr.animate(opts.animOut || {}, opts.speed, opts.easeOut || opts.easing, function() {
371
+ curr.css(opts.cssAfter || {});
372
+ if (!opts.sync) {
373
+ fn();
374
+ }
375
+ });
376
+ if (opts.sync) {
377
+ fn();
378
+ }
379
+ },
380
+
381
+ queueTransition: function( slideOpts, specificTimeout ) {
382
+ var opts = this.opts();
383
+ var timeout = specificTimeout !== undefined ? specificTimeout : slideOpts.timeout;
384
+ if (opts.nextSlide === 0 && --opts.loop === 0) {
385
+ opts.API.log('terminating; loop=0');
386
+ opts.timeout = 0;
387
+ if ( timeout ) {
388
+ setTimeout(function() {
389
+ opts.API.trigger('cycle-finished', [ opts ]);
390
+ }, timeout);
391
+ }
392
+ else {
393
+ opts.API.trigger('cycle-finished', [ opts ]);
394
+ }
395
+ // reset nextSlide
396
+ opts.nextSlide = opts.currSlide;
397
+ return;
398
+ }
399
+ if ( timeout ) {
400
+ opts._lastQueue = $.now();
401
+ if ( specificTimeout === undefined )
402
+ opts._remainingTimeout = slideOpts.timeout;
403
+
404
+ if ( !opts.paused && ! opts.hoverPaused ) {
405
+ opts.timeoutId = setTimeout(function() {
406
+ opts.API.prepareTx( false, !opts.reverse );
407
+ }, timeout );
408
+ }
409
+ }
410
+ },
411
+
412
+ stopTransition: function() {
413
+ var opts = this.opts();
414
+ if ( opts.slides.filter(':animated').length ) {
415
+ opts.slides.stop(false, true);
416
+ opts.API.trigger('cycle-transition-stopped', [ opts ]);
417
+ }
418
+
419
+ if ( opts._tx && opts._tx.stopTransition )
420
+ opts._tx.stopTransition( opts );
421
+ },
422
+
423
+ // advance slide forward or back
424
+ advanceSlide: function( val ) {
425
+ var opts = this.opts();
426
+ clearTimeout(opts.timeoutId);
427
+ opts.timeoutId = 0;
428
+ opts.nextSlide = opts.currSlide + val;
429
+
430
+ if (opts.nextSlide < 0)
431
+ opts.nextSlide = opts.slides.length - 1;
432
+ else if (opts.nextSlide >= opts.slides.length)
433
+ opts.nextSlide = 0;
434
+
435
+ opts.API.prepareTx( true, val >= 0 );
436
+ return false;
437
+ },
438
+
439
+ buildSlideOpts: function( slide ) {
440
+ var opts = this.opts();
441
+ var val, shortName;
442
+ var slideOpts = slide.data() || {};
443
+ for (var p in slideOpts) {
444
+ // allow props to be accessed sans 'cycle' prefix and log the overrides
445
+ if (slideOpts.hasOwnProperty(p) && /^cycle[A-Z]+/.test(p) ) {
446
+ val = slideOpts[p];
447
+ shortName = p.match(/^cycle(.*)/)[1].replace(/^[A-Z]/, lowerCase);
448
+ opts.API.log('['+(opts.slideCount-1)+']', shortName+':', val, '('+typeof val +')');
449
+ slideOpts[shortName] = val;
450
+ }
451
+ }
452
+
453
+ slideOpts = $.extend( {}, $.fn.cycle.defaults, opts, slideOpts );
454
+ slideOpts.slideNum = opts.slideCount;
455
+
456
+ try {
457
+ // these props should always be read from the master state object
458
+ delete slideOpts.API;
459
+ delete slideOpts.slideCount;
460
+ delete slideOpts.currSlide;
461
+ delete slideOpts.nextSlide;
462
+ delete slideOpts.slides;
463
+ } catch(e) {
464
+ // no op
465
+ }
466
+ return slideOpts;
467
+ },
468
+
469
+ getSlideOpts: function( index ) {
470
+ var opts = this.opts();
471
+ if ( index === undefined )
472
+ index = opts.currSlide;
473
+
474
+ var slide = opts.slides[index];
475
+ var slideOpts = $(slide).data('cycle.opts');
476
+ return $.extend( {}, opts, slideOpts );
477
+ },
478
+
479
+ initSlide: function( slideOpts, slide, suggestedZindex ) {
480
+ var opts = this.opts();
481
+ slide.css( slideOpts.slideCss || {} );
482
+ if ( suggestedZindex > 0 )
483
+ slide.css( 'zIndex', suggestedZindex );
484
+
485
+ // ensure that speed settings are sane
486
+ if ( isNaN( slideOpts.speed ) )
487
+ slideOpts.speed = $.fx.speeds[slideOpts.speed] || $.fx.speeds._default;
488
+ if ( !slideOpts.sync )
489
+ slideOpts.speed = slideOpts.speed / 2;
490
+
491
+ slide.addClass( opts.slideClass );
492
+ },
493
+
494
+ updateView: function( isAfter ) {
495
+ var opts = this.opts();
496
+ if ( !opts._initialized )
497
+ return;
498
+ var slideOpts = opts.API.getSlideOpts();
499
+ var currSlide = opts.slides[ opts.currSlide ];
500
+
501
+ if ( ! isAfter ) {
502
+ opts.API.trigger('cycle-update-view-before', [ opts, slideOpts, currSlide ]);
503
+ if ( opts.updateView < 0 )
504
+ return;
505
+ }
506
+
507
+ if ( opts.slideActiveClass ) {
508
+ opts.slides.removeClass( opts.slideActiveClass )
509
+ .eq( opts.currSlide ).addClass( opts.slideActiveClass );
510
+ }
511
+
512
+ if ( isAfter && opts.hideNonActive )
513
+ opts.slides.filter( ':not(.' + opts.slideActiveClass + ')' ).hide();
514
+
515
+ opts.API.trigger('cycle-update-view', [ opts, slideOpts, currSlide, isAfter ]);
516
+ opts.API.trigger('cycle-update-view-after', [ opts, slideOpts, currSlide ]);
517
+ },
518
+
519
+ getComponent: function( name ) {
520
+ var opts = this.opts();
521
+ var selector = opts[name];
522
+ if (typeof selector === 'string') {
523
+ // if selector is a child, sibling combinator, adjancent selector then use find, otherwise query full dom
524
+ return (/^\s*[\>|\+|~]/).test( selector ) ? opts.container.find( selector ) : $( selector );
525
+ }
526
+ if (selector.jquery)
527
+ return selector;
528
+
529
+ return $(selector);
530
+ },
531
+
532
+ stackSlides: function( curr, next, fwd ) {
533
+ var opts = this.opts();
534
+ if ( !curr ) {
535
+ curr = opts.slides[opts.currSlide];
536
+ next = opts.slides[opts.nextSlide];
537
+ fwd = !opts.reverse;
538
+ }
539
+
540
+ // reset the zIndex for the common case:
541
+ // curr slide on top, next slide beneath, and the rest in order to be shown
542
+ $(curr).css('zIndex', opts.maxZ);
543
+
544
+ var i;
545
+ var z = opts.maxZ - 2;
546
+ var len = opts.slideCount;
547
+ if (fwd) {
548
+ for ( i = opts.currSlide + 1; i < len; i++ )
549
+ $( opts.slides[i] ).css( 'zIndex', z-- );
550
+ for ( i = 0; i < opts.currSlide; i++ )
551
+ $( opts.slides[i] ).css( 'zIndex', z-- );
552
+ }
553
+ else {
554
+ for ( i = opts.currSlide - 1; i >= 0; i-- )
555
+ $( opts.slides[i] ).css( 'zIndex', z-- );
556
+ for ( i = len - 1; i > opts.currSlide; i-- )
557
+ $( opts.slides[i] ).css( 'zIndex', z-- );
558
+ }
559
+
560
+ $(next).css('zIndex', opts.maxZ - 1);
561
+ },
562
+
563
+ getSlideIndex: function( el ) {
564
+ return this.opts().slides.index( el );
565
+ }
566
+
567
+ }; // API
568
+
569
+ // default logger
570
+ $.fn.cycle.log = function log() {
571
+ /*global console:true */
572
+ if (window.console && console.log)
573
+ console.log('[cycle2] ' + Array.prototype.join.call(arguments, ' ') );
574
+ };
575
+
576
+ $.fn.cycle.version = function() { return 'Cycle2: ' + version; };
577
+
578
+ // helper functions
579
+
580
+ function lowerCase(s) {
581
+ return (s || '').toLowerCase();
582
+ }
583
+
584
+ // expose transition object
585
+ $.fn.cycle.transitions = {
586
+ custom: {
587
+ },
588
+ none: {
589
+ before: function( opts, curr, next, fwd ) {
590
+ opts.API.stackSlides( next, curr, fwd );
591
+ opts.cssBefore = { opacity: 1, display: 'block' };
592
+ }
593
+ },
594
+ fade: {
595
+ before: function( opts, curr, next, fwd ) {
596
+ var css = opts.API.getSlideOpts( opts.nextSlide ).slideCss || {};
597
+ opts.API.stackSlides( curr, next, fwd );
598
+ opts.cssBefore = $.extend(css, { opacity: 0, display: 'block' });
599
+ opts.animIn = { opacity: 1 };
600
+ opts.animOut = { opacity: 0 };
601
+ }
602
+ },
603
+ fadeout: {
604
+ before: function( opts , curr, next, fwd ) {
605
+ var css = opts.API.getSlideOpts( opts.nextSlide ).slideCss || {};
606
+ opts.API.stackSlides( curr, next, fwd );
607
+ opts.cssBefore = $.extend(css, { opacity: 1, display: 'block' });
608
+ opts.animOut = { opacity: 0 };
609
+ }
610
+ },
611
+ scrollHorz: {
612
+ before: function( opts, curr, next, fwd ) {
613
+ opts.API.stackSlides( curr, next, fwd );
614
+ var w = opts.container.css('overflow','hidden').width();
615
+ opts.cssBefore = { left: fwd ? w : - w, top: 0, opacity: 1, display: 'block' };
616
+ opts.cssAfter = { zIndex: opts._maxZ - 2, left: 0 };
617
+ opts.animIn = { left: 0 };
618
+ opts.animOut = { left: fwd ? -w : w };
619
+ }
620
+ }
621
+ };
622
+
623
+ // @see: http://jquery.malsup.com/cycle2/api
624
+ $.fn.cycle.defaults = {
625
+ allowWrap: true,
626
+ autoSelector: '.cycle-slideshow[data-cycle-auto-init!=false]',
627
+ delay: 0,
628
+ easing: null,
629
+ fx: 'fade',
630
+ hideNonActive: true,
631
+ loop: 0,
632
+ manualFx: undefined,
633
+ manualSpeed: undefined,
634
+ manualTrump: true,
635
+ maxZ: 100,
636
+ pauseOnHover: false,
637
+ reverse: false,
638
+ slideActiveClass: 'cycle-slide-active',
639
+ slideClass: 'cycle-slide',
640
+ slideCss: { position: 'absolute', top: 0, left: 0 },
641
+ slides: '> img',
642
+ speed: 500,
643
+ startingSlide: 0,
644
+ sync: true,
645
+ timeout: 4000,
646
+ updateView: -1
647
+ };
648
+
649
+ // automatically find and run slideshows
650
+ $(document).ready(function() {
651
+ $( $.fn.cycle.defaults.autoSelector ).cycle();
652
+ });
653
+
654
+ })(jQuery);
655
+
656
+ /*! Cycle2 autoheight plugin; Copyright (c) M.Alsup, 2012; version: 20130304 */
657
+ (function($) {
658
+ "use strict";
659
+
660
+ $.extend($.fn.cycle.defaults, {
661
+ autoHeight: 0 // setting this option to false disables autoHeight logic
662
+ });
663
+
664
+ $(document).on( 'cycle-initialized', function( e, opts ) {
665
+ var autoHeight = opts.autoHeight;
666
+ var t = $.type( autoHeight );
667
+ var resizeThrottle = null;
668
+ var ratio;
669
+
670
+ if ( t !== 'string' && t !== 'number' )
671
+ return;
672
+
673
+ // bind events
674
+ opts.container.on( 'cycle-slide-added cycle-slide-removed', initAutoHeight );
675
+ opts.container.on( 'cycle-destroyed', onDestroy );
676
+
677
+ if ( autoHeight == 'container' ) {
678
+ opts.container.on( 'cycle-before', onBefore );
679
+ }
680
+ else if ( t === 'string' && /\d+\:\d+/.test( autoHeight ) ) {
681
+ // use ratio
682
+ ratio = autoHeight.match(/(\d+)\:(\d+)/);
683
+ ratio = ratio[1] / ratio[2];
684
+ opts._autoHeightRatio = ratio;
685
+ }
686
+
687
+ // if autoHeight is a number then we don't need to recalculate the sentinel
688
+ // index on resize
689
+ if ( t !== 'number' ) {
690
+ // bind unique resize handler per slideshow (so it can be 'off-ed' in onDestroy)
691
+ opts._autoHeightOnResize = function () {
692
+ clearTimeout( resizeThrottle );
693
+ resizeThrottle = setTimeout( onResize, 50 );
694
+ };
695
+
696
+ $(window).on( 'resize orientationchange', opts._autoHeightOnResize );
697
+ }
698
+
699
+ setTimeout( onResize, 30 );
700
+
701
+ function onResize() {
702
+ initAutoHeight( e, opts );
703
+ }
704
+ });
705
+
706
+ function initAutoHeight( e, opts ) {
707
+ var clone, height, sentinelIndex;
708
+ var autoHeight = opts.autoHeight;
709
+
710
+ if ( autoHeight == 'container' ) {
711
+ height = $( opts.slides[ opts.currSlide ] ).outerHeight();
712
+ opts.container.height( height );
713
+ }
714
+ else if ( opts._autoHeightRatio ) {
715
+ opts.container.height( opts.container.width() / opts._autoHeightRatio );
716
+ }
717
+ else if ( autoHeight === 'calc' || ( $.type( autoHeight ) == 'number' && autoHeight >= 0 ) ) {
718
+ if ( autoHeight === 'calc' )
719
+ sentinelIndex = calcSentinelIndex( e, opts );
720
+ else if ( autoHeight >= opts.slides.length )
721
+ sentinelIndex = 0;
722
+ else
723
+ sentinelIndex = autoHeight;
724
+
725
+ // only recreate sentinel if index is different
726
+ if ( sentinelIndex == opts._sentinelIndex )
727
+ return;
728
+
729
+ opts._sentinelIndex = sentinelIndex;
730
+ if ( opts._sentinel )
731
+ opts._sentinel.remove();
732
+
733
+ // clone existing slide as sentinel
734
+ clone = $( opts.slides[ sentinelIndex ].cloneNode(true) );
735
+
736
+ // #50; remove special attributes from cloned content
737
+ clone.removeAttr( 'id name rel' ).find( '[id],[name],[rel]' ).removeAttr( 'id name rel' );
738
+
739
+ clone.css({
740
+ position: 'static',
741
+ visibility: 'hidden',
742
+ display: 'block'
743
+ }).prependTo( opts.container ).addClass('cycle-sentinel cycle-slide').removeClass('cycle-slide-active');
744
+ clone.find( '*' ).css( 'visibility', 'hidden' );
745
+
746
+ opts._sentinel = clone;
747
+ }
748
+ }
749
+
750
+ function calcSentinelIndex( e, opts ) {
751
+ var index = 0, max = -1;
752
+
753
+ // calculate tallest slide index
754
+ opts.slides.each(function(i) {
755
+ var h = $(this).height();
756
+ if ( h > max ) {
757
+ max = h;
758
+ index = i;
759
+ }
760
+ });
761
+ return index;
762
+ }
763
+
764
+ function onBefore( e, opts, outgoing, incoming, forward ) {
765
+ var h = $(incoming).outerHeight();
766
+ var duration = opts.sync ? opts.speed / 2 : opts.speed;
767
+ opts.container.animate( { height: h }, duration );
768
+ }
769
+
770
+ function onDestroy( e, opts ) {
771
+ if ( opts._autoHeightOnResize ) {
772
+ $(window).off( 'resize orientationchange', opts._autoHeightOnResize );
773
+ opts._autoHeightOnResize = null;
774
+ }
775
+ opts.container.off( 'cycle-slide-added cycle-slide-removed', initAutoHeight );
776
+ opts.container.off( 'cycle-destroyed', onDestroy );
777
+ opts.container.off( 'cycle-before', onBefore );
778
+
779
+ if ( opts._sentinel ) {
780
+ opts._sentinel.remove();
781
+ opts._sentinel = null;
782
+ }
783
+ }
784
+
785
+ })(jQuery);
786
+
787
+ /*! caption plugin for Cycle2; version: 20130306 */
788
+ (function($) {
789
+ "use strict";
790
+
791
+ $.extend($.fn.cycle.defaults, {
792
+ caption: '> .cycle-caption',
793
+ captionTemplate: '{{slideNum}} / {{slideCount}}',
794
+ overlay: '> .cycle-overlay',
795
+ overlayTemplate: '<div>{{title}}</div><div>{{desc}}</div>',
796
+ captionModule: 'caption'
797
+ });
798
+
799
+ $(document).on( 'cycle-update-view', function( e, opts, slideOpts, currSlide ) {
800
+ if ( opts.captionModule !== 'caption' )
801
+ return;
802
+ var el;
803
+ $.each(['caption','overlay'], function() {
804
+ var name = this;
805
+ var template = slideOpts[name+'Template'];
806
+ var el = opts.API.getComponent( name );
807
+ if( el.length && template ) {
808
+ el.html( opts.API.tmpl( template, slideOpts, opts, currSlide ) );
809
+ el.show();
810
+ }
811
+ else {
812
+ el.hide();
813
+ }
814
+ });
815
+ });
816
+
817
+ $(document).on( 'cycle-destroyed', function( e, opts ) {
818
+ var el;
819
+ $.each(['caption','overlay'], function() {
820
+ var name = this, template = opts[name+'Template'];
821
+ if ( opts[name] && template ) {
822
+ el = opts.API.getComponent( 'caption' );
823
+ el.empty();
824
+ }
825
+ });
826
+ });
827
+
828
+ })(jQuery);
829
+
830
+ /*! command plugin for Cycle2; version: 20130323 */
831
+ (function($) {
832
+ "use strict";
833
+
834
+ var c2 = $.fn.cycle;
835
+
836
+ $.fn.cycle = function( options ) {
837
+ var cmd, cmdFn, opts;
838
+ var args = $.makeArray( arguments );
839
+
840
+ if ( $.type( options ) == 'number' ) {
841
+ return this.cycle( 'goto', options );
842
+ }
843
+
844
+ if ( $.type( options ) == 'string' ) {
845
+ return this.each(function() {
846
+ var cmdArgs;
847
+ cmd = options;
848
+ opts = $(this).data('cycle.opts');
849
+
850
+ if ( opts === undefined ) {
851
+ c2.log('slideshow must be initialized before sending commands; "' + cmd + '" ignored');
852
+ return;
853
+ }
854
+ else {
855
+ cmd = cmd == 'goto' ? 'jump' : cmd; // issue #3; change 'goto' to 'jump' internally
856
+ cmdFn = opts.API[ cmd ];
857
+ if ( $.isFunction( cmdFn )) {
858
+ cmdArgs = $.makeArray( args );
859
+ cmdArgs.shift();
860
+ return cmdFn.apply( opts.API, cmdArgs );
861
+ }
862
+ else {
863
+ c2.log( 'unknown command: ', cmd );
864
+ }
865
+ }
866
+ });
867
+ }
868
+ else {
869
+ return c2.apply( this, arguments );
870
+ }
871
+ };
872
+
873
+ // copy props
874
+ $.extend( $.fn.cycle, c2 );
875
+
876
+ $.extend( c2.API, {
877
+ next: function() {
878
+ var opts = this.opts();
879
+ if ( opts.busy && ! opts.manualTrump )
880
+ return;
881
+
882
+ var count = opts.reverse ? -1 : 1;
883
+ if ( opts.allowWrap === false && ( opts.currSlide + count ) >= opts.slideCount )
884
+ return;
885
+
886
+ opts.API.advanceSlide( count );
887
+ opts.API.trigger('cycle-next', [ opts ]).log('cycle-next');
888
+ },
889
+
890
+ prev: function() {
891
+ var opts = this.opts();
892
+ if ( opts.busy && ! opts.manualTrump )
893
+ return;
894
+ var count = opts.reverse ? 1 : -1;
895
+ if ( opts.allowWrap === false && ( opts.currSlide + count ) < 0 )
896
+ return;
897
+
898
+ opts.API.advanceSlide( count );
899
+ opts.API.trigger('cycle-prev', [ opts ]).log('cycle-prev');
900
+ },
901
+
902
+ destroy: function() {
903
+ var opts = this.opts();
904
+ clearTimeout(opts.timeoutId);
905
+ opts.timeoutId = 0;
906
+ opts.API.stop();
907
+ opts.API.trigger( 'cycle-destroyed', [ opts ] ).log('cycle-destroyed');
908
+ opts.container.removeData( 'cycle.opts' );
909
+
910
+ // #75; remove inline styles
911
+ if ( ! opts.retainStylesOnDestroy ) {
912
+ opts.container.removeAttr( 'style' );
913
+ opts.slides.removeAttr( 'style' );
914
+ opts.slides.removeClass( 'cycle-slide-active' );
915
+ }
916
+ },
917
+
918
+ jump: function( index ) {
919
+ // go to the requested slide
920
+ var fwd;
921
+ var opts = this.opts();
922
+ if ( opts.busy && ! opts.manualTrump )
923
+ return;
924
+ var num = parseInt( index, 10 );
925
+ if (isNaN(num) || num < 0 || num >= opts.slides.length) {
926
+ opts.API.log('goto: invalid slide index: ' + num);
927
+ return;
928
+ }
929
+ if (num == opts.currSlide) {
930
+ opts.API.log('goto: skipping, already on slide', num);
931
+ return;
932
+ }
933
+ opts.nextSlide = num;
934
+ clearTimeout(opts.timeoutId);
935
+ opts.timeoutId = 0;
936
+ opts.API.log('goto: ', num, ' (zero-index)');
937
+ fwd = opts.currSlide < opts.nextSlide;
938
+ opts.API.prepareTx( true, fwd );
939
+ },
940
+
941
+ stop: function() {
942
+ var opts = this.opts();
943
+ var pauseObj = opts.container;
944
+ clearTimeout(opts.timeoutId);
945
+ opts.timeoutId = 0;
946
+ opts.API.stopTransition();
947
+ if ( opts.pauseOnHover ) {
948
+ if ( opts.pauseOnHover !== true )
949
+ pauseObj = $( opts.pauseOnHover );
950
+ pauseObj.off('mouseenter mouseleave');
951
+ }
952
+ opts.API.trigger('cycle-stopped', [ opts ]).log('cycle-stopped');
953
+ },
954
+
955
+ reinit: function() {
956
+ var opts = this.opts();
957
+ opts.API.destroy();
958
+ opts.container.cycle();
959
+ },
960
+
961
+ remove: function( index ) {
962
+ var opts = this.opts();
963
+ var slide, slideToRemove, slides = [], slideNum = 1;
964
+ for ( var i=0; i < opts.slides.length; i++ ) {
965
+ slide = opts.slides[i];
966
+ if ( i == index ) {
967
+ slideToRemove = slide;
968
+ }
969
+ else {
970
+ slides.push( slide );
971
+ $( slide ).data('cycle.opts').slideNum = slideNum;
972
+ slideNum++;
973
+ }
974
+ }
975
+ if ( slideToRemove ) {
976
+ opts.slides = $( slides );
977
+ opts.slideCount--;
978
+ $( slideToRemove ).remove();
979
+ if (index == opts.currSlide) {
980
+ opts.API.advanceSlide( 1 );
981
+ }
982
+
983
+ opts.API.trigger('cycle-slide-removed', [ opts, index, slideToRemove ]).log('cycle-slide-removed');
984
+ opts.API.updateView();
985
+ }
986
+ }
987
+
988
+ });
989
+
990
+ // listen for clicks on elements with data-cycle-cmd attribute
991
+ $(document).on('click.cycle', '[data-cycle-cmd]', function(e) {
992
+ // issue cycle command
993
+ e.preventDefault();
994
+ var el = $(this);
995
+ var command = el.data('cycle-cmd');
996
+ var context = el.data('cycle-context') || '.cycle-slideshow';
997
+ $(context).cycle(command, el.data('cycle-arg'));
998
+ });
999
+
1000
+
1001
+ })(jQuery);
1002
+
1003
+ /*! hash plugin for Cycle2; version: 20121120 */
1004
+ (function($) {
1005
+ "use strict";
1006
+
1007
+ $(document).on( 'cycle-pre-initialize', function( e, opts ) {
1008
+ onHashChange( opts, true );
1009
+
1010
+ opts._onHashChange = function() {
1011
+ onHashChange( opts, false );
1012
+ };
1013
+
1014
+ $( window ).on( 'hashchange', opts._onHashChange);
1015
+ });
1016
+
1017
+ $(document).on( 'cycle-update-view', function( e, opts, slideOpts ) {
1018
+ if ( slideOpts.hash ) {
1019
+ opts._hashFence = true;
1020
+ window.location.hash = slideOpts.hash;
1021
+ }
1022
+ });
1023
+
1024
+ $(document).on( 'cycle-destroyed', function( e, opts) {
1025
+ if ( opts._onHashChange ) {
1026
+ $( window ).off( 'hashchange', opts._onHashChange );
1027
+ }
1028
+ });
1029
+
1030
+ function onHashChange( opts, setStartingSlide ) {
1031
+ var hash;
1032
+ if ( opts._hashFence ) {
1033
+ opts._hashFence = false;
1034
+ return;
1035
+ }
1036
+
1037
+ hash = window.location.hash.substring(1);
1038
+
1039
+ opts.slides.each(function(i) {
1040
+ if ( $(this).data( 'cycle-hash' ) == hash ) {
1041
+ if ( setStartingSlide === true ) {
1042
+ opts.startingSlide = i;
1043
+ }
1044
+ else {
1045
+ opts.nextSlide = i;
1046
+ opts.API.prepareTx( true, false );
1047
+ }
1048
+ return false;
1049
+ }
1050
+ });
1051
+ }
1052
+
1053
+ })(jQuery);
1054
+
1055
+ /*! loader plugin for Cycle2; version: 20130307 */
1056
+ (function($) {
1057
+ "use strict";
1058
+
1059
+ $.extend($.fn.cycle.defaults, {
1060
+ loader: false
1061
+ });
1062
+
1063
+ $(document).on( 'cycle-bootstrap', function( e, opts ) {
1064
+ var addFn;
1065
+
1066
+ if ( !opts.loader )
1067
+ return;
1068
+
1069
+ // override API.add for this slideshow
1070
+ addFn = opts.API.add;
1071
+ opts.API.add = add;
1072
+
1073
+ function add( slides, prepend ) {
1074
+ var slideArr = [];
1075
+ if ( $.type( slides ) == 'string' )
1076
+ slides = $.trim( slides );
1077
+ else if ( $.type( slides) === 'array' ) {
1078
+ for (var i=0; i < slides.length; i++ )
1079
+ slides[i] = $(slides[i])[0];
1080
+ }
1081
+
1082
+ slides = $( slides );
1083
+ var slideCount = slides.length;
1084
+
1085
+ if ( ! slideCount )
1086
+ return;
1087
+
1088
+ slides.hide().appendTo('body').each(function(i) { // appendTo fixes #56
1089
+ var count = 0;
1090
+ var slide = $(this);
1091
+ var images = slide.is('img') ? slide : slide.find('img');
1092
+ slide.data('index', i);
1093
+ // allow some images to be marked as unimportant (and filter out images w/o src value)
1094
+ images = images.filter(':not(.cycle-loader-ignore)').filter(':not([src=""])');
1095
+ if ( ! images.length ) {
1096
+ --slideCount;
1097
+ slideArr.push( slide );
1098
+ return;
1099
+ }
1100
+
1101
+ count = images.length;
1102
+ images.each(function() {
1103
+ // add images that are already loaded
1104
+ if ( this.complete ) {
1105
+ imageLoaded();
1106
+ }
1107
+ else {
1108
+ $(this).load(function() {
1109
+ imageLoaded();
1110
+ }).error(function() {
1111
+ if ( --count === 0 ) {
1112
+ // ignore this slide
1113
+ opts.API.log('slide skipped; img not loaded:', this.src);
1114
+ if ( --slideCount === 0 && opts.loader == 'wait') {
1115
+ addFn.apply( opts.API, [ slideArr, prepend ] );
1116
+ }
1117
+ }
1118
+ });
1119
+ }
1120
+ });
1121
+
1122
+ function imageLoaded() {
1123
+ if ( --count === 0 ) {
1124
+ --slideCount;
1125
+ addSlide( slide );
1126
+ }
1127
+ }
1128
+ });
1129
+
1130
+ if ( slideCount )
1131
+ opts.container.addClass('cycle-loading');
1132
+
1133
+
1134
+ function addSlide( slide ) {
1135
+ var curr;
1136
+ if ( opts.loader == 'wait' ) {
1137
+ slideArr.push( slide );
1138
+ if ( slideCount === 0 ) {
1139
+ // #59; sort slides into original markup order
1140
+ slideArr.sort( sorter );
1141
+ addFn.apply( opts.API, [ slideArr, prepend ] );
1142
+ opts.container.removeClass('cycle-loading');
1143
+ }
1144
+ }
1145
+ else {
1146
+ curr = $(opts.slides[opts.currSlide]);
1147
+ addFn.apply( opts.API, [ slide, prepend ] );
1148
+ curr.show();
1149
+ opts.container.removeClass('cycle-loading');
1150
+ }
1151
+ }
1152
+
1153
+ function sorter(a, b) {
1154
+ return a.data('index') - b.data('index');
1155
+ }
1156
+ }
1157
+ });
1158
+
1159
+ })(jQuery);
1160
+
1161
+ /*! pager plugin for Cycle2; version: 20130203 */
1162
+ (function($) {
1163
+ "use strict";
1164
+
1165
+ $.extend($.fn.cycle.defaults, {
1166
+ pager: '> .cycle-pager',
1167
+ pagerActiveClass: 'cycle-pager-active',
1168
+ pagerEvent: 'click.cycle',
1169
+ pagerTemplate: '<span>&bull;</span>'
1170
+ });
1171
+
1172
+ $(document).on( 'cycle-bootstrap', function( e, opts, API ) {
1173
+ // add method to API
1174
+ API.buildPagerLink = buildPagerLink;
1175
+ });
1176
+
1177
+ $(document).on( 'cycle-slide-added', function( e, opts, slideOpts, slideAdded ) {
1178
+ if ( opts.pager ) {
1179
+ opts.API.buildPagerLink ( opts, slideOpts, slideAdded );
1180
+ opts.API.page = page;
1181
+ }
1182
+ });
1183
+
1184
+ $(document).on( 'cycle-slide-removed', function( e, opts, index, slideRemoved ) {
1185
+ if ( opts.pager ) {
1186
+ var pagers = opts.API.getComponent( 'pager' );
1187
+ pagers.each(function() {
1188
+ var pager = $(this);
1189
+ $( pager.children()[index] ).remove();
1190
+ });
1191
+ }
1192
+ });
1193
+
1194
+ $(document).on( 'cycle-update-view', function( e, opts, slideOpts ) {
1195
+ var pagers;
1196
+
1197
+ if ( opts.pager ) {
1198
+ pagers = opts.API.getComponent( 'pager' );
1199
+ pagers.each(function() {
1200
+ $(this).children().removeClass( opts.pagerActiveClass )
1201
+ .eq( opts.currSlide ).addClass( opts.pagerActiveClass );
1202
+ });
1203
+ }
1204
+ });
1205
+
1206
+ $(document).on( 'cycle-destroyed', function( e, opts ) {
1207
+ var pagers;
1208
+ if (opts.pager && opts.pagerTemplate) {
1209
+ pagers = opts.API.getComponent( 'pager' );
1210
+ pagers.empty();
1211
+ }
1212
+ });
1213
+
1214
+ function buildPagerLink( opts, slideOpts, slide ) {
1215
+ var pagerLink;
1216
+ var pagers = opts.API.getComponent( 'pager' );
1217
+ pagers.each(function() {
1218
+ var pager = $(this);
1219
+ if ( slideOpts.pagerTemplate ) {
1220
+ var markup = opts.API.tmpl( slideOpts.pagerTemplate, slideOpts, opts, slide[0] );
1221
+ pagerLink = $( markup ).appendTo( pager );
1222
+ }
1223
+ else {
1224
+ pagerLink = pager.children().eq( opts.slideCount - 1 );
1225
+ }
1226
+ pagerLink.on( opts.pagerEvent, function(e) {
1227
+ e.preventDefault();
1228
+ opts.API.page( pager, e.currentTarget);
1229
+ });
1230
+ });
1231
+ }
1232
+
1233
+ function page( pager, target ) {
1234
+ /*jshint validthis:true */
1235
+ var opts = this.opts();
1236
+ if ( opts.busy && ! opts.manualTrump )
1237
+ return;
1238
+
1239
+ var index = pager.children().index( target );
1240
+ var nextSlide = index;
1241
+ var fwd = opts.currSlide < nextSlide;
1242
+ if (opts.currSlide == nextSlide) {
1243
+ return; // no op, clicked pager for the currently displayed slide
1244
+ }
1245
+ opts.nextSlide = nextSlide;
1246
+ opts.API.prepareTx( true, fwd );
1247
+ opts.API.trigger('cycle-pager-activated', [opts, pager, target ]);
1248
+ }
1249
+
1250
+ })(jQuery);
1251
+
1252
+
1253
+ /*! prevnext plugin for Cycle2; version: 20130307 */
1254
+ (function($) {
1255
+ "use strict";
1256
+
1257
+ $.extend($.fn.cycle.defaults, {
1258
+ next: '> .cycle-next',
1259
+ nextEvent: 'click.cycle',
1260
+ disabledClass: 'disabled',
1261
+ prev: '> .cycle-prev',
1262
+ prevEvent: 'click.cycle',
1263
+ swipe: false
1264
+ });
1265
+
1266
+ $(document).on( 'cycle-initialized', function( e, opts ) {
1267
+ opts.API.getComponent( 'next' ).on( opts.nextEvent, function(e) {
1268
+ e.preventDefault();
1269
+ opts.API.next();
1270
+ });
1271
+
1272
+ opts.API.getComponent( 'prev' ).on( opts.prevEvent, function(e) {
1273
+ e.preventDefault();
1274
+ opts.API.prev();
1275
+ });
1276
+
1277
+ if ( opts.swipe ) {
1278
+ var nextEvent = opts.swipeVert ? 'swipeUp.cycle' : 'swipeLeft.cycle swipeleft.cycle';
1279
+ var prevEvent = opts.swipeVert ? 'swipeDown.cycle' : 'swipeRight.cycle swiperight.cycle';
1280
+ opts.container.on( nextEvent, function(e) {
1281
+ opts.API.next();
1282
+ });
1283
+ opts.container.on( prevEvent, function() {
1284
+ opts.API.prev();
1285
+ });
1286
+ }
1287
+ });
1288
+
1289
+ $(document).on( 'cycle-update-view', function( e, opts, slideOpts, currSlide ) {
1290
+ if ( opts.allowWrap )
1291
+ return;
1292
+
1293
+ var cls = opts.disabledClass;
1294
+ var next = opts.API.getComponent( 'next' );
1295
+ var prev = opts.API.getComponent( 'prev' );
1296
+ var prevBoundry = opts._prevBoundry || 0;
1297
+ var nextBoundry = opts._nextBoundry || opts.slideCount - 1;
1298
+
1299
+ if ( opts.currSlide == nextBoundry )
1300
+ next.addClass( cls ).prop( 'disabled', true );
1301
+ else
1302
+ next.removeClass( cls ).prop( 'disabled', false );
1303
+
1304
+ if ( opts.currSlide === prevBoundry )
1305
+ prev.addClass( cls ).prop( 'disabled', true );
1306
+ else
1307
+ prev.removeClass( cls ).prop( 'disabled', false );
1308
+ });
1309
+
1310
+
1311
+ $(document).on( 'cycle-destroyed', function( e, opts ) {
1312
+ opts.API.getComponent( 'prev' ).off( opts.nextEvent );
1313
+ opts.API.getComponent( 'next' ).off( opts.prevEvent );
1314
+ opts.container.off( 'swipeleft.cycle swiperight.cycle swipeLeft.cycle swipeRight.cycle swipeUp.cycle swipeDown.cycle' );
1315
+ });
1316
+
1317
+ })(jQuery);
1318
+
1319
+ /*! progressive loader plugin for Cycle2; version: 20130315 */
1320
+ (function($) {
1321
+ "use strict";
1322
+
1323
+ $.extend($.fn.cycle.defaults, {
1324
+ progressive: false
1325
+ });
1326
+
1327
+ $(document).on( 'cycle-pre-initialize', function( e, opts ) {
1328
+ if ( !opts.progressive )
1329
+ return;
1330
+
1331
+ var API = opts.API;
1332
+ var nextFn = API.next;
1333
+ var prevFn = API.prev;
1334
+ var prepareTxFn = API.prepareTx;
1335
+ var type = $.type( opts.progressive );
1336
+ var slides, scriptEl;
1337
+
1338
+ if ( type == 'array' ) {
1339
+ slides = opts.progressive;
1340
+ }
1341
+ else if ($.isFunction( opts.progressive ) ) {
1342
+ slides = opts.progressive( opts );
1343
+ }
1344
+ else if ( type == 'string' ) {
1345
+ scriptEl = $( opts.progressive );
1346
+ slides = $.trim( scriptEl.html() );
1347
+ if ( !slides )
1348
+ return;
1349
+ // is it json array?
1350
+ if ( /^(\[)/.test( slides ) ) {
1351
+ try {
1352
+ slides = $.parseJSON( slides );
1353
+ }
1354
+ catch(err) {
1355
+ API.log( 'error parsing progressive slides', err );
1356
+ return;
1357
+ }
1358
+ }
1359
+ else {
1360
+ // plain text, split on delimeter
1361
+ slides = slides.split( new RegExp( scriptEl.data('cycle-split') || '\n') );
1362
+
1363
+ // #95; look for empty slide
1364
+ if ( ! slides[ slides.length - 1 ] )
1365
+ slides.pop();
1366
+ }
1367
+ }
1368
+
1369
+
1370
+
1371
+ if ( prepareTxFn ) {
1372
+ API.prepareTx = function( manual, fwd ) {
1373
+ var index, slide;
1374
+
1375
+ if ( manual || slides.length === 0 ) {
1376
+ prepareTxFn.apply( opts.API, [ manual, fwd ] );
1377
+ return;
1378
+ }
1379
+
1380
+ if ( fwd && opts.currSlide == ( opts.slideCount-1) ) {
1381
+ slide = slides[ 0 ];
1382
+ slides = slides.slice( 1 );
1383
+ opts.container.one('cycle-slide-added', function(e, opts ) {
1384
+ setTimeout(function() {
1385
+ opts.API.advanceSlide( 1 );
1386
+ },50);
1387
+ });
1388
+ opts.API.add( slide );
1389
+ }
1390
+ else if ( !fwd && opts.currSlide === 0 ) {
1391
+ index = slides.length-1;
1392
+ slide = slides[ index ];
1393
+ slides = slides.slice( 0, index );
1394
+ opts.container.one('cycle-slide-added', function(e, opts ) {
1395
+ setTimeout(function() {
1396
+ opts.currSlide = 1;
1397
+ opts.API.advanceSlide( -1 );
1398
+ },50);
1399
+ });
1400
+ opts.API.add( slide, true );
1401
+ }
1402
+ else {
1403
+ prepareTxFn.apply( opts.API, [ manual, fwd ] );
1404
+ }
1405
+ };
1406
+ }
1407
+
1408
+ if ( nextFn ) {
1409
+ API.next = function() {
1410
+ var opts = this.opts();
1411
+ if ( slides.length && opts.currSlide == ( opts.slideCount - 1 ) ) {
1412
+ var slide = slides[ 0 ];
1413
+ slides = slides.slice( 1 );
1414
+ opts.container.one('cycle-slide-added', function(e, opts ) {
1415
+ nextFn.apply( opts.API );
1416
+ opts.container.removeClass('cycle-loading');
1417
+ });
1418
+ opts.container.addClass('cycle-loading');
1419
+ opts.API.add( slide );
1420
+ }
1421
+ else {
1422
+ nextFn.apply( opts.API );
1423
+ }
1424
+ };
1425
+ }
1426
+
1427
+ if ( prevFn ) {
1428
+ API.prev = function() {
1429
+ var opts = this.opts();
1430
+ if ( slides.length && opts.currSlide === 0 ) {
1431
+ var index = slides.length-1;
1432
+ var slide = slides[ index ];
1433
+ slides = slides.slice( 0, index );
1434
+ opts.container.one('cycle-slide-added', function(e, opts ) {
1435
+ opts.currSlide = 1;
1436
+ opts.API.advanceSlide( -1 );
1437
+ opts.container.removeClass('cycle-loading');
1438
+ });
1439
+ opts.container.addClass('cycle-loading');
1440
+ opts.API.add( slide, true );
1441
+ }
1442
+ else {
1443
+ prevFn.apply( opts.API );
1444
+ }
1445
+ };
1446
+ }
1447
+ });
1448
+
1449
+ })(jQuery);
1450
+
1451
+ /*! tmpl plugin for Cycle2; version: 20121227 */
1452
+ (function($) {
1453
+ "use strict";
1454
+
1455
+ $.extend($.fn.cycle.defaults, {
1456
+ tmplRegex: '{{((.)?.*?)}}'
1457
+ });
1458
+
1459
+ $.extend($.fn.cycle.API, {
1460
+ tmpl: function( str, opts /*, ... */) {
1461
+ var regex = new RegExp( opts.tmplRegex || $.fn.cycle.defaults.tmplRegex, 'g' );
1462
+ var args = $.makeArray( arguments );
1463
+ args.shift();
1464
+ return str.replace(regex, function(_, str) {
1465
+ var i, j, obj, prop, names = str.split('.');
1466
+ for (i=0; i < args.length; i++) {
1467
+ obj = args[i];
1468
+ if ( ! obj )
1469
+ continue;
1470
+ if (names.length > 1) {
1471
+ prop = obj;
1472
+ for (j=0; j < names.length; j++) {
1473
+ obj = prop;
1474
+ prop = prop[ names[j] ] || str;
1475
+ }
1476
+ } else {
1477
+ prop = obj[str];
1478
+ }
1479
+
1480
+ if ($.isFunction(prop))
1481
+ return prop.apply(obj, args);
1482
+ if (prop !== undefined && prop !== null && prop != str)
1483
+ return prop;
1484
+ }
1485
+ return str;
1486
+ });
1487
+ }
1488
+ });
1489
+
1490
+ })(jQuery);