|
376 | 376 |
|
377 | 377 | this.$el.on('show', this._onResize); |
378 | 378 |
|
| 379 | + this.resizeFileActionMenu = _.debounce(_.bind(this.resizeFileActionMenu, this), 250); |
| 380 | + $(window).resize(this.resizeFileActionMenu); |
| 381 | + |
379 | 382 | // reload files list on share accept |
380 | 383 | $('body').on('OCA.Notification.Action', function(eventObject) { |
381 | 384 | if (eventObject.notification.app === 'files_sharing' && eventObject.action.type === 'POST') { |
|
680 | 683 | * @param {boolean} [show=true] whether to open the sidebar if it was closed |
681 | 684 | */ |
682 | 685 | _updateDetailsView: function(fileName, show) { |
| 686 | + this.resizeFileActionMenu(); |
683 | 687 | if (!(OCA.Files && OCA.Files.Sidebar)) { |
684 | 688 | console.error('No sidebar available'); |
685 | 689 | return; |
|
1504 | 1508 | this.fileMultiSelectMenu.render(); |
1505 | 1509 | this.$el.find('.selectedActions .filesSelectMenu').remove(); |
1506 | 1510 | this.$el.find('.selectedActions').append(this.fileMultiSelectMenu.$el); |
| 1511 | + this.fileMultipleSelectionMenu = new OCA.Files.FileMultipleSelectionMenu(this.multiSelectMenuItems.sort(function(a, b) { |
| 1512 | + return a.order - b.order |
| 1513 | + })); |
| 1514 | + this.fileMultipleSelectionMenu.render(); |
| 1515 | + this.$el.find('.selectedActions .filesSelectionMenu').remove(); |
| 1516 | + this.$el.find('.selectedActions').append(this.fileMultipleSelectionMenu.$el); |
1507 | 1517 | }, |
1508 | 1518 |
|
1509 | 1519 | /** |
|
3504 | 3514 | } |
3505 | 3515 | }, |
3506 | 3516 |
|
| 3517 | + /** |
| 3518 | + * Show or hide file action menu based on the current selection |
| 3519 | + */ |
| 3520 | + resizeFileActionMenu: function() { |
| 3521 | + const appList = this.$el.find('.filesSelectionMenu ul li:not(.hidden-action)'); |
| 3522 | + const appListWidth = 179; |
| 3523 | + const checkWidth = Math.ceil(this.$el.find('.column-selection').outerWidth()); |
| 3524 | + const headerNameWidth = Math.ceil(this.$el.find('.column-name').outerWidth()); |
| 3525 | + const actionWidth = Math.ceil(this.$el.find('#selectedActionLabel').outerWidth()); |
| 3526 | + const allLabelWidth = Math.ceil(this.$el.find('#allLabel').not('#allLabel:hidden').outerWidth()); |
| 3527 | + let headerWidth = Math.ceil(this.$el.find('.files-filestable thead').outerWidth()); |
| 3528 | + |
| 3529 | + if($('#app-sidebar-vue').length>0){ |
| 3530 | + headerWidth = headerWidth - Math.ceil($('#app-sidebar-vue').outerWidth()); |
| 3531 | + } |
| 3532 | + |
| 3533 | + var availableWidth; |
| 3534 | + if(!allLabelWidth){ |
| 3535 | + availableWidth = headerWidth - (checkWidth + headerNameWidth); |
| 3536 | + } |
| 3537 | + else{ |
| 3538 | + availableWidth = headerWidth - (checkWidth + allLabelWidth+ headerNameWidth); |
| 3539 | + } |
| 3540 | + |
| 3541 | + let appCount = Math.floor((availableWidth / appListWidth)); |
| 3542 | + |
| 3543 | + if(appCount < appList.length) { |
| 3544 | + |
| 3545 | + if(!allLabelWidth){ |
| 3546 | + availableWidth = headerWidth - (checkWidth + headerNameWidth + actionWidth); |
| 3547 | + } |
| 3548 | + else{ |
| 3549 | + availableWidth = headerWidth - (checkWidth + allLabelWidth+ headerNameWidth + actionWidth); |
| 3550 | + } |
| 3551 | + appCount = Math.floor((availableWidth / appListWidth)); |
| 3552 | + } |
| 3553 | + |
| 3554 | + var summary = this._selectionSummary.summary; |
| 3555 | + if (summary.totalFiles === 0 && summary.totalDirs === 0) { |
| 3556 | + this.$el.find('#selectedActionLabel').css('display','none'); |
| 3557 | + } |
| 3558 | + else{ |
| 3559 | + if(appCount < appList.length) { |
| 3560 | + this.$el.find('#selectedActionLabel').css('display','block'); |
| 3561 | + } |
| 3562 | + else if(appCount == appList.length){ |
| 3563 | + this.$el.find('#selectedActionLabel').css('display','none'); |
| 3564 | + } |
| 3565 | + else if (!isFinite(appCount)) |
| 3566 | + { |
| 3567 | + this.$el.find('#selectedActionLabel').css('display','block'); |
| 3568 | + } |
| 3569 | + else if(appCount > appList.length){ |
| 3570 | + this.$el.find('#selectedActionLabel').css('display','none'); |
| 3571 | + } |
| 3572 | + } |
| 3573 | + |
| 3574 | + for (let k = 0; k < appList.length; k++) { |
| 3575 | + if (k < appCount) { |
| 3576 | + $(appList[k]).removeClass('hidden'); |
| 3577 | + } else { |
| 3578 | + $(appList[k]).addClass('hidden'); |
| 3579 | + } |
| 3580 | + } |
| 3581 | + }, |
| 3582 | + |
3507 | 3583 | /** |
3508 | 3584 | * Check whether all selected files are copiable |
3509 | 3585 | */ |
|
0 commit comments