diff --git a/apps/common/main/lib/controller/Themes.js b/apps/common/main/lib/controller/Themes.js index df4b95e11..7e20b00c1 100644 --- a/apps/common/main/lib/controller/Themes.js +++ b/apps/common/main/lib/controller/Themes.js @@ -251,6 +251,10 @@ define([ $(window).on('storage', function (e) { if ( e.key == 'ui-theme' || e.key == 'ui-theme-id' ) { me.setTheme(e.originalEvent.newValue, true); + } else + if ( e.key == 'content-theme' ) { + me.setContentTheme(e.originalEvent.newValue, true); + console.log('changed content', e.originalEvent.newValue); } }) @@ -335,6 +339,22 @@ define([ return Common.localStorage.getItem("content-theme") == 'dark'; }, + setContentTheme: function (mode, force) { + var set_dark = mode == 'dark'; + if ( set_dark && !this.isDarkTheme() ) + return; + + if ( set_dark != this.isContentThemeDark() || force ) { + if ( this.api.asc_setContentDarkMode ) + this.api.asc_setContentDarkMode(set_dark); + + if ( Common.localStorage.getItem('content-theme') != mode ) + Common.localStorage.setItem('content-theme', mode); + + Common.NotificationCenter.trigger('contenttheme:dark', set_dark); + } + }, + toggleContentTheme: function () { var is_current_dark = this.isContentThemeDark(); is_current_dark ? Common.localStorage.setItem('content-theme', 'light') : Common.localStorage.setItem('content-theme', 'dark');