jquery-radiantscroller-rails 0.0.2.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzUyZWI4ODFhY2MwNDQyZGNkOTk4YTI5NTM4ZjU3YzYyMTQ3NGI5NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yzc5NmIxMzQ3YTZhNjcxYWZkYjYzZGMyMzQ4NzdmZTY0NDA2ZGQ5Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmJlOWMzMjU1ODQ5ZDkwNWE4Y2QwYTM5NWRjOGUxNDljNTdkZjJkM2RkOTI3
|
10
|
+
NjZlZDgzZjQyZjcxOTA2ODYzOTk2NjJiYTBmYWZkZWQzMGIxZWY0ZjNjZDVj
|
11
|
+
Yzc3Y2Q0MWI1NzU4NTAzMWFhY2M2MDVjNDIzMjc0NzM5ZmRkZWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTE1NGZiY2QxNTkxNWE0NjRmZTUwNDk4NTM4ZDZiNGIxZDVhMDg0Yzk0NGE0
|
14
|
+
NjFiMzA1NDVmN2I1YWI4MjA5ODRlOWU1YWYyMDYxZWIzYTBlZjRlODQ1Mzg4
|
15
|
+
YTNhYWViM2M1MjI1YzMyYTlmZmZjZWI4ZmJjN2QwNDhiMzliM2I=
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
* jQuery RadiantScroller
|
3
|
-
* Version: 0.0.
|
3
|
+
* Version: 0.0.3 (07/01/2014)
|
4
4
|
* Copyright (c) 2013 Ilya Bodrov (http://www.radiant-wind.com/plugins/radiant_scroller)
|
5
5
|
*
|
6
6
|
* Requires: jQuery 1.7.0+
|
@@ -20,8 +20,7 @@
|
|
20
20
|
var elements = scroller.find('.scroller-el'),
|
21
21
|
el_count = elements.size(),
|
22
22
|
el_width = scroller.vars.elementWidth + scroller.vars.elementMargin,
|
23
|
-
per_row = Math.ceil(el_count / scroller.vars.rows)
|
24
|
-
visible_els = 0;
|
23
|
+
per_row = Math.ceil(el_count / scroller.vars.rows);
|
25
24
|
|
26
25
|
// Calculating scroller's width with regard to items per row
|
27
26
|
scroller.width( (el_width * per_row) - scroller.vars.elementMargin );
|
@@ -46,110 +45,103 @@
|
|
46
45
|
|
47
46
|
// Scroller methods
|
48
47
|
scroller.calculateVisibleElements = function() {
|
49
|
-
visible_els = Math.floor((wrapper.width() + scroller.vars.elementMargin) / el_width);
|
48
|
+
scroller.visible_els = Math.floor((wrapper.width() + scroller.vars.elementMargin) / el_width);
|
50
49
|
};
|
51
50
|
|
52
|
-
scroller.moveElements = function(
|
53
|
-
if(!scroller.animating) {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
if (
|
73
|
-
|
74
|
-
if (wrapper.current_page.next().size() > 0)
|
75
|
-
wrapper.current_page = wrapper.current_page.next();
|
76
|
-
}
|
77
|
-
else {
|
78
|
-
if (wrapper.current_page.prev().size() > 0)
|
79
|
-
wrapper.current_page = wrapper.current_page.prev();
|
80
|
-
}
|
81
|
-
} else {
|
82
|
-
wrapper.current_page = page_el;
|
83
|
-
}
|
84
|
-
wrapper.current_page.addClass('current-page');
|
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);
|
85
73
|
}
|
86
74
|
}
|
87
75
|
};
|
88
76
|
|
89
|
-
scroller.
|
77
|
+
scroller.initializePagination = function() {
|
90
78
|
// If there is the same number of visible elements we don't have to change anything
|
91
|
-
if (typeof
|
92
|
-
|
93
|
-
|
94
|
-
if (outer_wrapper.find('.radiant-pagination').size() > 0)
|
95
|
-
outer_wrapper.find('.radiant-pagination').remove();
|
96
|
-
|
97
|
-
var pagination = $('<div class="radiant-pagination" />').insertAfter(wrapper);
|
98
|
-
for (var i = 0; i < pages; i++) {
|
99
|
-
pagination.append('<div class="radiant-page" data-page="' + (i + 1) + '"></div>');
|
100
|
-
}
|
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);
|
101
82
|
|
102
|
-
if (typeof
|
83
|
+
if (typeof scroller.current_page === 'undefined') {
|
103
84
|
// If current page was not set previously, we set it now
|
104
|
-
|
85
|
+
scroller.current_page = 0;
|
105
86
|
} else {
|
106
|
-
|
107
|
-
wrapper.current_page = $(pagination.find('.radiant-page').get(new_current_page));
|
87
|
+
scroller.current_page = Math.ceil(wrapper.scrollLeft() / (scroller.visible_els * el_width));
|
108
88
|
}
|
109
|
-
|
89
|
+
|
90
|
+
if (scroller.vars.addPagination)
|
91
|
+
scroller.drawPagination();
|
92
|
+
}
|
93
|
+
};
|
94
|
+
|
95
|
+
scroller.drawPagination = function() {
|
96
|
+
if (outer_wrapper.find('.radiant-pagination').size() > 0)
|
97
|
+
outer_wrapper.find('.radiant-pagination').remove();
|
98
|
+
|
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 + '" />');
|
110
102
|
}
|
103
|
+
scroller.assignActivePage();
|
104
|
+
};
|
105
|
+
|
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');
|
111
110
|
};
|
112
111
|
|
113
112
|
// Binding events
|
114
113
|
$(window).bindWithDelay('resize', function() {
|
115
114
|
scroller.calculateVisibleElements();
|
116
|
-
|
117
|
-
scroller.createPagination();
|
118
|
-
}
|
115
|
+
scroller.initializePagination();
|
119
116
|
}, 500, true);
|
120
117
|
|
121
118
|
nav.on('click', '.radiant-next', function() {
|
122
|
-
scroller.moveElements(
|
119
|
+
scroller.moveElements(1);
|
123
120
|
});
|
124
121
|
|
125
122
|
nav.on('click', '.radiant-prev', function() {
|
126
|
-
scroller.moveElements(
|
123
|
+
scroller.moveElements(-1);
|
127
124
|
});
|
128
125
|
|
129
126
|
if (scroller.vars.useMouseWheel) {
|
130
127
|
wrapper.on('mousewheel', function(event) {
|
131
128
|
event.preventDefault();
|
132
|
-
|
133
|
-
scroller.moveElements('left'); }
|
129
|
+
scroller.moveElements(event.deltaY);
|
134
130
|
});
|
135
131
|
}
|
136
132
|
|
137
133
|
outer_wrapper.on('click', '.radiant-page', function() {
|
138
|
-
var
|
139
|
-
|
140
|
-
|
141
|
-
var
|
142
|
-
|
143
|
-
scroller.moveElements('left', current_page_number - this_page_number, $this);
|
144
|
-
} else { scroller.moveElements('right', this_page_number - current_page_number, $this); }
|
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);
|
145
139
|
}
|
146
140
|
});
|
147
141
|
|
148
142
|
// Init scroller
|
149
143
|
scroller.calculateVisibleElements();
|
150
|
-
|
151
|
-
scroller.createPagination();
|
152
|
-
}
|
144
|
+
scroller.initializePagination();
|
153
145
|
};
|
154
146
|
|
155
147
|
$.radiantScroller.defaults = {
|
@@ -165,7 +157,7 @@
|
|
165
157
|
prevButtonText: ''
|
166
158
|
};
|
167
159
|
|
168
|
-
$.fn.radiantScroller = function(options) {
|
160
|
+
$.fn.radiantScroller = function(options, options2) {
|
169
161
|
if (options === undefined) options = {};
|
170
162
|
|
171
163
|
if (typeof options === "object") {
|
@@ -173,8 +165,14 @@
|
|
173
165
|
} else {
|
174
166
|
var $scroller = $(this).data('radiantscroller');
|
175
167
|
switch (options) {
|
176
|
-
case "next": $scroller.moveElements(
|
177
|
-
case "prev": $scroller.moveElements(
|
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);
|
178
176
|
}
|
179
177
|
}
|
180
178
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-radiantscroller-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Bodrov
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project:
|
61
|
-
rubygems_version: 2.2.
|
61
|
+
rubygems_version: 2.2.1
|
62
62
|
signing_key:
|
63
63
|
specification_version: 4
|
64
64
|
summary: Includes javascript and css files for the Radiant Scroller plugin.
|