diff --git a/apps/common/main/lib/controller/Themes.js b/apps/common/main/lib/controller/Themes.js index ebcdf57d44..0f77e71c5c 100644 --- a/apps/common/main/lib/controller/Themes.js +++ b/apps/common/main/lib/controller/Themes.js @@ -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); diff --git a/apps/documenteditor/main/app/controller/ViewTab.js b/apps/documenteditor/main/app/controller/ViewTab.js index 623eae7f55..2a0a7472f3 100644 --- a/apps/documenteditor/main/app/controller/ViewTab.js +++ b/apps/documenteditor/main/app/controller/ViewTab.js @@ -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) { diff --git a/apps/documenteditor/main/app/view/ViewTab.js b/apps/documenteditor/main/app/view/ViewTab.js index 841bc6008f..d142f7ec34 100644 --- a/apps/documenteditor/main/app/view/ViewTab.js +++ b/apps/documenteditor/main/app/view/ViewTab.js @@ -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)); diff --git a/apps/pdfeditor/main/app/controller/ViewTab.js b/apps/pdfeditor/main/app/controller/ViewTab.js index 7b80efabcc..552a99cdb5 100644 --- a/apps/pdfeditor/main/app/controller/ViewTab.js +++ b/apps/pdfeditor/main/app/controller/ViewTab.js @@ -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) { diff --git a/apps/pdfeditor/main/app/view/ViewTab.js b/apps/pdfeditor/main/app/view/ViewTab.js index ca4de10152..456eb159d8 100644 --- a/apps/pdfeditor/main/app/view/ViewTab.js +++ b/apps/pdfeditor/main/app/view/ViewTab.js @@ -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));