{"version":3,"names":[],"mappings":"","sources":["scripts.bundle.js"],"sourcesContent":["\"use strict\";\r\n/**\r\n * @class KUtil base utilize class that privides helper functions\r\n */\r\n// Polyfill\r\n// matches polyfill\r\nthis.Element && function(ElementPrototype) {\r\n ElementPrototype.matches = ElementPrototype.matches ||\r\n ElementPrototype.matchesSelector ||\r\n ElementPrototype.webkitMatchesSelector ||\r\n ElementPrototype.msMatchesSelector ||\r\n function(selector) {\r\n var node = this,\r\n nodes = (node.parentNode || node.document).querySelectorAll(selector),\r\n i = -1;\r\n while (nodes[++i] && nodes[i] != node);\r\n return !!nodes[i];\r\n }\r\n}(Element.prototype);\r\n\r\n// closest polyfill\r\nthis.Element && function(ElementPrototype) {\r\n ElementPrototype.closest = ElementPrototype.closest ||\r\n function(selector) {\r\n var el = this;\r\n while (el.matches && !el.matches(selector)) el = el.parentNode;\r\n return el.matches ? el : null;\r\n }\r\n}(Element.prototype);\r\n\r\n\r\n// matches polyfill\r\nthis.Element && function(ElementPrototype) {\r\n ElementPrototype.matches = ElementPrototype.matches ||\r\n ElementPrototype.matchesSelector ||\r\n ElementPrototype.webkitMatchesSelector ||\r\n ElementPrototype.msMatchesSelector ||\r\n function(selector) {\r\n var node = this,\r\n nodes = (node.parentNode || node.document).querySelectorAll(selector),\r\n i = -1;\r\n while (nodes[++i] && nodes[i] != node);\r\n return !!nodes[i];\r\n }\r\n}(Element.prototype);\r\n\r\n//\r\n// requestAnimationFrame polyfill by Erik Möller.\r\n// With fixes from Paul Irish and Tino Zijdel\r\n//\r\n// http://paulirish.com/2011/requestanimationframe-for-smart-animating/\r\n// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating\r\n//\r\n// MIT license\r\n//\r\n(function() {\r\n var lastTime = 0;\r\n var vendors = ['webkit', 'moz'];\r\n for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {\r\n window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];\r\n window.cancelAnimationFrame =\r\n window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];\r\n }\r\n\r\n if (!window.requestAnimationFrame)\r\n window.requestAnimationFrame = function(callback) {\r\n var currTime = new Date().getTime();\r\n var timeToCall = Math.max(0, 16 - (currTime - lastTime));\r\n var id = window.setTimeout(function() {\r\n callback(currTime + timeToCall);\r\n }, timeToCall);\r\n lastTime = currTime + timeToCall;\r\n return id;\r\n };\r\n\r\n if (!window.cancelAnimationFrame)\r\n window.cancelAnimationFrame = function(id) {\r\n clearTimeout(id);\r\n };\r\n}());\r\n\r\n// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/prepend()/prepend().md\r\n(function(arr) {\r\n arr.forEach(function(item) {\r\n if (item.hasOwnProperty('prepend')) {\r\n return;\r\n }\r\n Object.defineProperty(item, 'prepend', {\r\n configurable: true,\r\n enumerable: true,\r\n writable: true,\r\n value: function prepend() {\r\n var argArr = Array.prototype.slice.call(arguments),\r\n docFrag = document.createDocumentFragment();\r\n\r\n argArr.forEach(function(argItem) {\r\n var isNode = argItem instanceof Node;\r\n docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));\r\n });\r\n\r\n this.insertBefore(docFrag, this.firstChild);\r\n }\r\n });\r\n });\r\n})([Element.prototype, Document.prototype, DocumentFragment.prototype]);\r\n\r\n// Global variables \r\nwindow.KUtilElementDataStore = {};\r\nwindow.KUtilElementDataStoreID = 0;\r\nwindow.KUtilDelegatedEventHandlers = {};\r\n\r\nvar KUtil = function() {\r\n\r\n var resizeHandlers = [];\r\n\r\n /** @type {object} breakpoints The device width breakpoints **/\r\n var breakpoints = {\r\n sm: 544, // Small screen / phone \r\n md: 768, // Medium screen / tablet \r\n lg: 1024, // Large screen / desktop \r\n xl: 1200 // Extra large screen / wide desktop\r\n };\r\n\r\n /**\r\n * Handle window resize event with some \r\n * delay to attach event handlers upon resize complete \r\n */\r\n var _windowResizeHandler = function() {\r\n var _runResizeHandlers = function() {\r\n // reinitialize other subscribed elements\r\n for (var i = 0; i < resizeHandlers.length; i++) {\r\n var each = resizeHandlers[i];\r\n each.call();\r\n }\r\n };\r\n\r\n var timeout = false; // holder for timeout id\r\n var delay = 250; // delay after event is \"complete\" to run callback\r\n\r\n window.addEventListener('resize', function() {\r\n clearTimeout(timeout);\r\n timeout = setTimeout(function() {\r\n _runResizeHandlers();\r\n }, delay); // wait 50ms until window resize finishes.\r\n });\r\n };\r\n\r\n return {\r\n /**\r\n * Class main initializer.\r\n * @param {object} options.\r\n * @returns null\r\n */\r\n //main function to initiate the theme\r\n init: function(options) {\r\n if (options && options.breakpoints) {\r\n breakpoints = options.breakpoints;\r\n }\r\n\r\n _windowResizeHandler();\r\n },\r\n\r\n /**\r\n * Adds window resize event handler.\r\n * @param {function} callback function.\r\n */\r\n addResizeHandler: function(callback) {\r\n resizeHandlers.push(callback);\r\n },\r\n\r\n /**\r\n * Removes window resize event handler.\r\n * @param {function} callback function.\r\n */\r\n removeResizeHandler: function(callback) {\r\n for (var i = 0; i < resizeHandlers.length; i++) {\r\n if (callback === resizeHandlers[i]) {\r\n delete resizeHandlers[i];\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Trigger window resize handlers.\r\n */\r\n runResizeHandlers: function() {\r\n _runResizeHandlers();\r\n },\r\n\r\n resize: function() {\r\n if (typeof(Event) === 'function') {\r\n // modern browsers\r\n window.dispatchEvent(new Event('resize'));\r\n } else {\r\n // for IE and other old browsers\r\n // causes deprecation warning on modern browsers\r\n var evt = window.document.createEvent('UIEvents'); \r\n evt.initUIEvent('resize', true, false, window, 0); \r\n window.dispatchEvent(evt);\r\n }\r\n },\r\n\r\n /**\r\n * Get GET parameter value from URL.\r\n * @param {string} paramName Parameter name.\r\n * @returns {string} \r\n */\r\n getURLParam: function(paramName) {\r\n var searchString = window.location.search.substring(1),\r\n i, val, params = searchString.split(\"&\");\r\n\r\n for (i = 0; i < params.length; i++) {\r\n val = params[i].split(\"=\");\r\n if (val[0] == paramName) {\r\n return unescape(val[1]);\r\n }\r\n }\r\n\r\n return null;\r\n },\r\n\r\n /**\r\n * Checks whether current device is mobile touch.\r\n * @returns {boolean} \r\n */\r\n isMobileDevice: function() {\r\n return (this.getViewPort().width < this.getBreakpoint('lg') ? true : false);\r\n },\r\n\r\n /**\r\n * Checks whether current device is desktop.\r\n * @returns {boolean} \r\n */\r\n isDesktopDevice: function() {\r\n return KUtil.isMobileDevice() ? false : true;\r\n },\r\n\r\n /**\r\n * Gets browser window viewport size. Ref:\r\n * http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/\r\n * @returns {object} \r\n */\r\n getViewPort: function() {\r\n var e = window,\r\n a = 'inner';\r\n if (!('innerWidth' in window)) {\r\n a = 'client';\r\n e = document.documentElement || document.body;\r\n }\r\n\r\n return {\r\n width: e[a + 'Width'],\r\n height: e[a + 'Height']\r\n };\r\n },\r\n\r\n /**\r\n * Checks whether given device mode is currently activated.\r\n * @param {string} mode Responsive mode name(e.g: desktop,\r\n * desktop-and-tablet, tablet, tablet-and-mobile, mobile)\r\n * @returns {boolean} \r\n */\r\n isInResponsiveRange: function(mode) {\r\n var breakpoint = this.getViewPort().width;\r\n\r\n if (mode == 'general') {\r\n return true;\r\n } else if (mode == 'desktop' && breakpoint >= (this.getBreakpoint('lg') + 1)) {\r\n return true;\r\n } else if (mode == 'tablet' && (breakpoint >= (this.getBreakpoint('md') + 1) && breakpoint < this.getBreakpoint('lg'))) {\r\n return true;\r\n } else if (mode == 'mobile' && breakpoint <= this.getBreakpoint('md')) {\r\n return true;\r\n } else if (mode == 'desktop-and-tablet' && breakpoint >= (this.getBreakpoint('md') + 1)) {\r\n return true;\r\n } else if (mode == 'tablet-and-mobile' && breakpoint <= this.getBreakpoint('lg')) {\r\n return true;\r\n } else if (mode == 'minimal-desktop-and-below' && breakpoint <= this.getBreakpoint('xl')) {\r\n return true;\r\n }\r\n\r\n return false;\r\n },\r\n\r\n /**\r\n * Generates unique ID for give prefix.\r\n * @param {string} prefix Prefix for generated ID\r\n * @returns {boolean} \r\n */\r\n getUniqueID: function(prefix) {\r\n return prefix + Math.floor(Math.random() * (new Date()).getTime());\r\n },\r\n\r\n /**\r\n * Gets window width for give breakpoint mode.\r\n * @param {string} mode Responsive mode name(e.g: xl, lg, md, sm)\r\n * @returns {number} \r\n */\r\n getBreakpoint: function(mode) {\r\n return breakpoints[mode];\r\n },\r\n\r\n /**\r\n * Checks whether object has property matchs given key path.\r\n * @param {object} obj Object contains values paired with given key path\r\n * @param {string} keys Keys path seperated with dots\r\n * @returns {object} \r\n */\r\n isset: function(obj, keys) {\r\n var stone;\r\n\r\n keys = keys || '';\r\n\r\n if (keys.indexOf('[') !== -1) {\r\n throw new Error('Unsupported object path notation.');\r\n }\r\n\r\n keys = keys.split('.');\r\n\r\n do {\r\n if (obj === undefined) {\r\n return false;\r\n }\r\n\r\n stone = keys.shift();\r\n\r\n if (!obj.hasOwnProperty(stone)) {\r\n return false;\r\n }\r\n\r\n obj = obj[stone];\r\n\r\n } while (keys.length);\r\n\r\n return true;\r\n },\r\n\r\n /**\r\n * Gets highest z-index of the given element parents\r\n * @param {object} el jQuery element object\r\n * @returns {number} \r\n */\r\n getHighestZindex: function(el) {\r\n var elem = KUtil.get(el),\r\n position, value;\r\n\r\n while (elem && elem !== document) {\r\n // Ignore z-index if position is set to a value where z-index is ignored by the browser\r\n // This makes behavior of this function consistent across browsers\r\n // WebKit always returns auto if the element is positioned\r\n position = KUtil.css(elem, 'position');\r\n\r\n if (position === \"absolute\" || position === \"relative\" || position === \"fixed\") {\r\n // IE returns 0 when zIndex is not specified\r\n // other browsers return a string\r\n // we ignore the case of nested elements with an explicit value of 0\r\n //