[all] added "dark theme" item in button "Options"

This commit is contained in:
Maxim Kadushkin 2021-02-14 00:43:51 +03:00
parent b84b3ccbdd
commit db3a344760
11 changed files with 72 additions and 0 deletions

View file

@ -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);
}
},

View file

@ -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 || {}))

View file

@ -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));

View file

@ -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;
}
},

View file

@ -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",

View file

@ -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));

View file

@ -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;
}
},

View file

@ -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",

View file

@ -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));

View file

@ -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;
}
},

View file

@ -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",