{"version":3,"file":"foundation.core.utils.js","sources":["../../../../IREP.Web.Content/v7/node_modules/foundation-sites/js/foundation.core.utils.js"],"sourcesContent":["import $ from 'jquery';\n\n// Core Foundation Utilities, utilized in a number of places.\n\n /**\n * Returns a boolean for RTL support\n */\nfunction rtl() {\n return $('html').attr('dir') === 'rtl';\n}\n\n/**\n * returns a random base-36 uid with namespacing\n * @function\n * @param {Number} length - number of random base-36 digits desired. Increase for more random strings.\n * @param {String} namespace - name of plugin to be incorporated in uid, optional.\n * @default {String} '' - if no plugin name is provided, nothing is appended to the uid.\n * @returns {String} - unique id\n */\nfunction GetYoDigits(length = 6, namespace){\n let str = '';\n const chars = '0123456789abcdefghijklmnopqrstuvwxyz';\n const charsLength = chars.length;\n for (let i = 0; i < length; i++) {\n str += chars[Math.floor(Math.random() * charsLength)];\n }\n return namespace ? `${str}-${namespace}` : str;\n}\n\n/**\n * Escape a string so it can be used as a regexp pattern\n * @function\n * @see https://stackoverflow.com/a/9310752/4317384\n *\n * @param {String} str - string to escape.\n * @returns {String} - escaped string\n */\nfunction RegExpEscape(str){\n return str.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n}\n\nfunction transitionend($elem){\n var transitions = {\n 'transition': 'transitionend',\n 'WebkitTransition': 'webkitTransitionEnd',\n 'MozTransition': 'transitionend',\n 'OTransition': 'otransitionend'\n };\n var elem = document.createElement('div'),\n end;\n\n for (let transition in transitions){\n if (typeof elem.style[transition] !== 'undefined'){\n end = transitions[transition];\n }\n }\n if (end) {\n return end;\n } else {\n setTimeout(function(){\n $elem.triggerHandler('transitionend', [$elem]);\n }, 1);\n return 'transitionend';\n }\n}\n\n/**\n * Return an event type to listen for window load.\n *\n * If `$elem` is passed, an event will be triggered on `$elem`. If window is already loaded, the event will still be triggered.\n * If `handler` is passed, attach it to the event on `$elem`.\n * Calling `onLoad` without handler allows you to get the event type that will be triggered before attaching the handler by yourself.\n * @function\n *\n * @param {Object} [] $elem - jQuery element on which the event will be triggered if passed.\n * @param {Function} [] handler - function to attach to the event.\n * @returns {String} - event type that should or will be triggered.\n */\nfunction onLoad($elem, handler) {\n const didLoad = document.readyState === 'complete';\n const eventType = (didLoad ? '_didLoad' : 'load') + '.zf.util.onLoad';\n const cb = () => $elem.triggerHandler(eventType);\n\n if ($elem) {\n if (handler) $elem.one(eventType, handler);\n\n if (didLoad)\n setTimeout(cb);\n else\n $(window).one('load', cb);\n }\n\n return eventType;\n}\n\n/**\n * Retuns an handler for the `mouseleave` that ignore disappeared mouses.\n *\n * If the mouse \"disappeared\" from the document (like when going on a browser UI element, See https://git.io/zf-11410),\n * the event is ignored.\n * - If the `ignoreLeaveWindow` is `true`, the event is ignored when the user actually left the window\n * (like by switching to an other window with [Alt]+[Tab]).\n * - If the `ignoreReappear` is `true`, the event will be ignored when the mouse will reappear later on the document\n * outside of the element it left.\n *\n * @function\n *\n * @param {Function} [] handler - handler for the filtered `mouseleave` event to watch.\n * @param {Object} [] options - object of options:\n * - {Boolean} [false] ignoreLeaveWindow - also ignore when the user switched windows.\n * - {Boolean} [false] ignoreReappear - also ignore when the mouse reappeared outside of the element it left.\n * @returns {Function} - filtered handler to use to listen on the `mouseleave` event.\n */\nfunction ignoreMousedisappear(handler, { ignoreLeaveWindow = false, ignoreReappear = false } = {}) {\n return function leaveEventHandler(eLeave, ...rest) {\n const callback = handler.bind(this, eLeave, ...rest);\n\n // The mouse left: call the given callback if the mouse entered elsewhere\n if (eLeave.relatedTarget !== null) {\n return callback();\n }\n\n // Otherwise, check if the mouse actually left the window.\n // In firefox if the user switched between windows, the window sill have the focus by the time\n // the event is triggered. We have to debounce the event to test this case.\n setTimeout(function leaveEventDebouncer() {\n if (!ignoreLeaveWindow && document.hasFocus && !document.hasFocus()) {\n return callback();\n }\n\n // Otherwise, wait for the mouse to reeapear outside of the element,\n if (!ignoreReappear) {\n $(document).one('mouseenter', function reenterEventHandler(eReenter) {\n if (!$(eLeave.currentTarget).has(eReenter.target).length) {\n // Fill where the mouse finally entered.\n eLeave.relatedTarget = eReenter.target;\n callback();\n }\n });\n }\n\n }, 0);\n };\n}\n\n\nexport { rtl, GetYoDigits, RegExpEscape, transitionend, onLoad, ignoreMousedisappear };\n"],"names":["rtl","$","attr","GetYoDigits","length","namespace","str","chars","i","Math","floor","random","RegExpEscape","replace","transitionend","$elem","end","transitions","transition","WebkitTransition","MozTransition","OTransition","elem","document","createElement","style","setTimeout","triggerHandler","onLoad","handler","didLoad","readyState","eventType","cb","one","window","ignoreMousedisappear","ignoreLeaveWindow","ignoreReappear","eLeave","rest","callback","bind","this","relatedTarget","hasFocus","eReenter","currentTarget","has","target"],"mappings":"gCAOA,SAASA,IACP,MAAiC,QAA1BC,EAAE,QAAQC,KAAK,MACxB,CAUA,SAASC,EAAYC,EAAS,EAAGC,GAC/B,IAAIC,EAAM,GACV,MAAMC,EAAQ,uCAEd,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,EAAQI,IAC1BF,GAAOC,EAAME,KAAKC,MAFAH,GAEME,KAAKE,WAE/B,OAAON,EAAY,GAAGC,KAAOD,IAAcC,CAC7C,CAUA,SAASM,EAAaN,GACpB,OAAOA,EAAIO,QAAQ,2BAA4B,OACjD,CAEA,SAASC,EAAcC,GACrB,IAOIC,EAPAC,EAAc,CAChBC,WAAc,gBACdC,iBAAoB,sBACpBC,cAAiB,gBACjBC,YAAe,kBAEbC,EAAOC,SAASC,cAAc,OAGlC,IAAK,IAAIN,KAAcD,OACiB,IAA3BK,EAAKG,MAAMP,KACpBF,EAAMC,EAAYC,IAGtB,OAAIF,IAGFU,YAAW,WACTX,EAAMY,eAAe,gBAAiB,CAACZ,GACxC,GAAE,GACI,gBAEX,CAcA,SAASa,EAAOb,EAAOc,GACrB,MAAMC,EAAkC,aAAxBP,SAASQ,WACnBC,GAAaF,EAAU,WAAa,QAAU,kBAC9CG,EAAK,IAAMlB,EAAMY,eAAeK,GAWtC,OATIjB,IACEc,GAASd,EAAMmB,IAAIF,EAAWH,GAE9BC,EAC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