|
5 | 5 | @endphp |
6 | 6 |
|
7 | 7 | <script> |
8 | | -(function() { |
| 8 | + (function() { |
9 | 9 | window.inlineScripts = window.inlineScripts || {}; |
10 | | - |
| 10 | +
|
11 | 11 | window.inlineScripts.refreshColorSchemeIcon = function() { |
12 | | - const currentScheme = localStorage.getItem('colorScheme'); |
13 | | - |
14 | | - const icons = document.querySelectorAll('[data-colorschemeicon]'); |
15 | | - icons.forEach(function(icon) { |
16 | | - const iconScheme = icon.getAttribute('data-icon'); |
17 | | - if (iconScheme === currentScheme) { |
18 | | - icon.classList.remove('hidden'); |
19 | | - } else { |
20 | | - icon.classList.add('hidden'); |
21 | | - } |
22 | | - }); |
| 12 | + const currentScheme = localStorage.getItem('colorScheme'); |
| 13 | +
|
| 14 | + const icons = document.querySelectorAll('[data-colorschemeicon]'); |
| 15 | + icons.forEach(function(icon) { |
| 16 | + const iconScheme = icon.getAttribute('data-colorschemeicon'); |
| 17 | + if (iconScheme === currentScheme) { |
| 18 | + icon.classList.remove('hidden'); |
| 19 | + } else { |
| 20 | + icon.classList.add('hidden'); |
| 21 | + } |
| 22 | + }); |
23 | 23 | }; |
24 | 24 |
|
25 | 25 | document.addEventListener('DOMContentLoaded', function() { |
26 | | - window.inlineScripts.refreshColorSchemeIcon(); |
| 26 | + window.inlineScripts.refreshColorSchemeIcon(); |
| 27 | + }); |
| 28 | +
|
| 29 | + document.addEventListener('colorSchemeChanged', function() { |
| 30 | + window.inlineScripts.refreshColorSchemeIcon(); |
27 | 31 | }); |
28 | | -})(); |
| 32 | + })(); |
29 | 33 | </script> |
30 | 34 |
|
31 | 35 | <button |
32 | | - {{-- .switchColorScheme() is defined in switch-script.js --}} |
33 | | - title="Color scheme switcher" |
34 | | - onclick="window.inlineScripts.switchColorScheme(); window.inlineScripts.refreshColorSchemeIcon();" |
| 36 | + {{-- .switchColorScheme() is defined in switch-script.js --}} |
| 37 | + title="Color scheme switcher" |
| 38 | + onclick="window.inlineScripts.switchColorScheme(); window.inlineScripts.refreshColorSchemeIcon();" |
35 | 39 | > |
36 | 40 |
|
37 | 41 | <span class="hidden" data-colorschemeicon="{{ SchemeTypeEnum::SYSTEM }}"> |
|
0 commit comments