|
145 | 145 | ...GROUPS_FILTER_DEFAULT |
146 | 146 | }; |
147 | 147 |
|
148 | | - const THEMES_DEFAULT = { |
149 | | - light: "Light", |
150 | | - rust: "Rust", |
151 | | - coal: "Coal", |
152 | | - navy: "Navy", |
153 | | - ayu: "Ayu" |
154 | | - }; |
155 | | - $scope.themes = THEMES_DEFAULT; |
156 | | - |
157 | 148 | $scope.versionFilters = { |
158 | 149 | "≥": {enabled: false, minorVersion: null }, |
159 | 150 | "≤": {enabled: false, minorVersion: null }, |
|
339 | 330 | $location.path($scope.search); |
340 | 331 | } |
341 | 332 |
|
342 | | - $scope.selectTheme = function (theme) { |
343 | | - setTheme(theme, true); |
344 | | - } |
345 | | - |
346 | 333 | $scope.toggleLevels = function (value) { |
347 | 334 | const levels = $scope.levels; |
348 | 335 | for (const key in levels) { |
@@ -598,6 +585,8 @@ function setTheme(theme, store) { |
598 | 585 |
|
599 | 586 | if (store) { |
600 | 587 | storeValue("theme", theme); |
| 588 | + } else { |
| 589 | + document.getElementById(`theme-choice`).value = theme; |
601 | 590 | } |
602 | 591 | } |
603 | 592 |
|
@@ -634,6 +623,30 @@ function changeSetting(elem) { |
634 | 623 | } |
635 | 624 | } |
636 | 625 |
|
| 626 | +function generateSettings() { |
| 627 | + const THEMES = ["Ayu", "Coal", "Light", "Navy", "Rust"]; |
| 628 | + const themesElem = document.getElementById("theme-choice"); |
| 629 | + let children = ''; |
| 630 | + |
| 631 | + for (const theme of THEMES) { |
| 632 | + const id = theme.toLowerCase(); |
| 633 | + children += `<option value="${id}">${theme}</option>`; |
| 634 | + } |
| 635 | + themesElem.innerHTML = children; |
| 636 | + |
| 637 | + const settings = document.getElementById("settings-dropdown"); |
| 638 | + settings.querySelector(".settings-icon").onclick = () => settings.classList.toggle("open"); |
| 639 | + settings.onblur = event => { |
| 640 | + if (!settings.contains(document.activeElement) && |
| 641 | + !settings.contains(event.relatedTarget) |
| 642 | + ) { |
| 643 | + settings.classList.remove("open"); |
| 644 | + } |
| 645 | + }; |
| 646 | +} |
| 647 | + |
| 648 | +generateSettings(); |
| 649 | + |
637 | 650 | // loading the theme after the initial load |
638 | 651 | const prefersDark = window.matchMedia("(prefers-color-scheme: dark)"); |
639 | 652 | const theme = loadValue('theme'); |
|
0 commit comments