From c94fb32c7a3c28b18a27460aa2447eeec1fac1de Mon Sep 17 00:00:00 2001 From: Pascal Szewczyk Date: Mon, 18 Jul 2016 23:23:54 +0200 Subject: uikit added --- js/core/alert.js | 66 ++++ js/core/alert.min.js | 2 + js/core/button.js | 157 +++++++++ js/core/button.min.js | 2 + js/core/core.js | 786 +++++++++++++++++++++++++++++++++++++++++++ js/core/core.min.js | 2 + js/core/cover.js | 95 ++++++ js/core/cover.min.js | 2 + js/core/dropdown.js | 525 +++++++++++++++++++++++++++++ js/core/dropdown.min.js | 2 + js/core/grid.js | 117 +++++++ js/core/grid.min.js | 2 + js/core/modal.js | 393 ++++++++++++++++++++++ js/core/modal.min.js | 2 + js/core/nav.js | 136 ++++++++ js/core/nav.min.js | 2 + js/core/offcanvas.js | 180 ++++++++++ js/core/offcanvas.min.js | 2 + js/core/scrollspy.js | 209 ++++++++++++ js/core/scrollspy.min.js | 2 + js/core/smooth-scroll.js | 62 ++++ js/core/smooth-scroll.min.js | 2 + js/core/switcher.js | 307 +++++++++++++++++ js/core/switcher.min.js | 2 + js/core/tab.js | 167 +++++++++ js/core/tab.min.js | 2 + js/core/toggle.js | 120 +++++++ js/core/toggle.min.js | 2 + js/core/touch.js | 175 ++++++++++ js/core/touch.min.js | 2 + js/core/utility.js | 319 ++++++++++++++++++ js/core/utility.min.js | 2 + 32 files changed, 3846 insertions(+) create mode 100755 js/core/alert.js create mode 100755 js/core/alert.min.js create mode 100755 js/core/button.js create mode 100755 js/core/button.min.js create mode 100755 js/core/core.js create mode 100755 js/core/core.min.js create mode 100755 js/core/cover.js create mode 100755 js/core/cover.min.js create mode 100755 js/core/dropdown.js create mode 100755 js/core/dropdown.min.js create mode 100755 js/core/grid.js create mode 100755 js/core/grid.min.js create mode 100755 js/core/modal.js create mode 100755 js/core/modal.min.js create mode 100755 js/core/nav.js create mode 100755 js/core/nav.min.js create mode 100755 js/core/offcanvas.js create mode 100755 js/core/offcanvas.min.js create mode 100755 js/core/scrollspy.js create mode 100755 js/core/scrollspy.min.js create mode 100755 js/core/smooth-scroll.js create mode 100755 js/core/smooth-scroll.min.js create mode 100755 js/core/switcher.js create mode 100755 js/core/switcher.min.js create mode 100755 js/core/tab.js create mode 100755 js/core/tab.min.js create mode 100755 js/core/toggle.js create mode 100755 js/core/toggle.min.js create mode 100755 js/core/touch.js create mode 100755 js/core/touch.min.js create mode 100755 js/core/utility.js create mode 100755 js/core/utility.min.js (limited to 'js/core') diff --git a/js/core/alert.js b/js/core/alert.js new file mode 100755 index 0000000..e145d5f --- /dev/null +++ b/js/core/alert.js @@ -0,0 +1,66 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + UI.component('alert', { + + defaults: { + "fade": true, + "duration": 200, + "trigger": ".uk-alert-close" + }, + + boot: function() { + + // init code + UI.$html.on("click.alert.uikit", "[data-uk-alert]", function(e) { + + var ele = UI.$(this); + + if (!ele.data("alert")) { + + var alert = UI.alert(ele, UI.Utils.options(ele.attr("data-uk-alert"))); + + if (UI.$(e.target).is(alert.options.trigger)) { + e.preventDefault(); + alert.close(); + } + } + }); + }, + + init: function() { + + var $this = this; + + this.on("click", this.options.trigger, function(e) { + e.preventDefault(); + $this.close(); + }); + }, + + close: function() { + + var element = this.trigger("close.uk.alert"), + removeElement = function () { + this.trigger("closed.uk.alert").remove(); + }.bind(this); + + if (this.options.fade) { + element.css("overflow", "hidden").css("max-height", element.height()).animate({ + "height" : 0, + "opacity" : 0, + "padding-top" : 0, + "padding-bottom" : 0, + "margin-top" : 0, + "margin-bottom" : 0 + }, this.options.duration, removeElement); + } else { + removeElement(); + } + } + + }); + +})(UIkit); diff --git a/js/core/alert.min.js b/js/core/alert.min.js new file mode 100755 index 0000000..501b85d --- /dev/null +++ b/js/core/alert.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";t.component("alert",{defaults:{fade:!0,duration:200,trigger:".uk-alert-close"},boot:function(){t.$html.on("click.alert.uikit","[data-uk-alert]",function(i){var o=t.$(this);if(!o.data("alert")){var e=t.alert(o,t.Utils.options(o.attr("data-uk-alert")));t.$(i.target).is(e.options.trigger)&&(i.preventDefault(),e.close())}})},init:function(){var t=this;this.on("click",this.options.trigger,function(i){i.preventDefault(),t.close()})},close:function(){var t=this.trigger("close.uk.alert"),i=function(){this.trigger("closed.uk.alert").remove()}.bind(this);this.options.fade?t.css("overflow","hidden").css("max-height",t.height()).animate({height:0,opacity:0,"padding-top":0,"padding-bottom":0,"margin-top":0,"margin-bottom":0},this.options.duration,i):i()}})}(UIkit); \ No newline at end of file diff --git a/js/core/button.js b/js/core/button.js new file mode 100755 index 0000000..9ebe57a --- /dev/null +++ b/js/core/button.js @@ -0,0 +1,157 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + UI.component('buttonRadio', { + + defaults: { + "activeClass": 'uk-active', + "target": ".uk-button" + }, + + boot: function() { + + // init code + UI.$html.on("click.buttonradio.uikit", "[data-uk-button-radio]", function(e) { + + var ele = UI.$(this); + + if (!ele.data("buttonRadio")) { + + var obj = UI.buttonRadio(ele, UI.Utils.options(ele.attr("data-uk-button-radio"))), + target = UI.$(e.target); + + if (target.is(obj.options.target)) { + target.trigger("click"); + } + } + }); + }, + + init: function() { + + var $this = this; + + // Init ARIA + this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true'); + + this.on("click", this.options.target, function(e) { + + var ele = UI.$(this); + + if (ele.is('a[href="#"]')) e.preventDefault(); + + $this.find($this.options.target).not(ele).removeClass($this.options.activeClass).blur(); + ele.addClass($this.options.activeClass); + + // Update ARIA + $this.find($this.options.target).not(ele).attr('aria-checked', 'false'); + ele.attr('aria-checked', 'true'); + + $this.trigger("change.uk.button", [ele]); + }); + + }, + + getSelected: function() { + return this.find('.' + this.options.activeClass); + } + }); + + UI.component('buttonCheckbox', { + + defaults: { + "activeClass": 'uk-active', + "target": ".uk-button" + }, + + boot: function() { + + UI.$html.on("click.buttoncheckbox.uikit", "[data-uk-button-checkbox]", function(e) { + var ele = UI.$(this); + + if (!ele.data("buttonCheckbox")) { + + var obj = UI.buttonCheckbox(ele, UI.Utils.options(ele.attr("data-uk-button-checkbox"))), + target = UI.$(e.target); + + if (target.is(obj.options.target)) { + target.trigger("click"); + } + } + }); + }, + + init: function() { + + var $this = this; + + // Init ARIA + this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true'); + + this.on("click", this.options.target, function(e) { + var ele = UI.$(this); + + if (ele.is('a[href="#"]')) e.preventDefault(); + + ele.toggleClass($this.options.activeClass).blur(); + + // Update ARIA + ele.attr('aria-checked', ele.hasClass($this.options.activeClass)); + + $this.trigger("change.uk.button", [ele]); + }); + + }, + + getSelected: function() { + return this.find('.' + this.options.activeClass); + } + }); + + + UI.component('button', { + + defaults: {}, + + boot: function() { + + UI.$html.on("click.button.uikit", "[data-uk-button]", function(e) { + var ele = UI.$(this); + + if (!ele.data("button")) { + + var obj = UI.button(ele, UI.Utils.options(ele.attr("data-uk-button"))); + ele.trigger("click"); + } + }); + }, + + init: function() { + + var $this = this; + + // Init ARIA + this.element.attr('aria-pressed', this.element.hasClass("uk-active")); + + this.on("click", function(e) { + + if ($this.element.is('a[href="#"]')) e.preventDefault(); + + $this.toggle(); + $this.trigger("change.uk.button", [$this.element.blur().hasClass("uk-active")]); + }); + + }, + + toggle: function() { + this.element.toggleClass("uk-active"); + + // Update ARIA + this.element.attr('aria-pressed', this.element.hasClass("uk-active")); + } + }); + +})(UIkit); + diff --git a/js/core/button.min.js b/js/core/button.min.js new file mode 100755 index 0000000..9458783 --- /dev/null +++ b/js/core/button.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";t.component("buttonRadio",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttonradio.uikit","[data-uk-button-radio]",function(i){var a=t.$(this);if(!a.data("buttonRadio")){var e=t.buttonRadio(a,t.Utils.options(a.attr("data-uk-button-radio"))),o=t.$(i.target);o.is(e.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(a){var e=t.$(this);e.is('a[href="#"]')&&a.preventDefault(),i.find(i.options.target).not(e).removeClass(i.options.activeClass).blur(),e.addClass(i.options.activeClass),i.find(i.options.target).not(e).attr("aria-checked","false"),e.attr("aria-checked","true"),i.trigger("change.uk.button",[e])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("buttonCheckbox",{defaults:{activeClass:"uk-active",target:".uk-button"},boot:function(){t.$html.on("click.buttoncheckbox.uikit","[data-uk-button-checkbox]",function(i){var a=t.$(this);if(!a.data("buttonCheckbox")){var e=t.buttonCheckbox(a,t.Utils.options(a.attr("data-uk-button-checkbox"))),o=t.$(i.target);o.is(e.options.target)&&o.trigger("click")}})},init:function(){var i=this;this.find(i.options.target).attr("aria-checked","false").filter("."+i.options.activeClass).attr("aria-checked","true"),this.on("click",this.options.target,function(a){var e=t.$(this);e.is('a[href="#"]')&&a.preventDefault(),e.toggleClass(i.options.activeClass).blur(),e.attr("aria-checked",e.hasClass(i.options.activeClass)),i.trigger("change.uk.button",[e])})},getSelected:function(){return this.find("."+this.options.activeClass)}}),t.component("button",{defaults:{},boot:function(){t.$html.on("click.button.uikit","[data-uk-button]",function(){var i=t.$(this);if(!i.data("button")){{t.button(i,t.Utils.options(i.attr("data-uk-button")))}i.trigger("click")}})},init:function(){var t=this;this.element.attr("aria-pressed",this.element.hasClass("uk-active")),this.on("click",function(i){t.element.is('a[href="#"]')&&i.preventDefault(),t.toggle(),t.trigger("change.uk.button",[t.element.blur().hasClass("uk-active")])})},toggle:function(){this.element.toggleClass("uk-active"),this.element.attr("aria-pressed",this.element.hasClass("uk-active"))}})}(UIkit); \ No newline at end of file diff --git a/js/core/core.js b/js/core/core.js new file mode 100755 index 0000000..85540af --- /dev/null +++ b/js/core/core.js @@ -0,0 +1,786 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(core) { + + if (typeof define == "function" && define.amd) { // AMD + + define("uikit", function(){ + + var uikit = window.UIkit || core(window, window.jQuery, window.document); + + uikit.load = function(res, req, onload, config) { + + var resources = res.split(','), load = [], i, base = (config.config && config.config.uikit && config.config.uikit.base ? config.config.uikit.base : "").replace(/\/+$/g, ""); + + if (!base) { + throw new Error( "Please define base path to UIkit in the requirejs config." ); + } + + for (i = 0; i < resources.length; i += 1) { + var resource = resources[i].replace(/\./g, '/'); + load.push(base+'/components/'+resource); + } + + req(load, function() { + onload(uikit); + }); + }; + + return uikit; + }); + } + + if (!window.jQuery) { + throw new Error( "UIkit requires jQuery" ); + } + + if (window && window.jQuery) { + core(window, window.jQuery, window.document); + } + + +})(function(global, $, doc) { + + "use strict"; + + var UI = {}, _UI = global.UIkit ? Object.create(global.UIkit) : undefined; + + UI.version = '2.26.4'; + + UI.noConflict = function() { + // restore UIkit version + if (_UI) { + global.UIkit = _UI; + $.UIkit = _UI; + $.fn.uk = _UI.fn; + } + + return UI; + }; + + UI.prefix = function(str) { + return str; + }; + + // cache jQuery + UI.$ = $; + + UI.$doc = UI.$(document); + UI.$win = UI.$(window); + UI.$html = UI.$('html'); + + UI.support = {}; + UI.support.transition = (function() { + + var transitionEnd = (function() { + + var element = doc.body || doc.documentElement, + transEndEventNames = { + WebkitTransition : 'webkitTransitionEnd', + MozTransition : 'transitionend', + OTransition : 'oTransitionEnd otransitionend', + transition : 'transitionend' + }, name; + + for (name in transEndEventNames) { + if (element.style[name] !== undefined) return transEndEventNames[name]; + } + }()); + + return transitionEnd && { end: transitionEnd }; + })(); + + UI.support.animation = (function() { + + var animationEnd = (function() { + + var element = doc.body || doc.documentElement, + animEndEventNames = { + WebkitAnimation : 'webkitAnimationEnd', + MozAnimation : 'animationend', + OAnimation : 'oAnimationEnd oanimationend', + animation : 'animationend' + }, name; + + for (name in animEndEventNames) { + if (element.style[name] !== undefined) return animEndEventNames[name]; + } + }()); + + return animationEnd && { end: animationEnd }; + })(); + + // requestAnimationFrame polyfill + //https://github.com/darius/requestAnimationFrame + (function() { + + Date.now = Date.now || function() { return new Date().getTime(); }; + + var vendors = ['webkit', 'moz']; + for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) { + var vp = vendors[i]; + window.requestAnimationFrame = window[vp+'RequestAnimationFrame']; + window.cancelAnimationFrame = (window[vp+'CancelAnimationFrame'] + || window[vp+'CancelRequestAnimationFrame']); + } + if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) // iOS6 is buggy + || !window.requestAnimationFrame || !window.cancelAnimationFrame) { + var lastTime = 0; + window.requestAnimationFrame = function(callback) { + var now = Date.now(); + var nextTime = Math.max(lastTime + 16, now); + return setTimeout(function() { callback(lastTime = nextTime); }, + nextTime - now); + }; + window.cancelAnimationFrame = clearTimeout; + } + }()); + + UI.support.touch = ( + ('ontouchstart' in document) || + (global.DocumentTouch && document instanceof global.DocumentTouch) || + (global.navigator.msPointerEnabled && global.navigator.msMaxTouchPoints > 0) || //IE 10 + (global.navigator.pointerEnabled && global.navigator.maxTouchPoints > 0) || //IE >=11 + false + ); + + UI.support.mutationobserver = (global.MutationObserver || global.WebKitMutationObserver || null); + + UI.Utils = {}; + + UI.Utils.isFullscreen = function() { + return document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement || document.fullscreenElement || false; + }; + + UI.Utils.str2json = function(str, notevil) { + try { + if (notevil) { + return JSON.parse(str + // wrap keys without quote with valid double quote + .replace(/([\$\w]+)\s*:/g, function(_, $1){return '"'+$1+'":';}) + // replacing single quote wrapped ones to double quote + .replace(/'([^']+)'/g, function(_, $1){return '"'+$1+'"';}) + ); + } else { + return (new Function("", "var json = " + str + "; return JSON.parse(JSON.stringify(json));"))(); + } + } catch(e) { return false; } + }; + + UI.Utils.debounce = function(func, wait, immediate) { + var timeout; + return function() { + var context = this, args = arguments; + var later = function() { + timeout = null; + if (!immediate) func.apply(context, args); + }; + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) func.apply(context, args); + }; + }; + + UI.Utils.throttle = function (func, limit) { + var wait = false; + return function () { + if (!wait) { + func.call(); + wait = true; + setTimeout(function () { + wait = false; + }, limit); + } + } + }; + + UI.Utils.removeCssRules = function(selectorRegEx) { + var idx, idxs, stylesheet, _i, _j, _k, _len, _len1, _len2, _ref; + + if(!selectorRegEx) return; + + setTimeout(function(){ + try { + _ref = document.styleSheets; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + stylesheet = _ref[_i]; + idxs = []; + stylesheet.cssRules = stylesheet.cssRules; + for (idx = _j = 0, _len1 = stylesheet.cssRules.length; _j < _len1; idx = ++_j) { + if (stylesheet.cssRules[idx].type === CSSRule.STYLE_RULE && selectorRegEx.test(stylesheet.cssRules[idx].selectorText)) { + idxs.unshift(idx); + } + } + for (_k = 0, _len2 = idxs.length; _k < _len2; _k++) { + stylesheet.deleteRule(idxs[_k]); + } + } + } catch (_error) {} + }, 0); + }; + + UI.Utils.isInView = function(element, options) { + + var $element = $(element); + + if (!$element.is(':visible')) { + return false; + } + + var window_left = UI.$win.scrollLeft(), window_top = UI.$win.scrollTop(), offset = $element.offset(), left = offset.left, top = offset.top; + + options = $.extend({topoffset:0, leftoffset:0}, options); + + if (top + $element.height() >= window_top && top - options.topoffset <= window_top + UI.$win.height() && + left + $element.width() >= window_left && left - options.leftoffset <= window_left + UI.$win.width()) { + return true; + } else { + return false; + } + }; + + UI.Utils.checkDisplay = function(context, initanimation) { + + var elements = UI.$('[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]', context || document), animated; + + if (context && !elements.length) { + elements = $(context); + } + + elements.trigger('display.uk.check'); + + // fix firefox / IE animations + if (initanimation) { + + if (typeof(initanimation)!='string') { + initanimation = '[class*="uk-animation-"]'; + } + + elements.find(initanimation).each(function(){ + + var ele = UI.$(this), + cls = ele.attr('class'), + anim = cls.match(/uk-animation-(.+)/); + + ele.removeClass(anim[0]).width(); + + ele.addClass(anim[0]); + }); + } + + return elements; + }; + + UI.Utils.options = function(string) { + + if ($.type(string)!='string') return string; + + if (string.indexOf(':') != -1 && string.trim().substr(-1) != '}') { + string = '{'+string+'}'; + } + + var start = (string ? string.indexOf("{") : -1), options = {}; + + if (start != -1) { + try { + options = UI.Utils.str2json(string.substr(start)); + } catch (e) {} + } + + return options; + }; + + UI.Utils.animate = function(element, cls) { + + var d = $.Deferred(); + + element = UI.$(element); + + element.css('display', 'none').addClass(cls).one(UI.support.animation.end, function() { + element.removeClass(cls); + d.resolve(); + }); + + element.css('display', ''); + + return d.promise(); + }; + + UI.Utils.uid = function(prefix) { + return (prefix || 'id') + (new Date().getTime())+"RAND"+(Math.ceil(Math.random() * 100000)); + }; + + UI.Utils.template = function(str, data) { + + var tokens = str.replace(/\n/g, '\\n').replace(/\{\{\{\s*(.+?)\s*\}\}\}/g, "{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g), + i=0, toc, cmd, prop, val, fn, output = [], openblocks = 0; + + while(i < tokens.length) { + + toc = tokens[i]; + + if(toc.match(/\{\{\s*(.+?)\s*\}\}/)) { + i = i + 1; + toc = tokens[i]; + cmd = toc[0]; + prop = toc.substring(toc.match(/^(\^|\#|\!|\~|\:)/) ? 1:0); + + switch(cmd) { + case '~': + output.push("for(var $i=0;$i<"+prop+".length;$i++) { var $item = "+prop+"[$i];"); + openblocks++; + break; + case ':': + output.push("for(var $key in "+prop+") { var $val = "+prop+"[$key];"); + openblocks++; + break; + case '#': + output.push("if("+prop+") {"); + openblocks++; + break; + case '^': + output.push("if(!"+prop+") {"); + openblocks++; + break; + case '/': + output.push("}"); + openblocks--; + break; + case '!': + output.push("__ret.push("+prop+");"); + break; + default: + output.push("__ret.push(escape("+prop+"));"); + break; + } + } else { + output.push("__ret.push('"+toc.replace(/\'/g, "\\'")+"');"); + } + i = i + 1; + } + + fn = new Function('$data', [ + 'var __ret = [];', + 'try {', + 'with($data){', (!openblocks ? output.join('') : '__ret = ["Not all blocks are closed correctly."]'), '};', + '}catch(e){__ret = [e.message];}', + 'return __ret.join("").replace(/\\n\\n/g, "\\n");', + "function escape(html) { return String(html).replace(/&/g, '&').replace(/\"/g, '"').replace(//g, '>');}" + ].join("\n")); + + return data ? fn(data) : fn; + }; + + UI.Utils.events = {}; + UI.Utils.events.click = UI.support.touch ? 'tap' : 'click'; + + global.UIkit = UI; + + // deprecated + + UI.fn = function(command, options) { + + var args = arguments, cmd = command.match(/^([a-z\-]+)(?:\.([a-z]+))?/i), component = cmd[1], method = cmd[2]; + + if (!UI[component]) { + $.error("UIkit component [" + component + "] does not exist."); + return this; + } + + return this.each(function() { + var $this = $(this), data = $this.data(component); + if (!data) $this.data(component, (data = UI[component](this, method ? undefined : options))); + if (method) data[method].apply(data, Array.prototype.slice.call(args, 1)); + }); + }; + + $.UIkit = UI; + $.fn.uk = UI.fn; + + UI.langdirection = UI.$html.attr("dir") == "rtl" ? "right" : "left"; + + UI.components = {}; + + UI.component = function(name, def) { + + var fn = function(element, options) { + + var $this = this; + + this.UIkit = UI; + this.element = element ? UI.$(element) : null; + this.options = $.extend(true, {}, this.defaults, options); + this.plugins = {}; + + if (this.element) { + this.element.data(name, this); + } + + this.init(); + + (this.options.plugins.length ? this.options.plugins : Object.keys(fn.plugins)).forEach(function(plugin) { + + if (fn.plugins[plugin].init) { + fn.plugins[plugin].init($this); + $this.plugins[plugin] = true; + } + + }); + + this.trigger('init.uk.component', [name, this]); + + return this; + }; + + fn.plugins = {}; + + $.extend(true, fn.prototype, { + + defaults : {plugins: []}, + + boot: function(){}, + init: function(){}, + + on: function(a1,a2,a3){ + return UI.$(this.element || this).on(a1,a2,a3); + }, + + one: function(a1,a2,a3){ + return UI.$(this.element || this).one(a1,a2,a3); + }, + + off: function(evt){ + return UI.$(this.element || this).off(evt); + }, + + trigger: function(evt, params) { + return UI.$(this.element || this).trigger(evt, params); + }, + + find: function(selector) { + return UI.$(this.element ? this.element: []).find(selector); + }, + + proxy: function(obj, methods) { + + var $this = this; + + methods.split(' ').forEach(function(method) { + if (!$this[method]) $this[method] = function() { return obj[method].apply(obj, arguments); }; + }); + }, + + mixin: function(obj, methods) { + + var $this = this; + + methods.split(' ').forEach(function(method) { + if (!$this[method]) $this[method] = obj[method].bind($this); + }); + }, + + option: function() { + + if (arguments.length == 1) { + return this.options[arguments[0]] || undefined; + } else if (arguments.length == 2) { + this.options[arguments[0]] = arguments[1]; + } + } + + }, def); + + this.components[name] = fn; + + this[name] = function() { + + var element, options; + + if (arguments.length) { + + switch(arguments.length) { + case 1: + + if (typeof arguments[0] === "string" || arguments[0].nodeType || arguments[0] instanceof jQuery) { + element = $(arguments[0]); + } else { + options = arguments[0]; + } + + break; + case 2: + + element = $(arguments[0]); + options = arguments[1]; + break; + } + } + + if (element && element.data(name)) { + return element.data(name); + } + + return (new UI.components[name](element, options)); + }; + + if (UI.domready) { + UI.component.boot(name); + } + + return fn; + }; + + UI.plugin = function(component, name, def) { + this.components[component].plugins[name] = def; + }; + + UI.component.boot = function(name) { + + if (UI.components[name].prototype && UI.components[name].prototype.boot && !UI.components[name].booted) { + UI.components[name].prototype.boot.apply(UI, []); + UI.components[name].booted = true; + } + }; + + UI.component.bootComponents = function() { + + for (var component in UI.components) { + UI.component.boot(component); + } + }; + + + // DOM mutation save ready helper function + + UI.domObservers = []; + UI.domready = false; + + UI.ready = function(fn) { + + UI.domObservers.push(fn); + + if (UI.domready) { + fn(document); + } + }; + + UI.on = function(a1,a2,a3){ + + if (a1 && a1.indexOf('ready.uk.dom') > -1 && UI.domready) { + a2.apply(UI.$doc); + } + + return UI.$doc.on(a1,a2,a3); + }; + + UI.one = function(a1,a2,a3){ + + if (a1 && a1.indexOf('ready.uk.dom') > -1 && UI.domready) { + a2.apply(UI.$doc); + return UI.$doc; + } + + return UI.$doc.one(a1,a2,a3); + }; + + UI.trigger = function(evt, params) { + return UI.$doc.trigger(evt, params); + }; + + UI.domObserve = function(selector, fn) { + + if(!UI.support.mutationobserver) return; + + fn = fn || function() {}; + + UI.$(selector).each(function() { + + var element = this, + $element = UI.$(element); + + if ($element.data('observer')) { + return; + } + + try { + + var observer = new UI.support.mutationobserver(UI.Utils.debounce(function(mutations) { + fn.apply(element, []); + $element.trigger('changed.uk.dom'); + }, 50), {childList: true, subtree: true}); + + // pass in the target node, as well as the observer options + observer.observe(element, { childList: true, subtree: true }); + + $element.data('observer', observer); + + } catch(e) {} + }); + }; + + UI.init = function(root) { + + root = root || document; + + UI.domObservers.forEach(function(fn){ + fn(root); + }); + }; + + UI.on('domready.uk.dom', function(){ + + UI.init(); + + if (UI.domready) UI.Utils.checkDisplay(); + }); + + document.addEventListener('DOMContentLoaded', function(){ + + var domReady = function() { + + UI.$body = UI.$('body'); + + UI.trigger('beforeready.uk.dom'); + + UI.component.bootComponents(); + + // custom scroll observer + var rafToken = requestAnimationFrame((function(){ + + var memory = {dir: {x:0, y:0}, x: window.pageXOffset, y:window.pageYOffset}; + + var fn = function(){ + // reading this (window.page[X|Y]Offset) causes a full page recalc of the layout in Chrome, + // so we only want to do this once + var wpxo = window.pageXOffset; + var wpyo = window.pageYOffset; + + // Did the scroll position change since the last time we were here? + if (memory.x != wpxo || memory.y != wpyo) { + + // Set the direction of the scroll and store the new position + if (wpxo != memory.x) {memory.dir.x = wpxo > memory.x ? 1:-1; } else { memory.dir.x = 0; } + if (wpyo != memory.y) {memory.dir.y = wpyo > memory.y ? 1:-1; } else { memory.dir.y = 0; } + + memory.x = wpxo; + memory.y = wpyo; + + // Trigger the scroll event, this could probably be sent using memory.clone() but this is + // more explicit and easier to see exactly what is being sent in the event. + UI.$doc.trigger('scrolling.uk.document', [{ + "dir": {"x": memory.dir.x, "y": memory.dir.y}, "x": wpxo, "y": wpyo + }]); + } + + cancelAnimationFrame(rafToken); + rafToken = requestAnimationFrame(fn); + }; + + if (UI.support.touch) { + UI.$html.on('touchmove touchend MSPointerMove MSPointerUp pointermove pointerup', fn); + } + + if (memory.x || memory.y) fn(); + + return fn; + + })()); + + // run component init functions on dom + UI.trigger('domready.uk.dom'); + + if (UI.support.touch) { + + // remove css hover rules for touch devices + // UI.Utils.removeCssRules(/\.uk-(?!navbar).*:hover/); + + // viewport unit fix for uk-height-viewport - should be fixed in iOS 8 + if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) { + + UI.$win.on('load orientationchange resize', UI.Utils.debounce((function(){ + + var fn = function() { + $('.uk-height-viewport').css('height', window.innerHeight); + return fn; + }; + + return fn(); + + })(), 100)); + } + } + + UI.trigger('afterready.uk.dom'); + + // mark that domready is left behind + UI.domready = true; + + // auto init js components + if (UI.support.mutationobserver) { + + var initFn = UI.Utils.debounce(function(){ + requestAnimationFrame(function(){ UI.init(document.body);}); + }, 10); + + (new UI.support.mutationobserver(function(mutations) { + + var init = false; + + mutations.every(function(mutation){ + + if (mutation.type != 'childList') return true; + + for (var i = 0, node; i < mutation.addedNodes.length; ++i) { + + node = mutation.addedNodes[i]; + + if (node.outerHTML && node.outerHTML.indexOf('data-uk-') !== -1) { + return (init = true) && false; + } + } + return true; + }); + + if (init) initFn(); + + })).observe(document.body, {childList: true, subtree: true}); + } + }; + + if (document.readyState == 'complete' || document.readyState == 'interactive') { + setTimeout(domReady); + } + + return domReady; + + }()); + + // add touch identifier class + UI.$html.addClass(UI.support.touch ? "uk-touch" : "uk-notouch"); + + // add uk-hover class on tap to support overlays on touch devices + if (UI.support.touch) { + + var hoverset = false, + exclude, + hovercls = 'uk-hover', + selector = '.uk-overlay, .uk-overlay-hover, .uk-overlay-toggle, .uk-animation-hover, .uk-has-hover'; + + UI.$html.on('mouseenter touchstart MSPointerDown pointerdown', selector, function() { + + if (hoverset) $('.'+hovercls).removeClass(hovercls); + + hoverset = $(this).addClass(hovercls); + + }).on('mouseleave touchend MSPointerUp pointerup', function(e) { + + exclude = $(e.target).parents(selector); + + if (hoverset) { + hoverset.not(exclude).removeClass(hovercls); + } + }); + } + + return UI; +}); diff --git a/js/core/core.min.js b/js/core/core.min.js new file mode 100755 index 0000000..07642d0 --- /dev/null +++ b/js/core/core.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){if("function"==typeof define&&define.amd&&define("uikit",function(){var n=window.UIkit||t(window,window.jQuery,window.document);return n.load=function(t,e,o,i){var r,a=t.split(","),s=[],u=(i.config&&i.config.uikit&&i.config.uikit.base?i.config.uikit.base:"").replace(/\/+$/g,"");if(!u)throw new Error("Please define base path to UIkit in the requirejs config.");for(r=0;r0||t.navigator.pointerEnabled&&t.navigator.maxTouchPoints>0||!1,o.support.mutationobserver=t.MutationObserver||t.WebKitMutationObserver||null,o.Utils={},o.Utils.isFullscreen=function(){return document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.fullscreenElement||!1},o.Utils.str2json=function(t,n){try{return n?JSON.parse(t.replace(/([\$\w]+)\s*:/g,function(t,n){return'"'+n+'":'}).replace(/'([^']+)'/g,function(t,n){return'"'+n+'"'})):new Function("","var json = "+t+"; return JSON.parse(JSON.stringify(json));")()}catch(e){return!1}},o.Utils.debounce=function(t,n,e){var o;return function(){var i=this,r=arguments,a=function(){o=null,e||t.apply(i,r)},s=e&&!o;clearTimeout(o),o=setTimeout(a,n),s&&t.apply(i,r)}},o.Utils.throttle=function(t,n){var e=!1;return function(){e||(t.call(),e=!0,setTimeout(function(){e=!1},n))}},o.Utils.removeCssRules=function(t){var n,e,o,i,r,a,s,u,c,d;t&&setTimeout(function(){try{for(d=document.styleSheets,i=0,s=d.length;s>i;i++){for(o=d[i],e=[],o.cssRules=o.cssRules,n=r=0,u=o.cssRules.length;u>r;n=++r)o.cssRules[n].type===CSSRule.STYLE_RULE&&t.test(o.cssRules[n].selectorText)&&e.unshift(n);for(a=0,c=e.length;c>a;a++)o.deleteRule(e[a])}}catch(l){}},0)},o.Utils.isInView=function(t,e){var i=n(t);if(!i.is(":visible"))return!1;var r=o.$win.scrollLeft(),a=o.$win.scrollTop(),s=i.offset(),u=s.left,c=s.top;return e=n.extend({topoffset:0,leftoffset:0},e),c+i.height()>=a&&c-e.topoffset<=a+o.$win.height()&&u+i.width()>=r&&u-e.leftoffset<=r+o.$win.width()?!0:!1},o.Utils.checkDisplay=function(t,e){var i=o.$("[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]",t||document);return t&&!i.length&&(i=n(t)),i.trigger("display.uk.check"),e&&("string"!=typeof e&&(e='[class*="uk-animation-"]'),i.find(e).each(function(){var t=o.$(this),n=t.attr("class"),e=n.match(/uk-animation-(.+)/);t.removeClass(e[0]).width(),t.addClass(e[0])})),i},o.Utils.options=function(t){if("string"!=n.type(t))return t;-1!=t.indexOf(":")&&"}"!=t.trim().substr(-1)&&(t="{"+t+"}");var e=t?t.indexOf("{"):-1,i={};if(-1!=e)try{i=o.Utils.str2json(t.substr(e))}catch(r){}return i},o.Utils.animate=function(t,e){var i=n.Deferred();return t=o.$(t),t.css("display","none").addClass(e).one(o.support.animation.end,function(){t.removeClass(e),i.resolve()}),t.css("display",""),i.promise()},o.Utils.uid=function(t){return(t||"id")+(new Date).getTime()+"RAND"+Math.ceil(1e5*Math.random())},o.Utils.template=function(t,n){for(var e,o,i,r,a=t.replace(/\n/g,"\\n").replace(/\{\{\{\s*(.+?)\s*\}\}\}/g,"{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g),s=0,u=[],c=0;s/g, '>');}"].join("\n")),n?r(n):r},o.Utils.events={},o.Utils.events.click=o.support.touch?"tap":"click",t.UIkit=o,o.fn=function(t,e){var i=arguments,r=t.match(/^([a-z\-]+)(?:\.([a-z]+))?/i),a=r[1],s=r[2];return o[a]?this.each(function(){var t=n(this),r=t.data(a);r||t.data(a,r=o[a](this,s?void 0:e)),s&&r[s].apply(r,Array.prototype.slice.call(i,1))}):(n.error("UIkit component ["+a+"] does not exist."),this)},n.UIkit=o,n.fn.uk=o.fn,o.langdirection="rtl"==o.$html.attr("dir")?"right":"left",o.components={},o.component=function(t,e){var i=function(e,r){var a=this;return this.UIkit=o,this.element=e?o.$(e):null,this.options=n.extend(!0,{},this.defaults,r),this.plugins={},this.element&&this.element.data(t,this),this.init(),(this.options.plugins.length?this.options.plugins:Object.keys(i.plugins)).forEach(function(t){i.plugins[t].init&&(i.plugins[t].init(a),a.plugins[t]=!0)}),this.trigger("init.uk.component",[t,this]),this};return i.plugins={},n.extend(!0,i.prototype,{defaults:{plugins:[]},boot:function(){},init:function(){},on:function(t,n,e){return o.$(this.element||this).on(t,n,e)},one:function(t,n,e){return o.$(this.element||this).one(t,n,e)},off:function(t){return o.$(this.element||this).off(t)},trigger:function(t,n){return o.$(this.element||this).trigger(t,n)},find:function(t){return o.$(this.element?this.element:[]).find(t)},proxy:function(t,n){var e=this;n.split(" ").forEach(function(n){e[n]||(e[n]=function(){return t[n].apply(t,arguments)})})},mixin:function(t,n){var e=this;n.split(" ").forEach(function(n){e[n]||(e[n]=t[n].bind(e))})},option:function(){return 1==arguments.length?this.options[arguments[0]]||void 0:(2==arguments.length&&(this.options[arguments[0]]=arguments[1]),void 0)}},e),this.components[t]=i,this[t]=function(){var e,i;if(arguments.length)switch(arguments.length){case 1:"string"==typeof arguments[0]||arguments[0].nodeType||arguments[0]instanceof jQuery?e=n(arguments[0]):i=arguments[0];break;case 2:e=n(arguments[0]),i=arguments[1]}return e&&e.data(t)?e.data(t):new o.components[t](e,i)},o.domready&&o.component.boot(t),i},o.plugin=function(t,n,e){this.components[t].plugins[n]=e},o.component.boot=function(t){o.components[t].prototype&&o.components[t].prototype.boot&&!o.components[t].booted&&(o.components[t].prototype.boot.apply(o,[]),o.components[t].booted=!0)},o.component.bootComponents=function(){for(var t in o.components)o.component.boot(t)},o.domObservers=[],o.domready=!1,o.ready=function(t){o.domObservers.push(t),o.domready&&t(document)},o.on=function(t,n,e){return t&&t.indexOf("ready.uk.dom")>-1&&o.domready&&n.apply(o.$doc),o.$doc.on(t,n,e)},o.one=function(t,n,e){return t&&t.indexOf("ready.uk.dom")>-1&&o.domready?(n.apply(o.$doc),o.$doc):o.$doc.one(t,n,e)},o.trigger=function(t,n){return o.$doc.trigger(t,n)},o.domObserve=function(t,n){o.support.mutationobserver&&(n=n||function(){},o.$(t).each(function(){var t=this,e=o.$(t);if(!e.data("observer"))try{var i=new o.support.mutationobserver(o.Utils.debounce(function(){n.apply(t,[]),e.trigger("changed.uk.dom")},50),{childList:!0,subtree:!0});i.observe(t,{childList:!0,subtree:!0}),e.data("observer",i)}catch(r){}}))},o.init=function(t){t=t||document,o.domObservers.forEach(function(n){n(t)})},o.on("domready.uk.dom",function(){o.init(),o.domready&&o.Utils.checkDisplay()}),document.addEventListener("DOMContentLoaded",function(){var t=function(){o.$body=o.$("body"),o.trigger("beforeready.uk.dom"),o.component.bootComponents();var t=requestAnimationFrame(function(){var n={dir:{x:0,y:0},x:window.pageXOffset,y:window.pageYOffset},e=function(){var i=window.pageXOffset,r=window.pageYOffset;(n.x!=i||n.y!=r)&&(n.dir.x=i!=n.x?i>n.x?1:-1:0,n.dir.y=r!=n.y?r>n.y?1:-1:0,n.x=i,n.y=r,o.$doc.trigger("scrolling.uk.document",[{dir:{x:n.dir.x,y:n.dir.y},x:i,y:r}])),cancelAnimationFrame(t),t=requestAnimationFrame(e)};return o.support.touch&&o.$html.on("touchmove touchend MSPointerMove MSPointerUp pointermove pointerup",e),(n.x||n.y)&&e(),e}());if(o.trigger("domready.uk.dom"),o.support.touch&&navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&o.$win.on("load orientationchange resize",o.Utils.debounce(function(){var t=function(){return n(".uk-height-viewport").css("height",window.innerHeight),t};return t()}(),100)),o.trigger("afterready.uk.dom"),o.domready=!0,o.support.mutationobserver){var e=o.Utils.debounce(function(){requestAnimationFrame(function(){o.init(document.body)})},10);new o.support.mutationobserver(function(t){var n=!1;t.every(function(t){if("childList"!=t.type)return!0;for(var e,o=0;o -1 ? '&':'?'), 'enablejsapi=1&api=1'].join('')); + } + }, + + check: function() { + + this.element.css({ + 'width' : '', + 'height' : '' + }); + + this.dimension = {w: this.element.width(), h: this.element.height()}; + + if (this.element.attr('width') && !isNaN(this.element.attr('width'))) { + this.dimension.w = this.element.attr('width'); + } + + if (this.element.attr('height') && !isNaN(this.element.attr('height'))) { + this.dimension.h = this.element.attr('height'); + } + + this.ratio = this.dimension.w / this.dimension.h; + + var w = this.parent.width(), h = this.parent.height(), width, height; + + // if element height < parent height (gap underneath) + if ((w / this.ratio) < h) { + + width = Math.ceil(h * this.ratio); + height = h; + + // element width < parent width (gap to right) + } else { + + width = w; + height = Math.ceil(w / this.ratio); + } + + this.element.css({ + 'width' : width, + 'height' : height + }); + } + }); + +})(UIkit); diff --git a/js/core/cover.min.js b/js/core/cover.min.js new file mode 100755 index 0000000..6bc18a9 --- /dev/null +++ b/js/core/cover.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";t.component("cover",{defaults:{automute:!0},boot:function(){t.ready(function(i){t.$("[data-uk-cover]",i).each(function(){var i=t.$(this);if(!i.data("cover")){t.cover(i,t.Utils.options(i.attr("data-uk-cover")))}})})},init:function(){if(this.parent=this.element.parent(),t.$win.on("load resize orientationchange",t.Utils.debounce(function(){this.check()}.bind(this),100)),this.on("display.uk.check",function(){this.element.is(":visible")&&this.check()}.bind(this)),this.check(),this.element.is("iframe")&&this.options.automute){var i=this.element.attr("src");this.element.attr("src","").on("load",function(){this.contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}',"*")}).attr("src",[i,i.indexOf("?")>-1?"&":"?","enablejsapi=1&api=1"].join(""))}},check:function(){this.element.css({width:"",height:""}),this.dimension={w:this.element.width(),h:this.element.height()},this.element.attr("width")&&!isNaN(this.element.attr("width"))&&(this.dimension.w=this.element.attr("width")),this.element.attr("height")&&!isNaN(this.element.attr("height"))&&(this.dimension.h=this.element.attr("height")),this.ratio=this.dimension.w/this.dimension.h;var t,i,e=this.parent.width(),n=this.parent.height();e/this.ratio boundarywidth) { + dropdown.addClass("uk-dropdown-stack"); + this.trigger('stack.uk.dropdown', [this]); + } + + dropdown.css(css).css("display", "").addClass('uk-dropdown-'+pp[0]); + }, + + checkBoundary: function(left, top, width, height, boundarywidth) { + + var axis = ""; + + if (left < 0 || ((left - UI.$win.scrollLeft())+width) > boundarywidth) { + axis += "x"; + } + + if ((top - UI.$win.scrollTop()) < 0 || ((top - UI.$win.scrollTop())+height) > window.innerHeight) { + axis += "y"; + } + + return axis; + } + }); + + + UI.component('dropdownOverlay', { + + defaults: { + 'justify' : false, + 'cls' : '', + 'duration': 200 + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-dropdown-overlay]", context).each(function() { + var ele = UI.$(this); + + if (!ele.data("dropdownOverlay")) { + UI.dropdownOverlay(ele, UI.Utils.options(ele.attr("data-uk-dropdown-overlay"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.justified = this.options.justify ? UI.$(this.options.justify) : false; + this.overlay = this.element.find('uk-dropdown-overlay'); + + if (!this.overlay.length) { + this.overlay = UI.$('
').appendTo(this.element); + } + + this.overlay.addClass(this.options.cls); + + this.on({ + + 'beforeshow.uk.dropdown': function(e, dropdown) { + $this.dropdown = dropdown; + + if ($this.justified && $this.justified.length) { + justify($this.overlay.css({'display':'block', 'margin-left':'','margin-right':''}), $this.justified, $this.justified.outerWidth()); + } + }, + + 'show.uk.dropdown': function(e, dropdown) { + + var h = $this.dropdown.dropdown.outerHeight(true); + + $this.dropdown.element.removeClass('uk-open'); + + $this.overlay.stop().css('display', 'block').animate({height: h}, $this.options.duration, function() { + + $this.dropdown.dropdown.css('visibility', ''); + $this.dropdown.element.addClass('uk-open'); + + UI.Utils.checkDisplay($this.dropdown.dropdown, true); + }); + + $this.pointerleave = false; + }, + + 'hide.uk.dropdown': function() { + $this.overlay.stop().animate({height: 0}, $this.options.duration); + }, + + 'pointerenter.uk.dropdown': function(e, dropdown) { + clearTimeout($this.remainIdle); + }, + + 'pointerleave.uk.dropdown': function(e, dropdown) { + $this.pointerleave = true; + } + }); + + + this.overlay.on({ + + 'mouseenter': function() { + if ($this.remainIdle) { + clearTimeout($this.dropdown.remainIdle); + clearTimeout($this.remainIdle); + } + }, + + 'mouseleave': function(){ + + if ($this.pointerleave && active) { + + $this.remainIdle = setTimeout(function() { + if(active) active.hide(); + }, active.options.remaintime); + } + } + }) + } + + }); + + + function justify(ele, justifyTo, boundarywidth, offset) { + + ele = UI.$(ele); + justifyTo = UI.$(justifyTo); + boundarywidth = boundarywidth || window.innerWidth; + offset = offset || ele.offset(); + + if (justifyTo.length) { + + var jwidth = justifyTo.outerWidth(); + + ele.css("min-width", jwidth); + + if (UI.langdirection == 'right') { + + var right1 = boundarywidth - (justifyTo.offset().left + jwidth), + right2 = boundarywidth - (ele.offset().left + ele.outerWidth()); + + ele.css("margin-right", right1 - right2); + + } else { + ele.css("margin-left", justifyTo.offset().left - offset.left); + } + } + } + +})(UIkit); diff --git a/js/core/dropdown.min.js b/js/core/dropdown.min.js new file mode 100755 index 0000000..410c82e --- /dev/null +++ b/js/core/dropdown.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function o(o,e,i,n){if(o=t.$(o),e=t.$(e),i=i||window.innerWidth,n=n||o.offset(),e.length){var r=e.outerWidth();if(o.css("min-width",r),"right"==t.langdirection){var s=i-(e.offset().left+r),d=i-(o.offset().left+o.outerWidth());o.css("margin-right",s-d)}else o.css("margin-left",e.offset().left-n.left)}}var e,i=!1,n={x:{"bottom-left":"bottom-right","bottom-right":"bottom-left","bottom-center":"bottom-center","top-left":"top-right","top-right":"top-left","top-center":"top-center","left-top":"right-top","left-bottom":"right-bottom","left-center":"right-center","right-top":"left-top","right-bottom":"left-bottom","right-center":"left-center"},y:{"bottom-left":"top-left","bottom-right":"top-right","bottom-center":"top-center","top-left":"bottom-left","top-right":"bottom-right","top-center":"bottom-center","left-top":"left-bottom","left-bottom":"left-top","left-center":"left-center","right-top":"right-bottom","right-bottom":"right-top","right-center":"right-center"},xy:{"bottom-left":"top-right","bottom-right":"top-left","bottom-center":"top-center","top-left":"bottom-right","top-right":"bottom-left","top-center":"bottom-center","left-top":"right-bottom","left-bottom":"right-top","left-center":"right-center","right-top":"left-bottom","right-bottom":"left-top","right-center":"left-center"}};t.component("dropdown",{defaults:{mode:"hover",pos:"bottom-left",offset:0,remaintime:800,justify:!1,boundary:t.$win,delay:0,dropdownSelector:".uk-dropdown,.uk-dropdown-blank",hoverDelayIdle:250,preventflip:!1},remainIdle:!1,boot:function(){var o=t.support.touch?"click":"mouseenter";t.$html.on(o+".dropdown.uikit","[data-uk-dropdown]",function(e){var i=t.$(this);if(!i.data("dropdown")){var n=t.dropdown(i,t.Utils.options(i.attr("data-uk-dropdown")));("click"==o||"mouseenter"==o&&"hover"==n.options.mode)&&n.element.trigger(o),n.element.find(n.options.dropdownSelector).length&&e.preventDefault()}})},init:function(){var o=this;this.dropdown=this.find(this.options.dropdownSelector),this.offsetParent=this.dropdown.parents().filter(function(){return-1!==t.$.inArray(t.$(this).css("position"),["relative","fixed","absolute"])}).slice(0,1),this.centered=this.dropdown.hasClass("uk-dropdown-center"),this.justified=this.options.justify?t.$(this.options.justify):!1,this.boundary=t.$(this.options.boundary),this.boundary.length||(this.boundary=t.$win),this.dropdown.hasClass("uk-dropdown-up")&&(this.options.pos="top-left"),this.dropdown.hasClass("uk-dropdown-flip")&&(this.options.pos=this.options.pos.replace("left","right")),this.dropdown.hasClass("uk-dropdown-center")&&(this.options.pos=this.options.pos.replace(/(left|right)/,"center")),this.element.attr("aria-haspopup","true"),this.element.attr("aria-expanded",this.element.hasClass("uk-open")),"click"==this.options.mode||t.support.touch?this.on("click.uk.dropdown",function(e){var i=t.$(e.target);i.parents(o.options.dropdownSelector).length||((i.is("a[href='#']")||i.parent().is("a[href='#']")||o.dropdown.length&&!o.dropdown.is(":visible"))&&e.preventDefault(),i.blur()),o.element.hasClass("uk-open")?(!o.dropdown.find(e.target).length||i.is(".uk-dropdown-close")||i.parents(".uk-dropdown-close").length)&&o.hide():o.show()}):this.on("mouseenter",function(){o.trigger("pointerenter.uk.dropdown",[o]),o.remainIdle&&clearTimeout(o.remainIdle),e&&clearTimeout(e),i&&i==o||(e=i&&i!=o?setTimeout(function(){e=setTimeout(o.show.bind(o),o.options.delay)},o.options.hoverDelayIdle):setTimeout(o.show.bind(o),o.options.delay))}).on("mouseleave",function(){e&&clearTimeout(e),o.remainIdle=setTimeout(function(){i&&i==o&&o.hide()},o.options.remaintime),o.trigger("pointerleave.uk.dropdown",[o])}).on("click",function(e){var n=t.$(e.target);return o.remainIdle&&clearTimeout(o.remainIdle),i&&i==o?((!o.dropdown.find(e.target).length||n.is(".uk-dropdown-close")||n.parents(".uk-dropdown-close").length)&&o.hide(),void 0):((n.is("a[href='#']")||n.parent().is("a[href='#']"))&&e.preventDefault(),o.show(),void 0)})},show:function(){t.$html.off("click.outer.dropdown"),i&&i!=this&&i.hide(!0),e&&clearTimeout(e),this.trigger("beforeshow.uk.dropdown",[this]),this.checkDimensions(),this.element.addClass("uk-open"),this.element.attr("aria-expanded","true"),this.trigger("show.uk.dropdown",[this]),t.Utils.checkDisplay(this.dropdown,!0),i=this,this.registerOuterClick()},hide:function(t){this.trigger("beforehide.uk.dropdown",[this,t]),this.element.removeClass("uk-open"),this.remainIdle&&clearTimeout(this.remainIdle),this.remainIdle=!1,this.element.attr("aria-expanded","false"),this.trigger("hide.uk.dropdown",[this,t]),i==this&&(i=!1)},registerOuterClick:function(){var o=this;t.$html.off("click.outer.dropdown"),setTimeout(function(){t.$html.on("click.outer.dropdown",function(n){e&&clearTimeout(e);t.$(n.target);i!=o||o.element.find(n.target).length||(o.hide(!0),t.$html.off("click.outer.dropdown"))})},10)},checkDimensions:function(){if(this.dropdown.length){this.dropdown.removeClass("uk-dropdown-top uk-dropdown-bottom uk-dropdown-left uk-dropdown-right uk-dropdown-stack").css({"top-left":"",left:"","margin-left":"","margin-right":""}),this.justified&&this.justified.length&&this.dropdown.css("min-width","");var e,i=t.$.extend({},this.offsetParent.offset(),{width:this.offsetParent[0].offsetWidth,height:this.offsetParent[0].offsetHeight}),r=this.options.offset,s=this.dropdown,d=(s.show().offset()||{left:0,top:0},s.outerWidth()),h=s.outerHeight(),l=this.boundary.width(),p=(this.boundary[0]!==window&&this.boundary.offset()?this.boundary.offset():{top:0,left:0},this.options.pos),a={"bottom-left":{top:0+i.height+r,left:0},"bottom-right":{top:0+i.height+r,left:0+i.width-d},"bottom-center":{top:0+i.height+r,left:0+i.width/2-d/2},"top-left":{top:0-h-r,left:0},"top-right":{top:0-h-r,left:0+i.width-d},"top-center":{top:0-h-r,left:0+i.width/2-d/2},"left-top":{top:0,left:0-d-r},"left-bottom":{top:0+i.height-h,left:0-d-r},"left-center":{top:0+i.height/2-h/2,left:0-d-r},"right-top":{top:0,left:0+i.width+r},"right-bottom":{top:0+i.height-h,left:0+i.width+r},"right-center":{top:0+i.height/2-h/2,left:0+i.width+r}},f={};if(e=p.split("-"),f=a[p]?a[p]:a["bottom-left"],this.justified&&this.justified.length)o(s.css({left:0}),this.justified,l);else if(this.options.preventflip!==!0){var u;switch(this.checkBoundary(i.left+f.left,i.top+f.top,d,h,l)){case"x":"x"!==this.options.preventflip&&(u=n.x[p]||"right-top");break;case"y":"y"!==this.options.preventflip&&(u=n.y[p]||"top-left");break;case"xy":this.options.preventflip||(u=n.xy[p]||"right-bottom")}u&&(e=u.split("-"),f=a[u]?a[u]:a["bottom-left"],this.checkBoundary(i.left+f.left,i.top+f.top,d,h,l)&&(e=p.split("-"),f=a[p]?a[p]:a["bottom-left"]))}d>l&&(s.addClass("uk-dropdown-stack"),this.trigger("stack.uk.dropdown",[this])),s.css(f).css("display","").addClass("uk-dropdown-"+e[0])}},checkBoundary:function(o,e,i,n,r){var s="";return(0>o||o-t.$win.scrollLeft()+i>r)&&(s+="x"),(e-t.$win.scrollTop()<0||e-t.$win.scrollTop()+n>window.innerHeight)&&(s+="y"),s}}),t.component("dropdownOverlay",{defaults:{justify:!1,cls:"",duration:200},boot:function(){t.ready(function(o){t.$("[data-uk-dropdown-overlay]",o).each(function(){var o=t.$(this);o.data("dropdownOverlay")||t.dropdownOverlay(o,t.Utils.options(o.attr("data-uk-dropdown-overlay")))})})},init:function(){var e=this;this.justified=this.options.justify?t.$(this.options.justify):!1,this.overlay=this.element.find("uk-dropdown-overlay"),this.overlay.length||(this.overlay=t.$('
').appendTo(this.element)),this.overlay.addClass(this.options.cls),this.on({"beforeshow.uk.dropdown":function(t,i){e.dropdown=i,e.justified&&e.justified.length&&o(e.overlay.css({display:"block","margin-left":"","margin-right":""}),e.justified,e.justified.outerWidth())},"show.uk.dropdown":function(){var o=e.dropdown.dropdown.outerHeight(!0);e.dropdown.element.removeClass("uk-open"),e.overlay.stop().css("display","block").animate({height:o},e.options.duration,function(){e.dropdown.dropdown.css("visibility",""),e.dropdown.element.addClass("uk-open"),t.Utils.checkDisplay(e.dropdown.dropdown,!0)}),e.pointerleave=!1},"hide.uk.dropdown":function(){e.overlay.stop().animate({height:0},e.options.duration)},"pointerenter.uk.dropdown":function(){clearTimeout(e.remainIdle)},"pointerleave.uk.dropdown":function(){e.pointerleave=!0}}),this.overlay.on({mouseenter:function(){e.remainIdle&&(clearTimeout(e.dropdown.remainIdle),clearTimeout(e.remainIdle))},mouseleave:function(){e.pointerleave&&i&&(e.remainIdle=setTimeout(function(){i&&i.hide()},i.options.remaintime))}})}})}(UIkit); \ No newline at end of file diff --git a/js/core/grid.js b/js/core/grid.js new file mode 100755 index 0000000..2552f93 --- /dev/null +++ b/js/core/grid.js @@ -0,0 +1,117 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + var grids = []; + + UI.component('gridMatchHeight', { + + defaults: { + "target" : false, + "row" : true, + "ignorestacked" : false, + "observe" : false + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-grid-match]", context).each(function() { + var grid = UI.$(this), obj; + + if (!grid.data("gridMatchHeight")) { + obj = UI.gridMatchHeight(grid, UI.Utils.options(grid.attr("data-uk-grid-match"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.columns = this.element.children(); + this.elements = this.options.target ? this.find(this.options.target) : this.columns; + + if (!this.columns.length) return; + + UI.$win.on('load resize orientationchange', (function() { + + var fn = function() { + if ($this.element.is(":visible")) $this.match(); + }; + + UI.$(function() { fn(); }); + + return UI.Utils.debounce(fn, 50); + })()); + + if (this.options.observe) { + + UI.domObserve(this.element, function(e) { + if ($this.element.is(":visible")) $this.match(); + }); + } + + this.on("display.uk.check", function(e) { + if(this.element.is(":visible")) this.match(); + }.bind(this)); + + grids.push(this); + }, + + match: function() { + + var firstvisible = this.columns.filter(":visible:first"); + + if (!firstvisible.length) return; + + var stacked = Math.ceil(100 * parseFloat(firstvisible.css('width')) / parseFloat(firstvisible.parent().css('width'))) >= 100; + + if (stacked && !this.options.ignorestacked) { + this.revert(); + } else { + UI.Utils.matchHeights(this.elements, this.options); + } + + return this; + }, + + revert: function() { + this.elements.css('min-height', ''); + return this; + } + }); + + UI.component('gridMargin', { + + defaults: { + cls : 'uk-grid-margin', + rowfirst : 'uk-row-first' + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-grid-margin]", context).each(function() { + var grid = UI.$(this), obj; + + if (!grid.data("gridMargin")) { + obj = UI.gridMargin(grid, UI.Utils.options(grid.attr("data-uk-grid-margin"))); + } + }); + }); + }, + + init: function() { + + var stackMargin = UI.stackMargin(this.element, this.options); + } + }); + +})(UIkit); diff --git a/js/core/grid.min.js b/js/core/grid.min.js new file mode 100755 index 0000000..fe52a52 --- /dev/null +++ b/js/core/grid.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";var i=[];t.component("gridMatchHeight",{defaults:{target:!1,row:!0,ignorestacked:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-grid-match]",i).each(function(){var i,n=t.$(this);n.data("gridMatchHeight")||(i=t.gridMatchHeight(n,t.Utils.options(n.attr("data-uk-grid-match"))))})})},init:function(){var n=this;this.columns=this.element.children(),this.elements=this.options.target?this.find(this.options.target):this.columns,this.columns.length&&(t.$win.on("load resize orientationchange",function(){var i=function(){n.element.is(":visible")&&n.match()};return t.$(function(){i()}),t.Utils.debounce(i,50)}()),this.options.observe&&t.domObserve(this.element,function(){n.element.is(":visible")&&n.match()}),this.on("display.uk.check",function(){this.element.is(":visible")&&this.match()}.bind(this)),i.push(this))},match:function(){var i=this.columns.filter(":visible:first");if(i.length){var n=Math.ceil(100*parseFloat(i.css("width"))/parseFloat(i.parent().css("width")))>=100;return n&&!this.options.ignorestacked?this.revert():t.Utils.matchHeights(this.elements,this.options),this}},revert:function(){return this.elements.css("min-height",""),this}}),t.component("gridMargin",{defaults:{cls:"uk-grid-margin",rowfirst:"uk-row-first"},boot:function(){t.ready(function(i){t.$("[data-uk-grid-margin]",i).each(function(){var i,n=t.$(this);n.data("gridMargin")||(i=t.gridMargin(n,t.Utils.options(n.attr("data-uk-grid-margin"))))})})},init:function(){t.stackMargin(this.element,this.options)}})}(UIkit); \ No newline at end of file diff --git a/js/core/modal.js b/js/core/modal.js new file mode 100755 index 0000000..74d122d --- /dev/null +++ b/js/core/modal.js @@ -0,0 +1,393 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + var active = false, activeCount = 0, $html = UI.$html, body; + + UI.$win.on("resize orientationchange", UI.Utils.debounce(function(){ + UI.$('.uk-modal.uk-open').each(function(){ + UI.$(this).data('modal').resize(); + }); + }, 150)); + + UI.component('modal', { + + defaults: { + keyboard: true, + bgclose: true, + minScrollHeight: 150, + center: false, + modal: true + }, + + scrollable: false, + transition: false, + hasTransitioned: true, + + init: function() { + + if (!body) body = UI.$('body'); + + if (!this.element.length) return; + + var $this = this; + + this.paddingdir = "padding-" + (UI.langdirection == 'left' ? "right":"left"); + this.dialog = this.find(".uk-modal-dialog"); + + this.active = false; + + // Update ARIA + this.element.attr('aria-hidden', this.element.hasClass("uk-open")); + + this.on("click", ".uk-modal-close", function(e) { + e.preventDefault(); + $this.hide(); + }).on("click", function(e) { + + var target = UI.$(e.target); + + if (target[0] == $this.element[0] && $this.options.bgclose) { + $this.hide(); + } + }); + + UI.domObserve(this.element, function(e) { $this.resize(); }); + }, + + toggle: function() { + return this[this.isActive() ? "hide" : "show"](); + }, + + show: function() { + + if (!this.element.length) return; + + var $this = this; + + if (this.isActive()) return; + + if (this.options.modal && active) { + active.hide(true); + } + + this.element.removeClass("uk-open").show(); + this.resize(true); + + if (this.options.modal) { + active = this; + } + + this.active = true; + + activeCount++; + + if (UI.support.transition) { + this.hasTransitioned = false; + this.element.one(UI.support.transition.end, function(){ + $this.hasTransitioned = true; + }).addClass("uk-open"); + } else { + this.element.addClass("uk-open"); + } + + $html.addClass("uk-modal-page").height(); // force browser engine redraw + + // Update ARIA + this.element.attr('aria-hidden', 'false'); + + this.element.trigger("show.uk.modal"); + + UI.Utils.checkDisplay(this.dialog, true); + + return this; + }, + + hide: function(force) { + + if (!force && UI.support.transition && this.hasTransitioned) { + + var $this = this; + + this.one(UI.support.transition.end, function() { + $this._hide(); + }).removeClass("uk-open"); + + } else { + + this._hide(); + } + + return this; + }, + + resize: function(force) { + + if (!this.isActive() && !force) return; + + var bodywidth = body.width(); + + this.scrollbarwidth = window.innerWidth - bodywidth; + + body.css(this.paddingdir, this.scrollbarwidth); + + this.element.css('overflow-y', this.scrollbarwidth ? 'scroll' : 'auto'); + + if (!this.updateScrollable() && this.options.center) { + + var dh = this.dialog.outerHeight(), + pad = parseInt(this.dialog.css('margin-top'), 10) + parseInt(this.dialog.css('margin-bottom'), 10); + + if ((dh + pad) < window.innerHeight) { + this.dialog.css({'top': (window.innerHeight/2 - dh/2) - pad }); + } else { + this.dialog.css({'top': ''}); + } + } + }, + + updateScrollable: function() { + + // has scrollable? + var scrollable = this.dialog.find('.uk-overflow-container:visible:first'); + + if (scrollable.length) { + + scrollable.css('height', 0); + + var offset = Math.abs(parseInt(this.dialog.css('margin-top'), 10)), + dh = this.dialog.outerHeight(), + wh = window.innerHeight, + h = wh - 2*(offset < 20 ? 20:offset) - dh; + + scrollable.css({ + 'max-height': (h < this.options.minScrollHeight ? '':h), + 'height':'' + }); + + return true; + } + + return false; + }, + + _hide: function() { + + this.active = false; + if (activeCount > 0) activeCount--; + else activeCount = 0; + + this.element.hide().removeClass('uk-open'); + + // Update ARIA + this.element.attr('aria-hidden', 'true'); + + if (!activeCount) { + $html.removeClass('uk-modal-page'); + body.css(this.paddingdir, ""); + } + + if (active===this) active = false; + + this.trigger('hide.uk.modal'); + }, + + isActive: function() { + return this.element.hasClass('uk-open'); + } + + }); + + UI.component('modalTrigger', { + + boot: function() { + + // init code + UI.$html.on("click.modal.uikit", "[data-uk-modal]", function(e) { + + var ele = UI.$(this); + + if (ele.is("a")) { + e.preventDefault(); + } + + if (!ele.data("modalTrigger")) { + var modal = UI.modalTrigger(ele, UI.Utils.options(ele.attr("data-uk-modal"))); + modal.show(); + } + + }); + + // close modal on esc button + UI.$html.on('keydown.modal.uikit', function (e) { + + if (active && e.keyCode === 27 && active.options.keyboard) { // ESC + e.preventDefault(); + active.hide(); + } + }); + }, + + init: function() { + + var $this = this; + + this.options = UI.$.extend({ + "target": $this.element.is("a") ? $this.element.attr("href") : false + }, this.options); + + this.modal = UI.modal(this.options.target, this.options); + + this.on("click", function(e) { + e.preventDefault(); + $this.show(); + }); + + //methods + this.proxy(this.modal, "show hide isActive"); + } + }); + + UI.modal.dialog = function(content, options) { + + var modal = UI.modal(UI.$(UI.modal.dialog.template).appendTo("body"), options); + + modal.on("hide.uk.modal", function(){ + if (modal.persist) { + modal.persist.appendTo(modal.persist.data("modalPersistParent")); + modal.persist = false; + } + modal.element.remove(); + }); + + setContent(content, modal); + + return modal; + }; + + UI.modal.dialog.template = '
'; + + UI.modal.alert = function(content, options) { + + options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options); + + var modal = UI.modal.dialog(([ + '
'+String(content)+'
', + '' + ]).join(""), options); + + modal.on('show.uk.modal', function(){ + setTimeout(function(){ + modal.element.find('button:first').focus(); + }, 50); + }); + + return modal.show(); + }; + + UI.modal.confirm = function(content, onconfirm, oncancel) { + + var options = arguments.length > 1 && arguments[arguments.length-1] ? arguments[arguments.length-1] : {}; + + onconfirm = UI.$.isFunction(onconfirm) ? onconfirm : function(){}; + oncancel = UI.$.isFunction(oncancel) ? oncancel : function(){}; + options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, UI.$.isFunction(options) ? {}:options); + + var modal = UI.modal.dialog(([ + '
'+String(content)+'
', + '' + ]).join(""), options); + + modal.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click", function(){ + UI.$(this).is('.js-modal-confirm') ? onconfirm() : oncancel(); + modal.hide(); + }); + + modal.on('show.uk.modal', function(){ + setTimeout(function(){ + modal.element.find('.js-modal-confirm').focus(); + }, 50); + }); + + return modal.show(); + }; + + UI.modal.prompt = function(text, value, onsubmit, options) { + + onsubmit = UI.$.isFunction(onsubmit) ? onsubmit : function(value){}; + options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options); + + var modal = UI.modal.dialog(([ + text ? '
'+String(text)+'
':'', + '

', + '' + ]).join(""), options), + + input = modal.element.find("input[type='text']").val(value || '').on('keyup', function(e){ + if (e.keyCode == 13) { + modal.element.find(".js-modal-ok").trigger('click'); + } + }); + + modal.element.find(".js-modal-ok").on("click", function(){ + if (onsubmit(input.val())!==false){ + modal.hide(); + } + }); + + modal.on('show.uk.modal', function(){ + setTimeout(function(){ + input.focus(); + }, 50); + }); + + return modal.show(); + }; + + UI.modal.blockUI = function(content, options) { + + var modal = UI.modal.dialog(([ + '
'+String(content || '
...
')+'
' + ]).join(""), UI.$.extend({bgclose:false, keyboard:false, modal:false}, options)); + + modal.content = modal.element.find('.uk-modal-content:first'); + + return modal.show(); + }; + + + UI.modal.labels = { + 'Ok': 'Ok', + 'Cancel': 'Cancel' + }; + + + // helper functions + function setContent(content, modal){ + + if(!modal) return; + + if (typeof content === 'object') { + + // convert DOM object to a jQuery object + content = content instanceof jQuery ? content : UI.$(content); + + if(content.parent().length) { + modal.persist = content; + modal.persist.data("modalPersistParent", content.parent()); + } + }else if (typeof content === 'string' || typeof content === 'number') { + // just insert the data as innerHTML + content = UI.$('
').html(content); + }else { + // unsupported data type! + content = UI.$('
').html('UIkit.modal Error: Unsupported data type: ' + typeof content); + } + + content.appendTo(modal.element.find('.uk-modal-dialog')); + + return modal; + } + +})(UIkit); diff --git a/js/core/modal.min.js b/js/core/modal.min.js new file mode 100755 index 0000000..6dc903a --- /dev/null +++ b/js/core/modal.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function i(i,e){return e?("object"==typeof i?(i=i instanceof jQuery?i:t.$(i),i.parent().length&&(e.persist=i,e.persist.data("modalPersistParent",i.parent()))):i="string"==typeof i||"number"==typeof i?t.$("
").html(i):t.$("
").html("UIkit.modal Error: Unsupported data type: "+typeof i),i.appendTo(e.element.find(".uk-modal-dialog")),e):void 0}var e,o=!1,n=0,s=t.$html;t.$win.on("resize orientationchange",t.Utils.debounce(function(){t.$(".uk-modal.uk-open").each(function(){t.$(this).data("modal").resize()})},150)),t.component("modal",{defaults:{keyboard:!0,bgclose:!0,minScrollHeight:150,center:!1,modal:!0},scrollable:!1,transition:!1,hasTransitioned:!0,init:function(){if(e||(e=t.$("body")),this.element.length){var i=this;this.paddingdir="padding-"+("left"==t.langdirection?"right":"left"),this.dialog=this.find(".uk-modal-dialog"),this.active=!1,this.element.attr("aria-hidden",this.element.hasClass("uk-open")),this.on("click",".uk-modal-close",function(t){t.preventDefault(),i.hide()}).on("click",function(e){var o=t.$(e.target);o[0]==i.element[0]&&i.options.bgclose&&i.hide()}),t.domObserve(this.element,function(){i.resize()})}},toggle:function(){return this[this.isActive()?"hide":"show"]()},show:function(){if(this.element.length){var i=this;if(!this.isActive())return this.options.modal&&o&&o.hide(!0),this.element.removeClass("uk-open").show(),this.resize(!0),this.options.modal&&(o=this),this.active=!0,n++,t.support.transition?(this.hasTransitioned=!1,this.element.one(t.support.transition.end,function(){i.hasTransitioned=!0}).addClass("uk-open")):this.element.addClass("uk-open"),s.addClass("uk-modal-page").height(),this.element.attr("aria-hidden","false"),this.element.trigger("show.uk.modal"),t.Utils.checkDisplay(this.dialog,!0),this}},hide:function(i){if(!i&&t.support.transition&&this.hasTransitioned){var e=this;this.one(t.support.transition.end,function(){e._hide()}).removeClass("uk-open")}else this._hide();return this},resize:function(t){if(this.isActive()||t){var i=e.width();if(this.scrollbarwidth=window.innerWidth-i,e.css(this.paddingdir,this.scrollbarwidth),this.element.css("overflow-y",this.scrollbarwidth?"scroll":"auto"),!this.updateScrollable()&&this.options.center){var o=this.dialog.outerHeight(),n=parseInt(this.dialog.css("margin-top"),10)+parseInt(this.dialog.css("margin-bottom"),10);o+ni?20:i)-e;return t.css({"max-height":n0?n--:n=0,this.element.hide().removeClass("uk-open"),this.element.attr("aria-hidden","true"),n||(s.removeClass("uk-modal-page"),e.css(this.paddingdir,"")),o===this&&(o=!1),this.trigger("hide.uk.modal")},isActive:function(){return this.element.hasClass("uk-open")}}),t.component("modalTrigger",{boot:function(){t.$html.on("click.modal.uikit","[data-uk-modal]",function(i){var e=t.$(this);if(e.is("a")&&i.preventDefault(),!e.data("modalTrigger")){var o=t.modalTrigger(e,t.Utils.options(e.attr("data-uk-modal")));o.show()}}),t.$html.on("keydown.modal.uikit",function(t){o&&27===t.keyCode&&o.options.keyboard&&(t.preventDefault(),o.hide())})},init:function(){var i=this;this.options=t.$.extend({target:i.element.is("a")?i.element.attr("href"):!1},this.options),this.modal=t.modal(this.options.target,this.options),this.on("click",function(t){t.preventDefault(),i.show()}),this.proxy(this.modal,"show hide isActive")}}),t.modal.dialog=function(e,o){var n=t.modal(t.$(t.modal.dialog.template).appendTo("body"),o);return n.on("hide.uk.modal",function(){n.persist&&(n.persist.appendTo(n.persist.data("modalPersistParent")),n.persist=!1),n.element.remove()}),i(e,n),n},t.modal.dialog.template='
',t.modal.alert=function(i,e){e=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},e);var o=t.modal.dialog(['
'+String(i)+"
",'"].join(""),e);return o.on("show.uk.modal",function(){setTimeout(function(){o.element.find("button:first").focus()},50)}),o.show()},t.modal.confirm=function(i,e,o){var n=arguments.length>1&&arguments[arguments.length-1]?arguments[arguments.length-1]:{};e=t.$.isFunction(e)?e:function(){},o=t.$.isFunction(o)?o:function(){},n=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},t.$.isFunction(n)?{}:n);var s=t.modal.dialog(['
'+String(i)+"
",'"].join(""),n);return s.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click",function(){t.$(this).is(".js-modal-confirm")?e():o(),s.hide()}),s.on("show.uk.modal",function(){setTimeout(function(){s.element.find(".js-modal-confirm").focus()},50)}),s.show()},t.modal.prompt=function(i,e,o,n){o=t.$.isFunction(o)?o:function(){},n=t.$.extend(!0,{bgclose:!1,keyboard:!1,modal:!1,labels:t.modal.labels},n);var s=t.modal.dialog([i?'
'+String(i)+"
":"",'

','"].join(""),n),a=s.element.find("input[type='text']").val(e||"").on("keyup",function(t){13==t.keyCode&&s.element.find(".js-modal-ok").trigger("click")});return s.element.find(".js-modal-ok").on("click",function(){o(a.val())!==!1&&s.hide()}),s.on("show.uk.modal",function(){setTimeout(function(){a.focus()},50)}),s.show()},t.modal.blockUI=function(i,e){var o=t.modal.dialog(['
'+String(i||'
...
')+"
"].join(""),t.$.extend({bgclose:!1,keyboard:!1,modal:!1},e));return o.content=o.element.find(".uk-modal-content:first"),o.show()},t.modal.labels={Ok:"Ok",Cancel:"Cancel"}}(UIkit); \ No newline at end of file diff --git a/js/core/nav.js b/js/core/nav.js new file mode 100755 index 0000000..a6157ab --- /dev/null +++ b/js/core/nav.js @@ -0,0 +1,136 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + UI.component('nav', { + + defaults: { + "toggle": ">li.uk-parent > a[href='#']", + "lists": ">li.uk-parent > ul", + "multiple": false + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-nav]", context).each(function() { + var nav = UI.$(this); + + if (!nav.data("nav")) { + var obj = UI.nav(nav, UI.Utils.options(nav.attr("data-uk-nav"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.on("click.uk.nav", this.options.toggle, function(e) { + e.preventDefault(); + var ele = UI.$(this); + $this.open(ele.parent()[0] == $this.element[0] ? ele : ele.parent("li")); + }); + + this.find(this.options.lists).each(function() { + var $ele = UI.$(this), + parent = $ele.parent(), + active = parent.hasClass("uk-active"); + + $ele.wrap('
'); + parent.data("list-container", $ele.parent()[active ? 'removeClass':'addClass']('uk-hidden')); + + // Init ARIA + parent.attr('aria-expanded', parent.hasClass("uk-open")); + + if (active) $this.open(parent, true); + }); + + }, + + open: function(li, noanimation) { + + var $this = this, element = this.element, $li = UI.$(li), $container = $li.data('list-container'); + + if (!this.options.multiple) { + + element.children('.uk-open').not(li).each(function() { + + var ele = UI.$(this); + + if (ele.data('list-container')) { + ele.data('list-container').stop().animate({height: 0}, function() { + UI.$(this).parent().removeClass('uk-open').end().addClass('uk-hidden'); + }); + } + }); + } + + $li.toggleClass('uk-open'); + + // Update ARIA + $li.attr('aria-expanded', $li.hasClass('uk-open')); + + if ($container) { + + if ($li.hasClass('uk-open')) { + $container.removeClass('uk-hidden'); + } + + if (noanimation) { + + $container.stop().height($li.hasClass('uk-open') ? 'auto' : 0); + + if (!$li.hasClass('uk-open')) { + $container.addClass('uk-hidden'); + } + + this.trigger('display.uk.check'); + + } else { + + $container.stop().animate({ + height: ($li.hasClass('uk-open') ? getHeight($container.find('ul:first')) : 0) + }, function() { + + if (!$li.hasClass('uk-open')) { + $container.addClass('uk-hidden'); + } else { + $container.css('height', ''); + } + + $this.trigger('display.uk.check'); + }); + } + } + } + }); + + + // helper + + function getHeight(ele) { + var $ele = UI.$(ele), height = "auto"; + + if ($ele.is(":visible")) { + height = $ele.outerHeight(); + } else { + var tmp = { + position: $ele.css("position"), + visibility: $ele.css("visibility"), + display: $ele.css("display") + }; + + height = $ele.css({position: 'absolute', visibility: 'hidden', display: 'block'}).outerHeight(); + + $ele.css(tmp); // reset element + } + + return height; + } + +})(UIkit); diff --git a/js/core/nav.min.js b/js/core/nav.min.js new file mode 100755 index 0000000..3ee579c --- /dev/null +++ b/js/core/nav.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(i){"use strict";function t(t){var s=i.$(t),a="auto";if(s.is(":visible"))a=s.outerHeight();else{var e={position:s.css("position"),visibility:s.css("visibility"),display:s.css("display")};a=s.css({position:"absolute",visibility:"hidden",display:"block"}).outerHeight(),s.css(e)}return a}i.component("nav",{defaults:{toggle:">li.uk-parent > a[href='#']",lists:">li.uk-parent > ul",multiple:!1},boot:function(){i.ready(function(t){i.$("[data-uk-nav]",t).each(function(){var t=i.$(this);if(!t.data("nav")){i.nav(t,i.Utils.options(t.attr("data-uk-nav")))}})})},init:function(){var t=this;this.on("click.uk.nav",this.options.toggle,function(s){s.preventDefault();var a=i.$(this);t.open(a.parent()[0]==t.element[0]?a:a.parent("li"))}),this.find(this.options.lists).each(function(){var s=i.$(this),a=s.parent(),e=a.hasClass("uk-active");s.wrap('
'),a.data("list-container",s.parent()[e?"removeClass":"addClass"]("uk-hidden")),a.attr("aria-expanded",a.hasClass("uk-open")),e&&t.open(a,!0)})},open:function(s,a){var e=this,n=this.element,o=i.$(s),l=o.data("list-container");this.options.multiple||n.children(".uk-open").not(s).each(function(){var t=i.$(this);t.data("list-container")&&t.data("list-container").stop().animate({height:0},function(){i.$(this).parent().removeClass("uk-open").end().addClass("uk-hidden")})}),o.toggleClass("uk-open"),o.attr("aria-expanded",o.hasClass("uk-open")),l&&(o.hasClass("uk-open")&&l.removeClass("uk-hidden"),a?(l.stop().height(o.hasClass("uk-open")?"auto":0),o.hasClass("uk-open")||l.addClass("uk-hidden"),this.trigger("display.uk.check")):l.stop().animate({height:o.hasClass("uk-open")?t(l.find("ul:first")):0},function(){o.hasClass("uk-open")?l.css("height",""):l.addClass("uk-hidden"),e.trigger("display.uk.check")}))}})}(UIkit); \ No newline at end of file diff --git a/js/core/offcanvas.js b/js/core/offcanvas.js new file mode 100755 index 0000000..9b2c289 --- /dev/null +++ b/js/core/offcanvas.js @@ -0,0 +1,180 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + var scrollpos = {x: window.scrollX, y: window.scrollY}, + $win = UI.$win, + $doc = UI.$doc, + $html = UI.$html, + Offcanvas = { + + show: function(element) { + + element = UI.$(element); + + if (!element.length) return; + + var $body = UI.$('body'), + bar = element.find(".uk-offcanvas-bar:first"), + rtl = (UI.langdirection == "right"), + flip = bar.hasClass("uk-offcanvas-bar-flip") ? -1:1, + dir = flip * (rtl ? -1 : 1), + + scrollbarwidth = window.innerWidth - $body.width(); + + scrollpos = {x: window.pageXOffset, y: window.pageYOffset}; + + element.addClass("uk-active"); + + $body.css({"width": window.innerWidth - scrollbarwidth, "height": window.innerHeight}).addClass("uk-offcanvas-page"); + $body.css((rtl ? "margin-right" : "margin-left"), (rtl ? -1 : 1) * (bar.outerWidth() * dir)).width(); // .width() - force redraw + + $html.css('margin-top', scrollpos.y * -1); + + bar.addClass("uk-offcanvas-bar-show"); + + this._initElement(element); + + bar.trigger('show.uk.offcanvas', [element, bar]); + + // Update ARIA + element.attr('aria-hidden', 'false'); + }, + + hide: function(force) { + + var $body = UI.$('body'), + panel = UI.$(".uk-offcanvas.uk-active"), + rtl = (UI.langdirection == "right"), + bar = panel.find(".uk-offcanvas-bar:first"), + finalize = function() { + $body.removeClass("uk-offcanvas-page").css({"width": "", "height": "", "margin-left": "", "margin-right": ""}); + panel.removeClass("uk-active"); + + bar.removeClass("uk-offcanvas-bar-show"); + $html.css('margin-top', ''); + window.scrollTo(scrollpos.x, scrollpos.y); + bar.trigger('hide.uk.offcanvas', [panel, bar]); + + // Update ARIA + panel.attr('aria-hidden', 'true'); + }; + + if (!panel.length) return; + + if (UI.support.transition && !force) { + + $body.one(UI.support.transition.end, function() { + finalize(); + }).css((rtl ? "margin-right" : "margin-left"), ""); + + setTimeout(function(){ + bar.removeClass("uk-offcanvas-bar-show"); + }, 0); + + } else { + finalize(); + } + }, + + _initElement: function(element) { + + if (element.data("OffcanvasInit")) return; + + element.on("click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas", function(e) { + + var target = UI.$(e.target); + + if (!e.type.match(/swipe/)) { + + if (!target.hasClass("uk-offcanvas-close")) { + if (target.hasClass("uk-offcanvas-bar")) return; + if (target.parents(".uk-offcanvas-bar:first").length) return; + } + } + + e.stopImmediatePropagation(); + Offcanvas.hide(); + }); + + element.on("click", "a[href*='#']", function(e){ + + var link = UI.$(this), + href = link.attr("href"); + + if (href == "#") { + return; + } + + UI.$doc.one('hide.uk.offcanvas', function() { + + var target; + + try { + target = UI.$(link[0].hash); + } catch (e){ + target = ''; + } + + if (!target.length) { + target = UI.$('[name="'+link[0].hash.replace('#','')+'"]'); + } + + if (target.length && UI.Utils.scrollToElement) { + UI.Utils.scrollToElement(target, UI.Utils.options(link.attr('data-uk-smooth-scroll') || '{}')); + } else { + window.location.href = href; + } + }); + + Offcanvas.hide(); + }); + + element.data("OffcanvasInit", true); + } + }; + + UI.component('offcanvasTrigger', { + + boot: function() { + + // init code + $html.on("click.offcanvas.uikit", "[data-uk-offcanvas]", function(e) { + + e.preventDefault(); + + var ele = UI.$(this); + + if (!ele.data("offcanvasTrigger")) { + var obj = UI.offcanvasTrigger(ele, UI.Utils.options(ele.attr("data-uk-offcanvas"))); + ele.trigger("click"); + } + }); + + $html.on('keydown.uk.offcanvas', function(e) { + + if (e.keyCode === 27) { // ESC + Offcanvas.hide(); + } + }); + }, + + init: function() { + + var $this = this; + + this.options = UI.$.extend({ + "target": $this.element.is("a") ? $this.element.attr("href") : false + }, this.options); + + this.on("click", function(e) { + e.preventDefault(); + Offcanvas.show($this.options.target); + }); + } + }); + + UI.offcanvas = Offcanvas; + +})(UIkit); diff --git a/js/core/offcanvas.min.js b/js/core/offcanvas.min.js new file mode 100755 index 0000000..faa3887 --- /dev/null +++ b/js/core/offcanvas.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(a){"use strict";var t={x:window.scrollX,y:window.scrollY},n=(a.$win,a.$doc,a.$html),i={show:function(i){if(i=a.$(i),i.length){var o=a.$("body"),s=i.find(".uk-offcanvas-bar:first"),e="right"==a.langdirection,f=s.hasClass("uk-offcanvas-bar-flip")?-1:1,r=f*(e?-1:1),c=window.innerWidth-o.width();t={x:window.pageXOffset,y:window.pageYOffset},i.addClass("uk-active"),o.css({width:window.innerWidth-c,height:window.innerHeight}).addClass("uk-offcanvas-page"),o.css(e?"margin-right":"margin-left",(e?-1:1)*s.outerWidth()*r).width(),n.css("margin-top",-1*t.y),s.addClass("uk-offcanvas-bar-show"),this._initElement(i),s.trigger("show.uk.offcanvas",[i,s]),i.attr("aria-hidden","false")}},hide:function(i){var o=a.$("body"),s=a.$(".uk-offcanvas.uk-active"),e="right"==a.langdirection,f=s.find(".uk-offcanvas-bar:first"),r=function(){o.removeClass("uk-offcanvas-page").css({width:"",height:"","margin-left":"","margin-right":""}),s.removeClass("uk-active"),f.removeClass("uk-offcanvas-bar-show"),n.css("margin-top",""),window.scrollTo(t.x,t.y),f.trigger("hide.uk.offcanvas",[s,f]),s.attr("aria-hidden","true")};s.length&&(a.support.transition&&!i?(o.one(a.support.transition.end,function(){r()}).css(e?"margin-right":"margin-left",""),setTimeout(function(){f.removeClass("uk-offcanvas-bar-show")},0)):r())},_initElement:function(t){t.data("OffcanvasInit")||(t.on("click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas",function(t){var n=a.$(t.target);if(!t.type.match(/swipe/)&&!n.hasClass("uk-offcanvas-close")){if(n.hasClass("uk-offcanvas-bar"))return;if(n.parents(".uk-offcanvas-bar:first").length)return}t.stopImmediatePropagation(),i.hide()}),t.on("click","a[href*='#']",function(){var t=a.$(this),n=t.attr("href");"#"!=n&&(a.$doc.one("hide.uk.offcanvas",function(){var i;try{i=a.$(t[0].hash)}catch(o){i=""}i.length||(i=a.$('[name="'+t[0].hash.replace("#","")+'"]')),i.length&&a.Utils.scrollToElement?a.Utils.scrollToElement(i,a.Utils.options(t.attr("data-uk-smooth-scroll")||"{}")):window.location.href=n}),i.hide())}),t.data("OffcanvasInit",!0))}};a.component("offcanvasTrigger",{boot:function(){n.on("click.offcanvas.uikit","[data-uk-offcanvas]",function(t){t.preventDefault();var n=a.$(this);if(!n.data("offcanvasTrigger")){{a.offcanvasTrigger(n,a.Utils.options(n.attr("data-uk-offcanvas")))}n.trigger("click")}}),n.on("keydown.uk.offcanvas",function(a){27===a.keyCode&&i.hide()})},init:function(){var t=this;this.options=a.$.extend({target:t.element.is("a")?t.element.attr("href"):!1},this.options),this.on("click",function(a){a.preventDefault(),i.show(t.options.target)})}}),a.offcanvas=i}(UIkit); \ No newline at end of file diff --git a/js/core/scrollspy.js b/js/core/scrollspy.js new file mode 100755 index 0000000..a67e2c8 --- /dev/null +++ b/js/core/scrollspy.js @@ -0,0 +1,209 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + var $win = UI.$win, + $doc = UI.$doc, + scrollspies = [], + checkScrollSpy = function() { + for(var i=0; i < scrollspies.length; i++) { + window.requestAnimationFrame.apply(window, [scrollspies[i].check]); + } + }; + + UI.component('scrollspy', { + + defaults: { + "target" : false, + "cls" : "uk-scrollspy-inview", + "initcls" : "uk-scrollspy-init-inview", + "topoffset" : 0, + "leftoffset" : 0, + "repeat" : false, + "delay" : 0 + }, + + boot: function() { + + // listen to scroll and resize + $doc.on("scrolling.uk.document", checkScrollSpy); + $win.on("load resize orientationchange", UI.Utils.debounce(checkScrollSpy, 50)); + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-scrollspy]", context).each(function() { + + var element = UI.$(this); + + if (!element.data("scrollspy")) { + var obj = UI.scrollspy(element, UI.Utils.options(element.attr("data-uk-scrollspy"))); + } + }); + }); + }, + + init: function() { + + var $this = this, inviewstate, initinview, togglecls = this.options.cls.split(/,/), fn = function(){ + + var elements = $this.options.target ? $this.element.find($this.options.target) : $this.element, + delayIdx = elements.length === 1 ? 1 : 0, + toggleclsIdx = 0; + + elements.each(function(idx){ + + var element = UI.$(this), + inviewstate = element.data('inviewstate'), + inview = UI.Utils.isInView(element, $this.options), + toggle = element.data('ukScrollspyCls') || togglecls[toggleclsIdx].trim(); + + if (inview && !inviewstate && !element.data('scrollspy-idle')) { + + if (!initinview) { + element.addClass($this.options.initcls); + $this.offset = element.offset(); + initinview = true; + + element.trigger("init.uk.scrollspy"); + } + + element.data('scrollspy-idle', setTimeout(function(){ + + element.addClass("uk-scrollspy-inview").toggleClass(toggle).width(); + element.trigger("inview.uk.scrollspy"); + + element.data('scrollspy-idle', false); + element.data('inviewstate', true); + + }, $this.options.delay * delayIdx)); + + delayIdx++; + } + + if (!inview && inviewstate && $this.options.repeat) { + + if (element.data('scrollspy-idle')) { + clearTimeout(element.data('scrollspy-idle')); + element.data('scrollspy-idle', false); + } + + element.removeClass("uk-scrollspy-inview").toggleClass(toggle); + element.data('inviewstate', false); + + element.trigger("outview.uk.scrollspy"); + } + + toggleclsIdx = togglecls[toggleclsIdx + 1] ? (toggleclsIdx + 1) : 0; + + }); + }; + + fn(); + + this.check = fn; + + scrollspies.push(this); + } + }); + + + var scrollspynavs = [], + checkScrollSpyNavs = function() { + for(var i=0; i < scrollspynavs.length; i++) { + window.requestAnimationFrame.apply(window, [scrollspynavs[i].check]); + } + }; + + UI.component('scrollspynav', { + + defaults: { + "cls" : 'uk-active', + "closest" : false, + "topoffset" : 0, + "leftoffset" : 0, + "smoothscroll" : false + }, + + boot: function() { + + // listen to scroll and resize + $doc.on("scrolling.uk.document", checkScrollSpyNavs); + $win.on("resize orientationchange", UI.Utils.debounce(checkScrollSpyNavs, 50)); + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-scrollspy-nav]", context).each(function() { + + var element = UI.$(this); + + if (!element.data("scrollspynav")) { + var obj = UI.scrollspynav(element, UI.Utils.options(element.attr("data-uk-scrollspy-nav"))); + } + }); + }); + }, + + init: function() { + + var ids = [], + links = this.find("a[href^='#']").each(function(){ if(this.getAttribute("href").trim()!=='#') ids.push(this.getAttribute("href")); }), + targets = UI.$(ids.join(",")), + + clsActive = this.options.cls, + clsClosest = this.options.closest || this.options.closest; + + var $this = this, inviews, fn = function(){ + + inviews = []; + + for (var i=0 ; i < targets.length ; i++) { + if (UI.Utils.isInView(targets.eq(i), $this.options)) { + inviews.push(targets.eq(i)); + } + } + + if (inviews.length) { + + var navitems, + scrollTop = $win.scrollTop(), + target = (function(){ + for(var i=0; i< inviews.length;i++){ + if (inviews[i].offset().top - $this.options.topoffset >= scrollTop){ + return inviews[i]; + } + } + })(); + + if (!target) return; + + if ($this.options.closest) { + links.blur().closest(clsClosest).removeClass(clsActive); + navitems = links.filter("a[href='#"+target.attr("id")+"']").closest(clsClosest).addClass(clsActive); + } else { + navitems = links.removeClass(clsActive).filter("a[href='#"+target.attr("id")+"']").addClass(clsActive); + } + + $this.element.trigger("inview.uk.scrollspynav", [target, navitems]); + } + }; + + if (this.options.smoothscroll && UI.smoothScroll) { + links.each(function(){ + UI.smoothScroll(this, $this.options.smoothscroll); + }); + } + + fn(); + + this.element.data("scrollspynav", this); + + this.check = fn; + scrollspynavs.push(this); + + } + }); + +})(UIkit); diff --git a/js/core/scrollspy.min.js b/js/core/scrollspy.min.js new file mode 100755 index 0000000..74d651b --- /dev/null +++ b/js/core/scrollspy.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";var s=t.$win,o=t.$doc,i=[],e=function(){for(var t=0;t=p)return o[t]}();if(!f)return;c.options.closest?(e.blur().closest(r).removeClass(a),l=e.filter("a[href='#"+f.attr("id")+"']").closest(r).addClass(a)):l=e.removeClass(a).filter("a[href='#"+f.attr("id")+"']").addClass(a),c.element.trigger("inview.uk.scrollspynav",[f,l])}};this.options.smoothscroll&&t.smoothScroll&&e.each(function(){t.smoothScroll(this,c.options.smoothscroll)}),p(),this.element.data("scrollspynav",this),this.check=p,l.push(this)}})}(UIkit); \ No newline at end of file diff --git a/js/core/smooth-scroll.js b/js/core/smooth-scroll.js new file mode 100755 index 0000000..789e426 --- /dev/null +++ b/js/core/smooth-scroll.js @@ -0,0 +1,62 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + UI.component('smoothScroll', { + + boot: function() { + + // init code + UI.$html.on("click.smooth-scroll.uikit", "[data-uk-smooth-scroll]", function(e) { + var ele = UI.$(this); + + if (!ele.data("smoothScroll")) { + var obj = UI.smoothScroll(ele, UI.Utils.options(ele.attr("data-uk-smooth-scroll"))); + ele.trigger("click"); + } + + return false; + }); + }, + + init: function() { + + var $this = this; + + this.on("click", function(e) { + e.preventDefault(); + scrollToElement(UI.$(this.hash).length ? UI.$(this.hash) : UI.$("body"), $this.options); + }); + } + }); + + function scrollToElement(ele, options) { + + options = UI.$.extend({ + duration: 1000, + transition: 'easeOutExpo', + offset: 0, + complete: function(){} + }, options); + + // get / set parameters + var target = ele.offset().top - options.offset, + docheight = UI.$doc.height(), + winheight = window.innerHeight; + + if ((target + winheight) > docheight) { + target = docheight - winheight; + } + + // animate to target, fire callback when done + UI.$("html,body").stop().animate({scrollTop: target}, options.duration, options.transition).promise().done(options.complete); + } + + UI.Utils.scrollToElement = scrollToElement; + + if (!UI.$.easing.easeOutExpo) { + UI.$.easing.easeOutExpo = function(x, t, b, c, d) { return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; }; + } + +})(UIkit); diff --git a/js/core/smooth-scroll.min.js b/js/core/smooth-scroll.min.js new file mode 100755 index 0000000..5968d4e --- /dev/null +++ b/js/core/smooth-scroll.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function o(o,i){i=t.$.extend({duration:1e3,transition:"easeOutExpo",offset:0,complete:function(){}},i);var n=o.offset().top-i.offset,s=t.$doc.height(),e=window.innerHeight;n+e>s&&(n=s-e),t.$("html,body").stop().animate({scrollTop:n},i.duration,i.transition).promise().done(i.complete)}t.component("smoothScroll",{boot:function(){t.$html.on("click.smooth-scroll.uikit","[data-uk-smooth-scroll]",function(){var o=t.$(this);if(!o.data("smoothScroll")){{t.smoothScroll(o,t.Utils.options(o.attr("data-uk-smooth-scroll")))}o.trigger("click")}return!1})},init:function(){var i=this;this.on("click",function(n){n.preventDefault(),o(t.$(this.hash).length?t.$(this.hash):t.$("body"),i.options)})}}),t.Utils.scrollToElement=o,t.$.easing.easeOutExpo||(t.$.easing.easeOutExpo=function(t,o,i,n,s){return o==s?i+n:n*(-Math.pow(2,-10*o/s)+1)+i})}(UIkit); \ No newline at end of file diff --git a/js/core/switcher.js b/js/core/switcher.js new file mode 100755 index 0000000..793eb3c --- /dev/null +++ b/js/core/switcher.js @@ -0,0 +1,307 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + var Animations; + + UI.component('switcher', { + + defaults: { + connect : false, + toggle : ">*", + active : 0, + animation : false, + duration : 200, + swiping : true + }, + + animating: false, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-switcher]", context).each(function() { + var switcher = UI.$(this); + + if (!switcher.data("switcher")) { + var obj = UI.switcher(switcher, UI.Utils.options(switcher.attr("data-uk-switcher"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.on("click.uk.switcher", this.options.toggle, function(e) { + e.preventDefault(); + $this.show(this); + }); + + if (this.options.connect) { + + this.connect = UI.$(this.options.connect); + + this.connect.children().removeClass("uk-active"); + + // delegate switch commands within container content + if (this.connect.length) { + + // Init ARIA for connect + this.connect.children().attr('aria-hidden', 'true'); + + this.connect.on("click", '[data-uk-switcher-item]', function(e) { + + e.preventDefault(); + + var item = UI.$(this).attr('data-uk-switcher-item'); + + if ($this.index == item) return; + + switch(item) { + case 'next': + case 'previous': + $this.show($this.index + (item=='next' ? 1:-1)); + break; + default: + $this.show(parseInt(item, 10)); + } + }); + + if (this.options.swiping) { + + this.connect.on('swipeRight swipeLeft', function(e) { + e.preventDefault(); + if(!window.getSelection().toString()) { + $this.show($this.index + (e.type == 'swipeLeft' ? 1 : -1)); + } + }); + } + } + + var toggles = this.find(this.options.toggle), + active = toggles.filter(".uk-active"); + + if (active.length) { + this.show(active, false); + } else { + + if (this.options.active===false) return; + + active = toggles.eq(this.options.active); + this.show(active.length ? active : toggles.eq(0), false); + } + + // Init ARIA for toggles + toggles.not(active).attr('aria-expanded', 'false'); + active.attr('aria-expanded', 'true'); + } + + }, + + show: function(tab, animate) { + + if (this.animating) { + return; + } + + if (isNaN(tab)) { + tab = UI.$(tab); + } else { + + var toggles = this.find(this.options.toggle); + + tab = tab < 0 ? toggles.length-1 : tab; + tab = toggles.eq(toggles[tab] ? tab : 0); + } + + var $this = this, + toggles = this.find(this.options.toggle), + active = UI.$(tab), + animation = Animations[this.options.animation] || function(current, next) { + + if (!$this.options.animation) { + return Animations.none.apply($this); + } + + var anim = $this.options.animation.split(','); + + if (anim.length == 1) { + anim[1] = anim[0]; + } + + anim[0] = anim[0].trim(); + anim[1] = anim[1].trim(); + + return coreAnimation.apply($this, [anim, current, next]); + }; + + if (animate===false || !UI.support.animation) { + animation = Animations.none; + } + + if (active.hasClass("uk-disabled")) return; + + // Update ARIA for Toggles + toggles.attr('aria-expanded', 'false'); + active.attr('aria-expanded', 'true'); + + toggles.filter(".uk-active").removeClass("uk-active"); + active.addClass("uk-active"); + + if (this.options.connect && this.connect.length) { + + this.index = this.find(this.options.toggle).index(active); + + if (this.index == -1 ) { + this.index = 0; + } + + this.connect.each(function() { + + var container = UI.$(this), + children = UI.$(container.children()), + current = UI.$(children.filter('.uk-active')), + next = UI.$(children.eq($this.index)); + + $this.animating = true; + + animation.apply($this, [current, next]).then(function(){ + + current.removeClass("uk-active"); + next.addClass("uk-active"); + + // Update ARIA for connect + current.attr('aria-hidden', 'true'); + next.attr('aria-hidden', 'false'); + + UI.Utils.checkDisplay(next, true); + + $this.animating = false; + + }); + }); + } + + this.trigger("show.uk.switcher", [active]); + } + }); + + Animations = { + + 'none': function() { + var d = UI.$.Deferred(); + d.resolve(); + return d.promise(); + }, + + 'fade': function(current, next) { + return coreAnimation.apply(this, ['uk-animation-fade', current, next]); + }, + + 'slide-bottom': function(current, next) { + return coreAnimation.apply(this, ['uk-animation-slide-bottom', current, next]); + }, + + 'slide-top': function(current, next) { + return coreAnimation.apply(this, ['uk-animation-slide-top', current, next]); + }, + + 'slide-vertical': function(current, next, dir) { + + var anim = ['uk-animation-slide-top', 'uk-animation-slide-bottom']; + + if (current && current.index() > next.index()) { + anim.reverse(); + } + + return coreAnimation.apply(this, [anim, current, next]); + }, + + 'slide-left': function(current, next) { + return coreAnimation.apply(this, ['uk-animation-slide-left', current, next]); + }, + + 'slide-right': function(current, next) { + return coreAnimation.apply(this, ['uk-animation-slide-right', current, next]); + }, + + 'slide-horizontal': function(current, next, dir) { + + var anim = ['uk-animation-slide-right', 'uk-animation-slide-left']; + + if (current && current.index() > next.index()) { + anim.reverse(); + } + + return coreAnimation.apply(this, [anim, current, next]); + }, + + 'scale': function(current, next) { + return coreAnimation.apply(this, ['uk-animation-scale-up', current, next]); + } + }; + + UI.switcher.animations = Animations; + + + // helpers + + function coreAnimation(cls, current, next) { + + var d = UI.$.Deferred(), clsIn = cls, clsOut = cls, release; + + if (next[0]===current[0]) { + d.resolve(); + return d.promise(); + } + + if (typeof(cls) == 'object') { + clsIn = cls[0]; + clsOut = cls[1] || cls[0]; + } + + UI.$body.css('overflow-x', 'hidden'); // fix scroll jumping in iOS + + release = function() { + + if (current) current.hide().removeClass('uk-active '+clsOut+' uk-animation-reverse'); + + next.addClass(clsIn).one(UI.support.animation.end, function() { + + setTimeout(function () { + next.removeClass(''+clsIn+'').css({opacity:'', display:''}); + }, 0); + + d.resolve(); + + UI.$body.css('overflow-x', ''); + + if (current) current.css({opacity:'', display:''}); + + }.bind(this)).show(); + }; + + next.css('animation-duration', this.options.duration+'ms'); + + if (current && current.length) { + + current.css('animation-duration', this.options.duration+'ms'); + + current.css('display', 'none').addClass(clsOut+' uk-animation-reverse').one(UI.support.animation.end, function() { + release(); + }.bind(this)).css('display', ''); + + } else { + next.addClass('uk-active'); + release(); + } + + return d.promise(); + } + +})(UIkit); diff --git a/js/core/switcher.min.js b/js/core/switcher.min.js new file mode 100755 index 0000000..9c4bc36 --- /dev/null +++ b/js/core/switcher.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";function i(i,n,e){var s,a=t.$.Deferred(),o=i,r=i;return e[0]===n[0]?(a.resolve(),a.promise()):("object"==typeof i&&(o=i[0],r=i[1]||i[0]),t.$body.css("overflow-x","hidden"),s=function(){n&&n.hide().removeClass("uk-active "+r+" uk-animation-reverse"),e.addClass(o).one(t.support.animation.end,function(){setTimeout(function(){e.removeClass(""+o).css({opacity:"",display:""})},0),a.resolve(),t.$body.css("overflow-x",""),n&&n.css({opacity:"",display:""})}.bind(this)).show()},e.css("animation-duration",this.options.duration+"ms"),n&&n.length?(n.css("animation-duration",this.options.duration+"ms"),n.css("display","none").addClass(r+" uk-animation-reverse").one(t.support.animation.end,function(){s()}.bind(this)).css("display","")):(e.addClass("uk-active"),s()),a.promise())}var n;t.component("switcher",{defaults:{connect:!1,toggle:">*",active:0,animation:!1,duration:200,swiping:!0},animating:!1,boot:function(){t.ready(function(i){t.$("[data-uk-switcher]",i).each(function(){var i=t.$(this);if(!i.data("switcher")){t.switcher(i,t.Utils.options(i.attr("data-uk-switcher")))}})})},init:function(){var i=this;if(this.on("click.uk.switcher",this.options.toggle,function(t){t.preventDefault(),i.show(this)}),this.options.connect){this.connect=t.$(this.options.connect),this.connect.children().removeClass("uk-active"),this.connect.length&&(this.connect.children().attr("aria-hidden","true"),this.connect.on("click","[data-uk-switcher-item]",function(n){n.preventDefault();var e=t.$(this).attr("data-uk-switcher-item");if(i.index!=e)switch(e){case"next":case"previous":i.show(i.index+("next"==e?1:-1));break;default:i.show(parseInt(e,10))}}),this.options.swiping&&this.connect.on("swipeRight swipeLeft",function(t){t.preventDefault(),window.getSelection().toString()||i.show(i.index+("swipeLeft"==t.type?1:-1))}));var n=this.find(this.options.toggle),e=n.filter(".uk-active");if(e.length)this.show(e,!1);else{if(this.options.active===!1)return;e=n.eq(this.options.active),this.show(e.length?e:n.eq(0),!1)}n.not(e).attr("aria-expanded","false"),e.attr("aria-expanded","true")}},show:function(e,s){if(!this.animating){if(isNaN(e))e=t.$(e);else{var a=this.find(this.options.toggle);e=0>e?a.length-1:e,e=a.eq(a[e]?e:0)}var o=this,a=this.find(this.options.toggle),r=t.$(e),c=n[this.options.animation]||function(t,e){if(!o.options.animation)return n.none.apply(o);var s=o.options.animation.split(",");return 1==s.length&&(s[1]=s[0]),s[0]=s[0].trim(),s[1]=s[1].trim(),i.apply(o,[s,t,e])};s!==!1&&t.support.animation||(c=n.none),r.hasClass("uk-disabled")||(a.attr("aria-expanded","false"),r.attr("aria-expanded","true"),a.filter(".uk-active").removeClass("uk-active"),r.addClass("uk-active"),this.options.connect&&this.connect.length&&(this.index=this.find(this.options.toggle).index(r),-1==this.index&&(this.index=0),this.connect.each(function(){var i=t.$(this),n=t.$(i.children()),e=t.$(n.filter(".uk-active")),s=t.$(n.eq(o.index));o.animating=!0,c.apply(o,[e,s]).then(function(){e.removeClass("uk-active"),s.addClass("uk-active"),e.attr("aria-hidden","true"),s.attr("aria-hidden","false"),t.Utils.checkDisplay(s,!0),o.animating=!1})})),this.trigger("show.uk.switcher",[r]))}}}),n={none:function(){var i=t.$.Deferred();return i.resolve(),i.promise()},fade:function(t,n){return i.apply(this,["uk-animation-fade",t,n])},"slide-bottom":function(t,n){return i.apply(this,["uk-animation-slide-bottom",t,n])},"slide-top":function(t,n){return i.apply(this,["uk-animation-slide-top",t,n])},"slide-vertical":function(t,n){var e=["uk-animation-slide-top","uk-animation-slide-bottom"];return t&&t.index()>n.index()&&e.reverse(),i.apply(this,[e,t,n])},"slide-left":function(t,n){return i.apply(this,["uk-animation-slide-left",t,n])},"slide-right":function(t,n){return i.apply(this,["uk-animation-slide-right",t,n])},"slide-horizontal":function(t,n){var e=["uk-animation-slide-right","uk-animation-slide-left"];return t&&t.index()>n.index()&&e.reverse(),i.apply(this,[e,t,n])},scale:function(t,n){return i.apply(this,["uk-animation-scale-up",t,n])}},t.switcher.animations=n}(UIkit); \ No newline at end of file diff --git a/js/core/tab.js b/js/core/tab.js new file mode 100755 index 0000000..4784a6f --- /dev/null +++ b/js/core/tab.js @@ -0,0 +1,167 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + UI.component('tab', { + + defaults: { + 'target' : '>li:not(.uk-tab-responsive, .uk-disabled)', + 'connect' : false, + 'active' : 0, + 'animation' : false, + 'duration' : 200, + 'swiping' : true + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-tab]", context).each(function() { + + var tab = UI.$(this); + + if (!tab.data("tab")) { + var obj = UI.tab(tab, UI.Utils.options(tab.attr("data-uk-tab"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + this.current = false; + + this.on("click.uk.tab", this.options.target, function(e) { + + e.preventDefault(); + + if ($this.switcher && $this.switcher.animating) { + return; + } + + var current = $this.find($this.options.target).not(this); + + current.removeClass("uk-active").blur(); + + $this.trigger("change.uk.tab", [UI.$(this).addClass("uk-active"), $this.current]); + + $this.current = UI.$(this); + + // Update ARIA + if (!$this.options.connect) { + current.attr('aria-expanded', 'false'); + UI.$(this).attr('aria-expanded', 'true'); + } + }); + + if (this.options.connect) { + this.connect = UI.$(this.options.connect); + } + + // init responsive tab + this.responsivetab = UI.$('
  • ').append('
      '); + + this.responsivetab.dropdown = this.responsivetab.find('.uk-dropdown'); + this.responsivetab.lst = this.responsivetab.dropdown.find('ul'); + this.responsivetab.caption = this.responsivetab.find('a:first'); + + if (this.element.hasClass("uk-tab-bottom")) this.responsivetab.dropdown.addClass("uk-dropdown-up"); + + // handle click + this.responsivetab.lst.on('click.uk.tab', 'a', function(e) { + + e.preventDefault(); + e.stopPropagation(); + + var link = UI.$(this); + + $this.element.children('li:not(.uk-tab-responsive)').eq(link.data('index')).trigger('click'); + }); + + this.on('show.uk.switcher change.uk.tab', function(e, tab) { + $this.responsivetab.caption.html(tab.text()); + }); + + this.element.append(this.responsivetab); + + // init UIkit components + if (this.options.connect) { + this.switcher = UI.switcher(this.element, { + 'toggle' : '>li:not(.uk-tab-responsive)', + 'connect' : this.options.connect, + 'active' : this.options.active, + 'animation' : this.options.animation, + 'duration' : this.options.duration, + 'swiping' : this.options.swiping + }); + } + + UI.dropdown(this.responsivetab, {"mode": "click", "preventflip": "y"}); + + // init + $this.trigger("change.uk.tab", [this.element.find(this.options.target).not('.uk-tab-responsive').filter('.uk-active')]); + + this.check(); + + UI.$win.on('resize orientationchange', UI.Utils.debounce(function(){ + if ($this.element.is(":visible")) $this.check(); + }, 100)); + + this.on('display.uk.check', function(){ + if ($this.element.is(":visible")) $this.check(); + }); + }, + + check: function() { + + var children = this.element.children('li:not(.uk-tab-responsive)').removeClass('uk-hidden'); + + if (!children.length) { + this.responsivetab.addClass('uk-hidden'); + return; + } + + var top = (children.eq(0).offset().top + Math.ceil(children.eq(0).height()/2)), + doresponsive = false, + item, link, clone; + + this.responsivetab.lst.empty(); + + children.each(function(){ + + if (UI.$(this).offset().top > top) { + doresponsive = true; + } + }); + + if (doresponsive) { + + for (var i = 0; i < children.length; i++) { + + item = UI.$(children.eq(i)); + link = item.find('a'); + + if (item.css('float') != 'none' && !item.attr('uk-dropdown')) { + + if (!item.hasClass('uk-disabled')) { + + clone = item[0].outerHTML.replace('li:not(.uk-tab-responsive, .uk-disabled)",connect:!1,active:0,animation:!1,duration:200,swiping:!0},boot:function(){t.ready(function(i){t.$("[data-uk-tab]",i).each(function(){var i=t.$(this);if(!i.data("tab")){t.tab(i,t.Utils.options(i.attr("data-uk-tab")))}})})},init:function(){var i=this;this.current=!1,this.on("click.uk.tab",this.options.target,function(e){if(e.preventDefault(),!i.switcher||!i.switcher.animating){var s=i.find(i.options.target).not(this);s.removeClass("uk-active").blur(),i.trigger("change.uk.tab",[t.$(this).addClass("uk-active"),i.current]),i.current=t.$(this),i.options.connect||(s.attr("aria-expanded","false"),t.$(this).attr("aria-expanded","true"))}}),this.options.connect&&(this.connect=t.$(this.options.connect)),this.responsivetab=t.$('
    • ').append('
        '),this.responsivetab.dropdown=this.responsivetab.find(".uk-dropdown"),this.responsivetab.lst=this.responsivetab.dropdown.find("ul"),this.responsivetab.caption=this.responsivetab.find("a:first"),this.element.hasClass("uk-tab-bottom")&&this.responsivetab.dropdown.addClass("uk-dropdown-up"),this.responsivetab.lst.on("click.uk.tab","a",function(e){e.preventDefault(),e.stopPropagation();var s=t.$(this);i.element.children("li:not(.uk-tab-responsive)").eq(s.data("index")).trigger("click")}),this.on("show.uk.switcher change.uk.tab",function(t,e){i.responsivetab.caption.html(e.text())}),this.element.append(this.responsivetab),this.options.connect&&(this.switcher=t.switcher(this.element,{toggle:">li:not(.uk-tab-responsive)",connect:this.options.connect,active:this.options.active,animation:this.options.animation,duration:this.options.duration,swiping:this.options.swiping})),t.dropdown(this.responsivetab,{mode:"click",preventflip:"y"}),i.trigger("change.uk.tab",[this.element.find(this.options.target).not(".uk-tab-responsive").filter(".uk-active")]),this.check(),t.$win.on("resize orientationchange",t.Utils.debounce(function(){i.element.is(":visible")&&i.check()},100)),this.on("display.uk.check",function(){i.element.is(":visible")&&i.check()})},check:function(){var i=this.element.children("li:not(.uk-tab-responsive)").removeClass("uk-hidden");if(!i.length)return this.responsivetab.addClass("uk-hidden"),void 0;var e,s,n,a=i.eq(0).offset().top+Math.ceil(i.eq(0).height()/2),o=!1;if(this.responsivetab.lst.empty(),i.each(function(){t.$(this).offset().top>a&&(o=!0)}),o)for(var r=0;r= Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down'); + } + + function longTap() { + longTapTimeout = null; + if (touch.last) { + if ( touch.el !== undefined ) touch.el.trigger('longTap'); + touch = {}; + } + } + + function cancelLongTap() { + if (longTapTimeout) clearTimeout(longTapTimeout); + longTapTimeout = null; + } + + function cancelAll() { + if (touchTimeout) clearTimeout(touchTimeout); + if (tapTimeout) clearTimeout(tapTimeout); + if (swipeTimeout) clearTimeout(swipeTimeout); + if (longTapTimeout) clearTimeout(longTapTimeout); + touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null; + touch = {}; + } + + function isPrimaryTouch(event){ + return event.pointerType == event.MSPOINTER_TYPE_TOUCH && event.isPrimary; + } + + $(function(){ + var now, delta, deltaX = 0, deltaY = 0, firstTouch; + + if ('MSGesture' in window) { + gesture = new MSGesture(); + gesture.target = document.body; + } + + $(document) + .on('MSGestureEnd gestureend', function(e){ + + var swipeDirectionFromVelocity = e.originalEvent.velocityX > 1 ? 'Right' : e.originalEvent.velocityX < -1 ? 'Left' : e.originalEvent.velocityY > 1 ? 'Down' : e.originalEvent.velocityY < -1 ? 'Up' : null; + + if (swipeDirectionFromVelocity && touch.el !== undefined) { + touch.el.trigger('swipe'); + touch.el.trigger('swipe'+ swipeDirectionFromVelocity); + } + }) + // MSPointerDown: for IE10 + // pointerdown: for IE11 + .on('touchstart MSPointerDown pointerdown', function(e){ + + if(e.type == 'MSPointerDown' && !isPrimaryTouch(e.originalEvent)) return; + + firstTouch = (e.type == 'MSPointerDown' || e.type == 'pointerdown') ? e : e.originalEvent.touches[0]; + + now = Date.now(); + delta = now - (touch.last || now); + touch.el = $('tagName' in firstTouch.target ? firstTouch.target : firstTouch.target.parentNode); + + if(touchTimeout) clearTimeout(touchTimeout); + + touch.x1 = firstTouch.pageX; + touch.y1 = firstTouch.pageY; + + if (delta > 0 && delta <= 250) touch.isDoubleTap = true; + + touch.last = now; + longTapTimeout = setTimeout(longTap, longTapDelay); + + // adds the current touch contact for IE gesture recognition + if (gesture && ( e.type == 'MSPointerDown' || e.type == 'pointerdown' || e.type == 'touchstart' ) ) { + gesture.addPointer(e.originalEvent.pointerId); + } + + }) + // MSPointerMove: for IE10 + // pointermove: for IE11 + .on('touchmove MSPointerMove pointermove', function(e){ + + if (e.type == 'MSPointerMove' && !isPrimaryTouch(e.originalEvent)) return; + + firstTouch = (e.type == 'MSPointerMove' || e.type == 'pointermove') ? e : e.originalEvent.touches[0]; + + cancelLongTap(); + touch.x2 = firstTouch.pageX; + touch.y2 = firstTouch.pageY; + + deltaX += Math.abs(touch.x1 - touch.x2); + deltaY += Math.abs(touch.y1 - touch.y2); + }) + // MSPointerUp: for IE10 + // pointerup: for IE11 + .on('touchend MSPointerUp pointerup', function(e){ + + if (e.type == 'MSPointerUp' && !isPrimaryTouch(e.originalEvent)) return; + + cancelLongTap(); + + // swipe + if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) || (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30)){ + + swipeTimeout = setTimeout(function() { + if ( touch.el !== undefined ) { + touch.el.trigger('swipe'); + touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2))); + } + touch = {}; + }, 0); + + // normal tap + } else if ('last' in touch) { + + // don't fire tap when delta position changed by more than 30 pixels, + // for instance when moving to a point and back to origin + if (isNaN(deltaX) || (deltaX < 30 && deltaY < 30)) { + // delay by one tick so we can cancel the 'tap' event if 'scroll' fires + // ('tap' fires before 'scroll') + tapTimeout = setTimeout(function() { + + // trigger universal 'tap' with the option to cancelTouch() + // (cancelTouch cancels processing of single vs double taps for faster 'tap' response) + var event = $.Event('tap'); + event.cancelTouch = cancelAll; + if ( touch.el !== undefined ) touch.el.trigger(event); + + // trigger double tap immediately + if (touch.isDoubleTap) { + if ( touch.el !== undefined ) touch.el.trigger('doubleTap'); + touch = {}; + } + + // trigger single tap after 250ms of inactivity + else { + touchTimeout = setTimeout(function(){ + touchTimeout = null; + if ( touch.el !== undefined ) touch.el.trigger('singleTap'); + touch = {}; + }, 250); + } + }, 0); + } else { + touch = {}; + } + deltaX = deltaY = 0; + } + }) + // when the browser window loses focus, + // for example when a modal dialog is shown, + // cancel all ongoing events + .on('touchcancel MSPointerCancel', cancelAll); + + // scrolling the window indicates intention of the user + // to scroll, not tap or swipe, so cancel all ongoing events + $(window).on('scroll', cancelAll); + }); + + ['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(eventName){ + $.fn[eventName] = function(callback){ return $(this).on(eventName, callback); }; + }); +})(jQuery); diff --git a/js/core/touch.min.js b/js/core/touch.min.js new file mode 100755 index 0000000..b86dfd1 --- /dev/null +++ b/js/core/touch.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){function t(e,t,n,o){return Math.abs(e-t)>=Math.abs(n-o)?e-t>0?"Left":"Right":n-o>0?"Up":"Down"}function n(){p=null,g.last&&(void 0!==g.el&&g.el.trigger("longTap"),g={})}function o(){p&&clearTimeout(p),p=null}function i(){a&&clearTimeout(a),l&&clearTimeout(l),u&&clearTimeout(u),p&&clearTimeout(p),a=l=u=p=null,g={}}function r(e){return e.pointerType==e.MSPOINTER_TYPE_TOUCH&&e.isPrimary}if(!e.fn.swipeLeft){var a,l,u,p,c,g={},s=750;e(function(){var v,y,w,f=0,d=0;"MSGesture"in window&&(c=new MSGesture,c.target=document.body),e(document).on("MSGestureEnd gestureend",function(e){var t=e.originalEvent.velocityX>1?"Right":e.originalEvent.velocityX<-1?"Left":e.originalEvent.velocityY>1?"Down":e.originalEvent.velocityY<-1?"Up":null;t&&void 0!==g.el&&(g.el.trigger("swipe"),g.el.trigger("swipe"+t))}).on("touchstart MSPointerDown pointerdown",function(t){("MSPointerDown"!=t.type||r(t.originalEvent))&&(w="MSPointerDown"==t.type||"pointerdown"==t.type?t:t.originalEvent.touches[0],v=Date.now(),y=v-(g.last||v),g.el=e("tagName"in w.target?w.target:w.target.parentNode),a&&clearTimeout(a),g.x1=w.pageX,g.y1=w.pageY,y>0&&250>=y&&(g.isDoubleTap=!0),g.last=v,p=setTimeout(n,s),!c||"MSPointerDown"!=t.type&&"pointerdown"!=t.type&&"touchstart"!=t.type||c.addPointer(t.originalEvent.pointerId))}).on("touchmove MSPointerMove pointermove",function(e){("MSPointerMove"!=e.type||r(e.originalEvent))&&(w="MSPointerMove"==e.type||"pointermove"==e.type?e:e.originalEvent.touches[0],o(),g.x2=w.pageX,g.y2=w.pageY,f+=Math.abs(g.x1-g.x2),d+=Math.abs(g.y1-g.y2))}).on("touchend MSPointerUp pointerup",function(n){("MSPointerUp"!=n.type||r(n.originalEvent))&&(o(),g.x2&&Math.abs(g.x1-g.x2)>30||g.y2&&Math.abs(g.y1-g.y2)>30?u=setTimeout(function(){void 0!==g.el&&(g.el.trigger("swipe"),g.el.trigger("swipe"+t(g.x1,g.x2,g.y1,g.y2))),g={}},0):"last"in g&&(isNaN(f)||30>f&&30>d?l=setTimeout(function(){var t=e.Event("tap");t.cancelTouch=i,void 0!==g.el&&g.el.trigger(t),g.isDoubleTap?(void 0!==g.el&&g.el.trigger("doubleTap"),g={}):a=setTimeout(function(){a=null,void 0!==g.el&&g.el.trigger("singleTap"),g={}},250)},0):g={},f=d=0))}).on("touchcancel MSPointerCancel",i),e(window).on("scroll",i)}),["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(t){e.fn[t]=function(n){return e(this).on(t,n)}})}}(jQuery); \ No newline at end of file diff --git a/js/core/utility.js b/js/core/utility.js new file mode 100755 index 0000000..0090b8c --- /dev/null +++ b/js/core/utility.js @@ -0,0 +1,319 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +(function(UI) { + + "use strict"; + + var stacks = []; + + UI.component('stackMargin', { + + defaults: { + cls: 'uk-margin-small-top', + rowfirst: false, + observe: false + }, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-margin]", context).each(function() { + + var ele = UI.$(this); + + if (!ele.data("stackMargin")) { + UI.stackMargin(ele, UI.Utils.options(ele.attr("data-uk-margin"))); + } + }); + }); + }, + + init: function() { + + var $this = this; + + UI.$win.on('resize orientationchange', (function() { + + var fn = function() { + $this.process(); + }; + + UI.$(function() { + fn(); + UI.$win.on("load", fn); + }); + + return UI.Utils.debounce(fn, 20); + })()); + + this.on("display.uk.check", function(e) { + if (this.element.is(":visible")) this.process(); + }.bind(this)); + + if (this.options.observe) { + + UI.domObserve(this.element, function(e) { + if ($this.element.is(":visible")) $this.process(); + }); + } + + stacks.push(this); + }, + + process: function() { + + var $this = this, columns = this.element.children(); + + UI.Utils.stackMargin(columns, this.options); + + if (!this.options.rowfirst || !columns.length) { + return this; + } + + // Mark first column elements + var group = {}, minleft = false; + + columns.removeClass(this.options.rowfirst).each(function(offset, $ele){ + + $ele = UI.$(this); + + if (this.style.display != 'none') { + offset = $ele.offset().left; + ((group[offset] = group[offset] || []) && group[offset]).push(this); + minleft = minleft === false ? offset : Math.min(minleft, offset); + } + }); + + UI.$(group[minleft]).addClass(this.options.rowfirst); + + return this; + } + + }); + + + // responsive element e.g. iframes + + (function(){ + + var elements = [], check = function(ele) { + + if (!ele.is(':visible')) return; + + var width = ele.parent().width(), + iwidth = ele.data('width'), + ratio = (width / iwidth), + height = Math.floor(ratio * ele.data('height')); + + ele.css({'height': (width < iwidth) ? height : ele.data('height')}); + }; + + UI.component('responsiveElement', { + + defaults: {}, + + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("iframe.uk-responsive-width, [data-uk-responsive]", context).each(function() { + + var ele = UI.$(this), obj; + + if (!ele.data("responsiveElement")) { + obj = UI.responsiveElement(ele, {}); + } + }); + }); + }, + + init: function() { + + var ele = this.element; + + if (ele.attr('width') && ele.attr('height')) { + + ele.data({ + + 'width' : ele.attr('width'), + 'height': ele.attr('height') + + }).on('display.uk.check', function(){ + check(ele); + }); + + check(ele); + + elements.push(ele); + } + } + }); + + UI.$win.on('resize load', UI.Utils.debounce(function(){ + + elements.forEach(function(ele){ + check(ele); + }); + + }, 15)); + + })(); + + + + // helper + + UI.Utils.stackMargin = function(elements, options) { + + options = UI.$.extend({ + 'cls': 'uk-margin-small-top' + }, options); + + elements = UI.$(elements).removeClass(options.cls); + + var min = false; + + elements.each(function(offset, height, pos, $ele){ + + $ele = UI.$(this); + + if ($ele.css('display') != 'none') { + + offset = $ele.offset(); + height = $ele.outerHeight(); + pos = offset.top + height; + + $ele.data({ + 'ukMarginPos': pos, + 'ukMarginTop': offset.top + }); + + if (min === false || (offset.top < min.top) ) { + + min = { + top : offset.top, + left : offset.left, + pos : pos + }; + } + } + + }).each(function($ele) { + + $ele = UI.$(this); + + if ($ele.css('display') != 'none' && $ele.data('ukMarginTop') > min.top && $ele.data('ukMarginPos') > min.pos) { + $ele.addClass(options.cls); + } + }); + }; + + UI.Utils.matchHeights = function(elements, options) { + + elements = UI.$(elements).css('min-height', ''); + options = UI.$.extend({ row : true }, options); + + var matchHeights = function(group){ + + if (group.length < 2) return; + + var max = 0; + + group.each(function() { + max = Math.max(max, UI.$(this).outerHeight()); + }).each(function() { + + var element = UI.$(this), + height = max - (element.css('box-sizing') == 'border-box' ? 0 : (element.outerHeight() - element.height())); + + element.css('min-height', height + 'px'); + }); + }; + + if (options.row) { + + elements.first().width(); // force redraw + + setTimeout(function(){ + + var lastoffset = false, group = []; + + elements.each(function() { + + var ele = UI.$(this), offset = ele.offset().top; + + if (offset != lastoffset && group.length) { + + matchHeights(UI.$(group)); + group = []; + offset = ele.offset().top; + } + + group.push(ele); + lastoffset = offset; + }); + + if (group.length) { + matchHeights(UI.$(group)); + } + + }, 0); + + } else { + matchHeights(elements); + } + }; + + (function(cacheSvgs){ + + UI.Utils.inlineSvg = function(selector, root) { + + var images = UI.$(selector || 'img[src$=".svg"]', root || document).each(function(){ + + var img = UI.$(this), + src = img.attr('src'); + + if (!cacheSvgs[src]) { + + var d = UI.$.Deferred(); + + UI.$.get(src, {nc: Math.random()}, function(data){ + d.resolve(UI.$(data).find('svg')); + }); + + cacheSvgs[src] = d.promise(); + } + + cacheSvgs[src].then(function(svg) { + + var $svg = UI.$(svg).clone(); + + if (img.attr('id')) $svg.attr('id', img.attr('id')); + if (img.attr('class')) $svg.attr('class', img.attr('class')); + if (img.attr('style')) $svg.attr('style', img.attr('style')); + + if (img.attr('width')) { + $svg.attr('width', img.attr('width')); + if (!img.attr('height')) $svg.removeAttr('height'); + } + + if (img.attr('height')){ + $svg.attr('height', img.attr('height')); + if (!img.attr('width')) $svg.removeAttr('width'); + } + + img.replaceWith($svg); + }); + }); + }; + + // init code + UI.ready(function(context) { + UI.Utils.inlineSvg('[data-uk-svg]', context); + }); + + })({}); + +})(UIkit); diff --git a/js/core/utility.min.js b/js/core/utility.min.js new file mode 100755 index 0000000..1b8e7ab --- /dev/null +++ b/js/core/utility.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(t){"use strict";var i=[];t.component("stackMargin",{defaults:{cls:"uk-margin-small-top",rowfirst:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-margin]",i).each(function(){var i=t.$(this);i.data("stackMargin")||t.stackMargin(i,t.Utils.options(i.attr("data-uk-margin")))})})},init:function(){var n=this;t.$win.on("resize orientationchange",function(){var i=function(){n.process()};return t.$(function(){i(),t.$win.on("load",i)}),t.Utils.debounce(i,20)}()),this.on("display.uk.check",function(){this.element.is(":visible")&&this.process()}.bind(this)),this.options.observe&&t.domObserve(this.element,function(){n.element.is(":visible")&&n.process()}),i.push(this)},process:function(){var i=this.element.children();if(t.Utils.stackMargin(i,this.options),!this.options.rowfirst||!i.length)return this;var n={},e=!1;return i.removeClass(this.options.rowfirst).each(function(i,s){s=t.$(this),"none"!=this.style.display&&(i=s.offset().left,((n[i]=n[i]||[])&&n[i]).push(this),e=e===!1?i:Math.min(e,i))}),t.$(n[e]).addClass(this.options.rowfirst),this}}),function(){var i=[],n=function(t){if(t.is(":visible")){var i=t.parent().width(),n=t.data("width"),e=i/n,s=Math.floor(e*t.data("height"));t.css({height:n>i?s:t.data("height")})}};t.component("responsiveElement",{defaults:{},boot:function(){t.ready(function(i){t.$("iframe.uk-responsive-width, [data-uk-responsive]",i).each(function(){var i,n=t.$(this);n.data("responsiveElement")||(i=t.responsiveElement(n,{}))})})},init:function(){var t=this.element;t.attr("width")&&t.attr("height")&&(t.data({width:t.attr("width"),height:t.attr("height")}).on("display.uk.check",function(){n(t)}),n(t),i.push(t))}}),t.$win.on("resize load",t.Utils.debounce(function(){i.forEach(function(t){n(t)})},15))}(),t.Utils.stackMargin=function(i,n){n=t.$.extend({cls:"uk-margin-small-top"},n),i=t.$(i).removeClass(n.cls);var e=!1;i.each(function(i,n,s,a){a=t.$(this),"none"!=a.css("display")&&(i=a.offset(),n=a.outerHeight(),s=i.top+n,a.data({ukMarginPos:s,ukMarginTop:i.top}),(e===!1||i.tope.top&&i.data("ukMarginPos")>e.pos&&i.addClass(n.cls)})},t.Utils.matchHeights=function(i,n){i=t.$(i).css("min-height",""),n=t.$.extend({row:!0},n);var e=function(i){if(!(i.length<2)){var n=0;i.each(function(){n=Math.max(n,t.$(this).outerHeight())}).each(function(){var i=t.$(this),e=n-("border-box"==i.css("box-sizing")?0:i.outerHeight()-i.height());i.css("min-height",e+"px")})}};n.row?(i.first().width(),setTimeout(function(){var n=!1,s=[];i.each(function(){var i=t.$(this),a=i.offset().top;a!=n&&s.length&&(e(t.$(s)),s=[],a=i.offset().top),s.push(i),n=a}),s.length&&e(t.$(s))},0)):e(i)},function(i){t.Utils.inlineSvg=function(n,e){t.$(n||'img[src$=".svg"]',e||document).each(function(){var n=t.$(this),e=n.attr("src");if(!i[e]){var s=t.$.Deferred();t.$.get(e,{nc:Math.random()},function(i){s.resolve(t.$(i).find("svg"))}),i[e]=s.promise()}i[e].then(function(i){var e=t.$(i).clone();n.attr("id")&&e.attr("id",n.attr("id")),n.attr("class")&&e.attr("class",n.attr("class")),n.attr("style")&&e.attr("style",n.attr("style")),n.attr("width")&&(e.attr("width",n.attr("width")),n.attr("height")||e.removeAttr("height")),n.attr("height")&&(e.attr("height",n.attr("height")),n.attr("width")||e.removeAttr("width")),n.replaceWith(e)})})},t.ready(function(i){t.Utils.inlineSvg("[data-uk-svg]",i)})}({})}(UIkit); \ No newline at end of file -- cgit v1.2.3