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);
3923

    
3924
/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
3925
(function(addon) {
3926
    var component;
3927

    
3928
    if (window.UIkit2) {
3929
        component = addon(UIkit2);
3930
    }
3931

    
3932
    if (typeof define == 'function' && define.amd) {
3933
        define('uikit-accordion', ['uikit'], function(){
3934
            return component || addon(UIkit2);
3935
        });
3936
    }
3937
})(function(UI){
3938

    
3939
    "use strict";
3940

    
3941
    UI.component('accordion', {
3942

    
3943
        defaults: {
3944
            showfirst  : true,
3945
            collapse   : true,
3946
            animate    : true,
3947
            easing     : 'swing',
3948
            duration   : 300,
3949
            toggle     : '.uk-accordion-title',
3950
            containers : '.uk-accordion-content',
3951
            clsactive  : 'uk-active'
3952
        },
3953

    
3954
        boot:  function() {
3955

    
3956
            // init code
3957
            UI.ready(function(context) {
3958

    
3959
                setTimeout(function(){
3960

    
3961
                    UI.$('[data-uk-accordion]', context).each(function(){
3962

    
3963
                        var ele = UI.$(this);
3964

    
3965
                        if (!ele.data('accordion')) {
3966
                            UI.accordion(ele, UI.Utils.options(ele.attr('data-uk-accordion')));
3967
                        }
3968
                    });
3969

    
3970
                }, 0);
3971
            });
3972
        },
3973

    
3974
        init: function() {
3975

    
3976
            var $this = this;
3977

    
3978
            this.element.on('click.uk.accordion', this.options.toggle, function(e) {
3979

    
3980
                e.preventDefault();
3981

    
3982
                $this.toggleItem(UI.$(this).data('wrapper'), $this.options.animate, $this.options.collapse);
3983
            });
3984

    
3985
            this.update(true);
3986

    
3987
            UI.domObserve(this.element, function(e) {
3988
                if ($this.element.children($this.options.containers).length) {
3989
                    $this.update();
3990
                }
3991
            });
3992
        },
3993

    
3994
        toggleItem: function(wrapper, animated, collapse) {
3995

    
3996
            var $this = this;
3997

    
3998
            wrapper.data('toggle').toggleClass(this.options.clsactive);
3999
            wrapper.data('content').toggleClass(this.options.clsactive);
4000

    
4001
            var active = wrapper.data('toggle').hasClass(this.options.clsactive);
4002

    
4003
            if (collapse) {
4004
                this.toggle.not(wrapper.data('toggle')).removeClass(this.options.clsactive);
4005
                this.content.not(wrapper.data('content')).removeClass(this.options.clsactive)
4006
                    .parent().stop().css('overflow', 'hidden').animate({ height: 0 }, {easing: this.options.easing, duration: animated ? this.options.duration : 0}).attr('aria-expanded', 'false');
4007
            }
4008

    
4009
            wrapper.stop().css('overflow', 'hidden');
4010

    
4011
            if (animated) {
4012

    
4013
                wrapper.animate({ height: active ? getHeight(wrapper.data('content')) : 0 }, {easing: this.options.easing, duration: this.options.duration, complete: function() {
4014

    
4015
                    if (active) {
4016
                        wrapper.css({'overflow': '', 'height': 'auto'});
4017
                        UI.Utils.checkDisplay(wrapper.data('content'));
4018
                    }
4019

    
4020
                    $this.trigger('display.uk.check');
4021
                }});
4022

    
4023
            } else {
4024

    
4025
                wrapper.height(active ? 'auto' : 0);
4026

    
4027
                if (active) {
4028
                    wrapper.css({'overflow': ''});
4029
                    UI.Utils.checkDisplay(wrapper.data('content'));
4030
                }
4031

    
4032
                this.trigger('display.uk.check');
4033
            }
4034

    
4035
            // Update ARIA
4036
            wrapper.attr('aria-expanded', active);
4037

    
4038
            this.element.trigger('toggle.uk.accordion', [active, wrapper.data('toggle'), wrapper.data('content')]);
4039
        },
4040

    
4041
        update: function(init) {
4042

    
4043
            var $this = this, $content, $wrapper, $toggle;
4044

    
4045
            this.toggle = this.find(this.options.toggle);
4046
            this.content = this.find(this.options.containers);
4047

    
4048
            this.content.each(function(index) {
4049

    
4050
                $content = UI.$(this);
4051

    
4052
                if ($content.parent().data('wrapper')) {
4053
                    $wrapper = $content.parent();
4054
                } else {
4055
                    $wrapper = UI.$(this).wrap('<div data-wrapper="true" style="overflow:hidden;height:0;position:relative;"></div>').parent();
4056

    
4057
                    // Init ARIA
4058
                    $wrapper.attr('aria-expanded', 'false');
4059
                }
4060

    
4061
                $toggle = $this.toggle.eq(index);
4062

    
4063
                $wrapper.data('toggle', $toggle);
4064
                $wrapper.data('content', $content);
4065
                $toggle.data('wrapper', $wrapper);
4066
                $content.data('wrapper', $wrapper);
4067
            });
4068

    
4069
            this.element.trigger('update.uk.accordion', [this]);
4070

    
4071
            if (init && this.options.showfirst) {
4072
                this.toggleItem(this.toggle.eq(0).data('wrapper'), false, false);
4073
            }
4074
        }
4075

    
4076
    });
4077

    
4078
    // helper
4079

    
4080
    function getHeight(ele) {
4081

    
4082
        var $ele = UI.$(ele), height = "auto";
4083

    
4084
        if ($ele.is(":visible")) {
4085
            height = $ele.outerHeight();
4086
        } else {
4087

    
4088
            var tmp = {
4089
                position   : $ele.css('position'),
4090
                visibility : $ele.css('visibility'),
4091
                display    : $ele.css('display')
4092
            };
4093

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

    
4096
            $ele.css(tmp); // reset element
4097
        }
4098

    
4099
        return height;
4100
    }
4101

    
4102
    return UI.accordion;
4103
});
4104

    
4105
/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
4106
(function(addon) {
4107

    
4108
    var component;
4109

    
4110
    if (window.UIkit2) {
4111
        component = addon(UIkit2);
4112
    }
4113

    
4114
    if (typeof define == 'function' && define.amd) {
4115
        define('uikit-grid', ['uikit'], function(){
4116
            return component || addon(UIkit2);
4117
        });
4118
    }
4119

    
4120
})(function(UI){
4121

    
4122
    "use strict";
4123

    
4124
    UI.component('grid', {
4125

    
4126
        defaults: {
4127
            colwidth  : 'auto',
4128
            animation : true,
4129
            duration  : 300,
4130
            gutter    : 0,
4131
            controls  : false,
4132
            filter    : false,
4133
            origin    : UI.langdirection
4134
        },
4135

    
4136
        boot:  function() {
4137

    
4138
            // init code
4139
            UI.ready(function(context) {
4140

    
4141
                UI.$('[data-uk-grid]', context).each(function(){
4142

    
4143
                    var ele = UI.$(this);
4144

    
4145
                    if(!ele.data('grid')) {
4146
                        UI.grid(ele, UI.Utils.options(ele.attr('data-uk-grid')));
4147
                    }
4148
                });
4149
            });
4150
        },
4151

    
4152
        init: function() {
4153

    
4154
            var $this = this, gutter = String(this.options.gutter).trim().split(' ');
4155

    
4156
            this.gutterv  = parseInt(gutter[0], 10);
4157
            this.gutterh  = parseInt((gutter[1] || gutter[0]), 10);
4158

    
4159
            // make sure parent element has the right position property
4160
            this.element.css({'position': 'relative'});
4161

    
4162
            this.controls = null;
4163
            this.origin   = this.options.origin;
4164

    
4165
            if (this.options.controls) {
4166

    
4167
                this.controls = UI.$(this.options.controls);
4168

    
4169
                // filter
4170
                this.controls.on('click', '[data-uk-filter]', function(e){
4171
                    e.preventDefault();
4172
                    $this.filter(UI.$(this).attr('data-uk-filter'));
4173
                });
4174

    
4175
                // sort
4176
                this.controls.on('click', '[data-uk-sort]', function(e){
4177
                    e.preventDefault();
4178
                    var cmd = UI.$(this).attr('data-uk-sort').split(':');
4179
                    $this.sort(cmd[0], cmd[1]);
4180
                });
4181
            }
4182

    
4183
            UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
4184

    
4185
                if ($this.currentfilter) {
4186
                    $this.filter($this.currentfilter);
4187
                } else {
4188
                    this.update();
4189
                }
4190

    
4191
            }.bind(this), 100));
4192

    
4193
            this.on('display.uk.check', function(){
4194
                if ($this.element.is(':visible'))  $this.update();
4195
            });
4196

    
4197
            UI.domObserve(this.element, function(e) {
4198
                $this.update();
4199
            });
4200

    
4201
            if (this.options.filter !== false) {
4202
                this.filter(this.options.filter);
4203
            } else {
4204
                this.update();
4205
            }
4206
        },
4207

    
4208
        _prepareElements: function() {
4209

    
4210
            var children = this.element.children().not('[data-grid-prepared]'), css;
4211

    
4212
            // exit if no already prepared elements found
4213
            if (!children.length) {
4214
                return;
4215
            }
4216

    
4217
            css = {
4218
                position  : 'absolute',
4219
                boxSizing : 'border-box',
4220
                width     : this.options.colwidth == 'auto' ? '' : this.options.colwidth
4221
            };
4222

    
4223
            if (this.options.gutter) {
4224

    
4225
                css['padding-'+this.origin] = this.gutterh;
4226
                css['padding-bottom'] = this.gutterv;
4227

    
4228
                this.element.css('margin-'+this.origin, this.gutterh * -1);
4229
            }
4230

    
4231
            children.attr('data-grid-prepared', 'true').css(css);
4232
        },
4233

    
4234
        update: function(elements) {
4235

    
4236
            var $this = this;
4237

    
4238
            this._prepareElements();
4239

    
4240
            elements = elements || this.element.children(':visible');
4241

    
4242
            var children  = elements,
4243
                maxwidth  = this.element.width() + (2*this.gutterh) + 2,
4244
                left      = 0,
4245
                top       = 0,
4246
                positions = [],
4247

    
4248
                item, width, height, pos, posi, i, z, max, size;
4249

    
4250
            this.trigger('beforeupdate.uk.grid', [children]);
4251

    
4252
            children.each(function(index){
4253

    
4254
                item   = UI.$(this);
4255
                size   = this.getBoundingClientRect();
4256
                width  = size.width;
4257
                height = size.height;
4258
                left   = 0;
4259
                top    = 0;
4260

    
4261
                for (i=0,max=positions.length;i<max;i++) {
4262

    
4263
                    pos = positions[i];
4264

    
4265
                    if (left <= pos.aX) { left = pos.aX; }
4266
                    if (maxwidth < (left + width)) { left = 0; }
4267
                    if (top <= pos.aY) { top = pos.aY; }
4268
                }
4269

    
4270
                posi = {
4271
                    ele    : item,
4272
                    top    : top,
4273
                    width  : width,
4274
                    height : height,
4275
                    aY     : (top  + height),
4276
                    aX     : (left + width)
4277
                };
4278

    
4279
                posi[$this.origin] = left;
4280

    
4281
                positions.push(posi);
4282
            });
4283

    
4284
            var posPrev, maxHeight = 0, positionto;
4285

    
4286
            // fix top
4287
            for (i=0,max=positions.length;i<max;i++) {
4288

    
4289
                pos = positions[i];
4290
                top = 0;
4291

    
4292
                for (z=0;z<i;z++) {
4293

    
4294
                    posPrev = positions[z];
4295

    
4296
                    // (posPrev.left + 1) fixex 1px bug when using % based widths
4297
                    if (pos[this.origin] < posPrev.aX && (posPrev[this.origin] +1) < pos.aX) {
4298
                        top = posPrev.aY;
4299
                    }
4300
                }
4301

    
4302
                pos.top = top;
4303
                pos.aY  = top + pos.height;
4304

    
4305
                maxHeight = Math.max(maxHeight, pos.aY);
4306
            }
4307

    
4308
            maxHeight = maxHeight - this.gutterv;
4309

    
4310
            if (this.options.animation) {
4311

    
4312
                this.element.stop().animate({'height': maxHeight}, 100);
4313

    
4314
                positions.forEach(function(pos){
4315

    
4316
                    positionto = {"top": pos.top, opacity: 1};
4317
                    positionto[$this.origin] = pos[$this.origin];
4318

    
4319
                    pos.ele.stop().animate(positionto, this.options.duration);
4320
                }.bind(this));
4321

    
4322
            } else {
4323

    
4324
                this.element.css('height', maxHeight);
4325

    
4326
                positions.forEach(function(pos){
4327
                    positionto = {"top": pos.top, opacity: 1};
4328
                    positionto[$this.origin] = pos[$this.origin];
4329
                    pos.ele.css(positionto);
4330
                }.bind(this));
4331
            }
4332

    
4333
            // make sure to trigger possible scrollpies etc.
4334
            setTimeout(function() {
4335
                UI.$doc.trigger('scrolling.uk.document');
4336
            }, 2 * this.options.duration * (this.options.animation ? 1:0));
4337

    
4338
            this.trigger('afterupdate.uk.grid', [children]);
4339
        },
4340

    
4341
        filter: function(filter) {
4342

    
4343
            this.currentfilter = filter;
4344

    
4345
            filter = filter || [];
4346

    
4347
            if (typeof(filter) === 'number') {
4348
                filter = filter.toString();
4349
            }
4350

    
4351
            if (typeof(filter) === 'string') {
4352
                filter = filter.split(/,/).map(function(item){ return item.trim(); });
4353
            }
4354

    
4355
            var $this = this, children = this.element.children(), elements = {"visible": [], "hidden": []}, visible, hidden;
4356

    
4357
            children.each(function(index){
4358

    
4359
                var ele = UI.$(this), f = ele.attr('data-uk-filter'), infilter = filter.length ? false : true;
4360

    
4361
                if (f) {
4362

    
4363
                    f = f.split(/,/).map(function(item){ return item.trim(); });
4364

    
4365
                    filter.forEach(function(item){
4366
                        if (f.indexOf(item) > -1) infilter = true;
4367
                    });
4368
                }
4369

    
4370
                elements[infilter ? "visible":"hidden"].push(ele);
4371
            });
4372

    
4373
            // convert to jQuery collections
4374
            elements.hidden  = UI.$(elements.hidden).map(function () {return this[0];});
4375
            elements.visible = UI.$(elements.visible).map(function () {return this[0];});
4376

    
4377
            elements.hidden.attr('aria-hidden', 'true').filter(':visible').fadeOut(this.options.duration);
4378
            elements.visible.attr('aria-hidden', 'false').filter(':hidden').css('opacity', 0).show();
4379

    
4380
            $this.update(elements.visible);
4381

    
4382
            if (this.controls && this.controls.length) {
4383
                this.controls.find('[data-uk-filter]').removeClass('uk-active').filter('[data-uk-filter="'+filter+'"]').addClass('uk-active');
4384
            }
4385
        },
4386

    
4387
        sort: function(by, order){
4388

    
4389
            order = order || 1;
4390

    
4391
            // covert from string (asc|desc) to number
4392
            if (typeof(order) === 'string') {
4393
                order = order.toLowerCase() == 'desc' ? -1 : 1;
4394
            }
4395

    
4396
            var elements = this.element.children();
4397

    
4398
            elements.sort(function(a, b){
4399

    
4400
                a = UI.$(a);
4401
                b = UI.$(b);
4402

    
4403
                return (b.data(by) || '') < (a.data(by) || '') ? order : (order*-1);
4404

    
4405
            }).appendTo(this.element);
4406

    
4407
            this.update(elements.filter(':visible'));
4408

    
4409
            if (this.controls && this.controls.length) {
4410
                this.controls.find('[data-uk-sort]').removeClass('uk-active').filter('[data-uk-sort="'+by+':'+(order == -1 ? 'desc':'asc')+'"]').addClass('uk-active');
4411
            }
4412
        }
4413
    });
4414

    
4415
});
4416

    
4417
/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
4418
(function(addon) {
4419

    
4420
    var component;
4421

    
4422
    if (window.UIkit2) {
4423
        component = addon(UIkit2);
4424
    }
4425

    
4426
    if (typeof define == 'function' && define.amd) { // AMD
4427
        define('uikit-lightbox', ['uikit'], function(){
4428
            return component || addon(UIkit2);
4429
        });
4430
    }
4431

    
4432
})(function(UI){
4433

    
4434
    "use strict";
4435

    
4436
    var modal, cache = {};
4437

    
4438
    UI.component('lightbox', {
4439

    
4440
        defaults: {
4441
            allowfullscreen : true,
4442
            duration        : 400,
4443
            group           : false,
4444
            keyboard        : true
4445
        },
4446

    
4447
        index : 0,
4448
        items : false,
4449

    
4450
        boot: function() {
4451

    
4452
            UI.$html.on('click', '[data-uk-lightbox]', function(e){
4453

    
4454
                e.preventDefault();
4455

    
4456
                var link = UI.$(this);
4457

    
4458
                if (!link.data('lightbox')) {
4459

    
4460
                    UI.lightbox(link, UI.Utils.options(link.attr('data-uk-lightbox')));
4461
                }
4462

    
4463
                link.data('lightbox').show(link);
4464
            });
4465

    
4466
            // keyboard navigation
4467
            UI.$doc.on('keyup', function(e) {
4468

    
4469
                if (modal && modal.is(':visible') && modal.lightbox.options.keyboard) {
4470

    
4471
                    e.preventDefault();
4472

    
4473
                    switch(e.keyCode) {
4474
                        case 37:
4475
                            modal.lightbox.previous();
4476
                            break;
4477
                        case 39:
4478
                            modal.lightbox.next();
4479
                            break;
4480
                    }
4481
                }
4482
            });
4483
        },
4484

    
4485
        init: function() {
4486

    
4487
            var siblings = [];
4488

    
4489
            this.index    = 0;
4490
            this.siblings = [];
4491

    
4492
            if (this.element && this.element.length) {
4493

    
4494
                var domSiblings  = this.options.group ? UI.$('[data-uk-lightbox*="'+this.options.group+'"]') : this.element;
4495

    
4496
                domSiblings.each(function() {
4497

    
4498
                    var ele = UI.$(this);
4499

    
4500
                    siblings.push({
4501
                        source : ele.attr('href'),
4502
                        title  : ele.attr('data-title') || ele.attr('title'),
4503
                        type   : ele.attr("data-lightbox-type") || 'auto',
4504
                        link   : ele
4505
                    });
4506
                });
4507

    
4508
                this.index    = domSiblings.index(this.element);
4509
                this.siblings = siblings;
4510

    
4511
            } else if (this.options.group && this.options.group.length) {
4512
                this.siblings = this.options.group;
4513
            }
4514

    
4515
            this.trigger('lightbox-init', [this]);
4516
        },
4517

    
4518
        show: function(index) {
4519

    
4520
            this.modal = getModal(this);
4521

    
4522
            // stop previous animation
4523
            this.modal.dialog.stop();
4524
            this.modal.content.stop();
4525

    
4526
            var $this = this, promise = UI.$.Deferred(), data, item;
4527

    
4528
            index = index || 0;
4529

    
4530
            // index is a jQuery object or DOM element
4531
            if (typeof(index) == 'object') {
4532

    
4533
                this.siblings.forEach(function(s, idx){
4534

    
4535
                    if (index[0] === s.link[0]) {
4536
                        index = idx;
4537
                    }
4538
                });
4539
            }
4540

    
4541
            // fix index if needed
4542
            if ( index < 0 ) {
4543
                index = this.siblings.length - index;
4544
            } else if (!this.siblings[index]) {
4545
                index = 0;
4546
            }
4547

    
4548
            item   = this.siblings[index];
4549

    
4550
            data = {
4551
                lightbox : $this,
4552
                source   : item.source,
4553
                type     : item.type,
4554
                index    : index,
4555
                promise  : promise,
4556
                title    : item.title,
4557
                item     : item,
4558
                meta     : {
4559
                    content : '',
4560
                    width   : null,
4561
                    height  : null
4562
                }
4563
            };
4564

    
4565
            this.index = index;
4566

    
4567
            this.modal.content.empty();
4568

    
4569
            if (!this.modal.is(':visible')) {
4570
                this.modal.content.css({width:'', height:''}).empty();
4571
                this.modal.modal.show();
4572
            }
4573

    
4574
            this.modal.loader.removeClass('uk-hidden');
4575

    
4576
            promise.promise().done(function() {
4577

    
4578
                $this.data = data;
4579
                $this.fitSize(data);
4580

    
4581
            }).fail(function(){
4582

    
4583
                data.meta.content = '<div class="uk-position-cover uk-flex uk-flex-middle uk-flex-center"><strong>Loading resource failed!</strong></div>';
4584
                data.meta.width   = 400;
4585
                data.meta.height  = 300;
4586

    
4587
                $this.data = data;
4588
                $this.fitSize(data);
4589
            });
4590

    
4591
            $this.trigger('showitem.uk.lightbox', [data]);
4592
        },
4593

    
4594
        fitSize: function() {
4595

    
4596
            var $this    = this,
4597
                data     = this.data,
4598
                pad      = this.modal.dialog.outerWidth() - this.modal.dialog.width(),
4599
                dpadTop  = parseInt(this.modal.dialog.css('margin-top'), 10),
4600
                dpadBot  = parseInt(this.modal.dialog.css('margin-bottom'), 10),
4601
                dpad     = dpadTop + dpadBot,
4602
                content  = data.meta.content,
4603
                duration = $this.options.duration;
4604

    
4605
            if (this.siblings.length > 1) {
4606

    
4607
                content = [
4608
                    content,
4609
                    '<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-previous uk-hidden-touch" data-lightbox-previous></a>',
4610
                    '<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-next uk-hidden-touch" data-lightbox-next></a>'
4611
                ].join('');
4612
            }
4613

    
4614
            // calculate width
4615
            var tmp = UI.$('<div>&nbsp;</div>').css({
4616
                opacity   : 0,
4617
                position  : 'absolute',
4618
                top       : 0,
4619
                left      : 0,
4620
                width     : '100%',
4621
                maxWidth  : $this.modal.dialog.css('max-width'),
4622
                padding   : $this.modal.dialog.css('padding'),
4623
                margin    : $this.modal.dialog.css('margin')
4624
            }), maxwidth, maxheight, w = data.meta.width, h = data.meta.height;
4625

    
4626
            tmp.appendTo('body').width();
4627

    
4628
            maxwidth  = tmp.width();
4629
            maxheight = window.innerHeight - dpad;
4630

    
4631
            tmp.remove();
4632

    
4633
            this.modal.dialog.find('.uk-modal-caption').remove();
4634

    
4635
            if (data.title) {
4636
                this.modal.dialog.append('<div class="uk-modal-caption">'+data.title+'</div>');
4637
                maxheight -= this.modal.dialog.find('.uk-modal-caption').outerHeight();
4638
            }
4639

    
4640
            if (maxwidth < data.meta.width) {
4641

    
4642
                h = Math.floor( h * (maxwidth / w) );
4643
                w = maxwidth;
4644
            }
4645

    
4646
            if (maxheight < h) {
4647

    
4648
                h = Math.floor(maxheight);
4649
                w = Math.ceil(data.meta.width * (maxheight/data.meta.height));
4650
            }
4651

    
4652
            this.modal.content.css('opacity', 0).width(w).html(content);
4653

    
4654
            if (data.type == 'iframe') {
4655
                this.modal.content.find('iframe:first').height(h);
4656
            }
4657

    
4658
            var dh   = h + pad,
4659
                t    = Math.floor(window.innerHeight/2 - dh/2) - dpad;
4660

    
4661
            if (t < 0) { t = 0; }
4662

    
4663
            this.modal.closer.addClass('uk-hidden');
4664

    
4665
            if ($this.modal.data('mwidth') == w &&  $this.modal.data('mheight') == h) {
4666
                duration = 0;
4667
            }
4668

    
4669
            this.modal.dialog.animate({width: w + pad, height: h + pad, top: t }, duration, 'swing', function() {
4670
                $this.modal.loader.addClass('uk-hidden');
4671
                $this.modal.content.css({width:''}).animate({opacity: 1}, function() {
4672
                    $this.modal.closer.removeClass('uk-hidden');
4673
                });
4674

    
4675
                $this.modal.data({mwidth: w, mheight: h});
4676
            });
4677
        },
4678

    
4679
        next: function() {
4680
            this.show(this.siblings[(this.index+1)] ? (this.index+1) : 0);
4681
        },
4682

    
4683
        previous: function() {
4684
            this.show(this.siblings[(this.index-1)] ? (this.index-1) : this.siblings.length-1);
4685
        }
4686
    });
4687

    
4688

    
4689
    // Plugins
4690

    
4691
    UI.plugin('lightbox', 'image', {
4692

    
4693
        init: function(lightbox) {
4694

    
4695
            lightbox.on('showitem.uk.lightbox', function(e, data){
4696

    
4697
                if (data.type == 'image' || data.source && data.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)) {
4698

    
4699
                    var resolve = function(source, width, height) {
4700

    
4701
                        data.meta = {
4702
                            content : '<img class="uk-responsive-width" width="'+width+'" height="'+height+'" src ="'+source+'">',
4703
                            width   : width,
4704
                            height  : height
4705
                        };
4706

    
4707
                        data.type = 'image';
4708

    
4709
                        data.promise.resolve();
4710
                    };
4711

    
4712
                    if (!cache[data.source]) {
4713

    
4714
                        var img = new Image();
4715

    
4716
                        img.onerror = function(){
4717
                            data.promise.reject('Loading image failed');
4718
                        };
4719

    
4720
                        img.onload = function(){
4721
                            cache[data.source] = {width: img.width, height: img.height};
4722
                            resolve(data.source, cache[data.source].width, cache[data.source].height);
4723
                        };
4724

    
4725
                        img.src = data.source;
4726

    
4727
                    } else {
4728
                        resolve(data.source, cache[data.source].width, cache[data.source].height);
4729
                    }
4730
                }
4731
            });
4732
        }
4733
    });
4734

    
4735
    UI.plugin('lightbox', 'youtube', {
4736

    
4737
        init: function(lightbox) {
4738

    
4739
            var youtubeRegExp = /(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,
4740
                youtubeRegExpShort = /youtu\.be\/(.*)/;
4741

    
4742

    
4743
            lightbox.on('showitem.uk.lightbox', function(e, data){
4744

    
4745
                var id, matches, resolve = function(id, width, height) {
4746

    
4747
                    data.meta = {
4748
                        content: '<iframe src="//www.youtube.com/embed/'+id+'" width="'+width+'" height="'+height+'" style="max-width:100%;"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
4749
                        width: width,
4750
                        height: height
4751
                    };
4752

    
4753
                    data.type = 'iframe';
4754

    
4755
                    data.promise.resolve();
4756
                };
4757

    
4758
                if (matches = data.source.match(youtubeRegExp)) {
4759
                    id = matches[2];
4760
                }
4761

    
4762
                if (matches = data.source.match(youtubeRegExpShort)) {
4763
                    id = matches[1];
4764
                }
4765

    
4766
                if (id) {
4767

    
4768
                    if(!cache[id]) {
4769

    
4770
                        var img = new Image(), lowres = false;
4771

    
4772
                        img.onerror = function(){
4773
                            cache[id] = {width:640, height:320};
4774
                            resolve(id, cache[id].width, cache[id].height);
4775
                        };
4776

    
4777
                        img.onload = function(){
4778
                            //youtube default 404 thumb, fall back to lowres
4779
                            if (img.width == 120 && img.height == 90) {
4780
                                if (!lowres) {
4781
                                    lowres = true;
4782
                                    img.src = '//img.youtube.com/vi/' + id + '/0.jpg';
4783
                                } else {
4784
                                    cache[id] = {width: 640, height: 320};
4785
                                    resolve(id, cache[id].width, cache[id].height);
4786
                                }
4787
                            } else {
4788
                                cache[id] = {width: img.width, height: img.height};
4789
                                resolve(id, img.width, img.height);
4790
                            }
4791
                        };
4792

    
4793
                        img.src = '//img.youtube.com/vi/'+id+'/maxresdefault.jpg';
4794

    
4795
                    } else {
4796
                        resolve(id, cache[id].width, cache[id].height);
4797
                    }
4798

    
4799
                    e.stopImmediatePropagation();
4800
                }
4801
            });
4802
        }
4803
    });
4804

    
4805

    
4806
    UI.plugin('lightbox', 'vimeo', {
4807

    
4808
        init: function(lightbox) {
4809

    
4810
            var regex = /(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/, matches;
4811

    
4812

    
4813
            lightbox.on('showitem.uk.lightbox', function(e, data){
4814

    
4815
                var id, resolve = function(id, width, height) {
4816

    
4817
                    data.meta = {
4818
                        content: '<iframe src="//player.vimeo.com/video/'+id+'" width="'+width+'" height="'+height+'" style="width:100%;box-sizing:border-box;"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
4819
                        width: width,
4820
                        height: height
4821
                    };
4822

    
4823
                    data.type = 'iframe';
4824

    
4825
                    data.promise.resolve();
4826
                };
4827

    
4828
                if (matches = data.source.match(regex)) {
4829

    
4830
                    id = matches[2];
4831

    
4832
                    if(!cache[id]) {
4833

    
4834
                        UI.$.ajax({
4835
                            type     : 'GET',
4836
                            url      : '//vimeo.com/api/oembed.json?url=' + encodeURI(data.source),
4837
                            jsonp    : 'callback',
4838
                            dataType : 'jsonp',
4839
                            success  : function(data) {
4840
                                cache[id] = {width:data.width, height:data.height};
4841
                                resolve(id, cache[id].width, cache[id].height);
4842
                            }
4843
                        });
4844

    
4845
                    } else {
4846
                        resolve(id, cache[id].width, cache[id].height);
4847
                    }
4848

    
4849
                    e.stopImmediatePropagation();
4850
                }
4851
            });
4852
        }
4853
    });
4854

    
4855
    UI.plugin('lightbox', 'video', {
4856

    
4857
        init: function(lightbox) {
4858

    
4859
            lightbox.on('showitem.uk.lightbox', function(e, data){
4860

    
4861

    
4862
                var resolve = function(source, width, height) {
4863

    
4864
                    data.meta = {
4865
                        content: '<video class="uk-responsive-width" src="'+source+'" width="'+width+'" height="'+height+'" controls></video>',
4866
                        width: width,
4867
                        height: height
4868
                    };
4869

    
4870
                    data.type = 'video';
4871

    
4872
                    data.promise.resolve();
4873
                };
4874

    
4875
                if (data.type == 'video' || data.source.match(/\.(mp4|webm|ogv)$/i)) {
4876

    
4877
                    if (!cache[data.source]) {
4878

    
4879
                        var vid = UI.$('<video style="position:fixed;visibility:hidden;top:-10000px;"></video>').attr('src', data.source).appendTo('body');
4880

    
4881
                        var idle = setInterval(function() {
4882

    
4883
                            if (vid[0].videoWidth) {
4884
                                clearInterval(idle);
4885
                                cache[data.source] = {width: vid[0].videoWidth, height: vid[0].videoHeight};
4886
                                resolve(data.source, cache[data.source].width, cache[data.source].height);
4887
                                vid.remove();
4888
                            }
4889

    
4890
                        }, 20);
4891

    
4892
                    } else {
4893
                        resolve(data.source, cache[data.source].width, cache[data.source].height);
4894
                    }
4895
                }
4896
            });
4897
        }
4898
    });
4899

    
4900

    
4901
    UI.plugin('lightbox', 'iframe', {
4902

    
4903
        init: function (lightbox) {
4904

    
4905
            lightbox.on('showitem.uk.lightbox', function (e, data) {
4906

    
4907
                var resolve = function (source, width, height) {
4908

    
4909
                    data.meta = {
4910
                        content: '<iframe class="uk-responsive-width" src="' + source + '" width="' + width + '" height="' + height + '"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
4911
                        width: width,
4912
                        height: height
4913
                    };
4914

    
4915
                    data.type = 'iframe';
4916

    
4917
                    data.promise.resolve();
4918
                };
4919

    
4920
                if (data.type === 'iframe' || data.source.match(/\.(html|php)$/)) {
4921
                    resolve(data.source, (lightbox.options.width || 800), (lightbox.options.height || 600));
4922
                }
4923
            });
4924

    
4925
        }
4926
    });
4927

    
4928
    function getModal(lightbox) {
4929

    
4930
        if (modal) {
4931
            modal.lightbox = lightbox;
4932
            return modal;
4933
        }
4934

    
4935
        // init lightbox container
4936
        modal = UI.$([
4937
            '<div class="uk-modal">',
4938
                '<div class="uk-modal-dialog uk-modal-dialog-lightbox uk-slidenav-position" style="margin-left:auto;margin-right:auto;width:200px;height:200px;top:'+Math.abs(window.innerHeight/2 - 200)+'px;">',
4939
                    '<a href="#" class="uk-modal-close uk-close uk-close-alt"></a>',
4940
                    '<div class="uk-lightbox-content"></div>',
4941
                    '<div class="uk-modal-spinner uk-hidden"></div>',
4942
                '</div>',
4943
            '</div>'
4944
        ].join('')).appendTo('body');
4945

    
4946
        modal.dialog  = modal.find('.uk-modal-dialog:first');
4947
        modal.content = modal.find('.uk-lightbox-content:first');
4948
        modal.loader  = modal.find('.uk-modal-spinner:first');
4949
        modal.closer  = modal.find('.uk-close.uk-close-alt');
4950
        modal.modal   = UI.modal(modal, {modal:false});
4951

    
4952
        // next / previous
4953
        modal.on('swipeRight swipeLeft', function(e) {
4954
            modal.lightbox[e.type=='swipeLeft' ? 'next':'previous']();
4955
        }).on('click', '[data-lightbox-previous], [data-lightbox-next]', function(e){
4956
            e.preventDefault();
4957
            modal.lightbox[UI.$(this).is('[data-lightbox-next]') ? 'next':'previous']();
4958
        });
4959

    
4960
        // destroy content on modal hide
4961
        modal.on('hide.uk.modal', function(e) {
4962
            modal.content.html('');
4963
        });
4964

    
4965
        var resizeCache = {w: window.innerWidth, h:window.innerHeight};
4966

    
4967
        UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(e){
4968

    
4969
            if (resizeCache.w !== window.innerWidth && modal.is(':visible') && !UI.Utils.isFullscreen()) {
4970
                modal.lightbox.fitSize();
4971
            }
4972

    
4973
            resizeCache = {w: window.innerWidth, h:window.innerHeight};
4974

    
4975
        }, 100));
4976

    
4977
        modal.lightbox = lightbox;
4978

    
4979
        return modal;
4980
    }
4981

    
4982
    UI.lightbox.create = function(items, options) {
4983

    
4984
        if (!items) return;
4985

    
4986
        var group = [], o;
4987

    
4988
        items.forEach(function(item) {
4989

    
4990
            group.push(UI.$.extend({
4991
                source : '',
4992
                title  : '',
4993
                type   : 'auto',
4994
                link   : false
4995
            }, (typeof(item) == 'string' ? {'source': item} : item)));
4996
        });
4997

    
4998
        o = UI.lightbox(UI.$.extend({}, options, {'group':group}));
4999

    
5000
        return o;
5001
    };
5002

    
5003
    return UI.lightbox;
5004
});
5005

    
5006
/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
5007
(function(addon) {
5008

    
5009
    var component;
5010

    
5011
    if (window.UIkit2) {
5012
        component = addon(UIkit2);
5013
    }
5014

    
5015
    if (typeof define == 'function' && define.amd) {
5016
        define('uikit-parallax', ['uikit'], function(){
5017
            return component || addon(UIkit2);
5018
        });
5019
    }
5020

    
5021
})(function(UI){
5022

    
5023
    "use strict";
5024

    
5025
    var parallaxes      = [],
5026
        supports3d      = false,
5027
        scrolltop       = 0,
5028
        wh              = window.innerHeight,
5029
        checkParallaxes = function() {
5030

    
5031
            scrolltop = UI.$win.scrollTop();
5032

    
5033
            window.requestAnimationFrame(function(){
5034
                for (var i=0; i < parallaxes.length; i++) {
5035
                    parallaxes[i].process();
5036
                }
5037
            });
5038
        };
5039

    
5040

    
5041
    UI.component('parallax', {
5042

    
5043
        defaults: {
5044
            velocity : 0.5,
5045
            target   : false,
5046
            viewport : false,
5047
            media    : false
5048
        },
5049

    
5050
        boot: function() {
5051

    
5052
            supports3d = (function(){
5053

    
5054
                var el = document.createElement('div'),
5055
                    has3d,
5056
                    transforms = {
5057
                        'WebkitTransform':'-webkit-transform',
5058
                        'MSTransform':'-ms-transform',
5059
                        'MozTransform':'-moz-transform',
5060
                        'Transform':'transform'
5061
                    };
5062

    
5063
                // Add it to the body to get the computed style.
5064
                document.body.insertBefore(el, null);
5065

    
5066
                for (var t in transforms) {
5067
                    if (el.style[t] !== undefined) {
5068
                        el.style[t] = 'translate3d(1px,1px,1px)';
5069
                        has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
5070
                    }
5071
                }
5072

    
5073
                document.body.removeChild(el);
5074

    
5075
                return (has3d !== undefined && has3d.length > 0 && has3d !== "none");
5076
            })();
5077

    
5078
            // listen to scroll and resize
5079
            UI.$doc.on('scrolling.uk.document', checkParallaxes);
5080
            UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
5081
                wh = window.innerHeight;
5082
                checkParallaxes();
5083
            }, 50));
5084

    
5085
            // init code
5086
            UI.ready(function(context) {
5087

    
5088
                UI.$('[data-uk-parallax]', context).each(function() {
5089

    
5090
                    var parallax = UI.$(this);
5091

    
5092
                    if (!parallax.data('parallax')) {
5093
                        UI.parallax(parallax, UI.Utils.options(parallax.attr('data-uk-parallax')));
5094
                    }
5095
                });
5096
            });
5097
        },
5098

    
5099
        init: function() {
5100

    
5101
            this.base     = this.options.target ? UI.$(this.options.target) : this.element;
5102
            this.props    = {};
5103
            this.velocity = (this.options.velocity || 1);
5104

    
5105
            var reserved  = ['target','velocity','viewport','plugins','media'];
5106

    
5107
            Object.keys(this.options).forEach(function(prop){
5108

    
5109
                if (reserved.indexOf(prop) !== -1) {
5110
                    return;
5111
                }
5112

    
5113
                var start, end, dir, diff, startend = String(this.options[prop]).split(',');
5114

    
5115
                if (prop.match(/color/i)) {
5116
                    start = startend[1] ? startend[0] : this._getStartValue(prop),
5117
                    end   = startend[1] ? startend[1] : startend[0];
5118

    
5119
                    if (!start) {
5120
                        start = 'rgba(255,255,255,0)';
5121
                    }
5122

    
5123
                } else {
5124
                    start = parseFloat(startend[1] ? startend[0] : this._getStartValue(prop)),
5125
                    end   = parseFloat(startend[1] ? startend[1] : startend[0]);
5126
                    diff  = (start < end ? (end-start):(start-end));
5127
                    dir   = (start < end ? 1:-1);
5128
                }
5129

    
5130
                this.props[prop] = { start: start, end: end, dir: dir, diff: diff };
5131

    
5132
            }.bind(this));
5133

    
5134
            parallaxes.push(this);
5135
        },
5136

    
5137
        process: function() {
5138

    
5139
            if (this.options.media) {
5140

    
5141
                switch(typeof(this.options.media)) {
5142
                    case 'number':
5143
                        if (window.innerWidth < this.options.media) {
5144
                            return false;
5145
                        }
5146
                        break;
5147
                    case 'string':
5148
                        if (window.matchMedia && !window.matchMedia(this.options.media).matches) {
5149
                            return false;
5150
                        }
5151
                        break;
5152
                }
5153
            }
5154

    
5155
            var percent = this.percentageInViewport();
5156

    
5157
            if (this.options.viewport !== false) {
5158
                percent = (this.options.viewport === 0) ? 1 : percent / this.options.viewport;
5159
            }
5160

    
5161
            this.update(percent);
5162
        },
5163

    
5164
        percentageInViewport: function() {
5165

    
5166
            var top     = this.base.offset().top,
5167
                height  = this.base.outerHeight(),
5168
                distance, percentage, percent;
5169

    
5170
            if (top > (scrolltop + wh)) {
5171
                percent = 0;
5172
            } else if ((top + height) < scrolltop) {
5173
                percent = 1;
5174
            } else {
5175

    
5176
                if ((top + height) < wh) {
5177

    
5178
                    percent = (scrolltop < wh ? scrolltop : scrolltop - wh) / (top+height);
5179

    
5180
                } else {
5181

    
5182
                    distance   = (scrolltop + wh) - top;
5183
                    percentage = Math.round(distance / ((wh + height) / 100));
5184
                    percent    = percentage/100;
5185
                }
5186
            }
5187

    
5188
            return percent;
5189
        },
5190

    
5191
        update: function(percent) {
5192

    
5193
            var $this      = this,
5194
                css        = {transform:'', filter:''},
5195
                compercent = percent * (1 - (this.velocity - (this.velocity * percent))),
5196
                opts, val;
5197

    
5198
            if (compercent < 0) compercent = 0;
5199
            if (compercent > 1) compercent = 1;
5200

    
5201
            if (this._percent !== undefined && this._percent == compercent) {
5202
                return;
5203
            }
5204

    
5205
            Object.keys(this.props).forEach(function(prop) {
5206

    
5207
                opts = this.props[prop];
5208

    
5209
                if (percent === 0) {
5210
                    val = opts.start;
5211
                } else if(percent === 1) {
5212
                    val = opts.end;
5213
                } else if(opts.diff !== undefined) {
5214
                    val = opts.start + (opts.diff * compercent * opts.dir);
5215
                }
5216

    
5217
                if ((prop == 'bg' || prop == 'bgp') && !this._bgcover) {
5218
                    this._bgcover = initBgImageParallax(this, prop, opts);
5219
                }
5220

    
5221
                switch(prop) {
5222

    
5223
                    // transforms
5224
                    case 'x':
5225
                        css.transform += supports3d ? ' translate3d('+val+'px, 0, 0)':' translateX('+val+'px)';
5226
                        break;
5227
                    case 'xp':
5228
                        css.transform += supports3d ? ' translate3d('+val+'%, 0, 0)':' translateX('+val+'%)';
5229
                        break;
5230
                    case 'y':
5231
                        css.transform += supports3d ? ' translate3d(0, '+val+'px, 0)':' translateY('+val+'px)';
5232
                        break;
5233
                    case 'yp':
5234
                        css.transform += supports3d ? ' translate3d(0, '+val+'%, 0)':' translateY('+val+'%)';
5235
                        break;
5236
                    case 'rotate':
5237
                        css.transform += ' rotate('+val+'deg)';
5238
                        break;
5239
                    case 'scale':
5240
                        css.transform += ' scale('+val+')';
5241
                        break;
5242

    
5243
                    // bg image
5244
                    case 'bg':
5245

    
5246
                        // don't move if image height is too small
5247
                        // if ($this.element.data('bgsize') && ($this.element.data('bgsize').h + val - window.innerHeight) < 0) {
5248
                        //     break;
5249
                        // }
5250

    
5251
                        css['background-position'] = '50% '+val+'px';
5252
                        break;
5253
                    case 'bgp':
5254
                        css['background-position'] = '50% '+val+'%';
5255
                        break;
5256

    
5257
                    // color
5258
                    case 'color':
5259
                    case 'background-color':
5260
                    case 'border-color':
5261
                        css[prop] = calcColor(opts.start, opts.end, compercent);
5262
                        break;
5263

    
5264
                    // CSS Filter
5265
                    case 'blur':
5266
                        css.filter += ' blur('+val+'px)';
5267
                        break;
5268
                    case 'hue':
5269
                        css.filter += ' hue-rotate('+val+'deg)';
5270
                        break;
5271
                    case 'grayscale':
5272
                        css.filter += ' grayscale('+val+'%)';
5273
                        break;
5274
                    case 'invert':
5275
                        css.filter += ' invert('+val+'%)';
5276
                        break;
5277
                    case 'fopacity':
5278
                        css.filter += ' opacity('+val+'%)';
5279
                        break;
5280
                    case 'saturate':
5281
                        css.filter += ' saturate('+val+'%)';
5282
                        break;
5283
                    case 'sepia':
5284
                        css.filter += ' sepia('+val+'%)';
5285
                        break;
5286

    
5287
                    default:
5288
                        css[prop] = val;
5289
                        break;
5290
                }
5291

    
5292
            }.bind(this));
5293

    
5294
            if (css.filter) {
5295
                css['-webkit-filter'] = css.filter;
5296
            }
5297

    
5298
            this.element.css(css);
5299

    
5300
            this._percent = compercent;
5301
        },
5302

    
5303
        _getStartValue: function(prop) {
5304

    
5305
            var value = 0;
5306

    
5307
            switch(prop) {
5308
                case 'scale':
5309
                    value = 1;
5310
                    break;
5311
                default:
5312
                    value = this.element.css(prop);
5313
            }
5314

    
5315
            return (value || 0);
5316
        }
5317

    
5318
    });
5319

    
5320

    
5321
    // helper
5322

    
5323
    function initBgImageParallax(obj, prop, opts) {
5324

    
5325
        var img = new Image(), url, element, size, check, ratio, width, height;
5326

    
5327
        element = obj.element.css({backgroundSize: 'cover',  backgroundRepeat: 'no-repeat'});
5328
        url     = element.css('background-image').replace(/^url\(/g, '').replace(/\)$/g, '').replace(/("|')/g, '');
5329
        check   = function() {
5330

    
5331
            var w = element.innerWidth(), h = element.innerHeight(), extra = (prop=='bg') ? opts.diff : (opts.diff/100) * h;
5332

    
5333
            h += extra;
5334
            w += Math.ceil(extra * ratio);
5335

    
5336
            if (w-extra < size.w && h < size.h) {
5337
                return obj.element.css({backgroundSize: 'auto'});
5338
            }
5339

    
5340
            // if element height < parent height (gap underneath)
5341
            if ((w / ratio) < h) {
5342

    
5343
                width  = Math.ceil(h * ratio);
5344
                height = h;
5345

    
5346
                if (h > window.innerHeight) {
5347
                    width  = width * 1.2;
5348
                    height = height * 1.2;
5349
                }
5350

    
5351
            // element width < parent width (gap to right)
5352
            } else {
5353

    
5354
                width  = w;
5355
                height = Math.ceil(w / ratio);
5356
            }
5357

    
5358
            element.css({backgroundSize: (width+'px '+height+'px')}).data('bgsize', {w:width,h:height});
5359
        };
5360

    
5361
        img.onerror = function(){
5362
            // image url doesn't exist
5363
        };
5364

    
5365
        img.onload = function(){
5366
            size  = {w:img.width, h:img.height};
5367
            ratio = img.width / img.height;
5368

    
5369
            UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
5370
                check();
5371
            }, 50));
5372

    
5373
            check();
5374
        };
5375

    
5376
        img.src = url;
5377

    
5378
        return true;
5379
    }
5380

    
5381

    
5382
    // Some named colors to work with, added by Bradley Ayers
5383
    // From Interface by Stefan Petre
5384
    // http://interface.eyecon.ro/
5385
    var colors = {
5386
        'black': [0,0,0,1],
5387
        'blue': [0,0,255,1],
5388
        'brown': [165,42,42,1],
5389
        'cyan': [0,255,255,1],
5390
        'fuchsia': [255,0,255,1],
5391
        'gold': [255,215,0,1],
5392
        'green': [0,128,0,1],
5393
        'indigo': [75,0,130,1],
5394
        'khaki': [240,230,140,1],
5395
        'lime': [0,255,0,1],
5396
        'magenta': [255,0,255,1],
5397
        'maroon': [128,0,0,1],
5398
        'navy': [0,0,128,1],
5399
        'olive': [128,128,0,1],
5400
        'orange': [255,165,0,1],
5401
        'pink': [255,192,203,1],
5402
        'purple': [128,0,128,1],
5403
        'violet': [128,0,128,1],
5404
        'red': [255,0,0,1],
5405
        'silver': [192,192,192,1],
5406
        'white': [255,255,255,1],
5407
        'yellow': [255,255,0,1],
5408
        'transparent': [255,255,255,0]
5409
    };
5410

    
5411
    function calcColor(start, end, pos) {
5412

    
5413
        start = parseColor(start);
5414
        end   = parseColor(end);
5415
        pos   = pos || 0;
5416

    
5417
        return calculateColor(start, end, pos);
5418
    }
5419

    
5420
    /**!
5421
     * @preserve Color animation 1.6.0
5422
     * http://www.bitstorm.org/jquery/color-animation/
5423
     * Copyright 2011, 2013 Edwin Martin <edwin@bitstorm.org>
5424
     * Released under the MIT and GPL licenses.
5425
     */
5426

    
5427
    // Calculate an in-between color. Returns "#aabbcc"-like string.
5428
    function calculateColor(begin, end, pos) {
5429
        var color = 'rgba('
5430
                + parseInt((begin[0] + pos * (end[0] - begin[0])), 10) + ','
5431
                + parseInt((begin[1] + pos * (end[1] - begin[1])), 10) + ','
5432
                + parseInt((begin[2] + pos * (end[2] - begin[2])), 10) + ','
5433
                + (begin && end ? parseFloat(begin[3] + pos * (end[3] - begin[3])) : 1);
5434

    
5435
        color += ')';
5436
        return color;
5437
    }
5438

    
5439
    // Parse an CSS-syntax color. Outputs an array [r, g, b]
5440
    function parseColor(color) {
5441

    
5442
        var match, quadruplet;
5443

    
5444
        // Match #aabbcc
5445
        if (match = /#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(color)) {
5446
            quadruplet = [parseInt(match[1], 16), parseInt(match[2], 16), parseInt(match[3], 16), 1];
5447

    
5448
            // Match #abc
5449
        } else if (match = /#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(color)) {
5450
            quadruplet = [parseInt(match[1], 16) * 17, parseInt(match[2], 16) * 17, parseInt(match[3], 16) * 17, 1];
5451

    
5452
            // Match rgb(n, n, n)
5453
        } else if (match = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) {
5454
            quadruplet = [parseInt(match[1]), parseInt(match[2]), parseInt(match[3]), 1];
5455

    
5456
        } else if (match = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(color)) {
5457
            quadruplet = [parseInt(match[1], 10), parseInt(match[2], 10), parseInt(match[3], 10),parseFloat(match[4])];
5458

    
5459
            // No browser returns rgb(n%, n%, n%), so little reason to support this format.
5460
        } else {
5461
            quadruplet = colors[color] || [255,255,255,0];
5462
        }
5463
        return quadruplet;
5464
    }
5465

    
5466
    return UI.parallax;
5467
});
5468

    
5469
/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
5470
(function(addon) {
5471

    
5472
    var component;
5473

    
5474
    if (window.UIkit2) {
5475
        component = addon(UIkit2);
5476
    }
5477

    
5478
    if (typeof define == 'function' && define.amd) {
5479
        define('uikit-slider', ['uikit'], function(){
5480
            return component || addon(UIkit2);
5481
        });
5482
    }
5483

    
5484
})(function(UI){
5485

    
5486
    "use strict";
5487

    
5488
    var dragging, delayIdle, anchor, dragged, store = {};
5489

    
5490
    UI.component('slider', {
5491

    
5492
        defaults: {
5493
            center           : false,
5494
            threshold        : 10,
5495
            infinite         : true,
5496
            autoplay         : false,
5497
            autoplayInterval : 7000,
5498
            pauseOnHover     : true,
5499
            activecls        : 'uk-active'
5500
        },
5501

    
5502
        boot:  function() {
5503

    
5504
            // init code
5505
            UI.ready(function(context) {
5506

    
5507
                setTimeout(function(){
5508

    
5509
                    UI.$('[data-uk-slider]', context).each(function(){
5510

    
5511
                        var ele = UI.$(this);
5512

    
5513
                        if (!ele.data('slider')) {
5514
                            UI.slider(ele, UI.Utils.options(ele.attr('data-uk-slider')));
5515
                        }
5516
                    });
5517

    
5518
                }, 0);
5519
            });
5520
        },
5521

    
5522
        init: function() {
5523

    
5524
            var $this = this;
5525

    
5526
            this.container = this.element.find('.uk-slider');
5527
            this.focus     = 0;
5528

    
5529
            UI.$win.on('resize load', UI.Utils.debounce(function() {
5530
                $this.update(true);
5531
            }, 100));
5532

    
5533
            this.on('click.uk.slider', '[data-uk-slider-item]', function(e) {
5534

    
5535
                e.preventDefault();
5536

    
5537
                var item = UI.$(this).attr('data-uk-slider-item');
5538

    
5539
                if ($this.focus == item) return;
5540

    
5541
                // stop autoplay
5542
                $this.stop();
5543

    
5544
                switch(item) {
5545
                    case 'next':
5546
                    case 'previous':
5547
                        $this[item=='next' ? 'next':'previous']();
5548
                        break;
5549
                    default:
5550
                        $this.updateFocus(parseInt(item, 10));
5551
                }
5552
            });
5553

    
5554
            this.container.on({
5555

    
5556
                'touchstart mousedown': function(evt) {
5557

    
5558
                    if (evt.originalEvent && evt.originalEvent.touches) {
5559
                        evt = evt.originalEvent.touches[0];
5560
                    }
5561

    
5562
                    // ignore right click button
5563
                    if (evt.button && evt.button==2 || !$this.active) {
5564
                        return;
5565
                    }
5566

    
5567
                    // stop autoplay
5568
                    $this.stop();
5569

    
5570
                    anchor  = UI.$(evt.target).is('a') ? UI.$(evt.target) : UI.$(evt.target).parents('a:first');
5571
                    dragged = false;
5572

    
5573
                    if (anchor.length) {
5574

    
5575
                        anchor.one('click', function(e){
5576
                            if (dragged) e.preventDefault();
5577
                        });
5578
                    }
5579

    
5580
                    delayIdle = function(e) {
5581

    
5582
                        dragged  = true;
5583
                        dragging = $this;
5584
                        store    = {
5585
                            touchx : parseInt(e.pageX, 10),
5586
                            dir    : 1,
5587
                            focus  : $this.focus,
5588
                            base   : $this.options.center ? 'center':'area'
5589
                        };
5590

    
5591
                        if (e.originalEvent && e.originalEvent.touches) {
5592
                            e = e.originalEvent.touches[0];
5593
                        }
5594

    
5595
                        dragging.element.data({
5596
                            'pointer-start': {x: parseInt(e.pageX, 10), y: parseInt(e.pageY, 10)},
5597
                            'pointer-pos-start': $this.pos
5598
                        });
5599

    
5600
                        $this.container.addClass('uk-drag');
5601

    
5602
                        delayIdle = false;
5603
                    };
5604

    
5605
                    delayIdle.x         = parseInt(evt.pageX, 10);
5606
                    delayIdle.threshold = $this.options.threshold;
5607

    
5608
                },
5609

    
5610
                mouseenter: function() { if ($this.options.pauseOnHover) $this.hovering = true;  },
5611
                mouseleave: function() { $this.hovering = false; }
5612
            });
5613

    
5614
            this.update(true);
5615

    
5616
            this.on('display.uk.check', function(){
5617
                if ($this.element.is(":visible")) {
5618
                    $this.update(true);
5619
                }
5620
            });
5621

    
5622
            // prevent dragging links + images
5623
            this.element.find('a,img').attr('draggable', 'false');
5624

    
5625
            // Set autoplay
5626
            if (this.options.autoplay) {
5627
                this.start();
5628
            }
5629

    
5630
            UI.domObserve(this.element, function(e) {
5631
                if ($this.element.children(':not([data-slider-slide])').length) {
5632
                    $this.update(true);
5633
                }
5634
            });
5635

    
5636
        },
5637

    
5638
        update: function(focus) {
5639

    
5640
            var $this = this, pos = 0, maxheight = 0, item, width, cwidth, size;
5641

    
5642
            this.items = this.container.children().filter(':visible');
5643
            this.vp    = this.element[0].getBoundingClientRect().width;
5644

    
5645
            this.container.css({'min-width': '', 'min-height': ''});
5646

    
5647
            this.items.each(function(idx){
5648

    
5649
                item      = UI.$(this).attr('data-slider-slide', idx);
5650
                size      = item.css({'left': '', 'width':''})[0].getBoundingClientRect();
5651
                width     = size.width;
5652
                cwidth    = item.width();
5653
                maxheight = Math.max(maxheight, size.height);
5654

    
5655
                item.css({'left': pos, 'width':width}).data({'idx':idx, 'left': pos, 'width': width, 'cwidth':cwidth, 'area': (pos+width), 'center':(pos - ($this.vp/2 - cwidth/2))});
5656

    
5657
                pos += width;
5658
            });
5659

    
5660
            this.container.css({'min-width': pos, 'min-height': maxheight});
5661

    
5662
            if (this.options.infinite && (pos <= (2*this.vp) || this.items.length < 5) && !this.itemsResized) {
5663

    
5664
                // fill with cloned items
5665
                this.container.children().each(function(idx){
5666
                   $this.container.append($this.items.eq(idx).clone(true).attr('id', ''));
5667
                }).each(function(idx){
5668
                   $this.container.append($this.items.eq(idx).clone(true).attr('id', ''));
5669
                });
5670

    
5671
                this.itemsResized = true;
5672

    
5673
                return this.update();
5674
            }
5675

    
5676
            this.cw     = pos;
5677
            this.pos    = 0;
5678
            this.active = pos >= this.vp;
5679

    
5680
            this.container.css({
5681
                '-ms-transform': '',
5682
                '-webkit-transform': '',
5683
                'transform': ''
5684
            });
5685

    
5686
            if (focus) this.updateFocus(this.focus);
5687
        },
5688

    
5689
        updatePos: function(pos) {
5690
            this.pos = pos;
5691
            this.container.css({
5692
                '-ms-transform': 'translateX('+pos+'px)',
5693
                '-webkit-transform': 'translateX('+pos+'px)',
5694
                'transform': 'translateX('+pos+'px)'
5695
            });
5696
        },
5697

    
5698
        updateFocus: function(idx, dir) {
5699

    
5700
            if (!this.active) {
5701
                return;
5702
            }
5703

    
5704
            dir = dir || (idx > this.focus ? 1:-1);
5705

    
5706
            var item = this.items.eq(idx), area, i;
5707

    
5708
            if (this.options.infinite) {
5709
                this.infinite(idx, dir);
5710
            }
5711

    
5712
            if (this.options.center) {
5713

    
5714
                this.updatePos(item.data('center')*-1);
5715

    
5716
                this.items.filter('.'+this.options.activecls).removeClass(this.options.activecls);
5717
                item.addClass(this.options.activecls);
5718

    
5719
            } else {
5720

    
5721
                if (this.options.infinite) {
5722

    
5723
                    this.updatePos(item.data('left')*-1);
5724

    
5725
                } else {
5726

    
5727
                    area = 0;
5728

    
5729
                    for (i=idx;i<this.items.length;i++) {
5730
                        area += this.items.eq(i).data('width');
5731
                    }
5732

    
5733

    
5734
                    if (area > this.vp) {
5735

    
5736
                        this.updatePos(item.data('left')*-1);
5737

    
5738
                    } else {
5739

    
5740
                        if (dir == 1) {
5741

    
5742
                            area = 0;
5743

    
5744
                            for (i=this.items.length-1;i>=0;i--) {
5745

    
5746
                                area += this.items.eq(i).data('width');
5747

    
5748
                                if (area == this.vp) {
5749
                                    idx = i;
5750
                                    break;
5751
                                }
5752

    
5753
                                if (area > this.vp) {
5754
                                    idx = (i < this.items.length-1) ? i+1 : i;
5755
                                    break;
5756
                                }
5757
                            }
5758

    
5759
                            if (area > this.vp) {
5760
                                this.updatePos((this.container.width() - this.vp) * -1);
5761
                            } else {
5762
                                this.updatePos(this.items.eq(idx).data('left')*-1);
5763
                            }
5764
                        }
5765
                    }
5766
                }
5767
            }
5768

    
5769
            // mark elements
5770
            var left = this.items.eq(idx).data('left');
5771

    
5772
            this.items.removeClass('uk-slide-before uk-slide-after').each(function(i){
5773
                if (i!==idx) {
5774
                    UI.$(this).addClass(UI.$(this).data('left') < left ? 'uk-slide-before':'uk-slide-after');
5775
                }
5776
            });
5777

    
5778
            this.focus = idx;
5779

    
5780
            this.trigger('focusitem.uk.slider', [idx,this.items.eq(idx),this]);
5781
        },
5782

    
5783
        next: function() {
5784

    
5785
            var focus = this.items[this.focus + 1] ? (this.focus + 1) : (this.options.infinite ? 0:this.focus);
5786

    
5787
            this.updateFocus(focus, 1);
5788
        },
5789

    
5790
        previous: function() {
5791

    
5792
            var focus = this.items[this.focus - 1] ? (this.focus - 1) : (this.options.infinite ? (this.items[this.focus - 1] ? this.items-1:this.items.length-1):this.focus);
5793

    
5794
            this.updateFocus(focus, -1);
5795
        },
5796

    
5797
        start: function() {
5798

    
5799
            this.stop();
5800

    
5801
            var $this = this;
5802

    
5803
            this.interval = setInterval(function() {
5804
                if (!$this.hovering) $this.next();
5805
            }, this.options.autoplayInterval);
5806

    
5807
        },
5808

    
5809
        stop: function() {
5810
            if (this.interval) clearInterval(this.interval);
5811
        },
5812

    
5813
        infinite: function(baseidx, direction) {
5814

    
5815
            var $this = this, item = this.items.eq(baseidx), i, z = baseidx, move = [], area = 0;
5816

    
5817
            if (direction == 1) {
5818

    
5819

    
5820
                for (i=0;i<this.items.length;i++) {
5821

    
5822
                    if (z != baseidx) {
5823
                        area += this.items.eq(z).data('width');
5824
                        move.push(this.items.eq(z));
5825
                    }
5826

    
5827
                    if (area > this.vp) {
5828
                        break;
5829
                    }
5830

    
5831
                    z = z+1 == this.items.length ? 0:z+1;
5832
                }
5833

    
5834
                if (move.length) {
5835

    
5836
                    move.forEach(function(itm){
5837

    
5838
                        var left = item.data('area');
5839

    
5840
                        itm.css({'left': left}).data({
5841
                            left  : left,
5842
                            area  : (left+itm.data('width')),
5843
                            center: (left - ($this.vp/2 - itm.data('cwidth')/2))
5844
                        });
5845

    
5846
                        item = itm;
5847
                    });
5848
                }
5849

    
5850

    
5851
            } else {
5852

    
5853
                for (i=this.items.length-1;i >-1 ;i--) {
5854

    
5855
                    area += this.items.eq(z).data('width');
5856

    
5857
                    if (z != baseidx) {
5858
                        move.push(this.items.eq(z));
5859
                    }
5860

    
5861
                    if (area > this.vp) {
5862
                        break;
5863
                    }
5864

    
5865
                    z = z-1 == -1 ? this.items.length-1:z-1;
5866
                }
5867

    
5868
                if (move.length) {
5869

    
5870
                    move.forEach(function(itm){
5871

    
5872
                        var left = item.data('left') - itm.data('width');
5873

    
5874
                        itm.css({'left': left}).data({
5875
                            left  : left,
5876
                            area  : (left+itm.data('width')),
5877
                            center: (left - ($this.vp/2 - itm.data('cwidth')/2))
5878
                        });
5879

    
5880
                        item = itm;
5881
                    });
5882
                }
5883
            }
5884
        }
5885
    });
5886

    
5887
    // handle dragging
5888
    UI.$doc.on('mousemove.uk.slider touchmove.uk.slider', function(e) {
5889

    
5890
        if (e.originalEvent && e.originalEvent.touches) {
5891
            e = e.originalEvent.touches[0];
5892
        }
5893

    
5894
        if (delayIdle && Math.abs(e.pageX - delayIdle.x) > delayIdle.threshold) {
5895

    
5896
            if (!window.getSelection().toString()) {
5897
                delayIdle(e);
5898
            } else {
5899
                dragging = delayIdle = false;
5900
            }
5901
        }
5902

    
5903
        if (!dragging) {
5904
            return;
5905
        }
5906

    
5907
        var x, xDiff, pos, dir, focus, item, next, diff, i, z, itm;
5908

    
5909
        if (e.clientX || e.clientY) {
5910
            x = e.clientX;
5911
        } else if (e.pageX || e.pageY) {
5912
            x = e.pageX - document.body.scrollLeft - document.documentElement.scrollLeft;
5913
        }
5914

    
5915
        focus = store.focus;
5916
        xDiff = x - dragging.element.data('pointer-start').x;
5917
        pos   = dragging.element.data('pointer-pos-start') + xDiff;
5918
        dir   = x > dragging.element.data('pointer-start').x ? -1:1;
5919
        item  = dragging.items.eq(store.focus);
5920

    
5921
        if (dir == 1) {
5922

    
5923
            diff = item.data('left') + Math.abs(xDiff);
5924

    
5925
            for (i=0,z=store.focus;i<dragging.items.length;i++) {
5926

    
5927
                itm = dragging.items.eq(z);
5928

    
5929
                if (z != store.focus && itm.data('left') < diff && itm.data('area') > diff) {
5930
                    focus = z;
5931
                    break;
5932
                }
5933

    
5934
                z = z+1 == dragging.items.length ? 0:z+1;
5935
            }
5936

    
5937
        } else {
5938

    
5939
            diff = item.data('left') - Math.abs(xDiff);
5940

    
5941
            for (i=0,z=store.focus;i<dragging.items.length;i++) {
5942

    
5943
                itm = dragging.items.eq(z);
5944

    
5945
                if (z != store.focus && itm.data('area') <= item.data('left') && itm.data('center') < diff) {
5946
                    focus = z;
5947
                    break;
5948
                }
5949

    
5950
                z = z-1 == -1 ? dragging.items.length-1:z-1;
5951
            }
5952
        }
5953

    
5954
        if (dragging.options.infinite && focus!=store._focus) {
5955
            dragging.infinite(focus, dir);
5956
        }
5957

    
5958
        dragging.updatePos(pos);
5959

    
5960
        store.dir     = dir;
5961
        store._focus  = focus;
5962
        store.touchx  = parseInt(e.pageX, 10);
5963
        store.diff    = diff;
5964
    });
5965

    
5966
    UI.$doc.on('mouseup.uk.slider touchend.uk.slider', function(e) {
5967

    
5968
        if (dragging) {
5969

    
5970
            dragging.container.removeClass('uk-drag');
5971

    
5972
            // TODO is this needed?
5973
            dragging.items.eq(store.focus);
5974

    
5975
            var itm, focus = false, i, z;
5976

    
5977
            if (store.dir == 1) {
5978

    
5979
                for (i=0,z=store.focus;i<dragging.items.length;i++) {
5980

    
5981
                    itm = dragging.items.eq(z);
5982

    
5983
                    if (z != store.focus && itm.data('left') > store.diff) {
5984
                        focus = z;
5985
                        break;
5986
                    }
5987

    
5988
                    z = z+1 == dragging.items.length ? 0:z+1;
5989
                }
5990
                if (!dragging.options.infinite && !focus) {
5991
                    focus = dragging.items.length;
5992
                }
5993

    
5994
            } else {
5995

    
5996
                for (i=0,z=store.focus;i<dragging.items.length;i++) {
5997

    
5998
                    itm = dragging.items.eq(z);
5999

    
6000
                    if (z != store.focus && itm.data('left') < store.diff) {
6001
                        focus = z;
6002
                        break;
6003
                    }
6004

    
6005
                    z = z-1 == -1 ? dragging.items.length-1:z-1;
6006
                }
6007
                if (!dragging.options.infinite && !focus) {
6008
                    focus = 0
6009
                }
6010
            }
6011

    
6012
            dragging.updateFocus(focus!==false ? focus:store._focus);
6013

    
6014
        }
6015

    
6016
        dragging = delayIdle = false;
6017
    });
6018

    
6019
    return UI.slider;
6020
});
6021

    
6022
/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
6023
(function(addon) {
6024

    
6025
    var component;
6026

    
6027
    if (window.UIkit2) {
6028
        component = addon(UIkit2);
6029
    }
6030

    
6031
    if (typeof define == 'function' && define.amd) {
6032
        define('uikit-slideshow', ['uikit'], function() {
6033
            return component || addon(UIkit2);
6034
        });
6035
    }
6036

    
6037
})(function(UI) {
6038

    
6039
    "use strict";
6040

    
6041
    var Animations, playerId = 0;
6042

    
6043
    UI.component('slideshow', {
6044

    
6045
        defaults: {
6046
            animation          : 'fade',
6047
            duration           : 500,
6048
            height             : 'auto',
6049
            start              : 0,
6050
            autoplay           : false,
6051
            autoplayInterval   : 7000,
6052
            videoautoplay      : true,
6053
            videomute          : true,
6054
            slices             : 15,
6055
            pauseOnHover       : true,
6056
            kenburns           : false,
6057
            kenburnsanimations : [
6058
                'uk-animation-middle-left',
6059
                'uk-animation-top-right',
6060
                'uk-animation-bottom-left',
6061
                'uk-animation-top-center',
6062
                '', // middle-center
6063
                'uk-animation-bottom-right'
6064
            ]
6065
        },
6066

    
6067
        current  : false,
6068
        interval : null,
6069
        hovering : false,
6070

    
6071
        boot: function() {
6072

    
6073
            // init code
6074
            UI.ready(function(context) {
6075

    
6076
                UI.$('[data-uk-slideshow]', context).each(function() {
6077

    
6078
                    var slideshow = UI.$(this);
6079

    
6080
                    if (!slideshow.data('slideshow')) {
6081
                        UI.slideshow(slideshow, UI.Utils.options(slideshow.attr('data-uk-slideshow')));
6082
                    }
6083
                });
6084
            });
6085
        },
6086

    
6087
        init: function() {
6088

    
6089
            var $this = this;
6090

    
6091
            this.container     = this.element.hasClass('uk-slideshow') ? this.element : UI.$(this.find('.uk-slideshow:first'));
6092
            this.current       = this.options.start;
6093
            this.animating     = false;
6094

    
6095
            this.fixFullscreen = navigator.userAgent.match(/(iPad|iPhone|iPod)/g) && this.container.hasClass('uk-slideshow-fullscreen'); // viewport unit fix for height:100vh - should be fixed in iOS 8
6096

    
6097
            if (this.options.kenburns) {
6098

    
6099
                this.kbanimduration = this.options.kenburns === true ? '15s': this.options.kenburns;
6100

    
6101
                if (!String(this.kbanimduration).match(/(ms|s)$/)) {
6102
                    this.kbanimduration += 'ms';
6103
                }
6104

    
6105
                if (typeof(this.options.kenburnsanimations) == 'string') {
6106
                    this.options.kenburnsanimations = this.options.kenburnsanimations.split(',');
6107
                }
6108
            }
6109

    
6110
            this.update();
6111

    
6112
            this.on('click.uk.slideshow', '[data-uk-slideshow-item]', function(e) {
6113

    
6114
                e.preventDefault();
6115

    
6116
                var slide = UI.$(this).attr('data-uk-slideshow-item');
6117

    
6118
                if ($this.current == slide) return;
6119

    
6120
                switch(slide) {
6121
                    case 'next':
6122
                    case 'previous':
6123
                        $this[slide=='next' ? 'next':'previous']();
6124
                        break;
6125
                    default:
6126
                        $this.show(parseInt(slide, 10));
6127
                }
6128

    
6129
                $this.stop();
6130
            });
6131

    
6132
            UI.$win.on("resize load", UI.Utils.debounce(function() {
6133
                $this.resize();
6134

    
6135
                if ($this.fixFullscreen) {
6136
                    $this.container.css('height', window.innerHeight);
6137
                    $this.slides.css('height', window.innerHeight);
6138
                }
6139
            }, 100));
6140

    
6141
            // chrome image load fix
6142
            setTimeout(function(){
6143
                $this.resize();
6144
            }, 80);
6145

    
6146
            // Set autoplay
6147
            if (this.options.autoplay) {
6148
                this.start();
6149
            }
6150

    
6151
            if (this.options.videoautoplay && this.slides.eq(this.current).data('media')) {
6152
                this.playmedia(this.slides.eq(this.current).data('media'));
6153
            }
6154

    
6155
            if (this.options.kenburns) {
6156
                this.applyKenBurns(this.slides.eq(this.current));
6157
            }
6158

    
6159
            this.container.on({
6160
                mouseenter: function() { if ($this.options.pauseOnHover) $this.hovering = true;  },
6161
                mouseleave: function() { $this.hovering = false; }
6162
            });
6163

    
6164
            this.on('swipeRight swipeLeft', function(e) {
6165
                $this[e.type=='swipeLeft' ? 'next' : 'previous']();
6166
            });
6167

    
6168
            this.on('display.uk.check', function(){
6169
                if ($this.element.is(':visible')) {
6170

    
6171
                    $this.resize();
6172

    
6173
                    if ($this.fixFullscreen) {
6174
                        $this.container.css('height', window.innerHeight);
6175
                        $this.slides.css('height', window.innerHeight);
6176
                    }
6177
                }
6178
            });
6179

    
6180
            UI.domObserve(this.element, function(e) {
6181
                if ($this.container.children(':not([data-slideshow-slide])').not('.uk-slideshow-ghost').length) {
6182
                    $this.update(true);
6183
                }
6184
            });
6185
        },
6186

    
6187
        update: function(resize) {
6188

    
6189
            var $this = this, canvas, processed = 0;
6190

    
6191
            this.slides        = this.container.children();
6192
            this.slidesCount   = this.slides.length;
6193

    
6194
            if (!this.slides.eq(this.current).length) {
6195
                this.current = 0;
6196
            }
6197

    
6198
            this.slides.each(function(index) {
6199

    
6200
                var slide = UI.$(this);
6201

    
6202
                if (slide.data('processed')) {
6203
                    return;
6204
                }
6205

    
6206
                var media = slide.children('img,video,iframe').eq(0), type = 'html';
6207

    
6208
                slide.data('media', media);
6209
                slide.data('sizer', media);
6210

    
6211
                if (media.length) {
6212

    
6213
                    var placeholder;
6214

    
6215
                    type = media[0].nodeName.toLowerCase();
6216

    
6217
                    switch(media[0].nodeName) {
6218
                        case 'IMG':
6219

    
6220
                            var cover = UI.$('<div class="uk-cover-background uk-position-cover"></div>').css({'background-image':'url('+ media.attr('src') + ')'});
6221

    
6222
                            if (media.attr('width') && media.attr('height')) {
6223
                                placeholder = UI.$('<canvas></canvas>').attr({width:media.attr('width'), height:media.attr('height')});
6224
                                media.replaceWith(placeholder);
6225
                                media = placeholder;
6226
                                placeholder = undefined;
6227
                            }
6228

    
6229
                            media.css({width: '100%',height: 'auto', opacity:0});
6230
                            slide.prepend(cover).data('cover', cover);
6231
                            break;
6232

    
6233
                        case 'IFRAME':
6234

    
6235
                            var src = media[0].src, iframeId = 'sw-'+(++playerId);
6236

    
6237
                            media
6238
                                .attr('src', '').on('load', function(){
6239

    
6240
                                    if (index !== $this.current || (index == $this.current && !$this.options.videoautoplay)) {
6241
                                        $this.pausemedia(media);
6242
                                    }
6243

    
6244
                                    if ($this.options.videomute) {
6245

    
6246
                                        $this.mutemedia(media);
6247

    
6248
                                        var inv = setInterval((function(ic) {
6249
                                            return function() {
6250
                                                $this.mutemedia(media);
6251
                                                if (++ic >= 4) clearInterval(inv);
6252
                                            }
6253
                                        })(0), 250);
6254
                                    }
6255

    
6256
                                })
6257
                                .data('slideshow', $this)  // add self-reference for the vimeo-ready listener
6258
                                .attr('data-player-id', iframeId)  // add frameId for the vimeo-ready listener
6259
                                .attr('src', [src, (src.indexOf('?') > -1 ? '&':'?'), 'enablejsapi=1&api=1&player_id='+iframeId].join(''))
6260
                                .addClass('uk-position-absolute');
6261

    
6262
                            // disable pointer events
6263
                            if(!UI.support.touch) media.css('pointer-events', 'none');
6264

    
6265
                            placeholder = true;
6266

    
6267
                            if (UI.cover) {
6268
                                UI.cover(media);
6269
                                media.attr('data-uk-cover', '{}');
6270
                            }
6271

    
6272
                            break;
6273

    
6274
                        case 'VIDEO':
6275
                            media.addClass('uk-cover-object uk-position-absolute');
6276
                            placeholder = true;
6277

    
6278
                            if ($this.options.videomute) $this.mutemedia(media);
6279
                    }
6280

    
6281
                    if (placeholder) {
6282

    
6283
                        canvas  = UI.$('<canvas></canvas>').attr({'width': media[0].width, 'height': media[0].height});
6284
                        var img = UI.$('<img style="width:100%;height:auto;">').attr('src', canvas[0].toDataURL());
6285

    
6286
                        slide.prepend(img);
6287
                        slide.data('sizer', img);
6288
                    }
6289

    
6290
                } else {
6291
                    slide.data('sizer', slide);
6292
                }
6293

    
6294
                if ($this.hasKenBurns(slide)) {
6295

    
6296
                    slide.data('cover').css({
6297
                        '-webkit-animation-duration': $this.kbanimduration,
6298
                        'animation-duration': $this.kbanimduration
6299
                    });
6300
                }
6301

    
6302
                slide.data('processed', ++processed);
6303
                slide.attr('data-slideshow-slide', type);
6304
            });
6305

    
6306
            if (processed) {
6307

    
6308
                this.triggers = this.find('[data-uk-slideshow-item]');
6309

    
6310
                // Set start slide
6311
                this.slides.attr('aria-hidden', 'true').removeClass('uk-active').eq(this.current).addClass('uk-active').attr('aria-hidden', 'false');
6312
                this.triggers.filter('[data-uk-slideshow-item="'+this.current+'"]').addClass('uk-active');
6313
            }
6314

    
6315
            if (resize && processed) {
6316
                this.resize();
6317
            }
6318
        },
6319

    
6320
        resize: function() {
6321

    
6322
            if (this.container.hasClass('uk-slideshow-fullscreen')) return;
6323

    
6324
            var height = this.options.height;
6325

    
6326
            if (this.options.height === 'auto') {
6327

    
6328
                height = 0;
6329

    
6330
                this.slides.css('height', '').each(function() {
6331
                    height = Math.max(height, UI.$(this).height());
6332
                });
6333
            }
6334

    
6335
            this.container.css('height', height);
6336
            this.slides.css('height', height);
6337
        },
6338

    
6339
        show: function(index, direction) {
6340

    
6341
            if (this.animating || this.current == index) return;
6342

    
6343
            this.animating = true;
6344

    
6345
            var $this        = this,
6346
                current      = this.slides.eq(this.current),
6347
                next         = this.slides.eq(index),
6348
                dir          = direction ? direction : this.current < index ? 1 : -1,
6349
                currentmedia = current.data('media'),
6350
                animation    = Animations[this.options.animation] ? this.options.animation : 'fade',
6351
                nextmedia    = next.data('media'),
6352
                finalize     = function() {
6353

    
6354
                    if (!$this.animating) return;
6355

    
6356
                    if (currentmedia && currentmedia.is('video,iframe')) {
6357
                        $this.pausemedia(currentmedia);
6358
                    }
6359

    
6360
                    if (nextmedia && nextmedia.is('video,iframe')) {
6361
                        $this.playmedia(nextmedia);
6362
                    }
6363

    
6364
                    next.addClass('uk-active').attr('aria-hidden', 'false');
6365
                    current.removeClass('uk-active').attr('aria-hidden', 'true');
6366

    
6367
                    $this.animating = false;
6368
                    $this.current   = index;
6369

    
6370
                    UI.Utils.checkDisplay(next, '[class*="uk-animation-"]:not(.uk-cover-background.uk-position-cover)');
6371

    
6372
                    $this.trigger('show.uk.slideshow', [next, current, $this]);
6373
                };
6374

    
6375
            $this.applyKenBurns(next);
6376

    
6377
            // animation fallback
6378
            if (!UI.support.animation) {
6379
                animation = 'none';
6380
            }
6381

    
6382
            current = UI.$(current);
6383
            next    = UI.$(next);
6384

    
6385
            $this.trigger('beforeshow.uk.slideshow', [next, current, $this]);
6386

    
6387
            Animations[animation].apply(this, [current, next, dir]).then(finalize);
6388

    
6389
            $this.triggers.removeClass('uk-active');
6390
            $this.triggers.filter('[data-uk-slideshow-item="'+index+'"]').addClass('uk-active');
6391
        },
6392

    
6393
        applyKenBurns: function(slide) {
6394

    
6395
            if (!this.hasKenBurns(slide)) {
6396
                return;
6397
            }
6398

    
6399
            var animations = this.options.kenburnsanimations,
6400
                index      = this.kbindex || 0;
6401

    
6402

    
6403
            slide.data('cover').attr('class', 'uk-cover-background uk-position-cover').width();
6404
            slide.data('cover').addClass(['uk-animation-scale', 'uk-animation-reverse', animations[index].trim()].join(' '));
6405

    
6406
            this.kbindex = animations[index + 1] ? (index+1):0;
6407
        },
6408

    
6409
        hasKenBurns: function(slide) {
6410
            return (this.options.kenburns && slide.data('cover'));
6411
        },
6412

    
6413
        next: function() {
6414
            this.show(this.slides[this.current + 1] ? (this.current + 1) : 0, 1);
6415
        },
6416

    
6417
        previous: function() {
6418
            this.show(this.slides[this.current - 1] ? (this.current - 1) : (this.slides.length - 1), -1);
6419
        },
6420

    
6421
        start: function() {
6422

    
6423
            this.stop();
6424

    
6425
            var $this = this;
6426

    
6427
            this.interval = setInterval(function() {
6428
                if (!$this.hovering) $this.next();
6429
            }, this.options.autoplayInterval);
6430

    
6431
        },
6432

    
6433
        stop: function() {
6434
            if (this.interval) clearInterval(this.interval);
6435
        },
6436

    
6437
        playmedia: function(media) {
6438

    
6439
            if (!(media && media[0])) return;
6440

    
6441
            switch(media[0].nodeName) {
6442
                case 'VIDEO':
6443

    
6444
                    if (!this.options.videomute) {
6445
                        media[0].muted = false;
6446
                    }
6447

    
6448
                    media[0].play();
6449
                    break;
6450
                case 'IFRAME':
6451

    
6452
                    if (!this.options.videomute) {
6453
                        media[0].contentWindow.postMessage('{ "event": "command", "func": "unmute", "method":"setVolume", "value":1}', '*');
6454
                    }
6455

    
6456
                    media[0].contentWindow.postMessage('{ "event": "command", "func": "playVideo", "method":"play"}', '*');
6457
                    break;
6458
            }
6459
        },
6460

    
6461
        pausemedia: function(media) {
6462

    
6463
            switch(media[0].nodeName) {
6464
                case 'VIDEO':
6465
                    media[0].pause();
6466
                    break;
6467
                case 'IFRAME':
6468
                    media[0].contentWindow.postMessage('{ "event": "command", "func": "pauseVideo", "method":"pause"}', '*');
6469
                    break;
6470
            }
6471
        },
6472

    
6473
        mutemedia: function(media) {
6474

    
6475
            switch(media[0].nodeName) {
6476
                case 'VIDEO':
6477
                    media[0].muted = true;
6478
                    break;
6479
                case 'IFRAME':
6480
                    media[0].contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}', '*');
6481
                    break;
6482
            }
6483
        }
6484
    });
6485

    
6486
    Animations = {
6487

    
6488
        'none': function() {
6489

    
6490
            var d = UI.$.Deferred();
6491
            d.resolve();
6492
            return d.promise();
6493
        },
6494

    
6495
        'scroll': function(current, next, dir) {
6496

    
6497
            var d = UI.$.Deferred();
6498

    
6499
            current.css('animation-duration', this.options.duration+'ms');
6500
            next.css('animation-duration', this.options.duration+'ms');
6501

    
6502
            next.css('opacity', 1).one(UI.support.animation.end, function() {
6503

    
6504
                current.css('opacity', 0).removeClass(dir == -1 ? 'uk-slideshow-scroll-backward-out' : 'uk-slideshow-scroll-forward-out');
6505
                next.removeClass(dir == -1 ? 'uk-slideshow-scroll-backward-in' : 'uk-slideshow-scroll-forward-in');
6506
                d.resolve();
6507

    
6508
            }.bind(this));
6509

    
6510
            current.addClass(dir == -1 ? 'uk-slideshow-scroll-backward-out' : 'uk-slideshow-scroll-forward-out');
6511
            next.addClass(dir == -1 ? 'uk-slideshow-scroll-backward-in' : 'uk-slideshow-scroll-forward-in');
6512
            next.width(); // force redraw
6513

    
6514
            return d.promise();
6515
        },
6516

    
6517
        'swipe': function(current, next, dir) {
6518

    
6519
            var d = UI.$.Deferred();
6520

    
6521
            current.css('animation-duration', this.options.duration+'ms');
6522
            next.css('animation-duration', this.options.duration+'ms');
6523

    
6524
            next.css('opacity', 1).one(UI.support.animation.end, function() {
6525

    
6526
                current.css('opacity', 0).removeClass(dir === -1 ? 'uk-slideshow-swipe-backward-out' : 'uk-slideshow-swipe-forward-out');
6527
                next.removeClass(dir === -1 ? 'uk-slideshow-swipe-backward-in' : 'uk-slideshow-swipe-forward-in');
6528
                d.resolve();
6529

    
6530
            }.bind(this));
6531

    
6532
            current.addClass(dir == -1 ? 'uk-slideshow-swipe-backward-out' : 'uk-slideshow-swipe-forward-out');
6533
            next.addClass(dir == -1 ? 'uk-slideshow-swipe-backward-in' : 'uk-slideshow-swipe-forward-in');
6534
            next.width(); // force redraw
6535

    
6536
            return d.promise();
6537
        },
6538

    
6539
        'scale': function(current, next, dir) {
6540

    
6541
            var d = UI.$.Deferred();
6542

    
6543
            current.css('animation-duration', this.options.duration+'ms');
6544
            next.css('animation-duration', this.options.duration+'ms');
6545

    
6546
            next.css('opacity', 1);
6547

    
6548
            current.one(UI.support.animation.end, function() {
6549

    
6550
                current.css('opacity', 0).removeClass('uk-slideshow-scale-out');
6551
                d.resolve();
6552

    
6553
            }.bind(this));
6554

    
6555
            current.addClass('uk-slideshow-scale-out');
6556
            current.width(); // force redraw
6557

    
6558
            return d.promise();
6559
        },
6560

    
6561
        'fade': function(current, next, dir) {
6562

    
6563
            var d = UI.$.Deferred();
6564

    
6565
            current.css('animation-duration', this.options.duration+'ms');
6566
            next.css('animation-duration', this.options.duration+'ms');
6567

    
6568
            next.css('opacity', 1);
6569

    
6570
            // for plain text content slides - looks smoother
6571
            if (!(next.data('cover') || next.data('placeholder'))) {
6572

    
6573
                next.css('opacity', 1).one(UI.support.animation.end, function() {
6574
                    next.removeClass('uk-slideshow-fade-in');
6575
                }).addClass('uk-slideshow-fade-in');
6576
            }
6577

    
6578
            current.one(UI.support.animation.end, function() {
6579

    
6580
                current.css('opacity', 0).removeClass('uk-slideshow-fade-out');
6581
                d.resolve();
6582

    
6583
            }.bind(this));
6584

    
6585
            current.addClass('uk-slideshow-fade-out');
6586
            current.width(); // force redraw
6587

    
6588
            return d.promise();
6589
        }
6590
    };
6591

    
6592
    UI.slideshow.animations = Animations;
6593

    
6594
    // Listen for messages from the vimeo player
6595
    window.addEventListener('message', function onMessageReceived(e) {
6596

    
6597
        var data = e.data, iframe;
6598

    
6599
        if (typeof(data) == 'string') {
6600

    
6601
            try {
6602
                data = JSON.parse(data);
6603
            } catch(err) {
6604
                data = {};
6605
            }
6606
        }
6607

    
6608
        if (e.origin && e.origin.indexOf('vimeo') > -1 && data.event == 'ready' && data.player_id) {
6609
            iframe = UI.$('[data-player-id="'+ data.player_id+'"]');
6610

    
6611
            if (iframe.length) {
6612
                iframe.data('slideshow').mutemedia(iframe);
6613
            }
6614
        }
6615
    }, false);
6616

    
6617
});
6618

    
6619
/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
6620
(function(addon) {
6621
    var component;
6622

    
6623
    if (window.UIkit2) {
6624
        component = addon(UIkit2);
6625
    }
6626

    
6627
    if (typeof define == 'function' && define.amd) {
6628
        define('uikit-tooltip', ['uikit'], function(){
6629
            return component || addon(UIkit2);
6630
        });
6631
    }
6632

    
6633
})(function(UI){
6634

    
6635
    "use strict";
6636

    
6637
    var $tooltip,   // tooltip container
6638
        tooltipdelay, checkIdle;
6639

    
6640
    UI.component('tooltip', {
6641

    
6642
        defaults: {
6643
            offset: 5,
6644
            pos: 'top',
6645
            animation: false,
6646
            delay: 0, // in miliseconds
6647
            cls: '',
6648
            activeClass: 'uk-active',
6649
            src: function(ele) {
6650
                var title = ele.attr('title');
6651

    
6652
                if (title !== undefined) {
6653
                    ele.data('cached-title', title).removeAttr('title');
6654
                }
6655

    
6656
                return ele.data("cached-title");
6657
            }
6658
        },
6659

    
6660
        tip: '',
6661

    
6662
        boot: function() {
6663

    
6664
            // init code
6665
            UI.$html.on('mouseenter.tooltip.uikit focus.tooltip.uikit', '[data-uk-tooltip]', function(e) {
6666
                var ele = UI.$(this);
6667

    
6668
                if (!ele.data('tooltip')) {
6669
                    UI.tooltip(ele, UI.Utils.options(ele.attr('data-uk-tooltip')));
6670
                    ele.trigger('mouseenter');
6671
                }
6672
            });
6673
        },
6674

    
6675
        init: function() {
6676

    
6677
            var $this = this;
6678

    
6679
            if (!$tooltip) {
6680
                $tooltip = UI.$('<div class="uk-tooltip"></div>').appendTo("body");
6681
            }
6682

    
6683
            this.on({
6684
                focus      : function(e) { $this.show(); },
6685
                blur       : function(e) { $this.hide(); },
6686
                mouseenter : function(e) { $this.show(); },
6687
                mouseleave : function(e) { $this.hide(); }
6688
            });
6689
        },
6690

    
6691
        show: function() {
6692

    
6693
            this.tip = typeof(this.options.src) === 'function' ? this.options.src(this.element) : this.options.src;
6694

    
6695
            if (tooltipdelay) clearTimeout(tooltipdelay);
6696
            if (checkIdle)    clearInterval(checkIdle);
6697

    
6698
            if (typeof(this.tip) === 'string' ? !this.tip.length:true) return;
6699

    
6700
            $tooltip.stop().css({top: -2000, visibility: 'hidden'}).removeClass(this.options.activeClass).show();
6701
            $tooltip.html('<div class="uk-tooltip-inner">' + this.tip + '</div>');
6702

    
6703
            var $this      = this,
6704
                pos        = UI.$.extend({}, this.element.offset(), {width: this.element[0].offsetWidth, height: this.element[0].offsetHeight}),
6705
                width      = $tooltip[0].offsetWidth,
6706
                height     = $tooltip[0].offsetHeight,
6707
                offset     = typeof(this.options.offset) === "function" ? this.options.offset.call(this.element) : this.options.offset,
6708
                position   = typeof(this.options.pos) === "function" ? this.options.pos.call(this.element) : this.options.pos,
6709
                tmppos     = position.split("-"),
6710
                tcss       = {
6711
                    display    : 'none',
6712
                    visibility : 'visible',
6713
                    top        : (pos.top + pos.height + height),
6714
                    left       : pos.left
6715
                };
6716

    
6717

    
6718
            // prevent strange position
6719
            // when tooltip is in offcanvas etc.
6720
            if (UI.$html.css('position')=='fixed' || UI.$body.css('position')=='fixed'){
6721
                var bodyoffset = UI.$('body').offset(),
6722
                    htmloffset = UI.$('html').offset(),
6723
                    docoffset  = {top: (htmloffset.top + bodyoffset.top), left: (htmloffset.left + bodyoffset.left)};
6724

    
6725
                pos.left -= docoffset.left;
6726
                pos.top  -= docoffset.top;
6727
            }
6728

    
6729

    
6730
            if ((tmppos[0] == 'left' || tmppos[0] == 'right') && UI.langdirection == 'right') {
6731
                tmppos[0] = tmppos[0] == 'left' ? 'right' : 'left';
6732
            }
6733

    
6734
            var variants =  {
6735
                bottom  : {top: pos.top + pos.height + offset, left: pos.left + pos.width / 2 - width / 2},
6736
                top     : {top: pos.top - height - offset, left: pos.left + pos.width / 2 - width / 2},
6737
                left    : {top: pos.top + pos.height / 2 - height / 2, left: pos.left - width - offset},
6738
                right   : {top: pos.top + pos.height / 2 - height / 2, left: pos.left + pos.width + offset}
6739
            };
6740

    
6741
            UI.$.extend(tcss, variants[tmppos[0]]);
6742

    
6743
            if (tmppos.length == 2) tcss.left = (tmppos[1] == 'left') ? (pos.left) : ((pos.left + pos.width) - width);
6744

    
6745
            var boundary = this.checkBoundary(tcss.left, tcss.top, width, height);
6746

    
6747
            if(boundary) {
6748

    
6749
                switch(boundary) {
6750
                    case 'x':
6751

    
6752
                        if (tmppos.length == 2) {
6753
                            position = tmppos[0]+"-"+(tcss.left < 0 ? 'left': 'right');
6754
                        } else {
6755
                            position = tcss.left < 0 ? 'right': 'left';
6756
                        }
6757

    
6758
                        break;
6759

    
6760
                    case 'y':
6761
                        if (tmppos.length == 2) {
6762
                            position = (tcss.top < 0 ? 'bottom': 'top')+'-'+tmppos[1];
6763
                        } else {
6764
                            position = (tcss.top < 0 ? 'bottom': 'top');
6765
                        }
6766

    
6767
                        break;
6768

    
6769
                    case 'xy':
6770
                        if (tmppos.length == 2) {
6771
                            position = (tcss.top < 0 ? 'bottom': 'top')+'-'+(tcss.left < 0 ? 'left': 'right');
6772
                        } else {
6773
                            position = tcss.left < 0 ? 'right': 'left';
6774
                        }
6775

    
6776
                        break;
6777

    
6778
                }
6779

    
6780
                tmppos = position.split('-');
6781

    
6782
                UI.$.extend(tcss, variants[tmppos[0]]);
6783

    
6784
                if (tmppos.length == 2) tcss.left = (tmppos[1] == 'left') ? (pos.left) : ((pos.left + pos.width) - width);
6785
            }
6786

    
6787

    
6788
            tcss.left -= UI.$body.position().left;
6789

    
6790
            tooltipdelay = setTimeout(function(){
6791

    
6792
                $tooltip.css(tcss).attr('class', ['uk-tooltip', 'uk-tooltip-'+position, $this.options.cls].join(' '));
6793

    
6794
                if ($this.options.animation) {
6795
                    $tooltip.css({opacity: 0, display: 'block'}).addClass($this.options.activeClass).animate({opacity: 1}, parseInt($this.options.animation, 10) || 400);
6796
                } else {
6797
                    $tooltip.show().addClass($this.options.activeClass);
6798
                }
6799

    
6800
                tooltipdelay = false;
6801

    
6802
                // close tooltip if element was removed or hidden
6803
                checkIdle = setInterval(function(){
6804
                    if(!$this.element.is(':visible')) $this.hide();
6805
                }, 150);
6806

    
6807
            }, parseInt(this.options.delay, 10) || 0);
6808
        },
6809

    
6810
        hide: function() {
6811

    
6812
            if (this.element.is('input') && this.element[0]===document.activeElement) return;
6813

    
6814
            if (tooltipdelay) clearTimeout(tooltipdelay);
6815
            if (checkIdle)  clearInterval(checkIdle);
6816

    
6817
            $tooltip.stop();
6818

    
6819
            if (this.options.animation) {
6820

    
6821
                var $this = this;
6822

    
6823
                $tooltip.fadeOut(parseInt(this.options.animation, 10) || 400, function(){
6824
                    $tooltip.removeClass($this.options.activeClass)
6825
                });
6826

    
6827
            } else {
6828
                $tooltip.hide().removeClass(this.options.activeClass);
6829
            }
6830
        },
6831

    
6832
        content: function() {
6833
            return this.tip;
6834
        },
6835

    
6836
        checkBoundary: function(left, top, width, height) {
6837

    
6838
            var axis = "";
6839

    
6840
            if(left < 0 || ((left - UI.$win.scrollLeft())+width) > window.innerWidth) {
6841
               axis += "x";
6842
            }
6843

    
6844
            if(top < 0 || ((top - UI.$win.scrollTop())+height) > window.innerHeight) {
6845
               axis += "y";
6846
            }
6847

    
6848
            return axis;
6849
        }
6850
    });
6851

    
6852
    return UI.tooltip;
6853
});
6854

    
6855
// http://getuikit.com/docs/documentation_javascript.html#js-override
6856

    
6857
if (typeof UIkit !== 'undefined') {
6858
    UIkit.on('beforeready.uk.dom', function () {
6859

    
6860
        // accrodion
6861
        if (typeof UIkit.components.accordion !== "undefined") { // check if accordion component is defined
6862
            $.extend(UIkit.components.accordion.prototype.defaults, {
6863
                easing: $.bez(easing_swiftOut),
6864
                duration: 200
6865
            });
6866
        }
6867

    
6868
        // dropdown
6869
        if (typeof UIkit.components.dropdown.prototype !== "undefined") { // check if dropdown component is defined
6870

    
6871
            $.extend(UIkit.components.dropdown.prototype.defaults, {
6872
                remaintime: 150,
6873
                delay: 50
6874
            });
6875

    
6876
            (function() {
6877
                var old_show_function = UIkit.components.dropdown.prototype.show;
6878

    
6879
                UIkit.components.dropdown.prototype.show = function() {
6880

    
6881
                    this.dropdown
6882
                        .css({
6883
                            'min-width': this.dropdown.outerWidth()
6884
                        })
6885
                        .addClass('uk-dropdown-active uk-dropdown-shown');
6886

    
6887
                    return old_show_function.apply(this, arguments);
6888
                }
6889
            })();
6890

    
6891
            (function() {
6892
                var old_hide_function = UIkit.components.dropdown.prototype.hide;
6893

    
6894
                UIkit.components.dropdown.prototype.hide = function() {
6895

    
6896
                    var this_dropdown = this.dropdown;
6897

    
6898
                    this_dropdown.removeClass('uk-dropdown-shown');
6899

    
6900
                    var dropdown_timeout = setTimeout(function() {
6901
                        this_dropdown.removeClass('uk-dropdown-active')
6902
                    },280);
6903

    
6904
                    return old_hide_function.apply(this, arguments);
6905
                }
6906
            })();
6907

    
6908
        }
6909

    
6910
        // modal
6911
        if (typeof UIkit.components.modal !== "undefined") { // check if modal component is defined
6912
            $.extend(UIkit.components.modal.prototype.defaults, {
6913
                center: true
6914
            });
6915

    
6916
            UIkit.modal.dialog.template = '<div class="uk-modal uk-modal-dialog-replace"><div class="uk-modal-dialog" style="min-height:0;"></div></div>';
6917
            $body
6918
                .on('show.uk.modal', '.uk-modal-dialog-replace', function () {
6919
                    // customize uikit dialog
6920
                    setTimeout(function () {
6921
                        var dialogReplace = $('.uk-modal-dialog-replace');
6922
                        if (dialogReplace.find('.uk-button-primary').length) {
6923
                            var actionBtn = dialogReplace.find('.uk-button-primary').toggleClass('uk-button-primary md-btn-flat-primary');
6924
                            if (actionBtn.next('button')) {
6925
                                actionBtn.next('button').after(actionBtn);
6926
                            }
6927
                        }
6928
                        if (dialogReplace.find('.uk-button').length) {
6929
                            dialogReplace.find('.uk-button').toggleClass('uk-button md-btn md-btn-flat');
6930
                        }
6931
                        if (dialogReplace.find('.uk-margin-small-top').length) {
6932
                            dialogReplace.find('.uk-margin-small-top').toggleClass('uk-margin-small-top uk-margin-top');
6933
                        }
6934
                        if (dialogReplace.find('input.uk-width-1-1').length) {
6935
                            dialogReplace.find('input.uk-width-1-1').toggleClass('uk-width-1-1 md-input');
6936
                            // reinitialize md inputs
6937
                            altair_md.inputs();
6938
                        }
6939
                        if (dialogReplace.find('.uk-form').length) {
6940
                            dialogReplace.find('.uk-form').removeClass('uk-form');
6941
                        }
6942
                    }, 50)
6943
                });
6944
        }
6945

    
6946
        // tooltip
6947
        if (typeof UIkit.components.tooltip !== "undefined") { // check if tooltip component is defined
6948
            $.extend(UIkit.components.tooltip.prototype.defaults, {
6949
                animation: 280,
6950
                offset: 8
6951
            });
6952
        }
6953

    
6954
    });
6955
}
(5-5/6)