From 7e850a9ac09510e019dfda6b7ca92116fb8e86c9 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 29 Oct 2021 00:19:47 +0300 Subject: [PATCH] [DE] Use config.customization.layout for menu File --- .../main/app/template/FileMenu.template | 6 +- apps/documenteditor/main/app/view/FileMenu.js | 136 +++++++++++------- 2 files changed, 89 insertions(+), 53 deletions(-) diff --git a/apps/documenteditor/main/app/template/FileMenu.template b/apps/documenteditor/main/app/template/FileMenu.template index 8bb022a44..335e29ba6 100644 --- a/apps/documenteditor/main/app/template/FileMenu.template +++ b/apps/documenteditor/main/app/template/FileMenu.template @@ -1,6 +1,6 @@
  • -
  • +
  • @@ -14,11 +14,11 @@
  • -
  • +
  • -
  • +
  • diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index 9345c5626..e63099a3d 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -84,6 +84,16 @@ define([ render: function () { var $markup = $(this.template()); + this.miClose = new Common.UI.MenuItem({ + el : $markup.elementById('#fm-btn-return'), + action : 'back', + caption : this.btnCloseMenuCaption, + canFocused: false, + dataHint: 1, + dataHintDirection: 'left-top', + dataHintOffset: [2, 14] + }); + this.miSave = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-save'), action : 'save', @@ -199,6 +209,16 @@ define([ dataHintOffset: [2, 14] }); + this.miInfo = new Common.UI.MenuItem({ + el : $markup.elementById('#fm-btn-info'), + action : 'info', + caption : this.btnInfoCaption, + canFocused: false, + dataHint: 1, + dataHintDirection: 'left-top', + dataHintOffset: [2, 14] + }); + this.miAccess = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-rights'), action : 'rights', @@ -223,6 +243,16 @@ define([ delete this.options.miHistory; } + this.miSettings = new Common.UI.MenuItem({ + el : $markup.elementById('#fm-btn-settings'), + action : 'opts', + caption : this.btnSettingsCaption, + canFocused: false, + dataHint: 1, + dataHintDirection: 'left-top', + dataHintOffset: [2, 14] + }); + this.miHelp = new Common.UI.MenuItem({ el : $markup.elementById('#fm-btn-help'), action : 'help', @@ -233,17 +263,19 @@ define([ dataHintOffset: [2, 14] }); + this.miBack = new Common.UI.MenuItem({ + el : $markup.elementById('#fm-btn-back'), + action : 'exit', + caption : this.btnBackCaption, + canFocused: false, + dataHint: 1, + dataHintDirection: 'left-top', + dataHintOffset: [2, 14] + }); + this.items = []; this.items.push( - new Common.UI.MenuItem({ - el : $markup.elementById('#fm-btn-return'), - action : 'back', - caption : this.btnCloseMenuCaption, - canFocused: false, - dataHint: 1, - dataHintDirection: 'left-top', - dataHintOffset: [2, 14] - }), + this.miClose, this.miSave, this.miEdit, this.miDownload, @@ -254,37 +286,12 @@ define([ this.miProtect, this.miRecent, this.miNew, - new Common.UI.MenuItem({ - el : $markup.elementById('#fm-btn-info'), - action : 'info', - caption : this.btnInfoCaption, - canFocused: false, - dataHint: 1, - dataHintDirection: 'left-top', - dataHintOffset: [2, 14] - }), + this.miInfo, this.miAccess, this.miHistory, - new Common.UI.MenuItem({ - el : $markup.elementById('#fm-btn-settings'), - action : 'opts', - caption : this.btnSettingsCaption, - canFocused: false, - dataHint: 1, - dataHintDirection: 'left-top', - dataHintOffset: [2, 14] - }), + this.miSettings, this.miHelp, - new Common.UI.MenuItem({ - el : $markup.elementById('#fm-btn-back'), - // el : _get_el('fm-btn-back'), - action : 'exit', - caption : this.btnBackCaption, - canFocused: false, - dataHint: 1, - dataHintDirection: 'left-top', - dataHintOffset: [2, 14] - }) + this.miBack ); this.rendered = true; @@ -350,6 +357,14 @@ define([ if (!this.mode) return; + var lastSeparator, + separatorVisible = false; + + var isVisible = Common.UI.LayoutManager.isElementVisible('toolbar-file-close'); + this.miClose[isVisible?'show':'hide'](); + this.miClose.$el.find('+.devider')[isVisible?'show':'hide'](); + isVisible && (lastSeparator = this.miClose.$el.find('+.devider')); + this.miDownload[((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide'](); var isBCSupport = window["AscDesktopEditor"] ? window["AscDesktopEditor"]["isBlockchainSupport"]() : false; this.miSaveCopyAs[((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline)) && (this.mode.canRequestSaveAs || this.mode.saveAsUrl) && !isBCSupport ?'show':'hide'](); @@ -359,22 +374,45 @@ define([ this.miPrint[this.mode.canPrint?'show':'hide'](); this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); this.miProtect[this.mode.canProtect ?'show':'hide'](); - var isVisible = this.mode.canDownload || this.mode.canDownloadOrigin || this.mode.isEdit || this.mode.canPrint || this.mode.canProtect || - !this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights || this.mode.canRename && !this.mode.isDesktopApp; - this.miProtect.$el.find('+.devider')[isVisible && !this.mode.isDisconnected?'show':'hide'](); + separatorVisible = (this.mode.canDownload || this.mode.canDownloadOrigin || this.mode.isEdit || this.mode.canPrint || this.mode.canProtect || + !this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights || this.mode.canRename && !this.mode.isDesktopApp) && !this.mode.isDisconnected; + this.miProtect.$el.find('+.devider')[separatorVisible?'show':'hide'](); + separatorVisible && (lastSeparator = this.miProtect.$el.find('+.devider')); + this.miRecent[this.mode.canOpenRecent?'show':'hide'](); this.miNew[this.mode.canCreateNew?'show':'hide'](); - this.miNew.$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); + separatorVisible = this.mode.canCreateNew; + this.miNew.$el.find('+.devider')[separatorVisible?'show':'hide'](); + separatorVisible && (lastSeparator = this.miNew.$el.find('+.devider')); - this.miAccess[(!this.mode.isOffline && this.document&&this.document.info && - (this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 || - (this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length || this.mode.canRequestSharingSettings)))?'show':'hide'](); + isVisible = Common.UI.LayoutManager.isElementVisible('toolbar-file-info'); + separatorVisible = isVisible; + this.miInfo[isVisible?'show':'hide'](); + isVisible = !this.mode.isOffline && this.document&&this.document.info && + (this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 || + (this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length || this.mode.canRequestSharingSettings)); + separatorVisible = separatorVisible || isVisible; + this.miAccess[isVisible?'show':'hide'](); + isVisible = this.mode.canUseHistory&&!this.mode.isDisconnected; + separatorVisible = separatorVisible || isVisible; + this.miHistory[isVisible?'show':'hide'](); + this.miHistory.$el.find('+.devider')[separatorVisible?'show':'hide'](); + separatorVisible && (lastSeparator = this.miHistory.$el.find('+.devider')); - this.miHelp[this.mode.canHelp ?'show':'hide'](); - this.miHelp.$el.prev()[this.mode.canHelp ?'show':'hide'](); + isVisible = Common.UI.LayoutManager.isElementVisible('toolbar-file-settings'); + this.miSettings[isVisible?'show':'hide'](); + this.miSettings.$el.find('+.devider')[isVisible?'show':'hide'](); + isVisible && (lastSeparator = this.miSettings.$el.find('+.devider')); + + isVisible = this.mode.canHelp; + this.miHelp[isVisible ?'show':'hide'](); + this.miHelp.$el.find('+.devider')[isVisible?'show':'hide'](); + isVisible && (lastSeparator = this.miHelp.$el.find('+.devider')); + + isVisible = this.mode.canBack; + this.miBack[isVisible ?'show':'hide'](); + lastSeparator && !isVisible && lastSeparator.hide(); - this.mode.canBack ? this.$el.find('#fm-btn-back').show().prev().show() : - this.$el.find('#fm-btn-back').hide().prev().hide(); if (!this.customizationDone) { this.customizationDone = true; Common.Utils.applyCustomization(this.mode.customization, {goback: '#fm-btn-back > a'}); @@ -415,8 +453,6 @@ define([ this.panels['help'] = ((new DE.Views.FileMenuPanels.Help({menu: this})).render()); this.panels['help'].setLangConfig(this.mode.lang); } - - this.miHistory[this.mode.canUseHistory&&!this.mode.isDisconnected?'show':'hide'](); }, setMode: function(mode, delay) {