uikit-sass-rails 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +15 -12
  4. data/lib/uikit/sass/rails/engine.rb +1 -1
  5. data/lib/uikit/sass/rails/version.rb +1 -1
  6. data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
  7. data/vendor/assets/fonts/fontawesome-webfont.otf +0 -0
  8. data/vendor/assets/fonts/fontawesome-webfont.svg +525 -464
  9. data/vendor/assets/fonts/fontawesome-webfont.ttf +0 -0
  10. data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
  11. data/vendor/assets/fonts/fontawesome-webfont.woff2 +0 -0
  12. data/vendor/assets/javascripts/uikit.js +30 -3
  13. data/vendor/assets/javascripts/uikit/components/accordion.js +172 -0
  14. data/vendor/assets/javascripts/uikit/components/autocomplete.js +48 -27
  15. data/vendor/assets/javascripts/uikit/components/datepicker.js +2887 -97
  16. data/vendor/assets/javascripts/uikit/components/form-password.js +24 -19
  17. data/vendor/assets/javascripts/uikit/components/form-select.js +24 -18
  18. data/vendor/assets/javascripts/uikit/components/grid.js +524 -0
  19. data/vendor/assets/javascripts/uikit/components/htmleditor.js +46 -39
  20. data/vendor/assets/javascripts/uikit/components/lightbox.js +543 -0
  21. data/vendor/assets/javascripts/uikit/components/nestable.js +125 -98
  22. data/vendor/assets/javascripts/uikit/components/notify.js +34 -22
  23. data/vendor/assets/javascripts/uikit/components/pagination.js +24 -21
  24. data/vendor/assets/javascripts/uikit/components/parallax.js +400 -0
  25. data/vendor/assets/javascripts/uikit/components/search.js +19 -16
  26. data/vendor/assets/javascripts/uikit/components/slider.js +482 -0
  27. data/vendor/assets/javascripts/uikit/components/slideset.js +498 -0
  28. data/vendor/assets/javascripts/uikit/components/slideshow-fx.js +377 -0
  29. data/vendor/assets/javascripts/uikit/components/slideshow.js +540 -0
  30. data/vendor/assets/javascripts/uikit/components/sortable.js +392 -263
  31. data/vendor/assets/javascripts/uikit/components/sticky.js +127 -68
  32. data/vendor/assets/javascripts/uikit/components/timepicker.js +65 -42
  33. data/vendor/assets/javascripts/uikit/components/tooltip.js +220 -0
  34. data/vendor/assets/javascripts/uikit/components/upload.js +11 -10
  35. data/vendor/assets/javascripts/uikit/core/alert.js +66 -0
  36. data/vendor/assets/javascripts/uikit/core/button.js +154 -0
  37. data/vendor/assets/javascripts/uikit/core/core.js +717 -0
  38. data/vendor/assets/javascripts/uikit/{components → core}/cover.js +41 -35
  39. data/vendor/assets/javascripts/uikit/core/dropdown.js +296 -0
  40. data/vendor/assets/javascripts/uikit/core/grid.js +172 -0
  41. data/vendor/assets/javascripts/uikit/core/modal.js +323 -0
  42. data/vendor/assets/javascripts/uikit/core/nav.js +117 -0
  43. data/vendor/assets/javascripts/uikit/core/offcanvas.js +178 -0
  44. data/vendor/assets/javascripts/uikit/core/scrollspy.js +208 -0
  45. data/vendor/assets/javascripts/uikit/core/smooth-scroll.js +62 -0
  46. data/vendor/assets/javascripts/uikit/core/switcher.js +298 -0
  47. data/vendor/assets/javascripts/uikit/core/tab.js +159 -0
  48. data/vendor/assets/javascripts/uikit/core/toggle.js +117 -0
  49. data/vendor/assets/javascripts/uikit/core/touch.js +173 -0
  50. data/vendor/assets/javascripts/uikit/core/utility.js +157 -0
  51. data/vendor/assets/javascripts/uikit/uikit.js +1538 -871
  52. data/vendor/assets/stylesheets/extra/font-awesome.scss +4 -7
  53. data/vendor/assets/stylesheets/uikit.scss +22 -1
  54. data/vendor/assets/stylesheets/uikit/almost-flat.scss +22 -2
  55. data/vendor/assets/stylesheets/uikit/components/accordion.almost-flat.scss +45 -0
  56. data/vendor/assets/stylesheets/uikit/components/accordion.gradient.scss +45 -0
  57. data/vendor/assets/stylesheets/uikit/components/accordion.scss +43 -0
  58. data/vendor/assets/stylesheets/uikit/components/autocomplete.almost-flat.scss +62 -0
  59. data/vendor/assets/stylesheets/uikit/components/autocomplete.gradient.scss +62 -0
  60. data/vendor/assets/stylesheets/uikit/components/autocomplete.scss +60 -0
  61. data/vendor/assets/stylesheets/uikit/components/datepicker.almost-flat.scss +148 -0
  62. data/vendor/assets/stylesheets/uikit/components/datepicker.gradient.scss +158 -0
  63. data/vendor/assets/stylesheets/uikit/components/datepicker.scss +142 -0
  64. data/vendor/assets/stylesheets/uikit/components/dotnav.almost-flat.scss +152 -0
  65. data/vendor/assets/stylesheets/uikit/components/dotnav.gradient.scss +152 -0
  66. data/vendor/assets/stylesheets/uikit/components/dotnav.scss +148 -0
  67. data/vendor/assets/stylesheets/uikit/components/form-advanced.almost-flat.scss +92 -0
  68. data/vendor/assets/stylesheets/uikit/components/form-advanced.gradient.scss +92 -0
  69. data/vendor/assets/stylesheets/uikit/components/form-advanced.scss +92 -0
  70. data/vendor/assets/stylesheets/uikit/components/form-file.almost-flat.scss +36 -0
  71. data/vendor/assets/stylesheets/uikit/components/form-file.gradient.scss +36 -0
  72. data/vendor/assets/stylesheets/uikit/components/form-file.scss +36 -0
  73. data/vendor/assets/stylesheets/uikit/components/form-password.almost-flat.scss +37 -0
  74. data/vendor/assets/stylesheets/uikit/components/form-password.gradient.scss +37 -0
  75. data/vendor/assets/stylesheets/uikit/components/form-password.scss +37 -0
  76. data/vendor/assets/stylesheets/uikit/components/form-select.almost-flat.scss +37 -0
  77. data/vendor/assets/stylesheets/uikit/components/form-select.gradient.scss +37 -0
  78. data/vendor/assets/stylesheets/uikit/components/form-select.scss +37 -0
  79. data/vendor/assets/stylesheets/uikit/components/htmleditor.almost-flat.scss +282 -0
  80. data/vendor/assets/stylesheets/uikit/components/htmleditor.gradient.scss +290 -0
  81. data/vendor/assets/stylesheets/uikit/components/htmleditor.scss +208 -0
  82. data/vendor/assets/stylesheets/uikit/components/nestable.almost-flat.scss +137 -0
  83. data/vendor/assets/stylesheets/uikit/components/nestable.gradient.scss +141 -0
  84. data/vendor/assets/stylesheets/uikit/components/nestable.scss +134 -0
  85. data/vendor/assets/stylesheets/uikit/components/notify.almost-flat.scss +112 -0
  86. data/vendor/assets/stylesheets/uikit/components/notify.gradient.scss +112 -0
  87. data/vendor/assets/stylesheets/uikit/components/notify.scss +106 -0
  88. data/vendor/assets/stylesheets/uikit/components/placeholder.almost-flat.scss +36 -0
  89. data/vendor/assets/stylesheets/uikit/components/placeholder.gradient.scss +36 -0
  90. data/vendor/assets/stylesheets/uikit/components/placeholder.scss +36 -0
  91. data/vendor/assets/stylesheets/uikit/components/progress.almost-flat.scss +130 -0
  92. data/vendor/assets/stylesheets/uikit/components/progress.gradient.scss +138 -0
  93. data/vendor/assets/stylesheets/uikit/components/progress.scss +118 -0
  94. data/vendor/assets/stylesheets/uikit/components/search.almost-flat.scss +216 -0
  95. data/vendor/assets/stylesheets/uikit/components/search.gradient.scss +216 -0
  96. data/vendor/assets/stylesheets/uikit/components/search.scss +214 -0
  97. data/vendor/assets/stylesheets/uikit/components/slidenav.almost-flat.scss +110 -0
  98. data/vendor/assets/stylesheets/uikit/components/slidenav.gradient.scss +110 -0
  99. data/vendor/assets/stylesheets/uikit/components/slidenav.scss +110 -0
  100. data/vendor/assets/stylesheets/uikit/components/slider.almost-flat.scss +105 -0
  101. data/vendor/assets/stylesheets/uikit/components/slider.gradient.scss +105 -0
  102. data/vendor/assets/stylesheets/uikit/components/slider.scss +105 -0
  103. data/vendor/assets/stylesheets/uikit/components/slideshow.almost-flat.scss +166 -0
  104. data/vendor/assets/stylesheets/uikit/components/slideshow.gradient.scss +166 -0
  105. data/vendor/assets/stylesheets/uikit/components/slideshow.scss +166 -0
  106. data/vendor/assets/stylesheets/uikit/components/sortable.almost-flat.scss +90 -0
  107. data/vendor/assets/stylesheets/uikit/components/sortable.gradient.scss +90 -0
  108. data/vendor/assets/stylesheets/uikit/components/sortable.scss +90 -0
  109. data/vendor/assets/stylesheets/uikit/components/sticky.almost-flat.scss +39 -0
  110. data/vendor/assets/stylesheets/uikit/components/sticky.gradient.scss +39 -0
  111. data/vendor/assets/stylesheets/uikit/components/sticky.scss +39 -0
  112. data/vendor/assets/stylesheets/uikit/components/tooltip.almost-flat.scss +129 -0
  113. data/vendor/assets/stylesheets/uikit/components/tooltip.gradient.scss +129 -0
  114. data/vendor/assets/stylesheets/uikit/components/tooltip.scss +127 -0
  115. data/vendor/assets/stylesheets/uikit/components/upload.almost-flat.scss +11 -0
  116. data/vendor/assets/stylesheets/uikit/components/upload.gradient.scss +11 -0
  117. data/vendor/assets/stylesheets/uikit/components/upload.scss +11 -0
  118. data/vendor/assets/stylesheets/uikit/gradient.scss +22 -2
  119. data/vendor/assets/stylesheets/uikit/uikit.almost-flat.scss +1768 -498
  120. data/vendor/assets/stylesheets/uikit/uikit.gradient.scss +1776 -512
  121. data/vendor/assets/stylesheets/uikit/uikit.scss +1722 -462
  122. metadata +92 -7
  123. data/vendor/assets/stylesheets/uikit/components/uikit.components.almost-flat.scss +0 -1586
  124. data/vendor/assets/stylesheets/uikit/components/uikit.components.gradient.scss +0 -1608
  125. data/vendor/assets/stylesheets/uikit/components/uikit.components.scss +0 -1489
@@ -1,19 +1,21 @@
1
- /*! UIkit 2.11.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
1
+ /*! UIkit 2.20.3 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2
2
  (function(addon) {
3
3
 
4
4
  var component;
5
5
 
6
- if (jQuery && jQuery.UIkit) {
7
- component = addon(jQuery, jQuery.UIkit);
6
+ if (window.UIkit) {
7
+ component = addon(UIkit);
8
8
  }
9
9
 
10
10
  if (typeof define == "function" && define.amd) {
11
11
  define("uikit-htmleditor", ["uikit"], function(){
12
- return component || addon(jQuery, jQuery.UIkit);
12
+ return component || addon(UIkit);
13
13
  });
14
14
  }
15
15
 
16
- })(function($, UI) {
16
+ })(function(UI) {
17
+
18
+ "use strict";
17
19
 
18
20
  var editors = [];
19
21
 
@@ -26,7 +28,6 @@
26
28
  autocomplete : true,
27
29
  height : 500,
28
30
  maxsplitsize : 1000,
29
- markedOptions: { gfm: true, tables: true, breaks: true, pedantic: true, sanitize: false, smartLists: true, smartypants: false, langPrefix: 'lang-'},
30
31
  codemirror : { mode: 'htmlmixed', lineWrapping: true, dragDrop: false, autoCloseTags: true, matchTags: true, autoCloseBrackets: true, matchBrackets: true, indentUnit: 4, indentWithTabs: false, tabSize: 4, hintOptions: {completionSingle:false} },
31
32
  toolbar : [ 'bold', 'italic', 'strike', 'link', 'image', 'blockquote', 'listUl', 'listOl' ],
32
33
  lblPreview : 'Preview',
@@ -34,6 +35,22 @@
34
35
  lblMarkedview: 'Markdown'
35
36
  },
36
37
 
38
+ boot: function() {
39
+
40
+ // init code
41
+ UI.ready(function(context) {
42
+
43
+ UI.$('textarea[data-uk-htmleditor]', context).each(function() {
44
+
45
+ var editor = UI.$(this), obj;
46
+
47
+ if (!editor.data('htmleditor')) {
48
+ obj = UI.htmleditor(editor, UI.Utils.options(editor.attr('data-uk-htmleditor')));
49
+ }
50
+ });
51
+ });
52
+ },
53
+
37
54
  init: function() {
38
55
 
39
56
  var $this = this, tpl = UI.components.htmleditor.template;
@@ -44,7 +61,7 @@
44
61
  tpl = tpl.replace(/\{:lblPreview\}/g, this.options.lblPreview);
45
62
  tpl = tpl.replace(/\{:lblCodeview\}/g, this.options.lblCodeview);
46
63
 
47
- this.htmleditor = $(tpl);
64
+ this.htmleditor = UI.$(tpl);
48
65
  this.content = this.htmleditor.find('.uk-htmleditor-content');
49
66
  this.toolbar = this.htmleditor.find('.uk-htmleditor-toolbar');
50
67
  this.preview = this.htmleditor.find('.uk-htmleditor-preview').children().eq(0);
@@ -54,20 +71,23 @@
54
71
  this.editor = this.CodeMirror.fromTextArea(this.element[0], this.options.codemirror);
55
72
  this.editor.htmleditor = this;
56
73
  this.editor.on('change', UI.Utils.debounce(function() { $this.render(); }, 150));
57
- this.editor.on('change', function() { $this.editor.save(); });
74
+ this.editor.on('change', function() {
75
+ $this.editor.save();
76
+ $this.element.trigger('input');
77
+ });
58
78
  this.code.find('.CodeMirror').css('height', this.options.height);
59
79
 
60
80
  // iframe mode?
61
81
  if (this.options.iframe) {
62
82
 
63
- this.iframe = $('<iframe class="uk-htmleditor-iframe" frameborder="0" scrolling="auto" height="100" width="100%"></iframe>');
83
+ this.iframe = UI.$('<iframe class="uk-htmleditor-iframe" frameborder="0" scrolling="auto" height="100" width="100%"></iframe>');
64
84
  this.preview.append(this.iframe);
65
85
 
66
86
  // must open and close document object to start using it!
67
87
  this.iframe[0].contentWindow.document.open();
68
88
  this.iframe[0].contentWindow.document.close();
69
89
 
70
- this.preview.container = $(this.iframe[0].contentWindow.document).find('body');
90
+ this.preview.container = UI.$(this.iframe[0].contentWindow.document).find('body');
71
91
 
72
92
  // append custom stylesheet
73
93
  if (typeof(this.options.iframe) === 'string') {
@@ -78,7 +98,7 @@
78
98
  this.preview.container = this.preview;
79
99
  }
80
100
 
81
- UI.$win.on('resize', UI.Utils.debounce(function() { $this.fit(); }, 200));
101
+ UI.$win.on('resize load', UI.Utils.debounce(function() { $this.fit(); }, 200));
82
102
 
83
103
  var previewContainer = this.iframe ? this.preview.container:$this.preview.parent(),
84
104
  codeContent = this.code.find('.CodeMirror-sizer'),
@@ -105,7 +125,7 @@
105
125
 
106
126
  $this.htmleditor.find('.uk-htmleditor-button-code, .uk-htmleditor-button-preview').removeClass('uk-active').filter(this).addClass('uk-active');
107
127
 
108
- $this.activetab = $(this).hasClass('uk-htmleditor-button-code') ? 'code' : 'preview';
128
+ $this.activetab = UI.$(this).hasClass('uk-htmleditor-button-code') ? 'code' : 'preview';
109
129
  $this.htmleditor.attr('data-active-tab', $this.activetab);
110
130
  $this.editor.refresh();
111
131
  }
@@ -116,7 +136,7 @@
116
136
 
117
137
  if (!$this.code.is(':visible')) return;
118
138
 
119
- $this.trigger('action.' + $(this).data('htmleditor-button'), [$this.editor]);
139
+ $this.trigger('action.' + UI.$(this).data('htmleditor-button'), [$this.editor]);
120
140
  });
121
141
 
122
142
  this.preview.parent().css('height', this.code.height());
@@ -140,12 +160,12 @@
140
160
 
141
161
  this.debouncedRedraw = UI.Utils.debounce(function () { $this.redraw(); }, 5);
142
162
 
143
- this.on('init', function() {
163
+ this.on('init.uk.component', function() {
144
164
  $this.redraw();
145
165
  });
146
166
 
147
- this.element.attr('data-uk-check-display', 1).on('uk.check.display', function(e) {
148
- if(this.htmleditor.is(":visible")) this.fit();
167
+ this.element.attr('data-uk-check-display', 1).on('display.uk.check', function(e) {
168
+ if (this.htmleditor.is(":visible")) this.fit();
149
169
  }.bind(this));
150
170
 
151
171
  editors.push(this);
@@ -156,7 +176,7 @@
156
176
  },
157
177
 
158
178
  addButtons: function(buttons) {
159
- $.extend(this.buttons, buttons);
179
+ UI.$.extend(this.buttons, buttons);
160
180
  },
161
181
 
162
182
  replaceInPreview: function(regexp, callback) {
@@ -180,15 +200,15 @@
180
200
  return cursor.ch >= match.from.ch && cursor.ch < match.to.ch;
181
201
  }
182
202
 
183
- return (cursor.line === match.from.line && cursor.ch >= match.from.ch)
184
- || (cursor.line > match.from.line && cursor.line < match.to.line)
185
- || (cursor.line === match.to.line && cursor.ch < match.to.ch);
203
+ return (cursor.line === match.from.line && cursor.ch >= match.from.ch) ||
204
+ (cursor.line > match.from.line && cursor.line < match.to.line) ||
205
+ (cursor.line === match.to.line && cursor.ch < match.to.ch);
186
206
  }
187
207
  };
188
208
 
189
209
  var result = callback(match);
190
210
 
191
- if (result == false) {
211
+ if (!result) {
192
212
  return arguments[0];
193
213
  }
194
214
 
@@ -285,7 +305,7 @@
285
305
 
286
306
  addShortcut: function(name, callback) {
287
307
  var map = {};
288
- if (!$.isArray(name)) {
308
+ if (!UI.$.isArray(name)) {
289
309
  name = [name];
290
310
  }
291
311
 
@@ -488,14 +508,12 @@
488
508
 
489
509
  init: function(editor) {
490
510
 
491
- var parser = editor.options.marked || marked;
511
+ var parser = editor.options.mdparser || marked || null;
492
512
 
493
513
  if (!parser) return;
494
514
 
495
- parser.setOptions(editor.options.markedOptions);
496
-
497
515
  if (editor.options.markdown) {
498
- enableMarkdown()
516
+ enableMarkdown();
499
517
  }
500
518
 
501
519
  addAction('bold', '**$1**');
@@ -564,7 +582,7 @@
564
582
  }
565
583
  });
566
584
 
567
- $.extend(editor, {
585
+ UI.$.extend(editor, {
568
586
 
569
587
  enableMarkdown: function() {
570
588
  enableMarkdown()
@@ -599,16 +617,5 @@
599
617
  }
600
618
  });
601
619
 
602
- // init code
603
- $(function() {
604
- $('textarea[data-uk-htmleditor]').each(function() {
605
- var editor = $(this), obj;
606
-
607
- if (!editor.data('htmleditor')) {
608
- obj = UI.htmleditor(editor, UI.Utils.options(editor.attr('data-uk-htmleditor')));
609
- }
610
- });
611
- });
612
-
613
620
  return UI.htmleditor;
614
- });
621
+ });
@@ -0,0 +1,543 @@
1
+ /*! UIkit 2.20.3 | 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
+ "group" : false,
26
+ "duration" : 400,
27
+ "keyboard" : true
28
+ },
29
+
30
+ index : 0,
31
+ items : false,
32
+
33
+ boot: function() {
34
+
35
+ UI.$html.on('click', '[data-uk-lightbox]', function(e){
36
+
37
+ e.preventDefault();
38
+
39
+ var link = UI.$(this);
40
+
41
+ if (!link.data("lightbox")) {
42
+
43
+ UI.lightbox(link, UI.Utils.options(link.attr("data-uk-lightbox")));
44
+ }
45
+
46
+ link.data("lightbox").show(link);
47
+ });
48
+
49
+ // keyboard navigation
50
+ UI.$doc.on('keyup', function(e) {
51
+
52
+ if (modal && modal.is(':visible') && modal.lightbox.options.keyboard) {
53
+
54
+ e.preventDefault();
55
+
56
+ switch(e.keyCode) {
57
+ case 37:
58
+ modal.lightbox.previous();
59
+ break;
60
+ case 39:
61
+ modal.lightbox.next();
62
+ break;
63
+ }
64
+ }
65
+ });
66
+ },
67
+
68
+ init: function() {
69
+
70
+ var $this = this, siblings = [];
71
+
72
+ this.index = 0;
73
+ this.siblings = [];
74
+
75
+ if (this.element && this.element.length) {
76
+
77
+ var domSiblings = this.options.group ? UI.$([
78
+ '[data-uk-lightbox*="'+this.options.group+'"]',
79
+ "[data-uk-lightbox*='"+this.options.group+"']"
80
+ ].join(',')) : this.element;
81
+
82
+ domSiblings.each(function() {
83
+
84
+ var ele = UI.$(this);
85
+
86
+ siblings.push({
87
+ 'source': ele.attr('href'),
88
+ 'title' : ele.attr('title'),
89
+ 'type' : ele.attr("data-lightbox-type") || 'auto',
90
+ 'link' : ele
91
+ });
92
+ });
93
+
94
+ this.index = domSiblings.index(this.element);
95
+ this.siblings = siblings;
96
+
97
+ } else if (this.options.group && this.options.group.length) {
98
+ this.siblings = this.options.group;
99
+ }
100
+
101
+ this.trigger('lightbox-init', [this]);
102
+ },
103
+
104
+ show: function(index) {
105
+
106
+ this.modal = getModal(this);
107
+
108
+ // stop previous animation
109
+ this.modal.dialog.stop();
110
+ this.modal.content.stop();
111
+
112
+ var $this = this, promise = UI.$.Deferred(), data, item;
113
+
114
+ index = index || 0;
115
+
116
+ // index is a jQuery object or DOM element
117
+ if (typeof(index) == 'object') {
118
+
119
+ this.siblings.forEach(function(s, idx){
120
+
121
+ if (index[0] === s.link[0]) {
122
+ index = idx;
123
+ }
124
+ });
125
+ }
126
+
127
+ // fix index if needed
128
+ if ( index < 0 ) {
129
+ index = this.siblings.length - index;
130
+ } else if (!this.siblings[index]) {
131
+ index = 0;
132
+ }
133
+
134
+ item = this.siblings[index];
135
+
136
+ data = {
137
+ "lightbox" : $this,
138
+ "source" : item.source,
139
+ "type" : item.type,
140
+ "index" : index,
141
+ "promise" : promise,
142
+ "title" : item.title,
143
+ "item" : item,
144
+ "meta" : {
145
+ "content" : '',
146
+ "width" : null,
147
+ "height" : null
148
+ }
149
+ };
150
+
151
+ this.index = index;
152
+
153
+ this.modal.content.empty();
154
+
155
+ if (!this.modal.is(':visible')) {
156
+ this.modal.content.css({width:'', height:''}).empty();
157
+ this.modal.modal.show();
158
+ }
159
+
160
+ this.modal.loader.removeClass('uk-hidden');
161
+
162
+ promise.promise().done(function() {
163
+
164
+ $this.data = data;
165
+ $this.fitSize(data);
166
+
167
+ }).fail(function(){
168
+
169
+ data.meta.content = '<div class="uk-position-cover uk-flex uk-flex-middle uk-flex-center"><strong>Loading resource failed!</strong></div>';
170
+ data.meta.width = 400;
171
+ data.meta.height = 300;
172
+
173
+ $this.data = data;
174
+ $this.fitSize(data);
175
+ });
176
+
177
+ $this.trigger('showitem.uk.lightbox', [data]);
178
+ },
179
+
180
+ fitSize: function() {
181
+
182
+ var $this = this,
183
+ data = this.data,
184
+ pad = this.modal.dialog.outerWidth() - this.modal.dialog.width(),
185
+ dpadTop = parseInt(this.modal.dialog.css('margin-top'), 10),
186
+ dpadBot = parseInt(this.modal.dialog.css('margin-bottom'), 10),
187
+ dpad = dpadTop + dpadBot,
188
+ content = data.meta.content,
189
+ duration = $this.options.duration;
190
+
191
+ if (this.siblings.length > 1) {
192
+
193
+ content = [
194
+ content,
195
+ '<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-previous uk-hidden-touch" data-lightbox-previous></a>',
196
+ '<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-next uk-hidden-touch" data-lightbox-next></a>'
197
+ ].join('');
198
+ }
199
+
200
+ // calculate width
201
+ var tmp = UI.$('<div>&nbsp;</div>').css({
202
+ 'opacity' : 0,
203
+ 'position' : 'absolute',
204
+ 'top' : 0,
205
+ 'left' : 0,
206
+ 'width' : '100%',
207
+ 'max-width' : $this.modal.dialog.css('max-width'),
208
+ 'padding' : $this.modal.dialog.css('padding'),
209
+ 'margin' : $this.modal.dialog.css('margin')
210
+ }), maxwidth, maxheight, w = data.meta.width, h = data.meta.height;
211
+
212
+ tmp.appendTo('body').width();
213
+
214
+ maxwidth = tmp.width();
215
+ maxheight = window.innerHeight - dpad;
216
+
217
+ tmp.remove();
218
+
219
+ this.modal.dialog.find('.uk-modal-caption').remove();
220
+
221
+ if (data.title) {
222
+ this.modal.dialog.append('<div class="uk-modal-caption">'+data.title+'</div>');
223
+ maxheight -= this.modal.dialog.find('.uk-modal-caption').outerHeight();
224
+ }
225
+
226
+ if (maxwidth < data.meta.width) {
227
+
228
+ h = Math.floor( h * (maxwidth / w) );
229
+ w = maxwidth;
230
+ }
231
+
232
+ if (maxheight < h) {
233
+
234
+ h = Math.floor(maxheight);
235
+ w = Math.ceil(data.meta.width * (maxheight/data.meta.height));
236
+ }
237
+
238
+ this.modal.content.css('opacity', 0).width(w).html(content);
239
+
240
+ if (data.type == 'iframe') {
241
+ this.modal.content.find('iframe:first').height(h);
242
+ }
243
+
244
+ var dh = h + pad,
245
+ t = Math.floor(window.innerHeight/2 - dh/2) - dpad;
246
+
247
+ if (t < 0) { t = 0; }
248
+
249
+ this.modal.closer.addClass('uk-hidden');
250
+
251
+ if ($this.modal.data('mwidth') == w && $this.modal.data('mheight') == h) {
252
+ duration = 0;
253
+ }
254
+
255
+ this.modal.dialog.animate({width: w + pad, height: h + pad, top: t }, duration, 'swing', function() {
256
+ $this.modal.loader.addClass('uk-hidden');
257
+ $this.modal.content.css({width:''}).animate({'opacity': 1}, function() {
258
+ $this.modal.closer.removeClass('uk-hidden');
259
+ });
260
+
261
+ $this.modal.data({'mwidth': w, 'mheight': h});
262
+ });
263
+ },
264
+
265
+ next: function() {
266
+ this.show(this.siblings[(this.index+1)] ? (this.index+1) : 0);
267
+ },
268
+
269
+ previous: function() {
270
+ this.show(this.siblings[(this.index-1)] ? (this.index-1) : this.siblings.length-1);
271
+ }
272
+ });
273
+
274
+
275
+ // Plugins
276
+
277
+ UI.plugin('lightbox', 'image', {
278
+
279
+ init: function(lightbox) {
280
+
281
+ lightbox.on("showitem.uk.lightbox", function(e, data){
282
+
283
+ if (data.type == 'image' || data.source && data.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)) {
284
+
285
+ var resolve = function(source, width, height) {
286
+
287
+ data.meta = {
288
+ "content" : '<img class="uk-responsive-width" width="'+width+'" height="'+height+'" src ="'+source+'">',
289
+ "width" : width,
290
+ "height" : height
291
+ };
292
+
293
+ data.type = 'image';
294
+
295
+ data.promise.resolve();
296
+ };
297
+
298
+ if (!cache[data.source]) {
299
+
300
+ var img = new Image();
301
+
302
+ img.onerror = function(){
303
+ data.promise.reject('Loading image failed');
304
+ };
305
+
306
+ img.onload = function(){
307
+ cache[data.source] = {width: img.width, height: img.height};
308
+ resolve(data.source, cache[data.source].width, cache[data.source].height);
309
+ };
310
+
311
+ img.src = data.source;
312
+
313
+ } else {
314
+ resolve(data.source, cache[data.source].width, cache[data.source].height);
315
+ }
316
+ }
317
+ });
318
+ }
319
+ });
320
+
321
+ UI.plugin("lightbox", "youtube", {
322
+
323
+ init: function(lightbox) {
324
+
325
+ var youtubeRegExp = /(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,
326
+ youtubeRegExpShort = /youtu\.be\/(.*)/;
327
+
328
+
329
+ lightbox.on("showitem.uk.lightbox", function(e, data){
330
+
331
+ var id, matches, resolve = function(id, width, height) {
332
+
333
+ data.meta = {
334
+ 'content': '<iframe src="//www.youtube.com/embed/'+id+'" width="'+width+'" height="'+height+'" style="max-width:100%;"></iframe>',
335
+ 'width': width,
336
+ 'height': height
337
+ };
338
+
339
+ data.type = 'iframe';
340
+
341
+ data.promise.resolve();
342
+ };
343
+
344
+ if (matches = data.source.match(youtubeRegExp)) {
345
+ id = matches[2];
346
+ }
347
+
348
+ if (matches = data.source.match(youtubeRegExpShort)) {
349
+ id = matches[1];
350
+ }
351
+
352
+ if (id) {
353
+
354
+ if(!cache[id]) {
355
+
356
+ var img = new Image();
357
+
358
+ img.onerror = function(){
359
+ cache[id] = {width:640, height:320};
360
+ resolve(id, cache[id].width, cache[id].height);
361
+ };
362
+
363
+ img.onload = function(){
364
+ cache[id] = {width:img.width, height:img.height};
365
+ resolve(id, img.width, img.height);
366
+ };
367
+
368
+ img.src = '//img.youtube.com/vi/'+id+'/0.jpg';
369
+
370
+ } else {
371
+ resolve(id, cache[id].width, cache[id].height);
372
+ }
373
+
374
+ e.stopImmediatePropagation();
375
+ }
376
+ });
377
+ }
378
+ });
379
+
380
+
381
+ UI.plugin("lightbox", "vimeo", {
382
+
383
+ init: function(lightbox) {
384
+
385
+ var regex = /(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/, matches;
386
+
387
+
388
+ lightbox.on("showitem.uk.lightbox", function(e, data){
389
+
390
+ var id, resolve = function(id, width, height) {
391
+
392
+ data.meta = {
393
+ 'content': '<iframe src="//player.vimeo.com/video/'+id+'" width="'+width+'" height="'+height+'" style="width:100%;box-sizing:border-box;"></iframe>',
394
+ 'width': width,
395
+ 'height': height
396
+ };
397
+
398
+ data.type = 'iframe';
399
+
400
+ data.promise.resolve();
401
+ };
402
+
403
+ if (matches = data.source.match(regex)) {
404
+
405
+ id = matches[2];
406
+
407
+ if(!cache[id]) {
408
+
409
+ UI.$.ajax({
410
+ type : 'GET',
411
+ url : 'http://vimeo.com/api/oembed.json?url=' + encodeURI(data.source),
412
+ jsonp : 'callback',
413
+ dataType : 'jsonp',
414
+ success : function(data) {
415
+ cache[id] = {width:data.width, height:data.height};
416
+ resolve(id, cache[id].width, cache[id].height);
417
+ }
418
+ });
419
+
420
+ } else {
421
+ resolve(id, cache[id].width, cache[id].height);
422
+ }
423
+
424
+ e.stopImmediatePropagation();
425
+ }
426
+ });
427
+ }
428
+ });
429
+
430
+ UI.plugin("lightbox", "video", {
431
+
432
+ init: function(lightbox) {
433
+
434
+ lightbox.on("showitem.uk.lightbox", function(e, data){
435
+
436
+ var resolve = function(source, width, height) {
437
+
438
+ data.meta = {
439
+ 'content': '<video class="uk-responsive-width" src="'+source+'" width="'+width+'" height="'+height+'" controls></video>',
440
+ 'width': width,
441
+ 'height': height
442
+ };
443
+
444
+ data.type = 'video';
445
+
446
+ data.promise.resolve();
447
+ };
448
+
449
+ if (data.type == 'video' || data.source.match(/\.(mp4|webm|ogv)$/i)) {
450
+
451
+ if (!cache[data.source]) {
452
+
453
+ var vid = UI.$('<video style="position:fixed;visibility:hidden;top:-10000px;"></video>').attr('src', data.source).appendTo('body');
454
+
455
+ var idle = setInterval(function() {
456
+
457
+ if (vid[0].videoWidth) {
458
+ clearInterval(idle);
459
+ cache[data.source] = {width: vid[0].videoWidth, height: vid[0].videoHeight};
460
+ resolve(data.source, cache[data.source].width, cache[data.source].height);
461
+ vid.remove();
462
+ }
463
+
464
+ }, 20);
465
+
466
+ } else {
467
+ resolve(data.source, cache[data.source].width, cache[data.source].height);
468
+ }
469
+ }
470
+ });
471
+ }
472
+ });
473
+
474
+
475
+ function getModal(lightbox) {
476
+
477
+ if (modal) {
478
+ modal.lightbox = lightbox;
479
+ return modal;
480
+ }
481
+
482
+ // init lightbox container
483
+ modal = UI.$([
484
+ '<div class="uk-modal">',
485
+ '<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;">',
486
+ '<a href="#" class="uk-modal-close uk-close uk-close-alt"></a>',
487
+ '<div class="uk-lightbox-content"></div>',
488
+ '<div class="uk-modal-spinner uk-hidden"></div>',
489
+ '</div>',
490
+ '</div>'
491
+ ].join('')).appendTo('body');
492
+
493
+ modal.dialog = modal.find('.uk-modal-dialog:first');
494
+ modal.content = modal.find('.uk-lightbox-content:first');
495
+ modal.loader = modal.find('.uk-modal-spinner:first');
496
+ modal.closer = modal.find('.uk-close.uk-close-alt');
497
+ modal.modal = UI.modal(modal);
498
+
499
+ // next / previous
500
+ modal.on("swipeRight swipeLeft", function(e) {
501
+ modal.lightbox[e.type=='swipeLeft' ? 'next':'previous']();
502
+ }).on("click", "[data-lightbox-previous], [data-lightbox-next]", function(e){
503
+ e.preventDefault();
504
+ modal.lightbox[UI.$(this).is('[data-lightbox-next]') ? 'next':'previous']();
505
+ });
506
+
507
+ // destroy content on modal hide
508
+ modal.on("hide.uk.modal", function(e) {
509
+ modal.content.html('');
510
+ });
511
+
512
+ UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
513
+ if (modal.is(':visible')) modal.lightbox.fitSize();
514
+ }.bind(this), 100));
515
+
516
+ modal.lightbox = lightbox;
517
+
518
+ return modal;
519
+ }
520
+
521
+ UI.lightbox.create = function(items, options) {
522
+
523
+ if (!items) return;
524
+
525
+ var group = [], o;
526
+
527
+ items.forEach(function(item) {
528
+
529
+ group.push(UI.$.extend({
530
+ 'source' : '',
531
+ 'title' : '',
532
+ 'type' : 'auto',
533
+ 'link' : false
534
+ }, (typeof(item) == 'string' ? {'source': item} : item)));
535
+ });
536
+
537
+ o = UI.lightbox(UI.$.extend({}, options, {'group':group}));
538
+
539
+ return o;
540
+ };
541
+
542
+ return UI.lightbox;
543
+ });