From bd9e655780940d24571093f4b7293bd11ee2cb7d Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 27 Sep 2021 20:02:14 +0300 Subject: [PATCH] [DE forms] Add interface theme to options menu --- .../app/controller/ApplicationController.js | 65 +++++++++++++++---- .../forms/app/view/ApplicationView.js | 12 +++- apps/documenteditor/forms/locale/en.json | 3 +- 3 files changed, 66 insertions(+), 14 deletions(-) diff --git a/apps/documenteditor/forms/app/controller/ApplicationController.js b/apps/documenteditor/forms/app/controller/ApplicationController.js index 4691d3ca5..5a5c6d99e 100644 --- a/apps/documenteditor/forms/app/controller/ApplicationController.js +++ b/apps/documenteditor/forms/app/controller/ApplicationController.js @@ -1063,28 +1063,49 @@ define([ } }, + onThemeClick: function(menu, item) { + Common.UI.Themes.setTheme(item.value); + }, + + onThemeChange: function() { + var current = Common.UI.Themes.currentThemeId(); + _.each(this.view.mnuThemes.items, function(item){ + item.setChecked(current===item.value, true); + }); + }, + createDelayedElements: function() { var me = this, menuItems = this.view.btnOptions.menu.items, - itemsCount = menuItems.length-3; + itemsCount = menuItems.length-4; var initMenu = function(menu) { var last; + // print if (!menuItems[0].isVisible()) menuItems[1].setVisible(false); else last = menuItems[1]; + // download if (!menuItems[2].isVisible() && !menuItems[3].isVisible() && !menuItems[4].isVisible()) menuItems[5].setVisible(false); else last = menuItems[5]; - if (!menuItems[6].isVisible() && !menuItems[7].isVisible()) - menuItems[8].setVisible(false); + // theme + if (!menuItems[6].isVisible()) + menuItems[7].setVisible(false); else - last = menuItems[8]; + last = menuItems[7]; - if (!menuItems[9].isVisible() && !menuItems[10].isVisible()) + // share, location + if (!menuItems[8].isVisible() && !menuItems[9].isVisible()) + menuItems[10].setVisible(false); + else + last = menuItems[10]; + + // embed, fullscreen + if (!menuItems[11].isVisible() && !menuItems[12].isVisible()) last && last.setVisible(false); menu.off('show:after', initMenu); @@ -1106,23 +1127,43 @@ define([ itemsCount -= 2; } - if ( !this.embedConfig.shareUrl || this.appOptions.canFillForms) { + if (Common.UI.Themes.available()) { + var current = Common.UI.Themes.currentThemeId(); + for (var t in Common.UI.Themes.map()) { + this.view.mnuThemes.addItem(new Common.UI.MenuItem({ + caption : Common.UI.Themes.get(t).text, + value : t, + toggleGroup : 'themes', + checkable : true, + checked : t===current + })); + } + } + if (this.view.mnuThemes.items.length<1) { menuItems[6].setVisible(false); itemsCount--; + } else { + this.view.mnuThemes.on('item:click', _.bind(this.onThemeClick, this)); + Common.NotificationCenter.on('uitheme:changed', this.onThemeChange.bind(this)); + } + + if ( !this.embedConfig.shareUrl || this.appOptions.canFillForms) { + menuItems[8].setVisible(false); + itemsCount--; } if (!this.appOptions.canBackToFolder) { - menuItems[7].setVisible(false); - itemsCount--; - } - - if ( !this.embedConfig.embedUrl || this.appOptions.canFillForms) { menuItems[9].setVisible(false); itemsCount--; } + if ( !this.embedConfig.embedUrl || this.appOptions.canFillForms) { + menuItems[11].setVisible(false); + itemsCount--; + } + if ( !this.embedConfig.fullscreenUrl ) { - menuItems[10].setVisible(false); + menuItems[12].setVisible(false); itemsCount--; } if (itemsCount<1) diff --git a/apps/documenteditor/forms/app/view/ApplicationView.js b/apps/documenteditor/forms/app/view/ApplicationView.js index 87a0eb765..b25dfde59 100644 --- a/apps/documenteditor/forms/app/view/ApplicationView.js +++ b/apps/documenteditor/forms/app/view/ApplicationView.js @@ -23,6 +23,15 @@ define([ {caption: this.txtDownloadDocx, value: 'download-docx', iconCls: 'mi-icon svg-icon download'}, {caption: this.txtDownloadPdf, value: 'download-pdf', iconCls: 'mi-icon'}, {caption: '--'}, + {caption: this.txtTheme, value: 'theme', iconCls: 'mi-icon', + menu : this.mnuThemes = new Common.UI.Menu({ + cls: 'shifted-right', + menuAlign: 'tl-tr', + restoreHeight: true, + items: [] + }) + }, + {caption: '--'}, {caption: this.txtShare, value: 'share', iconCls: 'mi-icon svg-icon share'}, {caption: this.txtFileLocation, value: 'close', iconCls: 'mi-icon svg-icon go-to-location'}, {caption: '--'}, @@ -81,6 +90,7 @@ define([ txtDownloadPdf: 'Download as pdf', textNext: 'Next Field', textClear: 'Clear All Fields', - textSubmit: 'Submit' + textSubmit: 'Submit', + txtTheme: 'Interface theme' }); }); \ No newline at end of file diff --git a/apps/documenteditor/forms/locale/en.json b/apps/documenteditor/forms/locale/en.json index 982d66587..ad6982bcb 100644 --- a/apps/documenteditor/forms/locale/en.json +++ b/apps/documenteditor/forms/locale/en.json @@ -57,5 +57,6 @@ "DE.ApplicationView.txtShare": "Share", "DE.ApplicationView.textSubmit": "Submit", "DE.ApplicationView.textClear": "Clear All Fields", - "DE.ApplicationView.textNext": "Next Field" + "DE.ApplicationView.textNext": "Next Field", + "DE.ApplicationView.txtTheme": "Interface theme" } \ No newline at end of file