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