Skip to content

Commit

Permalink
Merge pull request #3009 from ONLYOFFICE/fix/bug-68174
Browse files Browse the repository at this point in the history
Fix/bug 68174
  • Loading branch information
JuliaRadzhabova authored May 24, 2024
2 parents 6f158ed + c15ddca commit 32be51e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
9 changes: 5 additions & 4 deletions apps/common/main/lib/controller/Themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions apps/documenteditor/main/app/controller/ViewTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions apps/documenteditor/main/app/view/ViewTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
11 changes: 9 additions & 2 deletions apps/pdfeditor/main/app/controller/ViewTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions apps/pdfeditor/main/app/view/ViewTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 32be51e

Please sign in to comment.