[themes] changed theme's current value

This commit is contained in:
Maxim Kadushkin 2021-04-22 19:49:37 +03:00
parent acc67e6420
commit 493ad0ac9e

View file

@ -9,7 +9,6 @@ define([
Common.UI.Themes = new (function(locale) { Common.UI.Themes = new (function(locale) {
!locale && (locale = {}); !locale && (locale = {});
var id_default_theme = 'theme-classic-light';
var themes_map = { var themes_map = {
'theme-light': { 'theme-light': {
text: locale.txtThemeLight || 'Light', text: locale.txtThemeLight || 'Light',
@ -24,6 +23,8 @@ define([
type: 'dark' type: 'dark'
}, },
} }
var id_default_light_theme = 'theme-classic-light',
id_default_dark_theme = 'theme-dark';
var name_colors = [ var name_colors = [
"background-normal", "background-normal",
@ -205,7 +206,7 @@ define([
}) })
this.api = api; this.api = api;
var theme_name = Common.localStorage.getItem('ui-theme', id_default_theme); var theme_name = Common.localStorage.getItem('ui-theme', id_default_light_theme);
if ( !$('body').hasClass(theme_name) ) { if ( !$('body').hasClass(theme_name) ) {
$('body').addClass(theme_name); $('body').addClass(theme_name);
@ -232,19 +233,19 @@ define([
}, },
currentThemeId: function () { currentThemeId: function () {
return Common.localStorage.getItem('ui-theme') || id_default_theme; return Common.localStorage.getItem('ui-theme') || id_default_light_theme;
}, },
defaultThemeId: function () { defaultThemeId: function (type) {
return id_default_theme; return type == 'dark' ? id_default_dark_theme : id_default_light_theme;
}, },
defaultTheme: function () { defaultTheme: function (type) {
return themes_map[id_default_theme] return themes_map[this.defaultThemeId(type)]
}, },
isDarkTheme: function () { isDarkTheme: function () {
return themes_map[this.current()] == 'dark'; return themes_map[this.currentThemeId()].type == 'dark';
}, },
setTheme: function (id) { setTheme: function (id) {
@ -266,7 +267,7 @@ define([
}, },
toggleTheme: function () { toggleTheme: function () {
this.setTheme(this.current() == 'theme-dark' ? id_default_theme : 'theme-dark'); this.setTheme( this.isDarkTheme() ? id_default_light_theme : id_default_dark_theme );
} }
} }
})(Common.UI.Themes); })(Common.UI.Themes);