From 1ee730337c0444d72c85e265db9fefafa662b974 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 6 Oct 2021 20:07:57 +0300 Subject: [PATCH 1/3] [DE] hide "Dark mode" button for some formats --- apps/common/main/lib/view/Header.js | 4 +++- apps/documenteditor/main/app/controller/Viewport.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index f153840fe..38ae5144b 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -565,7 +565,9 @@ define([ if ( !!window.DE ) { var mode_cls = Common.UI.Themes.isContentThemeDark() ? 'btn-mode-light' : 'btn-mode-dark'; me.btnContentMode = createTitleButton('toolbar__icon icon--inverse ' + mode_cls, $html.findById('#slot-btn-mode'), undefined, 'bottom', 'big'); - me.btnContentMode.setVisible(Common.UI.Themes.isDarkTheme()); + + var document = this.getApplication().getController('Main').document; + me.btnContentMode.setVisible(Common.UI.Themes.isDarkTheme() && !/^pdf|djvu|xps|oxps$/.test(document.fileType)); } return $html; diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index 39f0d058d..809f1075d 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -325,7 +325,8 @@ define([ })).on('click', _on_btn_zoom.bind(me, 'up')); me.header.btnOptions.menu.on('item:click', me.onOptionsItemClick.bind(this)); - if ( !Common.UI.Themes.isDarkTheme() ) { + var document = DE.getController('Main').document; + if ( !Common.UI.Themes.isDarkTheme() || /^pdf|djvu|xps|oxps$/.test(document.fileType) ) { me.header.menuItemsDarkMode.hide(); me.header.menuItemsDarkMode.$el.prev('.divider').hide(); } From d68d1d220bb850cded29e2c7a5f243eb866feba5 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 6 Oct 2021 20:33:39 +0300 Subject: [PATCH 2/3] [DE] debug --- apps/common/main/lib/view/Header.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index 38ae5144b..d17a6a00f 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -566,7 +566,7 @@ define([ var mode_cls = Common.UI.Themes.isContentThemeDark() ? 'btn-mode-light' : 'btn-mode-dark'; me.btnContentMode = createTitleButton('toolbar__icon icon--inverse ' + mode_cls, $html.findById('#slot-btn-mode'), undefined, 'bottom', 'big'); - var document = this.getApplication().getController('Main').document; + var document = window.DE.getController('Main').document; me.btnContentMode.setVisible(Common.UI.Themes.isDarkTheme() && !/^pdf|djvu|xps|oxps$/.test(document.fileType)); } From ea623be83786eaca97d6bd6fc926916d1acd798f Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 6 Oct 2021 21:01:23 +0300 Subject: [PATCH 3/3] [DE] fixed theme chaging in viewer --- .../main/app/controller/Viewport.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index 809f1075d..0d7ea6770 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -371,13 +371,16 @@ define([ }, onThemeChanged: function (id) { - var current_dark = Common.UI.Themes.isDarkTheme(); - var menuItem = this.header.menuItemsDarkMode; - menuItem.setVisible(current_dark); - menuItem.$el.prev('.divider')[current_dark ? 'show' : 'hide'](); + var document = DE.getController('Main').document; + if ( !/^pdf|djvu|xps|oxps$/.test(document.fileType) ) { + var current_dark = Common.UI.Themes.isDarkTheme(); + var menuItem = this.header.menuItemsDarkMode; + menuItem.setVisible(current_dark); + menuItem.$el.prev('.divider')[current_dark ? 'show' : 'hide'](); - menuItem.setChecked(current_dark); - this.header.btnContentMode.setVisible(current_dark); + menuItem.setChecked(current_dark); + this.header.btnContentMode.setVisible(current_dark); + } }, onContentThemeChangedToDark: function (isdark) {