Merge pull request 'fix/(de,pdf,pe,se): unused delimiters removed' (#330) from fix/file-menu-dividers into release/v9.0.0

This commit is contained in:
Julia Radzhabova
2025-04-02 20:28:12 +00:00
6 changed files with 215 additions and 109 deletions

View File

@ -266,7 +266,10 @@ label {
}
&.devider {
.dropdown-menu .divider;
height: @scaled-one-px-value-ie;
height: @scaled-one-px-value;
background-color: @border-divider-ie;
background-color: @border-divider;
margin-top: 10px;
margin-bottom: 14px;
}

View File

@ -404,14 +404,11 @@ define([
if (!this.mode) return;
var lastSeparator,
separatorVisible = false;
// 1: Back button
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'));
// 3: Download, save, print, rename
this.miDownload[((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide']();
var isBCSupport = Common.Controllers.Desktop.isActive() ? Common.Controllers.Desktop.call("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']();
@ -424,44 +421,30 @@ define([
this.miPrintWithPreview[this.mode.canPreviewPrint?'show':'hide']();
this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide']();
this.miProtect[(this.mode.isSignatureSupport || this.mode.isPasswordSupport) ?'show':'hide']();
separatorVisible = (this.mode.canDownload || this.mode.canDownloadOrigin || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || (this.mode.isSignatureSupport || this.mode.isPasswordSupport) ||
canEdit || this.mode.canRename && !this.mode.isDesktopApp) && !this.mode.isDisconnected;
this.miProtect.$el.find('+.devider')[separatorVisible?'show':'hide']();
separatorVisible && (lastSeparator = this.miProtect.$el.find('+.devider'));
// 2: Recent, create new
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();
}
// 4: Info
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'));
// 6: Settings
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'));
// 5: Close button
isVisible = this.mode.canBack;
this.miBack[isVisible ?'show':'hide']();
lastSeparator && !isVisible && lastSeparator.hide();
if (!this.customizationDone) {
this.customizationDone = true;
@ -571,6 +554,46 @@ define([
}));
}
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) {

View File

@ -389,13 +389,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.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide']();
var isBCSupport = Common.Controllers.Desktop.isActive() ? Common.Controllers.Desktop.call("isBlockchainSupport") : false;
@ -407,39 +402,24 @@ define([
this.miPrintWithPreview[this.mode.canPreviewPrint?'show':'hide']();
this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide']();
this.miProtect[(this.mode.isSignatureSupport || this.mode.isPasswordSupport) ?'show':'hide']();
separatorVisible = (this.mode.canDownload || this.mode.canDownloadOrigin || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || (this.mode.isSignatureSupport || this.mode.isPasswordSupport) ||
!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']();
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']();
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;
@ -548,6 +528,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) {

View File

@ -401,13 +401,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;
@ -419,44 +414,26 @@ define([
this.miPrintWithPreview[this.mode.canPreviewPrint?'show':'hide']();
this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide']();
this.miProtect[(this.mode.isSignatureSupport || this.mode.isPasswordSupport) ?'show':'hide']();
separatorVisible = (this.mode.canDownload || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || (this.mode.isSignatureSupport || this.mode.isPasswordSupport) ||
!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']();
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']();
isVisible = this.mode.canUseHistory&&!this.mode.isDisconnected;
separatorVisible = separatorVisible || isVisible;
isVisible = this.mode.canUseHistory && !this.mode.isDisconnected;
this.miHistory[isVisible?'show':'hide']();
this.miHistory.$el.find('+.devider')[separatorVisible?'show':'hide']();
separatorVisible && (lastSeparator = this.miHistory.$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;
@ -565,6 +542,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) {

View File

@ -383,13 +383,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 = window["AscDesktopEditor"] ? window["AscDesktopEditor"]["isBlockchainSupport"]() : false;
@ -401,44 +396,26 @@ define([
this.miPrintWithPreview[this.mode.canPrint?'show':'hide']();
this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide']();
this.miProtect[(this.mode.isSignatureSupport || this.mode.isPasswordSupport) ?'show':'hide']();
separatorVisible = (this.mode.canDownload || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || (this.mode.isSignatureSupport || this.mode.isPasswordSupport) ||
!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']();
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']();
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'));
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;
@ -552,6 +529,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) {

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