diff options
Diffstat (limited to 'themes/CodeIT/src/js')
-rw-r--r-- | themes/CodeIT/src/js/theme.js | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/themes/CodeIT/src/js/theme.js b/themes/CodeIT/src/js/theme.js index 6421e18..cdb7896 100644 --- a/themes/CodeIT/src/js/theme.js +++ b/themes/CodeIT/src/js/theme.js @@ -102,7 +102,7 @@ class Theme { document.body.setAttribute("theme", "light"); else document.body.setAttribute("theme", "dark"); this.isDark = !this.isDark; - window.localStorage && + this.config.cookieconsent && window.localStorage && localStorage.setItem("theme", this.isDark ? "dark" : "light"); for (let event of this.switchThemeEventSet) event(); }, @@ -576,8 +576,8 @@ class Theme { const $headerLinkElements = document.getElementsByClassName("headerLink"); const headerIsFixed = document.body.getAttribute("header-desktop") !== "normal"; - const headerHeight = document.getElementById("header-desktop") - .offsetHeight; + const headerHeight = + document.getElementById("header-desktop").offsetHeight; const TOP_SPACING = 20 + (headerIsFixed ? headerHeight : 0); const minTocTop = $toc.offsetTop; const minScrollTop = @@ -610,8 +610,8 @@ class Theme { let activeTocIndex = $headerLinkElements.length - 1; for (let i = 0; i < $headerLinkElements.length - 1; i++) { const thisTop = $headerLinkElements[i].getBoundingClientRect().top; - const nextTop = $headerLinkElements[i + 1].getBoundingClientRect() - .top; + const nextTop = + $headerLinkElements[i + 1].getBoundingClientRect().top; if ( (i == 0 && thisTop > INDEX_SPACING) || (thisTop <= INDEX_SPACING && nextTop > INDEX_SPACING) @@ -708,6 +708,7 @@ class Theme { geolocate, scale, fullscreen, + optionsJson, } = this.data[$mapbox.id]; const mapbox = new mapboxgl.Map({ container: $mapbox, @@ -741,6 +742,18 @@ class Theme { if (fullscreen) { mapbox.addControl(new mapboxgl.FullscreenControl()); } + if (typeof optionsJson === "object" && optionsJson !== null) { + console.log(optionsJson); + mapbox.on("load", function () { + for (const source of optionsJson.sources) { + mapbox.addSource(source.id, source.properties); + } + + for (const layer of optionsJson.layers) { + mapbox.addLayer(layer); + } + }); + } mapbox.addControl(new MapboxLanguage()); this._mapboxArr.push(mapbox); } |