jquery-radiantscroller-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTJlMDJlOGY0YjkyZDRmMGQ3YjBiY2U4NTJmNDI1OGY3OTRhNjIwZg==
5
+ data.tar.gz: !binary |-
6
+ YTg5YjQ1NDMyZDAxNzRlYTU5MGM5ZGFlYTFiYmQzZDk2ODZjOTVlNA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NzZhYjYxMjgwMjAyZjNlNDNlNjMxMGMwNGIzZGM2ODI4YTAwNmM0NTMzOTUz
10
+ ZTVjYWY0N2M1ZmU4NmFlNGUxYzRlMmNjMjE2MTNkMDViYWQzZjVjMDlmNDhk
11
+ MDVmZTBmMzQ4OGUzYjE0ZDFkYWUzMjViMTczOTUxZmIyM2IxNTI=
12
+ data.tar.gz: !binary |-
13
+ MzAxZjY0NjRlN2I0YWMxZDk0MGE5YjYwMDJmZTRiNTVmMDk4MzYwOWQwOTM2
14
+ MTkyOThjYjU3MjAxZTdlZTFhOGI2ODRlNjg1Mzc5NTY5NGUxMWU5MmRhYmM0
15
+ N2M5ZTc1NGYzMzE0OTg2MWI3MWM0Mjc5MjhmZjc2ZGI4MWVjZjk=
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014, Ilya Bodrov (http://radiant-wind.com)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # RadiamtScroller plugin for Rails
2
+
3
+ A ruby gem that uses the Rails asset pipeline to include the Radiant Scroller plugin by Ilya Bodrov
4
+ (http://radiant-wind.com):
5
+
6
+ * Homepage: https://github.com/bodrovis/RadiantScroller
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'jquery-radiantscroller-rails'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install jquery-radiantscroller-rails
21
+
22
+ NOTE: this is a jQuery plugin so you will also need the `jquery-rails` gem:
23
+
24
+ * https://github.com/rails/jquery-rails
25
+
26
+ If you want to enable mousewheel support for Radiant Scroller, you can include jQuery MouseWheel plugin by Brandon Aaron
27
+ (https://github.com/brandonaaron/jquery-mousewheel/). There is a gem `jquery-mousewheel-rails` available:
28
+
29
+ * https://github.com/crazymykl/jquery-mousewheel-rails
30
+
31
+ ## Usage
32
+
33
+ In your `application.js` you will need to add this line:
34
+
35
+ //= require jquery.radiantscroller
36
+
37
+ And in your `application.css` you will need to add this line:
38
+
39
+ *= require jquery.radiantscroller
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
48
+
49
+ ## License
50
+
51
+ This plugin is licensed under the [MIT License](https://github.com/bodrovis/jquery-radiantscroller-rails/blob/master/LICENSE.txt).
52
+
53
+ Copyright (c) 2014 [Ilya Bodrov](http://radiant-wind.com)
@@ -0,0 +1,8 @@
1
+ require "jquery-radiantscroller-rails/version"
2
+
3
+ module RadiantScroller
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module RadiantScroller
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,240 @@
1
+ /*!
2
+ * jQuery RadiantScroller
3
+ * Version: 0.0.1 (07/01/2014)
4
+ * Copyright (c) 2013 Ilya Bodrov (http://radiant-wind.com)
5
+ *
6
+ * Requires: jQuery 1.7.0+
7
+ */
8
+
9
+ (function($) {
10
+ $.radiantScroller = function(el, options) {
11
+ var scroller = $(el);
12
+
13
+ scroller.vars = $.extend({}, $.radiantScroller.defaults, options);
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;
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),
24
+ visible_els = 0;
25
+
26
+ // Calculating scroller's width with regard to items per row
27
+ scroller.width( (el_width * per_row) - scroller.vars.elementMargin );
28
+
29
+ // Grouping elements by rows
30
+ do $(elements.slice(0, per_row)).wrapAll('<div class="radiant_scroller_row" />');
31
+ while((elements = elements.slice(per_row)).length > 0);
32
+
33
+ // Wrapper with hidden scrollbars
34
+ scroller.wrap('<div class="radiant_scroller"></div>').wrap('<div class="radiant_scroller_wrapper" />');
35
+ var wrapper = scroller.parent('.radiant_scroller_wrapper');
36
+ var outer_wrapper = wrapper.parent('.radiant_scroller');
37
+
38
+ var max_wrapper_width = (scroller.vars.cols * el_width - scroller.vars.elementMargin) + 'px';
39
+ wrapper.css('max-width', max_wrapper_width);
40
+ outer_wrapper.css('max-width', max_wrapper_width);
41
+
42
+ // Next/previous buttons
43
+ var nav = $('<div class="radiant-navigation" />').insertAfter(wrapper);
44
+ var prev = nav.append($('<div class="radiant-prev">' + scroller.vars.prevButtonText + '</div>'));
45
+ var next = nav.append($('<div class="radiant-next">' + scroller.vars.nextButtonText + '</div>'));
46
+
47
+ // Scroller methods
48
+ scroller.calculateVisibleElements = function() {
49
+ visible_els = Math.floor((wrapper.width() + scroller.vars.elementMargin) / el_width);
50
+ };
51
+
52
+ scroller.moveElements = function(direction, scrollBy, page_el) {
53
+ if(!scroller.animating) {
54
+ scroller.animating = true;
55
+ var distance = 0;
56
+ if (typeof scrollBy === 'undefined') {
57
+ distance = visible_els * el_width;
58
+ } else { distance = visible_els * el_width * scrollBy; }
59
+
60
+ var fraction = 0;
61
+ if (direction === 'left') { fraction = -distance ;
62
+ } else { fraction = distance; }
63
+
64
+ wrapper.animate(
65
+ { scrollLeft: wrapper.scrollLeft() + fraction },
66
+ scroller.vars.animateDuration, scroller.vars.easingType,
67
+ function() { scroller.animating = false; }
68
+ );
69
+
70
+ if (scroller.vars.addPagination) {
71
+ wrapper.current_page.removeClass('current-page');
72
+ if (typeof page_el === 'undefined') {
73
+ if (direction === 'right') {
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');
85
+ }
86
+ }
87
+ };
88
+
89
+ scroller.createPagination = function() {
90
+ // If there is the same number of visible elements we don't have to change anything
91
+ if (typeof this.visible_els === 'undefined' || this.visible_els !== visible_els) {
92
+ this.visible_els = visible_els;
93
+ var pages = Math.ceil(per_row / visible_els);
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
+ }
101
+
102
+ if (typeof wrapper.current_page === 'undefined') {
103
+ // If current page was not set previously, we set it now
104
+ wrapper.current_page = pagination.find('.radiant-page').first();
105
+ } else {
106
+ var new_current_page = Math.ceil(wrapper.scrollLeft() / (visible_els * el_width));
107
+ wrapper.current_page = $(pagination.find('.radiant-page').get(new_current_page));
108
+ }
109
+ wrapper.current_page.addClass('current-page');
110
+ }
111
+ };
112
+
113
+ // Binding events
114
+ $(window).bindWithDelay('resize', function() {
115
+ scroller.calculateVisibleElements();
116
+ if (scroller.vars.addPagination) {
117
+ scroller.createPagination();
118
+ }
119
+ }, 500, true);
120
+
121
+ nav.on('click', '.radiant-next', function() {
122
+ scroller.moveElements('right', 1);
123
+ });
124
+
125
+ nav.on('click', '.radiant-prev', function() {
126
+ scroller.moveElements('left', 1);
127
+ });
128
+
129
+ if (scroller.vars.useMouseWheel) {
130
+ wrapper.on('mousewheel', function(event) {
131
+ event.preventDefault();
132
+ if (event.deltaY > 0) { scroller.moveElements('right'); } else {
133
+ scroller.moveElements('left'); }
134
+ });
135
+ }
136
+
137
+ outer_wrapper.on('click', '.radiant-page', function() {
138
+ var $this = $(this);
139
+ if (wrapper.current_page.get(0) !== $this.get(0)) {
140
+ var current_page_number = wrapper.current_page.data('page');
141
+ var this_page_number = $this.data('page');
142
+ if (current_page_number > this_page_number) {
143
+ scroller.moveElements('left', current_page_number - this_page_number, $this);
144
+ } else { scroller.moveElements('right', this_page_number - current_page_number, $this); }
145
+ }
146
+ });
147
+
148
+ // Init scroller
149
+ scroller.calculateVisibleElements();
150
+ if (scroller.vars.addPagination) {
151
+ scroller.createPagination();
152
+ }
153
+ };
154
+
155
+ $.radiantScroller.defaults = {
156
+ cols: 2,
157
+ elementWidth: 200,
158
+ elementMargin: 10,
159
+ easingType: 'swing',
160
+ animateDuration: 700,
161
+ rows: 2,
162
+ useMouseWheel: false,
163
+ addPagination: false,
164
+ nextButtonText: '',
165
+ prevButtonText: ''
166
+ };
167
+
168
+ $.fn.radiantScroller = function(options) {
169
+ if (options === undefined) options = {};
170
+
171
+ if (typeof options === "object") {
172
+ new $.radiantScroller(this, options);
173
+ } else {
174
+ var $scroller = $(this).data('radiantscroller');
175
+ switch (options) {
176
+ case "next": $scroller.moveElements('right'); break;
177
+ case "prev": $scroller.moveElements('left'); break;
178
+ }
179
+ }
180
+
181
+ return this;
182
+ };
183
+ })(jQuery);
184
+
185
+ /*
186
+ bindWithDelay jQuery plugin
187
+ Author: Brian Grinstead
188
+ MIT license: http://www.opensource.org/licenses/mit-license.php
189
+
190
+ http://github.com/bgrins/bindWithDelay
191
+ http://briangrinstead.com/files/bindWithDelay
192
+
193
+ Usage:
194
+ See http://api.jquery.com/bind/
195
+ .bindWithDelay( eventType, [ eventData ], handler(eventObject), timeout, throttle )
196
+
197
+ Examples:
198
+ $("#foo").bindWithDelay("click", function(e) { }, 100);
199
+ $(window).bindWithDelay("resize", { optional: "eventData" }, callback, 1000);
200
+ $(window).bindWithDelay("resize", callback, 1000, true);
201
+ */
202
+
203
+ (function($) {
204
+
205
+ $.fn.bindWithDelay = function( type, data, fn, timeout, throttle ) {
206
+
207
+ if ( $.isFunction( data ) ) {
208
+ throttle = timeout;
209
+ timeout = fn;
210
+ fn = data;
211
+ data = undefined;
212
+ }
213
+
214
+ // Allow delayed function to be removed with fn in unbind function
215
+ fn.guid = fn.guid || ($.guid && $.guid++);
216
+
217
+ // Bind each separately so that each element has its own delay
218
+ return this.each(function() {
219
+
220
+ var wait = null;
221
+
222
+ function cb() {
223
+ var e = $.extend(true, { }, arguments[0]);
224
+ var ctx = this;
225
+ var throttler = function() {
226
+ wait = null;
227
+ fn.apply(ctx, [e]);
228
+ };
229
+
230
+ if (!throttle) { clearTimeout(wait); wait = null; }
231
+ if (!wait) { wait = setTimeout(throttler, timeout); }
232
+ }
233
+
234
+ cb.guid = fn.guid;
235
+
236
+ $(this).bind(type, data, cb);
237
+ });
238
+ };
239
+
240
+ })(jQuery);
@@ -0,0 +1,48 @@
1
+ /*!
2
+ * jQuery RadiantScroller
3
+ * Version: 0.0.1 (07/01/2014)
4
+ * Copyright (c) 2013 Ilya Bodrov (http://radiant-wind.com)
5
+ */
6
+
7
+ /* ======== Scroller and elements ======== */
8
+ .radiant_scroller {
9
+ position: relative;
10
+ }
11
+
12
+ .radiant_scroller_wrapper {
13
+ overflow: hidden;
14
+ }
15
+
16
+ .radiant_scroller_wrapper .scroller-el {
17
+ display: block;
18
+ float: left;
19
+ }
20
+
21
+ .radiant_scroller .radiant_scroller_row .scroller-el:last-of-type {
22
+ margin-right: 0;
23
+ }
24
+
25
+ .radiant_scroller .radiant_scroller_row:last-of-type .scroller-el {
26
+ margin-bottom: 0;
27
+ }
28
+
29
+ /* ======== Navigatonal buttons (previous/next) ======== */
30
+ .radiant_scroller .radiant-navigation {
31
+ clear: both;
32
+ }
33
+
34
+ .radiant_scroller .radiant-next, .radiant_scroller .radiant-prev {
35
+ position: absolute;
36
+ cursor: pointer;
37
+ }
38
+
39
+ /* ======== Pagination ======== */
40
+ .radiant_scroller .radiant-pagination .radiant-page {
41
+ display: inline-block;
42
+ margin-right: 10px;
43
+ cursor: pointer;
44
+ }
45
+
46
+ .radiant_scroller .radiant-pagination .radiant-page:last-of-type {
47
+ margin-right: 0;
48
+ }
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquery-radiantscroller-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ilya Bodrov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ description: ! "A ruby gem that uses the Rails asset pipeline to include the Radiant
28
+ Scroller plugin by Ilya Bodrov\n (http://radiant-wind.com)."
29
+ email:
30
+ - golosizpru@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE.txt
36
+ - README.md
37
+ - lib/jquery-radiantscroller-rails.rb
38
+ - lib/jquery-radiantscroller-rails/version.rb
39
+ - vendor/assets/javascripts/jquery.radiantscroller.js
40
+ - vendor/assets/stylesheets/jquery.radiantscroller.css
41
+ homepage: https://github.com/bodrovis/jquery-radiantscroller-rails
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.2.0
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Includes javascript and css files for the Radiant Scroller plugin.
65
+ test_files: []