From 800363c6ab9a73c464c64093e0874d4f91fd0025 Mon Sep 17 00:00:00 2001 From: Robert Clarke Date: Tue, 14 May 2019 13:29:45 +0100 Subject: [PATCH] made .box look better on newer themes; updated readme.md to add new themes; modularized blog sass some --- README.md | 6 +- content/_index.md | 3 + sass/_blog.scss | 114 ++++--------------------------- sass/_blog/_article.scss | 39 +++++++++++ sass/_blog/_nav.scss | 10 +++ sass/_blog/_pagination.scss | 8 +++ sass/_blog/_search-results.scss | 26 +++++++ sass/lux.scss | 9 +++ sass/pulse.scss | 10 +-- sass/simplex.scss | 10 +-- sass/slate.scss | 9 +++ sass/solar.scss | 9 +++ sass/superhero.scss | 9 +++ static/js/zulma_search.js.map | 2 +- static/js/zulma_switchcss.js.map | 2 +- 15 files changed, 143 insertions(+), 123 deletions(-) create mode 100644 content/_index.md create mode 100644 sass/_blog/_article.scss create mode 100644 sass/_blog/_nav.scss create mode 100644 sass/_blog/_pagination.scss create mode 100644 sass/_blog/_search-results.scss diff --git a/README.md b/README.md index 507fd46..3782279 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Zulma -A Bulma theme for Zola. +A Bulma theme for Zola. See a live preview [here](https://festive-morse-47d46c.netlify.com/) ![Zulma Screenshot](/screenshot.png) @@ -187,6 +187,10 @@ In extra, setting `zulma_theme` to a valid value will change the current colour - flatly - pulse - simplex +- lux +- slate +- solar +- superhero All valid themes can also be found under the `extra.zulma_themes` variable in the `theme.toml`. Choosing no theme will set default as the theme. Setting an invalid theme value will cause the site to render improperly. diff --git a/content/_index.md b/content/_index.md new file mode 100644 index 0000000..45910c9 --- /dev/null +++ b/content/_index.md @@ -0,0 +1,3 @@ ++++ +paginate_by=1 ++++ \ No newline at end of file diff --git a/sass/_blog.scss b/sass/_blog.scss index e91eed1..0e7f6b1 100644 --- a/sass/_blog.scss +++ b/sass/_blog.scss @@ -1,3 +1,6 @@ +@import "./_blog/article"; +@import "./_blog/search-results"; + html, body { font-family: "Open Sans", sans-serif; @@ -11,9 +14,13 @@ main { flex: 1; } -.navbar-brand .brand-text { - font-size: 1.11rem; - font-weight: bold; +.footer { + margin-top: 4rem; + padding: 2rem; + + .theme-select-container { + margin-left: auto; + } } .hero .title { @@ -28,110 +35,13 @@ main { } } -.media-center { - display: block; - margin-bottom: 1rem; -} - -.media-content { - margin-top: 1rem; -} - -.article { - margin-top: 1rem; -} - -.article-title { - font-size: 2rem; - font-weight: lighter; - line-height: 2; - margin-bottom: 0.5rem; -} - -.article-subtitle { - margin-bottom: 3rem; -} - -.article-footer, -.article-body { - margin: 2rem 0; - - @include desktop { - margin: 2rem 6rem; - } -} - -.article-body { - line-height: 1.4; -} - -.article-footer { - font-style: italic; - padding: 1.5rem; - width: 100%; - - .button, - .tag { - font-style: normal; - } -} - .list.box { margin-top: 1rem; display: flex; flex-direction: row; flex-wrap: wrap; - > a { + >a { margin: 0.2rem; } -} - -.paginator-container { - padding: 2rem 0; -} - -.search-results { - display: none; - max-height: 35rem; - overflow: auto; - - @include desktop { - position: absolute; - top: 100%; - width: 50rem; - right: 0; - margin-right: 0.75rem; - } -} - -.search-results__items > li { - list-style: none; - margin-top: 1rem; - - &:first-child { - margin-top: 0; - } -} - -.navbar-end { - height: 100%; -} - -input#search::placeholder { - color: $grey-darker; -} - -.footer { - margin-top: 4rem; - padding: 2rem; -} - -.pagination-previous, -.pagination-next { - flex-grow: 0; -} - -.theme-select-container { - margin-left: auto; -} +} \ No newline at end of file diff --git a/sass/_blog/_article.scss b/sass/_blog/_article.scss new file mode 100644 index 0000000..7a2a421 --- /dev/null +++ b/sass/_blog/_article.scss @@ -0,0 +1,39 @@ +.article { + margin-top: 1rem; + + + .article-title { + font-size: 2rem; + font-weight: lighter; + line-height: 2; + margin-bottom: 0.5rem; + } + + .article-subtitle { + margin-bottom: 3rem; + } + + .article-footer, + .article-body { + margin: 2rem 0; + + @include desktop { + margin: 2rem 6rem; + } + } + + .article-body { + line-height: 1.4; + } + + .article-footer { + font-style: italic; + padding: 1.5rem; + width: 100%; + + .button, + .tag { + font-style: normal; + } + } +} \ No newline at end of file diff --git a/sass/_blog/_nav.scss b/sass/_blog/_nav.scss new file mode 100644 index 0000000..f36f932 --- /dev/null +++ b/sass/_blog/_nav.scss @@ -0,0 +1,10 @@ +nav { + .navbar-end { + height: 100%; + } + + .navbar-brand .brand-text { + font-size: 1.11rem; + font-weight: bold; + } +} \ No newline at end of file diff --git a/sass/_blog/_pagination.scss b/sass/_blog/_pagination.scss new file mode 100644 index 0000000..78d3756 --- /dev/null +++ b/sass/_blog/_pagination.scss @@ -0,0 +1,8 @@ +.paginator-container { + padding: 2rem 0; + + .pagination-previous, + .pagination-next { + flex-grow: 0; + } +} \ No newline at end of file diff --git a/sass/_blog/_search-results.scss b/sass/_blog/_search-results.scss new file mode 100644 index 0000000..1934274 --- /dev/null +++ b/sass/_blog/_search-results.scss @@ -0,0 +1,26 @@ +.search-results { + display: none; + max-height: 35rem; + overflow: auto; + + @include desktop { + position: absolute; + top: 100%; + width: 50rem; + right: 0; + margin-right: 0.75rem; + } + + .search-results__items>li { + list-style: none; + margin-top: 1rem; + + &:first-child { + margin-top: 0; + } + } +} + +input#search::placeholder { + color: $grey-darker; +} \ No newline at end of file diff --git a/sass/lux.scss b/sass/lux.scss index 29add62..ab35e5a 100644 --- a/sass/lux.scss +++ b/sass/lux.scss @@ -3,3 +3,12 @@ @import "./_vendor/lux/overrides"; @import "./blog"; + +.box { + $card-border-color: $grey-darker; + $border-width: 2px default; + box-shadow: none; + border: $border-width solid $card-border-color; + background-color: $grey-darker; + border-radius: $radius; +} \ No newline at end of file diff --git a/sass/pulse.scss b/sass/pulse.scss index c2af8da..5f7f8e9 100644 --- a/sass/pulse.scss +++ b/sass/pulse.scss @@ -2,12 +2,4 @@ @import './_vendor/bulma-0.7.4/_bulma.sass'; @import './_vendor/pulse/overrides'; -@import './blog'; - -// .box { -// $card-border-color: lighten($grey-darker, 5); -// box-shadow: none; -// border: $border-width solid $card-border-color; -// background-color: $grey-darker; -// border-radius: $radius; -// } \ No newline at end of file +@import './blog'; \ No newline at end of file diff --git a/sass/simplex.scss b/sass/simplex.scss index 9a8b591..da4e9d8 100644 --- a/sass/simplex.scss +++ b/sass/simplex.scss @@ -2,12 +2,4 @@ @import './_vendor/bulma-0.7.4/_bulma.sass'; @import './_vendor/simplex/overrides'; -@import './blog'; - -// .box { -// $card-border-color: lighten($grey-darker, 5); -// box-shadow: none; -// border: $border-width solid $card-border-color; -// background-color: $grey-darker; -// border-radius: $radius; -// } \ No newline at end of file +@import './blog'; \ No newline at end of file diff --git a/sass/slate.scss b/sass/slate.scss index 2c717fc..0baead9 100644 --- a/sass/slate.scss +++ b/sass/slate.scss @@ -3,3 +3,12 @@ @import "./_vendor/slate/overrides"; @import "./blog"; + +.box { + $card-border-color: lighten($grey-darker, 5); + $border-width: 2px default; + box-shadow: none; + border: $border-width solid $card-border-color; + background-color: $grey-darker; + border-radius: $radius; +} \ No newline at end of file diff --git a/sass/solar.scss b/sass/solar.scss index 4d5e98a..9caddcb 100644 --- a/sass/solar.scss +++ b/sass/solar.scss @@ -3,3 +3,12 @@ @import "./_vendor/solar/overrides"; @import "./blog"; + +.box { + $card-border-color: lighten($grey-darker, 5); + $border-width: 2px default; + box-shadow: none; + border: $border-width solid $card-border-color; + background-color: $grey-darker; + border-radius: $radius; +} \ No newline at end of file diff --git a/sass/superhero.scss b/sass/superhero.scss index cb5c7bf..b41f4ba 100644 --- a/sass/superhero.scss +++ b/sass/superhero.scss @@ -3,3 +3,12 @@ @import "./_vendor/superhero/overrides"; @import "./blog"; + +.box { + $card-border-color: lighten($grey-darker, 5); + $border-width: 2px default; + box-shadow: none; + border: $border-width solid $card-border-color; + background-color: $grey-darker; + border-radius: $radius; +} \ No newline at end of file diff --git a/static/js/zulma_search.js.map b/static/js/zulma_search.js.map index a9f61cc..0e9e387 100644 --- a/static/js/zulma_search.js.map +++ b/static/js/zulma_search.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/zulma_search.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","formatSearchResultItem","item","terms","concat","ref","doc","title","body","stemmedTerms","map","w","elasticlunr","stemmer","toLowerCase","termFound","index","weighted","sentences","split","words","j","word","length","k","startsWith","push","windowWeights","windowSize","Math","min","curSum","maxSumIndex","maxFound","teaser","startIndex","substring","join","makeTeaser","initSearch","func","wait","timeout","$searchInput","document","getElementById","$searchResults","querySelector","$searchResultsItems","options","bool","fields","boost","Index","load","window","searchIndex","addEventListener","term","trim","style","display","innerHTML","results","search","createElement","appendChild","context","this","args","arguments","clearTimeout","setTimeout","apply","readyState","documentElement","doScroll"],"mappings":"aACA,IAAAA,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,GAAA,CACAG,EAAAH,EACAI,GAAA,EACAH,QAAA,IAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CZ,EAAAkB,EAAA,SAAAhB,GACA,oBAAAiB,eAAAC,aACAN,OAAAC,eAAAb,EAAAiB,OAAAC,YAAA,CAAwDC,MAAA,WAExDP,OAAAC,eAAAb,EAAA,cAAiDmB,OAAA,KAQjDrB,EAAAsB,EAAA,SAAAD,EAAAE,GAEA,GADA,EAAAA,IAAAF,EAAArB,EAAAqB,IACA,EAAAE,EAAA,OAAAF,EACA,KAAAE,GAAA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,OAAQ,CACN5C,MAAO,CACL6C,MAAO,GAET5C,KAAM,CACJ4C,MAAO,KAKTpC,EAAQJ,YAAYyC,MAAMC,KAAKC,OAAOC,aAE1Cb,EAAac,iBAAiB,SAtJdjB,EAsJgC,WAC9C,IAAIkB,EAAOf,EAAazD,MAAMyE,OAC9B,GAAK3C,IAGL8B,EAAec,MAAMC,QAAmB,KAATH,EAAc,OAAS,QACtDV,EAAoBc,UAAY,GACnB,KAATJ,GAAJ,CAIA,IAAIK,EAAU/C,EAAMgD,OAAON,EAAMT,GACjC,GAAuB,IAAnBc,EAAQxC,OAAZ,CAKcmC,EACd,IAAK,IAAIzF,EAAI,EAAGA,EAAI4D,KAAKC,IAAIiC,EAAQxC,OAlCvB,IAkC2CtD,IAAK,CAC5D,IAAIiC,EAAO0C,SAASqB,cAAc,MAClC/D,EAAK4D,UAAY7D,EAAuB8D,EAAQ9F,GAAIyF,EAAKvC,MAAM,MAC/D6B,EAAoBkB,YAAYhE,SARhC4C,EAAec,MAAMC,QAAU,SAnKbpB,EA6KnB,IA1KI,WACL,IAAI0B,EAAUC,KACVC,EAAOC,UACXC,aAAa7B,GAEbA,EAAU8B,WAAW,WACnB9B,EAAU,KACVF,EAAKiC,MAAMN,EAASE,IACnB5B,MAsKqB,aAAxBG,SAAS8B,YACc,YAAxB9B,SAAS8B,aAA6B9B,SAAS+B,gBAAgBC,SAEhErC,IAEAK,SAASa,iBAAiB,mBAAoBlB","file":"zulma_search.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 = 1);\n","/* eslint-disable */\r\n\r\nfunction debounce(func, wait) {\r\n var timeout;\r\n\r\n return function () {\r\n var context = this;\r\n var args = arguments;\r\n clearTimeout(timeout);\r\n\r\n timeout = setTimeout(function () {\r\n timeout = null;\r\n func.apply(context, args);\r\n }, wait);\r\n };\r\n}\r\n\r\n// Taken from mdbook\r\n// The strategy is as follows:\r\n// First, assign a value to each word in the document:\r\n// Words that correspond to search terms (stemmer aware): 40\r\n// Normal words: 2\r\n// First word in a sentence: 8\r\n// Then use a sliding window with a constant number of words and count the\r\n// sum of the values of the words within the window. Then use the window that got the\r\n// maximum sum. If there are multiple maximas, then get the last one.\r\n// Enclose the terms in .\r\nfunction makeTeaser(body, terms) {\r\n var TERM_WEIGHT = 40;\r\n var NORMAL_WORD_WEIGHT = 2;\r\n var FIRST_WORD_WEIGHT = 8;\r\n var TEASER_MAX_WORDS = 30;\r\n\r\n var stemmedTerms = terms.map(function (w) {\r\n return elasticlunr.stemmer(w.toLowerCase());\r\n });\r\n var termFound = false;\r\n var index = 0;\r\n var weighted = []; // contains elements of [\"word\", weight, index_in_document]\r\n\r\n // split in sentences, then words\r\n var sentences = body.toLowerCase().split(\". \");\r\n\r\n for (var i in sentences) {\r\n var words = sentences[i].split(\" \");\r\n var value = FIRST_WORD_WEIGHT;\r\n\r\n for (var j in words) {\r\n var word = words[j];\r\n\r\n if (word.length > 0) {\r\n for (var k in stemmedTerms) {\r\n if (elasticlunr.stemmer(word).startsWith(stemmedTerms[k])) {\r\n value = TERM_WEIGHT;\r\n termFound = true;\r\n }\r\n }\r\n weighted.push([word, value, index]);\r\n value = NORMAL_WORD_WEIGHT;\r\n }\r\n\r\n index += word.length;\r\n index += 1; // ' ' or '.' if last word in sentence\r\n }\r\n\r\n index += 1; // because we split at a two-char boundary '. '\r\n }\r\n\r\n if (weighted.length === 0) {\r\n return body;\r\n }\r\n\r\n var windowWeights = [];\r\n var windowSize = Math.min(weighted.length, TEASER_MAX_WORDS);\r\n // We add a window with all the weights first\r\n var curSum = 0;\r\n for (var i = 0; i < windowSize; i++) {\r\n curSum += weighted[i][1];\r\n }\r\n windowWeights.push(curSum);\r\n\r\n for (var i = 0; i < weighted.length - windowSize; i++) {\r\n curSum -= weighted[i][1];\r\n curSum += weighted[i + windowSize][1];\r\n windowWeights.push(curSum);\r\n }\r\n\r\n // If we didn't find the term, just pick the first window\r\n var maxSumIndex = 0;\r\n if (termFound) {\r\n var maxFound = 0;\r\n // backwards\r\n for (var i = windowWeights.length - 1; i >= 0; i--) {\r\n if (windowWeights[i] > maxFound) {\r\n maxFound = windowWeights[i];\r\n maxSumIndex = i;\r\n }\r\n }\r\n }\r\n\r\n var teaser = [];\r\n var startIndex = weighted[maxSumIndex][2];\r\n for (var i = maxSumIndex; i < maxSumIndex + windowSize; i++) {\r\n var word = weighted[i];\r\n if (startIndex < word[2]) {\r\n // missing text from index to start of `word`\r\n teaser.push(body.substring(startIndex, word[2]));\r\n startIndex = word[2];\r\n }\r\n\r\n // add around search terms\r\n if (word[1] === TERM_WEIGHT) {\r\n teaser.push(\"\");\r\n }\r\n startIndex = word[2] + word[0].length;\r\n teaser.push(body.substring(word[2], startIndex));\r\n\r\n if (word[1] === TERM_WEIGHT) {\r\n teaser.push(\"\");\r\n }\r\n }\r\n teaser.push(\"…\");\r\n return teaser.join(\"\");\r\n}\r\n\r\nfunction formatSearchResultItem(item, terms) {\r\n return '
' +\r\n `${item.doc.title}` +\r\n `
${makeTeaser(item.doc.body, terms)}
` +\r\n '
';\r\n}\r\n\r\nfunction initSearch() {\r\n var $searchInput = document.getElementById(\"search\");\r\n var $searchResults = document.querySelector(\".search-results\");\r\n var $searchResultsItems = document.querySelector(\".search-results__items\");\r\n var MAX_ITEMS = 10;\r\n\r\n var options = {\r\n bool: \"AND\",\r\n fields: {\r\n title: {\r\n boost: 2\r\n },\r\n body: {\r\n boost: 1\r\n },\r\n }\r\n };\r\n var currentTerm = \"\";\r\n var index = elasticlunr.Index.load(window.searchIndex);\r\n\r\n $searchInput.addEventListener(\"keyup\", debounce(function () {\r\n var term = $searchInput.value.trim();\r\n if (!index) {\r\n return;\r\n }\r\n $searchResults.style.display = term === \"\" ? \"none\" : \"block\";\r\n $searchResultsItems.innerHTML = \"\";\r\n if (term === \"\") {\r\n return;\r\n }\r\n\r\n var results = index.search(term, options);\r\n if (results.length === 0) {\r\n $searchResults.style.display = \"none\";\r\n return;\r\n }\r\n\r\n currentTerm = term;\r\n for (var i = 0; i < Math.min(results.length, MAX_ITEMS); i++) {\r\n var item = document.createElement(\"li\");\r\n item.innerHTML = formatSearchResultItem(results[i], term.split(\" \"));\r\n $searchResultsItems.appendChild(item);\r\n }\r\n }, 150));\r\n}\r\n\r\n\r\nif (document.readyState === \"complete\" ||\r\n (document.readyState !== \"loading\" && !document.documentElement.doScroll)\r\n) {\r\n initSearch();\r\n} else {\r\n document.addEventListener(\"DOMContentLoaded\", initSearch);\r\n}"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/zulma_search.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","formatSearchResultItem","item","terms","concat","ref","doc","title","body","stemmedTerms","map","w","elasticlunr","stemmer","toLowerCase","termFound","index","weighted","sentences","split","words","j","word","length","k","startsWith","push","windowWeights","windowSize","Math","min","curSum","maxSumIndex","maxFound","teaser","startIndex","substring","join","makeTeaser","initSearch","func","wait","timeout","$searchInput","document","getElementById","$searchResults","querySelector","$searchResultsItems","options","bool","fields","boost","Index","load","window","searchIndex","addEventListener","term","trim","style","display","innerHTML","results","search","createElement","appendChild","context","this","args","arguments","clearTimeout","setTimeout","apply","readyState","documentElement","doScroll"],"mappings":"aACA,IAAAA,EAAA,GAGA,SAAAC,EAAAC,GAGA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AAKvC,MAAM,MAC/D6B,EAAoBkB,YAAYhE,SARhC4C,EAAec,MAAMC,QAAU,SAnKbpB,EA6KnB,IA1KI,WACL,IAAI0B,EAAUC,KACVC,EAAOC,UACXC,aAAa7B,GAEbA,EAAU8B,WAAW,WACnB9B,EAAU,KACVF,EAAKiC,MAAMN,EAASE,IACnB5B,MAsKqB,aAAxBG,SAAS8B,YACc,YAAxB9B,SAAS8B,aAA6B9B,SAAS+B,gBAAgBC,SAEhErC,IAEAK,SAASa,iBAAiB,mBAAoBlB","file":"zulma_search.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 = 1);\n","/* eslint-disable */\r\n\r\nfunction debounce(func, wait) {\r\n var timeout;\r\n\r\n return function () {\r\n var context = this;\r\n var args = arguments;\r\n clearTimeout(timeout);\r\n\r\n timeout = setTimeout(function () {\r\n timeout = null;\r\n func.apply(context, args);\r\n }, wait);\r\n };\r\n}\r\n\r\n// Taken from mdbook\r\n// The strategy is as follows:\r\n// First, assign a value to each word in the document:\r\n// Words that correspond to search terms (stemmer aware): 40\r\n// Normal words: 2\r\n// First word in a sentence: 8\r\n// Then use a sliding window with a constant number of words and count the\r\n// sum of the values of the words within the window. Then use the window that got the\r\n// maximum sum. If there are multiple maximas, then get the last one.\r\n// Enclose the terms in .\r\nfunction makeTeaser(body, terms) {\r\n var TERM_WEIGHT = 40;\r\n var NORMAL_WORD_WEIGHT = 2;\r\n var FIRST_WORD_WEIGHT = 8;\r\n var TEASER_MAX_WORDS = 30;\r\n\r\n var stemmedTerms = terms.map(function (w) {\r\n return elasticlunr.stemmer(w.toLowerCase());\r\n });\r\n var termFound = false;\r\n var index = 0;\r\n var weighted = []; // contains elements of [\"word\", weight, index_in_document]\r\n\r\n // split in sentences, then words\r\n var sentences = body.toLowerCase().split(\". \");\r\n\r\n for (var i in sentences) {\r\n var words = sentences[i].split(\" \");\r\n var value = FIRST_WORD_WEIGHT;\r\n\r\n for (var j in words) {\r\n var word = words[j];\r\n\r\n if (word.length > 0) {\r\n for (var k in stemmedTerms) {\r\n if (elasticlunr.stemmer(word).startsWith(stemmedTerms[k])) {\r\n value = TERM_WEIGHT;\r\n termFound = true;\r\n }\r\n }\r\n weighted.push([word, value, index]);\r\n value = NORMAL_WORD_WEIGHT;\r\n }\r\n\r\n index += word.length;\r\n index += 1; // ' ' or '.' if last word in sentence\r\n }\r\n\r\n index += 1; // because we split at a two-char boundary '. '\r\n }\r\n\r\n if (weighted.length === 0) {\r\n return body;\r\n }\r\n\r\n var windowWeights = [];\r\n var windowSize = Math.min(weighted.length, TEASER_MAX_WORDS);\r\n // We add a window with all the weights first\r\n var curSum = 0;\r\n for (var i = 0; i < windowSize; i++) {\r\n curSum += weighted[i][1];\r\n }\r\n windowWeights.push(curSum);\r\n\r\n for (var i = 0; i < weighted.length - windowSize; i++) {\r\n curSum -= weighted[i][1];\r\n curSum += weighted[i + windowSize][1];\r\n windowWeights.push(curSum);\r\n }\r\n\r\n // If we didn't find the term, just pick the first window\r\n var maxSumIndex = 0;\r\n if (termFound) {\r\n var maxFound = 0;\r\n // backwards\r\n for (var i = windowWeights.length - 1; i >= 0; i--) {\r\n if (windowWeights[i] > maxFound) {\r\n maxFound = windowWeights[i];\r\n maxSumIndex = i;\r\n }\r\n }\r\n }\r\n\r\n var teaser = [];\r\n var startIndex = weighted[maxSumIndex][2];\r\n for (var i = maxSumIndex; i < maxSumIndex + windowSize; i++) {\r\n var word = weighted[i];\r\n if (startIndex < word[2]) {\r\n // missing text from index to start of `word`\r\n teaser.push(body.substring(startIndex, word[2]));\r\n startIndex = word[2];\r\n }\r\n\r\n // add around search terms\r\n if (word[1] === TERM_WEIGHT) {\r\n teaser.push(\"\");\r\n }\r\n startIndex = word[2] + word[0].length;\r\n teaser.push(body.substring(word[2], startIndex));\r\n\r\n if (word[1] === TERM_WEIGHT) {\r\n teaser.push(\"\");\r\n }\r\n }\r\n teaser.push(\"…\");\r\n return teaser.join(\"\");\r\n}\r\n\r\nfunction formatSearchResultItem(item, terms) {\r\n return '
' +\r\n `${item.doc.title}` +\r\n `
${makeTeaser(item.doc.body, terms)}
` +\r\n '
';\r\n}\r\n\r\nfunction initSearch() {\r\n var $searchInput = document.getElementById(\"search\");\r\n var $searchResults = document.querySelector(\".search-results\");\r\n var $searchResultsItems = document.querySelector(\".search-results__items\");\r\n var MAX_ITEMS = 10;\r\n\r\n var options = {\r\n bool: \"AND\",\r\n fields: {\r\n title: {\r\n boost: 2\r\n },\r\n body: {\r\n boost: 1\r\n },\r\n }\r\n };\r\n var currentTerm = \"\";\r\n var index = elasticlunr.Index.load(window.searchIndex);\r\n\r\n $searchInput.addEventListener(\"keyup\", debounce(function () {\r\n var term = $searchInput.value.trim();\r\n if (!index) {\r\n return;\r\n }\r\n $searchResults.style.display = term === \"\" ? \"none\" : \"block\";\r\n $searchResultsItems.innerHTML = \"\";\r\n if (term === \"\") {\r\n return;\r\n }\r\n\r\n var results = index.search(term, options);\r\n if (results.length === 0) {\r\n $searchResults.style.display = \"none\";\r\n return;\r\n }\r\n\r\n currentTerm = term;\r\n for (var i = 0; i < Math.min(results.length, MAX_ITEMS); i++) {\r\n var item = document.createElement(\"li\");\r\n item.innerHTML = formatSearchResultItem(results[i], term.split(\" \"));\r\n $searchResultsItems.appendChild(item);\r\n }\r\n }, 150));\r\n}\r\n\r\n\r\nif (document.readyState === \"complete\" ||\r\n (document.readyState !== \"loading\" && !document.documentElement.doScroll)\r\n) {\r\n initSearch();\r\n} else {\r\n document.addEventListener(\"DOMContentLoaded\", initSearch);\r\n}"],"sourceRoot":""} \ No newline at end of file diff --git a/static/js/zulma_switchcss.js.map b/static/js/zulma_switchcss.js.map index 57cf5dd..35c0d15 100644 --- a/static/js/zulma_switchcss.js.map +++ b/static/js/zulma_switchcss.js.map @@ -1 +1 @@ -{"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","STOP_BLINK_CSS_ID","STYLESHEET_CLASSNAME","previousLink","theme","localStorage","getItem","onLinkLoad","event","link","currentTarget","removeEventListener","onLinkError","removeStylesheets","className","showBody","removeItem","updateThemeSelect","id","remove","document","getElementsByTagName","appendChild","querySelectorAll","concat","changeTheme","themeName","firstLoad","fileref","createElement","rel","type","href","addEventListener","setItem","saveTheme","forEach","el","css","getElementById","setSelected","elements","length","element","selected","window","init","head","style","setAttribute","styleSheet","cssText","createTextNode","onchange","this"],"mappings":"aACA,IAAAA,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,GAAA,CACAG,EAAAH,EACAI,GAAA,EACAH,QAAA,IAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CZ,EAAAkB,EAAA,SAAAhB,GACA,oBAAAiB,eAAAC,aACAN,OAAAC,eA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3BU,EAAM1B,YAAYF,SAASgC,eAAed,IAE9CS,EAAKzB,YAAY0B,GAwCbvB,EAAYrB,GAAO,GAEnBa,EAAkBb,GAAO,IAG7ByC,OAAOZ,iBAAiB,mBAAoB,WACxCb,SAASmB,eAAe,gBAAgBc,SAAW,WAC/C5B,EAAY6B,KAAKtE,WA3JhC,CA+JCe,WAAa8C,OAAO9C,YAAc,IAEpCA,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) {\r\n //Constants\r\n const THEME_KEY = \"ZULMA_THEME\";\r\n const STOP_BLINK_CSS_ID = \"stop-blink\";\r\n const STYLESHEET_CLASSNAME = \"stylesheet\"\r\n\r\n //Variables\r\n //let link = null;\r\n let previousLink = null;\r\n let theme = localStorage.getItem(THEME_KEY);\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(document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`)[0].id, true)\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 = `/${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)\r\n 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 () {\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\r\n\r\nswitch_css.init(); // eslint-disable-line"],"sourceRoot":""} \ No newline at end of file +{"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","STOP_BLINK_CSS_ID","STYLESHEET_CLASSNAME","previousLink","theme","localStorage","getItem","onLinkLoad","event","link","currentTarget","removeEventListener","onLinkError","removeStylesheets","className","showBody","removeItem","updateThemeSelect","id","remove","document","getElementsByTagName","appendChild","querySelectorAll","concat","changeTheme","themeName","firstLoad","fileref","createElement","rel","type","href","addEventListener","setItem","saveTheme","forEach","el","css","getElementById","setSelected","elements","length","element","selected","window","init","head","style","setAttribute","styleSheet","cssText","createTextNode","onchange","this"],"mappings":"aACA,IAAAA,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,GAAA,CACAG,EAAAH,EACAI,GAAA,EACAH,QAAA,IAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CZ,EAAAkB,EAAA,SAAAhB,GACA,oBAAAiB,eAAAC,aACAN,OAAAC,eAAAb,EAAAiB,OAAAC,YAAA,CAAwDC,MAAA,WAExDP,OAAAC,eAAAb,EAAA,cAAiDmB,OAAA,KAQjDrB,EAAAsB,EAAA,SAAAD,EAAAE,GAEA,GADA,EAAAA,IAAAF,EAAArB,EAAAqB,IACA,EAAAE,EAAA,OAAAF,EACA,KAAAE,GAAA,iBAAAF,QAAAG,WAAA,OAAAH,EACA,IAAAI,EAAAX,OAAAY,OAAA,MAGA,GAFA1B,EAAAkB,EAAAO,GACAX,OAAAC,eAAAU,EAAA,WAAyCT,YAAA,EAAAK,UACzC,EAAAE,GAAA,iBAAAF,EAAA,QAAAM,KAA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Q1B,GAE9BE,EAAKwB,iBAAiB,QAASrB,GAG3Be,IAEFxB,EAAeiB,SAASG,iBAAT,IAAAC,OAA8BtB,IAAwB,GACrEW,KAcJ,SAAmBa,GACjBrB,aAAa6B,QAAQlC,EAAW0B,GAZhCS,CAAUT,GAIZ,SAASb,IACPO,SAASG,iBAAT,IAAAC,OAA8BtB,IAAwBkC,QAAQ,SAAAC,GAC5DA,EAAGlB,WAgCP,SAASJ,IACP,IAAIuB,EAAMlB,SAASmB,eAAetC,GAC9BqC,GAAKA,EAAInB,SAIf,SAASF,EAAkBb,EAAOoC,GAEhC,IAAIC,EAAWrB,SAASG,iBAAiB,wBAErCkB,EAASC,OACXD,EAASL,QAAQ,SAAAO,GACXA,EAAQ3D,QAAUoB,IAChBoC,EACFG,EAAQC,SAAW,WAEnBD,EAAQxB,YAMd0B,OAAOZ,iBAAiB,mBAAoB,WAC1ChB,EAAkBb,EAAOoC,KAM/BzC,EAAW+C,KAAO,WA9ClB,IACMC,EACAC,EACAV,EA6CAlC,IAAUgB,SAASmB,eAAenC,KA/ClC2C,EAAO3B,SAASC,qBAAqB,QAAQ,GAC7C2B,EAAQ5B,SAASS,cAAc,SAC/BS,EAAM,2BAEVU,EAAM9B,GAAKjB,EACX+C,EAAMC,aAAa,OAAQ,YAEvBD,EAAME,WACRF,EAAME,WAAWC,QAAUb,EAE3BU,EAAM1B,YAAYF,SAASgC,eAAed,IAE5CS,EAAKzB,YAAY0B,GAuCfvB,EAAYrB,GAAO,GAEnBa,EAAkBb,GAAO,IAG3ByC,OAAOZ,iBAAiB,mBAAoB,WAC1Cb,SAASmB,eAAe,gBAAgBc,SAAW,WACjD5B,EAAY6B,KAAKtE,WA5JzB,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) {\r\n //Constants\r\n const THEME_KEY = \"ZULMA_THEME\";\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 theme = localStorage.getItem(THEME_KEY);\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 = `/${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() {\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\r\n\r\nswitch_css.init(); // eslint-disable-line\r\n"],"sourceRoot":""} \ No newline at end of file