fix: additional checks for hide dividers

This commit is contained in:
Konstantin Kireyev
2025-04-02 22:35:20 +05:00
parent 631c7f1fd0
commit ee2909a1c6
5 changed files with 97 additions and 30 deletions

View File

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