jquery-radiantscroller-rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec6def1c740944fb1c0862fd33637e62dd4f952f
4
- data.tar.gz: 15f68352989c27d9dfb60aaabcf6c9dbe6b795aa
3
+ metadata.gz: ffce4f5a48353afbbfdab1ca1bef4aecf3d6dcb6
4
+ data.tar.gz: 870598a436c4c9e3bd6d17fa2604c0711f16f1eb
5
5
  SHA512:
6
- metadata.gz: a0201f03d0925285d61234a8a98da6783f63db4c0ef8c1ec6d9c0329b8c6f92cb35de3db77683eeb9f5533dc992a1906c7f47e6ab6be08a34d1d7b84d3529e65
7
- data.tar.gz: 8a619dab93b6bc98691584e825837456a8217ab8afc8bc4d970c7dc2ce1b189f39ca3d925c2447a34f081df41e8c309104fbfbf8ab58f7c09ab2afdabb33c779
6
+ metadata.gz: 514f254964e76dee7a8c3ea770a2ef277ba0361a8baf86732419cba44ef4f91ef8b0906c846bc6ad15f267bfd0b37c686ffc1addc33bb2e8d39dae32b062a6aa
7
+ data.tar.gz: 569ba7661c06423b6e81c1207f7fa2f3c3c7138d8df01ac9963b0612112b2bff7428fc6f155ed4c1809a5af3fce3fd8d5eefbbd8d29c9ef0a21f5765d69614c2
@@ -1,5 +1,5 @@
1
1
  module RadiantScroller
2
2
  module Rails
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -1,183 +1,189 @@
1
1
  /*!
2
2
  * jQuery RadiantScroller
3
- * Version: 0.0.4 (23/07/2014)
3
+ * Version: 0.0.5 (28/07/2014)
4
4
  * Copyright (c) 2014 Ilya Bodrov (http://www.radiant-wind.com/plugins/radiant_scroller)
5
5
  *
6
6
  * Requires: jQuery 1.7.0+
7
7
  */
8
8
 
9
9
  (function($) {
10
- $.radiantScroller = function(el, options) {
11
- var scroller = $(el);
10
+ $.radiantScroller = function(el, options) {
11
+ var scroller = $(el);
12
12
 
13
- scroller.vars = $.extend({}, $.radiantScroller.defaults, options);
13
+ scroller.vars = $.extend({}, $.radiantScroller.defaults, options);
14
14
 
15
- // Store reference to scroller in data of the object
16
- scroller.data("radiantscroller", scroller);
17
- // Set to true when scrolling
18
- scroller.animating = false;
15
+ // Store reference to scroller in data of the object
16
+ scroller.data("radiantscroller", scroller);
17
+ // Set to true when scrolling
18
+ scroller.animating = false;
19
19
 
20
- var elements = scroller.find('.scroller-el'),
21
- el_count = elements.size(),
22
- el_width = scroller.vars.elementWidth + scroller.vars.elementMargin,
23
- per_row = Math.ceil(el_count / scroller.vars.rows);
20
+ var elements = scroller.find('.scroller-el'),
21
+ el_count = elements.size(),
22
+ el_width = scroller.vars.elementWidth + scroller.vars.elementMargin,
23
+ per_row = Math.ceil(el_count / scroller.vars.rows);
24
24
 
25
- // Calculating scroller's width with regard to items per row
26
- scroller.width( (el_width * per_row) - scroller.vars.elementMargin );
25
+ // Calculating scroller's width with regard to items per row
26
+ scroller.width( (el_width * per_row) - scroller.vars.elementMargin );
27
27
 
28
- // Grouping elements by rows
29
- do $(elements.slice(0, per_row)).wrapAll('<div class="radiant_scroller_row" />');
30
- while((elements = elements.slice(per_row)).length > 0);
28
+ // Grouping elements by rows
29
+ do $(elements.slice(0, per_row)).wrapAll('<div class="radiant_scroller_row" />');
30
+ while((elements = elements.slice(per_row)).length > 0);
31
31
 
32
- // Wrapper with hidden scrollbars
33
- scroller.wrap('<div class="radiant_scroller"></div>').wrap('<div class="radiant_scroller_wrapper" />');
34
- var wrapper = scroller.parent('.radiant_scroller_wrapper');
35
- var outer_wrapper = wrapper.parent('.radiant_scroller');
32
+ // Wrapper with hidden scrollbars
33
+ scroller.wrap('<div class="radiant_scroller"></div>').wrap('<div class="radiant_scroller_wrapper" />');
34
+ var wrapper = scroller.parent('.radiant_scroller_wrapper'),
35
+ outer_wrapper = wrapper.parent('.radiant_scroller'),
36
+ max_wrapper_width = (scroller.vars.cols * el_width - scroller.vars.elementMargin) + 'px';
36
37
 
37
- var max_wrapper_width = (scroller.vars.cols * el_width - scroller.vars.elementMargin) + 'px';
38
- wrapper.css('max-width', max_wrapper_width);
39
- outer_wrapper.css('max-width', max_wrapper_width);
38
+ wrapper.css('max-width', max_wrapper_width);
39
+ outer_wrapper.css('max-width', max_wrapper_width);
40
40
 
41
- // Next/previous buttons
42
- var nav = $('<div class="radiant-navigation" />').insertAfter(wrapper);
43
- var prev = nav.append($('<div class="radiant-prev">' + scroller.vars.prevButtonText + '</div>'));
44
- var next = nav.append($('<div class="radiant-next">' + scroller.vars.nextButtonText + '</div>'));
41
+ // Next/previous buttons
42
+ var nav = $('<div class="radiant-navigation" />').insertAfter(wrapper),
43
+ prev = nav.append($('<div class="radiant-prev">' + scroller.vars.prevButtonText + '</div>')),
44
+ next = nav.append($('<div class="radiant-next">' + scroller.vars.nextButtonText + '</div>'));
45
45
 
46
- // Scroller methods
47
- scroller.calculateVisibleElements = function() {
48
- scroller.visible_els = (wrapper.width() + scroller.vars.elementMargin) / el_width;
49
- };
46
+ // Scroller methods
47
+ scroller.calculateVisibleElements = function() {
48
+ scroller.visible_els = (wrapper.width() + scroller.vars.elementMargin) / el_width;
49
+ };
50
50
 
51
- scroller.moveElements = function(scrollBy) {
52
- if (!scroller.animating) {
53
- if (typeof scrollBy === 'undefined')
54
- scrollBy = 1;
55
-
56
- var new_current_page = scroller.current_page + scrollBy;
57
- // The requested page should be between 0 and total number of pages and should not be the same page
58
- // as the current, otherwise do nothing
59
- if (new_current_page >= 0 && new_current_page < scroller.total_pages &&
60
- new_current_page !== scroller.current_page) {
61
- scroller.animating = true;
62
-
63
- wrapper.animate(
64
- { scrollLeft: wrapper.scrollLeft() + scroller.visible_els * el_width * scrollBy },
65
- scroller.vars.animateDuration, scroller.vars.easingType,
66
- function() { scroller.animating = false; }
67
- );
68
-
69
- scroller.current_page = new_current_page;
70
-
71
- if (scroller.vars.addPagination)
72
- scroller.assignActivePage(true);
73
- }
74
- }
75
- };
51
+ scroller.moveElements = function(scrollBy, instant) {
52
+ if (!scroller.animating) {
53
+ if (typeof scrollBy === 'undefined')
54
+ scrollBy = 1;
76
55
 
77
- scroller.initializePagination = function() {
78
- // If there is the same number of visible elements we don't have to change anything
79
- if (typeof scroller.old_visible_els === 'undefined' || scroller.old_visible_els !== scroller.visible_els) {
80
- scroller.old_visible_els = scroller.visible_els;
81
- scroller.total_pages = Math.ceil(per_row / scroller.visible_els);
82
-
83
- if (typeof scroller.current_page === 'undefined') {
84
- // If current page was not set previously, we set it now
85
- scroller.current_page = 0;
86
- } else {
87
- scroller.current_page = Math.ceil(wrapper.scrollLeft() / (scroller.visible_els * el_width));
88
- }
89
-
90
- if (scroller.vars.addPagination)
91
- scroller.drawPagination();
92
- }
93
- };
56
+ var duration = scroller.vars.animateDuration;
57
+ if (typeof instant !== 'undefined' && instant)
58
+ duration = 0;
94
59
 
95
- scroller.drawPagination = function() {
96
- if (outer_wrapper.find('.radiant-pagination').size() > 0)
97
- outer_wrapper.find('.radiant-pagination').remove();
60
+ var new_current_page = scroller.current_page + scrollBy;
61
+ // The requested page should be between 0 and total number of pages and should not be the same page
62
+ // as the current, otherwise do nothing
63
+ if (new_current_page >= 0 && new_current_page < scroller.total_pages &&
64
+ new_current_page !== scroller.current_page) {
65
+ scroller.animating = true;
98
66
 
99
- var pagination = $('<div class="radiant-pagination" />').insertAfter(wrapper);
100
- for (var i = 0; i < scroller.total_pages; i++) {
101
- pagination.append('<div class="radiant-page" data-page="' + i + '" />');
102
- }
103
- scroller.assignActivePage();
104
- };
67
+ wrapper.animate(
68
+ { scrollLeft: wrapper.scrollLeft() + scroller.visible_els * el_width * scrollBy },
69
+ duration, scroller.vars.easingType,
70
+ function() { scroller.animating = false; }
71
+ );
105
72
 
106
- scroller.assignActivePage = function(remove_old_active) {
107
- if (remove_old_active === true)
108
- outer_wrapper.find('.current-page').removeClass('current-page');
109
- $(outer_wrapper.find('.radiant-page').get(scroller.current_page)).addClass('current-page');
110
- };
73
+ scroller.current_page = new_current_page;
111
74
 
112
- // Binding events
113
- $(window).bindWithDelay('resize', function() {
114
- scroller.calculateVisibleElements();
115
- scroller.initializePagination();
116
- }, 500, true);
117
-
118
- nav.on('click', '.radiant-next', function() {
119
- scroller.moveElements(1);
120
- });
121
-
122
- nav.on('click', '.radiant-prev', function() {
123
- scroller.moveElements(-1);
124
- });
125
-
126
- if (scroller.vars.useMouseWheel) {
127
- wrapper.on('mousewheel', function(event) {
128
- event.preventDefault();
129
- scroller.moveElements(event.deltaY);
130
- });
75
+ if (scroller.vars.addPagination)
76
+ scroller.assignActivePage(true);
131
77
  }
132
-
133
- outer_wrapper.on('click', '.radiant-page', function() {
134
- var this_page = $(this).data('page');
135
- // If not clicking on the same page
136
- if (scroller.current_page !== this_page) {
137
- var current_page_number = scroller.current_page;
138
- scroller.moveElements(this_page - current_page_number);
139
- }
140
- });
141
-
142
- // Init scroller
143
- scroller.calculateVisibleElements();
144
- scroller.initializePagination();
145
- };
146
-
147
- $.radiantScroller.defaults = {
148
- cols: 2,
149
- elementWidth: 200,
150
- elementMargin: 10,
151
- easingType: 'swing',
152
- animateDuration: 700,
153
- rows: 2,
154
- useMouseWheel: false,
155
- addPagination: false,
156
- nextButtonText: '',
157
- prevButtonText: ''
78
+ }
158
79
  };
159
80
 
160
- $.fn.radiantScroller = function(options, options2) {
161
- if (options === undefined) options = {};
81
+ scroller.initializePagination = function() {
82
+ // If there is the same number of visible elements we don't have to change anything
83
+ if (typeof scroller.old_visible_els === 'undefined' || scroller.old_visible_els !== scroller.visible_els) {
84
+ scroller.old_visible_els = scroller.visible_els;
85
+ scroller.total_pages = Math.ceil(per_row / scroller.visible_els);
162
86
 
163
- if (typeof options === "object") {
164
- new $.radiantScroller(this, options);
87
+ if (typeof scroller.current_page === 'undefined') {
88
+ // If current page was not set previously, we set it now
89
+ scroller.current_page = 0;
165
90
  } else {
166
- var $scroller = $(this).data('radiantscroller');
167
- switch (options) {
168
- case "next": $scroller.moveElements(1); break;
169
- case "prev": $scroller.moveElements(-1); break;
170
- // radiantScroller('by', 2) - scroll by 2 pages, not to the 2nd page
171
- //TODO: check number
172
- case "by": if (typeof options2 === "number") $scroller.moveElements(options2); break;
173
- // Default behaviour: radiantScroller(3) means go to 3 page and page numeration starts from 1
174
- // (whereas plugin has numeration starting from 0, so have to substract 1!!!)
175
- default: if (typeof options === "number") $scroller.moveElements(options - 1 - $scroller.current_page);
176
- }
91
+ scroller.current_page = Math.ceil(wrapper.scrollLeft() / (scroller.visible_els * el_width));
177
92
  }
178
93
 
179
- return this;
94
+ if (scroller.vars.addPagination)
95
+ scroller.drawPagination();
96
+ }
180
97
  };
98
+
99
+ scroller.drawPagination = function() {
100
+ if (outer_wrapper.find('.radiant-pagination').size() > 0)
101
+ outer_wrapper.find('.radiant-pagination').remove();
102
+
103
+ var pagination = $('<div class="radiant-pagination" />').insertAfter(wrapper);
104
+ for (var i = 0; i < scroller.total_pages; i++) {
105
+ pagination.append('<div class="radiant-page" data-page="' + i + '" />');
106
+ }
107
+ scroller.assignActivePage();
108
+ };
109
+
110
+ scroller.assignActivePage = function(remove_old_active) {
111
+ if (remove_old_active === true)
112
+ outer_wrapper.find('.current-page').removeClass('current-page');
113
+ $(outer_wrapper.find('.radiant-page').get(scroller.current_page)).addClass('current-page');
114
+ };
115
+
116
+ // Binding events
117
+ $(window).bindWithDelay('resize', function() {
118
+ scroller.calculateVisibleElements();
119
+ scroller.initializePagination();
120
+ var temp_page = scroller.current_page;
121
+ scroller.moveElements(-temp_page, true);
122
+ scroller.moveElements(temp_page, true);
123
+ }, scroller.vars.delayDuration, true);
124
+
125
+ nav.on('click', '.radiant-next', function() {
126
+ scroller.moveElements(1);
127
+ });
128
+
129
+ nav.on('click', '.radiant-prev', function() {
130
+ scroller.moveElements(-1);
131
+ });
132
+
133
+ if (scroller.vars.useMouseWheel) {
134
+ wrapper.on('mousewheel', function(event) {
135
+ event.preventDefault();
136
+ scroller.moveElements(event.deltaY);
137
+ });
138
+ }
139
+
140
+ outer_wrapper.on('click', '.radiant-page', function() {
141
+ var this_page = $(this).data('page');
142
+ // If not clicking on the same page
143
+ if (scroller.current_page !== this_page) {
144
+ scroller.moveElements(this_page - scroller.current_page);
145
+ }
146
+ });
147
+
148
+ // Init scroller
149
+ scroller.calculateVisibleElements();
150
+ scroller.initializePagination();
151
+ };
152
+
153
+ $.radiantScroller.defaults = {
154
+ addPagination: false,
155
+ animateDuration: 700,
156
+ cols: 2,
157
+ delayDuration: 500,
158
+ easingType: 'swing',
159
+ elementMargin: 10,
160
+ elementWidth: 200,
161
+ nextButtonText: '',
162
+ prevButtonText: '',
163
+ rows: 2,
164
+ useMouseWheel: false
165
+ };
166
+
167
+ $.fn.radiantScroller = function(options, options2) {
168
+ if (options === undefined) options = {};
169
+
170
+ if (typeof options === "object") {
171
+ new $.radiantScroller(this, options);
172
+ } else {
173
+ var $scroller = $(this).data('radiantscroller');
174
+ switch (options) {
175
+ case "next": $scroller.moveElements(1); break;
176
+ case "prev": $scroller.moveElements(-1); break;
177
+ // radiantScroller('by', 2) - scroll by 2 pages, not to the 2nd page
178
+ case "by": if (typeof options2 === "number") $scroller.moveElements(options2); break;
179
+ // Default behaviour: radiantScroller(3) means go to 3 page and page numeration starts from 1
180
+ // (whereas plugin has numeration starting from 0, so have to substract 1!!!)
181
+ default: if (typeof options === "number") $scroller.moveElements(options - 1 - $scroller.current_page);
182
+ }
183
+ }
184
+
185
+ return this;
186
+ };
181
187
  })(jQuery);
182
188
 
183
189
  /*
@@ -200,39 +206,39 @@
200
206
 
201
207
  (function($) {
202
208
 
203
- $.fn.bindWithDelay = function( type, data, fn, timeout, throttle ) {
209
+ $.fn.bindWithDelay = function( type, data, fn, timeout, throttle ) {
204
210
 
205
- if ( $.isFunction( data ) ) {
206
- throttle = timeout;
207
- timeout = fn;
208
- fn = data;
209
- data = undefined;
210
- }
211
+ if ( $.isFunction( data ) ) {
212
+ throttle = timeout;
213
+ timeout = fn;
214
+ fn = data;
215
+ data = undefined;
216
+ }
211
217
 
212
- // Allow delayed function to be removed with fn in unbind function
213
- fn.guid = fn.guid || ($.guid && $.guid++);
218
+ // Allow delayed function to be removed with fn in unbind function
219
+ fn.guid = fn.guid || ($.guid && $.guid++);
214
220
 
215
- // Bind each separately so that each element has its own delay
216
- return this.each(function() {
221
+ // Bind each separately so that each element has its own delay
222
+ return this.each(function() {
217
223
 
218
- var wait = null;
224
+ var wait = null;
219
225
 
220
- function cb() {
221
- var e = $.extend(true, { }, arguments[0]);
222
- var ctx = this;
223
- var throttler = function() {
224
- wait = null;
225
- fn.apply(ctx, [e]);
226
- };
226
+ function cb() {
227
+ var e = $.extend(true, { }, arguments[0]);
228
+ var ctx = this;
229
+ var throttler = function() {
230
+ wait = null;
231
+ fn.apply(ctx, [e]);
232
+ };
227
233
 
228
- if (!throttle) { clearTimeout(wait); wait = null; }
229
- if (!wait) { wait = setTimeout(throttler, timeout); }
230
- }
234
+ if (!throttle) { clearTimeout(wait); wait = null; }
235
+ if (!wait) { wait = setTimeout(throttler, timeout); }
236
+ }
231
237
 
232
- cb.guid = fn.guid;
238
+ cb.guid = fn.guid;
233
239
 
234
- $(this).bind(type, data, cb);
235
- });
236
- };
240
+ $(this).bind(type, data, cb);
241
+ });
242
+ };
237
243
 
238
244
  })(jQuery);
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * jQuery RadiantScroller
3
- * Version: 0.0.4 (23/07/2014)
3
+ * Version: 0.0.5 (28/07/2014)
4
4
  * Copyright (c) 2014 Ilya Bodrov (http://www.radiant-wind.com/plugins/radiant_scroller)
5
5
  */
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-radiantscroller-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bodrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-23 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties