cycle2-rails 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ pkg
@@ -1,38 +1,38 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cycle2-rails (1.0.0)
4
+ cycle2-rails (1.1.0)
5
5
  jquery-rails (~> 2.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionpack (3.2.8)
11
- activemodel (= 3.2.8)
12
- activesupport (= 3.2.8)
10
+ actionpack (3.2.13)
11
+ activemodel (= 3.2.13)
12
+ activesupport (= 3.2.13)
13
13
  builder (~> 3.0.0)
14
14
  erubis (~> 2.7.0)
15
15
  journey (~> 1.0.4)
16
- rack (~> 1.4.0)
16
+ rack (~> 1.4.5)
17
17
  rack-cache (~> 1.2)
18
18
  rack-test (~> 0.6.1)
19
- sprockets (~> 2.1.3)
20
- activemodel (3.2.8)
21
- activesupport (= 3.2.8)
19
+ sprockets (~> 2.2.1)
20
+ activemodel (3.2.13)
21
+ activesupport (= 3.2.13)
22
22
  builder (~> 3.0.0)
23
- activesupport (3.2.8)
24
- i18n (~> 0.6)
23
+ activesupport (3.2.13)
24
+ i18n (= 0.6.1)
25
25
  multi_json (~> 1.0)
26
26
  builder (3.0.4)
27
27
  erubis (2.7.0)
28
28
  hike (1.2.2)
29
- i18n (0.6.4)
29
+ i18n (0.6.1)
30
30
  journey (1.0.4)
31
31
  jquery-rails (2.2.1)
32
32
  railties (>= 3.0, < 5.0)
33
33
  thor (>= 0.14, < 2.0)
34
- json (1.7.7)
35
- multi_json (1.7.3)
34
+ json (1.8.0)
35
+ multi_json (1.7.4)
36
36
  rack (1.4.5)
37
37
  rack-cache (1.2)
38
38
  rack (>= 0.4)
@@ -40,9 +40,9 @@ GEM
40
40
  rack
41
41
  rack-test (0.6.2)
42
42
  rack (>= 1.0)
43
- railties (3.2.8)
44
- actionpack (= 3.2.8)
45
- activesupport (= 3.2.8)
43
+ railties (3.2.13)
44
+ actionpack (= 3.2.13)
45
+ activesupport (= 3.2.13)
46
46
  rack-ssl (~> 1.3.2)
47
47
  rake (>= 0.8.7)
48
48
  rdoc (~> 3.4)
@@ -50,12 +50,13 @@ GEM
50
50
  rake (10.0.4)
51
51
  rdoc (3.12.2)
52
52
  json (~> 1.4)
53
- sprockets (2.1.3)
53
+ sprockets (2.2.2)
54
54
  hike (~> 1.2)
55
+ multi_json (~> 1.0)
55
56
  rack (~> 1.0)
56
57
  tilt (~> 1.1, != 1.3.0)
57
58
  thor (0.18.1)
58
- tilt (1.4.0)
59
+ tilt (1.4.1)
59
60
 
60
61
  PLATFORMS
61
62
  ruby
data/README.md CHANGED
@@ -22,8 +22,30 @@ And then execute:
22
22
 
23
23
  In your application.js
24
24
 
25
- //= require cycle2-rails
26
-
25
+ //= require jquery.cycle2
26
+
27
+ Additionaly you can use optional Cycle2 plugins like this:
28
+
29
+ //= require jquery.cycle2.carousel
30
+ //= require jquery.cycle2.swipe
31
+
32
+ Note jquery.cycle2 included automatically if you use any plugin.
33
+ More info about optional plugins on Cycle2 page: http://jquery.malsup.com/cycle2/download/
34
+
35
+ If you wish use only additional plugins you can include only needed base modules.
36
+ For example:
37
+
38
+ //= require jquery.cycle2.autoheight
39
+ //= require jquery.cycle2.swipe
40
+
41
+ More info about core plugins: http://jquery.malsup.com/cycle2/download/advanced.php
42
+
43
+ Also you can include all core modules and additional plugins:
44
+
45
+ //= require jquery.cycle2.all
46
+
47
+
48
+
27
49
  ## Contributing
28
50
 
29
51
  1. Fork it
data/Rakefile CHANGED
@@ -3,12 +3,71 @@ require "bundler/gem_tasks"
3
3
  require 'open-uri'
4
4
 
5
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
-
6
+ task :update do
7
+ base_output = "app/assets/javascripts/"
8
+
9
+ cycle2_core_url = 'http://malsup.github.com/jquery.cycle2.core.js'
10
+ outputfile = File.join(base_output, File.basename(cycle2_core_url))
10
11
  open(outputfile, 'wb') do |file|
11
- file << open(url).read
12
+ file << open(cycle2_core_url).read
13
+ end
14
+
15
+ components = %w[
16
+ http://malsup.github.com/jquery.cycle2.autoheight.js
17
+ http://malsup.github.com/jquery.cycle2.caption.js
18
+ http://malsup.github.com/jquery.cycle2.command.js
19
+ http://malsup.github.com/jquery.cycle2.hash.js
20
+ http://malsup.github.com/jquery.cycle2.loader.js
21
+ http://malsup.github.com/jquery.cycle2.pager.js
22
+ http://malsup.github.com/jquery.cycle2.prevnext.js
23
+ http://malsup.github.com/jquery.cycle2.progressive.js
24
+ http://malsup.github.com/jquery.cycle2.tmpl.js
25
+ ]
26
+ components.each do |component_url|
27
+ component_outputfile = File.join(base_output, File.basename(component_url))
28
+ open(component_outputfile, 'wb') do |file|
29
+ file << "//= require jquery.cycle2.core\n\n"
30
+ file << open(component_url).read
31
+ end
32
+ end
33
+
34
+ cycle2_base_outfile = File.join(base_output, 'jquery.cycle2.js')
35
+ open(cycle2_base_outfile, 'wb') do |file|
36
+ file << "//= require jquery.cycle2.core\n"
37
+ components.each do |component|
38
+ asset_name = File.basename(component, File.extname(component))
39
+ file << "//= require #{asset_name}\n"
40
+ end
41
+ file << "\n"
42
+ end
43
+
44
+ plugins = %w[http://malsup.github.com/jquery.cycle2.carousel.js
45
+ http://malsup.github.com/jquery.cycle2.ie-fade.js
46
+ http://malsup.github.com/jquery.cycle2.scrollVert.js
47
+ http://malsup.github.com/jquery.cycle2.shuffle.js
48
+ http://malsup.github.com/jquery.cycle2.tile.js
49
+ http://malsup.github.com/jquery.cycle2.caption2.js
50
+ http://malsup.github.com/jquery.cycle2.center.js
51
+ http://malsup.github.com/jquery.cycle2.swipe.js
52
+ http://malsup.github.com/jquery.cycle2.video.js]
53
+
54
+ plugins.each do |plugin_url|
55
+ plugin_outputfile = File.join(base_output, File.basename(plugin_url))
56
+ open(plugin_outputfile, 'wb') do |file|
57
+ file << "//= require jquery.cycle2\n\n"
58
+ file << open(plugin_url).read
59
+ end
12
60
  end
61
+
62
+
63
+ cycle2_all_outfile = File.join(base_output, 'jquery.cycle2.all.js')
64
+ open(cycle2_all_outfile, 'wb') do |file|
65
+ file << "//= require jquery.cycle2\n"
66
+ plugins.each do |plugin_url|
67
+ asset_name = File.basename(plugin_url, File.extname(plugin_url))
68
+ file << "//= require #{asset_name}\n"
69
+ end
70
+ file << "\n"
71
+ end
13
72
 
14
73
  end
@@ -0,0 +1,11 @@
1
+ //= require jquery.cycle2
2
+ //= require jquery.cycle2.carousel
3
+ //= require jquery.cycle2.ie-fade
4
+ //= require jquery.cycle2.scrollVert
5
+ //= require jquery.cycle2.shuffle
6
+ //= require jquery.cycle2.tile
7
+ //= require jquery.cycle2.caption2
8
+ //= require jquery.cycle2.center
9
+ //= require jquery.cycle2.swipe
10
+ //= require jquery.cycle2.video
11
+
@@ -0,0 +1,132 @@
1
+ //= require jquery.cycle2.core
2
+
3
+ /*! Cycle2 autoheight plugin; Copyright (c) M.Alsup, 2012; version: 20130304 */
4
+ (function($) {
5
+ "use strict";
6
+
7
+ $.extend($.fn.cycle.defaults, {
8
+ autoHeight: 0 // setting this option to false disables autoHeight logic
9
+ });
10
+
11
+ $(document).on( 'cycle-initialized', function( e, opts ) {
12
+ var autoHeight = opts.autoHeight;
13
+ var t = $.type( autoHeight );
14
+ var resizeThrottle = null;
15
+ var ratio;
16
+
17
+ if ( t !== 'string' && t !== 'number' )
18
+ return;
19
+
20
+ // bind events
21
+ opts.container.on( 'cycle-slide-added cycle-slide-removed', initAutoHeight );
22
+ opts.container.on( 'cycle-destroyed', onDestroy );
23
+
24
+ if ( autoHeight == 'container' ) {
25
+ opts.container.on( 'cycle-before', onBefore );
26
+ }
27
+ else if ( t === 'string' && /\d+\:\d+/.test( autoHeight ) ) {
28
+ // use ratio
29
+ ratio = autoHeight.match(/(\d+)\:(\d+)/);
30
+ ratio = ratio[1] / ratio[2];
31
+ opts._autoHeightRatio = ratio;
32
+ }
33
+
34
+ // if autoHeight is a number then we don't need to recalculate the sentinel
35
+ // index on resize
36
+ if ( t !== 'number' ) {
37
+ // bind unique resize handler per slideshow (so it can be 'off-ed' in onDestroy)
38
+ opts._autoHeightOnResize = function () {
39
+ clearTimeout( resizeThrottle );
40
+ resizeThrottle = setTimeout( onResize, 50 );
41
+ };
42
+
43
+ $(window).on( 'resize orientationchange', opts._autoHeightOnResize );
44
+ }
45
+
46
+ setTimeout( onResize, 30 );
47
+
48
+ function onResize() {
49
+ initAutoHeight( e, opts );
50
+ }
51
+ });
52
+
53
+ function initAutoHeight( e, opts ) {
54
+ var clone, height, sentinelIndex;
55
+ var autoHeight = opts.autoHeight;
56
+
57
+ if ( autoHeight == 'container' ) {
58
+ height = $( opts.slides[ opts.currSlide ] ).outerHeight();
59
+ opts.container.height( height );
60
+ }
61
+ else if ( opts._autoHeightRatio ) {
62
+ opts.container.height( opts.container.width() / opts._autoHeightRatio );
63
+ }
64
+ else if ( autoHeight === 'calc' || ( $.type( autoHeight ) == 'number' && autoHeight >= 0 ) ) {
65
+ if ( autoHeight === 'calc' )
66
+ sentinelIndex = calcSentinelIndex( e, opts );
67
+ else if ( autoHeight >= opts.slides.length )
68
+ sentinelIndex = 0;
69
+ else
70
+ sentinelIndex = autoHeight;
71
+
72
+ // only recreate sentinel if index is different
73
+ if ( sentinelIndex == opts._sentinelIndex )
74
+ return;
75
+
76
+ opts._sentinelIndex = sentinelIndex;
77
+ if ( opts._sentinel )
78
+ opts._sentinel.remove();
79
+
80
+ // clone existing slide as sentinel
81
+ clone = $( opts.slides[ sentinelIndex ].cloneNode(true) );
82
+
83
+ // #50; remove special attributes from cloned content
84
+ clone.removeAttr( 'id name rel' ).find( '[id],[name],[rel]' ).removeAttr( 'id name rel' );
85
+
86
+ clone.css({
87
+ position: 'static',
88
+ visibility: 'hidden',
89
+ display: 'block'
90
+ }).prependTo( opts.container ).addClass('cycle-sentinel cycle-slide').removeClass('cycle-slide-active');
91
+ clone.find( '*' ).css( 'visibility', 'hidden' );
92
+
93
+ opts._sentinel = clone;
94
+ }
95
+ }
96
+
97
+ function calcSentinelIndex( e, opts ) {
98
+ var index = 0, max = -1;
99
+
100
+ // calculate tallest slide index
101
+ opts.slides.each(function(i) {
102
+ var h = $(this).height();
103
+ if ( h > max ) {
104
+ max = h;
105
+ index = i;
106
+ }
107
+ });
108
+ return index;
109
+ }
110
+
111
+ function onBefore( e, opts, outgoing, incoming, forward ) {
112
+ var h = $(incoming).outerHeight();
113
+ var duration = opts.sync ? opts.speed / 2 : opts.speed;
114
+ opts.container.animate( { height: h }, duration );
115
+ }
116
+
117
+ function onDestroy( e, opts ) {
118
+ if ( opts._autoHeightOnResize ) {
119
+ $(window).off( 'resize orientationchange', opts._autoHeightOnResize );
120
+ opts._autoHeightOnResize = null;
121
+ }
122
+ opts.container.off( 'cycle-slide-added cycle-slide-removed', initAutoHeight );
123
+ opts.container.off( 'cycle-destroyed', onDestroy );
124
+ opts.container.off( 'cycle-before', onBefore );
125
+
126
+ if ( opts._sentinel ) {
127
+ opts._sentinel.remove();
128
+ opts._sentinel = null;
129
+ }
130
+ }
131
+
132
+ })(jQuery);
@@ -0,0 +1,44 @@
1
+ //= require jquery.cycle2.core
2
+
3
+ /*! caption plugin for Cycle2; version: 20130306 */
4
+ (function($) {
5
+ "use strict";
6
+
7
+ $.extend($.fn.cycle.defaults, {
8
+ caption: '> .cycle-caption',
9
+ captionTemplate: '{{slideNum}} / {{slideCount}}',
10
+ overlay: '> .cycle-overlay',
11
+ overlayTemplate: '<div>{{title}}</div><div>{{desc}}</div>',
12
+ captionModule: 'caption'
13
+ });
14
+
15
+ $(document).on( 'cycle-update-view', function( e, opts, slideOpts, currSlide ) {
16
+ if ( opts.captionModule !== 'caption' )
17
+ return;
18
+ var el;
19
+ $.each(['caption','overlay'], function() {
20
+ var name = this;
21
+ var template = slideOpts[name+'Template'];
22
+ var el = opts.API.getComponent( name );
23
+ if( el.length && template ) {
24
+ el.html( opts.API.tmpl( template, slideOpts, opts, currSlide ) );
25
+ el.show();
26
+ }
27
+ else {
28
+ el.hide();
29
+ }
30
+ });
31
+ });
32
+
33
+ $(document).on( 'cycle-destroyed', function( e, opts ) {
34
+ var el;
35
+ $.each(['caption','overlay'], function() {
36
+ var name = this, template = opts[name+'Template'];
37
+ if ( opts[name] && template ) {
38
+ el = opts.API.getComponent( 'caption' );
39
+ el.empty();
40
+ }
41
+ });
42
+ });
43
+
44
+ })(jQuery);
@@ -0,0 +1,69 @@
1
+ //= require jquery.cycle2
2
+
3
+ /*! caption2 plugin for Cycle2; version: 20130306 */
4
+ (function($) {
5
+ "use strict";
6
+
7
+ $.extend($.fn.cycle.defaults, {
8
+ captionFxOut: 'fadeOut',
9
+ captionFxIn: 'fadeIn',
10
+ captionFxSel: undefined,
11
+ overlayFxOut: 'fadeOut',
12
+ overlayFxIn: 'fadeIn',
13
+ overlayFxSel: undefined
14
+ });
15
+
16
+ $(document).on( 'cycle-bootstrap', function(e, opts) {
17
+ opts.container.on( 'cycle-update-view-before', update );
18
+ opts.container.one( 'cycle-update-view-after', init );
19
+ });
20
+
21
+ function update( e, opts, slideOpts, currSlide, isAfter ) {
22
+ if ( opts.captionPlugin !== 'caption2' )
23
+ return;
24
+ $.each(['caption','overlay'], function() {
25
+ var fxBase = this + 'Fx',
26
+ fx = opts[fxBase + 'Out'] || 'hide',
27
+ template = slideOpts[this+'Template'],
28
+ el = opts.API.getComponent( this ),
29
+ sel = opts[fxBase+'Sel'],
30
+ speed = opts.speed,
31
+ animEl;
32
+
33
+ if ( opts.sync )
34
+ speed = speed/2;
35
+
36
+ animEl = sel ? el.find( sel ) : el;
37
+
38
+ if( el.length && template ) {
39
+ if ( fx == 'hide')
40
+ speed = 0;
41
+ animEl[fx]( speed, function() {
42
+ var content = opts.API.tmpl( template, slideOpts, opts, currSlide );
43
+ el.html( content );
44
+ animEl = sel ? el.find( sel ) : el;
45
+ if ( sel )
46
+ animEl.hide();
47
+ fx = opts[ fxBase + 'In'] || 'show';
48
+ animEl[fx]( speed );
49
+ });
50
+ }
51
+ else {
52
+ el.hide();
53
+ }
54
+ });
55
+ }
56
+
57
+ function init( e, opts, slideOpts, currSlide, isAfter ) {
58
+ if ( opts.captionPlugin !== 'caption2' )
59
+ return;
60
+ $.each(['caption','overlay'], function() {
61
+ var template = slideOpts[this+'Template'],
62
+ el = opts.API.getComponent( this );
63
+
64
+ if( el.length && template )
65
+ el.html( opts.API.tmpl( template, slideOpts, opts, currSlide ) );
66
+ });
67
+ }
68
+
69
+ })(jQuery);