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,591 @@
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) { // AMD
11
+ define("uikit-lightbox", ["uikit"], function(){
12
+ return component || addon(UIkit);
13
+ });
14
+ }
15
+
16
+ })(function(UI){
17
+
18
+ "use strict";
19
+
20
+ var modal, cache = {};
21
+
22
+ UI.component('lightbox', {
23
+
24
+ defaults: {
25
+ allowfullscreen : true,
26
+ duration : 400,
27
+ group : false,
28
+ keyboard : true
29
+ },
30
+
31
+ index : 0,
32
+ items : false,
33
+
34
+ boot: function() {
35
+
36
+ UI.$html.on('click', '[data-uk-lightbox]', function(e){
37
+
38
+ e.preventDefault();
39
+
40
+ var link = UI.$(this);
41
+
42
+ if (!link.data("lightbox")) {
43
+
44
+ UI.lightbox(link, UI.Utils.options(link.attr("data-uk-lightbox")));
45
+ }
46
+
47
+ link.data("lightbox").show(link);
48
+ });
49
+
50
+ // keyboard navigation
51
+ UI.$doc.on('keyup', function(e) {
52
+
53
+ if (modal && modal.is(':visible') && modal.lightbox.options.keyboard) {
54
+
55
+ e.preventDefault();
56
+
57
+ switch(e.keyCode) {
58
+ case 37:
59
+ modal.lightbox.previous();
60
+ break;
61
+ case 39:
62
+ modal.lightbox.next();
63
+ break;
64
+ }
65
+ }
66
+ });
67
+ },
68
+
69
+ init: function() {
70
+
71
+ var siblings = [];
72
+
73
+ this.index = 0;
74
+ this.siblings = [];
75
+
76
+ if (this.element && this.element.length) {
77
+
78
+ var domSiblings = this.options.group ? UI.$([
79
+ '[data-uk-lightbox*="'+this.options.group+'"]',
80
+ "[data-uk-lightbox*='"+this.options.group+"']"
81
+ ].join(',')) : this.element;
82
+
83
+ domSiblings.each(function() {
84
+
85
+ var ele = UI.$(this);
86
+
87
+ siblings.push({
88
+ 'source': ele.attr('href'),
89
+ 'title' : ele.attr('data-title') || ele.attr('title'),
90
+ 'type' : ele.attr("data-lightbox-type") || 'auto',
91
+ 'link' : ele
92
+ });
93
+ });
94
+
95
+ this.index = domSiblings.index(this.element);
96
+ this.siblings = siblings;
97
+
98
+ } else if (this.options.group && this.options.group.length) {
99
+ this.siblings = this.options.group;
100
+ }
101
+
102
+ this.trigger('lightbox-init', [this]);
103
+ },
104
+
105
+ show: function(index) {
106
+
107
+ this.modal = getModal(this);
108
+
109
+ // stop previous animation
110
+ this.modal.dialog.stop();
111
+ this.modal.content.stop();
112
+
113
+ var $this = this, promise = UI.$.Deferred(), data, item;
114
+
115
+ index = index || 0;
116
+
117
+ // index is a jQuery object or DOM element
118
+ if (typeof(index) == 'object') {
119
+
120
+ this.siblings.forEach(function(s, idx){
121
+
122
+ if (index[0] === s.link[0]) {
123
+ index = idx;
124
+ }
125
+ });
126
+ }
127
+
128
+ // fix index if needed
129
+ if ( index < 0 ) {
130
+ index = this.siblings.length - index;
131
+ } else if (!this.siblings[index]) {
132
+ index = 0;
133
+ }
134
+
135
+ item = this.siblings[index];
136
+
137
+ data = {
138
+ lightbox : $this,
139
+ source : item.source,
140
+ type : item.type,
141
+ index : index,
142
+ promise : promise,
143
+ title : item.title,
144
+ item : item,
145
+ meta : {
146
+ content : '',
147
+ width : null,
148
+ height : null
149
+ }
150
+ };
151
+
152
+ this.index = index;
153
+
154
+ this.modal.content.empty();
155
+
156
+ if (!this.modal.is(':visible')) {
157
+ this.modal.content.css({width:'', height:''}).empty();
158
+ this.modal.modal.show();
159
+ }
160
+
161
+ this.modal.loader.removeClass('uk-hidden');
162
+
163
+ promise.promise().done(function() {
164
+
165
+ $this.data = data;
166
+ $this.fitSize(data);
167
+
168
+ }).fail(function(){
169
+
170
+ data.meta.content = '<div class="uk-position-cover uk-flex uk-flex-middle uk-flex-center"><strong>Loading resource failed!</strong></div>';
171
+ data.meta.width = 400;
172
+ data.meta.height = 300;
173
+
174
+ $this.data = data;
175
+ $this.fitSize(data);
176
+ });
177
+
178
+ $this.trigger('showitem.uk.lightbox', [data]);
179
+ },
180
+
181
+ fitSize: function() {
182
+
183
+ var $this = this,
184
+ data = this.data,
185
+ pad = this.modal.dialog.outerWidth() - this.modal.dialog.width(),
186
+ dpadTop = parseInt(this.modal.dialog.css('margin-top'), 10),
187
+ dpadBot = parseInt(this.modal.dialog.css('margin-bottom'), 10),
188
+ dpad = dpadTop + dpadBot,
189
+ content = data.meta.content,
190
+ duration = $this.options.duration;
191
+
192
+ if (this.siblings.length > 1) {
193
+
194
+ content = [
195
+ content,
196
+ '<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-previous uk-hidden-touch" data-lightbox-previous></a>',
197
+ '<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-next uk-hidden-touch" data-lightbox-next></a>'
198
+ ].join('');
199
+ }
200
+
201
+ // calculate width
202
+ var tmp = UI.$('<div>&nbsp;</div>').css({
203
+ opacity : 0,
204
+ position : 'absolute',
205
+ top : 0,
206
+ left : 0,
207
+ width : '100%',
208
+ 'max-width' : $this.modal.dialog.css('max-width'),
209
+ padding : $this.modal.dialog.css('padding'),
210
+ margin : $this.modal.dialog.css('margin')
211
+ }), maxwidth, maxheight, w = data.meta.width, h = data.meta.height;
212
+
213
+ tmp.appendTo('body').width();
214
+
215
+ maxwidth = tmp.width();
216
+ maxheight = window.innerHeight - dpad;
217
+
218
+ tmp.remove();
219
+
220
+ this.modal.dialog.find('.uk-modal-caption').remove();
221
+
222
+ if (data.title) {
223
+ this.modal.dialog.append('<div class="uk-modal-caption">'+data.title+'</div>');
224
+ maxheight -= this.modal.dialog.find('.uk-modal-caption').outerHeight();
225
+ }
226
+
227
+ if (maxwidth < data.meta.width) {
228
+
229
+ h = Math.floor( h * (maxwidth / w) );
230
+ w = maxwidth;
231
+ }
232
+
233
+ if (maxheight < h) {
234
+
235
+ h = Math.floor(maxheight);
236
+ w = Math.ceil(data.meta.width * (maxheight/data.meta.height));
237
+ }
238
+
239
+ this.modal.content.css('opacity', 0).width(w).html(content);
240
+
241
+ if (data.type == 'iframe') {
242
+ this.modal.content.find('iframe:first').height(h);
243
+ }
244
+
245
+ var dh = h + pad,
246
+ t = Math.floor(window.innerHeight/2 - dh/2) - dpad;
247
+
248
+ if (t < 0) { t = 0; }
249
+
250
+ this.modal.closer.addClass('uk-hidden');
251
+
252
+ if ($this.modal.data('mwidth') == w && $this.modal.data('mheight') == h) {
253
+ duration = 0;
254
+ }
255
+
256
+ this.modal.dialog.animate({width: w + pad, height: h + pad, top: t }, duration, 'swing', function() {
257
+ $this.modal.loader.addClass('uk-hidden');
258
+ $this.modal.content.css({width:''}).animate({'opacity': 1}, function() {
259
+ $this.modal.closer.removeClass('uk-hidden');
260
+ });
261
+
262
+ $this.modal.data({'mwidth': w, 'mheight': h});
263
+ });
264
+ },
265
+
266
+ next: function() {
267
+ this.show(this.siblings[(this.index+1)] ? (this.index+1) : 0);
268
+ },
269
+
270
+ previous: function() {
271
+ this.show(this.siblings[(this.index-1)] ? (this.index-1) : this.siblings.length-1);
272
+ }
273
+ });
274
+
275
+
276
+ // Plugins
277
+
278
+ UI.plugin('lightbox', 'image', {
279
+
280
+ init: function(lightbox) {
281
+
282
+ lightbox.on("showitem.uk.lightbox", function(e, data){
283
+
284
+ if (data.type == 'image' || data.source && data.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)) {
285
+
286
+ var resolve = function(source, width, height) {
287
+
288
+ data.meta = {
289
+ content : '<img class="uk-responsive-width" width="'+width+'" height="'+height+'" src ="'+source+'">',
290
+ width : width,
291
+ height : height
292
+ };
293
+
294
+ data.type = 'image';
295
+
296
+ data.promise.resolve();
297
+ };
298
+
299
+ if (!cache[data.source]) {
300
+
301
+ var img = new Image();
302
+
303
+ img.onerror = function(){
304
+ data.promise.reject('Loading image failed');
305
+ };
306
+
307
+ img.onload = function(){
308
+ cache[data.source] = {width: img.width, height: img.height};
309
+ resolve(data.source, cache[data.source].width, cache[data.source].height);
310
+ };
311
+
312
+ img.src = data.source;
313
+
314
+ } else {
315
+ resolve(data.source, cache[data.source].width, cache[data.source].height);
316
+ }
317
+ }
318
+ });
319
+ }
320
+ });
321
+
322
+ UI.plugin("lightbox", "youtube", {
323
+
324
+ init: function(lightbox) {
325
+
326
+ var youtubeRegExp = /(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,
327
+ youtubeRegExpShort = /youtu\.be\/(.*)/;
328
+
329
+
330
+ lightbox.on("showitem.uk.lightbox", function(e, data){
331
+
332
+ var id, matches, resolve = function(id, width, height) {
333
+
334
+ data.meta = {
335
+ content: '<iframe src="//www.youtube.com/embed/'+id+'" width="'+width+'" height="'+height+'" style="max-width:100%;"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
336
+ width: width,
337
+ height: height
338
+ };
339
+
340
+ data.type = 'iframe';
341
+
342
+ data.promise.resolve();
343
+ };
344
+
345
+ if (matches = data.source.match(youtubeRegExp)) {
346
+ id = matches[2];
347
+ }
348
+
349
+ if (matches = data.source.match(youtubeRegExpShort)) {
350
+ id = matches[1];
351
+ }
352
+
353
+ if (id) {
354
+
355
+ if(!cache[id]) {
356
+
357
+ var img = new Image(), lowres = false;
358
+
359
+ img.onerror = function(){
360
+ cache[id] = {width:640, height:320};
361
+ resolve(id, cache[id].width, cache[id].height);
362
+ };
363
+
364
+ img.onload = function(){
365
+ //youtube default 404 thumb, fall back to lowres
366
+ if (img.width == 120 && img.height == 90) {
367
+ if (!lowres) {
368
+ lowres = true;
369
+ img.src = '//img.youtube.com/vi/' + id + '/0.jpg';
370
+ } else {
371
+ cache[id] = {width: 640, height: 320};
372
+ resolve(id, cache[id].width, cache[id].height);
373
+ }
374
+ } else {
375
+ cache[id] = {width: img.width, height: img.height};
376
+ resolve(id, img.width, img.height);
377
+ }
378
+ };
379
+
380
+ img.src = '//img.youtube.com/vi/'+id+'/maxresdefault.jpg';
381
+
382
+ } else {
383
+ resolve(id, cache[id].width, cache[id].height);
384
+ }
385
+
386
+ e.stopImmediatePropagation();
387
+ }
388
+ });
389
+ }
390
+ });
391
+
392
+
393
+ UI.plugin("lightbox", "vimeo", {
394
+
395
+ init: function(lightbox) {
396
+
397
+ var regex = /(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/, matches;
398
+
399
+
400
+ lightbox.on("showitem.uk.lightbox", function(e, data){
401
+
402
+ var id, resolve = function(id, width, height) {
403
+
404
+ data.meta = {
405
+ content: '<iframe src="//player.vimeo.com/video/'+id+'" width="'+width+'" height="'+height+'" style="width:100%;box-sizing:border-box;"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
406
+ width: width,
407
+ height: height
408
+ };
409
+
410
+ data.type = 'iframe';
411
+
412
+ data.promise.resolve();
413
+ };
414
+
415
+ if (matches = data.source.match(regex)) {
416
+
417
+ id = matches[2];
418
+
419
+ if(!cache[id]) {
420
+
421
+ UI.$.ajax({
422
+ type : 'GET',
423
+ url : '//vimeo.com/api/oembed.json?url=' + encodeURI(data.source),
424
+ jsonp : 'callback',
425
+ dataType : 'jsonp',
426
+ success : function(data) {
427
+ cache[id] = {width:data.width, height:data.height};
428
+ resolve(id, cache[id].width, cache[id].height);
429
+ }
430
+ });
431
+
432
+ } else {
433
+ resolve(id, cache[id].width, cache[id].height);
434
+ }
435
+
436
+ e.stopImmediatePropagation();
437
+ }
438
+ });
439
+ }
440
+ });
441
+
442
+ UI.plugin("lightbox", "video", {
443
+
444
+ init: function(lightbox) {
445
+
446
+ lightbox.on("showitem.uk.lightbox", function(e, data){
447
+
448
+
449
+ var resolve = function(source, width, height) {
450
+
451
+ data.meta = {
452
+ content: '<video class="uk-responsive-width" src="'+source+'" width="'+width+'" height="'+height+'" controls></video>',
453
+ width: width,
454
+ height: height
455
+ };
456
+
457
+ data.type = 'video';
458
+
459
+ data.promise.resolve();
460
+ };
461
+
462
+ if (data.type == 'video' || data.source.match(/\.(mp4|webm|ogv)$/i)) {
463
+
464
+ if (!cache[data.source]) {
465
+
466
+ var vid = UI.$('<video style="position:fixed;visibility:hidden;top:-10000px;"></video>').attr('src', data.source).appendTo('body');
467
+
468
+ var idle = setInterval(function() {
469
+
470
+ if (vid[0].videoWidth) {
471
+ clearInterval(idle);
472
+ cache[data.source] = {width: vid[0].videoWidth, height: vid[0].videoHeight};
473
+ resolve(data.source, cache[data.source].width, cache[data.source].height);
474
+ vid.remove();
475
+ }
476
+
477
+ }, 20);
478
+
479
+ } else {
480
+ resolve(data.source, cache[data.source].width, cache[data.source].height);
481
+ }
482
+ }
483
+ });
484
+ }
485
+ });
486
+
487
+
488
+ UIkit.plugin("lightbox", "iframe", {
489
+
490
+ init: function (lightbox) {
491
+
492
+ lightbox.on("showitem.uk.lightbox", function (e, data) {
493
+
494
+ var resolve = function (source, width, height) {
495
+
496
+ data.meta = {
497
+ content: '<iframe class="uk-responsive-width" src="' + source + '" width="' + width + '" height="' + height + '"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
498
+ width: width,
499
+ height: height
500
+ };
501
+
502
+ data.type = 'iframe';
503
+
504
+ data.promise.resolve();
505
+ };
506
+
507
+ if (data.type === 'iframe' || data.source.match(/\.(html|php)$/)) {
508
+ resolve(data.source, (lightbox.options.width || 800), (lightbox.options.height || 600));
509
+ }
510
+ });
511
+
512
+ }
513
+ });
514
+
515
+ function getModal(lightbox) {
516
+
517
+ if (modal) {
518
+ modal.lightbox = lightbox;
519
+ return modal;
520
+ }
521
+
522
+ // init lightbox container
523
+ modal = UI.$([
524
+ '<div class="uk-modal">',
525
+ '<div class="uk-modal-dialog uk-modal-dialog-lightbox uk-slidenav-position" style="margin-left:auto;margin-right:auto;width:200px;height:200px;top:'+Math.abs(window.innerHeight/2 - 200)+'px;">',
526
+ '<a href="#" class="uk-modal-close uk-close uk-close-alt"></a>',
527
+ '<div class="uk-lightbox-content"></div>',
528
+ '<div class="uk-modal-spinner uk-hidden"></div>',
529
+ '</div>',
530
+ '</div>'
531
+ ].join('')).appendTo('body');
532
+
533
+ modal.dialog = modal.find('.uk-modal-dialog:first');
534
+ modal.content = modal.find('.uk-lightbox-content:first');
535
+ modal.loader = modal.find('.uk-modal-spinner:first');
536
+ modal.closer = modal.find('.uk-close.uk-close-alt');
537
+ modal.modal = UI.modal(modal, {modal:false});
538
+
539
+ // next / previous
540
+ modal.on("swipeRight swipeLeft", function(e) {
541
+ modal.lightbox[e.type=='swipeLeft' ? 'next':'previous']();
542
+ }).on("click", "[data-lightbox-previous], [data-lightbox-next]", function(e){
543
+ e.preventDefault();
544
+ modal.lightbox[UI.$(this).is('[data-lightbox-next]') ? 'next':'previous']();
545
+ });
546
+
547
+ // destroy content on modal hide
548
+ modal.on("hide.uk.modal", function(e) {
549
+ modal.content.html('');
550
+ });
551
+
552
+ var resizeCache = {w: window.innerWidth, h:window.innerHeight};
553
+
554
+ UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(e){
555
+
556
+ if (resizeCache.w !== window.innerWidth && modal.is(':visible') && !UI.Utils.isFullscreen()) {
557
+ modal.lightbox.fitSize();
558
+ }
559
+
560
+ resizeCache = {w: window.innerWidth, h:window.innerHeight};
561
+
562
+ }, 100));
563
+
564
+ modal.lightbox = lightbox;
565
+
566
+ return modal;
567
+ }
568
+
569
+ UI.lightbox.create = function(items, options) {
570
+
571
+ if (!items) return;
572
+
573
+ var group = [], o;
574
+
575
+ items.forEach(function(item) {
576
+
577
+ group.push(UI.$.extend({
578
+ source : '',
579
+ title : '',
580
+ type : 'auto',
581
+ link : false
582
+ }, (typeof(item) == 'string' ? {'source': item} : item)));
583
+ });
584
+
585
+ o = UI.lightbox(UI.$.extend({}, options, {'group':group}));
586
+
587
+ return o;
588
+ };
589
+
590
+ return UI.lightbox;
591
+ });