uikit-on-rails 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/README.md +37 -0
  4. data/Rakefile +1 -0
  5. data/lib/uikit-on-rails.rb +1 -0
  6. data/lib/uikit/sass/rails.rb +2 -0
  7. data/lib/uikit/sass/rails/engine.rb +12 -0
  8. data/lib/uikit/sass/rails/version.rb +7 -0
  9. data/uikit-on-rails.gemspec +23 -0
  10. data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
  11. data/vendor/assets/fonts/fontawesome-webfont.otf +0 -0
  12. data/vendor/assets/fonts/fontawesome-webfont.svg +565 -0
  13. data/vendor/assets/fonts/fontawesome-webfont.ttf +0 -0
  14. data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
  15. data/vendor/assets/fonts/fontawesome-webfont.woff2 +0 -0
  16. data/vendor/assets/javascripts/uikit.js +19 -0
  17. data/vendor/assets/javascripts/uikit/components/accordion.js +180 -0
  18. data/vendor/assets/javascripts/uikit/components/autocomplete.js +340 -0
  19. data/vendor/assets/javascripts/uikit/components/datepicker.js +3167 -0
  20. data/vendor/assets/javascripts/uikit/components/form-password.js +67 -0
  21. data/vendor/assets/javascripts/uikit/components/form-select.js +85 -0
  22. data/vendor/assets/javascripts/uikit/components/grid-parallax.js +168 -0
  23. data/vendor/assets/javascripts/uikit/components/grid.js +540 -0
  24. data/vendor/assets/javascripts/uikit/components/htmleditor.js +679 -0
  25. data/vendor/assets/javascripts/uikit/components/lightbox.js +591 -0
  26. data/vendor/assets/javascripts/uikit/components/nestable.js +653 -0
  27. data/vendor/assets/javascripts/uikit/components/notify.js +189 -0
  28. data/vendor/assets/javascripts/uikit/components/pagination.js +147 -0
  29. data/vendor/assets/javascripts/uikit/components/parallax.js +462 -0
  30. data/vendor/assets/javascripts/uikit/components/search.js +92 -0
  31. data/vendor/assets/javascripts/uikit/components/slider.js +552 -0
  32. data/vendor/assets/javascripts/uikit/components/slideset.js +523 -0
  33. data/vendor/assets/javascripts/uikit/components/slideshow-fx.js +383 -0
  34. data/vendor/assets/javascripts/uikit/components/slideshow.js +596 -0
  35. data/vendor/assets/javascripts/uikit/components/sortable.js +688 -0
  36. data/vendor/assets/javascripts/uikit/components/sticky.js +364 -0
  37. data/vendor/assets/javascripts/uikit/components/timepicker.js +192 -0
  38. data/vendor/assets/javascripts/uikit/components/tooltip.js +234 -0
  39. data/vendor/assets/javascripts/uikit/components/upload.js +262 -0
  40. data/vendor/assets/javascripts/uikit/core/alert.js +66 -0
  41. data/vendor/assets/javascripts/uikit/core/button.js +156 -0
  42. data/vendor/assets/javascripts/uikit/core/core.js +820 -0
  43. data/vendor/assets/javascripts/uikit/core/cover.js +95 -0
  44. data/vendor/assets/javascripts/uikit/core/dropdown.js +529 -0
  45. data/vendor/assets/javascripts/uikit/core/grid.js +117 -0
  46. data/vendor/assets/javascripts/uikit/core/modal.js +389 -0
  47. data/vendor/assets/javascripts/uikit/core/nav.js +152 -0
  48. data/vendor/assets/javascripts/uikit/core/offcanvas.js +197 -0
  49. data/vendor/assets/javascripts/uikit/core/scrollspy.js +209 -0
  50. data/vendor/assets/javascripts/uikit/core/smooth-scroll.js +62 -0
  51. data/vendor/assets/javascripts/uikit/core/switcher.js +309 -0
  52. data/vendor/assets/javascripts/uikit/core/tab.js +167 -0
  53. data/vendor/assets/javascripts/uikit/core/toggle.js +124 -0
  54. data/vendor/assets/javascripts/uikit/core/touch.js +175 -0
  55. data/vendor/assets/javascripts/uikit/core/utility.js +338 -0
  56. data/vendor/assets/javascripts/uikit/uikit.js +3905 -0
  57. data/vendor/assets/stylesheets/extra/font-awesome.scss +14 -0
  58. data/vendor/assets/stylesheets/uikit.scss +7 -0
  59. data/vendor/assets/stylesheets/uikit/components/accordion.scss +94 -0
  60. data/vendor/assets/stylesheets/uikit/components/autocomplete.scss +107 -0
  61. data/vendor/assets/stylesheets/uikit/components/datepicker.scss +197 -0
  62. data/vendor/assets/stylesheets/uikit/components/dotnav.scss +212 -0
  63. data/vendor/assets/stylesheets/uikit/components/form-advanced.scss +128 -0
  64. data/vendor/assets/stylesheets/uikit/components/form-file.scss +63 -0
  65. data/vendor/assets/stylesheets/uikit/components/form-password.scss +74 -0
  66. data/vendor/assets/stylesheets/uikit/components/form-select.scss +66 -0
  67. data/vendor/assets/stylesheets/uikit/components/htmleditor.scss +269 -0
  68. data/vendor/assets/stylesheets/uikit/components/nestable.scss +231 -0
  69. data/vendor/assets/stylesheets/uikit/components/notify.scss +190 -0
  70. data/vendor/assets/stylesheets/uikit/components/placeholder.scss +66 -0
  71. data/vendor/assets/stylesheets/uikit/components/progress.scss +173 -0
  72. data/vendor/assets/stylesheets/uikit/components/search.scss +309 -0
  73. data/vendor/assets/stylesheets/uikit/components/slidenav.scss +183 -0
  74. data/vendor/assets/stylesheets/uikit/components/slider.scss +139 -0
  75. data/vendor/assets/stylesheets/uikit/components/slideshow.scss +208 -0
  76. data/vendor/assets/stylesheets/uikit/components/sortable.scss +124 -0
  77. data/vendor/assets/stylesheets/uikit/components/sticky.scss +57 -0
  78. data/vendor/assets/stylesheets/uikit/components/tooltip.scss +177 -0
  79. data/vendor/assets/stylesheets/uikit/components/upload.scss +34 -0
  80. data/vendor/assets/stylesheets/uikit/core/alert.scss +141 -0
  81. data/vendor/assets/stylesheets/uikit/core/animation.scss +599 -0
  82. data/vendor/assets/stylesheets/uikit/core/article.scss +139 -0
  83. data/vendor/assets/stylesheets/uikit/core/badge.scss +110 -0
  84. data/vendor/assets/stylesheets/uikit/core/base.scss +563 -0
  85. data/vendor/assets/stylesheets/uikit/core/block.scss +155 -0
  86. data/vendor/assets/stylesheets/uikit/core/breadcrumb.scss +86 -0
  87. data/vendor/assets/stylesheets/uikit/core/button.scss +406 -0
  88. data/vendor/assets/stylesheets/uikit/core/close.scss +132 -0
  89. data/vendor/assets/stylesheets/uikit/core/column.scss +209 -0
  90. data/vendor/assets/stylesheets/uikit/core/comment.scss +172 -0
  91. data/vendor/assets/stylesheets/uikit/core/contrast.scss +493 -0
  92. data/vendor/assets/stylesheets/uikit/core/cover.scss +70 -0
  93. data/vendor/assets/stylesheets/uikit/core/description-list.scss +71 -0
  94. data/vendor/assets/stylesheets/uikit/core/dropdown.scss +280 -0
  95. data/vendor/assets/stylesheets/uikit/core/flex.scss +320 -0
  96. data/vendor/assets/stylesheets/uikit/core/form.scss +629 -0
  97. data/vendor/assets/stylesheets/uikit/core/grid.scss +731 -0
  98. data/vendor/assets/stylesheets/uikit/core/icon.scss +930 -0
  99. data/vendor/assets/stylesheets/uikit/core/list.scss +102 -0
  100. data/vendor/assets/stylesheets/uikit/core/modal.scss +343 -0
  101. data/vendor/assets/stylesheets/uikit/core/nav.scss +468 -0
  102. data/vendor/assets/stylesheets/uikit/core/navbar.scss +325 -0
  103. data/vendor/assets/stylesheets/uikit/core/offcanvas.scss +203 -0
  104. data/vendor/assets/stylesheets/uikit/core/overlay.scss +534 -0
  105. data/vendor/assets/stylesheets/uikit/core/pagination.scss +197 -0
  106. data/vendor/assets/stylesheets/uikit/core/panel.scss +332 -0
  107. data/vendor/assets/stylesheets/uikit/core/print.scss +61 -0
  108. data/vendor/assets/stylesheets/uikit/core/subnav.scss +213 -0
  109. data/vendor/assets/stylesheets/uikit/core/switcher.scss +38 -0
  110. data/vendor/assets/stylesheets/uikit/core/tab.scss +368 -0
  111. data/vendor/assets/stylesheets/uikit/core/table.scss +147 -0
  112. data/vendor/assets/stylesheets/uikit/core/text.scss +136 -0
  113. data/vendor/assets/stylesheets/uikit/core/thumbnail.scss +122 -0
  114. data/vendor/assets/stylesheets/uikit/core/thumbnav.scss +122 -0
  115. data/vendor/assets/stylesheets/uikit/core/utility.scss +610 -0
  116. data/vendor/assets/stylesheets/uikit/core/variables.scss +23 -0
  117. data/vendor/assets/stylesheets/uikit/uikit-mixins.scss +327 -0
  118. data/vendor/assets/stylesheets/uikit/uikit-variables.scss +819 -0
  119. data/vendor/assets/stylesheets/uikit/uikit.scss +52 -0
  120. metadata +177 -0
@@ -0,0 +1,383 @@
1
+ /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2
+ (function(addon) {
3
+
4
+ var component;
5
+
6
+ if (window.UIkit) {
7
+ component = addon(UIkit);
8
+ }
9
+
10
+ if (typeof define == "function" && define.amd) {
11
+ define("uikit-slideshow-fx", ["uikit"], function() {
12
+ return component || addon(UIkit);
13
+ });
14
+ }
15
+
16
+ })(function(UI) {
17
+
18
+ "use strict";
19
+
20
+ var Animations = UI.slideshow.animations;
21
+
22
+ UI.$.extend(UI.slideshow.animations, {
23
+ slice: function(current, next, dir, fromfx) {
24
+
25
+ if (!current.data('cover')) {
26
+ return Animations.fade.apply(this, arguments);
27
+ }
28
+
29
+ var d = UI.$.Deferred();
30
+
31
+ var sliceWidth = Math.ceil(this.element.width() / this.options.slices),
32
+ bgimage = next.data('cover').css('background-image'),
33
+ ghost = UI.$('<li></li>').css({
34
+ top : 0,
35
+ left : 0,
36
+ width : this.container.width(),
37
+ height : this.container.height(),
38
+ opacity: 1,
39
+ zIndex : 15
40
+ }),
41
+ ghostWidth = ghost.width(),
42
+ ghostHeight = ghost.height(),
43
+ pos = fromfx == 'slice-up' ? ghostHeight:'0',
44
+ bar;
45
+
46
+ for (var i = 0; i < this.options.slices; i++) {
47
+
48
+ if (fromfx == 'slice-up-down') {
49
+ pos = ((i % 2) + 2) % 2==0 ? '0':ghostHeight;
50
+ }
51
+
52
+ var width = (i == this.options.slices-1) ? sliceWidth : sliceWidth,
53
+ clipto = ('rect(0px, '+(width*(i+1))+'px, '+ghostHeight+'px, '+(sliceWidth*i)+'px)'),
54
+ clipfrom;
55
+
56
+ //slice-down - default
57
+ clipfrom = ('rect(0px, '+(width*(i+1))+'px, 0px, '+(sliceWidth*i)+'px)');
58
+
59
+ if (fromfx == 'slice-up' || (fromfx == 'slice-up-down' && ((i % 2) + 2) % 2==0 )) {
60
+ clipfrom = ('rect('+ghostHeight+'px, '+(width*(i+1))+'px, '+ghostHeight+'px, '+(sliceWidth*i)+'px)');
61
+ }
62
+
63
+ bar = UI.$('<div class="uk-cover-background"></div>').css({
64
+ 'position' : 'absolute',
65
+ 'top' : 0,
66
+ 'left' : 0,
67
+ 'width' : ghostWidth,
68
+ 'height' : ghostHeight,
69
+ 'background-image' : bgimage,
70
+ 'clip' : clipfrom,
71
+ 'opacity' : 0,
72
+ 'transition' : 'all '+this.options.duration+'ms ease-in-out '+(i*60)+'ms',
73
+ '-webkit-transition' : 'all '+this.options.duration+'ms ease-in-out '+(i*60)+'ms'
74
+
75
+ }).data('clip', clipto);
76
+
77
+ ghost.append(bar);
78
+ }
79
+
80
+ this.container.append(ghost);
81
+
82
+ ghost.children().last().on(UI.support.transition.end, function() {
83
+
84
+ setTimeout(ghost.remove.bind(ghost), 0);
85
+
86
+ d.resolve();
87
+ });
88
+
89
+ ghost.width();
90
+
91
+ ghost.children().each(function() {
92
+ var bar = UI.$(this);
93
+
94
+ bar.css({
95
+ 'clip': bar.data('clip'),
96
+ 'opacity': 1
97
+ });
98
+ });
99
+
100
+ return d.promise();
101
+ },
102
+
103
+ 'slice-up': function(current, next, dir) {
104
+ return Animations.slice.apply(this, [current, next, dir, 'slice-up']);
105
+ },
106
+
107
+ 'slice-down': function(current, next, dir) {
108
+ return Animations.slice.apply(this, [current, next, dir, 'slice-down']);
109
+ },
110
+
111
+ 'slice-up-down': function(current, next, dir) {
112
+ return Animations.slice.apply(this, [current, next, dir, 'slice-up-down']);
113
+ },
114
+
115
+ fold: function(current, next, dir) {
116
+
117
+ if (!next.data('cover')) {
118
+ return Animations.fade.apply(this, arguments);
119
+ }
120
+
121
+ var d = UI.$.Deferred();
122
+
123
+ var sliceWidth = Math.ceil(this.element.width() / this.options.slices),
124
+ bgimage = next.data('cover').css('background-image'),
125
+ ghost = UI.$('<li></li>').css({
126
+ width : next.width(),
127
+ height : next.height(),
128
+ opacity: 1,
129
+ zIndex : 15
130
+ }),
131
+ ghostWidth = next.width(),
132
+ ghostHeight = next.height(),
133
+ bar;
134
+
135
+ for (var i = 0; i < this.options.slices; i++) {
136
+
137
+ bar = UI.$('<div class="uk-cover-background"></div>').css({
138
+ 'position' : 'absolute',
139
+ 'top' : 0,
140
+ 'left' : 0,
141
+ 'width' : ghostWidth,
142
+ 'height' : ghostHeight,
143
+ 'background-image' : bgimage,
144
+ 'transform-origin' : (sliceWidth*i)+'px 0 0',
145
+ 'clip' : ('rect(0px, '+(sliceWidth*(i+1))+'px, '+ghostHeight+'px, '+(sliceWidth*i)+'px)'),
146
+ 'opacity' : 0,
147
+ 'transform' : 'scaleX(0.000001)',
148
+ 'transition' : 'all '+this.options.duration+'ms ease-in-out '+(100+i*60)+'ms',
149
+ '-webkit-transition' : 'all '+this.options.duration+'ms ease-in-out '+(100+i*60)+'ms'
150
+ });
151
+
152
+ ghost.prepend(bar);
153
+ }
154
+
155
+ this.container.append(ghost);
156
+
157
+ ghost.width();
158
+
159
+ ghost.children().first().on(UI.support.transition.end, function() {
160
+
161
+ setTimeout(ghost.remove.bind(ghost), 0);
162
+
163
+ d.resolve();
164
+ }).end().css({
165
+ 'transform': 'scaleX(1)',
166
+ 'opacity': 1
167
+ });
168
+
169
+ return d.promise();
170
+ },
171
+
172
+ puzzle: function(current, next, dir) {
173
+
174
+ if (!next.data('cover')) {
175
+ return Animations.fade.apply(this, arguments);
176
+ }
177
+
178
+ var d = UI.$.Deferred(), $this = this;
179
+
180
+ var boxCols = Math.round(this.options.slices/2),
181
+ boxWidth = Math.round(next.width()/boxCols),
182
+ boxRows = Math.round(next.height()/boxWidth),
183
+ boxHeight = Math.round(next.height()/boxRows)+1,
184
+ bgimage = next.data('cover').css('background-image'),
185
+ ghost = UI.$('<li></li>').css({
186
+ width : this.container.width(),
187
+ height : this.container.height(),
188
+ opacity : 1,
189
+ zIndex : 15
190
+ }),
191
+ ghostWidth = this.container.width(),
192
+ ghostHeight = this.container.height(),
193
+ box, rect, width;
194
+
195
+ for (var rows = 0; rows < boxRows; rows++) {
196
+
197
+ for (var cols = 0; cols < boxCols; cols++) {
198
+
199
+ width = (cols == boxCols-1) ? (boxWidth + 2) : boxWidth;
200
+
201
+ rect = [
202
+ (boxHeight * rows) +'px', // top
203
+ (width * (cols+1)) +'px', // right
204
+ (boxHeight * (rows + 1)) +'px', // bottom
205
+ (boxWidth * cols) +'px' // left
206
+ ];
207
+
208
+ box = UI.$('<div class="uk-cover-background"></div>').css({
209
+ 'position' : 'absolute',
210
+ 'top' : 0,
211
+ 'left' : 0,
212
+ 'opacity' : 0,
213
+ 'width' : ghostWidth,
214
+ 'height' : ghostHeight,
215
+ 'background-image' : bgimage,
216
+ 'clip' : ('rect('+rect.join(',')+')'),
217
+ '-webkit-transform' : 'translateZ(0)', // fixes webkit opacity flickering bug
218
+ 'transform' : 'translateZ(0)' // fixes moz opacity flickering bug
219
+ });
220
+
221
+ ghost.append(box);
222
+ }
223
+ }
224
+
225
+ this.container.append(ghost);
226
+
227
+ var boxes = shuffle(ghost.children());
228
+
229
+ boxes.each(function(i) {
230
+ UI.$(this).css({
231
+ 'transition': 'all '+$this.options.duration+'ms ease-in-out '+(50+i*25)+'ms',
232
+ '-webkit-transition': 'all '+$this.options.duration+'ms ease-in-out '+(50+i*25)+'ms'
233
+ });
234
+ }).last().on(UI.support.transition.end, function() {
235
+
236
+ setTimeout(ghost.remove.bind(ghost), 0);
237
+
238
+ d.resolve();
239
+ });
240
+
241
+ ghost.width();
242
+
243
+ boxes.css({'opacity': 1});
244
+
245
+ return d.promise();
246
+ },
247
+
248
+ boxes: function(current, next, dir, fromfx) {
249
+
250
+ if (!next.data('cover')) {
251
+ return Animations.fade.apply(this, arguments);
252
+ }
253
+
254
+ var d = UI.$.Deferred();
255
+
256
+ var boxCols = Math.round(this.options.slices/2),
257
+ boxWidth = Math.round(next.width()/boxCols),
258
+ boxRows = Math.round(next.height()/boxWidth),
259
+ boxHeight = Math.round(next.height()/boxRows)+1,
260
+ bgimage = next.data('cover').css('background-image'),
261
+ ghost = UI.$('<li></li>').css({
262
+ width : next.width(),
263
+ height : next.height(),
264
+ opacity : 1,
265
+ zIndex : 15
266
+ }),
267
+ ghostWidth = next.width(),
268
+ ghostHeight = next.height(),
269
+ box, rect, width, cols;
270
+
271
+ for (var rows = 0; rows < boxRows; rows++) {
272
+
273
+ for (cols = 0; cols < boxCols; cols++) {
274
+
275
+ width = (cols == boxCols-1) ? (boxWidth + 2) : boxWidth;
276
+
277
+ rect = [
278
+ (boxHeight * rows) +'px', // top
279
+ (width * (cols+1)) +'px', // right
280
+ (boxHeight * (rows + 1)) +'px', // bottom
281
+ (boxWidth * cols) +'px' // left
282
+ ];
283
+
284
+ box = UI.$('<div class="uk-cover-background"></div>').css({
285
+ 'position' : 'absolute',
286
+ 'top' : 0,
287
+ 'left' : 0,
288
+ 'opacity' : 1,
289
+ 'width' : ghostWidth,
290
+ 'height' : ghostHeight,
291
+ 'background-image' : bgimage,
292
+ 'transform-origin' : rect[3]+' '+rect[0]+' 0',
293
+ 'clip' : ('rect('+rect.join(',')+')'),
294
+ '-webkit-transform' : 'scale(0.0000000000000001)',
295
+ 'transform' : 'scale(0.0000000000000001)'
296
+ });
297
+
298
+ ghost.append(box);
299
+ }
300
+ }
301
+
302
+ this.container.append(ghost);
303
+
304
+ var rowIndex = 0, colIndex = 0, timeBuff = 0, box2Darr = [[]], boxes = ghost.children(), prevCol;
305
+
306
+ if (fromfx == 'boxes-reverse') {
307
+ boxes = [].reverse.apply(boxes);
308
+ }
309
+
310
+ boxes.each(function() {
311
+
312
+ box2Darr[rowIndex][colIndex] = UI.$(this);
313
+ colIndex++;
314
+
315
+ if(colIndex == boxCols) {
316
+ rowIndex++;
317
+ colIndex = 0;
318
+ box2Darr[rowIndex] = [];
319
+ }
320
+ });
321
+
322
+ for (cols = 0, prevCol = 0; cols < (boxCols * boxRows); cols++) {
323
+
324
+ prevCol = cols;
325
+
326
+ for (var row = 0; row < boxRows; row++) {
327
+
328
+ if (prevCol >= 0 && prevCol < boxCols) {
329
+
330
+ box2Darr[row][prevCol].css({
331
+ 'transition': 'all '+this.options.duration+'ms linear '+(50+timeBuff)+'ms',
332
+ '-webkit-transition': 'all '+this.options.duration+'ms linear '+(50+timeBuff)+'ms'
333
+ });
334
+ }
335
+ prevCol--;
336
+ }
337
+ timeBuff += 100;
338
+ }
339
+
340
+ boxes.last().on(UI.support.transition.end, function() {
341
+
342
+ setTimeout(ghost.remove.bind(ghost), 0);
343
+
344
+ d.resolve();
345
+ });
346
+
347
+ ghost.width();
348
+
349
+ boxes.css({
350
+ '-webkit-transform': 'scale(1)',
351
+ 'transform': 'scale(1)'
352
+ });
353
+
354
+ return d.promise();
355
+ },
356
+
357
+ 'boxes-reverse': function(current, next, dir) {
358
+ return Animations.boxes.apply(this, [current, next, dir, 'boxes-reverse']);
359
+ },
360
+
361
+ 'random-fx': function(){
362
+
363
+ var animations = ['slice-up', 'fold', 'puzzle', 'slice-down', 'boxes', 'slice-up-down', 'boxes-reverse'];
364
+
365
+ this.fxIndex = (this.fxIndex === undefined ? -1 : this.fxIndex) + 1;
366
+
367
+ if (!animations[this.fxIndex]) this.fxIndex = 0;
368
+
369
+ return Animations[animations[this.fxIndex]].apply(this, arguments);
370
+ }
371
+ });
372
+
373
+
374
+ // helper functions
375
+
376
+ // Shuffle an array
377
+ var shuffle = function(arr) {
378
+ for (var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x) {}
379
+ return arr;
380
+ };
381
+
382
+ return UI.slideshow.animations;
383
+ });
@@ -0,0 +1,596 @@
1
+ /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2
+ (function(addon) {
3
+
4
+ var component;
5
+
6
+ if (window.UIkit) {
7
+ component = addon(UIkit);
8
+ }
9
+
10
+ if (typeof define == "function" && define.amd) {
11
+ define("uikit-slideshow", ["uikit"], function() {
12
+ return component || addon(UIkit);
13
+ });
14
+ }
15
+
16
+ })(function(UI) {
17
+
18
+ "use strict";
19
+
20
+ var Animations, playerId = 0;
21
+
22
+ UI.component('slideshow', {
23
+
24
+ defaults: {
25
+ animation : "fade",
26
+ duration : 500,
27
+ height : "auto",
28
+ start : 0,
29
+ autoplay : false,
30
+ autoplayInterval : 7000,
31
+ videoautoplay : true,
32
+ videomute : true,
33
+ slices : 15,
34
+ pauseOnHover : true,
35
+ kenburns : false,
36
+ kenburnsanimations : [
37
+ 'uk-animation-middle-left',
38
+ 'uk-animation-top-right',
39
+ 'uk-animation-bottom-left',
40
+ 'uk-animation-top-center',
41
+ '', // middle-center
42
+ 'uk-animation-bottom-right'
43
+ ]
44
+ },
45
+
46
+ current : false,
47
+ interval : null,
48
+ hovering : false,
49
+
50
+ boot: function() {
51
+
52
+ // init code
53
+ UI.ready(function(context) {
54
+
55
+ UI.$('[data-uk-slideshow]', context).each(function() {
56
+
57
+ var slideshow = UI.$(this);
58
+
59
+ if (!slideshow.data("slideshow")) {
60
+ UI.slideshow(slideshow, UI.Utils.options(slideshow.attr("data-uk-slideshow")));
61
+ }
62
+ });
63
+ });
64
+ },
65
+
66
+ init: function() {
67
+
68
+ var $this = this;
69
+
70
+ this.container = this.element.hasClass('uk-slideshow') ? this.element : UI.$(this.find('.uk-slideshow:first'));
71
+ this.current = this.options.start;
72
+ this.animating = false;
73
+
74
+ this.fixFullscreen = navigator.userAgent.match(/(iPad|iPhone|iPod)/g) && this.container.hasClass('uk-slideshow-fullscreen'); // viewport unit fix for height:100vh - should be fixed in iOS 8
75
+
76
+ if (this.options.kenburns) {
77
+
78
+ this.kbanimduration = this.options.kenburns === true ? '15s': this.options.kenburns;
79
+
80
+ if (!String(this.kbanimduration).match(/(ms|s)$/)) {
81
+ this.kbanimduration += 'ms';
82
+ }
83
+
84
+ if (typeof(this.options.kenburnsanimations) == 'string') {
85
+ this.options.kenburnsanimations = this.options.kenburnsanimations.split(',');
86
+ }
87
+ }
88
+
89
+ this.update();
90
+
91
+ this.on("click.uk.slideshow", '[data-uk-slideshow-item]', function(e) {
92
+
93
+ e.preventDefault();
94
+
95
+ var slide = UI.$(this).attr('data-uk-slideshow-item');
96
+
97
+ if ($this.current == slide) return;
98
+
99
+ switch(slide) {
100
+ case 'next':
101
+ case 'previous':
102
+ $this[slide=='next' ? 'next':'previous']();
103
+ break;
104
+ default:
105
+ $this.show(parseInt(slide, 10));
106
+ }
107
+
108
+ $this.stop();
109
+ });
110
+
111
+ UI.$win.on("resize load", UI.Utils.debounce(function() {
112
+ $this.resize();
113
+
114
+ if ($this.fixFullscreen) {
115
+ $this.container.css('height', window.innerHeight);
116
+ $this.slides.css('height', window.innerHeight);
117
+ }
118
+ }, 100));
119
+
120
+ // chrome image load fix
121
+ setTimeout(function(){
122
+ $this.resize();
123
+ }, 80);
124
+
125
+ // Set autoplay
126
+ if (this.options.autoplay) {
127
+ this.start();
128
+ }
129
+
130
+ if (this.options.videoautoplay && this.slides.eq(this.current).data('media')) {
131
+ this.playmedia(this.slides.eq(this.current).data('media'));
132
+ }
133
+
134
+ if (this.options.kenburns) {
135
+ this.applyKenBurns(this.slides.eq(this.current));
136
+ }
137
+
138
+ this.container.on({
139
+ mouseenter: function() { if ($this.options.pauseOnHover) $this.hovering = true; },
140
+ mouseleave: function() { $this.hovering = false; }
141
+ });
142
+
143
+ this.on('swipeRight swipeLeft', function(e) {
144
+ $this[e.type=='swipeLeft' ? 'next' : 'previous']();
145
+ });
146
+
147
+ this.on('display.uk.check', function(){
148
+ if ($this.element.is(":visible")) {
149
+
150
+ $this.resize();
151
+
152
+ if ($this.fixFullscreen) {
153
+ $this.container.css('height', window.innerHeight);
154
+ $this.slides.css('height', window.innerHeight);
155
+ }
156
+ }
157
+ });
158
+
159
+ UI.domObserve(this.element, function(e) {
160
+ if ($this.container.children(':not([data-slide])').length) {
161
+ $this.update(true);
162
+ }
163
+ });
164
+ },
165
+
166
+ update: function(resize) {
167
+
168
+ var $this = this, canvas, processed = 0;
169
+
170
+ this.slides = this.container.children();
171
+ this.slidesCount = this.slides.length;
172
+
173
+ if (!this.slides.eq(this.current).length) {
174
+ this.current = 0;
175
+ }
176
+
177
+ this.slides.each(function(index) {
178
+
179
+ var slide = UI.$(this);
180
+
181
+ if (slide.data('processed')) {
182
+ return;
183
+ }
184
+
185
+ var media = slide.children('img,video,iframe').eq(0), type = 'html';
186
+
187
+ slide.data('media', media);
188
+ slide.data('sizer', media);
189
+
190
+ if (media.length) {
191
+
192
+ var placeholder;
193
+
194
+ type = media[0].nodeName.toLowerCase();
195
+
196
+ switch(media[0].nodeName) {
197
+ case 'IMG':
198
+
199
+ var cover = UI.$('<div class="uk-cover-background uk-position-cover"></div>').css({'background-image':'url('+ media.attr('src') + ')'});
200
+
201
+ if (media.attr('width') && media.attr('height')) {
202
+ placeholder = UI.$('<canvas></canvas>').attr({width:media.attr('width'), height:media.attr('height')});
203
+ media.replaceWith(placeholder);
204
+ media = placeholder;
205
+ placeholder = undefined;
206
+ }
207
+
208
+ media.css({width: '100%',height: 'auto', opacity:0});
209
+ slide.prepend(cover).data('cover', cover);
210
+ break;
211
+
212
+ case 'IFRAME':
213
+
214
+ var src = media[0].src, iframeId = 'sw-'+(++playerId);
215
+
216
+ media
217
+ .attr('src', '').on('load', function(){
218
+
219
+ if (index !== $this.current || (index == $this.current && !$this.options.videoautoplay)) {
220
+ $this.pausemedia(media);
221
+ }
222
+
223
+ if ($this.options.videomute) {
224
+
225
+ $this.mutemedia(media);
226
+
227
+ var inv = setInterval((function(ic) {
228
+ return function() {
229
+ $this.mutemedia(media);
230
+ if (++ic >= 4) clearInterval(inv);
231
+ }
232
+ })(0), 250);
233
+ }
234
+
235
+ })
236
+ .data('slideshow', $this) // add self-reference for the vimeo-ready listener
237
+ .attr('data-player-id', iframeId) // add frameId for the vimeo-ready listener
238
+ .attr('src', [src, (src.indexOf('?') > -1 ? '&':'?'), 'enablejsapi=1&api=1&player_id='+iframeId].join(''))
239
+ .addClass('uk-position-absolute');
240
+
241
+ // disable pointer events
242
+ if(!UI.support.touch) media.css('pointer-events', 'none');
243
+
244
+ placeholder = true;
245
+
246
+ if (UI.cover) {
247
+ UI.cover(media);
248
+ media.attr('data-uk-cover', '{}');
249
+ }
250
+
251
+ break;
252
+
253
+ case 'VIDEO':
254
+ media.addClass('uk-cover-object uk-position-absolute');
255
+ placeholder = true;
256
+
257
+ if ($this.options.videomute) $this.mutemedia(media);
258
+ }
259
+
260
+ if (placeholder) {
261
+
262
+ canvas = UI.$('<canvas></canvas>').attr({'width': media[0].width, 'height': media[0].height});
263
+ var img = UI.$('<img style="width:100%;height:auto;">').attr('src', canvas[0].toDataURL());
264
+
265
+ slide.prepend(img);
266
+ slide.data('sizer', img);
267
+ }
268
+
269
+ } else {
270
+ slide.data('sizer', slide);
271
+ }
272
+
273
+ if ($this.hasKenBurns(slide)) {
274
+
275
+ slide.data('cover').css({
276
+ '-webkit-animation-duration': $this.kbanimduration,
277
+ 'animation-duration': $this.kbanimduration
278
+ });
279
+ }
280
+
281
+ slide.data('processed', ++processed);
282
+ slide.attr('data-slide', type);
283
+ });
284
+
285
+ if (processed) {
286
+
287
+ this.triggers = this.find('[data-uk-slideshow-item]');
288
+
289
+ // Set start slide
290
+ this.slides.attr('aria-hidden', 'true').removeClass('uk-active').eq(this.current).addClass('uk-active').attr('aria-hidden', 'false');
291
+ this.triggers.filter('[data-uk-slideshow-item="'+this.current+'"]').addClass('uk-active');
292
+ }
293
+
294
+ if (resize && processed) {
295
+ this.resize();
296
+ }
297
+ },
298
+
299
+ resize: function() {
300
+
301
+ if (this.container.hasClass('uk-slideshow-fullscreen')) return;
302
+
303
+ var height = this.options.height;
304
+
305
+ if (this.options.height === 'auto') {
306
+
307
+ height = 0;
308
+
309
+ this.slides.css('height', '').each(function() {
310
+ height = Math.max(height, UI.$(this).height());
311
+ });
312
+ }
313
+
314
+ this.container.css('height', height);
315
+ this.slides.css('height', height);
316
+ },
317
+
318
+ show: function(index, direction) {
319
+
320
+ if (this.animating || this.current == index) return;
321
+
322
+ this.animating = true;
323
+
324
+ var $this = this,
325
+ current = this.slides.eq(this.current),
326
+ next = this.slides.eq(index),
327
+ dir = direction ? direction : this.current < index ? 1 : -1,
328
+ currentmedia = current.data('media'),
329
+ animation = Animations[this.options.animation] ? this.options.animation : 'fade',
330
+ nextmedia = next.data('media'),
331
+ finalize = function() {
332
+
333
+ if (!$this.animating) return;
334
+
335
+ if (currentmedia && currentmedia.is('video,iframe')) {
336
+ $this.pausemedia(currentmedia);
337
+ }
338
+
339
+ if (nextmedia && nextmedia.is('video,iframe')) {
340
+ $this.playmedia(nextmedia);
341
+ }
342
+
343
+ next.addClass("uk-active").attr('aria-hidden', 'false');
344
+ current.removeClass("uk-active").attr('aria-hidden', 'true');
345
+
346
+ $this.animating = false;
347
+ $this.current = index;
348
+
349
+ UI.Utils.checkDisplay(next, '[class*="uk-animation-"]:not(.uk-cover-background.uk-position-cover)');
350
+
351
+ $this.trigger('show.uk.slideshow', [next, current, $this]);
352
+ };
353
+
354
+ $this.applyKenBurns(next);
355
+
356
+ // animation fallback
357
+ if (!UI.support.animation) {
358
+ animation = 'none';
359
+ }
360
+
361
+ current = UI.$(current);
362
+ next = UI.$(next);
363
+
364
+ $this.trigger('beforeshow.uk.slideshow', [next, current, $this]);
365
+
366
+ Animations[animation].apply(this, [current, next, dir]).then(finalize);
367
+
368
+ $this.triggers.removeClass('uk-active');
369
+ $this.triggers.filter('[data-uk-slideshow-item="'+index+'"]').addClass('uk-active');
370
+ },
371
+
372
+ applyKenBurns: function(slide) {
373
+
374
+ if (!this.hasKenBurns(slide)) {
375
+ return;
376
+ }
377
+
378
+ var animations = this.options.kenburnsanimations,
379
+ index = this.kbindex || 0;
380
+
381
+
382
+ slide.data('cover').attr('class', 'uk-cover-background uk-position-cover').width();
383
+ slide.data('cover').addClass(['uk-animation-scale', 'uk-animation-reverse', animations[index].trim()].join(' '));
384
+
385
+ this.kbindex = animations[index + 1] ? (index+1):0;
386
+ },
387
+
388
+ hasKenBurns: function(slide) {
389
+ return (this.options.kenburns && slide.data('cover'));
390
+ },
391
+
392
+ next: function() {
393
+ this.show(this.slides[this.current + 1] ? (this.current + 1) : 0, 1);
394
+ },
395
+
396
+ previous: function() {
397
+ this.show(this.slides[this.current - 1] ? (this.current - 1) : (this.slides.length - 1), -1);
398
+ },
399
+
400
+ start: function() {
401
+
402
+ this.stop();
403
+
404
+ var $this = this;
405
+
406
+ this.interval = setInterval(function() {
407
+ if (!$this.hovering) $this.next();
408
+ }, this.options.autoplayInterval);
409
+
410
+ },
411
+
412
+ stop: function() {
413
+ if (this.interval) clearInterval(this.interval);
414
+ },
415
+
416
+ playmedia: function(media) {
417
+
418
+ if (!(media && media[0])) return;
419
+
420
+ switch(media[0].nodeName) {
421
+ case 'VIDEO':
422
+
423
+ if (!this.options.videomute) {
424
+ media[0].muted = false;
425
+ }
426
+
427
+ media[0].play();
428
+ break;
429
+ case 'IFRAME':
430
+
431
+ if (!this.options.videomute) {
432
+ media[0].contentWindow.postMessage('{ "event": "command", "func": "unmute", "method":"setVolume", "value":1}', '*');
433
+ }
434
+
435
+ media[0].contentWindow.postMessage('{ "event": "command", "func": "playVideo", "method":"play"}', '*');
436
+ break;
437
+ }
438
+ },
439
+
440
+ pausemedia: function(media) {
441
+
442
+ switch(media[0].nodeName) {
443
+ case 'VIDEO':
444
+ media[0].pause();
445
+ break;
446
+ case 'IFRAME':
447
+ media[0].contentWindow.postMessage('{ "event": "command", "func": "pauseVideo", "method":"pause"}', '*');
448
+ break;
449
+ }
450
+ },
451
+
452
+ mutemedia: function(media) {
453
+
454
+ switch(media[0].nodeName) {
455
+ case 'VIDEO':
456
+ media[0].muted = true;
457
+ break;
458
+ case 'IFRAME':
459
+ media[0].contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}', '*');
460
+ break;
461
+ }
462
+ }
463
+ });
464
+
465
+ Animations = {
466
+
467
+ 'none': function() {
468
+
469
+ var d = UI.$.Deferred();
470
+ d.resolve();
471
+ return d.promise();
472
+ },
473
+
474
+ 'scroll': function(current, next, dir) {
475
+
476
+ var d = UI.$.Deferred();
477
+
478
+ current.css('animation-duration', this.options.duration+'ms');
479
+ next.css('animation-duration', this.options.duration+'ms');
480
+
481
+ next.css('opacity', 1).one(UI.support.animation.end, function() {
482
+
483
+ current.css('opacity', 0).removeClass(dir == -1 ? 'uk-slideshow-scroll-backward-out' : 'uk-slideshow-scroll-forward-out');
484
+ next.removeClass(dir == -1 ? 'uk-slideshow-scroll-backward-in' : 'uk-slideshow-scroll-forward-in');
485
+ d.resolve();
486
+
487
+ }.bind(this));
488
+
489
+ current.addClass(dir == -1 ? 'uk-slideshow-scroll-backward-out' : 'uk-slideshow-scroll-forward-out');
490
+ next.addClass(dir == -1 ? 'uk-slideshow-scroll-backward-in' : 'uk-slideshow-scroll-forward-in');
491
+ next.width(); // force redraw
492
+
493
+ return d.promise();
494
+ },
495
+
496
+ 'swipe': function(current, next, dir) {
497
+
498
+ var d = UI.$.Deferred();
499
+
500
+ current.css('animation-duration', this.options.duration+'ms');
501
+ next.css('animation-duration', this.options.duration+'ms');
502
+
503
+ next.css('opacity', 1).one(UI.support.animation.end, function() {
504
+
505
+ current.css('opacity', 0).removeClass(dir === -1 ? 'uk-slideshow-swipe-backward-out' : 'uk-slideshow-swipe-forward-out');
506
+ next.removeClass(dir === -1 ? 'uk-slideshow-swipe-backward-in' : 'uk-slideshow-swipe-forward-in');
507
+ d.resolve();
508
+
509
+ }.bind(this));
510
+
511
+ current.addClass(dir == -1 ? 'uk-slideshow-swipe-backward-out' : 'uk-slideshow-swipe-forward-out');
512
+ next.addClass(dir == -1 ? 'uk-slideshow-swipe-backward-in' : 'uk-slideshow-swipe-forward-in');
513
+ next.width(); // force redraw
514
+
515
+ return d.promise();
516
+ },
517
+
518
+ 'scale': function(current, next, dir) {
519
+
520
+ var d = UI.$.Deferred();
521
+
522
+ current.css('animation-duration', this.options.duration+'ms');
523
+ next.css('animation-duration', this.options.duration+'ms');
524
+
525
+ next.css('opacity', 1);
526
+
527
+ current.one(UI.support.animation.end, function() {
528
+
529
+ current.css('opacity', 0).removeClass('uk-slideshow-scale-out');
530
+ d.resolve();
531
+
532
+ }.bind(this));
533
+
534
+ current.addClass('uk-slideshow-scale-out');
535
+ current.width(); // force redraw
536
+
537
+ return d.promise();
538
+ },
539
+
540
+ 'fade': function(current, next, dir) {
541
+
542
+ var d = UI.$.Deferred();
543
+
544
+ current.css('animation-duration', this.options.duration+'ms');
545
+ next.css('animation-duration', this.options.duration+'ms');
546
+
547
+ next.css('opacity', 1);
548
+
549
+ // for plain text content slides - looks smoother
550
+ if (!(next.data('cover') || next.data('placeholder'))) {
551
+
552
+ next.css('opacity', 1).one(UI.support.animation.end, function() {
553
+ next.removeClass('uk-slideshow-fade-in');
554
+ }).addClass('uk-slideshow-fade-in');
555
+ }
556
+
557
+ current.one(UI.support.animation.end, function() {
558
+
559
+ current.css('opacity', 0).removeClass('uk-slideshow-fade-out');
560
+ d.resolve();
561
+
562
+ }.bind(this));
563
+
564
+ current.addClass('uk-slideshow-fade-out');
565
+ current.width(); // force redraw
566
+
567
+ return d.promise();
568
+ }
569
+ };
570
+
571
+ UI.slideshow.animations = Animations;
572
+
573
+ // Listen for messages from the vimeo player
574
+ window.addEventListener('message', function onMessageReceived(e) {
575
+
576
+ var data = e.data, iframe;
577
+
578
+ if (typeof(data) == 'string') {
579
+
580
+ try {
581
+ data = JSON.parse(data);
582
+ } catch(err) {
583
+ data = {};
584
+ }
585
+ }
586
+
587
+ if (e.origin && e.origin.indexOf('vimeo') > -1 && data.event == 'ready' && data.player_id) {
588
+ iframe = UI.$('[data-player-id="'+ data.player_id+'"]');
589
+
590
+ if (iframe.length) {
591
+ iframe.data('slideshow').mutemedia(iframe);
592
+ }
593
+ }
594
+ }, false);
595
+
596
+ });