Skip to content
Prev Previous commit
Next Next commit
Fixed action label issue
Signed-off-by: Kavita Sonawane <[email protected]>
  • Loading branch information
TSI-kavitasonawane committed Nov 1, 2021
commit 70311f8139d646f465fcd6428fad71c9eaba914b
45 changes: 31 additions & 14 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@

this.$el.on('show', this._onResize);

$('#selectedActionLabel').css('display','none');
this.resizeFileActionMenu = _.debounce(_.bind(this.resizeFileActionMenu, this), 250);
$(window).resize(this.resizeFileActionMenu);

Expand Down Expand Up @@ -3468,12 +3467,9 @@
this.$el.find('#headerSizeCount').removeClass('hidden');
this.$el.find('.headerSizeOpen').removeClass('hidden');
this.$el.find('#selectedActionsList').removeClass('menu-center');
if (window.matchMedia('(max-width: 480px)').matches) {
$('#selectedActionLabel').css('display','block');
}
this.resizeFileActionMenu();
this.$el.find('#headerSizeCount').text(OC.Util.humanFileSize(summary.totalSize));
this.fileMultipleSelectionMenu.show(this);
this.resizeFileActionMenu();

var directoryInfo = n('files', '%n folder', '%n folders', summary.totalDirs);
var fileInfo = n('files', '%n file', '%n files', summary.totalFiles);
Expand Down Expand Up @@ -3519,28 +3515,48 @@
/**
* Show or hide file action menu based on the current selection
*/
resizeFileActionMenu: function() {
resizeFileActionMenu: function() {
const appList = $('.filesSelectionMenu ul li').not('.item-toggleSelectionMode:hidden,.item-tags:hidden');
const headerWidth = $('#filestable thead').outerWidth();
const checkWidth = $('#headerSelection').outerWidth();
const headerNameWidth = $('#headerName').outerWidth();
const actionWidth = $('#selectedActionLabel').outerWidth();
const allLabelWidth = $('#allLabel').outerWidth();
const allLabelWidth = $('#allLabel').not('#allLabel:hidden').outerWidth();
var availableWidth;
if(!allLabelWidth){
availableWidth = headerWidth - (checkWidth + headerNameWidth);
}
else{
availableWidth = headerWidth - (checkWidth + allLabelWidth+ headerNameWidth);
}

let availableWidth = headerWidth - (checkWidth + allLabelWidth+ headerNameWidth);
let appCount = Math.floor((availableWidth / $(appList).width()));
let appListCount = $(appList).width();

if(appCount < appList.length) {
$('#selectedActionLabel').css('display','block');
availableWidth = headerWidth - (checkWidth + allLabelWidth+ headerNameWidth + actionWidth);
if(!allLabelWidth){
availableWidth = headerWidth - (checkWidth + headerNameWidth + actionWidth);
}
else{
availableWidth = headerWidth - (checkWidth + allLabelWidth+ headerNameWidth + actionWidth);
}
appCount = Math.floor((availableWidth / $(appList).width()));
}
else if(appListCount==0) {
$('#selectedActionLabel').css('display','block');

var summary = this._selectionSummary.summary;
if (summary.totalFiles === 0 && summary.totalDirs === 0) {
$('#selectedActionLabel').css('display','none');
}
else{
$('#selectedActionLabel').css('display','none');
if(appCount < appList.length) {
$('#selectedActionLabel').css('display','block');
}
else if(appCount == appList.length){
$('#selectedActionLabel').css('display','none');
}
else if (!isFinite(appCount))
{
$('#selectedActionLabel').css('display','block');
}
}

for (let k = 0; k < appList.length; k++) {
Expand All @@ -3552,6 +3568,7 @@
}
},


/**
* Check whether all selected files are copiable
*/
Expand Down