Merge pull request #1337 from ONLYOFFICE/fix/bug-53753

[DE forms] Add dark mode
This commit is contained in:
Julia Radzhabova 2021-11-19 17:43:40 +03:00 committed by GitHub
commit 3e9469ccbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 4 deletions

View file

@ -1111,7 +1111,11 @@ define([
}, },
onThemeClick: function(menu, item) { onThemeClick: function(menu, item) {
Common.UI.Themes.setTheme(item.value); (item.value!==null) && Common.UI.Themes.setTheme(item.value);
},
onDarkModeClick: function(item) {
Common.UI.Themes.toggleContentTheme();
}, },
onThemeChange: function() { onThemeChange: function() {
@ -1119,6 +1123,11 @@ define([
_.each(this.view.mnuThemes.items, function(item){ _.each(this.view.mnuThemes.items, function(item){
item.setChecked(current===item.value, true); item.setChecked(current===item.value, true);
}); });
if (this.view.menuItemsDarkMode) {
this.view.menuItemsDarkMode.setDisabled(!Common.UI.Themes.isDarkTheme());
this.view.menuItemsDarkMode.setChecked(Common.UI.Themes.isContentThemeDark());
}
if (this.appOptions.canBranding) { if (this.appOptions.canBranding) {
var value = this.appOptions.customization; var value = this.appOptions.customization;
if ( value && value.logo && (value.logo.image || value.logo.imageDark) && (value.logo.image !== value.logo.imageDark)) { if ( value && value.logo && (value.logo.image || value.logo.imageDark) && (value.logo.image !== value.logo.imageDark)) {
@ -1128,6 +1137,10 @@ define([
} }
}, },
onContentThemeChangedToDark: function (isdark) {
this.view.menuItemsDarkMode.setChecked(isdark, true);
},
createDelayedElements: function() { createDelayedElements: function() {
var me = this, var me = this,
menuItems = this.view.btnOptions.menu.items, menuItems = this.view.btnOptions.menu.items,
@ -1197,8 +1210,18 @@ define([
menuItems[6].setVisible(false); menuItems[6].setVisible(false);
itemsCount--; itemsCount--;
} else { } else {
this.view.menuItemsDarkMode = new Common.UI.MenuItem({
caption: this.view.txtDarkMode,
checkable: true,
checked: Common.UI.Themes.isContentThemeDark(),
disabled: !Common.UI.Themes.isDarkTheme()
});
this.view.mnuThemes.addItem(new Common.UI.MenuItem({caption : '--'}));
this.view.mnuThemes.addItem(this.view.menuItemsDarkMode);
this.view.mnuThemes.on('item:click', _.bind(this.onThemeClick, this)); this.view.mnuThemes.on('item:click', _.bind(this.onThemeClick, this));
this.view.menuItemsDarkMode.on('click', _.bind(this.onDarkModeClick, this));
Common.NotificationCenter.on('uitheme:changed', this.onThemeChange.bind(this)); Common.NotificationCenter.on('uitheme:changed', this.onThemeChange.bind(this));
Common.NotificationCenter.on('contenttheme:dark', this.onContentThemeChangedToDark.bind(this));
} }
if ( !this.embedConfig.shareUrl || this.appOptions.canFillForms) { if ( !this.embedConfig.shareUrl || this.appOptions.canFillForms) {

View file

@ -113,7 +113,8 @@ define([
textCut: 'Cut', textCut: 'Cut',
textCopy: 'Copy', textCopy: 'Copy',
textPaste: 'Paste', textPaste: 'Paste',
textPrintSel: 'Print Selection' textPrintSel: 'Print Selection',
txtDarkMode: 'Dark mode'
}, DE.Views.ApplicationView || {})); }, DE.Views.ApplicationView || {}));
}); });

View file

@ -123,5 +123,6 @@
"DE.Views.ApplicationView.txtFullScreen": "Full Screen", "DE.Views.ApplicationView.txtFullScreen": "Full Screen",
"DE.Views.ApplicationView.txtPrint": "Print", "DE.Views.ApplicationView.txtPrint": "Print",
"DE.Views.ApplicationView.txtShare": "Share", "DE.Views.ApplicationView.txtShare": "Share",
"DE.Views.ApplicationView.txtTheme": "Interface theme" "DE.Views.ApplicationView.txtTheme": "Interface theme",
"DE.Views.ApplicationView.txtDarkMode": "Dark mode"
} }

View file

@ -123,5 +123,6 @@
"DE.Views.ApplicationView.txtFullScreen": "Во весь экран", "DE.Views.ApplicationView.txtFullScreen": "Во весь экран",
"DE.Views.ApplicationView.txtPrint": "Печать", "DE.Views.ApplicationView.txtPrint": "Печать",
"DE.Views.ApplicationView.txtShare": "Поделиться", "DE.Views.ApplicationView.txtShare": "Поделиться",
"DE.Views.ApplicationView.txtTheme": "Тема интерфейса" "DE.Views.ApplicationView.txtTheme": "Тема интерфейса",
"DE.Views.ApplicationView.txtDarkMode": "Темный режим"
} }