rails-gallery 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +9 -0
  4. data/Gemfile.lock +37 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.md +298 -0
  7. data/Rakefile +49 -0
  8. data/VERSION +1 -0
  9. data/app/views/gallery/_galleria.html.haml +4 -0
  10. data/app/views/gallery/_responsive.html.haml +15 -0
  11. data/app/views/gallery/_slideshow.html.haml +26 -0
  12. data/app/views/gallery/template/_responsive.html.haml +14 -0
  13. data/config/locales/rails_gallery.yml +5 -0
  14. data/lib/rails-gallery.rb +3 -0
  15. data/lib/rails-gallery/engine.rb +9 -0
  16. data/lib/rails-gallery/rgallery.rb +7 -0
  17. data/lib/rails-gallery/rgallery/page.rb +24 -0
  18. data/lib/rails-gallery/rgallery/pages.rb +34 -0
  19. data/lib/rails-gallery/rgallery/photo.rb +50 -0
  20. data/lib/rails-gallery/rgallery/photo_config.rb +18 -0
  21. data/lib/rails-gallery/rgallery/photos.rb +45 -0
  22. data/lib/rails-gallery/view_helper.rb +27 -0
  23. data/lib/rails-gallery/view_helper/galleria.rb +11 -0
  24. data/lib/rails-gallery/view_helper/responsive.rb +9 -0
  25. data/lib/rails-gallery/view_helper/slideshow.rb +9 -0
  26. data/rails-gallery.gemspec +217 -0
  27. data/spec/galleria_snippet.html +54 -0
  28. data/spec/galleria_snippet.html.haml +9 -0
  29. data/spec/images/photo_gallery/icons/IconsByGentleface.txt +1 -0
  30. data/spec/images/photo_gallery/icons/grid.png +0 -0
  31. data/spec/images/photo_gallery/icons/loading.gif +0 -0
  32. data/spec/images/photo_gallery/icons/next.png +0 -0
  33. data/spec/images/photo_gallery/icons/next_thumb.png +0 -0
  34. data/spec/images/photo_gallery/icons/pause.png +0 -0
  35. data/spec/images/photo_gallery/icons/play.png +0 -0
  36. data/spec/images/photo_gallery/icons/prev.png +0 -0
  37. data/spec/images/photo_gallery/icons/prev_thumb.png +0 -0
  38. data/spec/images/photo_gallery/icons/up.png +0 -0
  39. data/spec/images/photo_gallery/images/1.jpg +0 -0
  40. data/spec/images/photo_gallery/images/10.jpg +0 -0
  41. data/spec/images/photo_gallery/images/11.jpg +0 -0
  42. data/spec/images/photo_gallery/images/12.jpg +0 -0
  43. data/spec/images/photo_gallery/images/2.jpg +0 -0
  44. data/spec/images/photo_gallery/images/3.jpg +0 -0
  45. data/spec/images/photo_gallery/images/4.jpg +0 -0
  46. data/spec/images/photo_gallery/images/5.jpg +0 -0
  47. data/spec/images/photo_gallery/images/6.jpg +0 -0
  48. data/spec/images/photo_gallery/images/7.jpg +0 -0
  49. data/spec/images/photo_gallery/images/8.jpg +0 -0
  50. data/spec/images/photo_gallery/images/9.jpg +0 -0
  51. data/spec/images/photo_gallery/images/ImagesByTibchris.txt +3 -0
  52. data/spec/images/photo_gallery/images/thumbs/1.jpg +0 -0
  53. data/spec/images/photo_gallery/images/thumbs/10.jpg +0 -0
  54. data/spec/images/photo_gallery/images/thumbs/11.jpg +0 -0
  55. data/spec/images/photo_gallery/images/thumbs/12.jpg +0 -0
  56. data/spec/images/photo_gallery/images/thumbs/2.jpg +0 -0
  57. data/spec/images/photo_gallery/images/thumbs/3.jpg +0 -0
  58. data/spec/images/photo_gallery/images/thumbs/4.jpg +0 -0
  59. data/spec/images/photo_gallery/images/thumbs/5.jpg +0 -0
  60. data/spec/images/photo_gallery/images/thumbs/6.jpg +0 -0
  61. data/spec/images/photo_gallery/images/thumbs/7.jpg +0 -0
  62. data/spec/images/photo_gallery/images/thumbs/8.jpg +0 -0
  63. data/spec/images/photo_gallery/images/thumbs/9.jpg +0 -0
  64. data/spec/images/property/1.jpg +0 -0
  65. data/spec/images/property/2.jpg +0 -0
  66. data/spec/images/property/3.jpg +0 -0
  67. data/spec/images/property/4.jpg +0 -0
  68. data/spec/images/property/5.jpg +0 -0
  69. data/spec/images/property/6.jpg +0 -0
  70. data/spec/images/property/7.jpg +0 -0
  71. data/spec/images/property/ads/ad1.jpg +0 -0
  72. data/spec/images/property/ads/ad2.jpg +0 -0
  73. data/spec/images/property/ads/ad3.jpg +0 -0
  74. data/spec/images/property/thumbs/1.jpg +0 -0
  75. data/spec/images/property/thumbs/2.jpg +0 -0
  76. data/spec/images/property/thumbs/3.jpg +0 -0
  77. data/spec/images/property/thumbs/4.jpg +0 -0
  78. data/spec/images/property/thumbs/5.jpg +0 -0
  79. data/spec/images/property/thumbs/6.jpg +0 -0
  80. data/spec/images/property/thumbs/7.jpg +0 -0
  81. data/spec/images/responsive-gallery/icons/ajax-loader.gif +0 -0
  82. data/spec/images/responsive-gallery/icons/black.png +0 -0
  83. data/spec/images/responsive-gallery/icons/nav.png +0 -0
  84. data/spec/images/responsive-gallery/icons/nav_thumbs.png +0 -0
  85. data/spec/images/responsive-gallery/icons/pattern.png +0 -0
  86. data/spec/images/responsive-gallery/icons/views.png +0 -0
  87. data/spec/images/responsive-gallery/images/1.jpg +0 -0
  88. data/spec/images/responsive-gallery/images/10.jpg +0 -0
  89. data/spec/images/responsive-gallery/images/11.jpg +0 -0
  90. data/spec/images/responsive-gallery/images/12.jpg +0 -0
  91. data/spec/images/responsive-gallery/images/13.jpg +0 -0
  92. data/spec/images/responsive-gallery/images/14.jpg +0 -0
  93. data/spec/images/responsive-gallery/images/15.jpg +0 -0
  94. data/spec/images/responsive-gallery/images/16.jpg +0 -0
  95. data/spec/images/responsive-gallery/images/17.jpg +0 -0
  96. data/spec/images/responsive-gallery/images/18.jpg +0 -0
  97. data/spec/images/responsive-gallery/images/19.jpg +0 -0
  98. data/spec/images/responsive-gallery/images/2.jpg +0 -0
  99. data/spec/images/responsive-gallery/images/20.jpg +0 -0
  100. data/spec/images/responsive-gallery/images/21.jpg +0 -0
  101. data/spec/images/responsive-gallery/images/22.jpg +0 -0
  102. data/spec/images/responsive-gallery/images/23.jpg +0 -0
  103. data/spec/images/responsive-gallery/images/24.jpg +0 -0
  104. data/spec/images/responsive-gallery/images/3.jpg +0 -0
  105. data/spec/images/responsive-gallery/images/4.jpg +0 -0
  106. data/spec/images/responsive-gallery/images/5.jpg +0 -0
  107. data/spec/images/responsive-gallery/images/6.jpg +0 -0
  108. data/spec/images/responsive-gallery/images/7.jpg +0 -0
  109. data/spec/images/responsive-gallery/images/8.jpg +0 -0
  110. data/spec/images/responsive-gallery/images/9.jpg +0 -0
  111. data/spec/images/responsive-gallery/images/thumbs/1.jpg +0 -0
  112. data/spec/images/responsive-gallery/images/thumbs/10.jpg +0 -0
  113. data/spec/images/responsive-gallery/images/thumbs/11.jpg +0 -0
  114. data/spec/images/responsive-gallery/images/thumbs/12.jpg +0 -0
  115. data/spec/images/responsive-gallery/images/thumbs/13.jpg +0 -0
  116. data/spec/images/responsive-gallery/images/thumbs/14.jpg +0 -0
  117. data/spec/images/responsive-gallery/images/thumbs/15.jpg +0 -0
  118. data/spec/images/responsive-gallery/images/thumbs/16.jpg +0 -0
  119. data/spec/images/responsive-gallery/images/thumbs/17.jpg +0 -0
  120. data/spec/images/responsive-gallery/images/thumbs/18.jpg +0 -0
  121. data/spec/images/responsive-gallery/images/thumbs/19.jpg +0 -0
  122. data/spec/images/responsive-gallery/images/thumbs/2.jpg +0 -0
  123. data/spec/images/responsive-gallery/images/thumbs/20.jpg +0 -0
  124. data/spec/images/responsive-gallery/images/thumbs/21.jpg +0 -0
  125. data/spec/images/responsive-gallery/images/thumbs/22.jpg +0 -0
  126. data/spec/images/responsive-gallery/images/thumbs/23.jpg +0 -0
  127. data/spec/images/responsive-gallery/images/thumbs/24.jpg +0 -0
  128. data/spec/images/responsive-gallery/images/thumbs/3.jpg +0 -0
  129. data/spec/images/responsive-gallery/images/thumbs/4.jpg +0 -0
  130. data/spec/images/responsive-gallery/images/thumbs/5.jpg +0 -0
  131. data/spec/images/responsive-gallery/images/thumbs/6.jpg +0 -0
  132. data/spec/images/responsive-gallery/images/thumbs/7.jpg +0 -0
  133. data/spec/images/responsive-gallery/images/thumbs/8.jpg +0 -0
  134. data/spec/images/responsive-gallery/images/thumbs/9.jpg +0 -0
  135. data/spec/rails-gallery_spec.rb +7 -0
  136. data/spec/spec_helper.rb +10 -0
  137. data/vendor/assets/images/gallery/galleria/classic/loader.gif +0 -0
  138. data/vendor/assets/images/gallery/galleria/classic/map.png +0 -0
  139. data/vendor/assets/images/gallery/responsive/icons/ajax-loader.gif +0 -0
  140. data/vendor/assets/images/gallery/responsive/icons/black.png +0 -0
  141. data/vendor/assets/images/gallery/responsive/icons/nav.png +0 -0
  142. data/vendor/assets/images/gallery/responsive/icons/nav_thumbs.png +0 -0
  143. data/vendor/assets/images/gallery/responsive/icons/pattern.png +0 -0
  144. data/vendor/assets/images/gallery/responsive/icons/views.png +0 -0
  145. data/vendor/assets/images/gallery/slideshow/icons/grid.png +0 -0
  146. data/vendor/assets/images/gallery/slideshow/icons/loading.gif +0 -0
  147. data/vendor/assets/images/gallery/slideshow/icons/next.png +0 -0
  148. data/vendor/assets/images/gallery/slideshow/icons/next_thumb.png +0 -0
  149. data/vendor/assets/images/gallery/slideshow/icons/pause.png +0 -0
  150. data/vendor/assets/images/gallery/slideshow/icons/play.png +0 -0
  151. data/vendor/assets/images/gallery/slideshow/icons/prev.png +0 -0
  152. data/vendor/assets/images/gallery/slideshow/icons/prev_thumb.png +0 -0
  153. data/vendor/assets/images/gallery/slideshow/icons/up.png +0 -0
  154. data/vendor/assets/javascripts/gallery/galleria-1.2.8.js +5926 -0
  155. data/vendor/assets/javascripts/gallery/galleria-1.2.8.min.js +9 -0
  156. data/vendor/assets/javascripts/gallery/galleria/classic.js +95 -0
  157. data/vendor/assets/javascripts/gallery/galleria/classic.min.js +8 -0
  158. data/vendor/assets/javascripts/gallery/responsive.js +261 -0
  159. data/vendor/assets/javascripts/gallery/slideshow.js +308 -0
  160. data/vendor/assets/javascripts/jquery/jquery.easing-1.3.js +205 -0
  161. data/vendor/assets/javascripts/jquery/jquery.elastislide.js +467 -0
  162. data/vendor/assets/javascripts/jquery/jquery.tmpl.min.js +1 -0
  163. data/vendor/assets/stylesheets/gallery/galleria/classic.css +217 -0
  164. data/vendor/assets/stylesheets/gallery/responsive.css +105 -0
  165. data/vendor/assets/stylesheets/gallery/responsive/elastislide.css +69 -0
  166. data/vendor/assets/stylesheets/gallery/slideshow.css +171 -0
  167. metadata +297 -0
@@ -0,0 +1,205 @@
1
+ /*
2
+ * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
3
+ *
4
+ * Uses the built in easing capabilities added In jQuery 1.1
5
+ * to offer multiple easing options
6
+ *
7
+ * TERMS OF USE - jQuery Easing
8
+ *
9
+ * Open source under the BSD License.
10
+ *
11
+ * Copyright © 2008 George McGinley Smith
12
+ * All rights reserved.
13
+ *
14
+ * Redistribution and use in source and binary forms, with or without modification,
15
+ * are permitted provided that the following conditions are met:
16
+ *
17
+ * Redistributions of source code must retain the above copyright notice, this list of
18
+ * conditions and the following disclaimer.
19
+ * Redistributions in binary form must reproduce the above copyright notice, this list
20
+ * of conditions and the following disclaimer in the documentation and/or other materials
21
+ * provided with the distribution.
22
+ *
23
+ * Neither the name of the author nor the names of contributors may be used to endorse
24
+ * or promote products derived from this software without specific prior written permission.
25
+ *
26
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
27
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
31
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
32
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
34
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
35
+ *
36
+ */
37
+
38
+ // t: current time, b: begInnIng value, c: change In value, d: duration
39
+ jQuery.easing['jswing'] = jQuery.easing['swing'];
40
+
41
+ jQuery.extend( jQuery.easing,
42
+ {
43
+ def: 'easeOutQuad',
44
+ swing: function (x, t, b, c, d) {
45
+ //alert(jQuery.easing.default);
46
+ return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
47
+ },
48
+ easeInQuad: function (x, t, b, c, d) {
49
+ return c*(t/=d)*t + b;
50
+ },
51
+ easeOutQuad: function (x, t, b, c, d) {
52
+ return -c *(t/=d)*(t-2) + b;
53
+ },
54
+ easeInOutQuad: function (x, t, b, c, d) {
55
+ if ((t/=d/2) < 1) return c/2*t*t + b;
56
+ return -c/2 * ((--t)*(t-2) - 1) + b;
57
+ },
58
+ easeInCubic: function (x, t, b, c, d) {
59
+ return c*(t/=d)*t*t + b;
60
+ },
61
+ easeOutCubic: function (x, t, b, c, d) {
62
+ return c*((t=t/d-1)*t*t + 1) + b;
63
+ },
64
+ easeInOutCubic: function (x, t, b, c, d) {
65
+ if ((t/=d/2) < 1) return c/2*t*t*t + b;
66
+ return c/2*((t-=2)*t*t + 2) + b;
67
+ },
68
+ easeInQuart: function (x, t, b, c, d) {
69
+ return c*(t/=d)*t*t*t + b;
70
+ },
71
+ easeOutQuart: function (x, t, b, c, d) {
72
+ return -c * ((t=t/d-1)*t*t*t - 1) + b;
73
+ },
74
+ easeInOutQuart: function (x, t, b, c, d) {
75
+ if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
76
+ return -c/2 * ((t-=2)*t*t*t - 2) + b;
77
+ },
78
+ easeInQuint: function (x, t, b, c, d) {
79
+ return c*(t/=d)*t*t*t*t + b;
80
+ },
81
+ easeOutQuint: function (x, t, b, c, d) {
82
+ return c*((t=t/d-1)*t*t*t*t + 1) + b;
83
+ },
84
+ easeInOutQuint: function (x, t, b, c, d) {
85
+ if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
86
+ return c/2*((t-=2)*t*t*t*t + 2) + b;
87
+ },
88
+ easeInSine: function (x, t, b, c, d) {
89
+ return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
90
+ },
91
+ easeOutSine: function (x, t, b, c, d) {
92
+ return c * Math.sin(t/d * (Math.PI/2)) + b;
93
+ },
94
+ easeInOutSine: function (x, t, b, c, d) {
95
+ return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
96
+ },
97
+ easeInExpo: function (x, t, b, c, d) {
98
+ return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
99
+ },
100
+ easeOutExpo: function (x, t, b, c, d) {
101
+ return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
102
+ },
103
+ easeInOutExpo: function (x, t, b, c, d) {
104
+ if (t==0) return b;
105
+ if (t==d) return b+c;
106
+ if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
107
+ return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
108
+ },
109
+ easeInCirc: function (x, t, b, c, d) {
110
+ return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
111
+ },
112
+ easeOutCirc: function (x, t, b, c, d) {
113
+ return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
114
+ },
115
+ easeInOutCirc: function (x, t, b, c, d) {
116
+ if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
117
+ return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
118
+ },
119
+ easeInElastic: function (x, t, b, c, d) {
120
+ var s=1.70158;var p=0;var a=c;
121
+ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
122
+ if (a < Math.abs(c)) { a=c; var s=p/4; }
123
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
124
+ return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
125
+ },
126
+ easeOutElastic: function (x, t, b, c, d) {
127
+ var s=1.70158;var p=0;var a=c;
128
+ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
129
+ if (a < Math.abs(c)) { a=c; var s=p/4; }
130
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
131
+ return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
132
+ },
133
+ easeInOutElastic: function (x, t, b, c, d) {
134
+ var s=1.70158;var p=0;var a=c;
135
+ if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
136
+ if (a < Math.abs(c)) { a=c; var s=p/4; }
137
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
138
+ if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
139
+ return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
140
+ },
141
+ easeInBack: function (x, t, b, c, d, s) {
142
+ if (s == undefined) s = 1.70158;
143
+ return c*(t/=d)*t*((s+1)*t - s) + b;
144
+ },
145
+ easeOutBack: function (x, t, b, c, d, s) {
146
+ if (s == undefined) s = 1.70158;
147
+ return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
148
+ },
149
+ easeInOutBack: function (x, t, b, c, d, s) {
150
+ if (s == undefined) s = 1.70158;
151
+ if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
152
+ return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
153
+ },
154
+ easeInBounce: function (x, t, b, c, d) {
155
+ return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
156
+ },
157
+ easeOutBounce: function (x, t, b, c, d) {
158
+ if ((t/=d) < (1/2.75)) {
159
+ return c*(7.5625*t*t) + b;
160
+ } else if (t < (2/2.75)) {
161
+ return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
162
+ } else if (t < (2.5/2.75)) {
163
+ return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
164
+ } else {
165
+ return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
166
+ }
167
+ },
168
+ easeInOutBounce: function (x, t, b, c, d) {
169
+ if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
170
+ return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
171
+ }
172
+ });
173
+
174
+ /*
175
+ *
176
+ * TERMS OF USE - EASING EQUATIONS
177
+ *
178
+ * Open source under the BSD License.
179
+ *
180
+ * Copyright © 2001 Robert Penner
181
+ * All rights reserved.
182
+ *
183
+ * Redistribution and use in source and binary forms, with or without modification,
184
+ * are permitted provided that the following conditions are met:
185
+ *
186
+ * Redistributions of source code must retain the above copyright notice, this list of
187
+ * conditions and the following disclaimer.
188
+ * Redistributions in binary form must reproduce the above copyright notice, this list
189
+ * of conditions and the following disclaimer in the documentation and/or other materials
190
+ * provided with the distribution.
191
+ *
192
+ * Neither the name of the author nor the names of contributors may be used to endorse
193
+ * or promote products derived from this software without specific prior written permission.
194
+ *
195
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
196
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
197
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
198
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
199
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
200
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
201
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
202
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
203
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
204
+ *
205
+ */
@@ -0,0 +1,467 @@
1
+ (function( window, $, undefined ) {
2
+
3
+ // http://www.netcu.de/jquery-touchwipe-iphone-ipad-library
4
+ $.fn.touchwipe = function(settings) {
5
+
6
+ var config = {
7
+ min_move_x: 20,
8
+ min_move_y: 20,
9
+ wipeLeft: function() { },
10
+ wipeRight: function() { },
11
+ wipeUp: function() { },
12
+ wipeDown: function() { },
13
+ preventDefaultEvents: true
14
+ };
15
+
16
+ if (settings) $.extend(config, settings);
17
+
18
+ this.each(function() {
19
+ var startX;
20
+ var startY;
21
+ var isMoving = false;
22
+
23
+ function cancelTouch() {
24
+ this.removeEventListener('touchmove', onTouchMove);
25
+ startX = null;
26
+ isMoving = false;
27
+ }
28
+
29
+ function onTouchMove(e) {
30
+ if(config.preventDefaultEvents) {
31
+ e.preventDefault();
32
+ }
33
+ if(isMoving) {
34
+ var x = e.touches[0].pageX;
35
+ var y = e.touches[0].pageY;
36
+ var dx = startX - x;
37
+ var dy = startY - y;
38
+ if(Math.abs(dx) >= config.min_move_x) {
39
+ cancelTouch();
40
+ if(dx > 0) {
41
+ config.wipeLeft();
42
+ }
43
+ else {
44
+ config.wipeRight();
45
+ }
46
+ }
47
+ else if(Math.abs(dy) >= config.min_move_y) {
48
+ cancelTouch();
49
+ if(dy > 0) {
50
+ config.wipeDown();
51
+ }
52
+ else {
53
+ config.wipeUp();
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ function onTouchStart(e)
60
+ {
61
+ if (e.touches.length == 1) {
62
+ startX = e.touches[0].pageX;
63
+ startY = e.touches[0].pageY;
64
+ isMoving = true;
65
+ this.addEventListener('touchmove', onTouchMove, false);
66
+ }
67
+ }
68
+ if ('ontouchstart' in document.documentElement) {
69
+ this.addEventListener('touchstart', onTouchStart, false);
70
+ }
71
+ });
72
+
73
+ return this;
74
+ };
75
+
76
+ $.elastislide = function( options, element ) {
77
+ this.$el = $( element );
78
+ this._init( options );
79
+ };
80
+
81
+ $.elastislide.defaults = {
82
+ speed : 450, // animation speed
83
+ easing : '', // animation easing effect
84
+ imageW : 190, // the images width
85
+ margin : 3, // image margin right
86
+ border : 2, // image border
87
+ minItems : 1, // the minimum number of items to show.
88
+ // when we resize the window, this will make sure minItems are always shown
89
+ // (unless of course minItems is higher than the total number of elements)
90
+ current : 0, // index of the current item
91
+ // when we resize the window, the carousel will make sure this item is visible
92
+ onClick : function() { return false; } // click item callback
93
+ };
94
+
95
+ $.elastislide.prototype = {
96
+ _init : function( options ) {
97
+
98
+ this.options = $.extend( true, {}, $.elastislide.defaults, options );
99
+
100
+ // <ul>
101
+ this.$slider = this.$el.find('ul');
102
+
103
+ // <li>
104
+ this.$items = this.$slider.children('li');
105
+
106
+ // total number of elements / images
107
+ this.itemsCount = this.$items.length;
108
+
109
+ // cache the <ul>'s parent, since we will eventually need to recalculate its width on window resize
110
+ this.$esCarousel = this.$slider.parent();
111
+
112
+ // validate options
113
+ this._validateOptions();
114
+
115
+ // set sizes and initialize some vars...
116
+ this._configure();
117
+
118
+ // add navigation buttons
119
+ this._addControls();
120
+
121
+ // initialize the events
122
+ this._initEvents();
123
+
124
+ // show the <ul>
125
+ this.$slider.show();
126
+
127
+ // slide to current's position
128
+ this._slideToCurrent( false );
129
+
130
+ },
131
+ _validateOptions : function() {
132
+
133
+ if( this.options.speed < 0 )
134
+ this.options.speed = 450;
135
+ if( this.options.margin < 0 )
136
+ this.options.margin = 4;
137
+ if( this.options.border < 0 )
138
+ this.options.border = 1;
139
+ if( this.options.minItems < 1 || this.options.minItems > this.itemsCount )
140
+ this.options.minItems = 1;
141
+ if( this.options.current > this.itemsCount - 1 )
142
+ this.options.current = 0;
143
+
144
+ },
145
+ _configure : function() {
146
+
147
+ // current item's index
148
+ this.current = this.options.current;
149
+
150
+ // the ul's parent's (div.es-carousel) width is the "visible" width
151
+ this.visibleWidth = this.$esCarousel.width();
152
+
153
+ // test to see if we need to initially resize the items
154
+ if( this.visibleWidth < this.options.minItems * ( this.options.imageW + 2 * this.options.border ) + ( this.options.minItems - 1 ) * this.options.margin ) {
155
+ this._setDim( ( this.visibleWidth - ( this.options.minItems - 1 ) * this.options.margin ) / this.options.minItems );
156
+ this._setCurrentValues();
157
+ // how many items fit with the current width
158
+ this.fitCount = this.options.minItems;
159
+ }
160
+ else {
161
+ this._setDim();
162
+ this._setCurrentValues();
163
+ }
164
+
165
+ // set the <ul> width
166
+ this.$slider.css({
167
+ width : this.sliderW
168
+ });
169
+
170
+ },
171
+ _setDim : function( elW ) {
172
+
173
+ // <li> style
174
+ this.$items.css({
175
+ marginRight : this.options.margin,
176
+ width : ( elW ) ? elW : this.options.imageW + 2 * this.options.border
177
+ }).children('a').css({ // <a> style
178
+ borderWidth : this.options.border
179
+ });
180
+
181
+ },
182
+ _setCurrentValues : function() {
183
+
184
+ // the total space occupied by one item
185
+ this.itemW = this.$items.outerWidth(true);
186
+
187
+ // total width of the slider / <ul>
188
+ // this will eventually change on window resize
189
+ this.sliderW = this.itemW * this.itemsCount;
190
+
191
+ // the ul parent's (div.es-carousel) width is the "visible" width
192
+ this.visibleWidth = this.$esCarousel.width();
193
+
194
+ // how many items fit with the current width
195
+ this.fitCount = Math.floor( this.visibleWidth / this.itemW );
196
+
197
+ },
198
+ _addControls : function() {
199
+
200
+ this.$navNext = $('<span class="es-nav-next">Next</span>');
201
+ this.$navPrev = $('<span class="es-nav-prev">Previous</span>');
202
+ $('<div class="es-nav"/>')
203
+ .append( this.$navPrev )
204
+ .append( this.$navNext )
205
+ .appendTo( this.$el );
206
+
207
+ //this._toggleControls();
208
+
209
+ },
210
+ _toggleControls : function( dir, status ) {
211
+
212
+ // show / hide navigation buttons
213
+ if( dir && status ) {
214
+ if( status === 1 )
215
+ ( dir === 'right' ) ? this.$navNext.show() : this.$navPrev.show();
216
+ else
217
+ ( dir === 'right' ) ? this.$navNext.hide() : this.$navPrev.hide();
218
+ }
219
+ else if( this.current === this.itemsCount - 1 || this.fitCount >= this.itemsCount )
220
+ this.$navNext.hide();
221
+
222
+ },
223
+ _initEvents : function() {
224
+
225
+ var instance = this;
226
+
227
+ // window resize
228
+ $(window).on('resize.elastislide', function( event ) {
229
+
230
+ instance._reload();
231
+
232
+ // slide to the current element
233
+ clearTimeout( instance.resetTimeout );
234
+ instance.resetTimeout = setTimeout(function() {
235
+ instance._slideToCurrent();
236
+ }, 200);
237
+
238
+ });
239
+
240
+ // navigation buttons events
241
+ this.$navNext.on('click.elastislide', function( event ) {
242
+ instance._slide('right');
243
+ });
244
+
245
+ this.$navPrev.on('click.elastislide', function( event ) {
246
+ instance._slide('left');
247
+ });
248
+
249
+ // item click event
250
+ this.$slider.on('click.elastislide', 'li', function( event ) {
251
+ instance.options.onClick( $(this) );
252
+ return false;
253
+ });
254
+
255
+ // touch events
256
+ instance.$slider.touchwipe({
257
+ wipeLeft : function() {
258
+ instance._slide('right');
259
+ },
260
+ wipeRight : function() {
261
+ instance._slide('left');
262
+ }
263
+ });
264
+
265
+ },
266
+ reload : function( callback ) {
267
+ this._reload();
268
+ if ( callback ) callback.call();
269
+
270
+ },
271
+ _reload : function() {
272
+
273
+ var instance = this;
274
+
275
+ // set values again
276
+ instance._setCurrentValues();
277
+
278
+ // need to resize items
279
+ if( instance.visibleWidth < instance.options.minItems * ( instance.options.imageW + 2 * instance.options.border ) + ( instance.options.minItems - 1 ) * instance.options.margin ) {
280
+ instance._setDim( ( instance.visibleWidth - ( instance.options.minItems - 1 ) * instance.options.margin ) / instance.options.minItems );
281
+ instance._setCurrentValues();
282
+ instance.fitCount = instance.options.minItems;
283
+ }
284
+ else{
285
+ instance._setDim();
286
+ instance._setCurrentValues();
287
+ }
288
+
289
+ instance.$slider.css({
290
+ width : instance.sliderW + 10 // TODO: +10px seems to solve a firefox "bug" :S
291
+ });
292
+
293
+ },
294
+ _slide : function( dir, val, anim, callback ) {
295
+
296
+ // if animating return
297
+ //if( this.$slider.is(':animated') )
298
+ //return false;
299
+
300
+ // current margin left
301
+ var ml = parseFloat( this.$slider.css('margin-left') );
302
+
303
+ // val is just passed when we want an exact value for the margin left (used in the _slideToCurrent function)
304
+ if( val === undefined ) {
305
+
306
+ // how much to slide?
307
+ var amount = this.fitCount * this.itemW, val;
308
+
309
+ if( amount < 0 ) return false;
310
+
311
+ // make sure not to leave a space between the last item / first item and the end / beggining of the slider available width
312
+ if( dir === 'right' && this.sliderW - ( Math.abs( ml ) + amount ) < this.visibleWidth ) {
313
+ amount = this.sliderW - ( Math.abs( ml ) + this.visibleWidth ) - this.options.margin; // decrease the margin left
314
+ // show / hide navigation buttons
315
+ this._toggleControls( 'right', -1 );
316
+ this._toggleControls( 'left', 1 );
317
+ }
318
+ else if( dir === 'left' && Math.abs( ml ) - amount < 0 ) {
319
+ amount = Math.abs( ml );
320
+ // show / hide navigation buttons
321
+ this._toggleControls( 'left', -1 );
322
+ this._toggleControls( 'right', 1 );
323
+ }
324
+ else {
325
+ var fml; // future margin left
326
+ ( dir === 'right' )
327
+ ? fml = Math.abs( ml ) + this.options.margin + Math.abs( amount )
328
+ : fml = Math.abs( ml ) - this.options.margin - Math.abs( amount );
329
+
330
+ // show / hide navigation buttons
331
+ if( fml > 0 )
332
+ this._toggleControls( 'left', 1 );
333
+ else
334
+ this._toggleControls( 'left', -1 );
335
+
336
+ if( fml < this.sliderW - this.visibleWidth )
337
+ this._toggleControls( 'right', 1 );
338
+ else
339
+ this._toggleControls( 'right', -1 );
340
+
341
+ }
342
+
343
+ ( dir === 'right' ) ? val = '-=' + amount : val = '+=' + amount
344
+
345
+ }
346
+ else {
347
+ var fml = Math.abs( val ); // future margin left
348
+
349
+ if( Math.max( this.sliderW, this.visibleWidth ) - fml < this.visibleWidth ) {
350
+ val = - ( Math.max( this.sliderW, this.visibleWidth ) - this.visibleWidth );
351
+ if( val !== 0 )
352
+ val += this.options.margin; // decrease the margin left if not on the first position
353
+
354
+ // show / hide navigation buttons
355
+ this._toggleControls( 'right', -1 );
356
+ fml = Math.abs( val );
357
+ }
358
+
359
+ // show / hide navigation buttons
360
+ if( fml > 0 )
361
+ this._toggleControls( 'left', 1 );
362
+ else
363
+ this._toggleControls( 'left', -1 );
364
+
365
+ if( Math.max( this.sliderW, this.visibleWidth ) - this.visibleWidth > fml + this.options.margin )
366
+ this._toggleControls( 'right', 1 );
367
+ else
368
+ this._toggleControls( 'right', -1 );
369
+
370
+ }
371
+
372
+ $.fn.applyStyle = ( anim === undefined ) ? $.fn.animate : $.fn.css;
373
+
374
+ var sliderCSS = { marginLeft : val };
375
+
376
+ var instance = this;
377
+
378
+ this.$slider.stop().applyStyle( sliderCSS, $.extend( true, [], { duration : this.options.speed, easing : this.options.easing, complete : function() {
379
+ if( callback ) callback.call();
380
+ } } ) );
381
+
382
+ },
383
+ _slideToCurrent : function( anim ) {
384
+
385
+ // how much to slide?
386
+ var amount = this.current * this.itemW;
387
+ this._slide('', -amount, anim );
388
+
389
+ },
390
+ add : function( $newelems, callback ) {
391
+
392
+ // adds new items to the carousel
393
+ this.$items = this.$items.add( $newelems );
394
+ this.itemsCount = this.$items.length;
395
+ this._setDim();
396
+ this._setCurrentValues();
397
+ this.$slider.css({
398
+ width : this.sliderW
399
+ });
400
+ this._slideToCurrent();
401
+
402
+ if ( callback ) callback.call( $newelems );
403
+
404
+ },
405
+ setCurrent : function( idx, callback ) {
406
+
407
+ this.current = idx;
408
+
409
+ var ml = Math.abs( parseFloat( this.$slider.css('margin-left') ) ),
410
+ posR = ml + this.visibleWidth,
411
+ fml = Math.abs( this.current * this.itemW );
412
+
413
+ if( fml + this.itemW > posR || fml < ml ) {
414
+ this._slideToCurrent();
415
+ }
416
+
417
+ if ( callback ) callback.call();
418
+
419
+ },
420
+ destroy : function( callback ) {
421
+
422
+ this._destroy( callback );
423
+
424
+ },
425
+ _destroy : function( callback ) {
426
+ this.$el.off('.elastislide').removeData('elastislide');
427
+ $(window).off('.elastislide');
428
+ if ( callback ) callback.call();
429
+ }
430
+ };
431
+
432
+ var logError = function( message ) {
433
+ if ( this.console ) {
434
+ console.error( message );
435
+ }
436
+ };
437
+
438
+ $.fn.elastislide = function( options ) {
439
+ if ( typeof options === 'string' ) {
440
+ var args = Array.prototype.slice.call( arguments, 1 );
441
+
442
+ this.each(function() {
443
+ var instance = $.data( this, 'elastislide' );
444
+ if ( !instance ) {
445
+ logError( "cannot call methods on elastislide prior to initialization; " +
446
+ "attempted to call method '" + options + "'" );
447
+ return;
448
+ }
449
+ if ( !$.isFunction( instance[options] ) || options.charAt(0) === "_" ) {
450
+ logError( "no such method '" + options + "' for elastislide instance" );
451
+ return;
452
+ }
453
+ instance[ options ].apply( instance, args );
454
+ });
455
+ }
456
+ else {
457
+ this.each(function() {
458
+ var instance = $.data( this, 'elastislide' );
459
+ if ( !instance ) {
460
+ $.data( this, 'elastislide', new $.elastislide( options, this ) );
461
+ }
462
+ });
463
+ }
464
+ return this;
465
+ };
466
+
467
+ })( window, jQuery );