summaryrefslogtreecommitdiff
path: root/js/uikit.js
diff options
context:
space:
mode:
authorerdgeist <erdgeist@bauklotz.fritz.box>2016-08-07 02:17:47 +0200
committererdgeist <erdgeist@bauklotz.fritz.box>2016-08-07 02:17:47 +0200
commit2653f6a943a6ed74e2b72246ba8211c5fb699a7f (patch)
tree1583823bf875456212156452ba464933139c3ceb /js/uikit.js
parentd850c105940f414caf44705191af8c8b19ca9c85 (diff)
restructured ;)
Diffstat (limited to 'js/uikit.js')
-rwxr-xr-xjs/uikit.js3814
1 files changed, 0 insertions, 3814 deletions
diff --git a/js/uikit.js b/js/uikit.js
deleted file mode 100755
index cf8b403..0000000
--- a/js/uikit.js
+++ /dev/null
@@ -1,3814 +0,0 @@
1/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2(function(core) {
3
4 if (typeof define == "function" && define.amd) { // AMD
5
6 define("uikit", function(){
7
8 var uikit = window.UIkit || core(window, window.jQuery, window.document);
9
10 uikit.load = function(res, req, onload, config) {
11
12 var resources = res.split(','), load = [], i, base = (config.config && config.config.uikit && config.config.uikit.base ? config.config.uikit.base : "").replace(/\/+$/g, "");
13
14 if (!base) {
15 throw new Error( "Please define base path to UIkit in the requirejs config." );
16 }
17
18 for (i = 0; i < resources.length; i += 1) {
19 var resource = resources[i].replace(/\./g, '/');
20 load.push(base+'/components/'+resource);
21 }
22
23 req(load, function() {
24 onload(uikit);
25 });
26 };
27
28 return uikit;
29 });
30 }
31
32 if (!window.jQuery) {
33 throw new Error( "UIkit requires jQuery" );
34 }
35
36 if (window && window.jQuery) {
37 core(window, window.jQuery, window.document);
38 }
39
40
41})(function(global, $, doc) {
42
43 "use strict";
44
45 var UI = {}, _UI = global.UIkit ? Object.create(global.UIkit) : undefined;
46
47 UI.version = '2.26.4';
48
49 UI.noConflict = function() {
50 // restore UIkit version
51 if (_UI) {
52 global.UIkit = _UI;
53 $.UIkit = _UI;
54 $.fn.uk = _UI.fn;
55 }
56
57 return UI;
58 };
59
60 UI.prefix = function(str) {
61 return str;
62 };
63
64 // cache jQuery
65 UI.$ = $;
66
67 UI.$doc = UI.$(document);
68 UI.$win = UI.$(window);
69 UI.$html = UI.$('html');
70
71 UI.support = {};
72 UI.support.transition = (function() {
73
74 var transitionEnd = (function() {
75
76 var element = doc.body || doc.documentElement,
77 transEndEventNames = {
78 WebkitTransition : 'webkitTransitionEnd',
79 MozTransition : 'transitionend',
80 OTransition : 'oTransitionEnd otransitionend',
81 transition : 'transitionend'
82 }, name;
83
84 for (name in transEndEventNames) {
85 if (element.style[name] !== undefined) return transEndEventNames[name];
86 }
87 }());
88
89 return transitionEnd && { end: transitionEnd };
90 })();
91
92 UI.support.animation = (function() {
93
94 var animationEnd = (function() {
95
96 var element = doc.body || doc.documentElement,
97 animEndEventNames = {
98 WebkitAnimation : 'webkitAnimationEnd',
99 MozAnimation : 'animationend',
100 OAnimation : 'oAnimationEnd oanimationend',
101 animation : 'animationend'
102 }, name;
103
104 for (name in animEndEventNames) {
105 if (element.style[name] !== undefined) return animEndEventNames[name];
106 }
107 }());
108
109 return animationEnd && { end: animationEnd };
110 })();
111
112 // requestAnimationFrame polyfill
113 //https://github.com/darius/requestAnimationFrame
114 (function() {
115
116 Date.now = Date.now || function() { return new Date().getTime(); };
117
118 var vendors = ['webkit', 'moz'];
119 for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
120 var vp = vendors[i];
121 window.requestAnimationFrame = window[vp+'RequestAnimationFrame'];
122 window.cancelAnimationFrame = (window[vp+'CancelAnimationFrame']
123 || window[vp+'CancelRequestAnimationFrame']);
124 }
125 if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) // iOS6 is buggy
126 || !window.requestAnimationFrame || !window.cancelAnimationFrame) {
127 var lastTime = 0;
128 window.requestAnimationFrame = function(callback) {
129 var now = Date.now();
130 var nextTime = Math.max(lastTime + 16, now);
131 return setTimeout(function() { callback(lastTime = nextTime); },
132 nextTime - now);
133 };
134 window.cancelAnimationFrame = clearTimeout;
135 }
136 }());
137
138 UI.support.touch = (
139 ('ontouchstart' in document) ||
140 (global.DocumentTouch && document instanceof global.DocumentTouch) ||
141 (global.navigator.msPointerEnabled && global.navigator.msMaxTouchPoints > 0) || //IE 10
142 (global.navigator.pointerEnabled && global.navigator.maxTouchPoints > 0) || //IE >=11
143 false
144 );
145
146 UI.support.mutationobserver = (global.MutationObserver || global.WebKitMutationObserver || null);
147
148 UI.Utils = {};
149
150 UI.Utils.isFullscreen = function() {
151 return document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement || document.fullscreenElement || false;
152 };
153
154 UI.Utils.str2json = function(str, notevil) {
155 try {
156 if (notevil) {
157 return JSON.parse(str
158 // wrap keys without quote with valid double quote
159 .replace(/([\$\w]+)\s*:/g, function(_, $1){return '"'+$1+'":';})
160 // replacing single quote wrapped ones to double quote
161 .replace(/'([^']+)'/g, function(_, $1){return '"'+$1+'"';})
162 );
163 } else {
164 return (new Function("", "var json = " + str + "; return JSON.parse(JSON.stringify(json));"))();
165 }
166 } catch(e) { return false; }
167 };
168
169 UI.Utils.debounce = function(func, wait, immediate) {
170 var timeout;
171 return function() {
172 var context = this, args = arguments;
173 var later = function() {
174 timeout = null;
175 if (!immediate) func.apply(context, args);
176 };
177 var callNow = immediate && !timeout;
178 clearTimeout(timeout);
179 timeout = setTimeout(later, wait);
180 if (callNow) func.apply(context, args);
181 };
182 };
183
184 UI.Utils.throttle = function (func, limit) {
185 var wait = false;
186 return function () {
187 if (!wait) {
188 func.call();
189 wait = true;
190 setTimeout(function () {
191 wait = false;
192 }, limit);
193 }
194 }
195 };
196
197 UI.Utils.removeCssRules = function(selectorRegEx) {
198 var idx, idxs, stylesheet, _i, _j, _k, _len, _len1, _len2, _ref;
199
200 if(!selectorRegEx) return;
201
202 setTimeout(function(){
203 try {
204 _ref = document.styleSheets;
205 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
206 stylesheet = _ref[_i];
207 idxs = [];
208 stylesheet.cssRules = stylesheet.cssRules;
209 for (idx = _j = 0, _len1 = stylesheet.cssRules.length; _j < _len1; idx = ++_j) {
210 if (stylesheet.cssRules[idx].type === CSSRule.STYLE_RULE && selectorRegEx.test(stylesheet.cssRules[idx].selectorText)) {
211 idxs.unshift(idx);
212 }
213 }
214 for (_k = 0, _len2 = idxs.length; _k < _len2; _k++) {
215 stylesheet.deleteRule(idxs[_k]);
216 }
217 }
218 } catch (_error) {}
219 }, 0);
220 };
221
222 UI.Utils.isInView = function(element, options) {
223
224 var $element = $(element);
225
226 if (!$element.is(':visible')) {
227 return false;
228 }
229
230 var window_left = UI.$win.scrollLeft(), window_top = UI.$win.scrollTop(), offset = $element.offset(), left = offset.left, top = offset.top;
231
232 options = $.extend({topoffset:0, leftoffset:0}, options);
233
234 if (top + $element.height() >= window_top && top - options.topoffset <= window_top + UI.$win.height() &&
235 left + $element.width() >= window_left && left - options.leftoffset <= window_left + UI.$win.width()) {
236 return true;
237 } else {
238 return false;
239 }
240 };
241
242 UI.Utils.checkDisplay = function(context, initanimation) {
243
244 var elements = UI.$('[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]', context || document), animated;
245
246 if (context && !elements.length) {
247 elements = $(context);
248 }
249
250 elements.trigger('display.uk.check');
251
252 // fix firefox / IE animations
253 if (initanimation) {
254
255 if (typeof(initanimation)!='string') {
256 initanimation = '[class*="uk-animation-"]';
257 }
258
259 elements.find(initanimation).each(function(){
260
261 var ele = UI.$(this),
262 cls = ele.attr('class'),
263 anim = cls.match(/uk-animation-(.+)/);
264
265 ele.removeClass(anim[0]).width();
266
267 ele.addClass(anim[0]);
268 });
269 }
270
271 return elements;
272 };
273
274 UI.Utils.options = function(string) {
275
276 if ($.type(string)!='string') return string;
277
278 if (string.indexOf(':') != -1 && string.trim().substr(-1) != '}') {
279 string = '{'+string+'}';
280 }
281
282 var start = (string ? string.indexOf("{") : -1), options = {};
283
284 if (start != -1) {
285 try {
286 options = UI.Utils.str2json(string.substr(start));
287 } catch (e) {}
288 }
289
290 return options;
291 };
292
293 UI.Utils.animate = function(element, cls) {
294
295 var d = $.Deferred();
296
297 element = UI.$(element);
298
299 element.css('display', 'none').addClass(cls).one(UI.support.animation.end, function() {
300 element.removeClass(cls);
301 d.resolve();
302 });
303
304 element.css('display', '');
305
306 return d.promise();
307 };
308
309 UI.Utils.uid = function(prefix) {
310 return (prefix || 'id') + (new Date().getTime())+"RAND"+(Math.ceil(Math.random() * 100000));
311 };
312
313 UI.Utils.template = function(str, data) {
314
315 var tokens = str.replace(/\n/g, '\\n').replace(/\{\{\{\s*(.+?)\s*\}\}\}/g, "{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g),
316 i=0, toc, cmd, prop, val, fn, output = [], openblocks = 0;
317
318 while(i < tokens.length) {
319
320 toc = tokens[i];
321
322 if(toc.match(/\{\{\s*(.+?)\s*\}\}/)) {
323 i = i + 1;
324 toc = tokens[i];
325 cmd = toc[0];
326 prop = toc.substring(toc.match(/^(\^|\#|\!|\~|\:)/) ? 1:0);
327
328 switch(cmd) {
329 case '~':
330 output.push("for(var $i=0;$i<"+prop+".length;$i++) { var $item = "+prop+"[$i];");
331 openblocks++;
332 break;
333 case ':':
334 output.push("for(var $key in "+prop+") { var $val = "+prop+"[$key];");
335 openblocks++;
336 break;
337 case '#':
338 output.push("if("+prop+") {");
339 openblocks++;
340 break;
341 case '^':
342 output.push("if(!"+prop+") {");
343 openblocks++;
344 break;
345 case '/':
346 output.push("}");
347 openblocks--;
348 break;
349 case '!':
350 output.push("__ret.push("+prop+");");
351 break;
352 default:
353 output.push("__ret.push(escape("+prop+"));");
354 break;
355 }
356 } else {
357 output.push("__ret.push('"+toc.replace(/\'/g, "\\'")+"');");
358 }
359 i = i + 1;
360 }
361
362 fn = new Function('$data', [
363 'var __ret = [];',
364 'try {',
365 'with($data){', (!openblocks ? output.join('') : '__ret = ["Not all blocks are closed correctly."]'), '};',
366 '}catch(e){__ret = [e.message];}',
367 'return __ret.join("").replace(/\\n\\n/g, "\\n");',
368 "function escape(html) { return String(html).replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');}"
369 ].join("\n"));
370
371 return data ? fn(data) : fn;
372 };
373
374 UI.Utils.events = {};
375 UI.Utils.events.click = UI.support.touch ? 'tap' : 'click';
376
377 global.UIkit = UI;
378
379 // deprecated
380
381 UI.fn = function(command, options) {
382
383 var args = arguments, cmd = command.match(/^([a-z\-]+)(?:\.([a-z]+))?/i), component = cmd[1], method = cmd[2];
384
385 if (!UI[component]) {
386 $.error("UIkit component [" + component + "] does not exist.");
387 return this;
388 }
389
390 return this.each(function() {
391 var $this = $(this), data = $this.data(component);
392 if (!data) $this.data(component, (data = UI[component](this, method ? undefined : options)));
393 if (method) data[method].apply(data, Array.prototype.slice.call(args, 1));
394 });
395 };
396
397 $.UIkit = UI;
398 $.fn.uk = UI.fn;
399
400 UI.langdirection = UI.$html.attr("dir") == "rtl" ? "right" : "left";
401
402 UI.components = {};
403
404 UI.component = function(name, def) {
405
406 var fn = function(element, options) {
407
408 var $this = this;
409
410 this.UIkit = UI;
411 this.element = element ? UI.$(element) : null;
412 this.options = $.extend(true, {}, this.defaults, options);
413 this.plugins = {};
414
415 if (this.element) {
416 this.element.data(name, this);
417 }
418
419 this.init();
420
421 (this.options.plugins.length ? this.options.plugins : Object.keys(fn.plugins)).forEach(function(plugin) {
422
423 if (fn.plugins[plugin].init) {
424 fn.plugins[plugin].init($this);
425 $this.plugins[plugin] = true;
426 }
427
428 });
429
430 this.trigger('init.uk.component', [name, this]);
431
432 return this;
433 };
434
435 fn.plugins = {};
436
437 $.extend(true, fn.prototype, {
438
439 defaults : {plugins: []},
440
441 boot: function(){},
442 init: function(){},
443
444 on: function(a1,a2,a3){
445 return UI.$(this.element || this).on(a1,a2,a3);
446 },
447
448 one: function(a1,a2,a3){
449 return UI.$(this.element || this).one(a1,a2,a3);
450 },
451
452 off: function(evt){
453 return UI.$(this.element || this).off(evt);
454 },
455
456 trigger: function(evt, params) {
457 return UI.$(this.element || this).trigger(evt, params);
458 },
459
460 find: function(selector) {
461 return UI.$(this.element ? this.element: []).find(selector);
462 },
463
464 proxy: function(obj, methods) {
465
466 var $this = this;
467
468 methods.split(' ').forEach(function(method) {
469 if (!$this[method]) $this[method] = function() { return obj[method].apply(obj, arguments); };
470 });
471 },
472
473 mixin: function(obj, methods) {
474
475 var $this = this;
476
477 methods.split(' ').forEach(function(method) {
478 if (!$this[method]) $this[method] = obj[method].bind($this);
479 });
480 },
481
482 option: function() {
483
484 if (arguments.length == 1) {
485 return this.options[arguments[0]] || undefined;
486 } else if (arguments.length == 2) {
487 this.options[arguments[0]] = arguments[1];
488 }
489 }
490
491 }, def);
492
493 this.components[name] = fn;
494
495 this[name] = function() {
496
497 var element, options;
498
499 if (arguments.length) {
500
501 switch(arguments.length) {
502 case 1:
503
504 if (typeof arguments[0] === "string" || arguments[0].nodeType || arguments[0] instanceof jQuery) {
505 element = $(arguments[0]);
506 } else {
507 options = arguments[0];
508 }
509
510 break;
511 case 2:
512
513 element = $(arguments[0]);
514 options = arguments[1];
515 break;
516 }
517 }
518
519 if (element && element.data(name)) {
520 return element.data(name);
521 }
522
523 return (new UI.components[name](element, options));
524 };
525
526 if (UI.domready) {
527 UI.component.boot(name);
528 }
529
530 return fn;
531 };
532
533 UI.plugin = function(component, name, def) {
534 this.components[component].plugins[name] = def;
535 };
536
537 UI.component.boot = function(name) {
538
539 if (UI.components[name].prototype && UI.components[name].prototype.boot && !UI.components[name].booted) {
540 UI.components[name].prototype.boot.apply(UI, []);
541 UI.components[name].booted = true;
542 }
543 };
544
545 UI.component.bootComponents = function() {
546
547 for (var component in UI.components) {
548 UI.component.boot(component);
549 }
550 };
551
552
553 // DOM mutation save ready helper function
554
555 UI.domObservers = [];
556 UI.domready = false;
557
558 UI.ready = function(fn) {
559
560 UI.domObservers.push(fn);
561
562 if (UI.domready) {
563 fn(document);
564 }
565 };
566
567 UI.on = function(a1,a2,a3){
568
569 if (a1 && a1.indexOf('ready.uk.dom') > -1 && UI.domready) {
570 a2.apply(UI.$doc);
571 }
572
573 return UI.$doc.on(a1,a2,a3);
574 };
575
576 UI.one = function(a1,a2,a3){
577
578 if (a1 && a1.indexOf('ready.uk.dom') > -1 && UI.domready) {
579 a2.apply(UI.$doc);
580 return UI.$doc;
581 }
582
583 return UI.$doc.one(a1,a2,a3);
584 };
585
586 UI.trigger = function(evt, params) {
587 return UI.$doc.trigger(evt, params);
588 };
589
590 UI.domObserve = function(selector, fn) {
591
592 if(!UI.support.mutationobserver) return;
593
594 fn = fn || function() {};
595
596 UI.$(selector).each(function() {
597
598 var element = this,
599 $element = UI.$(element);
600
601 if ($element.data('observer')) {
602 return;
603 }
604
605 try {
606
607 var observer = new UI.support.mutationobserver(UI.Utils.debounce(function(mutations) {
608 fn.apply(element, []);
609 $element.trigger('changed.uk.dom');
610 }, 50), {childList: true, subtree: true});
611
612 // pass in the target node, as well as the observer options
613 observer.observe(element, { childList: true, subtree: true });
614
615 $element.data('observer', observer);
616
617 } catch(e) {}
618 });
619 };
620
621 UI.init = function(root) {
622
623 root = root || document;
624
625 UI.domObservers.forEach(function(fn){
626 fn(root);
627 });
628 };
629
630 UI.on('domready.uk.dom', function(){
631
632 UI.init();
633
634 if (UI.domready) UI.Utils.checkDisplay();
635 });
636
637 document.addEventListener('DOMContentLoaded', function(){
638
639 var domReady = function() {
640
641 UI.$body = UI.$('body');
642
643 UI.trigger('beforeready.uk.dom');
644
645 UI.component.bootComponents();
646
647 // custom scroll observer
648 var rafToken = requestAnimationFrame((function(){
649
650 var memory = {dir: {x:0, y:0}, x: window.pageXOffset, y:window.pageYOffset};
651
652 var fn = function(){
653 // reading this (window.page[X|Y]Offset) causes a full page recalc of the layout in Chrome,
654 // so we only want to do this once
655 var wpxo = window.pageXOffset;
656 var wpyo = window.pageYOffset;
657
658 // Did the scroll position change since the last time we were here?
659 if (memory.x != wpxo || memory.y != wpyo) {
660
661 // Set the direction of the scroll and store the new position
662 if (wpxo != memory.x) {memory.dir.x = wpxo > memory.x ? 1:-1; } else { memory.dir.x = 0; }
663 if (wpyo != memory.y) {memory.dir.y = wpyo > memory.y ? 1:-1; } else { memory.dir.y = 0; }
664
665 memory.x = wpxo;
666 memory.y = wpyo;
667
668 // Trigger the scroll event, this could probably be sent using memory.clone() but this is
669 // more explicit and easier to see exactly what is being sent in the event.
670 UI.$doc.trigger('scrolling.uk.document', [{
671 "dir": {"x": memory.dir.x, "y": memory.dir.y}, "x": wpxo, "y": wpyo
672 }]);
673 }
674
675 cancelAnimationFrame(rafToken);
676 rafToken = requestAnimationFrame(fn);
677 };
678
679 if (UI.support.touch) {
680 UI.$html.on('touchmove touchend MSPointerMove MSPointerUp pointermove pointerup', fn);
681 }
682
683 if (memory.x || memory.y) fn();
684
685 return fn;
686
687 })());
688
689 // run component init functions on dom
690 UI.trigger('domready.uk.dom');
691
692 if (UI.support.touch) {
693
694 // remove css hover rules for touch devices
695 // UI.Utils.removeCssRules(/\.uk-(?!navbar).*:hover/);
696
697 // viewport unit fix for uk-height-viewport - should be fixed in iOS 8
698 if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) {
699
700 UI.$win.on('load orientationchange resize', UI.Utils.debounce((function(){
701
702 var fn = function() {
703 $('.uk-height-viewport').css('height', window.innerHeight);
704 return fn;
705 };
706
707 return fn();
708
709 })(), 100));
710 }
711 }
712
713 UI.trigger('afterready.uk.dom');
714
715 // mark that domready is left behind
716 UI.domready = true;
717
718 // auto init js components
719 if (UI.support.mutationobserver) {
720
721 var initFn = UI.Utils.debounce(function(){
722 requestAnimationFrame(function(){ UI.init(document.body);});
723 }, 10);
724
725 (new UI.support.mutationobserver(function(mutations) {
726
727 var init = false;
728
729 mutations.every(function(mutation){
730
731 if (mutation.type != 'childList') return true;
732
733 for (var i = 0, node; i < mutation.addedNodes.length; ++i) {
734
735 node = mutation.addedNodes[i];
736
737 if (node.outerHTML && node.outerHTML.indexOf('data-uk-') !== -1) {
738 return (init = true) && false;
739 }
740 }
741 return true;
742 });
743
744 if (init) initFn();
745
746 })).observe(document.body, {childList: true, subtree: true});
747 }
748 };
749
750 if (document.readyState == 'complete' || document.readyState == 'interactive') {
751 setTimeout(domReady);
752 }
753
754 return domReady;
755
756 }());
757
758 // add touch identifier class
759 UI.$html.addClass(UI.support.touch ? "uk-touch" : "uk-notouch");
760
761 // add uk-hover class on tap to support overlays on touch devices
762 if (UI.support.touch) {
763
764 var hoverset = false,
765 exclude,
766 hovercls = 'uk-hover',
767 selector = '.uk-overlay, .uk-overlay-hover, .uk-overlay-toggle, .uk-animation-hover, .uk-has-hover';
768
769 UI.$html.on('mouseenter touchstart MSPointerDown pointerdown', selector, function() {
770
771 if (hoverset) $('.'+hovercls).removeClass(hovercls);
772
773 hoverset = $(this).addClass(hovercls);
774
775 }).on('mouseleave touchend MSPointerUp pointerup', function(e) {
776
777 exclude = $(e.target).parents(selector);
778
779 if (hoverset) {
780 hoverset.not(exclude).removeClass(hovercls);
781 }
782 });
783 }
784
785 return UI;
786});
787
788// Based on Zeptos touch.js
789// https://raw.github.com/madrobby/zepto/master/src/touch.js
790// Zepto.js may be freely distributed under the MIT license.
791
792;(function($){
793
794 if ($.fn.swipeLeft) {
795 return;
796 }
797
798
799 var touch = {}, touchTimeout, tapTimeout, swipeTimeout, longTapTimeout, longTapDelay = 750, gesture;
800
801 function swipeDirection(x1, x2, y1, y2) {
802 return Math.abs(x1 - x2) >= Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down');
803 }
804
805 function longTap() {
806 longTapTimeout = null;
807 if (touch.last) {
808 if ( touch.el !== undefined ) touch.el.trigger('longTap');
809 touch = {};
810 }
811 }
812
813 function cancelLongTap() {
814 if (longTapTimeout) clearTimeout(longTapTimeout);
815 longTapTimeout = null;
816 }
817
818 function cancelAll() {
819 if (touchTimeout) clearTimeout(touchTimeout);
820 if (tapTimeout) clearTimeout(tapTimeout);
821 if (swipeTimeout) clearTimeout(swipeTimeout);
822 if (longTapTimeout) clearTimeout(longTapTimeout);
823 touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null;
824 touch = {};
825 }
826
827 function isPrimaryTouch(event){
828 return event.pointerType == event.MSPOINTER_TYPE_TOUCH && event.isPrimary;
829 }
830
831 $(function(){
832 var now, delta, deltaX = 0, deltaY = 0, firstTouch;
833
834 if ('MSGesture' in window) {
835 gesture = new MSGesture();
836 gesture.target = document.body;
837 }
838
839 $(document)
840 .on('MSGestureEnd gestureend', function(e){
841
842 var swipeDirectionFromVelocity = e.originalEvent.velocityX > 1 ? 'Right' : e.originalEvent.velocityX < -1 ? 'Left' : e.originalEvent.velocityY > 1 ? 'Down' : e.originalEvent.velocityY < -1 ? 'Up' : null;
843
844 if (swipeDirectionFromVelocity && touch.el !== undefined) {
845 touch.el.trigger('swipe');
846 touch.el.trigger('swipe'+ swipeDirectionFromVelocity);
847 }
848 })
849 // MSPointerDown: for IE10
850 // pointerdown: for IE11
851 .on('touchstart MSPointerDown pointerdown', function(e){
852
853 if(e.type == 'MSPointerDown' && !isPrimaryTouch(e.originalEvent)) return;
854
855 firstTouch = (e.type == 'MSPointerDown' || e.type == 'pointerdown') ? e : e.originalEvent.touches[0];
856
857 now = Date.now();
858 delta = now - (touch.last || now);
859 touch.el = $('tagName' in firstTouch.target ? firstTouch.target : firstTouch.target.parentNode);
860
861 if(touchTimeout) clearTimeout(touchTimeout);
862
863 touch.x1 = firstTouch.pageX;
864 touch.y1 = firstTouch.pageY;
865
866 if (delta > 0 && delta <= 250) touch.isDoubleTap = true;
867
868 touch.last = now;
869 longTapTimeout = setTimeout(longTap, longTapDelay);
870
871 // adds the current touch contact for IE gesture recognition
872 if (gesture && ( e.type == 'MSPointerDown' || e.type == 'pointerdown' || e.type == 'touchstart' ) ) {
873 gesture.addPointer(e.originalEvent.pointerId);
874 }
875
876 })
877 // MSPointerMove: for IE10
878 // pointermove: for IE11
879 .on('touchmove MSPointerMove pointermove', function(e){
880
881 if (e.type == 'MSPointerMove' && !isPrimaryTouch(e.originalEvent)) return;
882
883 firstTouch = (e.type == 'MSPointerMove' || e.type == 'pointermove') ? e : e.originalEvent.touches[0];
884
885 cancelLongTap();
886 touch.x2 = firstTouch.pageX;
887 touch.y2 = firstTouch.pageY;
888
889 deltaX += Math.abs(touch.x1 - touch.x2);
890 deltaY += Math.abs(touch.y1 - touch.y2);
891 })
892 // MSPointerUp: for IE10
893 // pointerup: for IE11
894 .on('touchend MSPointerUp pointerup', function(e){
895
896 if (e.type == 'MSPointerUp' && !isPrimaryTouch(e.originalEvent)) return;
897
898 cancelLongTap();
899
900 // swipe
901 if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) || (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30)){
902
903 swipeTimeout = setTimeout(function() {
904 if ( touch.el !== undefined ) {
905 touch.el.trigger('swipe');
906 touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)));
907 }
908 touch = {};
909 }, 0);
910
911 // normal tap
912 } else if ('last' in touch) {
913
914 // don't fire tap when delta position changed by more than 30 pixels,
915 // for instance when moving to a point and back to origin
916 if (isNaN(deltaX) || (deltaX < 30 && deltaY < 30)) {
917 // delay by one tick so we can cancel the 'tap' event if 'scroll' fires
918 // ('tap' fires before 'scroll')
919 tapTimeout = setTimeout(function() {
920
921 // trigger universal 'tap' with the option to cancelTouch()
922 // (cancelTouch cancels processing of single vs double taps for faster 'tap' response)
923 var event = $.Event('tap');
924 event.cancelTouch = cancelAll;
925 if ( touch.el !== undefined ) touch.el.trigger(event);
926
927 // trigger double tap immediately
928 if (touch.isDoubleTap) {
929 if ( touch.el !== undefined ) touch.el.trigger('doubleTap');
930 touch = {};
931 }
932
933 // trigger single tap after 250ms of inactivity
934 else {
935 touchTimeout = setTimeout(function(){
936 touchTimeout = null;
937 if ( touch.el !== undefined ) touch.el.trigger('singleTap');
938 touch = {};
939 }, 250);
940 }
941 }, 0);
942 } else {
943 touch = {};
944 }
945 deltaX = deltaY = 0;
946 }
947 })
948 // when the browser window loses focus,
949 // for example when a modal dialog is shown,
950 // cancel all ongoing events
951 .on('touchcancel MSPointerCancel', cancelAll);
952
953 // scrolling the window indicates intention of the user
954 // to scroll, not tap or swipe, so cancel all ongoing events
955 $(window).on('scroll', cancelAll);
956 });
957
958 ['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(eventName){
959 $.fn[eventName] = function(callback){ return $(this).on(eventName, callback); };
960 });
961})(jQuery);
962
963(function(UI) {
964
965 "use strict";
966
967 var stacks = [];
968
969 UI.component('stackMargin', {
970
971 defaults: {
972 cls: 'uk-margin-small-top',
973 rowfirst: false,
974 observe: false
975 },
976
977 boot: function() {
978
979 // init code
980 UI.ready(function(context) {
981
982 UI.$("[data-uk-margin]", context).each(function() {
983
984 var ele = UI.$(this);
985
986 if (!ele.data("stackMargin")) {
987 UI.stackMargin(ele, UI.Utils.options(ele.attr("data-uk-margin")));
988 }
989 });
990 });
991 },
992
993 init: function() {
994
995 var $this = this;
996
997 UI.$win.on('resize orientationchange', (function() {
998
999 var fn = function() {
1000 $this.process();
1001 };
1002
1003 UI.$(function() {
1004 fn();
1005 UI.$win.on("load", fn);
1006 });
1007
1008 return UI.Utils.debounce(fn, 20);
1009 })());
1010
1011 this.on("display.uk.check", function(e) {
1012 if (this.element.is(":visible")) this.process();
1013 }.bind(this));
1014
1015 if (this.options.observe) {
1016
1017 UI.domObserve(this.element, function(e) {
1018 if ($this.element.is(":visible")) $this.process();
1019 });
1020 }
1021
1022 stacks.push(this);
1023 },
1024
1025 process: function() {
1026
1027 var $this = this, columns = this.element.children();
1028
1029 UI.Utils.stackMargin(columns, this.options);
1030
1031 if (!this.options.rowfirst || !columns.length) {
1032 return this;
1033 }
1034
1035 // Mark first column elements
1036 var group = {}, minleft = false;
1037
1038 columns.removeClass(this.options.rowfirst).each(function(offset, $ele){
1039
1040 $ele = UI.$(this);
1041
1042 if (this.style.display != 'none') {
1043 offset = $ele.offset().left;
1044 ((group[offset] = group[offset] || []) && group[offset]).push(this);
1045 minleft = minleft === false ? offset : Math.min(minleft, offset);
1046 }
1047 });
1048
1049 UI.$(group[minleft]).addClass(this.options.rowfirst);
1050
1051 return this;
1052 }
1053
1054 });
1055
1056
1057 // responsive element e.g. iframes
1058
1059 (function(){
1060
1061 var elements = [], check = function(ele) {
1062
1063 if (!ele.is(':visible')) return;
1064
1065 var width = ele.parent().width(),
1066 iwidth = ele.data('width'),
1067 ratio = (width / iwidth),
1068 height = Math.floor(ratio * ele.data('height'));
1069
1070 ele.css({'height': (width < iwidth) ? height : ele.data('height')});
1071 };
1072
1073 UI.component('responsiveElement', {
1074
1075 defaults: {},
1076
1077 boot: function() {
1078
1079 // init code
1080 UI.ready(function(context) {
1081
1082 UI.$("iframe.uk-responsive-width, [data-uk-responsive]", context).each(function() {
1083
1084 var ele = UI.$(this), obj;
1085
1086 if (!ele.data("responsiveElement")) {
1087 obj = UI.responsiveElement(ele, {});
1088 }
1089 });
1090 });
1091 },
1092
1093 init: function() {
1094
1095 var ele = this.element;
1096
1097 if (ele.attr('width') && ele.attr('height')) {
1098
1099 ele.data({
1100
1101 'width' : ele.attr('width'),
1102 'height': ele.attr('height')
1103
1104 }).on('display.uk.check', function(){
1105 check(ele);
1106 });
1107
1108 check(ele);
1109
1110 elements.push(ele);
1111 }
1112 }
1113 });
1114
1115 UI.$win.on('resize load', UI.Utils.debounce(function(){
1116
1117 elements.forEach(function(ele){
1118 check(ele);
1119 });
1120
1121 }, 15));
1122
1123 })();
1124
1125
1126
1127 // helper
1128
1129 UI.Utils.stackMargin = function(elements, options) {
1130
1131 options = UI.$.extend({
1132 'cls': 'uk-margin-small-top'
1133 }, options);
1134
1135 elements = UI.$(elements).removeClass(options.cls);
1136
1137 var min = false;
1138
1139 elements.each(function(offset, height, pos, $ele){
1140
1141 $ele = UI.$(this);
1142
1143 if ($ele.css('display') != 'none') {
1144
1145 offset = $ele.offset();
1146 height = $ele.outerHeight();
1147 pos = offset.top + height;
1148
1149 $ele.data({
1150 'ukMarginPos': pos,
1151 'ukMarginTop': offset.top
1152 });
1153
1154 if (min === false || (offset.top < min.top) ) {
1155
1156 min = {
1157 top : offset.top,
1158 left : offset.left,
1159 pos : pos
1160 };
1161 }
1162 }
1163
1164 }).each(function($ele) {
1165
1166 $ele = UI.$(this);
1167
1168 if ($ele.css('display') != 'none' && $ele.data('ukMarginTop') > min.top && $ele.data('ukMarginPos') > min.pos) {
1169 $ele.addClass(options.cls);
1170 }
1171 });
1172 };
1173
1174 UI.Utils.matchHeights = function(elements, options) {
1175
1176 elements = UI.$(elements).css('min-height', '');
1177 options = UI.$.extend({ row : true }, options);
1178
1179 var matchHeights = function(group){
1180
1181 if (group.length < 2) return;
1182
1183 var max = 0;
1184
1185 group.each(function() {
1186 max = Math.max(max, UI.$(this).outerHeight());
1187 }).each(function() {
1188
1189 var element = UI.$(this),
1190 height = max - (element.css('box-sizing') == 'border-box' ? 0 : (element.outerHeight() - element.height()));
1191
1192 element.css('min-height', height + 'px');
1193 });
1194 };
1195
1196 if (options.row) {
1197
1198 elements.first().width(); // force redraw
1199
1200 setTimeout(function(){
1201
1202 var lastoffset = false, group = [];
1203
1204 elements.each(function() {
1205
1206 var ele = UI.$(this), offset = ele.offset().top;
1207
1208 if (offset != lastoffset && group.length) {
1209
1210 matchHeights(UI.$(group));
1211 group = [];
1212 offset = ele.offset().top;
1213 }
1214
1215 group.push(ele);
1216 lastoffset = offset;
1217 });
1218
1219 if (group.length) {
1220 matchHeights(UI.$(group));
1221 }
1222
1223 }, 0);
1224
1225 } else {
1226 matchHeights(elements);
1227 }
1228 };
1229
1230 (function(cacheSvgs){
1231
1232 UI.Utils.inlineSvg = function(selector, root) {
1233
1234 var images = UI.$(selector || 'img[src$=".svg"]', root || document).each(function(){
1235
1236 var img = UI.$(this),
1237 src = img.attr('src');
1238
1239 if (!cacheSvgs[src]) {
1240
1241 var d = UI.$.Deferred();
1242
1243 UI.$.get(src, {nc: Math.random()}, function(data){
1244 d.resolve(UI.$(data).find('svg'));
1245 });
1246
1247 cacheSvgs[src] = d.promise();
1248 }
1249
1250 cacheSvgs[src].then(function(svg) {
1251
1252 var $svg = UI.$(svg).clone();
1253
1254 if (img.attr('id')) $svg.attr('id', img.attr('id'));
1255 if (img.attr('class')) $svg.attr('class', img.attr('class'));
1256 if (img.attr('style')) $svg.attr('style', img.attr('style'));
1257
1258 if (img.attr('width')) {
1259 $svg.attr('width', img.attr('width'));
1260 if (!img.attr('height')) $svg.removeAttr('height');
1261 }
1262
1263 if (img.attr('height')){
1264 $svg.attr('height', img.attr('height'));
1265 if (!img.attr('width')) $svg.removeAttr('width');
1266 }
1267
1268 img.replaceWith($svg);
1269 });
1270 });
1271 };
1272
1273 // init code
1274 UI.ready(function(context) {
1275 UI.Utils.inlineSvg('[data-uk-svg]', context);
1276 });
1277
1278 })({});
1279
1280})(UIkit);
1281
1282(function(UI) {
1283
1284 "use strict";
1285
1286 UI.component('smoothScroll', {
1287
1288 boot: function() {
1289
1290 // init code
1291 UI.$html.on("click.smooth-scroll.uikit", "[data-uk-smooth-scroll]", function(e) {
1292 var ele = UI.$(this);
1293
1294 if (!ele.data("smoothScroll")) {
1295 var obj = UI.smoothScroll(ele, UI.Utils.options(ele.attr("data-uk-smooth-scroll")));
1296 ele.trigger("click");
1297 }
1298
1299 return false;
1300 });
1301 },
1302
1303 init: function() {
1304
1305 var $this = this;
1306
1307 this.on("click", function(e) {
1308 e.preventDefault();
1309 scrollToElement(UI.$(this.hash).length ? UI.$(this.hash) : UI.$("body"), $this.options);
1310 });
1311 }
1312 });
1313
1314 function scrollToElement(ele, options) {
1315
1316 options = UI.$.extend({
1317 duration: 1000,
1318 transition: 'easeOutExpo',
1319 offset: 0,
1320 complete: function(){}
1321 }, options);
1322
1323 // get / set parameters
1324 var target = ele.offset().top - options.offset,
1325 docheight = UI.$doc.height(),
1326 winheight = window.innerHeight;
1327
1328 if ((target + winheight) > docheight) {
1329 target = docheight - winheight;
1330 }
1331
1332 // animate to target, fire callback when done
1333 UI.$("html,body").stop().animate({scrollTop: target}, options.duration, options.transition).promise().done(options.complete);
1334 }
1335
1336 UI.Utils.scrollToElement = scrollToElement;
1337
1338 if (!UI.$.easing.easeOutExpo) {
1339 UI.$.easing.easeOutExpo = function(x, t, b, c, d) { return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; };
1340 }
1341
1342})(UIkit);
1343
1344(function(UI) {
1345
1346 "use strict";
1347
1348 var $win = UI.$win,
1349 $doc = UI.$doc,
1350 scrollspies = [],
1351 checkScrollSpy = function() {
1352 for(var i=0; i < scrollspies.length; i++) {
1353 window.requestAnimationFrame.apply(window, [scrollspies[i].check]);
1354 }
1355 };
1356
1357 UI.component('scrollspy', {
1358
1359 defaults: {
1360 "target" : false,
1361 "cls" : "uk-scrollspy-inview",
1362 "initcls" : "uk-scrollspy-init-inview",
1363 "topoffset" : 0,
1364 "leftoffset" : 0,
1365 "repeat" : false,
1366 "delay" : 0
1367 },
1368
1369 boot: function() {
1370
1371 // listen to scroll and resize
1372 $doc.on("scrolling.uk.document", checkScrollSpy);
1373 $win.on("load resize orientationchange", UI.Utils.debounce(checkScrollSpy, 50));
1374
1375 // init code
1376 UI.ready(function(context) {
1377
1378 UI.$("[data-uk-scrollspy]", context).each(function() {
1379
1380 var element = UI.$(this);
1381
1382 if (!element.data("scrollspy")) {
1383 var obj = UI.scrollspy(element, UI.Utils.options(element.attr("data-uk-scrollspy")));
1384 }
1385 });
1386 });
1387 },
1388
1389 init: function() {
1390
1391 var $this = this, inviewstate, initinview, togglecls = this.options.cls.split(/,/), fn = function(){
1392
1393 var elements = $this.options.target ? $this.element.find($this.options.target) : $this.element,
1394 delayIdx = elements.length === 1 ? 1 : 0,
1395 toggleclsIdx = 0;
1396
1397 elements.each(function(idx){
1398
1399 var element = UI.$(this),
1400 inviewstate = element.data('inviewstate'),
1401 inview = UI.Utils.isInView(element, $this.options),
1402 toggle = element.data('ukScrollspyCls') || togglecls[toggleclsIdx].trim();
1403
1404 if (inview && !inviewstate && !element.data('scrollspy-idle')) {
1405
1406 if (!initinview) {
1407 element.addClass($this.options.initcls);
1408 $this.offset = element.offset();
1409 initinview = true;
1410
1411 element.trigger("init.uk.scrollspy");
1412 }
1413
1414 element.data('scrollspy-idle', setTimeout(function(){
1415
1416 element.addClass("uk-scrollspy-inview").toggleClass(toggle).width();
1417 element.trigger("inview.uk.scrollspy");
1418
1419 element.data('scrollspy-idle', false);
1420 element.data('inviewstate', true);
1421
1422 }, $this.options.delay * delayIdx));
1423
1424 delayIdx++;
1425 }
1426
1427 if (!inview && inviewstate && $this.options.repeat) {
1428
1429 if (element.data('scrollspy-idle')) {
1430 clearTimeout(element.data('scrollspy-idle'));
1431 element.data('scrollspy-idle', false);
1432 }
1433
1434 element.removeClass("uk-scrollspy-inview").toggleClass(toggle);
1435 element.data('inviewstate', false);
1436
1437 element.trigger("outview.uk.scrollspy");
1438 }
1439
1440 toggleclsIdx = togglecls[toggleclsIdx + 1] ? (toggleclsIdx + 1) : 0;
1441
1442 });
1443 };
1444
1445 fn();
1446
1447 this.check = fn;
1448
1449 scrollspies.push(this);
1450 }
1451 });
1452
1453
1454 var scrollspynavs = [],
1455 checkScrollSpyNavs = function() {
1456 for(var i=0; i < scrollspynavs.length; i++) {
1457 window.requestAnimationFrame.apply(window, [scrollspynavs[i].check]);
1458 }
1459 };
1460
1461 UI.component('scrollspynav', {
1462
1463 defaults: {
1464 "cls" : 'uk-active',
1465 "closest" : false,
1466 "topoffset" : 0,
1467 "leftoffset" : 0,
1468 "smoothscroll" : false
1469 },
1470
1471 boot: function() {
1472
1473 // listen to scroll and resize
1474 $doc.on("scrolling.uk.document", checkScrollSpyNavs);
1475 $win.on("resize orientationchange", UI.Utils.debounce(checkScrollSpyNavs, 50));
1476
1477 // init code
1478 UI.ready(function(context) {
1479
1480 UI.$("[data-uk-scrollspy-nav]", context).each(function() {
1481
1482 var element = UI.$(this);
1483
1484 if (!element.data("scrollspynav")) {
1485 var obj = UI.scrollspynav(element, UI.Utils.options(element.attr("data-uk-scrollspy-nav")));
1486 }
1487 });
1488 });
1489 },
1490
1491 init: function() {
1492
1493 var ids = [],
1494 links = this.find("a[href^='#']").each(function(){ if(this.getAttribute("href").trim()!=='#') ids.push(this.getAttribute("href")); }),
1495 targets = UI.$(ids.join(",")),
1496
1497 clsActive = this.options.cls,
1498 clsClosest = this.options.closest || this.options.closest;
1499
1500 var $this = this, inviews, fn = function(){
1501
1502 inviews = [];
1503
1504 for (var i=0 ; i < targets.length ; i++) {
1505 if (UI.Utils.isInView(targets.eq(i), $this.options)) {
1506 inviews.push(targets.eq(i));
1507 }
1508 }
1509
1510 if (inviews.length) {
1511
1512 var navitems,
1513 scrollTop = $win.scrollTop(),
1514 target = (function(){
1515 for(var i=0; i< inviews.length;i++){
1516 if (inviews[i].offset().top - $this.options.topoffset >= scrollTop){
1517 return inviews[i];
1518 }
1519 }
1520 })();
1521
1522 if (!target) return;
1523
1524 if ($this.options.closest) {
1525 links.blur().closest(clsClosest).removeClass(clsActive);
1526 navitems = links.filter("a[href='#"+target.attr("id")+"']").closest(clsClosest).addClass(clsActive);
1527 } else {
1528 navitems = links.removeClass(clsActive).filter("a[href='#"+target.attr("id")+"']").addClass(clsActive);
1529 }
1530
1531 $this.element.trigger("inview.uk.scrollspynav", [target, navitems]);
1532 }
1533 };
1534
1535 if (this.options.smoothscroll && UI.smoothScroll) {
1536 links.each(function(){
1537 UI.smoothScroll(this, $this.options.smoothscroll);
1538 });
1539 }
1540
1541 fn();
1542
1543 this.element.data("scrollspynav", this);
1544
1545 this.check = fn;
1546 scrollspynavs.push(this);
1547
1548 }
1549 });
1550
1551})(UIkit);
1552
1553(function(UI){
1554
1555 "use strict";
1556
1557 var toggles = [];
1558
1559 UI.component('toggle', {
1560
1561 defaults: {
1562 target : false,
1563 cls : 'uk-hidden',
1564 animation : false,
1565 duration : 200
1566 },
1567
1568 boot: function(){
1569
1570 // init code
1571 UI.ready(function(context) {
1572
1573 UI.$("[data-uk-toggle]", context).each(function() {
1574 var ele = UI.$(this);
1575
1576 if (!ele.data("toggle")) {
1577 var obj = UI.toggle(ele, UI.Utils.options(ele.attr("data-uk-toggle")));
1578 }
1579 });
1580
1581 setTimeout(function(){
1582
1583 toggles.forEach(function(toggle){
1584 toggle.getToggles();
1585 });
1586
1587 }, 0);
1588 });
1589 },
1590
1591 init: function() {
1592
1593 var $this = this;
1594
1595 this.aria = (this.options.cls.indexOf('uk-hidden') !== -1);
1596
1597 this.getToggles();
1598
1599 this.on("click", function(e) {
1600 if ($this.element.is('a[href="#"]')) e.preventDefault();
1601 $this.toggle();
1602 });
1603
1604 toggles.push(this);
1605 },
1606
1607 toggle: function() {
1608
1609 if(!this.totoggle.length) return;
1610
1611 if (this.options.animation && UI.support.animation) {
1612
1613 var $this = this, animations = this.options.animation.split(',');
1614
1615 if (animations.length == 1) {
1616 animations[1] = animations[0];
1617 }
1618
1619 animations[0] = animations[0].trim();
1620 animations[1] = animations[1].trim();
1621
1622 this.totoggle.css('animation-duration', this.options.duration+'ms');
1623
1624 this.totoggle.each(function(){
1625
1626 var ele = UI.$(this);
1627
1628 if (ele.hasClass($this.options.cls)) {
1629
1630 ele.toggleClass($this.options.cls);
1631
1632 UI.Utils.animate(ele, animations[0]).then(function(){
1633 ele.css('animation-duration', '');
1634 UI.Utils.checkDisplay(ele);
1635 });
1636
1637 } else {
1638
1639 UI.Utils.animate(this, animations[1]+' uk-animation-reverse').then(function(){
1640 ele.toggleClass($this.options.cls).css('animation-duration', '');
1641 UI.Utils.checkDisplay(ele);
1642 });
1643
1644 }
1645
1646 });
1647
1648 } else {
1649 this.totoggle.toggleClass(this.options.cls);
1650 UI.Utils.checkDisplay(this.totoggle);
1651 }
1652
1653 this.updateAria();
1654
1655 },
1656
1657 getToggles: function() {
1658 this.totoggle = this.options.target ? UI.$(this.options.target):[];
1659 this.updateAria();
1660 },
1661
1662 updateAria: function() {
1663 if (this.aria && this.totoggle.length) {
1664 this.totoggle.each(function(){
1665 UI.$(this).attr('aria-hidden', UI.$(this).hasClass('uk-hidden'));
1666 });
1667 }
1668 }
1669 });
1670
1671})(UIkit);
1672
1673(function(UI) {
1674
1675 "use strict";
1676
1677 UI.component('alert', {
1678
1679 defaults: {
1680 "fade": true,
1681 "duration": 200,
1682 "trigger": ".uk-alert-close"
1683 },
1684
1685 boot: function() {
1686
1687 // init code
1688 UI.$html.on("click.alert.uikit", "[data-uk-alert]", function(e) {
1689
1690 var ele = UI.$(this);
1691
1692 if (!ele.data("alert")) {
1693
1694 var alert = UI.alert(ele, UI.Utils.options(ele.attr("data-uk-alert")));
1695
1696 if (UI.$(e.target).is(alert.options.trigger)) {
1697 e.preventDefault();
1698 alert.close();
1699 }
1700 }
1701 });
1702 },
1703
1704 init: function() {
1705
1706 var $this = this;
1707
1708 this.on("click", this.options.trigger, function(e) {
1709 e.preventDefault();
1710 $this.close();
1711 });
1712 },
1713
1714 close: function() {
1715
1716 var element = this.trigger("close.uk.alert"),
1717 removeElement = function () {
1718 this.trigger("closed.uk.alert").remove();
1719 }.bind(this);
1720
1721 if (this.options.fade) {
1722 element.css("overflow", "hidden").css("max-height", element.height()).animate({
1723 "height" : 0,
1724 "opacity" : 0,
1725 "padding-top" : 0,
1726 "padding-bottom" : 0,
1727 "margin-top" : 0,
1728 "margin-bottom" : 0
1729 }, this.options.duration, removeElement);
1730 } else {
1731 removeElement();
1732 }
1733 }
1734
1735 });
1736
1737})(UIkit);
1738
1739(function(UI) {
1740
1741 "use strict";
1742
1743 UI.component('buttonRadio', {
1744
1745 defaults: {
1746 "activeClass": 'uk-active',
1747 "target": ".uk-button"
1748 },
1749
1750 boot: function() {
1751
1752 // init code
1753 UI.$html.on("click.buttonradio.uikit", "[data-uk-button-radio]", function(e) {
1754
1755 var ele = UI.$(this);
1756
1757 if (!ele.data("buttonRadio")) {
1758
1759 var obj = UI.buttonRadio(ele, UI.Utils.options(ele.attr("data-uk-button-radio"))),
1760 target = UI.$(e.target);
1761
1762 if (target.is(obj.options.target)) {
1763 target.trigger("click");
1764 }
1765 }
1766 });
1767 },
1768
1769 init: function() {
1770
1771 var $this = this;
1772
1773 // Init ARIA
1774 this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true');
1775
1776 this.on("click", this.options.target, function(e) {
1777
1778 var ele = UI.$(this);
1779
1780 if (ele.is('a[href="#"]')) e.preventDefault();
1781
1782 $this.find($this.options.target).not(ele).removeClass($this.options.activeClass).blur();
1783 ele.addClass($this.options.activeClass);
1784
1785 // Update ARIA
1786 $this.find($this.options.target).not(ele).attr('aria-checked', 'false');
1787 ele.attr('aria-checked', 'true');
1788
1789 $this.trigger("change.uk.button", [ele]);
1790 });
1791
1792 },
1793
1794 getSelected: function() {
1795 return this.find('.' + this.options.activeClass);
1796 }
1797 });
1798
1799 UI.component('buttonCheckbox', {
1800
1801 defaults: {
1802 "activeClass": 'uk-active',
1803 "target": ".uk-button"
1804 },
1805
1806 boot: function() {
1807
1808 UI.$html.on("click.buttoncheckbox.uikit", "[data-uk-button-checkbox]", function(e) {
1809 var ele = UI.$(this);
1810
1811 if (!ele.data("buttonCheckbox")) {
1812
1813 var obj = UI.buttonCheckbox(ele, UI.Utils.options(ele.attr("data-uk-button-checkbox"))),
1814 target = UI.$(e.target);
1815
1816 if (target.is(obj.options.target)) {
1817 target.trigger("click");
1818 }
1819 }
1820 });
1821 },
1822
1823 init: function() {
1824
1825 var $this = this;
1826
1827 // Init ARIA
1828 this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true');
1829
1830 this.on("click", this.options.target, function(e) {
1831 var ele = UI.$(this);
1832
1833 if (ele.is('a[href="#"]')) e.preventDefault();
1834
1835 ele.toggleClass($this.options.activeClass).blur();
1836
1837 // Update ARIA
1838 ele.attr('aria-checked', ele.hasClass($this.options.activeClass));
1839
1840 $this.trigger("change.uk.button", [ele]);
1841 });
1842
1843 },
1844
1845 getSelected: function() {
1846 return this.find('.' + this.options.activeClass);
1847 }
1848 });
1849
1850
1851 UI.component('button', {
1852
1853 defaults: {},
1854
1855 boot: function() {
1856
1857 UI.$html.on("click.button.uikit", "[data-uk-button]", function(e) {
1858 var ele = UI.$(this);
1859
1860 if (!ele.data("button")) {
1861
1862 var obj = UI.button(ele, UI.Utils.options(ele.attr("data-uk-button")));
1863 ele.trigger("click");
1864 }
1865 });
1866 },
1867
1868 init: function() {
1869
1870 var $this = this;
1871
1872 // Init ARIA
1873 this.element.attr('aria-pressed', this.element.hasClass("uk-active"));
1874
1875 this.on("click", function(e) {
1876
1877 if ($this.element.is('a[href="#"]')) e.preventDefault();
1878
1879 $this.toggle();
1880 $this.trigger("change.uk.button", [$this.element.blur().hasClass("uk-active")]);
1881 });
1882
1883 },
1884
1885 toggle: function() {
1886 this.element.toggleClass("uk-active");
1887
1888 // Update ARIA
1889 this.element.attr('aria-pressed', this.element.hasClass("uk-active"));
1890 }
1891 });
1892
1893})(UIkit);
1894
1895
1896(function(UI) {
1897
1898 "use strict";
1899
1900 var active = false, hoverIdle, flips = {
1901 'x': {
1902 "bottom-left" : 'bottom-right',
1903 "bottom-right" : 'bottom-left',
1904 "bottom-center" : 'bottom-center',
1905 "top-left" : 'top-right',
1906 "top-right" : 'top-left',
1907 "top-center" : 'top-center',
1908 "left-top" : 'right-top',
1909 "left-bottom" : 'right-bottom',
1910 "left-center" : 'right-center',
1911 "right-top" : 'left-top',
1912 "right-bottom" : 'left-bottom',
1913 "right-center" : 'left-center'
1914 },
1915 'y': {
1916 "bottom-left" : 'top-left',
1917 "bottom-right" : 'top-right',
1918 "bottom-center" : 'top-center',
1919 "top-left" : 'bottom-left',
1920 "top-right" : 'bottom-right',
1921 "top-center" : 'bottom-center',
1922 "left-top" : 'left-bottom',
1923 "left-bottom" : 'left-top',
1924 "left-center" : 'left-center',
1925 "right-top" : 'right-bottom',
1926 "right-bottom" : 'right-top',
1927 "right-center" : 'right-center'
1928 },
1929 'xy': {
1930 "bottom-left" : 'top-right',
1931 "bottom-right" : 'top-left',
1932 "bottom-center" : 'top-center',
1933 "top-left" : 'bottom-right',
1934 "top-right" : 'bottom-left',
1935 "top-center" : 'bottom-center',
1936 "left-top" : 'right-bottom',
1937 "left-bottom" : 'right-top',
1938 "left-center" : 'right-center',
1939 "right-top" : 'left-bottom',
1940 "right-bottom" : 'left-top',
1941 "right-center" : 'left-center'
1942 }
1943 };
1944
1945 UI.component('dropdown', {
1946
1947 defaults: {
1948 'mode' : 'hover',
1949 'pos' : 'bottom-left',
1950 'offset' : 0,
1951 'remaintime' : 800,
1952 'justify' : false,
1953 'boundary' : UI.$win,
1954 'delay' : 0,
1955 'dropdownSelector': '.uk-dropdown,.uk-dropdown-blank',
1956 'hoverDelayIdle' : 250,
1957 'preventflip' : false
1958 },
1959
1960 remainIdle: false,
1961
1962 boot: function() {
1963
1964 var triggerevent = UI.support.touch ? "click" : "mouseenter";
1965
1966 // init code
1967 UI.$html.on(triggerevent+".dropdown.uikit", "[data-uk-dropdown]", function(e) {
1968
1969 var ele = UI.$(this);
1970
1971 if (!ele.data("dropdown")) {
1972
1973 var dropdown = UI.dropdown(ele, UI.Utils.options(ele.attr("data-uk-dropdown")));
1974
1975 if (triggerevent=="click" || (triggerevent=="mouseenter" && dropdown.options.mode=="hover")) {
1976 dropdown.element.trigger(triggerevent);
1977 }
1978
1979 if (dropdown.element.find(dropdown.options.dropdownSelector).length) {
1980 e.preventDefault();
1981 }
1982 }
1983 });
1984 },
1985
1986 init: function() {
1987
1988 var $this = this;
1989
1990 this.dropdown = this.find(this.options.dropdownSelector);
1991 this.offsetParent = this.dropdown.parents().filter(function() {
1992 return UI.$.inArray(UI.$(this).css('position'), ['relative', 'fixed', 'absolute']) !== -1;
1993 }).slice(0,1);
1994
1995 this.centered = this.dropdown.hasClass('uk-dropdown-center');
1996 this.justified = this.options.justify ? UI.$(this.options.justify) : false;
1997
1998 this.boundary = UI.$(this.options.boundary);
1999
2000 if (!this.boundary.length) {
2001 this.boundary = UI.$win;
2002 }
2003
2004 // legacy DEPRECATED!
2005 if (this.dropdown.hasClass('uk-dropdown-up')) {
2006 this.options.pos = 'top-left';
2007 }
2008 if (this.dropdown.hasClass('uk-dropdown-flip')) {
2009 this.options.pos = this.options.pos.replace('left','right');
2010 }
2011 if (this.dropdown.hasClass('uk-dropdown-center')) {
2012 this.options.pos = this.options.pos.replace(/(left|right)/,'center');
2013 }
2014 //-- end legacy
2015
2016 // Init ARIA
2017 this.element.attr('aria-haspopup', 'true');
2018 this.element.attr('aria-expanded', this.element.hasClass("uk-open"));
2019
2020 if (this.options.mode == "click" || UI.support.touch) {
2021
2022 this.on("click.uk.dropdown", function(e) {
2023
2024 var $target = UI.$(e.target);
2025
2026 if (!$target.parents($this.options.dropdownSelector).length) {
2027
2028 if ($target.is("a[href='#']") || $target.parent().is("a[href='#']") || ($this.dropdown.length && !$this.dropdown.is(":visible")) ){
2029 e.preventDefault();
2030 }
2031
2032 $target.blur();
2033 }
2034
2035 if (!$this.element.hasClass('uk-open')) {
2036
2037 $this.show();
2038
2039 } else {
2040
2041 if (!$this.dropdown.find(e.target).length || $target.is(".uk-dropdown-close") || $target.parents(".uk-dropdown-close").length) {
2042 $this.hide();
2043 }
2044 }
2045 });
2046
2047 } else {
2048
2049 this.on("mouseenter", function(e) {
2050
2051 $this.trigger('pointerenter.uk.dropdown', [$this]);
2052
2053 if ($this.remainIdle) {
2054 clearTimeout($this.remainIdle);
2055 }
2056
2057 if (hoverIdle) {
2058 clearTimeout(hoverIdle);
2059 }
2060
2061 if (active && active == $this) {
2062 return;
2063 }
2064
2065 // pseudo manuAim
2066 if (active && active != $this) {
2067
2068 hoverIdle = setTimeout(function() {
2069 hoverIdle = setTimeout($this.show.bind($this), $this.options.delay);
2070 }, $this.options.hoverDelayIdle);
2071
2072 } else {
2073
2074 hoverIdle = setTimeout($this.show.bind($this), $this.options.delay);
2075 }
2076
2077 }).on("mouseleave", function() {
2078
2079 if (hoverIdle) {
2080 clearTimeout(hoverIdle);
2081 }
2082
2083 $this.remainIdle = setTimeout(function() {
2084 if (active && active == $this) $this.hide();
2085 }, $this.options.remaintime);
2086
2087 $this.trigger('pointerleave.uk.dropdown', [$this]);
2088
2089 }).on("click", function(e){
2090
2091 var $target = UI.$(e.target);
2092
2093 if ($this.remainIdle) {
2094 clearTimeout($this.remainIdle);
2095 }
2096
2097 if (active && active == $this) {
2098 if (!$this.dropdown.find(e.target).length || $target.is(".uk-dropdown-close") || $target.parents(".uk-dropdown-close").length) {
2099 $this.hide();
2100 }
2101 return;
2102 }
2103
2104 if ($target.is("a[href='#']") || $target.parent().is("a[href='#']")){
2105 e.preventDefault();
2106 }
2107
2108 $this.show();
2109 });
2110 }
2111 },
2112
2113 show: function(){
2114
2115 UI.$html.off("click.outer.dropdown");
2116
2117 if (active && active != this) {
2118 active.hide(true);
2119 }
2120
2121 if (hoverIdle) {
2122 clearTimeout(hoverIdle);
2123 }
2124
2125 this.trigger('beforeshow.uk.dropdown', [this]);
2126
2127 this.checkDimensions();
2128 this.element.addClass('uk-open');
2129
2130 // Update ARIA
2131 this.element.attr('aria-expanded', 'true');
2132
2133 this.trigger('show.uk.dropdown', [this]);
2134
2135 UI.Utils.checkDisplay(this.dropdown, true);
2136 active = this;
2137
2138 this.registerOuterClick();
2139 },
2140
2141 hide: function(force) {
2142
2143 this.trigger('beforehide.uk.dropdown', [this, force]);
2144
2145 this.element.removeClass('uk-open');
2146
2147 if (this.remainIdle) {
2148 clearTimeout(this.remainIdle);
2149 }
2150
2151 this.remainIdle = false;
2152
2153 // Update ARIA
2154 this.element.attr('aria-expanded', 'false');
2155
2156 this.trigger('hide.uk.dropdown', [this, force]);
2157
2158 if (active == this) active = false;
2159 },
2160
2161 registerOuterClick: function(){
2162
2163 var $this = this;
2164
2165 UI.$html.off("click.outer.dropdown");
2166
2167 setTimeout(function() {
2168
2169 UI.$html.on("click.outer.dropdown", function(e) {
2170
2171 if (hoverIdle) {
2172 clearTimeout(hoverIdle);
2173 }
2174
2175 var $target = UI.$(e.target);
2176
2177 if (active == $this && !$this.element.find(e.target).length) {
2178 $this.hide(true);
2179 UI.$html.off("click.outer.dropdown");
2180 }
2181 });
2182 }, 10);
2183 },
2184
2185 checkDimensions: function() {
2186
2187 if (!this.dropdown.length) return;
2188
2189 // reset
2190 this.dropdown.removeClass('uk-dropdown-top uk-dropdown-bottom uk-dropdown-left uk-dropdown-right uk-dropdown-stack').css({
2191 'top-left':'',
2192 'left':'',
2193 'margin-left' :'',
2194 'margin-right':''
2195 });
2196
2197 if (this.justified && this.justified.length) {
2198 this.dropdown.css("min-width", "");
2199 }
2200
2201 var $this = this,
2202 pos = UI.$.extend({}, this.offsetParent.offset(), {width: this.offsetParent[0].offsetWidth, height: this.offsetParent[0].offsetHeight}),
2203 posoffset = this.options.offset,
2204 dropdown = this.dropdown,
2205 offset = dropdown.show().offset() || {left: 0, top: 0},
2206 width = dropdown.outerWidth(),
2207 height = dropdown.outerHeight(),
2208 boundarywidth = this.boundary.width(),
2209 boundaryoffset = this.boundary[0] !== window && this.boundary.offset() ? this.boundary.offset(): {top:0, left:0},
2210 dpos = this.options.pos;
2211
2212 var variants = {
2213 "bottom-left" : {top: 0 + pos.height + posoffset, left: 0},
2214 "bottom-right" : {top: 0 + pos.height + posoffset, left: 0 + pos.width - width},
2215 "bottom-center" : {top: 0 + pos.height + posoffset, left: 0 + pos.width / 2 - width / 2},
2216 "top-left" : {top: 0 - height - posoffset, left: 0},
2217 "top-right" : {top: 0 - height - posoffset, left: 0 + pos.width - width},
2218 "top-center" : {top: 0 - height - posoffset, left: 0 + pos.width / 2 - width / 2},
2219 "left-top" : {top: 0, left: 0 - width - posoffset},
2220 "left-bottom" : {top: 0 + pos.height - height, left: 0 - width - posoffset},
2221 "left-center" : {top: 0 + pos.height / 2 - height / 2, left: 0 - width - posoffset},
2222 "right-top" : {top: 0, left: 0 + pos.width + posoffset},
2223 "right-bottom" : {top: 0 + pos.height - height, left: 0 + pos.width + posoffset},
2224 "right-center" : {top: 0 + pos.height / 2 - height / 2, left: 0 + pos.width + posoffset}
2225 },
2226 css = {},
2227 pp;
2228
2229 pp = dpos.split('-');
2230 css = variants[dpos] ? variants[dpos] : variants['bottom-left'];
2231
2232 // justify dropdown
2233 if (this.justified && this.justified.length) {
2234 justify(dropdown.css({left:0}), this.justified, boundarywidth);
2235 } else {
2236
2237 if (this.options.preventflip !== true) {
2238
2239 var fdpos;
2240
2241 switch(this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) {
2242 case "x":
2243 if(this.options.preventflip !=='x') fdpos = flips['x'][dpos] || 'right-top';
2244 break;
2245 case "y":
2246 if(this.options.preventflip !=='y') fdpos = flips['y'][dpos] || 'top-left';
2247 break;
2248 case "xy":
2249 if(!this.options.preventflip) fdpos = flips['xy'][dpos] || 'right-bottom';
2250 break;
2251 }
2252
2253 if (fdpos) {
2254
2255 pp = fdpos.split('-');
2256 css = variants[fdpos] ? variants[fdpos] : variants['bottom-left'];
2257
2258 // check flipped
2259 if (this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) {
2260 pp = dpos.split('-');
2261 css = variants[dpos] ? variants[dpos] : variants['bottom-left'];
2262 }
2263 }
2264 }
2265 }
2266
2267 if (width > boundarywidth) {
2268 dropdown.addClass("uk-dropdown-stack");
2269 this.trigger('stack.uk.dropdown', [this]);
2270 }
2271
2272 dropdown.css(css).css("display", "").addClass('uk-dropdown-'+pp[0]);
2273 },
2274
2275 checkBoundary: function(left, top, width, height, boundarywidth) {
2276
2277 var axis = "";
2278
2279 if (left < 0 || ((left - UI.$win.scrollLeft())+width) > boundarywidth) {
2280 axis += "x";
2281 }
2282
2283 if ((top - UI.$win.scrollTop()) < 0 || ((top - UI.$win.scrollTop())+height) > window.innerHeight) {
2284 axis += "y";
2285 }
2286
2287 return axis;
2288 }
2289 });
2290
2291
2292 UI.component('dropdownOverlay', {
2293
2294 defaults: {
2295 'justify' : false,
2296 'cls' : '',
2297 'duration': 200
2298 },
2299
2300 boot: function() {
2301
2302 // init code
2303 UI.ready(function(context) {
2304
2305 UI.$("[data-uk-dropdown-overlay]", context).each(function() {
2306 var ele = UI.$(this);
2307
2308 if (!ele.data("dropdownOverlay")) {
2309 UI.dropdownOverlay(ele, UI.Utils.options(ele.attr("data-uk-dropdown-overlay")));
2310 }
2311 });
2312 });
2313 },
2314
2315 init: function() {
2316
2317 var $this = this;
2318
2319 this.justified = this.options.justify ? UI.$(this.options.justify) : false;
2320 this.overlay = this.element.find('uk-dropdown-overlay');
2321
2322 if (!this.overlay.length) {
2323 this.overlay = UI.$('<div class="uk-dropdown-overlay"></div>').appendTo(this.element);
2324 }
2325
2326 this.overlay.addClass(this.options.cls);
2327
2328 this.on({
2329
2330 'beforeshow.uk.dropdown': function(e, dropdown) {
2331 $this.dropdown = dropdown;
2332
2333 if ($this.justified && $this.justified.length) {
2334 justify($this.overlay.css({'display':'block', 'margin-left':'','margin-right':''}), $this.justified, $this.justified.outerWidth());
2335 }
2336 },
2337
2338 'show.uk.dropdown': function(e, dropdown) {
2339
2340 var h = $this.dropdown.dropdown.outerHeight(true);
2341
2342 $this.dropdown.element.removeClass('uk-open');
2343
2344 $this.overlay.stop().css('display', 'block').animate({height: h}, $this.options.duration, function() {
2345
2346 $this.dropdown.dropdown.css('visibility', '');
2347 $this.dropdown.element.addClass('uk-open');
2348
2349 UI.Utils.checkDisplay($this.dropdown.dropdown, true);
2350 });
2351
2352 $this.pointerleave = false;
2353 },
2354
2355 'hide.uk.dropdown': function() {
2356 $this.overlay.stop().animate({height: 0}, $this.options.duration);
2357 },
2358
2359 'pointerenter.uk.dropdown': function(e, dropdown) {
2360 clearTimeout($this.remainIdle);
2361 },
2362
2363 'pointerleave.uk.dropdown': function(e, dropdown) {
2364 $this.pointerleave = true;
2365 }
2366 });
2367
2368
2369 this.overlay.on({
2370
2371 'mouseenter': function() {
2372 if ($this.remainIdle) {
2373 clearTimeout($this.dropdown.remainIdle);
2374 clearTimeout($this.remainIdle);
2375 }
2376 },
2377
2378 'mouseleave': function(){
2379
2380 if ($this.pointerleave && active) {
2381
2382 $this.remainIdle = setTimeout(function() {
2383 if(active) active.hide();
2384 }, active.options.remaintime);
2385 }
2386 }
2387 })
2388 }
2389
2390 });
2391
2392
2393 function justify(ele, justifyTo, boundarywidth, offset) {
2394
2395 ele = UI.$(ele);
2396 justifyTo = UI.$(justifyTo);
2397 boundarywidth = boundarywidth || window.innerWidth;
2398 offset = offset || ele.offset();
2399
2400 if (justifyTo.length) {
2401
2402 var jwidth = justifyTo.outerWidth();
2403
2404 ele.css("min-width", jwidth);
2405
2406 if (UI.langdirection == 'right') {
2407
2408 var right1 = boundarywidth - (justifyTo.offset().left + jwidth),
2409 right2 = boundarywidth - (ele.offset().left + ele.outerWidth());
2410
2411 ele.css("margin-right", right1 - right2);
2412
2413 } else {
2414 ele.css("margin-left", justifyTo.offset().left - offset.left);
2415 }
2416 }
2417 }
2418
2419})(UIkit);
2420
2421(function(UI) {
2422
2423 "use strict";
2424
2425 var grids = [];
2426
2427 UI.component('gridMatchHeight', {
2428
2429 defaults: {
2430 "target" : false,
2431 "row" : true,
2432 "ignorestacked" : false,
2433 "observe" : false
2434 },
2435
2436 boot: function() {
2437
2438 // init code
2439 UI.ready(function(context) {
2440
2441 UI.$("[data-uk-grid-match]", context).each(function() {
2442 var grid = UI.$(this), obj;
2443
2444 if (!grid.data("gridMatchHeight")) {
2445 obj = UI.gridMatchHeight(grid, UI.Utils.options(grid.attr("data-uk-grid-match")));
2446 }
2447 });
2448 });
2449 },
2450
2451 init: function() {
2452
2453 var $this = this;
2454
2455 this.columns = this.element.children();
2456 this.elements = this.options.target ? this.find(this.options.target) : this.columns;
2457
2458 if (!this.columns.length) return;
2459
2460 UI.$win.on('load resize orientationchange', (function() {
2461
2462 var fn = function() {
2463 if ($this.element.is(":visible")) $this.match();
2464 };
2465
2466 UI.$(function() { fn(); });
2467
2468 return UI.Utils.debounce(fn, 50);
2469 })());
2470
2471 if (this.options.observe) {
2472
2473 UI.domObserve(this.element, function(e) {
2474 if ($this.element.is(":visible")) $this.match();
2475 });
2476 }
2477
2478 this.on("display.uk.check", function(e) {
2479 if(this.element.is(":visible")) this.match();
2480 }.bind(this));
2481
2482 grids.push(this);
2483 },
2484
2485 match: function() {
2486
2487 var firstvisible = this.columns.filter(":visible:first");
2488
2489 if (!firstvisible.length) return;
2490
2491 var stacked = Math.ceil(100 * parseFloat(firstvisible.css('width')) / parseFloat(firstvisible.parent().css('width'))) >= 100;
2492
2493 if (stacked && !this.options.ignorestacked) {
2494 this.revert();
2495 } else {
2496 UI.Utils.matchHeights(this.elements, this.options);
2497 }
2498
2499 return this;
2500 },
2501
2502 revert: function() {
2503 this.elements.css('min-height', '');
2504 return this;
2505 }
2506 });
2507
2508 UI.component('gridMargin', {
2509
2510 defaults: {
2511 cls : 'uk-grid-margin',
2512 rowfirst : 'uk-row-first'
2513 },
2514
2515 boot: function() {
2516
2517 // init code
2518 UI.ready(function(context) {
2519
2520 UI.$("[data-uk-grid-margin]", context).each(function() {
2521 var grid = UI.$(this), obj;
2522
2523 if (!grid.data("gridMargin")) {
2524 obj = UI.gridMargin(grid, UI.Utils.options(grid.attr("data-uk-grid-margin")));
2525 }
2526 });
2527 });
2528 },
2529
2530 init: function() {
2531
2532 var stackMargin = UI.stackMargin(this.element, this.options);
2533 }
2534 });
2535
2536})(UIkit);
2537
2538(function(UI) {
2539
2540 "use strict";
2541
2542 var active = false, activeCount = 0, $html = UI.$html, body;
2543
2544 UI.$win.on("resize orientationchange", UI.Utils.debounce(function(){
2545 UI.$('.uk-modal.uk-open').each(function(){
2546 UI.$(this).data('modal').resize();
2547 });
2548 }, 150));
2549
2550 UI.component('modal', {
2551
2552 defaults: {
2553 keyboard: true,
2554 bgclose: true,
2555 minScrollHeight: 150,
2556 center: false,
2557 modal: true
2558 },
2559
2560 scrollable: false,
2561 transition: false,
2562 hasTransitioned: true,
2563
2564 init: function() {
2565
2566 if (!body) body = UI.$('body');
2567
2568 if (!this.element.length) return;
2569
2570 var $this = this;
2571
2572 this.paddingdir = "padding-" + (UI.langdirection == 'left' ? "right":"left");
2573 this.dialog = this.find(".uk-modal-dialog");
2574
2575 this.active = false;
2576
2577 // Update ARIA
2578 this.element.attr('aria-hidden', this.element.hasClass("uk-open"));
2579
2580 this.on("click", ".uk-modal-close", function(e) {
2581 e.preventDefault();
2582 $this.hide();
2583 }).on("click", function(e) {
2584
2585 var target = UI.$(e.target);
2586
2587 if (target[0] == $this.element[0] && $this.options.bgclose) {
2588 $this.hide();
2589 }
2590 });
2591
2592 UI.domObserve(this.element, function(e) { $this.resize(); });
2593 },
2594
2595 toggle: function() {
2596 return this[this.isActive() ? "hide" : "show"]();
2597 },
2598
2599 show: function() {
2600
2601 if (!this.element.length) return;
2602
2603 var $this = this;
2604
2605 if (this.isActive()) return;
2606
2607 if (this.options.modal && active) {
2608 active.hide(true);
2609 }
2610
2611 this.element.removeClass("uk-open").show();
2612 this.resize(true);
2613
2614 if (this.options.modal) {
2615 active = this;
2616 }
2617
2618 this.active = true;
2619
2620 activeCount++;
2621
2622 if (UI.support.transition) {
2623 this.hasTransitioned = false;
2624 this.element.one(UI.support.transition.end, function(){
2625 $this.hasTransitioned = true;
2626 }).addClass("uk-open");
2627 } else {
2628 this.element.addClass("uk-open");
2629 }
2630
2631 $html.addClass("uk-modal-page").height(); // force browser engine redraw
2632
2633 // Update ARIA
2634 this.element.attr('aria-hidden', 'false');
2635
2636 this.element.trigger("show.uk.modal");
2637
2638 UI.Utils.checkDisplay(this.dialog, true);
2639
2640 return this;
2641 },
2642
2643 hide: function(force) {
2644
2645 if (!force && UI.support.transition && this.hasTransitioned) {
2646
2647 var $this = this;
2648
2649 this.one(UI.support.transition.end, function() {
2650 $this._hide();
2651 }).removeClass("uk-open");
2652
2653 } else {
2654
2655 this._hide();
2656 }
2657
2658 return this;
2659 },
2660
2661 resize: function(force) {
2662
2663 if (!this.isActive() && !force) return;
2664
2665 var bodywidth = body.width();
2666
2667 this.scrollbarwidth = window.innerWidth - bodywidth;
2668
2669 body.css(this.paddingdir, this.scrollbarwidth);
2670
2671 this.element.css('overflow-y', this.scrollbarwidth ? 'scroll' : 'auto');
2672
2673 if (!this.updateScrollable() && this.options.center) {
2674
2675 var dh = this.dialog.outerHeight(),
2676 pad = parseInt(this.dialog.css('margin-top'), 10) + parseInt(this.dialog.css('margin-bottom'), 10);
2677
2678 if ((dh + pad) < window.innerHeight) {
2679 this.dialog.css({'top': (window.innerHeight/2 - dh/2) - pad });
2680 } else {
2681 this.dialog.css({'top': ''});
2682 }
2683 }
2684 },
2685
2686 updateScrollable: function() {
2687
2688 // has scrollable?
2689 var scrollable = this.dialog.find('.uk-overflow-container:visible:first');
2690
2691 if (scrollable.length) {
2692
2693 scrollable.css('height', 0);
2694
2695 var offset = Math.abs(parseInt(this.dialog.css('margin-top'), 10)),
2696 dh = this.dialog.outerHeight(),
2697 wh = window.innerHeight,
2698 h = wh - 2*(offset < 20 ? 20:offset) - dh;
2699
2700 scrollable.css({
2701 'max-height': (h < this.options.minScrollHeight ? '':h),
2702 'height':''
2703 });
2704
2705 return true;
2706 }
2707
2708 return false;
2709 },
2710
2711 _hide: function() {
2712
2713 this.active = false;
2714 if (activeCount > 0) activeCount--;
2715 else activeCount = 0;
2716
2717 this.element.hide().removeClass('uk-open');
2718
2719 // Update ARIA
2720 this.element.attr('aria-hidden', 'true');
2721
2722 if (!activeCount) {
2723 $html.removeClass('uk-modal-page');
2724 body.css(this.paddingdir, "");
2725 }
2726
2727 if (active===this) active = false;
2728
2729 this.trigger('hide.uk.modal');
2730 },
2731
2732 isActive: function() {
2733 return this.element.hasClass('uk-open');
2734 }
2735
2736 });
2737
2738 UI.component('modalTrigger', {
2739
2740 boot: function() {
2741
2742 // init code
2743 UI.$html.on("click.modal.uikit", "[data-uk-modal]", function(e) {
2744
2745 var ele = UI.$(this);
2746
2747 if (ele.is("a")) {
2748 e.preventDefault();
2749 }
2750
2751 if (!ele.data("modalTrigger")) {
2752 var modal = UI.modalTrigger(ele, UI.Utils.options(ele.attr("data-uk-modal")));
2753 modal.show();
2754 }
2755
2756 });
2757
2758 // close modal on esc button
2759 UI.$html.on('keydown.modal.uikit', function (e) {
2760
2761 if (active && e.keyCode === 27 && active.options.keyboard) { // ESC
2762 e.preventDefault();
2763 active.hide();
2764 }
2765 });
2766 },
2767
2768 init: function() {
2769
2770 var $this = this;
2771
2772 this.options = UI.$.extend({
2773 "target": $this.element.is("a") ? $this.element.attr("href") : false
2774 }, this.options);
2775
2776 this.modal = UI.modal(this.options.target, this.options);
2777
2778 this.on("click", function(e) {
2779 e.preventDefault();
2780 $this.show();
2781 });
2782
2783 //methods
2784 this.proxy(this.modal, "show hide isActive");
2785 }
2786 });
2787
2788 UI.modal.dialog = function(content, options) {
2789
2790 var modal = UI.modal(UI.$(UI.modal.dialog.template).appendTo("body"), options);
2791
2792 modal.on("hide.uk.modal", function(){
2793 if (modal.persist) {
2794 modal.persist.appendTo(modal.persist.data("modalPersistParent"));
2795 modal.persist = false;
2796 }
2797 modal.element.remove();
2798 });
2799
2800 setContent(content, modal);
2801
2802 return modal;
2803 };
2804
2805 UI.modal.dialog.template = '<div class="uk-modal"><div class="uk-modal-dialog" style="min-height:0;"></div></div>';
2806
2807 UI.modal.alert = function(content, options) {
2808
2809 options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options);
2810
2811 var modal = UI.modal.dialog(([
2812 '<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
2813 '<div class="uk-modal-footer uk-text-right"><button class="uk-button uk-button-primary uk-modal-close">'+options.labels.Ok+'</button></div>'
2814 ]).join(""), options);
2815
2816 modal.on('show.uk.modal', function(){
2817 setTimeout(function(){
2818 modal.element.find('button:first').focus();
2819 }, 50);
2820 });
2821
2822 return modal.show();
2823 };
2824
2825 UI.modal.confirm = function(content, onconfirm, oncancel) {
2826
2827 var options = arguments.length > 1 && arguments[arguments.length-1] ? arguments[arguments.length-1] : {};
2828
2829 onconfirm = UI.$.isFunction(onconfirm) ? onconfirm : function(){};
2830 oncancel = UI.$.isFunction(oncancel) ? oncancel : function(){};
2831 options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, UI.$.isFunction(options) ? {}:options);
2832
2833 var modal = UI.modal.dialog(([
2834 '<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
2835 '<div class="uk-modal-footer uk-text-right"><button class="uk-button js-modal-confirm-cancel">'+options.labels.Cancel+'</button> <button class="uk-button uk-button-primary js-modal-confirm">'+options.labels.Ok+'</button></div>'
2836 ]).join(""), options);
2837
2838 modal.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click", function(){
2839 UI.$(this).is('.js-modal-confirm') ? onconfirm() : oncancel();
2840 modal.hide();
2841 });
2842
2843 modal.on('show.uk.modal', function(){
2844 setTimeout(function(){
2845 modal.element.find('.js-modal-confirm').focus();
2846 }, 50);
2847 });
2848
2849 return modal.show();
2850 };
2851
2852 UI.modal.prompt = function(text, value, onsubmit, options) {
2853
2854 onsubmit = UI.$.isFunction(onsubmit) ? onsubmit : function(value){};
2855 options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options);
2856
2857 var modal = UI.modal.dialog(([
2858 text ? '<div class="uk-modal-content uk-form">'+String(text)+'</div>':'',
2859 '<div class="uk-margin-small-top uk-modal-content uk-form"><p><input type="text" class="uk-width-1-1"></p></div>',
2860 '<div class="uk-modal-footer uk-text-right"><button class="uk-button uk-modal-close">'+options.labels.Cancel+'</button> <button class="uk-button uk-button-primary js-modal-ok">'+options.labels.Ok+'</button></div>'
2861 ]).join(""), options),
2862
2863 input = modal.element.find("input[type='text']").val(value || '').on('keyup', function(e){
2864 if (e.keyCode == 13) {
2865 modal.element.find(".js-modal-ok").trigger('click');
2866 }
2867 });
2868
2869 modal.element.find(".js-modal-ok").on("click", function(){
2870 if (onsubmit(input.val())!==false){
2871 modal.hide();
2872 }
2873 });
2874
2875 modal.on('show.uk.modal', function(){
2876 setTimeout(function(){
2877 input.focus();
2878 }, 50);
2879 });
2880
2881 return modal.show();
2882 };
2883
2884 UI.modal.blockUI = function(content, options) {
2885
2886 var modal = UI.modal.dialog(([
2887 '<div class="uk-margin uk-modal-content">'+String(content || '<div class="uk-text-center">...</div>')+'</div>'
2888 ]).join(""), UI.$.extend({bgclose:false, keyboard:false, modal:false}, options));
2889
2890 modal.content = modal.element.find('.uk-modal-content:first');
2891
2892 return modal.show();
2893 };
2894
2895
2896 UI.modal.labels = {
2897 'Ok': 'Ok',
2898 'Cancel': 'Cancel'
2899 };
2900
2901
2902 // helper functions
2903 function setContent(content, modal){
2904
2905 if(!modal) return;
2906
2907 if (typeof content === 'object') {
2908
2909 // convert DOM object to a jQuery object
2910 content = content instanceof jQuery ? content : UI.$(content);
2911
2912 if(content.parent().length) {
2913 modal.persist = content;
2914 modal.persist.data("modalPersistParent", content.parent());
2915 }
2916 }else if (typeof content === 'string' || typeof content === 'number') {
2917 // just insert the data as innerHTML
2918 content = UI.$('<div></div>').html(content);
2919 }else {
2920 // unsupported data type!
2921 content = UI.$('<div></div>').html('UIkit.modal Error: Unsupported data type: ' + typeof content);
2922 }
2923
2924 content.appendTo(modal.element.find('.uk-modal-dialog'));
2925
2926 return modal;
2927 }
2928
2929})(UIkit);
2930
2931(function(UI) {
2932
2933 "use strict";
2934
2935 UI.component('nav', {
2936
2937 defaults: {
2938 "toggle": ">li.uk-parent > a[href='#']",
2939 "lists": ">li.uk-parent > ul",
2940 "multiple": false
2941 },
2942
2943 boot: function() {
2944
2945 // init code
2946 UI.ready(function(context) {
2947
2948 UI.$("[data-uk-nav]", context).each(function() {
2949 var nav = UI.$(this);
2950
2951 if (!nav.data("nav")) {
2952 var obj = UI.nav(nav, UI.Utils.options(nav.attr("data-uk-nav")));
2953 }
2954 });
2955 });
2956 },
2957
2958 init: function() {
2959
2960 var $this = this;
2961
2962 this.on("click.uk.nav", this.options.toggle, function(e) {
2963 e.preventDefault();
2964 var ele = UI.$(this);
2965 $this.open(ele.parent()[0] == $this.element[0] ? ele : ele.parent("li"));
2966 });
2967
2968 this.find(this.options.lists).each(function() {
2969 var $ele = UI.$(this),
2970 parent = $ele.parent(),
2971 active = parent.hasClass("uk-active");
2972
2973 $ele.wrap('<div style="overflow:hidden;height:0;position:relative;"></div>');
2974 parent.data("list-container", $ele.parent()[active ? 'removeClass':'addClass']('uk-hidden'));
2975
2976 // Init ARIA
2977 parent.attr('aria-expanded', parent.hasClass("uk-open"));
2978
2979 if (active) $this.open(parent, true);
2980 });
2981
2982 },
2983
2984 open: function(li, noanimation) {
2985
2986 var $this = this, element = this.element, $li = UI.$(li), $container = $li.data('list-container');
2987
2988 if (!this.options.multiple) {
2989
2990 element.children('.uk-open').not(li).each(function() {
2991
2992 var ele = UI.$(this);
2993
2994 if (ele.data('list-container')) {
2995 ele.data('list-container').stop().animate({height: 0}, function() {
2996 UI.$(this).parent().removeClass('uk-open').end().addClass('uk-hidden');
2997 });
2998 }
2999 });
3000 }
3001
3002 $li.toggleClass('uk-open');
3003
3004 // Update ARIA
3005 $li.attr('aria-expanded', $li.hasClass('uk-open'));
3006
3007 if ($container) {
3008
3009 if ($li.hasClass('uk-open')) {
3010 $container.removeClass('uk-hidden');
3011 }
3012
3013 if (noanimation) {
3014
3015 $container.stop().height($li.hasClass('uk-open') ? 'auto' : 0);
3016
3017 if (!$li.hasClass('uk-open')) {
3018 $container.addClass('uk-hidden');
3019 }
3020
3021 this.trigger('display.uk.check');
3022
3023 } else {
3024
3025 $container.stop().animate({
3026 height: ($li.hasClass('uk-open') ? getHeight($container.find('ul:first')) : 0)
3027 }, function() {
3028
3029 if (!$li.hasClass('uk-open')) {
3030 $container.addClass('uk-hidden');
3031 } else {
3032 $container.css('height', '');
3033 }
3034
3035 $this.trigger('display.uk.check');
3036 });
3037 }
3038 }
3039 }
3040 });
3041
3042
3043 // helper
3044
3045 function getHeight(ele) {
3046 var $ele = UI.$(ele), height = "auto";
3047
3048 if ($ele.is(":visible")) {
3049 height = $ele.outerHeight();
3050 } else {
3051 var tmp = {
3052 position: $ele.css("position"),
3053 visibility: $ele.css("visibility"),
3054 display: $ele.css("display")
3055 };
3056
3057 height = $ele.css({position: 'absolute', visibility: 'hidden', display: 'block'}).outerHeight();
3058
3059 $ele.css(tmp); // reset element
3060 }
3061
3062 return height;
3063 }
3064
3065})(UIkit);
3066
3067(function(UI) {
3068
3069 "use strict";
3070
3071 var scrollpos = {x: window.scrollX, y: window.scrollY},
3072 $win = UI.$win,
3073 $doc = UI.$doc,
3074 $html = UI.$html,
3075 Offcanvas = {
3076
3077 show: function(element) {
3078
3079 element = UI.$(element);
3080
3081 if (!element.length) return;
3082
3083 var $body = UI.$('body'),
3084 bar = element.find(".uk-offcanvas-bar:first"),
3085 rtl = (UI.langdirection == "right"),
3086 flip = bar.hasClass("uk-offcanvas-bar-flip") ? -1:1,
3087 dir = flip * (rtl ? -1 : 1),
3088
3089 scrollbarwidth = window.innerWidth - $body.width();
3090
3091 scrollpos = {x: window.pageXOffset, y: window.pageYOffset};
3092
3093 element.addClass("uk-active");
3094
3095 $body.css({"width": window.innerWidth - scrollbarwidth, "height": window.innerHeight}).addClass("uk-offcanvas-page");
3096 $body.css((rtl ? "margin-right" : "margin-left"), (rtl ? -1 : 1) * (bar.outerWidth() * dir)).width(); // .width() - force redraw
3097
3098 $html.css('margin-top', scrollpos.y * -1);
3099
3100 bar.addClass("uk-offcanvas-bar-show");
3101
3102 this._initElement(element);
3103
3104 bar.trigger('show.uk.offcanvas', [element, bar]);
3105
3106 // Update ARIA
3107 element.attr('aria-hidden', 'false');
3108 },
3109
3110 hide: function(force) {
3111
3112 var $body = UI.$('body'),
3113 panel = UI.$(".uk-offcanvas.uk-active"),
3114 rtl = (UI.langdirection == "right"),
3115 bar = panel.find(".uk-offcanvas-bar:first"),
3116 finalize = function() {
3117 $body.removeClass("uk-offcanvas-page").css({"width": "", "height": "", "margin-left": "", "margin-right": ""});
3118 panel.removeClass("uk-active");
3119
3120 bar.removeClass("uk-offcanvas-bar-show");
3121 $html.css('margin-top', '');
3122 window.scrollTo(scrollpos.x, scrollpos.y);
3123 bar.trigger('hide.uk.offcanvas', [panel, bar]);
3124
3125 // Update ARIA
3126 panel.attr('aria-hidden', 'true');
3127 };
3128
3129 if (!panel.length) return;
3130
3131 if (UI.support.transition && !force) {
3132
3133 $body.one(UI.support.transition.end, function() {
3134 finalize();
3135 }).css((rtl ? "margin-right" : "margin-left"), "");
3136
3137 setTimeout(function(){
3138 bar.removeClass("uk-offcanvas-bar-show");
3139 }, 0);
3140
3141 } else {
3142 finalize();
3143 }
3144 },
3145
3146 _initElement: function(element) {
3147
3148 if (element.data("OffcanvasInit")) return;
3149
3150 element.on("click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas", function(e) {
3151
3152 var target = UI.$(e.target);
3153
3154 if (!e.type.match(/swipe/)) {
3155
3156 if (!target.hasClass("uk-offcanvas-close")) {
3157 if (target.hasClass("uk-offcanvas-bar")) return;
3158 if (target.parents(".uk-offcanvas-bar:first").length) return;
3159 }
3160 }
3161
3162 e.stopImmediatePropagation();
3163 Offcanvas.hide();
3164 });
3165
3166 element.on("click", "a[href*='#']", function(e){
3167
3168 var link = UI.$(this),
3169 href = link.attr("href");
3170
3171 if (href == "#") {
3172 return;
3173 }
3174
3175 UI.$doc.one('hide.uk.offcanvas', function() {
3176
3177 var target;
3178
3179 try {
3180 target = UI.$(link[0].hash);
3181 } catch (e){
3182 target = '';
3183 }
3184
3185 if (!target.length) {
3186 target = UI.$('[name="'+link[0].hash.replace('#','')+'"]');
3187 }
3188
3189 if (target.length && UI.Utils.scrollToElement) {
3190 UI.Utils.scrollToElement(target, UI.Utils.options(link.attr('data-uk-smooth-scroll') || '{}'));
3191 } else {
3192 window.location.href = href;
3193 }
3194 });
3195
3196 Offcanvas.hide();
3197 });
3198
3199 element.data("OffcanvasInit", true);
3200 }
3201 };
3202
3203 UI.component('offcanvasTrigger', {
3204
3205 boot: function() {
3206
3207 // init code
3208 $html.on("click.offcanvas.uikit", "[data-uk-offcanvas]", function(e) {
3209
3210 e.preventDefault();
3211
3212 var ele = UI.$(this);
3213
3214 if (!ele.data("offcanvasTrigger")) {
3215 var obj = UI.offcanvasTrigger(ele, UI.Utils.options(ele.attr("data-uk-offcanvas")));
3216 ele.trigger("click");
3217 }
3218 });
3219
3220 $html.on('keydown.uk.offcanvas', function(e) {
3221
3222 if (e.keyCode === 27) { // ESC
3223 Offcanvas.hide();
3224 }
3225 });
3226 },
3227
3228 init: function() {
3229
3230 var $this = this;
3231
3232 this.options = UI.$.extend({
3233 "target": $this.element.is("a") ? $this.element.attr("href") : false
3234 }, this.options);
3235
3236 this.on("click", function(e) {
3237 e.preventDefault();
3238 Offcanvas.show($this.options.target);
3239 });
3240 }
3241 });
3242
3243 UI.offcanvas = Offcanvas;
3244
3245})(UIkit);
3246
3247(function(UI) {
3248
3249 "use strict";
3250
3251 var Animations;
3252
3253 UI.component('switcher', {
3254
3255 defaults: {
3256 connect : false,
3257 toggle : ">*",
3258 active : 0,
3259 animation : false,
3260 duration : 200,
3261 swiping : true
3262 },
3263
3264 animating: false,
3265
3266 boot: function() {
3267
3268 // init code
3269 UI.ready(function(context) {
3270
3271 UI.$("[data-uk-switcher]", context).each(function() {
3272 var switcher = UI.$(this);
3273
3274 if (!switcher.data("switcher")) {
3275 var obj = UI.switcher(switcher, UI.Utils.options(switcher.attr("data-uk-switcher")));
3276 }
3277 });
3278 });
3279 },
3280
3281 init: function() {
3282
3283 var $this = this;
3284
3285 this.on("click.uk.switcher", this.options.toggle, function(e) {
3286 e.preventDefault();
3287 $this.show(this);
3288 });
3289
3290 if (this.options.connect) {
3291
3292 this.connect = UI.$(this.options.connect);
3293
3294 this.connect.children().removeClass("uk-active");
3295
3296 // delegate switch commands within container content
3297 if (this.connect.length) {
3298
3299 // Init ARIA for connect
3300 this.connect.children().attr('aria-hidden', 'true');
3301
3302 this.connect.on("click", '[data-uk-switcher-item]', function(e) {
3303
3304 e.preventDefault();
3305
3306 var item = UI.$(this).attr('data-uk-switcher-item');
3307
3308 if ($this.index == item) return;
3309
3310 switch(item) {
3311 case 'next':
3312 case 'previous':
3313 $this.show($this.index + (item=='next' ? 1:-1));
3314 break;
3315 default:
3316 $this.show(parseInt(item, 10));
3317 }
3318 });
3319
3320 if (this.options.swiping) {
3321
3322 this.connect.on('swipeRight swipeLeft', function(e) {
3323 e.preventDefault();
3324 if(!window.getSelection().toString()) {
3325 $this.show($this.index + (e.type == 'swipeLeft' ? 1 : -1));
3326 }
3327 });
3328 }
3329 }
3330
3331 var toggles = this.find(this.options.toggle),
3332 active = toggles.filter(".uk-active");
3333
3334 if (active.length) {
3335 this.show(active, false);
3336 } else {
3337
3338 if (this.options.active===false) return;
3339
3340 active = toggles.eq(this.options.active);
3341 this.show(active.length ? active : toggles.eq(0), false);
3342 }
3343
3344 // Init ARIA for toggles
3345 toggles.not(active).attr('aria-expanded', 'false');
3346 active.attr('aria-expanded', 'true');
3347 }
3348
3349 },
3350
3351 show: function(tab, animate) {
3352
3353 if (this.animating) {
3354 return;
3355 }
3356
3357 if (isNaN(tab)) {
3358 tab = UI.$(tab);
3359 } else {
3360
3361 var toggles = this.find(this.options.toggle);
3362
3363 tab = tab < 0 ? toggles.length-1 : tab;
3364 tab = toggles.eq(toggles[tab] ? tab : 0);
3365 }
3366
3367 var $this = this,
3368 toggles = this.find(this.options.toggle),
3369 active = UI.$(tab),
3370 animation = Animations[this.options.animation] || function(current, next) {
3371
3372 if (!$this.options.animation) {
3373 return Animations.none.apply($this);
3374 }
3375
3376 var anim = $this.options.animation.split(',');
3377
3378 if (anim.length == 1) {
3379 anim[1] = anim[0];
3380 }
3381
3382 anim[0] = anim[0].trim();
3383 anim[1] = anim[1].trim();
3384
3385 return coreAnimation.apply($this, [anim, current, next]);
3386 };
3387
3388 if (animate===false || !UI.support.animation) {
3389 animation = Animations.none;
3390 }
3391
3392 if (active.hasClass("uk-disabled")) return;
3393
3394 // Update ARIA for Toggles
3395 toggles.attr('aria-expanded', 'false');
3396 active.attr('aria-expanded', 'true');
3397
3398 toggles.filter(".uk-active").removeClass("uk-active");
3399 active.addClass("uk-active");
3400
3401 if (this.options.connect && this.connect.length) {
3402
3403 this.index = this.find(this.options.toggle).index(active);
3404
3405 if (this.index == -1 ) {
3406 this.index = 0;
3407 }
3408
3409 this.connect.each(function() {
3410
3411 var container = UI.$(this),
3412 children = UI.$(container.children()),
3413 current = UI.$(children.filter('.uk-active')),
3414 next = UI.$(children.eq($this.index));
3415
3416 $this.animating = true;
3417
3418 animation.apply($this, [current, next]).then(function(){
3419
3420 current.removeClass("uk-active");
3421 next.addClass("uk-active");
3422
3423 // Update ARIA for connect
3424 current.attr('aria-hidden', 'true');
3425 next.attr('aria-hidden', 'false');
3426
3427 UI.Utils.checkDisplay(next, true);
3428
3429 $this.animating = false;
3430
3431 });
3432 });
3433 }
3434
3435 this.trigger("show.uk.switcher", [active]);
3436 }
3437 });
3438
3439 Animations = {
3440
3441 'none': function() {
3442 var d = UI.$.Deferred();
3443 d.resolve();
3444 return d.promise();
3445 },
3446
3447 'fade': function(current, next) {
3448 return coreAnimation.apply(this, ['uk-animation-fade', current, next]);
3449 },
3450
3451 'slide-bottom': function(current, next) {
3452 return coreAnimation.apply(this, ['uk-animation-slide-bottom', current, next]);
3453 },
3454
3455 'slide-top': function(current, next) {
3456 return coreAnimation.apply(this, ['uk-animation-slide-top', current, next]);
3457 },
3458
3459 'slide-vertical': function(current, next, dir) {
3460
3461 var anim = ['uk-animation-slide-top', 'uk-animation-slide-bottom'];
3462
3463 if (current && current.index() > next.index()) {
3464 anim.reverse();
3465 }
3466
3467 return coreAnimation.apply(this, [anim, current, next]);
3468 },
3469
3470 'slide-left': function(current, next) {
3471 return coreAnimation.apply(this, ['uk-animation-slide-left', current, next]);
3472 },
3473
3474 'slide-right': function(current, next) {
3475 return coreAnimation.apply(this, ['uk-animation-slide-right', current, next]);
3476 },
3477
3478 'slide-horizontal': function(current, next, dir) {
3479
3480 var anim = ['uk-animation-slide-right', 'uk-animation-slide-left'];
3481
3482 if (current && current.index() > next.index()) {
3483 anim.reverse();
3484 }
3485
3486 return coreAnimation.apply(this, [anim, current, next]);
3487 },
3488
3489 'scale': function(current, next) {
3490 return coreAnimation.apply(this, ['uk-animation-scale-up', current, next]);
3491 }
3492 };
3493
3494 UI.switcher.animations = Animations;
3495
3496
3497 // helpers
3498
3499 function coreAnimation(cls, current, next) {
3500
3501 var d = UI.$.Deferred(), clsIn = cls, clsOut = cls, release;
3502
3503 if (next[0]===current[0]) {
3504 d.resolve();
3505 return d.promise();
3506 }
3507
3508 if (typeof(cls) == 'object') {
3509 clsIn = cls[0];
3510 clsOut = cls[1] || cls[0];
3511 }
3512
3513 UI.$body.css('overflow-x', 'hidden'); // fix scroll jumping in iOS
3514
3515 release = function() {
3516
3517 if (current) current.hide().removeClass('uk-active '+clsOut+' uk-animation-reverse');
3518
3519 next.addClass(clsIn).one(UI.support.animation.end, function() {
3520
3521 setTimeout(function () {
3522 next.removeClass(''+clsIn+'').css({opacity:'', display:''});
3523 }, 0);
3524
3525 d.resolve();
3526
3527 UI.$body.css('overflow-x', '');
3528
3529 if (current) current.css({opacity:'', display:''});
3530
3531 }.bind(this)).show();
3532 };
3533
3534 next.css('animation-duration', this.options.duration+'ms');
3535
3536 if (current && current.length) {
3537
3538 current.css('animation-duration', this.options.duration+'ms');
3539
3540 current.css('display', 'none').addClass(clsOut+' uk-animation-reverse').one(UI.support.animation.end, function() {
3541 release();
3542 }.bind(this)).css('display', '');
3543
3544 } else {
3545 next.addClass('uk-active');
3546 release();
3547 }
3548
3549 return d.promise();
3550 }
3551
3552})(UIkit);
3553
3554(function(UI) {
3555
3556 "use strict";
3557
3558 UI.component('tab', {
3559
3560 defaults: {
3561 'target' : '>li:not(.uk-tab-responsive, .uk-disabled)',
3562 'connect' : false,
3563 'active' : 0,
3564 'animation' : false,
3565 'duration' : 200,
3566 'swiping' : true
3567 },
3568
3569 boot: function() {
3570
3571 // init code
3572 UI.ready(function(context) {
3573
3574 UI.$("[data-uk-tab]", context).each(function() {
3575
3576 var tab = UI.$(this);
3577
3578 if (!tab.data("tab")) {
3579 var obj = UI.tab(tab, UI.Utils.options(tab.attr("data-uk-tab")));
3580 }
3581 });
3582 });
3583 },
3584
3585 init: function() {
3586
3587 var $this = this;
3588
3589 this.current = false;
3590
3591 this.on("click.uk.tab", this.options.target, function(e) {
3592
3593 e.preventDefault();
3594
3595 if ($this.switcher && $this.switcher.animating) {
3596 return;
3597 }
3598
3599 var current = $this.find($this.options.target).not(this);
3600
3601 current.removeClass("uk-active").blur();
3602
3603 $this.trigger("change.uk.tab", [UI.$(this).addClass("uk-active"), $this.current]);
3604
3605 $this.current = UI.$(this);
3606
3607 // Update ARIA
3608 if (!$this.options.connect) {
3609 current.attr('aria-expanded', 'false');
3610 UI.$(this).attr('aria-expanded', 'true');
3611 }
3612 });
3613
3614 if (this.options.connect) {
3615 this.connect = UI.$(this.options.connect);
3616 }
3617
3618 // init responsive tab
3619 this.responsivetab = UI.$('<li class="uk-tab-responsive uk-active"><a></a></li>').append('<div class="uk-dropdown uk-dropdown-small"><ul class="uk-nav uk-nav-dropdown"></ul><div>');
3620
3621 this.responsivetab.dropdown = this.responsivetab.find('.uk-dropdown');
3622 this.responsivetab.lst = this.responsivetab.dropdown.find('ul');
3623 this.responsivetab.caption = this.responsivetab.find('a:first');
3624
3625 if (this.element.hasClass("uk-tab-bottom")) this.responsivetab.dropdown.addClass("uk-dropdown-up");
3626
3627 // handle click
3628 this.responsivetab.lst.on('click.uk.tab', 'a', function(e) {
3629
3630 e.preventDefault();
3631 e.stopPropagation();
3632
3633 var link = UI.$(this);
3634
3635 $this.element.children('li:not(.uk-tab-responsive)').eq(link.data('index')).trigger('click');
3636 });
3637
3638 this.on('show.uk.switcher change.uk.tab', function(e, tab) {
3639 $this.responsivetab.caption.html(tab.text());
3640 });
3641
3642 this.element.append(this.responsivetab);
3643
3644 // init UIkit components
3645 if (this.options.connect) {
3646 this.switcher = UI.switcher(this.element, {
3647 'toggle' : '>li:not(.uk-tab-responsive)',
3648 'connect' : this.options.connect,
3649 'active' : this.options.active,
3650 'animation' : this.options.animation,
3651 'duration' : this.options.duration,
3652 'swiping' : this.options.swiping
3653 });
3654 }
3655
3656 UI.dropdown(this.responsivetab, {"mode": "click", "preventflip": "y"});
3657
3658 // init
3659 $this.trigger("change.uk.tab", [this.element.find(this.options.target).not('.uk-tab-responsive').filter('.uk-active')]);
3660
3661 this.check();
3662
3663 UI.$win.on('resize orientationchange', UI.Utils.debounce(function(){
3664 if ($this.element.is(":visible")) $this.check();
3665 }, 100));
3666
3667 this.on('display.uk.check', function(){
3668 if ($this.element.is(":visible")) $this.check();
3669 });
3670 },
3671
3672 check: function() {
3673
3674 var children = this.element.children('li:not(.uk-tab-responsive)').removeClass('uk-hidden');
3675
3676 if (!children.length) {
3677 this.responsivetab.addClass('uk-hidden');
3678 return;
3679 }
3680
3681 var top = (children.eq(0).offset().top + Math.ceil(children.eq(0).height()/2)),
3682 doresponsive = false,
3683 item, link, clone;
3684
3685 this.responsivetab.lst.empty();
3686
3687 children.each(function(){
3688
3689 if (UI.$(this).offset().top > top) {
3690 doresponsive = true;
3691 }
3692 });
3693
3694 if (doresponsive) {
3695
3696 for (var i = 0; i < children.length; i++) {
3697
3698 item = UI.$(children.eq(i));
3699 link = item.find('a');
3700
3701 if (item.css('float') != 'none' && !item.attr('uk-dropdown')) {
3702
3703 if (!item.hasClass('uk-disabled')) {
3704
3705 clone = item[0].outerHTML.replace('<a ', '<a data-index="'+i+'" ');
3706
3707 this.responsivetab.lst.append(clone);
3708 }
3709
3710 item.addClass('uk-hidden');
3711 }
3712 }
3713 }
3714
3715 this.responsivetab[this.responsivetab.lst.children('li').length ? 'removeClass':'addClass']('uk-hidden');
3716 }
3717 });
3718
3719})(UIkit);
3720
3721(function(UI){
3722
3723 "use strict";
3724
3725 UI.component('cover', {
3726
3727 defaults: {
3728 automute : true
3729 },
3730
3731 boot: function() {
3732
3733 // auto init
3734 UI.ready(function(context) {
3735
3736 UI.$("[data-uk-cover]", context).each(function(){
3737
3738 var ele = UI.$(this);
3739
3740 if(!ele.data("cover")) {
3741 var plugin = UI.cover(ele, UI.Utils.options(ele.attr("data-uk-cover")));
3742 }
3743 });
3744 });
3745 },
3746
3747 init: function() {
3748
3749 this.parent = this.element.parent();
3750
3751 UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
3752 this.check();
3753 }.bind(this), 100));
3754
3755 this.on("display.uk.check", function(e) {
3756 if(this.element.is(":visible")) this.check();
3757 }.bind(this));
3758
3759 this.check();
3760
3761 if (this.element.is('iframe') && this.options.automute) {
3762
3763 var src = this.element.attr('src');
3764
3765 this.element.attr('src', '').on('load', function(){
3766
3767 this.contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}', '*');
3768
3769 }).attr('src', [src, (src.indexOf('?') > -1 ? '&':'?'), 'enablejsapi=1&api=1'].join(''));
3770 }
3771 },
3772
3773 check: function() {
3774
3775 this.element.css({
3776 'width' : '',
3777 'height' : ''
3778 });
3779
3780 this.dimension = {w: this.element.width(), h: this.element.height()};
3781
3782 if (this.element.attr('width') && !isNaN(this.element.attr('width'))) {
3783 this.dimension.w = this.element.attr('width');
3784 }
3785
3786 if (this.element.attr('height') && !isNaN(this.element.attr('height'))) {
3787 this.dimension.h = this.element.attr('height');
3788 }
3789
3790 this.ratio = this.dimension.w / this.dimension.h;
3791
3792 var w = this.parent.width(), h = this.parent.height(), width, height;
3793
3794 // if element height < parent height (gap underneath)
3795 if ((w / this.ratio) < h) {
3796
3797 width = Math.ceil(h * this.ratio);
3798 height = h;
3799
3800 // element width < parent width (gap to right)
3801 } else {
3802
3803 width = w;
3804 height = Math.ceil(w / this.ratio);
3805 }
3806
3807 this.element.css({
3808 'width' : width,
3809 'height' : height
3810 });
3811 }
3812 });
3813
3814})(UIkit);