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