[themes] hide "Dark mode" button instead of disable

This commit is contained in:
Maxim Kadushkin 2021-07-27 16:48:44 +03:00
parent eec8783d5b
commit d936e8765e
2 changed files with 10 additions and 12 deletions

View file

@ -563,6 +563,7 @@ define([
if ( !!window.DE ) { if ( !!window.DE ) {
var mode_cls = Common.UI.Themes.isContentThemeDark() ? 'btn-mode-light' : 'btn-mode-dark'; 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')); me.btnContentMode = createTitleButton('toolbar__icon icon--inverse ' + mode_cls, $html.findById('#slot-btn-mode'));
me.btnContentMode.setVisible(Common.UI.Themes.isDarkTheme());
} }
return $html; return $html;

View file

@ -254,7 +254,6 @@ define([
caption: 'Dark mode', caption: 'Dark mode',
checkable: true, checkable: true,
checked: Common.UI.Themes.isContentThemeDark(), checked: Common.UI.Themes.isContentThemeDark(),
disabled: !Common.UI.Themes.isDarkTheme(),
value: 'mode:dark' value: 'mode:dark'
}); });
@ -326,7 +325,10 @@ define([
})).on('click', _on_btn_zoom.bind(me, 'up')); })).on('click', _on_btn_zoom.bind(me, 'up'));
me.header.btnOptions.menu.on('item:click', me.onOptionsItemClick.bind(this)); me.header.btnOptions.menu.on('item:click', me.onOptionsItemClick.bind(this));
me.header.btnContentMode.setDisabled(!Common.UI.Themes.isDarkTheme()); if ( !Common.UI.Themes.isDarkTheme() ) {
me.header.menuItemsDarkMode.hide();
me.header.menuItemsDarkMode.$el.prev('.divider').hide();
}
} }
}, },
@ -368,18 +370,13 @@ define([
}, },
onThemeChanged: function (id) { onThemeChanged: function (id) {
var current_dark = Common.UI.Themes.isDarkTheme();
var menuItem = this.header.menuItemsDarkMode; var menuItem = this.header.menuItemsDarkMode;
if ( !Common.UI.Themes.isDarkTheme() ) { menuItem.setVisible(current_dark);
Common.Utils.InternalSettings.set("de-mode-dark", menuItem.isChecked()); menuItem.$el.prev('.divider')[current_dark ? 'show' : 'hide']();
menuItem.setChecked(false); menuItem.setChecked(current_dark);
menuItem.setDisabled(true); this.header.btnContentMode.setVisible(current_dark);
} else {
menuItem.setChecked(Common.Utils.InternalSettings.get("de-mode-dark"));
menuItem.setDisabled(false);
}
this.header.btnContentMode.setDisabled(!Common.UI.Themes.isDarkTheme());
}, },
onContentThemeChangedToDark: function (isdark) { onContentThemeChangedToDark: function (isdark) {