rails-gallery 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -11,6 +11,7 @@ Popular Javascript Photo galleries/carousels ready to use with Rails 3+.
11
11
  * slideshow
12
12
  * responsive
13
13
  * galleria
14
+ * touch_touch
14
15
 
15
16
  Please add more using a similar convention as is used for these galleries ;)
16
17
 
@@ -25,16 +26,18 @@ In `application.css` manifest file:
25
26
  * require gallery/responsive/style
26
27
  * require gallery/slideshow
27
28
  * require gallery/galleria
29
+ * require gallery/touch_touch
28
30
  */
29
31
  ```
30
32
 
31
- Using Compass, f.ex in `application.css.scss.erb`
33
+ Using Compass, f.ex in `application.css.scss`
32
34
 
33
35
  ```
34
36
  @import 'gallery/responsive/elastislide';
35
- @import 'gallery/responsive/style';
37
+ @import 'gallery/responsive';
36
38
  @import 'gallery/slideshow';
37
39
  @import 'gallery/galleria';
40
+ @import 'gallery/touch_touch';
38
41
  ```
39
42
 
40
43
  In `application.js` manifest file:
@@ -43,12 +46,26 @@ In `application.js` manifest file:
43
46
  //= require gallery/responsive
44
47
  //= require gallery/slideshow
45
48
  //= require gallery/galleria
49
+ //= require gallery/touch_touch
46
50
 
47
- //= require jquery.easing-1.3
48
- //= require jquery.elastislide
49
- //= require jquery.tmpl.min
51
+ //= require jquery/jquery.easing-1.3
52
+ //= require jquery/jquery.elastislide
53
+ //= require jquery/jquery.tmpl.min
50
54
  ```
51
55
 
56
+ ## Touch-Touch
57
+
58
+ ```javascript
59
+ $(function(){
60
+
61
+ // Initialize the gallery
62
+ $('#thumbs a').touchTouch();
63
+
64
+ });
65
+ ```
66
+
67
+ See [TouchTouch](http://tutorialzine.com/2012/04/mobile-touch-gallery/) and [github repo](https://github.com/martinaglv/touchTouch)
68
+
52
69
  ## Minimalistic Slideshow gallery
53
70
 
54
71
  See [minimalistic-slideshow-gallery](http://tympanus.net/codrops/2010/07/05/minimalistic-slideshow-gallery/) for more info.
@@ -95,15 +112,40 @@ To adjust placement of thumbnails, use: `prependTo` or `appendTo` in `gallery/re
95
112
  *Automatic slideshow*
96
113
 
97
114
  I wanted the same thing and I find a way to do it.
98
- In the file gallery.js, in the function _initCarousel add these lines after `$esCarousel.elastislide( ‘setCurrent’, current );` (~ line 103):
115
+ In the file gallery.js, in the function _initCarousel add these lines after:
116
+
117
+ `$esCarousel.elastislide( 'setCurrent', current );`
99
118
 
100
119
  ```javascript
101
120
  window.setInterval(function(){
102
- _navigate( right );
121
+ _navigate( 'right' );
103
122
  }, 5000);
104
123
  ```
105
124
 
106
- You just have to change 5000 to the value you want (milliseconds).
125
+ You just have to change `5000` to the value you want (milliseconds).
126
+
127
+ * Fancybox integration*
128
+
129
+ First you have to include the js and the css file of fancybox in the file where you have the carousel.
130
+
131
+ In the file `responsive.js`, replace this line:
132
+
133
+ `$rgGallery.find('div.rg-image').empty().append('img src="' + largesrc + '"');`
134
+
135
+ With this (which adds 'fancybox' class to all images):
136
+
137
+ `$rgGallery.find('div.rg-image').empty().append('a class="fancybox"
138
+ href="'+largesrc+ '" img src="' + largesrc + '" a');`
139
+
140
+ In this line, don’t forget to add the `"` for the img and link tags.
141
+
142
+ Then do the fancybox magic on any class with the `fancybox` class
143
+
144
+ ```javascript
145
+ $(document).ready(function() {
146
+ $(“.fancybox”).fancybox();
147
+ });
148
+ ```
107
149
 
108
150
  ## Galleria
109
151
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rails-gallery"
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = "2012-08-22"
12
+ s.date = "2012-08-26"
13
13
  s.description = "Adds popular javascript galleries to asset pipeline and includes a few Rails Gallery utils and helpers"
14
14
  s.email = "kmandrup@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -170,19 +170,23 @@ Gem::Specification.new do |s|
170
170
  "vendor/assets/images/gallery/slideshow/icons/prev.png",
171
171
  "vendor/assets/images/gallery/slideshow/icons/prev_thumb.png",
172
172
  "vendor/assets/images/gallery/slideshow/icons/up.png",
173
+ "vendor/assets/images/gallery/touch_touch/arrows.png",
174
+ "vendor/assets/images/gallery/touch_touch/preloader.gif",
173
175
  "vendor/assets/javascripts/gallery/galleria-1.2.8.js",
174
176
  "vendor/assets/javascripts/gallery/galleria-1.2.8.min.js",
175
177
  "vendor/assets/javascripts/gallery/galleria/classic.js",
176
178
  "vendor/assets/javascripts/gallery/galleria/classic.min.js",
177
179
  "vendor/assets/javascripts/gallery/responsive.js",
178
180
  "vendor/assets/javascripts/gallery/slideshow.js",
181
+ "vendor/assets/javascripts/gallery/touch_touch.js",
179
182
  "vendor/assets/javascripts/jquery/jquery.easing-1.3.js",
180
183
  "vendor/assets/javascripts/jquery/jquery.elastislide.js",
181
184
  "vendor/assets/javascripts/jquery/jquery.tmpl.min.js",
182
185
  "vendor/assets/stylesheets/gallery/galleria/classic.css",
183
186
  "vendor/assets/stylesheets/gallery/responsive.css",
184
187
  "vendor/assets/stylesheets/gallery/responsive/elastislide.css",
185
- "vendor/assets/stylesheets/gallery/slideshow.css"
188
+ "vendor/assets/stylesheets/gallery/slideshow.css",
189
+ "vendor/assets/stylesheets/touch_touch.css"
186
190
  ]
187
191
  s.homepage = "http://github.com/kristianmandrup/rails-gallery"
188
192
  s.licenses = ["MIT"]
@@ -0,0 +1,235 @@
1
+ /**
2
+ * @name jQuery touchTouch plugin
3
+ * @author Martin Angelov
4
+ * @version 1.0
5
+ * @url http://tutorialzine.com/2012/04/mobile-touch-gallery/
6
+ * @license MIT License
7
+ */
8
+
9
+ (function(){
10
+
11
+ /* Private variables */
12
+
13
+ var overlay = $('<div id="galleryOverlay">'),
14
+ slider = $('<div id="gallerySlider">'),
15
+ prevArrow = $('<a id="prevArrow"></a>'),
16
+ nextArrow = $('<a id="nextArrow"></a>'),
17
+ overlayVisible = false;
18
+
19
+
20
+ /* Creating the plugin */
21
+
22
+ $.fn.touchTouch = function(){
23
+
24
+ var placeholders = $([]),
25
+ index = 0,
26
+ items = this;
27
+
28
+ // Appending the markup to the page
29
+ overlay.hide().appendTo('body');
30
+ slider.appendTo(overlay);
31
+
32
+ // Creating a placeholder for each image
33
+ items.each(function(){
34
+ placeholders = placeholders.add($('<div class="placeholder">'));
35
+ });
36
+
37
+ // Hide the gallery if the background is touched / clicked
38
+ slider.append(placeholders).on('click',function(e){
39
+ if(!$(e.target).is('img')){
40
+ hideOverlay();
41
+ }
42
+ });
43
+
44
+ // Listen for touch events on the body and check if they
45
+ // originated in #gallerySlider img - the images in the slider.
46
+ $('body').on('touchstart', '#gallerySlider img', function(e){
47
+
48
+ var touch = e.originalEvent,
49
+ startX = touch.changedTouches[0].pageX;
50
+
51
+ slider.on('touchmove',function(e){
52
+
53
+ e.preventDefault();
54
+
55
+ touch = e.originalEvent.touches[0] ||
56
+ e.originalEvent.changedTouches[0];
57
+
58
+ if(touch.pageX - startX > 10){
59
+ slider.off('touchmove');
60
+ showPrevious();
61
+ }
62
+ else if (touch.pageX - startX < -10){
63
+ slider.off('touchmove');
64
+ showNext();
65
+ }
66
+ });
67
+
68
+ // Return false to prevent image
69
+ // highlighting on Android
70
+ return false;
71
+
72
+ }).on('touchend',function(){
73
+ slider.off('touchmove');
74
+ });
75
+
76
+ // Listening for clicks on the thumbnails
77
+
78
+ items.on('click', function(e){
79
+ e.preventDefault();
80
+
81
+ // Find the position of this image
82
+ // in the collection
83
+
84
+ index = items.index(this);
85
+ showOverlay(index);
86
+ showImage(index);
87
+
88
+ // Preload the next image
89
+ preload(index+1);
90
+
91
+ // Preload the previous
92
+ preload(index-1);
93
+
94
+ });
95
+
96
+ // If the browser does not have support
97
+ // for touch, display the arrows
98
+ if ( !("ontouchstart" in window) ){
99
+ overlay.append(prevArrow).append(nextArrow);
100
+
101
+ prevArrow.click(function(e){
102
+ e.preventDefault();
103
+ showPrevious();
104
+ });
105
+
106
+ nextArrow.click(function(e){
107
+ e.preventDefault();
108
+ showNext();
109
+ });
110
+ }
111
+
112
+ // Listen for arrow keys
113
+ $(window).bind('keydown', function(e){
114
+
115
+ if (e.keyCode == 37){
116
+ showPrevious();
117
+ }
118
+ else if (e.keyCode==39){
119
+ showNext();
120
+ }
121
+
122
+ });
123
+
124
+
125
+ /* Private functions */
126
+
127
+
128
+ function showOverlay(index){
129
+
130
+ // If the overlay is already shown, exit
131
+ if (overlayVisible){
132
+ return false;
133
+ }
134
+
135
+ // Show the overlay
136
+ overlay.show();
137
+
138
+ setTimeout(function(){
139
+ // Trigger the opacity CSS transition
140
+ overlay.addClass('visible');
141
+ }, 100);
142
+
143
+ // Move the slider to the correct image
144
+ offsetSlider(index);
145
+
146
+ // Raise the visible flag
147
+ overlayVisible = true;
148
+ }
149
+
150
+ function hideOverlay(){
151
+ // If the overlay is not shown, exit
152
+ if(!overlayVisible){
153
+ return false;
154
+ }
155
+
156
+ // Hide the overlay
157
+ overlay.hide().removeClass('visible');
158
+ overlayVisible = false;
159
+ }
160
+
161
+ function offsetSlider(index){
162
+ // This will trigger a smooth css transition
163
+ slider.css('left',(-index*100)+'%');
164
+ }
165
+
166
+ // Preload an image by its index in the items array
167
+ function preload(index){
168
+ setTimeout(function(){
169
+ showImage(index);
170
+ }, 1000);
171
+ }
172
+
173
+ // Show image in the slider
174
+ function showImage(index){
175
+
176
+ // If the index is outside the bonds of the array
177
+ if(index < 0 || index >= items.length){
178
+ return false;
179
+ }
180
+
181
+ // Call the load function with the href attribute of the item
182
+ loadImage(items.eq(index).attr('href'), function(){
183
+ placeholders.eq(index).html(this);
184
+ });
185
+ }
186
+
187
+ // Load the image and execute a callback function.
188
+ // Returns a jQuery object
189
+
190
+ function loadImage(src, callback){
191
+ var img = $('<img>').on('load', function(){
192
+ callback.call(img);
193
+ });
194
+
195
+ img.attr('src',src);
196
+ }
197
+
198
+ function showNext(){
199
+
200
+ // If this is not the last image
201
+ if(index+1 < items.length){
202
+ index++;
203
+ offsetSlider(index);
204
+ preload(index+1);
205
+ }
206
+ else{
207
+ // Trigger the spring animation
208
+
209
+ slider.addClass('rightSpring');
210
+ setTimeout(function(){
211
+ slider.removeClass('rightSpring');
212
+ },500);
213
+ }
214
+ }
215
+
216
+ function showPrevious(){
217
+
218
+ // If this is not the first image
219
+ if(index>0){
220
+ index--;
221
+ offsetSlider(index);
222
+ preload(index-1);
223
+ }
224
+ else{
225
+ // Trigger the spring animation
226
+
227
+ slider.addClass('leftSpring');
228
+ setTimeout(function(){
229
+ slider.removeClass('leftSpring');
230
+ },500);
231
+ }
232
+ }
233
+ };
234
+
235
+ })(jQuery);
@@ -0,0 +1,185 @@
1
+ /*----------------------------
2
+ Thumbnails
3
+ -----------------------------*/
4
+
5
+ #thumbs{
6
+ width:480px;
7
+ margin:60px auto 35px;
8
+ text-align:center;
9
+ }
10
+
11
+ #thumbs a{
12
+ width:120px;
13
+ height:120px;
14
+ display:inline-block;
15
+ border:7px solid #303030;
16
+ box-shadow:0 1px 3px rgba(0,0,0,0.5);
17
+ border-radius:4px;
18
+ margin: 6px 6px 40px;
19
+ position:relative;
20
+ text-decoration:none;
21
+
22
+ background-position:center center;
23
+ background-repeat: no-repeat;
24
+
25
+ background-size:cover;
26
+ -moz-background-size:cover;
27
+ -webkit-background-size:cover;
28
+ }
29
+
30
+ #thumbs a:after{
31
+ background-color: #303030;
32
+ border-radius: 7px;
33
+ bottom: -136px;
34
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
35
+ color: #FFFFFF;
36
+ content: attr(title);
37
+ display: inline-block;
38
+ font-size: 10px;
39
+ max-width: 90px;
40
+ overflow: hidden;
41
+ padding: 2px 10px;
42
+ position: relative;
43
+ text-align: center;
44
+ white-space: nowrap;
45
+ }
46
+
47
+ /* The gallery overlay */
48
+
49
+ #galleryOverlay{
50
+ width:100%;
51
+ height:100%;
52
+ position:fixed;
53
+ top:0;
54
+ left:0;
55
+ opacity:0;
56
+ z-index:100000;
57
+ background-color:#222;
58
+ background-color:rgba(0,0,0,0.8);
59
+ overflow:hidden;
60
+ display:none;
61
+
62
+ -moz-transition:opacity 1s ease;
63
+ -webkit-transition:opacity 1s ease;
64
+ transition:opacity 1s ease;
65
+ }
66
+
67
+ /* This class will trigger the animation */
68
+
69
+ #galleryOverlay.visible{
70
+ opacity:1;
71
+ }
72
+
73
+ #gallerySlider{
74
+ height:100%;
75
+
76
+ left:0;
77
+ top:0;
78
+
79
+ width:100%;
80
+ white-space: nowrap;
81
+ position:absolute;
82
+
83
+ -moz-transition:left 0.4s ease;
84
+ -webkit-transition:left 0.4s ease;
85
+ transition:left 0.4s ease;
86
+ }
87
+
88
+ #gallerySlider .placeholder{
89
+ background: url(/assets/gallery/touch_touch/preloader.gif) no-repeat center center;
90
+ height: 100%;
91
+ line-height: 1px;
92
+ text-align: center;
93
+ width:100%;
94
+ display:inline-block;
95
+ }
96
+
97
+ /* The before element moves the
98
+ * image halfway from the top */
99
+
100
+ #gallerySlider .placeholder:before{
101
+ content: "";
102
+ display: inline-block;
103
+ height: 50%;
104
+ width: 1px;
105
+ margin-right:-1px;
106
+ }
107
+
108
+ #gallerySlider .placeholder img{
109
+ display: inline-block;
110
+ max-height: 100%;
111
+ max-width: 100%;
112
+ vertical-align: middle;
113
+ }
114
+
115
+ #gallerySlider.rightSpring{
116
+ -moz-animation: rightSpring 0.3s;
117
+ -webkit-animation: rightSpring 0.3s;
118
+ }
119
+
120
+ #gallerySlider.leftSpring{
121
+ -moz-animation: leftSpring 0.3s;
122
+ -webkit-animation: leftSpring 0.3s;
123
+ }
124
+
125
+ /* Firefox Keyframe Animations */
126
+
127
+ @-moz-keyframes rightSpring{
128
+ 0%{ margin-left:0px;}
129
+ 50%{ margin-left:-30px;}
130
+ 100%{ margin-left:0px;}
131
+ }
132
+
133
+ @-moz-keyframes leftSpring{
134
+ 0%{ margin-left:0px;}
135
+ 50%{ margin-left:30px;}
136
+ 100%{ margin-left:0px;}
137
+ }
138
+
139
+ /* Safari and Chrome Keyframe Animations */
140
+
141
+ @-webkit-keyframes rightSpring{
142
+ 0%{ margin-left:0px;}
143
+ 50%{ margin-left:-30px;}
144
+ 100%{ margin-left:0px;}
145
+ }
146
+
147
+ @-webkit-keyframes leftSpring{
148
+ 0%{ margin-left:0px;}
149
+ 50%{ margin-left:30px;}
150
+ 100%{ margin-left:0px;}
151
+ }
152
+
153
+ /* Arrows */
154
+
155
+ #prevArrow,#nextArrow{
156
+ border:none;
157
+ text-decoration:none;
158
+ background:url(/assets/gallery/touch_touch/arrows.png) no-repeat;
159
+ opacity:0.5;
160
+ cursor:pointer;
161
+ position:absolute;
162
+ width:43px;
163
+ height:58px;
164
+
165
+ top:50%;
166
+ margin-top:-29px;
167
+
168
+ -moz-transition:opacity 0.2s ease;
169
+ -webkit-transition:opacity 0.2s ease;
170
+ transition:opacity 0.2s ease;
171
+ }
172
+
173
+ #prevArrow:hover, #nextArrow:hover{
174
+ opacity:1;
175
+ }
176
+
177
+ #prevArrow{
178
+ background-position:left top;
179
+ left:40px;
180
+ }
181
+
182
+ #nextArrow{
183
+ background-position:right top;
184
+ right:40px;
185
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-gallery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-22 00:00:00.000000000 Z
12
+ date: 2012-08-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -253,12 +253,15 @@ files:
253
253
  - vendor/assets/images/gallery/slideshow/icons/prev.png
254
254
  - vendor/assets/images/gallery/slideshow/icons/prev_thumb.png
255
255
  - vendor/assets/images/gallery/slideshow/icons/up.png
256
+ - vendor/assets/images/gallery/touch_touch/arrows.png
257
+ - vendor/assets/images/gallery/touch_touch/preloader.gif
256
258
  - vendor/assets/javascripts/gallery/galleria-1.2.8.js
257
259
  - vendor/assets/javascripts/gallery/galleria-1.2.8.min.js
258
260
  - vendor/assets/javascripts/gallery/galleria/classic.js
259
261
  - vendor/assets/javascripts/gallery/galleria/classic.min.js
260
262
  - vendor/assets/javascripts/gallery/responsive.js
261
263
  - vendor/assets/javascripts/gallery/slideshow.js
264
+ - vendor/assets/javascripts/gallery/touch_touch.js
262
265
  - vendor/assets/javascripts/jquery/jquery.easing-1.3.js
263
266
  - vendor/assets/javascripts/jquery/jquery.elastislide.js
264
267
  - vendor/assets/javascripts/jquery/jquery.tmpl.min.js
@@ -266,6 +269,7 @@ files:
266
269
  - vendor/assets/stylesheets/gallery/responsive.css
267
270
  - vendor/assets/stylesheets/gallery/responsive/elastislide.css
268
271
  - vendor/assets/stylesheets/gallery/slideshow.css
272
+ - vendor/assets/stylesheets/touch_touch.css
269
273
  homepage: http://github.com/kristianmandrup/rails-gallery
270
274
  licenses:
271
275
  - MIT
@@ -281,7 +285,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
285
  version: '0'
282
286
  segments:
283
287
  - 0
284
- hash: 1056637450518557715
288
+ hash: -1925983774391637922
285
289
  required_rubygems_version: !ruby/object:Gem::Requirement
286
290
  none: false
287
291
  requirements: