[common] extended theme's object
This commit is contained in:
parent
0cec65caae
commit
57c9c6268e
|
@ -7,24 +7,22 @@ define([
|
|||
], function () {
|
||||
'use strict';
|
||||
|
||||
Common.UI.Themes = new (function() {
|
||||
var sdk_themes_alias = {
|
||||
'theme-light': 'flat',
|
||||
'theme-dark': 'flatDark'
|
||||
};
|
||||
|
||||
Common.UI.Themes = new (function(locale) {
|
||||
!locale && (locale = {});
|
||||
var id_default_theme = 'theme-classic-light';
|
||||
var themes_map = {
|
||||
'theme-light': 'light',
|
||||
'theme-classic-light': 'light',
|
||||
'theme-dark': 'dark'
|
||||
}
|
||||
|
||||
sdk_themes_alias.contains = function (name) {
|
||||
return !!this[name];
|
||||
}
|
||||
|
||||
themes_map.contains = function (name) {
|
||||
return !!this[name];
|
||||
'theme-light': {
|
||||
text: locale.txtThemeLight || 'Light',
|
||||
type: 'light'
|
||||
},
|
||||
'theme-classic-light': {
|
||||
text: locale.txtThemeClassicLight || 'Classic Light',
|
||||
type: 'light'
|
||||
},
|
||||
'theme-dark': {
|
||||
text: locale.txtThemeDark || 'Dark',
|
||||
type: 'dark'
|
||||
},
|
||||
}
|
||||
|
||||
var name_colors = [
|
||||
|
@ -128,10 +126,6 @@ define([
|
|||
}
|
||||
|
||||
return {
|
||||
THEME_LIGHT_ID: 'theme-light',
|
||||
THEME_CLASSIC_LIGHT_ID: 'theme-classic-light',
|
||||
THEME_DARK_ID: 'theme-dark',
|
||||
|
||||
init: function (api) {
|
||||
var me = this;
|
||||
|
||||
|
@ -142,7 +136,7 @@ define([
|
|||
})
|
||||
|
||||
this.api = api;
|
||||
var theme_name = Common.localStorage.getItem('ui-theme', 'theme-light');
|
||||
var theme_name = Common.localStorage.getItem('ui-theme', id_default_theme);
|
||||
|
||||
if ( !$('body').hasClass(theme_name) ) {
|
||||
$('body').addClass(theme_name);
|
||||
|
@ -152,50 +146,57 @@ define([
|
|||
obj.type = themes_map[theme_name];
|
||||
obj.name = theme_name;
|
||||
api.asc_setSkin(obj);
|
||||
|
||||
// app.eventbus.addListeners({
|
||||
// 'FileMenu': {
|
||||
// 'settings:apply': function (menu) {
|
||||
// }
|
||||
// }
|
||||
// }, {id: 'Themes'});
|
||||
|
||||
// getComputedStyle(document.documentElement).getPropertyValue('--background-normal');
|
||||
},
|
||||
|
||||
available: function () {
|
||||
return !Common.Utils.isIE;
|
||||
},
|
||||
|
||||
current: function () {
|
||||
return Common.localStorage.getItem('ui-theme') || 'theme-light';
|
||||
map: function () {
|
||||
return themes_map
|
||||
},
|
||||
|
||||
get: function (id) {
|
||||
return themes_map[id]
|
||||
},
|
||||
|
||||
currentThemeId: function () {
|
||||
return Common.localStorage.getItem('ui-theme') || id_default_theme;
|
||||
},
|
||||
|
||||
defaultThemeId: function () {
|
||||
return id_default_theme;
|
||||
},
|
||||
|
||||
defaultTheme: function () {
|
||||
return themes_map[id_default_theme]
|
||||
},
|
||||
|
||||
isDarkTheme: function () {
|
||||
return themes_map[this.current()] == 'dark';
|
||||
},
|
||||
|
||||
setTheme: function (name) {
|
||||
if ( themes_map.contains(name) ) {
|
||||
setTheme: function (id) {
|
||||
if ( !!themes_map[id] ) {
|
||||
var classname = document.documentElement.className.replace(/theme-\w+\s?/, '');
|
||||
document.body.className = classname;
|
||||
|
||||
$('body').addClass(name);
|
||||
$('body').addClass(id);
|
||||
|
||||
var obj = get_current_theme_colors(name_colors);
|
||||
obj.type = themes_map[name];
|
||||
obj.name = name;
|
||||
obj.type = themes_map[id].type;
|
||||
obj.name = id;
|
||||
|
||||
this.api.asc_setSkin(obj);
|
||||
|
||||
Common.localStorage.setItem('ui-theme', name);
|
||||
Common.NotificationCenter.trigger('uitheme:changed', name);
|
||||
Common.localStorage.setItem('ui-theme', id);
|
||||
Common.NotificationCenter.trigger('uitheme:changed', id);
|
||||
}
|
||||
},
|
||||
|
||||
toggleTheme: function () {
|
||||
this.setTheme(this.current() == 'theme-dark' ? 'theme-light' : 'theme-dark');
|
||||
this.setTheme(this.current() == 'theme-dark' ? id_default_theme : 'theme-dark');
|
||||
}
|
||||
}
|
||||
})();
|
||||
})(Common.UI.Themes);
|
||||
});
|
||||
|
|
|
@ -782,7 +782,6 @@ define([
|
|||
textAdvSettings: 'Advanced Settings',
|
||||
tipViewSettings: 'View Settings',
|
||||
textRemoveFavorite: 'Remove from Favorites',
|
||||
textDarkTheme: 'Dark theme',
|
||||
textAddFavorite: 'Mark as favorite'
|
||||
}
|
||||
}(), Common.Views.Header || {}))
|
||||
|
|
|
@ -464,11 +464,6 @@ define([
|
|||
style : 'width: 160px;',
|
||||
editable : false,
|
||||
cls : 'input-group-nr',
|
||||
data : [
|
||||
{ value: Common.UI.Themes.THEME_LIGHT_ID, displayValue: this.txtThemeLight },
|
||||
{ value: Common.UI.Themes.THEME_CLASSIC_LIGHT_ID, displayValue: "Classic light" },
|
||||
{ value: Common.UI.Themes.THEME_DARK_ID, displayValue: this.txtThemeDark }
|
||||
]
|
||||
});
|
||||
|
||||
$markup.find('.btn.primary').each(function(index, el){
|
||||
|
@ -601,8 +596,16 @@ define([
|
|||
|
||||
this.chPaste.setValue(Common.Utils.InternalSettings.get("de-settings-paste-button"));
|
||||
|
||||
item = this.cmbTheme.store.findWhere({value: Common.UI.Themes.current()});
|
||||
this.cmbTheme.setValue(item ? item.get('value') : Common.UI.Themes.THEME_LIGHT_ID);
|
||||
var data = [];
|
||||
for (var t in Common.UI.Themes.map()) {
|
||||
data.push({value: t, displayValue: Common.UI.Themes.get(t).text});
|
||||
}
|
||||
|
||||
if ( data.length ) {
|
||||
this.cmbTheme.setData(data);
|
||||
item = this.cmbTheme.store.findWhere({value: Common.UI.Themes.currentThemeId()});
|
||||
this.cmbTheme.setValue(item ? item.get('value') : Common.UI.Themes.defaultThemeId());
|
||||
}
|
||||
},
|
||||
|
||||
applySettings: function() {
|
||||
|
@ -731,8 +734,6 @@ define([
|
|||
strPasteButton: 'Show Paste Options button when content is pasted',
|
||||
txtProofing: 'Proofing',
|
||||
strTheme: 'Theme',
|
||||
txtThemeLight: 'Light',
|
||||
txtThemeDark: 'Dark',
|
||||
txtAutoCorrect: 'AutoCorrect options...'
|
||||
}, DE.Views.FileMenuPanels.Settings || {}));
|
||||
|
||||
|
|
|
@ -192,6 +192,9 @@
|
|||
"Common.UI.Window.textInformation": "Information",
|
||||
"Common.UI.Window.textWarning": "Warning",
|
||||
"Common.UI.Window.yesButtonText": "Yes",
|
||||
"Common.UI.Themes.txtThemeDark": "Dark",
|
||||
"Common.UI.Themes.txtThemeLight": "Light",
|
||||
"Common.UI.Themes.txtThemeClassicLight": "Classic Light",
|
||||
"Common.Utils.Metric.txtCm": "cm",
|
||||
"Common.Utils.Metric.txtPt": "pt",
|
||||
"Common.Views.About.txtAddress": "address: ",
|
||||
|
@ -260,7 +263,7 @@
|
|||
"Common.Views.Header.textAdvSettings": "Advanced settings",
|
||||
"Common.Views.Header.textBack": "Open file location",
|
||||
"Common.Views.Header.textCompactView": "Hide Toolbar",
|
||||
"Common.Views.Header.textDarkTheme": "Dark theme",
|
||||
"del_Common.Views.Header.textDarkTheme": "Dark theme",
|
||||
"Common.Views.Header.textHideLines": "Hide Rulers",
|
||||
"Common.Views.Header.textHideStatusBar": "Hide Status Bar",
|
||||
"Common.Views.Header.textRemoveFavorite": "Remove from Favorites",
|
||||
|
@ -1716,8 +1719,8 @@
|
|||
"DE.Views.FileMenuPanels.Settings.txtSpellCheck": "Spell Checking",
|
||||
"DE.Views.FileMenuPanels.Settings.txtStopMacros": "Disable All",
|
||||
"DE.Views.FileMenuPanels.Settings.txtStopMacrosDesc": "Disable all macros without a notification",
|
||||
"DE.Views.FileMenuPanels.Settings.txtThemeDark": "Dark",
|
||||
"DE.Views.FileMenuPanels.Settings.txtThemeLight": "Light",
|
||||
"del_DE.Views.FileMenuPanels.Settings.txtThemeDark": "Dark",
|
||||
"del_DE.Views.FileMenuPanels.Settings.txtThemeLight": "Light",
|
||||
"DE.Views.FileMenuPanels.Settings.txtWarnMacros": "Show Notification",
|
||||
"DE.Views.FileMenuPanels.Settings.txtWarnMacrosDesc": "Disable all macros with a notification",
|
||||
"DE.Views.FileMenuPanels.Settings.txtWin": "as Windows",
|
||||
|
|
|
@ -403,10 +403,6 @@ define([
|
|||
style : 'width: 160px;',
|
||||
editable : false,
|
||||
cls : 'input-group-nr',
|
||||
data : [
|
||||
{ value: Common.UI.Themes.THEME_LIGHT_ID, displayValue: this.txtThemeLight },
|
||||
{ value: Common.UI.Themes.THEME_DARK_ID, displayValue: this.txtThemeDark }
|
||||
]
|
||||
});
|
||||
|
||||
$markup.find('.btn.primary').each(function(index, el){
|
||||
|
@ -529,8 +525,16 @@ define([
|
|||
|
||||
this.chPaste.setValue(Common.Utils.InternalSettings.get("pe-settings-paste-button"));
|
||||
|
||||
item = this.cmbTheme.store.findWhere({value: Common.UI.Themes.current()});
|
||||
this.cmbTheme.setValue(item ? item.get('value') : Common.UI.Themes.THEME_LIGHT_ID);
|
||||
var data = [];
|
||||
for (var t in Common.UI.Themes.map()) {
|
||||
data.push({value: t, displayValue: Common.UI.Themes.get(t).text});
|
||||
}
|
||||
|
||||
if ( data.length ) {
|
||||
this.cmbTheme.setData(data);
|
||||
item = this.cmbTheme.store.findWhere({value: Common.UI.Themes.currentThemeId()});
|
||||
this.cmbTheme.setValue(item ? item.get('value') : Common.UI.Themes.defaultThemeId());
|
||||
}
|
||||
},
|
||||
|
||||
applySettings: function() {
|
||||
|
|
|
@ -83,6 +83,9 @@
|
|||
"Common.UI.Window.textInformation": "Information",
|
||||
"Common.UI.Window.textWarning": "Warning",
|
||||
"Common.UI.Window.yesButtonText": "Yes",
|
||||
"Common.UI.Themes.txtThemeDark": "Dark",
|
||||
"Common.UI.Themes.txtThemeLight": "Light",
|
||||
"Common.UI.Themes.txtThemeClassicLight": "Classic Light",
|
||||
"Common.Utils.Metric.txtCm": "cm",
|
||||
"Common.Utils.Metric.txtPt": "pt",
|
||||
"Common.Views.About.txtAddress": "address: ",
|
||||
|
@ -148,7 +151,7 @@
|
|||
"Common.Views.Header.textAdvSettings": "Advanced settings",
|
||||
"Common.Views.Header.textBack": "Open file location",
|
||||
"Common.Views.Header.textCompactView": "Hide Toolbar",
|
||||
"Common.Views.Header.textDarkTheme": "Dark theme",
|
||||
"del_Common.Views.Header.textDarkTheme": "Dark theme",
|
||||
"Common.Views.Header.textHideLines": "Hide Rulers",
|
||||
"Common.Views.Header.textHideStatusBar": "Hide Status Bar",
|
||||
"Common.Views.Header.textRemoveFavorite": "Remove from Favorites",
|
||||
|
@ -1352,8 +1355,8 @@
|
|||
"PE.Views.FileMenuPanels.Settings.txtSpellCheck": "Spell Checking",
|
||||
"PE.Views.FileMenuPanels.Settings.txtStopMacros": "Disable All",
|
||||
"PE.Views.FileMenuPanels.Settings.txtStopMacrosDesc": "Disable all macros without a notification",
|
||||
"PE.Views.FileMenuPanels.Settings.txtThemeDark": "Dark",
|
||||
"PE.Views.FileMenuPanels.Settings.txtThemeLight": "Light",
|
||||
"del_PE.Views.FileMenuPanels.Settings.txtThemeDark": "Dark",
|
||||
"del_PE.Views.FileMenuPanels.Settings.txtThemeLight": "Light",
|
||||
"PE.Views.FileMenuPanels.Settings.txtWarnMacros": "Show Notification",
|
||||
"PE.Views.FileMenuPanels.Settings.txtWarnMacrosDesc": "Disable all macros with a notification",
|
||||
"PE.Views.FileMenuPanels.Settings.txtWin": "as Windows",
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
// Bootstrap overwrite
|
||||
@import "../../../../common/main/resources/less/variables.less";
|
||||
@import "../../../../common/main/resources/less/colors-table.less";
|
||||
@import "../../../../common/main/resources/less/colors-table-classic.less";
|
||||
@import "../../../../common/main/resources/less/colors-table-dark.less";
|
||||
|
||||
//
|
||||
|
|
|
@ -1009,10 +1009,6 @@ define([
|
|||
style : 'width: 160px;',
|
||||
editable : false,
|
||||
cls : 'input-group-nr',
|
||||
data : [
|
||||
{ value: Common.UI.Themes.THEME_LIGHT_ID, displayValue: this.txtThemeLight },
|
||||
{ value: Common.UI.Themes.THEME_DARK_ID, displayValue: this.txtThemeDark }
|
||||
]
|
||||
});
|
||||
|
||||
$markup.find('.btn.primary').each(function(index, el){
|
||||
|
@ -1175,8 +1171,16 @@ define([
|
|||
|
||||
this.chPaste.setValue(Common.Utils.InternalSettings.get("sse-settings-paste-button"));
|
||||
|
||||
item = this.cmbTheme.store.findWhere({value: Common.UI.Themes.current()});
|
||||
this.cmbTheme.setValue(item ? item.get('value') : Common.UI.Themes.THEME_LIGHT_ID);
|
||||
var data = [];
|
||||
for (var t in Common.UI.Themes.map()) {
|
||||
data.push({value: t, displayValue: Common.UI.Themes.get(t).text});
|
||||
}
|
||||
|
||||
if ( data.length ) {
|
||||
this.cmbTheme.setData(data);
|
||||
item = this.cmbTheme.store.findWhere({value: Common.UI.Themes.currentThemeId()});
|
||||
this.cmbTheme.setValue(item ? item.get('value') : Common.UI.Themes.defaultThemeId());
|
||||
}
|
||||
},
|
||||
|
||||
applySettings: function() {
|
||||
|
|
|
@ -84,6 +84,9 @@
|
|||
"Common.UI.Window.textInformation": "Information",
|
||||
"Common.UI.Window.textWarning": "Warning",
|
||||
"Common.UI.Window.yesButtonText": "Yes",
|
||||
"Common.UI.Themes.txtThemeDark": "Dark",
|
||||
"Common.UI.Themes.txtThemeLight": "Light",
|
||||
"Common.UI.Themes.txtThemeClassicLight": "Classic Light",
|
||||
"Common.Utils.Metric.txtCm": "cm",
|
||||
"Common.Utils.Metric.txtPt": "pt",
|
||||
"Common.Views.About.txtAddress": "address: ",
|
||||
|
@ -144,7 +147,7 @@
|
|||
"Common.Views.Header.textAdvSettings": "Advanced settings",
|
||||
"Common.Views.Header.textBack": "Open file location",
|
||||
"Common.Views.Header.textCompactView": "Hide Toolbar",
|
||||
"Common.Views.Header.textDarkTheme": "Dark theme",
|
||||
"del_Common.Views.Header.textDarkTheme": "Dark theme",
|
||||
"Common.Views.Header.textHideLines": "Hide Rulers",
|
||||
"Common.Views.Header.textHideStatusBar": "Hide Status Bar",
|
||||
"Common.Views.Header.textRemoveFavorite": "Remove from Favorites",
|
||||
|
@ -1938,8 +1941,8 @@
|
|||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtRunMacrosDesc": "Enable all macros without a notification",
|
||||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtStopMacros": "Disable All",
|
||||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtStopMacrosDesc": "Disable all macros without a notification",
|
||||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtThemeDark": "Dark",
|
||||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtThemeLight": "Light",
|
||||
"del_SSE.Views.FileMenuPanels.MainSettingsGeneral.txtThemeDark": "Dark",
|
||||
"del_SSE.Views.FileMenuPanels.MainSettingsGeneral.txtThemeLight": "Light",
|
||||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtWarnMacros": "Show Notification",
|
||||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtWarnMacrosDesc": "Disable all macros with a notification",
|
||||
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtWin": "as Windows",
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
// Bootstrap overwrite
|
||||
@import "../../../../common/main/resources/less/variables.less";
|
||||
@import "../../../../common/main/resources/less/colors-table.less";
|
||||
@import "../../../../common/main/resources/less/colors-table-classic.less";
|
||||
@import "../../../../common/main/resources/less/colors-table-dark.less";
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue