PageSourceSearch

https://www.lib.nkust.edu.tw/portal/js/uikit.js

js nkust.edu.tw collected 2026-10-01 11:27:31 UTC 120,485 bytes, 3,961 lines download raw bytes

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

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.