Merge pull request #3009 from ONLYOFFICE/fix/bug-68174

Fix/bug 68174
This commit is contained in:
Julia Radzhabova
2024-05-24 17:03:45 +03:00
committed by GitHub
5 changed files with 27 additions and 12 deletions

View File

@ -408,7 +408,7 @@ define([
}
} else
if ( e.key == 'content-theme' ) {
this.setContentTheme(e.originalEvent.newValue, true);
this.setContentTheme(e.originalEvent.newValue, true, false);
}
}.bind(this))
@ -479,14 +479,15 @@ define([
return window.uitheme.iscontentdark;
},
setContentTheme: function (mode, force) {
setContentTheme: function (mode, force, keep) {
var set_dark = mode == 'dark';
if ( set_dark != window.uitheme.iscontentdark || force ) {
window.uitheme.iscontentdark = set_dark;
if ( this.isDarkTheme() )
this.api.asc_setContentDarkMode(set_dark);
window.uitheme.iscontentdark = mode;
if ( Common.localStorage.getItem('content-theme') != mode )
if ( !(keep === false) && Common.localStorage.getItem('content-theme') != mode )
Common.localStorage.setItem('content-theme', mode);
Common.NotificationCenter.trigger('contenttheme:dark', set_dark);

View File

@ -297,8 +297,15 @@ define([
Common.NotificationCenter.trigger('edit:complete', this.view);
},
onChangeDarkMode: function () {
Common.UI.Themes.toggleContentTheme();
onChangeDarkMode: function (isdarkmode) {
if (!this._darkModeTimer) {
var me = this;
me._darkModeTimer = setTimeout(function() {
me._darkModeTimer = undefined;
}, 500);
Common.UI.Themes.setContentTheme(isdarkmode?'dark':'light');
} else
this.onContentThemeChangedToDark(Common.UI.Themes.isContentThemeDark());
},
onContentThemeChangedToDark: function (isdark) {

View File

@ -131,8 +131,8 @@ define([
me.chRightMenu.on('change', _.bind(function (checkbox, state) {
me.fireEvent('rightmenu:hide', [me.chRightMenu, state === 'checked']);
}, me));
me.btnDarkDocument.on('click', _.bind(function () {
me.fireEvent('darkmode:change');
me.btnDarkDocument.on('click', _.bind(function (e) {
me.fireEvent('darkmode:change', [e.pressed]);
}, me));
me.cmbsZoom.forEach(function (cmb) {
cmb.on('combo:focusin', _.bind(me.onComboOpen, this, false));

View File

@ -282,8 +282,15 @@ define([
Common.NotificationCenter.trigger('edit:complete', this.view);
},
onChangeDarkMode: function () {
Common.UI.Themes.toggleContentTheme();
onChangeDarkMode: function (isdarkmode) {
if (!this._darkModeTimer) {
var me = this;
me._darkModeTimer = setTimeout(function() {
me._darkModeTimer = undefined;
}, 500);
Common.UI.Themes.setContentTheme(isdarkmode?'dark':'light');
} else
this.onContentThemeChangedToDark(Common.UI.Themes.isContentThemeDark());
},
onContentThemeChangedToDark: function (isdark) {

View File

@ -119,8 +119,8 @@ define([
me.chLeftMenu.on('change', _.bind(function (checkbox, state) {
me.fireEvent('leftmenu:hide', [me.chLeftMenu, state === 'checked']);
}, me));
me.btnDarkDocument.on('click', _.bind(function () {
me.fireEvent('darkmode:change');
me.btnDarkDocument.on('click', _.bind(function (e) {
me.fireEvent('darkmode:change', [e.pressed]);
}, me));
me.cmbsZoom.forEach(function (cmb) {
cmb.on('combo:focusin', _.bind(me.onComboOpen, this, false));