diff --git a/frappe/public/js/frappe/ui/theme_switcher.js b/frappe/public/js/frappe/ui/theme_switcher.js
index 31baf697f0..317198bca5 100644
--- a/frappe/public/js/frappe/ui/theme_switcher.js
+++ b/frappe/public/js/frappe/ui/theme_switcher.js
@@ -14,7 +14,7 @@ frappe.ui.ThemeSwitcher = class ThemeSwitcher {
}
refresh() {
- this.current_theme = document.body.dataset.theme;
+ this.current_theme = document.documentElement.getAttribute("data-theme") || "light";
this.fetch_themes().then(() => {
this.render();
});
@@ -45,7 +45,6 @@ frappe.ui.ThemeSwitcher = class ThemeSwitcher {
});
}
-
get_preview_html(theme) {
const preview = $(`
@@ -69,15 +68,9 @@ frappe.ui.ThemeSwitcher = class ThemeSwitcher {
`);
- // preview.on('mouseover', () => {
- // this.toggle_theme(theme.name, true)
- // })
-
- // preview.on('mouseleave', () => {
- // this.toggle_theme(this.current_theme, true)
- // })
-
preview.on('click', () => {
+ if (this.current_theme === theme.name) return;
+
this.themes.forEach((th) => {
th.$html.removeClass("selected");
});
@@ -89,19 +82,15 @@ frappe.ui.ThemeSwitcher = class ThemeSwitcher {
return preview;
}
- toggle_theme(theme, preview=false) {
- if (!preview) {
- document.body.dataset.theme = theme.toLowerCase();
- frappe.show_alert("Theme Changed", 3);
+ toggle_theme(theme) {
+ this.current_theme = theme.toLowerCase();
+ document.documentElement.setAttribute("data-theme", this.current_theme);
+ frappe.show_alert("Theme Changed", 3);
- frappe.call('frappe.core.doctype.user.user.switch_theme', {
- theme: toTitle(theme)
- });
- } else {
- document.body.dataset.theme = theme.toLowerCase();
- }
+ frappe.xcall("frappe.core.doctype.user.user.switch_theme", {
+ theme: toTitle(theme)
+ });
}
-
show() {
this.dialog.show();
}
@@ -109,4 +98,4 @@ frappe.ui.ThemeSwitcher = class ThemeSwitcher {
hide() {
this.dialog.hide();
}
-};
\ No newline at end of file
+};
diff --git a/frappe/www/app.html b/frappe/www/app.html
index 715ddaf409..8da4d11c00 100644
--- a/frappe/www/app.html
+++ b/frappe/www/app.html
@@ -1,65 +1,67 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Frappe
-
-
- {% for include in include_css -%}
-
- {%- endfor -%}
-
-
- {% include "public/icons/timeless/symbol-defs.svg" %}
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Frappe
+
+
+ {% for include in include_css -%}
+
+ {%- endfor -%}
+
+
+ {% include "public/icons/timeless/symbol-defs.svg" %}
+
+
+
+
-
+
-
+
- {% for include in include_js %}
-
- {% endfor %}
- {% include "templates/includes/app_analytics/google_analytics.html" %}
- {% include "templates/includes/app_analytics/mixpanel_analytics.html" %}
+ {% for include in include_js %}
+
+ {% endfor %}
+ {% include "templates/includes/app_analytics/google_analytics.html" %}
+ {% include "templates/includes/app_analytics/mixpanel_analytics.html" %}
- {% for sound in (sounds or []) %}
-
-
-
- {% endfor %}
-
+ {% for sound in (sounds or []) %}
+
+
+
+ {% endfor %}
+
+