daux.io/themes/daux/js/daux.min.js.map

1 line
9.2 KiB
Plaintext
Raw Normal View History

{"version":3,"file":"daux.min.js.map","sources":["../../../src/js/theme_daux/utils.js","../../../src/js/theme_daux/code_toggle.js","../../../src/js/theme_daux/menu.js","../../../src/js/theme_daux/hamburger.js","../../../src/js/theme_daux/highlight.js"],"sourcesContent":["/* eslint-disable @swissquote/swissquote/import/prefer-default-export */\n\nexport function ready(fn) {\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", fn);\n } else {\n fn();\n }\n}\n","import { ready } from \"./utils\";\n\nconst LOCAL_STORAGE_KEY = \"daux_code_blocks_hidden\";\n\nfunction setCodeBlockStyle(codeBlocks, hidden) {\n for (let a = 0; a < codeBlocks.length; a++) {\n codeBlocks[a].classList.toggle(\"CodeToggler--hidden\", hidden);\n }\n try {\n localStorage.setItem(LOCAL_STORAGE_KEY, hidden);\n } catch (e) {\n // local storage operations can fail with the file:// protocol\n }\n}\n\nfunction enableToggler(toggleCodeSection, codeBlocks) {\n const toggleCodeBlockBtnSet = toggleCodeSection.querySelector(\n \".CodeToggler__button--main\"\n ); // available when floating is disabled\n\n toggleCodeBlockBtnSet.addEventListener(\n \"change\",\n ev => {\n setCodeBlockStyle(codeBlocks, !ev.target.checked);\n },\n false\n );\n\n let hidden = false;\n try {\n hidden = localStorage.getItem(LOCAL_STORAGE_KEY);\n\n if (hidden === \"false\") {\n hidden = false;\n } else if (hidden === \"true\") {\n hidden = true;\n }\n\n if (hidden) {\n setCodeBlockStyle(codeBlocks, !!hidden);\n toggleCodeBlockBtnSet.checked = !hidden;\n }\n } catch (e) {\n // local storage operations can fail with the file:// protocol\n }\n}\n\nready(() => {\n const codeBlocks = document.querySelectorAll(\".s-content pre\");\n const toggleCodeSection = document.querySelector(\".CodeToggler\");\n\n if (!toggleCodeSection) {\n return;\n }\n\n if (codeBlocks.length) {\n enableToggler(toggleCodeSection, codeBlocks);\n } else {\n toggleCodeSection.classList.add(\"CodeToggler--hidden\");\n }\n});\n","import { ready } from \"./utils\";\n\n/**\n * After the transition finishes set the height to auto so child\n * menus can expand properly.\n * @param {Element} item\n */\nfunction resetHeightAfterAnimation(item) {\n const setHeightToAuto = ev => {\n if (ev.target.style.height !== \"0px\") {\n ev.target.style.height = \"auto\";\n }\n\n ev.target.removeEventListener(\"transitionend\", setHeightToAuto);\n };\n\n item.addEventListener(\"transitionend\", setHeightToAuto);\n}\n\nfunction findNavItem(start) {\n let elem = start;\n while ((elem = elem.parentNode) && elem.nodeType !== 9) {\n if (elem.nodeType === 1 && elem.classList.contains(\"Nav__item\")) {\n return elem;\n }\n }\n\n throw new Error(\"Could not find a NavItem...\");\n}\n\nfunction toggleSubMenu(ev) {\n const isEvent = ev.preventDefault !== undefined;\n\n if (isEvent) {\n ev.preventDefault();\n }\n\n const parent = findNavItem(ev.target);\n const subNav = parent.querySelector(\"ul.Nav\");\n\n if (isEvent && parent.classList.contains(\"Nav__item--open\")) {\n // Temporarily set the height so the transition can work.\n subNav.style.height = `${subNav.scrollHeight}px`;\n subNav.style.transitionDuration = \"150ms\";\n subNav.style.height = \"0px\";\n parent.classList.remove(\"Nav__item--open\");\n } else {\n if (isEvent) {\n subNav.style.transitionDuration = \"150ms\";\n resetHeightAfterAnimation(subNav);\n subNav.style.height = `${subNav.scrollHeight}px`;\n parent.classList.add(\"Nav__item--open\");\n } else {\n // When running at page load the transitions don't need to fire and\n // the classList doesn't need to be altered