Project

General

Profile

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;$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

    
2127
                    $this.trigger('pointerenter.uk.dropdown', [$this]);
2128

    
2129
                    if ($this.remainIdle) {
2130
                        clearTimeout($this.remainIdle);
2131
                    }
2132

    
2133
                    if (hoverIdle) {
2134
                        clearTimeout(hoverIdle);
2135
                    }
2136

    
2137
                    if (active && active == $this) {
2138
                        return;
2139
                    }
2140

    
2141
                    // pseudo manuAim
2142
                    if (active && active != $this) {
2143

    
2144
                        hoverIdle = setTimeout(function() {
2145
                            hoverIdle = setTimeout($this.show.bind($this), $this.options.delay);
2146
                        }, $this.options.hoverDelayIdle);
2147

    
2148
                    } else {
2149

    
2150
                        hoverIdle = setTimeout($this.show.bind($this), $this.options.delay);
2151
                    }
2152

    
2153
                }).on('mouseleave', function() {
2154

    
2155
                    if (hoverIdle) {
2156
                        clearTimeout(hoverIdle);
2157
                    }
2158

    
2159
                    $this.remainIdle = setTimeout(function() {
2160
                        if (active && active == $this) $this.hide();
2161
                    }, $this.options.remaintime);
2162

    
2163
                    $this.trigger('pointerleave.uk.dropdown', [$this]);
2164

    
2165
                }).on('click', function(e){
2166

    
2167
                    var $target = UI.$(e.target);
2168

    
2169
                    if ($this.remainIdle) {
2170
                        clearTimeout($this.remainIdle);
2171
                    }
2172

    
2173
                    if (active && active == $this) {
2174
                        if (!$this.dropdown.find(e.target).length || $target.is('.uk-dropdown-close') || $target.parents('.uk-dropdown-close').length) {
2175
                            $this.hide();
2176
                        }
2177
                        return;
2178
                    }
2179

    
2180
                    if ($target.is("a[href='#']") || $target.parent().is("a[href='#']")){
2181
                        e.preventDefault();
2182
                    }
2183

    
2184
                    $this.show();
2185
                });
2186
            }
2187
        },
2188

    
2189
        show: function(){
2190

    
2191
            UI.$html.off('click.outer.dropdown');
2192

    
2193
            if (active && active != this) {
2194
                active.hide(true);
2195
            }
2196

    
2197
            if (hoverIdle) {
2198
                clearTimeout(hoverIdle);
2199
            }
2200

    
2201
            this.trigger('beforeshow.uk.dropdown', [this]);
2202

    
2203
            this.checkDimensions();
2204
            this.element.addClass('uk-open');
2205

    
2206
            // Update ARIA
2207
            this.element.attr('aria-expanded', 'true');
2208
            this.dropdown.attr('aria-hidden', 'false');
2209

    
2210
            this.trigger('show.uk.dropdown', [this]);
2211

    
2212
            UI.Utils.checkDisplay(this.dropdown, true);
2213
            UI.Utils.focus(this.dropdown);
2214
            active = this;
2215

    
2216
            this.registerOuterClick();
2217
        },
2218

    
2219
        hide: function(force) {
2220

    
2221
            this.trigger('beforehide.uk.dropdown', [this, force]);
2222

    
2223
            this.element.removeClass('uk-open');
2224

    
2225
            if (this.remainIdle) {
2226
                clearTimeout(this.remainIdle);
2227
            }
2228

    
2229
            this.remainIdle = false;
2230

    
2231
            // Update ARIA
2232
            this.element.attr('aria-expanded', 'false');
2233
            this.dropdown.attr('aria-hidden', 'true');
2234

    
2235
            this.trigger('hide.uk.dropdown', [this, force]);
2236

    
2237
            if (active == this) active = false;
2238
        },
2239

    
2240
        registerOuterClick: function(){
2241

    
2242
            var $this = this;
2243

    
2244
            UI.$html.off('click.outer.dropdown');
2245

    
2246
            setTimeout(function() {
2247

    
2248
                UI.$html.on('click.outer.dropdown', function(e) {
2249

    
2250
                    if (hoverIdle) {
2251
                        clearTimeout(hoverIdle);
2252
                    }
2253

    
2254
                    var $target = UI.$(e.target);
2255

    
2256
                    if (active == $this && !$this.element.find(e.target).length) {
2257
                        $this.hide(true);
2258
                        UI.$html.off('click.outer.dropdown');
2259
                    }
2260
                });
2261
            }, 10);
2262
        },
2263

    
2264
        checkDimensions: function() {
2265

    
2266
            if (!this.dropdown.length) return;
2267

    
2268
            // reset
2269
            this.dropdown.removeClass('uk-dropdown-top uk-dropdown-bottom uk-dropdown-left uk-dropdown-right uk-dropdown-stack uk-dropdown-autoflip').css({
2270
                topLeft :'',
2271
                left :'',
2272
                marginLeft :'',
2273
                marginRight :''
2274
            });
2275

    
2276
            if (this.justified && this.justified.length) {
2277
                this.dropdown.css('min-width', '');
2278
            }
2279

    
2280
            var $this          = this,
2281
                pos            = UI.$.extend({}, this.offsetParent.offset(), {width: this.offsetParent[0].offsetWidth, height: this.offsetParent[0].offsetHeight}),
2282
                posoffset      = this.options.offset,
2283
                dropdown       = this.dropdown,
2284
                offset         = dropdown.show().offset() || {left: 0, top: 0},
2285
                width          = dropdown.outerWidth(),
2286
                height         = dropdown.outerHeight(),
2287
                boundarywidth  = this.boundary.width(),
2288
                boundaryoffset = this.boundary[0] !== window && this.boundary.offset() ? this.boundary.offset(): {top:0, left:0},
2289
                dpos           = this.options.pos;
2290

    
2291
            var variants =  {
2292
                    'bottom-left'   : {top: 0 + pos.height + posoffset, left: 0},
2293
                    'bottom-right'  : {top: 0 + pos.height + posoffset, left: 0 + pos.width - width},
2294
                    'bottom-center' : {top: 0 + pos.height + posoffset, left: 0 + pos.width / 2 - width / 2},
2295
                    'top-left'      : {top: 0 - height - posoffset, left: 0},
2296
                    'top-right'     : {top: 0 - height - posoffset, left: 0 + pos.width - width},
2297
                    'top-center'    : {top: 0 - height - posoffset, left: 0 + pos.width / 2 - width / 2},
2298
                    'left-top'      : {top: 0, left: 0 - width - posoffset},
2299
                    'left-bottom'   : {top: 0 + pos.height - height, left: 0 - width - posoffset},
2300
                    'left-center'   : {top: 0 + pos.height / 2 - height / 2, left: 0 - width - posoffset},
2301
                    'right-top'     : {top: 0, left: 0 + pos.width + posoffset},
2302
                    'right-bottom'  : {top: 0 + pos.height - height, left: 0 + pos.width + posoffset},
2303
                    'right-center'  : {top: 0 + pos.height / 2 - height / 2, left: 0 + pos.width + posoffset}
2304
                },
2305
                css = {},
2306
                pp;
2307

    
2308
            pp = dpos.split('-');
2309
            css = variants[dpos] ? variants[dpos] : variants['bottom-left'];
2310

    
2311
            // justify dropdown
2312
            if (this.justified && this.justified.length) {
2313
                justify(dropdown.css({left:0}), this.justified, boundarywidth);
2314
            } else {
2315

    
2316
                if (this.options.preventflip !== true) {
2317

    
2318
                    var fdpos;
2319

    
2320
                    switch(this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) {
2321
                        case "x":
2322
                            if(this.options.preventflip !=='x') fdpos = flips['x'][dpos] || 'right-top';
2323
                            break;
2324
                        case "y":
2325
                            if(this.options.preventflip !=='y') fdpos = flips['y'][dpos] || 'top-left';
2326
                            break;
2327
                        case "xy":
2328
                            if(!this.options.preventflip) fdpos = flips['xy'][dpos] || 'right-bottom';
2329
                            break;
2330
                    }
2331

    
2332
                    if (fdpos) {
2333

    
2334
                        pp  = fdpos.split('-');
2335
                        css = variants[fdpos] ? variants[fdpos] : variants['bottom-left'];
2336
                        dropdown.addClass('uk-dropdown-autoflip');
2337

    
2338
                        // check flipped
2339
                        if (this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) {
2340
                            pp  = dpos.split('-');
2341
                            css = variants[dpos] ? variants[dpos] : variants['bottom-left'];
2342
                        }
2343
                    }
2344
                }
2345
            }
2346

    
2347
            if (width > boundarywidth) {
2348
                dropdown.addClass('uk-dropdown-stack');
2349
                this.trigger('stack.uk.dropdown', [this]);
2350
            }
2351

    
2352
            dropdown.css(css).css('display', '').addClass('uk-dropdown-'+pp[0]);
2353
        },
2354

    
2355
        checkBoundary: function(left, top, width, height, boundarywidth) {
2356

    
2357
            var axis = "";
2358

    
2359
            if (left < 0 || ((left - UI.$win.scrollLeft())+width) > boundarywidth) {
2360
               axis += "x";
2361
            }
2362

    
2363
            if ((top - UI.$win.scrollTop()) < 0 || ((top - UI.$win.scrollTop())+height) > window.innerHeight) {
2364
               axis += "y";
2365
            }
2366

    
2367
            return axis;
2368
        }
2369
    });
2370

    
2371

    
2372
    UI.component('dropdownOverlay', {
2373

    
2374
        defaults: {
2375
           justify : false,
2376
           cls     : '',
2377
           duration: 200
2378
        },
2379

    
2380
        boot: function() {
2381

    
2382
            // init code
2383
            UI.ready(function(context) {
2384

    
2385
                UI.$('[data-uk-dropdown-overlay]', context).each(function() {
2386
                    var ele = UI.$(this);
2387

    
2388
                    if (!ele.data('dropdownOverlay')) {
2389
                        UI.dropdownOverlay(ele, UI.Utils.options(ele.attr('data-uk-dropdown-overlay')));
2390
                    }
2391
                });
2392
            });
2393
        },
2394

    
2395
        init: function() {
2396

    
2397
            var $this = this;
2398

    
2399
            this.justified = this.options.justify ? UI.$(this.options.justify) : false;
2400
            this.overlay   = this.element.find('uk-dropdown-overlay');
2401

    
2402
            if (!this.overlay.length) {
2403
                this.overlay = UI.$('<div class="uk-dropdown-overlay"></div>').appendTo(this.element);
2404
            }
2405

    
2406
            this.overlay.addClass(this.options.cls);
2407

    
2408
            this.on({
2409

    
2410
                'beforeshow.uk.dropdown': function(e, dropdown) {
2411
                    $this.dropdown = dropdown;
2412

    
2413
                    if ($this.justified && $this.justified.length) {
2414
                        justify($this.overlay.css({display:'block', marginLeft:'', marginRight:''}), $this.justified, $this.justified.outerWidth());
2415
                    }
2416
                },
2417

    
2418
                'show.uk.dropdown': function(e, dropdown) {
2419

    
2420
                    var h = $this.dropdown.dropdown.outerHeight(true);
2421

    
2422
                    $this.dropdown.element.removeClass('uk-open');
2423

    
2424
                    $this.overlay.stop().css('display', 'block').animate({height: h}, $this.options.duration, function() {
2425

    
2426
                       $this.dropdown.dropdown.css('visibility', '');
2427
                       $this.dropdown.element.addClass('uk-open');
2428

    
2429
                       UI.Utils.checkDisplay($this.dropdown.dropdown, true);
2430
                    });
2431

    
2432
                    $this.pointerleave = false;
2433
                },
2434

    
2435
                'hide.uk.dropdown': function() {
2436
                    $this.overlay.stop().animate({height: 0}, $this.options.duration);
2437
                },
2438

    
2439
                'pointerenter.uk.dropdown': function(e, dropdown) {
2440
                    clearTimeout($this.remainIdle);
2441
                },
2442

    
2443
                'pointerleave.uk.dropdown': function(e, dropdown) {
2444
                    $this.pointerleave = true;
2445
                }
2446
            });
2447

    
2448

    
2449
            this.overlay.on({
2450

    
2451
                'mouseenter': function() {
2452
                    if ($this.remainIdle) {
2453
                        clearTimeout($this.dropdown.remainIdle);
2454
                        clearTimeout($this.remainIdle);
2455
                    }
2456
                },
2457

    
2458
                'mouseleave': function(){
2459

    
2460
                    if ($this.pointerleave && active) {
2461

    
2462
                        $this.remainIdle = setTimeout(function() {
2463
                           if(active) active.hide();
2464
                        }, active.options.remaintime);
2465
                    }
2466
                }
2467
            })
2468
        }
2469

    
2470
    });
2471

    
2472

    
2473
    function justify(ele, justifyTo, boundarywidth, offset) {
2474

    
2475
        ele           = UI.$(ele);
2476
        justifyTo     = UI.$(justifyTo);
2477
        boundarywidth = boundarywidth || window.innerWidth;
2478
        offset        = offset || ele.offset();
2479

    
2480
        if (justifyTo.length) {
2481

    
2482
            var jwidth = justifyTo.outerWidth();
2483

    
2484
            ele.css('min-width', jwidth);
2485

    
2486
            if (UI.langdirection == 'right') {
2487

    
2488
                var right1   = boundarywidth - (justifyTo.offset().left + jwidth),
2489
                    right2   = boundarywidth - (ele.offset().left + ele.outerWidth());
2490

    
2491
                ele.css('margin-right', right1 - right2);
2492

    
2493
            } else {
2494
                ele.css('margin-left', justifyTo.offset().left - offset.left);
2495
            }
2496
        }
2497
    }
2498

    
2499
})(UIkit2);
2500

    
2501
(function(UI) {
2502

    
2503
    "use strict";
2504

    
2505
    var grids = [];
2506

    
2507
    UI.component('gridMatchHeight', {
2508

    
2509
        defaults: {
2510
            target        : false,
2511
            row           : true,
2512
            ignorestacked : false,
2513
            observe       : false
2514
        },
2515

    
2516
        boot: function() {
2517

    
2518
            // init code
2519
            UI.ready(function(context) {
2520

    
2521
                UI.$('[data-uk-grid-match]', context).each(function() {
2522
                    var grid = UI.$(this), obj;
2523

    
2524
                    if (!grid.data('gridMatchHeight')) {
2525
                        obj = UI.gridMatchHeight(grid, UI.Utils.options(grid.attr('data-uk-grid-match')));
2526
                    }
2527
                });
2528
            });
2529
        },
2530

    
2531
        init: function() {
2532

    
2533
            var $this = this;
2534

    
2535
            this.columns  = this.element.children();
2536
            this.elements = this.options.target ? this.find(this.options.target) : this.columns;
2537

    
2538
            if (!this.columns.length) return;
2539

    
2540
            UI.$win.on('load resize orientationchange', (function() {
2541

    
2542
                var fn = function() {
2543
                    if ($this.element.is(':visible')) $this.match();
2544
                };
2545

    
2546
                UI.$(function() { fn(); });
2547

    
2548
                return UI.Utils.debounce(fn, 50);
2549
            })());
2550

    
2551
            if (this.options.observe) {
2552

    
2553
                UI.domObserve(this.element, function(e) {
2554
                    if ($this.element.is(':visible')) $this.match();
2555
                });
2556
            }
2557

    
2558
            this.on('display.uk.check', function(e) {
2559
                if(this.element.is(':visible')) this.match();
2560
            }.bind(this));
2561

    
2562
            grids.push(this);
2563
        },
2564

    
2565
        match: function() {
2566

    
2567
            var firstvisible = this.columns.filter(':visible:first');
2568

    
2569
            if (!firstvisible.length) return;
2570

    
2571
            var stacked = Math.ceil(100 * parseFloat(firstvisible.css('width')) / parseFloat(firstvisible.parent().css('width'))) >= 100;
2572

    
2573
            if (stacked && !this.options.ignorestacked) {
2574
                this.revert();
2575
            } else {
2576
                UI.Utils.matchHeights(this.elements, this.options);
2577
            }
2578

    
2579
            return this;
2580
        },
2581

    
2582
        revert: function() {
2583
            this.elements.css('min-height', '');
2584
            return this;
2585
        }
2586
    });
2587

    
2588
    UI.component('gridMargin', {
2589

    
2590
        defaults: {
2591
            cls      : 'uk-grid-margin',
2592
            rowfirst : 'uk-row-first'
2593
        },
2594

    
2595
        boot: function() {
2596

    
2597
            // init code
2598
            UI.ready(function(context) {
2599

    
2600
                UI.$('[data-uk-grid-margin]', context).each(function() {
2601
                    var grid = UI.$(this), obj;
2602

    
2603
                    if (!grid.data('gridMargin')) {
2604
                        obj = UI.gridMargin(grid, UI.Utils.options(grid.attr('data-uk-grid-margin')));
2605
                    }
2606
                });
2607
            });
2608
        },
2609

    
2610
        init: function() {
2611

    
2612
            var stackMargin = UI.stackMargin(this.element, this.options);
2613
        }
2614
    });
2615

    
2616
})(UIkit2);
2617

    
2618
(function(UI) {
2619

    
2620
    "use strict";
2621

    
2622
    var active = false, activeCount = 0, $html = UI.$html, body;
2623

    
2624
    UI.$win.on('resize orientationchange', UI.Utils.debounce(function(){
2625
        UI.$('.uk-modal.uk-open').each(function(){
2626
            return UI.$(this).data('modal') && UI.$(this).data('modal').resize();
2627
        });
2628
    }, 150));
2629

    
2630
    UI.component('modal', {
2631

    
2632
        defaults: {
2633
            keyboard: true,
2634
            bgclose: true,
2635
            minScrollHeight: 150,
2636
            center: false,
2637
            modal: true
2638
        },
2639

    
2640
        scrollable: false,
2641
        transition: false,
2642
        hasTransitioned: true,
2643

    
2644
        init: function() {
2645

    
2646
            if (!body) body = UI.$('body');
2647

    
2648
            if (!this.element.length) return;
2649

    
2650
            var $this = this;
2651

    
2652
            this.paddingdir = 'padding-' + (UI.langdirection == 'left' ? 'right':'left');
2653
            this.dialog     = this.find('.uk-modal-dialog');
2654

    
2655
            this.active     = false;
2656

    
2657
            // Update ARIA
2658
            this.element.attr('aria-hidden', this.element.hasClass('uk-open'));
2659

    
2660
            this.on('click', '.uk-modal-close', function(e) {
2661

    
2662
                e.preventDefault();
2663

    
2664
                var modal = UI.$(e.target).closest('.uk-modal');
2665
                if (modal[0] === $this.element[0]) $this.hide();
2666

    
2667
            }).on('click', function(e) {
2668

    
2669
                var target = UI.$(e.target);
2670

    
2671
                if (target[0] == $this.element[0] && $this.options.bgclose) {
2672
                    $this.hide();
2673
                }
2674
            });
2675

    
2676
            UI.domObserve(this.element, function(e) { $this.resize(); });
2677
        },
2678

    
2679
        toggle: function() {
2680
            return this[this.isActive() ? 'hide' : 'show']();
2681
        },
2682

    
2683
        show: function() {
2684

    
2685
            if (!this.element.length) return;
2686

    
2687
            var $this = this;
2688

    
2689
            if (this.isActive()) return;
2690

    
2691
            if (this.options.modal && active) {
2692
                active.hide(true);
2693
            }
2694

    
2695
            this.element.removeClass('uk-open').show();
2696
            this.resize(true);
2697

    
2698
            if (this.options.modal) {
2699
                active = this;
2700
            }
2701

    
2702
            this.active = true;
2703

    
2704
            activeCount++;
2705

    
2706
            if (UI.support.transition) {
2707
                this.hasTransitioned = false;
2708
                this.element.one(UI.support.transition.end, function(){
2709
                    $this.hasTransitioned = true;
2710
                    UI.Utils.focus($this.dialog, 'a[href]');
2711
                }).addClass('uk-open');
2712
            } else {
2713
                this.element.addClass('uk-open');
2714
                UI.Utils.focus(this.dialog, 'a[href]');
2715
            }
2716

    
2717
            $html.addClass('uk-modal-page').height(); // force browser engine redraw
2718

    
2719
            // Update ARIA
2720
            this.element.attr('aria-hidden', 'false');
2721

    
2722
            this.element.trigger('show.uk.modal');
2723

    
2724
            UI.Utils.checkDisplay(this.dialog, true);
2725

    
2726
            return this;
2727
        },
2728

    
2729
        hide: function(force) {
2730

    
2731
            if (!force && UI.support.transition && this.hasTransitioned) {
2732

    
2733
                var $this = this;
2734

    
2735
                this.one(UI.support.transition.end, function() {
2736
                    $this._hide();
2737
                }).removeClass('uk-open');
2738

    
2739
            } else {
2740

    
2741
                this._hide();
2742
            }
2743

    
2744
            return this;
2745
        },
2746

    
2747
        resize: function(force) {
2748

    
2749
            if (!this.isActive() && !force) return;
2750

    
2751
            var bodywidth  = body.width();
2752

    
2753
            this.scrollbarwidth = window.innerWidth - bodywidth;
2754

    
2755
            body.css(this.paddingdir, this.scrollbarwidth);
2756

    
2757
            this.element.css('overflow-y', this.scrollbarwidth ? 'scroll' : 'auto');
2758

    
2759
            if (!this.updateScrollable() && this.options.center) {
2760

    
2761
                var dh  = this.dialog.outerHeight(),
2762
                pad = parseInt(this.dialog.css('margin-top'), 10) + parseInt(this.dialog.css('margin-bottom'), 10);
2763

    
2764
                if ((dh + pad) < window.innerHeight) {
2765
                    this.dialog.css({top: (window.innerHeight/2 - dh/2) - pad });
2766
                } else {
2767
                    this.dialog.css({top: ''});
2768
                }
2769
            }
2770
        },
2771

    
2772
        updateScrollable: function() {
2773

    
2774
            // has scrollable?
2775
            var scrollable = this.dialog.find('.uk-overflow-container:visible:first');
2776

    
2777
            if (scrollable.length) {
2778

    
2779
                scrollable.css('height', 0);
2780

    
2781
                var offset = Math.abs(parseInt(this.dialog.css('margin-top'), 10)),
2782
                dh     = this.dialog.outerHeight(),
2783
                wh     = window.innerHeight,
2784
                h      = wh - 2*(offset < 20 ? 20:offset) - dh;
2785

    
2786
                scrollable.css({
2787
                    maxHeight: (h < this.options.minScrollHeight ? '':h),
2788
                    height:''
2789
                });
2790

    
2791
                return true;
2792
            }
2793

    
2794
            return false;
2795
        },
2796

    
2797
        _hide: function() {
2798

    
2799
            this.active = false;
2800
            if (activeCount > 0) activeCount--;
2801
            else activeCount = 0;
2802

    
2803
            this.element.hide().removeClass('uk-open');
2804

    
2805
            // Update ARIA
2806
            this.element.attr('aria-hidden', 'true');
2807

    
2808
            if (!activeCount) {
2809
                $html.removeClass('uk-modal-page');
2810
                body.css(this.paddingdir, "");
2811
            }
2812

    
2813
            if (active===this) active = false;
2814

    
2815
            this.trigger('hide.uk.modal');
2816
        },
2817

    
2818
        isActive: function() {
2819
            return this.element.hasClass('uk-open');
2820
        }
2821

    
2822
    });
2823

    
2824
    UI.component('modalTrigger', {
2825

    
2826
        boot: function() {
2827

    
2828
            // init code
2829
            UI.$html.on('click.modal.uikit', '[data-uk-modal]', function(e) {
2830

    
2831
                var ele = UI.$(this);
2832

    
2833
                if (ele.is('a')) {
2834
                    e.preventDefault();
2835
                }
2836

    
2837
                if (!ele.data('modalTrigger')) {
2838
                    var modal = UI.modalTrigger(ele, UI.Utils.options(ele.attr('data-uk-modal')));
2839
                    modal.show();
2840
                }
2841

    
2842
            });
2843

    
2844
            // close modal on esc button
2845
            UI.$html.on('keydown.modal.uikit', function (e) {
2846

    
2847
                if (active && e.keyCode === 27 && active.options.keyboard) { // ESC
2848
                    e.preventDefault();
2849
                    active.hide();
2850
                }
2851
            });
2852
        },
2853

    
2854
        init: function() {
2855

    
2856
            var $this = this;
2857

    
2858
            this.options = UI.$.extend({
2859
                target: $this.element.is('a') ? $this.element.attr('href') : false
2860
            }, this.options);
2861

    
2862
            this.modal = UI.modal(this.options.target, this.options);
2863

    
2864
            this.on("click", function(e) {
2865
                e.preventDefault();
2866
                $this.show();
2867
            });
2868

    
2869
            //methods
2870
            this.proxy(this.modal, 'show hide isActive');
2871
        }
2872
    });
2873

    
2874
    UI.modal.dialog = function(content, options) {
2875

    
2876
        var modal = UI.modal(UI.$(UI.modal.dialog.template).appendTo('body'), options);
2877

    
2878
        modal.on('hide.uk.modal', function(){
2879
            if (modal.persist) {
2880
                modal.persist.appendTo(modal.persist.data('modalPersistParent'));
2881
                modal.persist = false;
2882
            }
2883
            modal.element.remove();
2884
        });
2885

    
2886
        setContent(content, modal);
2887

    
2888
        return modal;
2889
    };
2890

    
2891
    UI.modal.dialog.template = '<div class="uk-modal"><div class="uk-modal-dialog" style="min-height:0;"></div></div>';
2892

    
2893
    UI.modal.alert = function(content, options) {
2894

    
2895
        options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options);
2896

    
2897
        var modal = UI.modal.dialog(([
2898
            '<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
2899
            '<div class="uk-modal-footer uk-text-right"><button class="uk-button uk-button-primary uk-modal-close">'+options.labels.Ok+'</button></div>'
2900
        ]).join(""), options);
2901

    
2902
        modal.on('show.uk.modal', function(){
2903
            setTimeout(function(){
2904
                modal.element.find('button:first').focus();
2905
            }, 50);
2906
        });
2907

    
2908
        return modal.show();
2909
    };
2910

    
2911
    UI.modal.confirm = function(content, onconfirm, oncancel) {
2912

    
2913
        var options = arguments.length > 1 && arguments[arguments.length-1] ? arguments[arguments.length-1] : {};
2914

    
2915
        onconfirm = UI.$.isFunction(onconfirm) ? onconfirm : function(){};
2916
        oncancel  = UI.$.isFunction(oncancel) ? oncancel : function(){};
2917
        options   = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, UI.$.isFunction(options) ? {}:options);
2918

    
2919
        var modal = UI.modal.dialog(([
2920
            '<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
2921
            '<div class="uk-modal-footer uk-text-right"><button class="uk-button js-modal-confirm-cancel">'+options.labels.Cancel+'</button> <button class="uk-button uk-button-primary js-modal-confirm">'+options.labels.Ok+'</button></div>'
2922
        ]).join(""), options);
2923

    
2924
        modal.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click", function(){
2925
            UI.$(this).is('.js-modal-confirm') ? onconfirm() : oncancel();
2926
            modal.hide();
2927
        });
2928

    
2929
        modal.on('show.uk.modal', function(){
2930
            setTimeout(function(){
2931
                modal.element.find('.js-modal-confirm').focus();
2932
            }, 50);
2933
        });
2934

    
2935
        return modal.show();
2936
    };
2937

    
2938
    UI.modal.prompt = function(text, value, onsubmit, options) {
2939

    
2940
        onsubmit = UI.$.isFunction(onsubmit) ? onsubmit : function(value){};
2941
        options  = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options);
2942

    
2943
        var modal = UI.modal.dialog(([
2944
            text ? '<div class="uk-modal-content uk-form">'+String(text)+'</div>':'',
2945
            '<div class="uk-margin-small-top uk-modal-content uk-form"><p><input type="text" class="uk-width-1-1"></p></div>',
2946
            '<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>'
2947
        ]).join(""), options),
2948

    
2949
        input = modal.element.find("input[type='text']").val(value || '').on('keyup', function(e){
2950
            if (e.keyCode == 13) {
2951
                modal.element.find('.js-modal-ok').trigger('click');
2952
            }
2953
        });
2954

    
2955
        modal.element.find('.js-modal-ok').on('click', function(){
2956
            if (onsubmit(input.val())!==false){
2957
                modal.hide();
2958
            }
2959
        });
2960

    
2961
        return modal.show();
2962
    };
2963

    
2964
    UI.modal.blockUI = function(content, options) {
2965

    
2966
        var modal = UI.modal.dialog(([
2967
            '<div class="uk-margin uk-modal-content">'+String(content || '<div class="uk-text-center">...</div>')+'</div>'
2968
        ]).join(""), UI.$.extend({bgclose:false, keyboard:false, modal:false}, options));
2969

    
2970
        modal.content = modal.element.find('.uk-modal-content:first');
2971

    
2972
        return modal.show();
2973
    };
2974

    
2975
    UI.modal.labels = {
2976
        Ok: 'Ok',
2977
        Cancel: 'Cancel'
2978
    };
2979

    
2980
    // helper functions
2981
    function setContent(content, modal){
2982

    
2983
        if(!modal) return;
2984

    
2985
        if (typeof content === 'object') {
2986

    
2987
            // convert DOM object to a jQuery object
2988
            content = content instanceof jQuery ? content : UI.$(content);
2989

    
2990
            if(content.parent().length) {
2991
                modal.persist = content;
2992
                modal.persist.data('modalPersistParent', content.parent());
2993
            }
2994
        }else if (typeof content === 'string' || typeof content === 'number') {
2995
                // just insert the data as innerHTML
2996
                content = UI.$('<div></div>').html(content);
2997
        }else {
2998
                // unsupported data type!
2999
                content = UI.$('<div></div>').html('UIkit2.modal Error: Unsupported data type: ' + typeof content);
3000
        }
3001

    
3002
        content.appendTo(modal.element.find('.uk-modal-dialog'));
3003

    
3004
        return modal;
3005
    }
3006

    
3007
})(UIkit2);
3008

    
3009
(function(UI) {
3010

    
3011
    "use strict";
3012

    
3013
    UI.component('nav', {
3014

    
3015
        defaults: {
3016
            toggle: '>li.uk-parent > a[href="#"]',
3017
            lists: '>li.uk-parent > ul',
3018
            multiple: false
3019
        },
3020

    
3021
        boot: function() {
3022

    
3023
            // init code
3024
            UI.ready(function(context) {
3025

    
3026
                UI.$('[data-uk-nav]', context).each(function() {
3027
                    var nav = UI.$(this);
3028

    
3029
                    if (!nav.data('nav')) {
3030
                        var obj = UI.nav(nav, UI.Utils.options(nav.attr('data-uk-nav')));
3031
                    }
3032
                });
3033
            });
3034
        },
3035

    
3036
        init: function() {
3037

    
3038
            var $this = this;
3039

    
3040
            this.on('click.uk.nav', this.options.toggle, function(e) {
3041
                e.preventDefault();
3042
                var ele = UI.$(this);
3043
                $this.open(ele.parent()[0] == $this.element[0] ? ele : ele.parent("li"));
3044
            });
3045

    
3046
            this.update();
3047

    
3048
            UI.domObserve(this.element, function(e) {
3049
                if ($this.element.find($this.options.lists).not('[role]').length) {
3050
                    $this.update();
3051
                }
3052
            });
3053
        },
3054

    
3055
        update: function() {
3056

    
3057
            var $this = this;
3058

    
3059
            this.find(this.options.lists).each(function() {
3060

    
3061
                var $ele   = UI.$(this).attr('role', 'menu'),
3062
                    parent = $ele.closest('li'),
3063
                    active = parent.hasClass("uk-active");
3064

    
3065
                if (!parent.data('list-container')) {
3066
                    $ele.wrap('<div style="overflow:hidden;height:0;position:relative;"></div>');
3067
                    parent.data('list-container', $ele.parent()[active ? 'removeClass':'addClass']('uk-hidden'));
3068
                }
3069

    
3070
                // Init ARIA
3071
                parent.attr('aria-expanded', parent.hasClass("uk-open"));
3072

    
3073
                if (active) $this.open(parent, true);
3074
            });
3075
        },
3076

    
3077
        open: function(li, noanimation) {
3078

    
3079
            var $this = this, element = this.element, $li = UI.$(li), $container = $li.data('list-container');
3080

    
3081
            if (!this.options.multiple) {
3082

    
3083
                element.children('.uk-open').not(li).each(function() {
3084

    
3085
                    var ele = UI.$(this);
3086

    
3087
                    if (ele.data('list-container')) {
3088
                        ele.data('list-container').stop().animate({height: 0}, function() {
3089
                            UI.$(this).parent().removeClass('uk-open').end().addClass('uk-hidden');
3090
                        });
3091
                    }
3092
                });
3093
            }
3094

    
3095
            $li.toggleClass('uk-open');
3096

    
3097
            // Update ARIA
3098
            $li.attr('aria-expanded', $li.hasClass('uk-open'));
3099

    
3100
            if ($container) {
3101

    
3102
                if ($li.hasClass('uk-open')) {
3103
                    $container.removeClass('uk-hidden');
3104
                }
3105

    
3106
                if (noanimation) {
3107

    
3108
                    $container.stop().height($li.hasClass('uk-open') ? 'auto' : 0);
3109

    
3110
                    if (!$li.hasClass('uk-open')) {
3111
                        $container.addClass('uk-hidden');
3112
                    }
3113

    
3114
                    this.trigger('display.uk.check');
3115

    
3116
                } else {
3117

    
3118
                    $container.stop().animate({
3119
                        height: ($li.hasClass('uk-open') ? getHeight($container.find('ul:first')) : 0)
3120
                    }, function() {
3121

    
3122
                        if (!$li.hasClass('uk-open')) {
3123
                            $container.addClass('uk-hidden');
3124
                        } else {
3125
                            $container.css('height', '');
3126
                        }
3127

    
3128
                        $this.trigger('display.uk.check');
3129
                    });
3130
                }
3131
            }
3132
        }
3133
    });
3134

    
3135

    
3136
    // helper
3137

    
3138
    function getHeight(ele) {
3139

    
3140
        var $ele = UI.$(ele), height = 'auto';
3141

    
3142
        if ($ele.is(':visible')) {
3143
            height = $ele.outerHeight();
3144
        } else {
3145

    
3146
            var tmp = {
3147
                position: $ele.css('position'),
3148
                visibility: $ele.css('visibility'),
3149
                display: $ele.css('display')
3150
            };
3151

    
3152
            height = $ele.css({position: 'absolute', visibility: 'hidden', display: 'block'}).outerHeight();
3153

    
3154
            $ele.css(tmp); // reset element
3155
        }
3156

    
3157
        return height;
3158
    }
3159

    
3160
})(UIkit2);
3161

    
3162
(function(UI) {
3163

    
3164
    "use strict";
3165

    
3166
    var scrollpos = {x: window.scrollX, y: window.scrollY},
3167
        $win      = UI.$win,
3168
        $doc      = UI.$doc,
3169
        $html     = UI.$html,
3170
        Offcanvas = {
3171

    
3172
        show: function(element, options) {
3173

    
3174
            element = UI.$(element);
3175

    
3176
            if (!element.length) return;
3177

    
3178
            options = UI.$.extend({mode: 'push'}, options);
3179

    
3180
            var $body     = UI.$('body'),
3181
                bar       = element.find('.uk-offcanvas-bar:first'),
3182
                rtl       = (UI.langdirection == 'right'),
3183
                flip      = bar.hasClass('uk-offcanvas-bar-flip') ? -1:1,
3184
                dir       = flip * (rtl ? -1 : 1),
3185

    
3186
                scrollbarwidth =  window.innerWidth - $body.width();
3187

    
3188
            scrollpos = {x: window.pageXOffset, y: window.pageYOffset};
3189

    
3190
            bar.attr('mode', options.mode);
3191
            element.addClass('uk-active');
3192

    
3193
            $body.css({width: window.innerWidth - scrollbarwidth, height: window.innerHeight}).addClass('uk-offcanvas-page');
3194

    
3195
            if (options.mode == 'push' || options.mode == 'reveal') {
3196
                $body.css((rtl ? 'margin-right' : 'margin-left'), (rtl ? -1 : 1) * (bar.outerWidth() * dir));
3197
            }
3198

    
3199
            if (options.mode == 'reveal') {
3200
                bar.css('clip', 'rect(0, '+bar.outerWidth()+'px, 100vh, 0)');
3201
            }
3202

    
3203
            $html.css('margin-top', scrollpos.y * -1).width(); // .width() - force redraw
3204

    
3205

    
3206
            bar.addClass('uk-offcanvas-bar-show');
3207

    
3208
            this._initElement(element);
3209

    
3210
            bar.trigger('show.uk.offcanvas', [element, bar]);
3211

    
3212
            // Update ARIA
3213
            element.attr('aria-hidden', 'false');
3214
        },
3215

    
3216
        hide: function(force) {
3217

    
3218
            var $body = UI.$('body'),
3219
                panel = UI.$('.uk-offcanvas.uk-active'),
3220
                rtl   = (UI.langdirection == 'right'),
3221
                bar   = panel.find('.uk-offcanvas-bar:first'),
3222
                finalize = function() {
3223
                    $body.removeClass('uk-offcanvas-page').css({width: '', height: '', marginLeft: '', marginRight: ''});
3224
                    panel.removeClass('uk-active');
3225

    
3226
                    bar.removeClass('uk-offcanvas-bar-show');
3227
                    $html.css('margin-top', '');
3228
                    window.scrollTo(scrollpos.x, scrollpos.y);
3229
                    bar.trigger('hide.uk.offcanvas', [panel, bar]);
3230

    
3231
                    // Update ARIA
3232
                    panel.attr('aria-hidden', 'true');
3233
                };
3234

    
3235
            if (!panel.length) return;
3236
            if (bar.attr('mode') == 'none') force = true;
3237

    
3238
            if (UI.support.transition && !force) {
3239

    
3240
                $body.one(UI.support.transition.end, function() {
3241
                    finalize();
3242
                }).css((rtl ? 'margin-right' : 'margin-left'), '');
3243

    
3244
                if (bar.attr('mode') == 'reveal') {
3245
                    bar.css('clip', '');
3246
                }
3247

    
3248
                setTimeout(function(){
3249
                    bar.removeClass('uk-offcanvas-bar-show');
3250
                }, 0);
3251

    
3252
            } else {
3253
                finalize();
3254
            }
3255
        },
3256

    
3257
        _initElement: function(element) {
3258

    
3259
            if (element.data('OffcanvasInit')) return;
3260

    
3261
            element.on('click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas', function(e) {
3262

    
3263
                var target = UI.$(e.target);
3264

    
3265
                if (e.type.match(/swipe/)) {
3266
                    if (target.parents('.uk-offcanvas-bar:first').length) return;
3267
                } else {
3268

    
3269
                    if (!target.hasClass('uk-offcanvas-close')) {
3270
                        if (target.hasClass('uk-offcanvas-bar')) return;
3271
                        if (target.parents('.uk-offcanvas-bar:first').length) return;
3272
                    }
3273
                }
3274

    
3275
                e.stopImmediatePropagation();
3276
                Offcanvas.hide();
3277
            });
3278

    
3279
            element.on('click', 'a[href*="#"]', function(e){
3280

    
3281
                var link = UI.$(this),
3282
                    href = link.attr('href');
3283

    
3284
                if (href == '#') {
3285
                    return;
3286
                }
3287

    
3288
                UI.$doc.one('hide.uk.offcanvas', function() {
3289

    
3290
                    var target;
3291

    
3292
                    try {
3293
                        target = UI.$(link[0].hash);
3294
                    } catch (e){
3295
                        target = '';
3296
                    }
3297

    
3298
                    if (!target.length) {
3299
                        target = UI.$('[name="'+link[0].hash.replace('#','')+'"]');
3300
                    }
3301

    
3302
                    if (target.length && UI.Utils.scrollToElement) {
3303
                        UI.Utils.scrollToElement(target, UI.Utils.options(link.attr('data-uk-smooth-scroll') || '{}'));
3304
                    } else {
3305
                        window.location.href = href;
3306
                    }
3307
                });
3308

    
3309
                Offcanvas.hide();
3310
            });
3311

    
3312
            element.data('OffcanvasInit', true);
3313
        }
3314
    };
3315

    
3316
    UI.component('offcanvasTrigger', {
3317

    
3318
        boot: function() {
3319

    
3320
            // init code
3321
            $html.on('click.offcanvas.uikit', '[data-uk-offcanvas]', function(e) {
3322

    
3323
                e.preventDefault();
3324

    
3325
                var ele = UI.$(this);
3326

    
3327
                if (!ele.data('offcanvasTrigger')) {
3328
                    var obj = UI.offcanvasTrigger(ele, UI.Utils.options(ele.attr('data-uk-offcanvas')));
3329
                    ele.trigger("click");
3330
                }
3331
            });
3332

    
3333
            $html.on('keydown.uk.offcanvas', function(e) {
3334

    
3335
                if (e.keyCode === 27) { // ESC
3336
                    Offcanvas.hide();
3337
                }
3338
            });
3339
        },
3340

    
3341
        init: function() {
3342

    
3343
            var $this = this;
3344

    
3345
            this.options = UI.$.extend({
3346
                target: $this.element.is('a') ? $this.element.attr('href') : false,
3347
                mode: 'push'
3348
            }, this.options);
3349

    
3350
            this.on('click', function(e) {
3351
                e.preventDefault();
3352
                Offcanvas.show($this.options.target, $this.options);
3353
            });
3354
        }
3355
    });
3356

    
3357
    UI.offcanvas = Offcanvas;
3358

    
3359
})(UIkit2);
3360

    
3361
(function(UI) {
3362

    
3363
    "use strict";
3364

    
3365
    var Animations;
3366

    
3367
    UI.component('switcher', {
3368

    
3369
        defaults: {
3370
            connect   : false,
3371
            toggle    : '>*',
3372
            active    : 0,
3373
            animation : false,
3374
            duration  : 200,
3375
            swiping   : true
3376
        },
3377

    
3378
        animating: false,
3379

    
3380
        boot: function() {
3381

    
3382
            // init code
3383
            UI.ready(function(context) {
3384

    
3385
                UI.$('[data-uk-switcher]', context).each(function() {
3386
                    var switcher = UI.$(this);
3387

    
3388
                    if (!switcher.data('switcher')) {
3389
                        var obj = UI.switcher(switcher, UI.Utils.options(switcher.attr('data-uk-switcher')));
3390
                    }
3391
                });
3392
            });
3393
        },
3394

    
3395
        init: function() {
3396

    
3397
            var $this = this;
3398

    
3399
            this.on('click.uk.switcher', this.options.toggle, function(e) {
3400
                e.preventDefault();
3401
                $this.show(this);
3402
            });
3403

    
3404
            if (!this.options.connect) {
3405
                return;
3406
            }
3407

    
3408
            this.connect = UI.$(this.options.connect);
3409

    
3410
            if (!this.connect.length) {
3411
                return;
3412
            }
3413

    
3414
            this.connect.on('click.uk.switcher', '[data-uk-switcher-item]', function(e) {
3415

    
3416
                e.preventDefault();
3417

    
3418
                var item = UI.$(this).attr('data-uk-switcher-item');
3419

    
3420
                if ($this.index == item) return;
3421

    
3422
                switch(item) {
3423
                    case 'next':
3424
                    case 'previous':
3425
                        $this.show($this.index + (item=='next' ? 1:-1));
3426
                        break;
3427
                    default:
3428
                        $this.show(parseInt(item, 10));
3429
                }
3430
            });
3431

    
3432
            if (this.options.swiping) {
3433

    
3434
                this.connect.on('swipeRight swipeLeft', function(e) {
3435
                    e.preventDefault();
3436
                    if (!window.getSelection().toString()) {
3437
                        $this.show($this.index + (e.type == 'swipeLeft' ? 1 : -1));
3438
                    }
3439
                });
3440
            }
3441

    
3442
            this.update();
3443
        },
3444

    
3445
        update: function() {
3446

    
3447
            this.connect.children().removeClass('uk-active').attr('aria-hidden', 'true');
3448

    
3449
            var toggles = this.find(this.options.toggle),
3450
                active  = toggles.filter('.uk-active');
3451

    
3452
            if (active.length) {
3453
                this.show(active, false);
3454
            } else {
3455

    
3456
                if (this.options.active===false) return;
3457

    
3458
                active = toggles.eq(this.options.active);
3459
                this.show(active.length ? active : toggles.eq(0), false);
3460
            }
3461

    
3462
            // Init ARIA for toggles
3463
            toggles.not(active).attr('aria-expanded', 'false');
3464
            active.attr('aria-expanded', 'true');
3465
        },
3466

    
3467
        show: function(tab, animate) {
3468

    
3469
            if (this.animating) {
3470
                return;
3471
            }
3472

    
3473
            var toggles = this.find(this.options.toggle);
3474

    
3475
            if (isNaN(tab)) {
3476
                tab = UI.$(tab);
3477
            } else {
3478
                tab = tab < 0 ? toggles.length-1 : tab;
3479
                tab = toggles.eq(toggles[tab] ? tab : 0);
3480
            }
3481

    
3482
            var $this     = this,
3483
                active    = UI.$(tab),
3484
                animation = Animations[this.options.animation] || function(current, next) {
3485

    
3486
                    if (!$this.options.animation) {
3487
                        return Animations.none.apply($this);
3488
                    }
3489

    
3490
                    var anim = $this.options.animation.split(',');
3491

    
3492
                    if (anim.length == 1) {
3493
                        anim[1] = anim[0];
3494
                    }
3495

    
3496
                    anim[0] = anim[0].trim();
3497
                    anim[1] = anim[1].trim();
3498

    
3499
                    return coreAnimation.apply($this, [anim, current, next]);
3500
                };
3501

    
3502
            if (animate===false || !UI.support.animation) {
3503
                animation = Animations.none;
3504
            }
3505

    
3506
            if (active.hasClass("uk-disabled")) return;
3507

    
3508
            // Update ARIA for Toggles
3509
            toggles.attr('aria-expanded', 'false');
3510
            active.attr('aria-expanded', 'true');
3511

    
3512
            toggles.filter(".uk-active").removeClass("uk-active");
3513
            active.addClass("uk-active");
3514

    
3515
            if (this.options.connect && this.connect.length) {
3516

    
3517
                this.index = this.find(this.options.toggle).index(active);
3518

    
3519
                if (this.index == -1 ) {
3520
                    this.index = 0;
3521
                }
3522

    
3523
                this.connect.each(function() {
3524

    
3525
                    var container = UI.$(this),
3526
                        children  = UI.$(container.children()),
3527
                        current   = UI.$(children.filter('.uk-active')),
3528
                        next      = UI.$(children.eq($this.index));
3529

    
3530
                        $this.animating = true;
3531

    
3532
                        animation.apply($this, [current, next]).then(function(){
3533

    
3534
                            current.removeClass("uk-active");
3535
                            next.addClass("uk-active");
3536

    
3537
                            // Update ARIA for connect
3538
                            current.attr('aria-hidden', 'true');
3539
                            next.attr('aria-hidden', 'false');
3540

    
3541
                            UI.Utils.checkDisplay(next, true);
3542

    
3543
                            $this.animating = false;
3544

    
3545
                        });
3546
                });
3547
            }
3548

    
3549
            this.trigger("show.uk.switcher", [active]);
3550
        }
3551
    });
3552

    
3553
    Animations = {
3554

    
3555
        'none': function() {
3556
            var d = UI.$.Deferred();
3557
            d.resolve();
3558
            return d.promise();
3559
        },
3560

    
3561
        'fade': function(current, next) {
3562
            return coreAnimation.apply(this, ['uk-animation-fade', current, next]);
3563
        },
3564

    
3565
        'slide-bottom': function(current, next) {
3566
            return coreAnimation.apply(this, ['uk-animation-slide-bottom', current, next]);
3567
        },
3568

    
3569
        'slide-top': function(current, next) {
3570
            return coreAnimation.apply(this, ['uk-animation-slide-top', current, next]);
3571
        },
3572

    
3573
        'slide-vertical': function(current, next, dir) {
3574

    
3575
            var anim = ['uk-animation-slide-top', 'uk-animation-slide-bottom'];
3576

    
3577
            if (current && current.index() > next.index()) {
3578
                anim.reverse();
3579
            }
3580

    
3581
            return coreAnimation.apply(this, [anim, current, next]);
3582
        },
3583

    
3584
        'slide-left': function(current, next) {
3585
            return coreAnimation.apply(this, ['uk-animation-slide-left', current, next]);
3586
        },
3587

    
3588
        'slide-right': function(current, next) {
3589
            return coreAnimation.apply(this, ['uk-animation-slide-right', current, next]);
3590
        },
3591

    
3592
        'slide-horizontal': function(current, next, dir) {
3593

    
3594
            var anim = ['uk-animation-slide-right', 'uk-animation-slide-left'];
3595

    
3596
            if (current && current.index() > next.index()) {
3597
                anim.reverse();
3598
            }
3599

    
3600
            return coreAnimation.apply(this, [anim, current, next]);
3601
        },
3602

    
3603
        'scale': function(current, next) {
3604
            return coreAnimation.apply(this, ['uk-animation-scale-up', current, next]);
3605
        }
3606
    };
3607

    
3608
    UI.switcher.animations = Animations;
3609

    
3610

    
3611
    // helpers
3612

    
3613
    function coreAnimation(cls, current, next) {
3614

    
3615
        var d = UI.$.Deferred(), clsIn = cls, clsOut = cls, release;
3616

    
3617
        if (next[0]===current[0]) {
3618
            d.resolve();
3619
            return d.promise();
3620
        }
3621

    
3622
        if (typeof(cls) == 'object') {
3623
            clsIn  = cls[0];
3624
            clsOut = cls[1] || cls[0];
3625
        }
3626

    
3627
        UI.$body.css('overflow-x', 'hidden'); // fix scroll jumping in iOS
3628

    
3629
        release = function() {
3630

    
3631
            if (current) current.hide().removeClass('uk-active '+clsOut+' uk-animation-reverse');
3632

    
3633
            next.addClass(clsIn).one(UI.support.animation.end, function() {
3634

    
3635
                setTimeout(function () {
3636
                    next.removeClass(''+clsIn+'').css({opacity:'', display:''});
3637
                }, 0);
3638

    
3639
                d.resolve();
3640

    
3641
                UI.$body.css('overflow-x', '');
3642

    
3643
                if (current) current.css({opacity:'', display:''});
3644

    
3645
            }.bind(this)).show();
3646
        };
3647

    
3648
        next.css('animation-duration', this.options.duration+'ms');
3649

    
3650
        if (current && current.length) {
3651

    
3652
            current.css('animation-duration', this.options.duration+'ms');
3653

    
3654
            current.css('display', 'none').addClass(clsOut+' uk-animation-reverse').one(UI.support.animation.end, function() {
3655
                release();
3656
            }.bind(this)).css('display', '');
3657

    
3658
        } else {
3659
            next.addClass('uk-active');
3660
            release();
3661
        }
3662

    
3663
        return d.promise();
3664
    }
3665

    
3666
})(UIkit2);
3667

    
3668
(function(UI) {
3669

    
3670
    "use strict";
3671

    
3672
    UI.component('tab', {
3673

    
3674
        defaults: {
3675
            target    : '>li:not(.uk-tab-responsive, .uk-disabled)',
3676
            connect   : false,
3677
            active    : 0,
3678
            animation : false,
3679
            duration  : 200,
3680
            swiping   : true
3681
        },
3682

    
3683
        boot: function() {
3684

    
3685
            // init code
3686
            UI.ready(function(context) {
3687

    
3688
                UI.$('[data-uk-tab]', context).each(function() {
3689

    
3690
                    var tab = UI.$(this);
3691

    
3692
                    if (!tab.data('tab')) {
3693
                        var obj = UI.tab(tab, UI.Utils.options(tab.attr('data-uk-tab')));
3694
                    }
3695
                });
3696
            });
3697
        },
3698

    
3699
        init: function() {
3700

    
3701
            var $this = this;
3702

    
3703
            this.current = false;
3704

    
3705
            this.on('click.uk.tab', this.options.target, function(e) {
3706

    
3707
                e.preventDefault();
3708

    
3709
                if ($this.switcher && $this.switcher.animating) {
3710
                    return;
3711
                }
3712

    
3713
                var current = $this.find($this.options.target).not(this);
3714

    
3715
                current.removeClass('uk-active').blur();
3716

    
3717
                $this.trigger('change.uk.tab', [UI.$(this).addClass('uk-active'), $this.current]);
3718

    
3719
                $this.current = UI.$(this);
3720

    
3721
                // Update ARIA
3722
                if (!$this.options.connect) {
3723
                    current.attr('aria-expanded', 'false');
3724
                    UI.$(this).attr('aria-expanded', 'true');
3725
                }
3726
            });
3727

    
3728
            if (this.options.connect) {
3729
                this.connect = UI.$(this.options.connect);
3730
            }
3731

    
3732
            // init responsive tab
3733
            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>');
3734

    
3735
            this.responsivetab.dropdown = this.responsivetab.find('.uk-dropdown');
3736
            this.responsivetab.lst      = this.responsivetab.dropdown.find('ul');
3737
            this.responsivetab.caption  = this.responsivetab.find('a:first');
3738

    
3739
            if (this.element.hasClass('uk-tab-bottom')) this.responsivetab.dropdown.addClass('uk-dropdown-up');
3740

    
3741
            // handle click
3742
            this.responsivetab.lst.on('click.uk.tab', 'a', function(e) {
3743

    
3744
                e.preventDefault();
3745
                e.stopPropagation();
3746

    
3747
                var link = UI.$(this);
3748

    
3749
                $this.element.children('li:not(.uk-tab-responsive)').eq(link.data('index')).trigger('click');
3750
            });
3751

    
3752
            this.on('show.uk.switcher change.uk.tab', function(e, tab) {
3753
                $this.responsivetab.caption.html(tab.text());
3754
            });
3755

    
3756
            this.element.append(this.responsivetab);
3757

    
3758
            // init UIkit components
3759
            if (this.options.connect) {
3760

    
3761
                this.switcher = UI.switcher(this.element, {
3762
                    toggle    : '>li:not(.uk-tab-responsive)',
3763
                    connect   : this.options.connect,
3764
                    active    : this.options.active,
3765
                    animation : this.options.animation,
3766
                    duration  : this.options.duration,
3767
                    swiping   : this.options.swiping
3768
                });
3769
            }
3770

    
3771
            UI.dropdown(this.responsivetab, {mode: 'click', preventflip: 'y'});
3772

    
3773
            // init
3774
            $this.trigger('change.uk.tab', [this.element.find(this.options.target).not('.uk-tab-responsive').filter('.uk-active')]);
3775

    
3776
            this.check();
3777

    
3778
            UI.$win.on('resize orientationchange', UI.Utils.debounce(function(){
3779
                if ($this.element.is(':visible'))  $this.check();
3780
            }, 100));
3781

    
3782
            this.on('display.uk.check', function(){
3783
                if ($this.element.is(':visible'))  $this.check();
3784
            });
3785
        },
3786

    
3787
        check: function() {
3788

    
3789
            var children = this.element.children('li:not(.uk-tab-responsive)').removeClass('uk-hidden');
3790

    
3791
            if (!children.length) {
3792
                this.responsivetab.addClass('uk-hidden');
3793
                return;
3794
            }
3795

    
3796
            var top          = (children.eq(0).offset().top + Math.ceil(children.eq(0).height()/2)),
3797
                doresponsive = false,
3798
                item, link, clone;
3799

    
3800
            this.responsivetab.lst.empty();
3801

    
3802
            children.each(function(){
3803

    
3804
                if (UI.$(this).offset().top > top) {
3805
                    doresponsive = true;
3806
                }
3807
            });
3808

    
3809
            if (doresponsive) {
3810

    
3811
                for (var i = 0; i < children.length; i++) {
3812

    
3813
                    item  = UI.$(children.eq(i));
3814
                    link  = item.find('a');
3815

    
3816
                    if (item.css('float') != 'none' && !item.attr('uk-dropdown')) {
3817

    
3818
                        if (!item.hasClass('uk-disabled')) {
3819

    
3820
                            clone = UI.$(item[0].outerHTML);
3821
                            clone.find('a').data('index', i);
3822

    
3823
                            this.responsivetab.lst.append(clone);
3824
                        }
3825

    
3826
                        item.addClass('uk-hidden');
3827
                    }
3828
                }
3829
            }
3830

    
3831
            this.responsivetab[this.responsivetab.lst.children('li').length ? 'removeClass':'addClass']('uk-hidden');
3832
        }
3833
    });
3834

    
3835
})(UIkit2);
3836

    
3837
(function(UI){
3838

    
3839
    "use strict";
3840

    
3841
    UI.component('cover', {
3842

    
3843
        defaults: {
3844
            automute : true
3845
        },
3846

    
3847
        boot: function() {
3848

    
3849
            // auto init
3850
            UI.ready(function(context) {
3851

    
3852
                UI.$('[data-uk-cover]', context).each(function(){
3853

    
3854
                    var ele = UI.$(this);
3855

    
3856
                    if(!ele.data('cover')) {
3857
                        var plugin = UI.cover(ele, UI.Utils.options(ele.attr('data-uk-cover')));
3858
                    }
3859
                });
3860
            });
3861
        },
3862

    
3863
        init: function() {
3864

    
3865
            this.parent = this.element.parent();
3866

    
3867
            UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
3868
                this.check();
3869
            }.bind(this), 100));
3870

    
3871
            this.on('display.uk.check', function(e) {
3872
                if (this.element.is(':visible')) this.check();
3873
            }.bind(this));
3874

    
3875
            this.check();
3876

    
3877
            if (this.element.is('iframe') && this.options.automute) {
3878

    
3879
                var src = this.element.attr('src');
3880

    
3881
                this.element.attr('src', '').on('load', function(){
3882
                    this.contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}', '*');
3883
                }).attr('src', [src, (src.indexOf('?') > -1 ? '&':'?'), 'enablejsapi=1&api=1'].join(''));
3884
            }
3885
        },
3886

    
3887
        check: function() {
3888

    
3889
            this.element.css({ width  : '', height : '' });
3890

    
3891
            this.dimension = {w: this.element.width(), h: this.element.height()};
3892

    
3893
            if (this.element.attr('width') && !isNaN(this.element.attr('width'))) {
3894
                this.dimension.w = this.element.attr('width');
3895
            }
3896

    
3897
            if (this.element.attr('height') && !isNaN(this.element.attr('height'))) {
3898
                this.dimension.h = this.element.attr('height');
3899
            }
3900

    
3901
            this.ratio = this.dimension.w / this.dimension.h;
3902

    
3903
            var w = this.parent.width(), h = this.parent.height(), width, height;
3904

    
3905
            // if element height < parent height (gap underneath)
3906
            if ((w / this.ratio) < h) {
3907

    
3908
                width  = Math.ceil(h * this.ratio);
3909
                height = h;
3910

    
3911
            // element width < parent width (gap to right)
3912
            } else {
3913

    
3914
                width  = w;
3915
                height = Math.ceil(w / this.ratio);
3916
            }
3917

    
3918
            this.element.css({ width  : width, height : height });
3919
        }
3920
    });
3921

    
3922
})(UIkit2);
(1-1/2)