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,364 @@
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-sticky", ["uikit"], function(){
12
+ return component || addon(UIkit);
13
+ });
14
+ }
15
+
16
+ })(function(UI){
17
+
18
+ "use strict";
19
+
20
+ var $win = UI.$win,
21
+ $doc = UI.$doc,
22
+ sticked = [],
23
+ direction = 1;
24
+
25
+ UI.component('sticky', {
26
+
27
+ defaults: {
28
+ top : 0,
29
+ bottom : 0,
30
+ animation : '',
31
+ clsinit : 'uk-sticky-init',
32
+ clsactive : 'uk-active',
33
+ clsinactive : '',
34
+ getWidthFrom : '',
35
+ showup : false,
36
+ boundary : false,
37
+ media : false,
38
+ target : false,
39
+ disabled : false
40
+ },
41
+
42
+ boot: function() {
43
+
44
+ // should be more efficient than using $win.scroll(checkscrollposition):
45
+ UI.$doc.on('scrolling.uk.document', function(e, data) {
46
+ if (!data || !data.dir) return;
47
+ direction = data.dir.y;
48
+ checkscrollposition();
49
+ });
50
+
51
+ UI.$win.on('resize orientationchange', UI.Utils.debounce(function() {
52
+
53
+ if (!sticked.length) return;
54
+
55
+ for (var i = 0; i < sticked.length; i++) {
56
+ sticked[i].reset(true);
57
+ sticked[i].self.computeWrapper();
58
+ }
59
+
60
+ checkscrollposition();
61
+ }, 100));
62
+
63
+ // init code
64
+ UI.ready(function(context) {
65
+
66
+ setTimeout(function(){
67
+
68
+ UI.$("[data-uk-sticky]", context).each(function(){
69
+
70
+ var $ele = UI.$(this);
71
+
72
+ if (!$ele.data("sticky")) {
73
+ UI.sticky($ele, UI.Utils.options($ele.attr('data-uk-sticky')));
74
+ }
75
+ });
76
+
77
+ checkscrollposition();
78
+ }, 0);
79
+ });
80
+ },
81
+
82
+ init: function() {
83
+
84
+ var boundary = this.options.boundary, boundtoparent;
85
+
86
+ this.wrapper = this.element.wrap('<div class="uk-sticky-placeholder"></div>').parent();
87
+ this.computeWrapper();
88
+ this.wrapper.css({
89
+ 'margin-top' : this.element.css('margin-top'),
90
+ 'margin-bottom' : this.element.css('margin-bottom'),
91
+ 'margin-left' : this.element.css('margin-left'),
92
+ 'margin-right' : this.element.css('margin-right')
93
+ })
94
+ this.element.css('margin', 0);
95
+
96
+ if (boundary) {
97
+
98
+ if (boundary === true || boundary[0] === '!') {
99
+
100
+ boundary = boundary === true ? this.wrapper.parent() : this.wrapper.closest(boundary.substr(1));
101
+ boundtoparent = true;
102
+
103
+ } else if (typeof boundary === "string") {
104
+ boundary = UI.$(boundary);
105
+ }
106
+ }
107
+
108
+ this.sticky = {
109
+ self : this,
110
+ options : this.options,
111
+ element : this.element,
112
+ currentTop : null,
113
+ wrapper : this.wrapper,
114
+ init : false,
115
+ getWidthFrom : UI.$(this.options.getWidthFrom || this.wrapper),
116
+ boundary : boundary,
117
+ boundtoparent : boundtoparent,
118
+ top : 0,
119
+ calcTop : function() {
120
+
121
+ var top = this.options.top;
122
+
123
+ // dynamic top parameter
124
+ if (this.options.top && typeof(this.options.top) == 'string') {
125
+
126
+ // e.g. 50vh
127
+ if (this.options.top.match(/^(-|)(\d+)vh$/)) {
128
+ top = window.innerHeight * parseInt(this.options.top, 10)/100;
129
+ // e.g. #elementId, or .class-1,class-2,.class-3 (first found is used)
130
+ } else {
131
+
132
+ var topElement = UI.$(this.options.top).first();
133
+
134
+ if (topElement.length && topElement.is(':visible')) {
135
+ top = -1 * ((topElement.offset().top + topElement.outerHeight()) - this.wrapper.offset().top);
136
+ }
137
+ }
138
+
139
+ }
140
+
141
+ this.top = top;
142
+ },
143
+
144
+ reset: function(force) {
145
+
146
+ this.calcTop();
147
+
148
+ var finalize = function() {
149
+ this.element.css({"position":"", "top":"", "width":"", "left":"", "margin":"0"});
150
+ this.element.removeClass([this.options.animation, 'uk-animation-reverse', this.options.clsactive].join(' '));
151
+ this.element.addClass(this.options.clsinactive);
152
+ this.element.trigger('inactive.uk.sticky');
153
+
154
+ this.currentTop = null;
155
+ this.animate = false;
156
+
157
+ }.bind(this);
158
+
159
+
160
+ if (!force && this.options.animation && UI.support.animation && !UI.Utils.isInView(this.wrapper)) {
161
+
162
+ this.animate = true;
163
+
164
+ this.element.removeClass(this.options.animation).one(UI.support.animation.end, function(){
165
+ finalize();
166
+ }).width(); // force redraw
167
+
168
+ this.element.addClass(this.options.animation+' '+'uk-animation-reverse');
169
+ } else {
170
+ finalize();
171
+ }
172
+ },
173
+
174
+ check: function() {
175
+
176
+ if (this.options.disabled) {
177
+ return false;
178
+ }
179
+
180
+ if (this.options.media) {
181
+
182
+ switch(typeof(this.options.media)) {
183
+ case 'number':
184
+ if (window.innerWidth < this.options.media) {
185
+ return false;
186
+ }
187
+ break;
188
+ case 'string':
189
+ if (window.matchMedia && !window.matchMedia(this.options.media).matches) {
190
+ return false;
191
+ }
192
+ break;
193
+ }
194
+ }
195
+
196
+ var scrollTop = $win.scrollTop(),
197
+ documentHeight = $doc.height(),
198
+ dwh = documentHeight - window.innerHeight,
199
+ extra = (scrollTop > dwh) ? dwh - scrollTop : 0,
200
+ elementTop = this.wrapper.offset().top,
201
+ etse = elementTop - this.top - extra,
202
+ active = (scrollTop >= etse);
203
+
204
+ if (active && this.options.showup) {
205
+
206
+ // set inactiv if scrolling down
207
+ if (direction == 1) {
208
+ active = false;
209
+ }
210
+
211
+ // set inactive when wrapper is still in view
212
+ if (direction == -1 && !this.element.hasClass(this.options.clsactive) && UI.Utils.isInView(this.wrapper)) {
213
+ active = false;
214
+ }
215
+ }
216
+
217
+ return active;
218
+ }
219
+ };
220
+
221
+ this.sticky.calcTop();
222
+
223
+ sticked.push(this.sticky);
224
+ },
225
+
226
+ update: function() {
227
+ checkscrollposition(this.sticky);
228
+ },
229
+
230
+ enable: function() {
231
+ this.options.disabled = false;
232
+ this.update();
233
+ },
234
+
235
+ disable: function(force) {
236
+ this.options.disabled = true;
237
+ this.sticky.reset(force);
238
+ },
239
+
240
+ computeWrapper: function() {
241
+
242
+ this.wrapper.css({
243
+ 'height' : ['absolute','fixed'].indexOf(this.element.css('position')) == -1 ? this.element.outerHeight() : '',
244
+ 'float' : this.element.css('float') != 'none' ? this.element.css('float') : ''
245
+ });
246
+
247
+ if (this.element.css('position') == 'fixed') {
248
+ this.element.css({
249
+ width: this.sticky.getWidthFrom.length ? this.sticky.getWidthFrom.width() : this.element.width()
250
+ });
251
+ }
252
+ }
253
+ });
254
+
255
+ function checkscrollposition(direction) {
256
+
257
+ var stickies = arguments.length ? arguments : sticked;
258
+
259
+ if (!stickies.length || $win.scrollTop() < 0) return;
260
+
261
+ var scrollTop = $win.scrollTop(),
262
+ documentHeight = $doc.height(),
263
+ windowHeight = $win.height(),
264
+ dwh = documentHeight - windowHeight,
265
+ extra = (scrollTop > dwh) ? dwh - scrollTop : 0,
266
+ newTop, containerBottom, stickyHeight, sticky;
267
+
268
+ for (var i = 0; i < stickies.length; i++) {
269
+
270
+ sticky = stickies[i];
271
+
272
+ if (!sticky.element.is(":visible") || sticky.animate) {
273
+ continue;
274
+ }
275
+
276
+ if (!sticky.check()) {
277
+
278
+ if (sticky.currentTop !== null) {
279
+ sticky.reset();
280
+ }
281
+
282
+ } else {
283
+
284
+ if (sticky.top < 0) {
285
+ newTop = 0;
286
+ } else {
287
+ stickyHeight = sticky.element.outerHeight();
288
+ newTop = documentHeight - stickyHeight - sticky.top - sticky.options.bottom - scrollTop - extra;
289
+ newTop = newTop < 0 ? newTop + sticky.top : sticky.top;
290
+ }
291
+
292
+ if (sticky.boundary && sticky.boundary.length) {
293
+
294
+ var bTop = sticky.boundary.offset().top;
295
+
296
+ if (sticky.boundtoparent) {
297
+ containerBottom = documentHeight - (bTop + sticky.boundary.outerHeight()) + parseInt(sticky.boundary.css('padding-bottom'));
298
+ } else {
299
+ containerBottom = documentHeight - bTop;
300
+ }
301
+
302
+ newTop = (scrollTop + stickyHeight) > (documentHeight - containerBottom - (sticky.top < 0 ? 0 : sticky.top)) ? (documentHeight - containerBottom) - (scrollTop + stickyHeight) : newTop;
303
+ }
304
+
305
+
306
+ if (sticky.currentTop != newTop) {
307
+
308
+ sticky.element.css({
309
+ position : "fixed",
310
+ top : newTop,
311
+ width : sticky.getWidthFrom.length ? sticky.getWidthFrom.width() : sticky.element.width()
312
+ });
313
+
314
+ if (!sticky.init) {
315
+
316
+ sticky.element.addClass(sticky.options.clsinit);
317
+
318
+ if (location.hash && scrollTop > 0 && sticky.options.target) {
319
+
320
+ var $target = UI.$(location.hash);
321
+
322
+ if ($target.length) {
323
+
324
+ setTimeout((function($target, sticky){
325
+
326
+ return function() {
327
+
328
+ sticky.element.width(); // force redraw
329
+
330
+ var offset = $target.offset(),
331
+ maxoffset = offset.top + $target.outerHeight(),
332
+ stickyOffset = sticky.element.offset(),
333
+ stickyHeight = sticky.element.outerHeight(),
334
+ stickyMaxOffset = stickyOffset.top + stickyHeight;
335
+
336
+ if (stickyOffset.top < maxoffset && offset.top < stickyMaxOffset) {
337
+ scrollTop = offset.top - stickyHeight - sticky.options.target;
338
+ window.scrollTo(0, scrollTop);
339
+ }
340
+ };
341
+
342
+ })($target, sticky), 0);
343
+ }
344
+ }
345
+ }
346
+
347
+ sticky.element.addClass(sticky.options.clsactive).removeClass(sticky.options.clsinactive);
348
+ sticky.element.trigger('active.uk.sticky');
349
+ sticky.element.css('margin', '');
350
+
351
+ if (sticky.options.animation && sticky.init && !UI.Utils.isInView(sticky.wrapper)) {
352
+ sticky.element.addClass(sticky.options.animation);
353
+ }
354
+
355
+ sticky.currentTop = newTop;
356
+ }
357
+ }
358
+
359
+ sticky.init = true;
360
+ }
361
+ }
362
+
363
+ return UI.sticky;
364
+ });
@@ -0,0 +1,192 @@
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-timepicker", ["uikit"], function(){
12
+ return component || addon(UIkit);
13
+ });
14
+ }
15
+
16
+ })(function(UI){
17
+
18
+ "use strict";
19
+
20
+
21
+ UI.component('timepicker', {
22
+
23
+ defaults: {
24
+ format : '24h',
25
+ delay : 0,
26
+ start : 0,
27
+ end : 24
28
+ },
29
+
30
+ boot: function() {
31
+
32
+ // init code
33
+ UI.$html.on("focus.timepicker.uikit", "[data-uk-timepicker]", function(e) {
34
+
35
+ var ele = UI.$(this);
36
+
37
+ if (!ele.data("timepicker")) {
38
+ var obj = UI.timepicker(ele, UI.Utils.options(ele.attr("data-uk-timepicker")));
39
+
40
+ setTimeout(function(){
41
+ obj.autocomplete.input.focus();
42
+ }, 40);
43
+ }
44
+ });
45
+ },
46
+
47
+ init: function() {
48
+
49
+ var $this = this, times = getTimeRange(this.options.start, this.options.end), container;
50
+
51
+ this.options.minLength = 0;
52
+ this.options.template = '<ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results">{{~items}}<li data-value="{{$item.value}}"><a>{{$item.value}}</a></li>{{/items}}</ul>';
53
+
54
+ this.options.source = function(release) {
55
+ release(times[$this.options.format] || times['12h']);
56
+ };
57
+
58
+ if (this.element.is('input')) {
59
+ this.element.wrap('<div class="uk-autocomplete"></div>');
60
+ container = this.element.parent();
61
+ } else {
62
+ container = this.element.addClass('uk-autocomplete');
63
+ }
64
+
65
+ this.autocomplete = UI.autocomplete(container, this.options);
66
+ this.autocomplete.dropdown.addClass('uk-dropdown-small uk-dropdown-scrollable');
67
+
68
+ this.autocomplete.on('show.uk.autocomplete', function() {
69
+
70
+ var selected = $this.autocomplete.dropdown.find('[data-value="'+$this.autocomplete.input.val()+'"]');
71
+
72
+ setTimeout(function(){
73
+ $this.autocomplete.pick(selected, true);
74
+ }, 10);
75
+ });
76
+
77
+ this.autocomplete.input.on('focus', function(){
78
+
79
+ $this.autocomplete.value = Math.random();
80
+ $this.autocomplete.triggercomplete();
81
+
82
+ }).on('blur', UI.Utils.debounce(function() {
83
+ $this.checkTime();
84
+ }, 100));
85
+
86
+ this.element.data("timepicker", this);
87
+ },
88
+
89
+ checkTime: function() {
90
+
91
+ var arr, timeArray, meridian = 'AM', hour, minute, time = this.autocomplete.input.val();
92
+
93
+ if (this.options.format == '12h') {
94
+ arr = time.split(' ');
95
+ timeArray = arr[0].split(':');
96
+ meridian = arr[1];
97
+ } else {
98
+ timeArray = time.split(':');
99
+ }
100
+
101
+ hour = parseInt(timeArray[0], 10);
102
+ minute = parseInt(timeArray[1], 10);
103
+
104
+ if (isNaN(hour)) hour = 0;
105
+ if (isNaN(minute)) minute = 0;
106
+
107
+ if (this.options.format == '12h') {
108
+ if (hour > 12) {
109
+ hour = 12;
110
+ } else if (hour < 0) {
111
+ hour = 12;
112
+ }
113
+
114
+ if (meridian === 'am' || meridian === 'a') {
115
+ meridian = 'AM';
116
+ } else if (meridian === 'pm' || meridian === 'p') {
117
+ meridian = 'PM';
118
+ }
119
+
120
+ if (meridian !== 'AM' && meridian !== 'PM') {
121
+ meridian = 'AM';
122
+ }
123
+
124
+ } else {
125
+
126
+ if (hour >= 24) {
127
+ hour = 23;
128
+ } else if (hour < 0) {
129
+ hour = 0;
130
+ }
131
+ }
132
+
133
+ if (minute < 0) {
134
+ minute = 0;
135
+ } else if (minute >= 60) {
136
+ minute = 0;
137
+ }
138
+
139
+ this.autocomplete.input.val(this.formatTime(hour, minute, meridian)).trigger('change');
140
+ },
141
+
142
+ formatTime: function(hour, minute, meridian) {
143
+ hour = hour < 10 ? '0' + hour : hour;
144
+ minute = minute < 10 ? '0' + minute : minute;
145
+ return hour + ':' + minute + (this.options.format == '12h' ? ' ' + meridian : '');
146
+ }
147
+ });
148
+
149
+ // helper
150
+
151
+ function getTimeRange(start, end) {
152
+
153
+ start = start || 0;
154
+ end = end || 24;
155
+
156
+ var times = {'12h':[], '24h':[]}, i, h;
157
+
158
+ for (i = start, h=''; i<end; i++) {
159
+
160
+ h = ''+i;
161
+
162
+ if (i<10) h = '0'+h;
163
+
164
+ times['24h'].push({value: (h+':00')});
165
+ times['24h'].push({value: (h+':30')});
166
+
167
+ if (i === 0) {
168
+ h = 12;
169
+ times['12h'].push({value: (h+':00 AM')});
170
+ times['12h'].push({value: (h+':30 AM')});
171
+ }
172
+
173
+ if (i > 0 && i<13 && i!==12) {
174
+ times['12h'].push({value: (h+':00 AM')});
175
+ times['12h'].push({value: (h+':30 AM')});
176
+ }
177
+
178
+ if (i >= 12) {
179
+
180
+ h = h-12;
181
+ if (h === 0) h = 12;
182
+ if (h < 10) h = '0'+String(h);
183
+
184
+ times['12h'].push({value: (h+':00 PM')});
185
+ times['12h'].push({value: (h+':30 PM')});
186
+ }
187
+ }
188
+
189
+ return times;
190
+ }
191
+
192
+ });