jquery-radiantscroller-rails 0.0.5 → 0.1.0

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: ffce4f5a48353afbbfdab1ca1bef4aecf3d6dcb6
4
- data.tar.gz: 870598a436c4c9e3bd6d17fa2604c0711f16f1eb
3
+ metadata.gz: cba69ee23600efbf2776301f5fdd93fed5b36dd0
4
+ data.tar.gz: 11e3b14fcd9ea5a44ce16025af7c73874c922a15
5
5
  SHA512:
6
- metadata.gz: 514f254964e76dee7a8c3ea770a2ef277ba0361a8baf86732419cba44ef4f91ef8b0906c846bc6ad15f267bfd0b37c686ffc1addc33bb2e8d39dae32b062a6aa
7
- data.tar.gz: 569ba7661c06423b6e81c1207f7fa2f3c3c7138d8df01ac9963b0612112b2bff7428fc6f155ed4c1809a5af3fce3fd8d5eefbbd8d29c9ef0a21f5765d69614c2
6
+ metadata.gz: 0de50b4ae63e82fe319f25cb5fbdd1dc7e6dcaa80e5a64256ccd7f16e6a2e037a73e4497af0a4efce9cce331496b1f78ebedc59d7c0566a7ca848e39fc87c083
7
+ data.tar.gz: 40b0ef01be59b1fe0c70116ddc4e960049163346df9f584e30f50cf1332feb2d3c88497d32981acb1dfc9b3e87cca1b671bf8397263f0283cf56539be9c40dab
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # RadiamtScroller plugin for Rails
1
+ # RadiantScroller plugin for Rails
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/jquery-radiantscroller-rails.png)](http://badge.fury.io/rb/jquery-radiantscroller-rails)
4
4
 
@@ -1,5 +1,5 @@
1
1
  module RadiantScroller
2
2
  module Rails
3
- VERSION = "0.0.5"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * jQuery RadiantScroller
3
- * Version: 0.0.5 (28/07/2014)
3
+ * Version: 0.1.0 (29/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+
@@ -26,8 +26,9 @@
26
26
  scroller.width( (el_width * per_row) - scroller.vars.elementMargin );
27
27
 
28
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);
29
+ var elements_tmp = elements;
30
+ do $(elements_tmp.slice(0, per_row)).wrapAll('<div class="radiant_scroller_row" />');
31
+ while((elements_tmp = elements_tmp.slice(per_row)).length > 0);
31
32
 
32
33
  // Wrapper with hidden scrollbars
33
34
  scroller.wrap('<div class="radiant_scroller"></div>').wrap('<div class="radiant_scroller_wrapper" />');
@@ -64,6 +65,9 @@
64
65
  new_current_page !== scroller.current_page) {
65
66
  scroller.animating = true;
66
67
 
68
+ if (duration !== 0)
69
+ scroller.vars.beforeMove(scroller); // Callback telling moving animation is started
70
+
67
71
  wrapper.animate(
68
72
  { scrollLeft: wrapper.scrollLeft() + scroller.visible_els * el_width * scrollBy },
69
73
  duration, scroller.vars.easingType,
@@ -74,6 +78,15 @@
74
78
 
75
79
  if (scroller.vars.addPagination)
76
80
  scroller.assignActivePage(true);
81
+
82
+ if (duration !== 0) {
83
+ // Callback telling moving animation is finished
84
+ scroller.vars.afterMove(scroller);
85
+
86
+ if (new_current_page + 1 === scroller.total_pages)
87
+ // Callback telling moving animation is finished
88
+ scroller.vars.lastPageReached(scroller);
89
+ }
77
90
  }
78
91
  }
79
92
  };
@@ -113,6 +126,42 @@
113
126
  $(outer_wrapper.find('.radiant-page').get(scroller.current_page)).addClass('current-page');
114
127
  };
115
128
 
129
+ // Captions are added by assigning `title` attribute to imgs like
130
+ // <img src="test.jpg" title="My caption" />
131
+ scroller.addCaptions = function() {
132
+ var child_img, child_img_title;
133
+
134
+ elements.each(function() {
135
+ child_img = $(this).find('img');
136
+ child_img_title = $.trim(child_img.attr('title'));
137
+
138
+ if (typeof child_img_title !== 'undefined' && child_img_title !== '') {
139
+ child_img.attr('title', '');
140
+ $(this).append('<div class="radiant-caption">' +
141
+ child_img_title + '</div>');
142
+ }
143
+ });
144
+
145
+ var slide_animation_opts = {
146
+ duration: scroller.vars.captionsAnimateDuration,
147
+ easing: scroller.vars.captionsAnimateEasingType
148
+ };
149
+
150
+ scroller.on('mouseenter', '.scroller-el', function() {
151
+ var caption = $(this).find('.radiant-caption');
152
+ if (caption.size() > 0 && !caption.is(':visible')) {
153
+ caption.slideDown(slide_animation_opts, scroller.vars.afterShowingCaption(caption));
154
+ }
155
+ });
156
+
157
+ scroller.on('mouseleave', '.scroller-el', function() {
158
+ var caption = $(this).find('.radiant-caption');
159
+ if (caption.size() > 0 && caption.is(':visible')) {
160
+ caption.slideUp(slide_animation_opts, scroller.vars.afterHidingCaption(caption));
161
+ }
162
+ });
163
+ };
164
+
116
165
  // Binding events
117
166
  $(window).bindWithDelay('resize', function() {
118
167
  scroller.calculateVisibleElements();
@@ -148,11 +197,18 @@
148
197
  // Init scroller
149
198
  scroller.calculateVisibleElements();
150
199
  scroller.initializePagination();
200
+ if (scroller.vars.useCaptions) {
201
+ scroller.addCaptions();
202
+ }
203
+
204
+ scroller.vars.loaded(scroller); // Fire callback telling the scroller is loaded
151
205
  };
152
206
 
153
207
  $.radiantScroller.defaults = {
154
208
  addPagination: false,
155
209
  animateDuration: 700,
210
+ captionsAnimateDuration: 400,
211
+ captionsAnimateEasingType: 'swing',
156
212
  cols: 2,
157
213
  delayDuration: 500,
158
214
  easingType: 'swing',
@@ -161,7 +217,15 @@
161
217
  nextButtonText: '',
162
218
  prevButtonText: '',
163
219
  rows: 2,
164
- useMouseWheel: false
220
+ useCaptions: false,
221
+ useMouseWheel: false,
222
+ // Callbacks
223
+ loaded: function() {}, // Called when the scroller is loaded and ready
224
+ beforeMove: function() {}, // Called before each scroller moving animation
225
+ afterMove: function() {}, // Called after each scroller moving animation is finished
226
+ lastPageReached: function() {}, // Called when the last page of the scroller is reached
227
+ afterHidingCaption: function() {}, // Called after the caption was hidden
228
+ afterShowingCaption: function() {} // Called after the caption was showed
165
229
  };
166
230
 
167
231
  $.fn.radiantScroller = function(options, options2) {
@@ -1,48 +1,62 @@
1
1
  /*!
2
2
  * jQuery RadiantScroller
3
- * Version: 0.0.5 (28/07/2014)
3
+ * Version: 0.1.0 (29/07/2014)
4
4
  * Copyright (c) 2014 Ilya Bodrov (http://www.radiant-wind.com/plugins/radiant_scroller)
5
5
  */
6
6
 
7
7
  /* ======== Scroller and elements ======== */
8
8
  .radiant_scroller {
9
- position: relative;
9
+ position: relative;
10
10
  }
11
11
 
12
12
  .radiant_scroller_wrapper {
13
- overflow: hidden;
13
+ overflow: hidden;
14
14
  }
15
15
 
16
16
  .radiant_scroller_wrapper .scroller-el {
17
- display: block;
18
- float: left;
17
+ display: block;
18
+ float: left;
19
+ position: relative;
19
20
  }
20
21
 
21
22
  .radiant_scroller .radiant_scroller_row .scroller-el:last-of-type {
22
- margin-right: 0;
23
+ margin-right: 0;
23
24
  }
24
25
 
25
26
  .radiant_scroller .radiant_scroller_row:last-of-type .scroller-el {
26
- margin-bottom: 0;
27
+ margin-bottom: 0;
27
28
  }
28
29
 
29
30
  /* ======== Navigatonal buttons (previous/next) ======== */
30
31
  .radiant_scroller .radiant-navigation {
31
- clear: both;
32
+ clear: both;
32
33
  }
33
34
 
34
35
  .radiant_scroller .radiant-next, .radiant_scroller .radiant-prev {
35
- position: absolute;
36
- cursor: pointer;
36
+ position: absolute;
37
+ cursor: pointer;
37
38
  }
38
39
 
39
40
  /* ======== Pagination ======== */
40
41
  .radiant_scroller .radiant-pagination .radiant-page {
41
- display: inline-block;
42
- margin-right: 10px;
43
- cursor: pointer;
42
+ display: inline-block;
43
+ margin-right: 10px;
44
+ cursor: pointer;
44
45
  }
45
46
 
46
47
  .radiant_scroller .radiant-pagination .radiant-page:last-of-type {
47
- margin-right: 0;
48
+ margin-right: 0;
49
+ }
50
+
51
+ /* ======== Captions ======== */
52
+ .radiant_scroller .radiant-caption {
53
+ position: absolute;
54
+ bottom: 0;
55
+ text-align: center;
56
+ color: #fff;
57
+ width: 100%;
58
+ padding-top: 5px;
59
+ padding-bottom: 5px;
60
+ display: none;
61
+ background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABVJREFUeNpiYWBgaABiBiYGKAAIMAAHbACHQpFYbQAAAABJRU5ErkJggg==') repeat;
48
62
  }
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.5
4
+ version: 0.1.0
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-28 00:00:00.000000000 Z
11
+ date: 2014-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties