diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index 60b491adab..6fda745d5d 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -564,12 +564,23 @@ define([ .map((el, i) => ({ el, i })) .filter(({ el }) => $(el).hasClass('fm-btn') && $(el).css('display') !== 'none'); + if (!visibleIndices.length) { + items.forEach(el => { + const $el = $(el); + if ($el.hasClass('devider')) { + $el.css('display', 'none'); + } + }); + return; + } + const firstVisible = visibleIndices[0].i; const lastVisible = visibleIndices[visibleIndices.length - 1].i; let prevWasDivider = false; - items.forEach((el, i) => { - const $el = $(el); + for (let i = items.length - 1; i >= 0; i--) { + const $el = $(items[i]); + if ($el.hasClass('devider')) { const shouldShow = i > firstVisible && i < lastVisible; @@ -582,7 +593,7 @@ define([ } else if ($el.hasClass('fm-btn') && $el.css('display') !== 'none') { prevWasDivider = false; } - }); + } }, setMode: function(mode, delay) { diff --git a/apps/pdfeditor/main/app/view/FileMenu.js b/apps/pdfeditor/main/app/view/FileMenu.js index 57469e0097..75a1df28e8 100644 --- a/apps/pdfeditor/main/app/view/FileMenu.js +++ b/apps/pdfeditor/main/app/view/FileMenu.js @@ -539,12 +539,23 @@ define([ .map((el, i) => ({ el, i })) .filter(({ el }) => $(el).hasClass('fm-btn') && $(el).css('display') !== 'none'); + if (!visibleIndices.length) { + items.forEach(el => { + const $el = $(el); + if ($el.hasClass('devider')) { + $el.css('display', 'none'); + } + }); + return; + } + const firstVisible = visibleIndices[0].i; const lastVisible = visibleIndices[visibleIndices.length - 1].i; let prevWasDivider = false; - items.forEach((el, i) => { - const $el = $(el); + for (let i = items.length - 1; i >= 0; i--) { + const $el = $(items[i]); + if ($el.hasClass('devider')) { const shouldShow = i > firstVisible && i < lastVisible; @@ -557,7 +568,7 @@ define([ } else if ($el.hasClass('fm-btn') && $el.css('display') !== 'none') { prevWasDivider = false; } - }); + } }, setMode: function(mode, delay) { diff --git a/apps/presentationeditor/main/app/view/FileMenu.js b/apps/presentationeditor/main/app/view/FileMenu.js index 059a0a5344..01a111cd76 100644 --- a/apps/presentationeditor/main/app/view/FileMenu.js +++ b/apps/presentationeditor/main/app/view/FileMenu.js @@ -553,12 +553,23 @@ define([ .map((el, i) => ({ el, i })) .filter(({ el }) => $(el).hasClass('fm-btn') && $(el).css('display') !== 'none'); + if (!visibleIndices.length) { + items.forEach(el => { + const $el = $(el); + if ($el.hasClass('devider')) { + $el.css('display', 'none'); + } + }); + return; + } + const firstVisible = visibleIndices[0].i; const lastVisible = visibleIndices[visibleIndices.length - 1].i; let prevWasDivider = false; - items.forEach((el, i) => { - const $el = $(el); + for (let i = items.length - 1; i >= 0; i--) { + const $el = $(items[i]); + if ($el.hasClass('devider')) { const shouldShow = i > firstVisible && i < lastVisible; @@ -571,7 +582,7 @@ define([ } else if ($el.hasClass('fm-btn') && $el.css('display') !== 'none') { prevWasDivider = false; } - }); + } }, setMode: function(mode, delay) { diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index a39b7188b6..0125aa9d10 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -540,12 +540,23 @@ define([ .map((el, i) => ({ el, i })) .filter(({ el }) => $(el).hasClass('fm-btn') && $(el).css('display') !== 'none'); + if (!visibleIndices.length) { + items.forEach(el => { + const $el = $(el); + if ($el.hasClass('devider')) { + $el.css('display', 'none'); + } + }); + return; + } + const firstVisible = visibleIndices[0].i; const lastVisible = visibleIndices[visibleIndices.length - 1].i; let prevWasDivider = false; - items.forEach((el, i) => { - const $el = $(el); + for (let i = items.length - 1; i >= 0; i--) { + const $el = $(items[i]); + if ($el.hasClass('devider')) { const shouldShow = i > firstVisible && i < lastVisible; @@ -558,7 +569,7 @@ define([ } else if ($el.hasClass('fm-btn') && $el.css('display') !== 'none') { prevWasDivider = false; } - }); + } }, setMode: function(mode, delay) { diff --git a/apps/visioeditor/main/app/view/FileMenu.js b/apps/visioeditor/main/app/view/FileMenu.js index 3468e57f14..8f4e619dbf 100644 --- a/apps/visioeditor/main/app/view/FileMenu.js +++ b/apps/visioeditor/main/app/view/FileMenu.js @@ -323,13 +323,8 @@ 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.isDesktopApp || !this.mode.isOffline))?'show':'hide'](); var isBCSupport = Common.Controllers.Desktop.isActive() ? Common.Controllers.Desktop.call("isBlockchainSupport") : false; @@ -337,38 +332,25 @@ define([ this.miSaveAs[(this.mode.canDownload && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide'](); this.miPrint[this.mode.canPrint && !this.mode.canPreviewPrint ?'show':'hide'](); this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); - separatorVisible = (this.mode.canDownload || this.mode.canPrint || this.mode.canRename && !this.mode.isDesktopApp) && !this.mode.isDisconnected; - separatorVisible && (lastSeparator = this.miRename.$el.find('+.devider')); this.miRecent[this.mode.canOpenRecent?'show':'hide'](); this.miNew[this.mode.canCreateNew?'show':'hide'](); - if (!this.mode.canOpenRecent && !this.mode.canCreateNew) { - this.miRecent.$el.find('+.devider').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'](); - separatorVisible && (lastSeparator = this.miAccess.$el.find('+.devider')); 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(); if (!this.customizationDone) { this.customizationDone = true; @@ -465,6 +447,47 @@ define([ iconCls: 'menu__icon btn-switch-mobile' })); } + + this.hideDividers(); + }, + + hideDividers: function () { + const items = Array.from(this.$el.find('.panel-menu > li')); + + const visibleIndices = items + .map((el, i) => ({ el, i })) + .filter(({ el }) => $(el).hasClass('fm-btn') && $(el).css('display') !== 'none'); + + if (!visibleIndices.length) { + items.forEach(el => { + const $el = $(el); + if ($el.hasClass('devider')) { + $el.css('display', 'none'); + } + }); + return; + } + + const firstVisible = visibleIndices[0].i; + const lastVisible = visibleIndices[visibleIndices.length - 1].i; + let prevWasDivider = false; + + for (let i = items.length - 1; i >= 0; i--) { + const $el = $(items[i]); + + if ($el.hasClass('devider')) { + const shouldShow = i > firstVisible && i < lastVisible; + + if (shouldShow && !prevWasDivider) { + $el.show(); + prevWasDivider = true; + } else { + $el.hide(); + } + } else if ($el.hasClass('fm-btn') && $el.css('display') !== 'none') { + prevWasDivider = false; + } + } }, setMode: function(mode, delay) {