{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/zulma_switchcss.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","switch_css","THEME_KEY","THEME","localStorage","getItem","STOP_BLINK_CSS_ID","STYLESHEET_CLASSNAME","previousLink","baseUrl","onLinkLoad","event","link","currentTarget","removeEventListener","onLinkError","removeStylesheets","className","showBody","removeItem","updateThemeSelect","id","remove","document","getElementsByTagName","appendChild","querySelectorAll","changeTheme","themeName","firstLoad","fileref","createElement","rel","type","href","addEventListener","setItem","saveTheme","forEach","el","css","getElementById","theme","setSelected","elements","length","element","selected","window","init","url","head","style","setAttribute","styleSheet","cssText","createTextNode","onchange","this"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAA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AAY2B,GAwCfzB,EAAYxB,GAAO,GAEnBiB,EAAkBjB,GAAO,IAG3B6C,OAAOb,iBAAiB,oBAAoB,WAC1CZ,SAASkB,eAAe,gBAAgBgB,SAAW,WACjD9B,EAAY+B,KAAKxE,YA9JzB,CAkKIe,WAAa+C,OAAO/C,YAAc","file":"zulma_switchcss.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","(function (switch_css) {\r\n //Constants\r\n const THEME_KEY = \"ZULMA_THEME\";\r\n const THEME = localStorage.getItem(THEME_KEY);\r\n const STOP_BLINK_CSS_ID = \"stop-blink\";\r\n const STYLESHEET_CLASSNAME = \"stylesheet\";\r\n\r\n //Variables\r\n let previousLink = null;\r\n let baseUrl = \"\";\r\n\r\n //Events\r\n /* The function called when the css has finished loading */\r\n const onLinkLoad = event => {\r\n //remove event listeners\r\n let link = event.currentTarget;\r\n link.removeEventListener(\"load\", onLinkLoad);\r\n link.removeEventListener(\"error\", onLinkError);\r\n //remove the previous stylesheet(s)\r\n removeStylesheets();\r\n //add stylesheet class\r\n link.className += STYLESHEET_CLASSNAME;\r\n //everything is good, so we don't need this\r\n previousLink = null;\r\n //make body visible again if it was hidden\r\n showBody();\r\n };\r\n\r\n const onLinkError = event => {\r\n //remove event listeners\r\n let link = event.currentTarget;\r\n link.removeEventListener(\"load\", onLinkLoad);\r\n link.removeEventListener(\"error\", onLinkError);\r\n //remove theme from localstorage\r\n clearTheme();\r\n //remove theme from dropdown list\r\n updateThemeSelect(link.id, false);\r\n //remove link from page\r\n link.remove();\r\n //re-add the previous stylesheet (if any)\r\n if (previousLink) {\r\n document.getElementsByTagName(\"head\")[0].appendChild(previousLink);\r\n }\r\n //set the theme select to the previous stylesheet\r\n updateThemeSelect(\r\n document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`)[0].id,\r\n true\r\n );\r\n //make body visible again if it was hidden\r\n showBody();\r\n };\r\n\r\n //Private Methods\r\n /* Called when the theme is changed */\r\n function changeTheme(themeName, firstLoad) {\r\n //create the css link element\r\n var fileref = document.createElement(\"link\");\r\n fileref.rel = \"stylesheet\";\r\n fileref.type = \"text/css\";\r\n fileref.href = `${baseUrl}/${themeName}.css`;\r\n fileref.id = themeName;\r\n\r\n //append it to the head\r\n let link = document.getElementsByTagName(\"head\")[0].appendChild(fileref);\r\n\r\n //when it's loaded, call onLinkLoad\r\n link.addEventListener(\"load\", onLinkLoad);\r\n //if it errors, call onLinkError\r\n link.addEventListener(\"error\", onLinkError);\r\n\r\n //if this is the first load of the page, remove the current stylesheet early to avoid flash of wrongly styled content\r\n if (firstLoad) {\r\n //keep the old link in case something goes wrong\r\n previousLink = document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`)[0];\r\n removeStylesheets();\r\n }\r\n\r\n saveTheme(themeName);\r\n }\r\n\r\n /* Removes all current stylesheets on the page */\r\n function removeStylesheets() {\r\n document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`).forEach(el => {\r\n el.remove();\r\n });\r\n }\r\n\r\n /* Saves the current theme in localstorage */\r\n function saveTheme(themeName) {\r\n localStorage.setItem(THEME_KEY, themeName);\r\n }\r\n\r\n /* Clears the current theme in localstorage */\r\n function clearTheme() {\r\n localStorage.removeItem(THEME_KEY);\r\n }\r\n\r\n /* Hides the body of the page */\r\n function hideBody() {\r\n let head = document.getElementsByTagName(\"head\")[0];\r\n let style = document.createElement(\"style\");\r\n let css = \"body{visibility:hidden;}\";\r\n\r\n style.id = STOP_BLINK_CSS_ID;\r\n style.setAttribute(\"type\", \"text/css\");\r\n\r\n if (style.styleSheet) {\r\n style.styleSheet.cssText = css;\r\n } else {\r\n style.appendChild(document.createTextNode(css));\r\n }\r\n head.appendChild(style);\r\n }\r\n\r\n /* Shows the body of the page */\r\n function showBody() {\r\n let css = document.getElementById(STOP_BLINK_CSS_ID);\r\n if (css) css.remove();\r\n }\r\n\r\n /* Either sets the theme selection to the given theme, or removes it from the list */\r\n function updateThemeSelect(theme, setSelected) {\r\n //get all select options\r\n let elements = document.querySelectorAll(\"#theme-select>option\");\r\n //if there are elements, the page is loaded and continue\r\n if (elements.length) {\r\n elements.forEach(element => {\r\n if (element.value === theme) {\r\n if (setSelected) {\r\n element.selected = \"selected\";\r\n } else {\r\n element.remove();\r\n }\r\n }\r\n });\r\n } else {\r\n //if there are no elements, the page is not yet loaded; wait for loaded event and try again.\r\n window.addEventListener(\"DOMContentLoaded\", () => {\r\n updateThemeSelect(theme, setSelected);\r\n });\r\n }\r\n }\r\n\r\n //Public Methods\r\n switch_css.init = function (url) {\r\n baseUrl = url\r\n //if user has selected and theme and it is not the current theme\r\n if (THEME && !document.getElementById(THEME)) {\r\n //hide the body to stop FOUC\r\n hideBody();\r\n //change the theme\r\n changeTheme(THEME, true);\r\n //when the DOM is loaded, change the select to their current choice\r\n updateThemeSelect(THEME, true);\r\n }\r\n //when the DOM is loaded, set the dropdown to trigger the theme change\r\n window.addEventListener(\"DOMContentLoaded\", () => {\r\n document.getElementById(\"theme-select\").onchange = function () {\r\n changeTheme(this.value);\r\n };\r\n });\r\n };\r\n})((switch_css = window.switch_css || {})); // eslint-disable-line"],"sourceRoot":""}