{"version":3,"file":"main.min.js","sources":["../../../Hedeparken.Frontend/js/utils/helpers.js","../../../Hedeparken.Frontend/js/utils/onReady.js","../../../Hedeparken.Frontend/js/utils/scrollPosition.js","../../../Hedeparken.Frontend/js/utils/elementProperties.js","../../../Hedeparken.Frontend/js/utils/scrollLock.js","../../../Hedeparken.Frontend/js/modules/navigation.js","../../../Hedeparken.Frontend/js/utils/windowResize.js","../../../node_modules/sal.js/dist/sal.js","../../../Hedeparken.Frontend/js/utils/scrollTo.js","../../../Hedeparken.Frontend/js/utils/variables.js","../../../node_modules/rellax/rellax.js","../../../Hedeparken.Frontend/js/modules/rellax.js","../../../node_modules/intersection-observer/intersection-observer.js","../../../Hedeparken.Frontend/js/main.js","../../../Hedeparken.Frontend/js/modules/faq.js","../../../Hedeparken.Frontend/js/modules/anchors.js"],"sourcesContent":["export const transitionEndEventName = detectTransitionEndEventName();\r\n\r\nexport function detectTransitionEndEventName() {\r\n\r\n const transitions = {\r\n \"transition\": \"transitionend\",\r\n \"OTransition\": \"oTransitionEnd\",\r\n \"MozTransition\": \"transitionend\",\r\n \"WebkitTransition\": \"webkitTransitionEnd\"\r\n };\r\n\r\n const el = document.createElement(\"div\");\r\n\r\n for (const t in transitions) {\r\n if (el.style[t] !== undefined) {\r\n return transitions[t];\r\n }\r\n }\r\n return \"\";\r\n}\r\n\r\nexport function isVisible (elem) {\r\n return !!elem && !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length);\r\n}\r\n\r\nexport function cssAnimateNewHeight(container, classTarget = container, classOnBoth = false) {\r\n let newHeight;\r\n const prevHeight = container.offsetHeight;\r\n\r\n const delayedClose = () => {\r\n if (classOnBoth) {\r\n container.classList.remove('open');\r\n classTarget.classList.remove('open');\r\n } else {\r\n classTarget.classList.remove('open');\r\n }\r\n\r\n classTarget.blur(); // removes focus if its a button\r\n container.removeEventListener(transitionEndEventName, delayedClose);\r\n };\r\n\r\n container.removeAttribute('style');\r\n\r\n if (classTarget.classList.contains('open')) {\r\n newHeight = 0;\r\n container.addEventListener(transitionEndEventName, delayedClose);\r\n\r\n if (classOnBoth) {\r\n classTarget.classList.remove('open');\r\n }\r\n } else {\r\n classTarget.classList.add('open');\r\n\r\n if (classOnBoth) {\r\n container.classList.add('open');\r\n }\r\n\r\n newHeight = container.offsetHeight;\r\n }\r\n\r\n container.style.height = `${prevHeight}px`;\r\n\r\n setTimeout(() => {\r\n container.style.height = `${newHeight}px`;\r\n }, 10);\r\n}\r\n\r\nexport function setupReadmore(selector = '[data-action*=\"readmore\"]') {\r\n const readMoreBtns = document.body.querySelectorAll(selector);\r\n\r\n for (let i = 0; i < readMoreBtns.length; i++) {\r\n const readMoreBtn = readMoreBtns[i];\r\n const readMoreContainer = readMoreBtn.hasAttribute('data-target') ? document.getElementById(readMoreBtn.getAttribute('data-target').replace('#', '')) : readMoreBtn.nextElementSibling;\r\n\r\n if (readMoreContainer != null) {\r\n readMoreBtn.addEventListener('click', e => {\r\n e.preventDefault();\r\n\r\n cssAnimateNewHeight(readMoreContainer, readMoreBtn, true);\r\n });\r\n }\r\n\r\n }\r\n}\r\n\r\nexport function polyfillClosest() {\r\n Element.prototype.closest = function (selector) {\r\n const theparent = this.parentNode;\r\n const find = document.querySelectorAll(selector);\r\n\r\n if (theparent !== document.body) {\r\n let found = false;\r\n\r\n for (let a = 0; a < find.length; a++) {\r\n if (find[a] === theparent) {\r\n found = true;\r\n }\r\n }\r\n\r\n if (found) {\r\n return theparent;\r\n } else {\r\n return this.parentNode.closest(selector);\r\n }\r\n } else {\r\n return 0;\r\n }\r\n };\r\n}\r\n\r\nexport function scrollTo(element, to, duration) {\r\n const start = element.scrollTop,\r\n change = to - start,\r\n increment = 20;\r\n\r\n const animateScroll = function (elapsedTime) {\r\n elapsedTime += increment;\r\n const position = easeInOut(elapsedTime, start, change, duration);\r\n element.scrollTop = position;\r\n\r\n if (elapsedTime < duration) {\r\n setTimeout(() => {\r\n animateScroll(elapsedTime);\r\n }, increment);\r\n }\r\n };\r\n\r\n animateScroll(0);\r\n}\r\n\r\nfunction easeInOut(currentTime, start, change, duration) {\r\n currentTime /= duration / 2;\r\n if (currentTime < 1) {\r\n return change / 2 * currentTime * currentTime + start;\r\n }\r\n currentTime -= 1;\r\n return -change / 2 * (currentTime * (currentTime - 2) - 1) + start;\r\n}\r\n\r\n/**\r\n * Find out whether or not the given argument is an element that would react somewhat normally to DOM-manipulations.\r\n *\r\n * @param {*} element - The element to check.\r\n * @returns {boolean} `true` if the given argument is an element (or document, or window), and `false` otherwise.\r\n */\r\nexport function isElement(element) {\r\n return element instanceof Element ||\r\n element instanceof Document ||\r\n element instanceof Window;\r\n}\r\n","/**\r\n * Handler to trigger callbacks once the browser is ready for them.\r\n *\r\n * You can keep adding references using onReady() even after the page is loaded. In that case they will be\r\n * run at once.\r\n *\r\n * @example\r\n * import { onReady } from './utils/events/onReady';\r\n *\r\n * onReady(yourFunctionHere);\r\n *\r\n */\r\n\r\nlet functionReferences = [];\r\n\r\n// Set the initial readyState based on the browser's current state. If the script has been loaded\r\n// asynchronously, the DOM might be ready for us already, in which case there's no reason to delay\r\n// any further processing. The following will evaluate as true if the DOM is ready, or the page is\r\n// complete.\r\nlet readyState = document.readyState === \"interactive\" || document.readyState === \"complete\";\r\n\r\n\r\n// Defines whether or not the window.onReady event has been bound, so we won't do it twice. That\r\n// would just be stupid.\r\nlet readyEventBound = false;\r\n\r\n\r\n\r\n/**\r\n * Run the given array of callback functions.\r\n *\r\n * @private\r\n * @param {Array} funcArray\r\n */\r\nfunction runFunctionArray(funcArray) {\r\n funcArray.forEach(funcRef => funcRef());\r\n}\r\n\r\n\r\n/**\r\n * Empty the callback arrays\r\n *\r\n * @private\r\n */\r\nfunction emptyCallbackArrays() {\r\n\r\n // Keep iterating through the function references until there are none left.\r\n while (functionReferences.length) {\r\n\r\n // Set up a temporary array that mirrors the list of callbacks, and empty the real one.\r\n const tempArray = functionReferences.slice(0);\r\n functionReferences = [];\r\n\r\n // Run the callbacks. The callbacks themselves may set up more callbacks, which\r\n // is why we keep looping the array until we're done.\r\n runFunctionArray(tempArray);\r\n\r\n }\r\n\r\n // At this point we'll assume we're ready for anything!\r\n readyState = true;\r\n}\r\n\r\n\r\n/**\r\n * Make sure the \"ready\"-event is set.\r\n *\r\n * @private\r\n */\r\nfunction bindReadyEvent() {\r\n\r\n if (!readyEventBound) {\r\n if (document.readyState === 'loading') {\r\n // loading yet, wait for the event\r\n document.addEventListener('DOMContentLoaded', emptyCallbackArrays);\r\n } else {\r\n // DOM is ready!\r\n emptyCallbackArrays();\r\n }\r\n\r\n readyEventBound = true;\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Register a function to run when the page is ready.\r\n *\r\n * @param {Function} functionReference - The function you want to run.\r\n */\r\nexport function onReady(functionReference) {\r\n\r\n if (typeof functionReference === \"function\") {\r\n if (readyState) {\r\n functionReference();\r\n } else {\r\n\r\n bindReadyEvent();\r\n\r\n functionReferences.push(functionReference);\r\n }\r\n }\r\n}\r\n","import { activityThrottler } from \"../utils/trottle\";\r\n\r\n//use window.scrollY\r\nlet scrollpos = window.scrollY;\r\nconst header = document.getElementById(\"header\");\r\n\r\n// eslint-disable-next-line camelcase\r\nfunction addClassOnScroll() {\r\n header.classList.add(\"scroll\");\r\n}\r\n\r\n// eslint-disable-next-line camelcase\r\nfunction removeClassOnScroll() {\r\n header.classList.remove(\"scroll\");\r\n}\r\n\r\n\r\nfunction scrollEvent() {\r\n //Here you forgot to update the value\r\n scrollpos = window.scrollY;\r\n\r\n if (scrollpos > 10) {\r\n addClassOnScroll();\r\n }\r\n else {\r\n removeClassOnScroll();\r\n }\r\n}\r\n\r\nexport function initScrollHeader() {\r\n window.addEventListener('scroll', () => {\r\n scrollEvent();\r\n });\r\n\r\n}\r\n","/**\r\n * Utilities for checking properties and states of elements.\r\n */\r\n\r\n\r\nimport { isElement } from \"./helpers\";\r\n\r\n\r\n/**\r\n * Check if an element is empty.\r\n *\r\n * @param {Node} element - Check if this element is empty.\r\n * @param {boolean} [strict=true] - Set this to **false** to ignore nodes with whitespace.\r\n * @returns {boolean} **True** if the element is empty.\r\n */\r\nexport function elementIsEmpty(element, strict = true) {\r\n return strict ? !element.childNodes.length : !element.innerHTML.trim().length;\r\n}\r\n\r\n\r\n/**\r\n * Check if an element is hidden in the DOM with `display: none;`\r\n *\r\n * @param {HTMLElement} element - The element to check.\r\n * @returns {boolean} **True** if element is hidden, otherwise **false**.\r\n */\r\nexport function elementIsHidden(element) {\r\n return element.offsetParent === null;\r\n}\r\n\r\n\r\n/**\r\n * Return the position of an element\r\n *\r\n * @param {Element|String} element - The HTML element to work with or its ID\r\n * @param {Element|String|Window} [relativeTo=window] - The HTML element to return the position relative to or its ID\r\n * @returns {{top: Number, left: Number}} An object with top and left positions in pixels\r\n *\r\n *\r\n * @example