1 line
No EOL
12 KiB
Text
1 line
No EOL
12 KiB
Text
{"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","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","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,EAA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vB,GAAO,GAEnBgB,EAAkBhB,GAAO,IAG3B4C,OAAOb,iBAAiB,oBAAoB,WAC1CZ,SAASkB,eAAe,gBAAgBe,SAAW,WACjD7B,EAAY8B,KAAKtE,YA5JzB,CAgKIe,WAAa8C,OAAO9C,YAAc,IAEtCA,WAAW+C","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) {\n //Constants\n const THEME_KEY = \"ZULMA_THEME\";\n const THEME = localStorage.getItem(THEME_KEY);\n const STOP_BLINK_CSS_ID = \"stop-blink\";\n const STYLESHEET_CLASSNAME = \"stylesheet\";\n\n //Variables\n let previousLink = null;\n\n //Events\n /* The function called when the css has finished loading */\n const onLinkLoad = event => {\n //remove event listeners\n let link = event.currentTarget;\n link.removeEventListener(\"load\", onLinkLoad);\n link.removeEventListener(\"error\", onLinkError);\n //remove the previous stylesheet(s)\n removeStylesheets();\n //add stylesheet class\n link.className += STYLESHEET_CLASSNAME;\n //everything is good, so we don't need this\n previousLink = null;\n //make body visible again if it was hidden\n showBody();\n };\n\n const onLinkError = event => {\n //remove event listeners\n let link = event.currentTarget;\n link.removeEventListener(\"load\", onLinkLoad);\n link.removeEventListener(\"error\", onLinkError);\n //remove theme from localstorage\n clearTheme();\n //remove theme from dropdown list\n updateThemeSelect(link.id, false);\n //remove link from page\n link.remove();\n //re-add the previous stylesheet (if any)\n if (previousLink) {\n document.getElementsByTagName(\"head\")[0].appendChild(previousLink);\n }\n //set the theme select to the previous stylesheet\n updateThemeSelect(\n document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`)[0].id,\n true\n );\n //make body visible again if it was hidden\n showBody();\n };\n\n //Private Methods\n /* Called when the theme is changed */\n function changeTheme(themeName, firstLoad) {\n //create the css link element\n var fileref = document.createElement(\"link\");\n fileref.rel = \"stylesheet\";\n fileref.type = \"text/css\";\n fileref.href = `/${themeName}.css`;\n fileref.id = themeName;\n\n //append it to the head\n let link = document.getElementsByTagName(\"head\")[0].appendChild(fileref);\n\n //when it's loaded, call onLinkLoad\n link.addEventListener(\"load\", onLinkLoad);\n //if it errors, call onLinkError\n link.addEventListener(\"error\", onLinkError);\n\n //if this is the first load of the page, remove the current stylesheet early to avoid flash of wrongly styled content\n if (firstLoad) {\n //keep the old link in case something goes wrong\n previousLink = document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`)[0];\n removeStylesheets();\n }\n\n saveTheme(themeName);\n }\n\n /* Removes all current stylesheets on the page */\n function removeStylesheets() {\n document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`).forEach(el => {\n el.remove();\n });\n }\n\n /* Saves the current theme in localstorage */\n function saveTheme(themeName) {\n localStorage.setItem(THEME_KEY, themeName);\n }\n\n /* Clears the current theme in localstorage */\n function clearTheme() {\n localStorage.removeItem(THEME_KEY);\n }\n\n /* Hides the body of the page */\n function hideBody() {\n let head = document.getElementsByTagName(\"head\")[0];\n let style = document.createElement(\"style\");\n let css = \"body{visibility:hidden;}\";\n\n style.id = STOP_BLINK_CSS_ID;\n style.setAttribute(\"type\", \"text/css\");\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n head.appendChild(style);\n }\n\n /* Shows the body of the page */\n function showBody() {\n let css = document.getElementById(STOP_BLINK_CSS_ID);\n if (css) css.remove();\n }\n\n /* Either sets the theme selection to the given theme, or removes it from the list */\n function updateThemeSelect(theme, setSelected) {\n //get all select options\n let elements = document.querySelectorAll(\"#theme-select>option\");\n //if there are elements, the page is loaded and continue\n if (elements.length) {\n elements.forEach(element => {\n if (element.value === theme) {\n if (setSelected) {\n element.selected = \"selected\";\n } else {\n element.remove();\n }\n }\n });\n } else {\n //if there are no elements, the page is not yet loaded; wait for loaded event and try again.\n window.addEventListener(\"DOMContentLoaded\", () => {\n updateThemeSelect(theme, setSelected);\n });\n }\n }\n\n //Public Methods\n switch_css.init = function() {\n //if user has selected and theme and it is not the current theme\n if (THEME && !document.getElementById(THEME)) {\n //hide the body to stop FOUC\n hideBody();\n //change the theme\n changeTheme(THEME, true);\n //when the DOM is loaded, change the select to their current choice\n updateThemeSelect(THEME, true);\n }\n //when the DOM is loaded, set the dropdown to trigger the theme change\n window.addEventListener(\"DOMContentLoaded\", () => {\n document.getElementById(\"theme-select\").onchange = function() {\n changeTheme(this.value);\n };\n });\n };\n})((switch_css = window.switch_css || {})); // eslint-disable-line\n\nswitch_css.init(); // eslint-disable-line\n"],"sourceRoot":""} |