:zap: [Enhance] DarkThemeToggleButton: Auto swicth button title
Browse files
components/buttons_binder.js
CHANGED
@@ -352,11 +352,11 @@ class AvailableModelsSelectBinder {
|
|
352 |
class DarkThemeToggleButtonBinder {
|
353 |
constructor() {
|
354 |
this.storage_key = "theme";
|
|
|
355 |
window.onload = () => this.set_theme();
|
356 |
}
|
357 |
bind() {
|
358 |
-
|
359 |
-
toggle_button.click(() => {
|
360 |
let theme = localStorage.getItem(this.storage_key);
|
361 |
if (theme === "dark") {
|
362 |
localStorage.setItem(this.storage_key, "light");
|
@@ -371,8 +371,10 @@ class DarkThemeToggleButtonBinder {
|
|
371 |
let theme = localStorage.getItem(this.storage_key);
|
372 |
if (theme === "dark") {
|
373 |
DarkReader.enable();
|
|
|
374 |
} else {
|
375 |
DarkReader.disable();
|
|
|
376 |
}
|
377 |
console.log("set theme:", theme);
|
378 |
}
|
|
|
352 |
class DarkThemeToggleButtonBinder {
|
353 |
constructor() {
|
354 |
this.storage_key = "theme";
|
355 |
+
this.toggle_button = $("#dark-theme-toggle-button");
|
356 |
window.onload = () => this.set_theme();
|
357 |
}
|
358 |
bind() {
|
359 |
+
this.toggle_button.click(() => {
|
|
|
360 |
let theme = localStorage.getItem(this.storage_key);
|
361 |
if (theme === "dark") {
|
362 |
localStorage.setItem(this.storage_key, "light");
|
|
|
371 |
let theme = localStorage.getItem(this.storage_key);
|
372 |
if (theme === "dark") {
|
373 |
DarkReader.enable();
|
374 |
+
this.toggle_button.attr("title", "Switch to Light theme");
|
375 |
} else {
|
376 |
DarkReader.disable();
|
377 |
+
this.toggle_button.attr("title", "Switch to Dark theme");
|
378 |
}
|
379 |
console.log("set theme:", theme);
|
380 |
}
|