diff --git a/apps/common/main/lib/controller/Themes.js b/apps/common/main/lib/controller/Themes.js index 4f55a05a0..722f42cf7 100644 --- a/apps/common/main/lib/controller/Themes.js +++ b/apps/common/main/lib/controller/Themes.js @@ -43,6 +43,10 @@ define([ return Common.localStorage.getItem('ui-theme', 'theme-light'); }, + isDarkTheme: function () { + return this.current() == 'theme-dark'; + }, + setTheme: function (name) { if ( sdk_themes_relation.contains(name) ) { var classname = document.documentElement.className.replace(/theme-\w+\s?/, ''); @@ -51,6 +55,7 @@ define([ this.api.asc_setSkin(sdk_themes_relation[name]); $(':root').addClass(name); Common.localStorage.setItem('ui-theme', name); + Common.NotificationCenter.trigger('uitheme:change', name); } }, diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index ef4565e76..85bb1a407 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -768,6 +768,7 @@ define([ textAdvSettings: 'Advanced Settings', tipViewSettings: 'View Settings', textRemoveFavorite: 'Remove from Favorites', + textDarkTheme: 'Dark theme', textAddFavorite: 'Mark as favorite' } }(), Common.Views.Header || {})) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index da6d8f1df..bf72d1026 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -387,6 +387,7 @@ define([ this.appOptions.canFeatureComparison = !!this.api.asc_isSupportFeature("comparison"); this.appOptions.canFeatureContentControl = !!this.api.asc_isSupportFeature("content-controls"); this.appOptions.mentionShare = !((typeof (this.appOptions.customization) == 'object') && (this.appOptions.customization.mentionShare==false)); + this.appOptions.canChangeUITheme = true; this.appOptions.user.guest && this.appOptions.canRenameAnonymous && Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this)); diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index 3597aaee3..e3728a889 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -313,6 +313,22 @@ define([ cls : 'btn-toolbar' })).on('click', _on_btn_zoom.bind(me, 'up')); + if ( config.canChangeUITheme ) { + var mnuitemDarkTheme = new Common.UI.MenuItem({ + caption: me.header.textDarkTheme, + checked: Common.UI.Themes.isDarkTheme(), + checkable: true, + value: 'theme:dark' + }); + + + me.header.btnOptions.menu.insertItem(7, mnuitemDarkTheme); + me.header.btnOptions.menu.insertItem(7, {caption:'--'}); + Common.NotificationCenter.on('uitheme:change', function (name) { + mnuitemDarkTheme.setChecked(Common.UI.Themes.isDarkTheme()); + }); + } + me.header.btnOptions.menu.on('item:click', me.onOptionsItemClick.bind(this)); } }, @@ -400,6 +416,10 @@ define([ Common.NotificationCenter.trigger('edit:complete', me.header); break; case 'advanced': me.header.fireEvent('file:settings', me.header); break; + case 'theme:dark': + if ( item.isChecked() != Common.UI.Themes.isDarkTheme() ) + Common.UI.Themes.toggleTheme(); + break; } }, diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 39667bcf7..ccbb98aed 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -271,6 +271,7 @@ "Common.Views.Header.tipViewUsers": "View users and manage document access rights", "Common.Views.Header.txtAccessRights": "Change access rights", "Common.Views.Header.txtRename": "Rename", + "Common.Views.Header.textDarkTheme": "Dark theme", "Common.Views.History.textCloseHistory": "Close History", "Common.Views.History.textHide": "Collapse", "Common.Views.History.textHideAll": "Hide detailed changes", diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 40da77dd4..8595c24ce 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -345,6 +345,7 @@ define([ this.appOptions.compatibleFeatures = (typeof (this.appOptions.customization) == 'object') && !!this.appOptions.customization.compatibleFeatures; this.appOptions.canRequestSharingSettings = this.editorConfig.canRequestSharingSettings; this.appOptions.mentionShare = !((typeof (this.appOptions.customization) == 'object') && (this.appOptions.customization.mentionShare==false)); + this.appOptions.canChangeUITheme = true; this.appOptions.user.guest && this.appOptions.canRenameAnonymous && Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this)); diff --git a/apps/presentationeditor/main/app/controller/Viewport.js b/apps/presentationeditor/main/app/controller/Viewport.js index 08e9608ca..1627ca698 100644 --- a/apps/presentationeditor/main/app/controller/Viewport.js +++ b/apps/presentationeditor/main/app/controller/Viewport.js @@ -316,6 +316,22 @@ define([ cls : 'btn-toolbar' })).on('click', _on_btn_zoom.bind(me, 'up')); + if ( config.canChangeUITheme ) { + var mnuitemDarkTheme = new Common.UI.MenuItem({ + caption: me.header.textDarkTheme, + checked: Common.UI.Themes.isDarkTheme(), + checkable: true, + value: 'theme:dark' + }); + + + me.header.btnOptions.menu.insertItem(7, mnuitemDarkTheme); + me.header.btnOptions.menu.insertItem(7, {caption:'--'}); + Common.NotificationCenter.on('uitheme:change', function (name) { + mnuitemDarkTheme.setChecked(Common.UI.Themes.isDarkTheme()); + }); + } + me.header.btnOptions.menu.on('item:click', me.onOptionsItemClick.bind(this)); } }, @@ -443,6 +459,10 @@ define([ Common.NotificationCenter.trigger('edit:complete', me.header); break; case 'advanced': me.header.fireEvent('file:settings', me.header); break; + case 'theme:dark': + if ( item.isChecked() != Common.UI.Themes.isDarkTheme() ) + Common.UI.Themes.toggleTheme(); + break; } }, diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 044ceac66..5d2ed73b4 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -168,6 +168,7 @@ "Common.Views.Header.tipViewUsers": "View users and manage document access rights", "Common.Views.Header.txtAccessRights": "Change access rights", "Common.Views.Header.txtRename": "Rename", + "Common.Views.Header.textDarkTheme": "Dark theme", "Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:", "Common.Views.ImageFromUrlDialog.txtEmpty": "This field is required", "Common.Views.ImageFromUrlDialog.txtNotUrl": "This field should be a URL in the \"http://www.example.com\" format", diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index a9f054d13..320289ade 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -374,6 +374,7 @@ define([ this.appOptions.canMakeActionLink = this.editorConfig.canMakeActionLink; this.appOptions.canFeaturePivot = true; this.appOptions.canFeatureViews = !!this.api.asc_isSupportFeature("sheet-views"); + this.appOptions.canChangeUITheme = true; if (this.appOptions.user.guest && this.appOptions.canRenameAnonymous && !this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge) Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this)); diff --git a/apps/spreadsheeteditor/main/app/controller/Viewport.js b/apps/spreadsheeteditor/main/app/controller/Viewport.js index 685e1c6e1..3d2042754 100644 --- a/apps/spreadsheeteditor/main/app/controller/Viewport.js +++ b/apps/spreadsheeteditor/main/app/controller/Viewport.js @@ -327,6 +327,22 @@ define([ cls : 'btn-toolbar' })).on('click', _on_btn_zoom.bind(me, 'up')); + if ( config.canChangeUITheme ) { + var mnuitemDarkTheme = new Common.UI.MenuItem({ + caption: me.header.textDarkTheme, + checked: Common.UI.Themes.isDarkTheme(), + checkable: true, + value: 'theme:dark' + }); + + + me.header.btnOptions.menu.insertItem(10, mnuitemDarkTheme); + me.header.btnOptions.menu.insertItem(10, {caption:'--'}); + Common.NotificationCenter.on('uitheme:change', function (name) { + mnuitemDarkTheme.setChecked(Common.UI.Themes.isDarkTheme()); + }); + } + me.header.btnOptions.menu.on('item:click', me.onOptionsItemClick.bind(this)); } }, @@ -490,6 +506,10 @@ define([ Common.localStorage.setBool('sse-freeze-shadow', item.isChecked()); break; case 'advanced': me.header.fireEvent('file:settings', me.header); break; + case 'theme:dark': + if ( item.isChecked() != Common.UI.Themes.isDarkTheme() ) + Common.UI.Themes.toggleTheme(); + break; } }, diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 414f06191..1e6d0758a 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -164,6 +164,7 @@ "Common.Views.Header.tipViewUsers": "View users and manage document access rights", "Common.Views.Header.txtAccessRights": "Change access rights", "Common.Views.Header.txtRename": "Rename", + "Common.Views.Header.textDarkTheme": "Dark theme", "Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:", "Common.Views.ImageFromUrlDialog.txtEmpty": "This field is required", "Common.Views.ImageFromUrlDialog.txtNotUrl": "This field should be a URL in the \"http://www.example.com\" format",