From 90460bef435005095107839a4e037281097c07e2 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 1 Dec 2016 19:11:48 -0500 Subject: [PATCH] New button in file manager that triggers the right click menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable’s support on mobile devices and those who cannot right click (blessed be them) closes #182 --- CHANGELOG.md | 1 + resources/views/server/files/list.blade.php | 9 +- .../js/filemanager/contextmenu.blade.php | 173 +++++++++--------- 3 files changed, 98 insertions(+), 85 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6efd4f0e4..32a436a48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. ## v0.5.4 (Bodacious Boreopterus) ### Added * Changing node configuration values now automatically makes a call to the daemon and updates the configuration there. Changing daemon tokens now does not require any intervention, and takes effect immediately. SSL & Port configurations will still require a daemon reboot. +* New button in file manager that triggers the right click menu to enable support on mobile devices and those who cannot right click (blessed be them). ### Changed * File uploads now account for a maximum file size that is assigned for the daemon, and gives cleaner errors when that limit is reached. diff --git a/resources/views/server/files/list.blade.php b/resources/views/server/files/list.blade.php index 74f539efb..ff6a28551 100644 --- a/resources/views/server/files/list.blade.php +++ b/resources/views/server/files/list.blade.php @@ -21,13 +21,14 @@ - File Name + File Name Size Last Modified + - + /home/container{{ $directory['header'] }} @@ -44,6 +45,7 @@ + @endif @if (isset($directory['show']) && $directory['show'] === true) @@ -54,6 +56,7 @@ + @endif @foreach ($folders as $folder) @@ -73,6 +76,7 @@ {{ $carbon->diffForHumans() }} @endif + @endforeach @foreach ($files as $file) @@ -149,6 +153,7 @@ {{ $carbon->diffForHumans() }} @endif + @endforeach diff --git a/resources/views/server/js/filemanager/contextmenu.blade.php b/resources/views/server/js/filemanager/contextmenu.blade.php index a4111415c..e396b50aa 100644 --- a/resources/views/server/js/filemanager/contextmenu.blade.php +++ b/resources/views/server/js/filemanager/contextmenu.blade.php @@ -56,102 +56,109 @@ class ContextMenuClass { } rightClick() { - $('#file_listing > tbody td').on('contextmenu', event => { - - const parent = $(event.target).closest('tr'); - const menu = $(this.makeMenu(parent)); - - if (parent.data('type') === 'disabled') return; + $('[data-action="toggleMenu"]').on('mousedown', () => { event.preventDefault(); + this.showMenu(event); + }); + $('#file_listing > tbody td').on('contextmenu', event => { + this.showMenu(event); + }); + } - $(menu).appendTo('body'); - $(menu).data('invokedOn', $(event.target)).show().css({ - position: 'absolute', - left: event.pageX, - top: event.pageY, - }); + showMenu(event) { + const parent = $(event.target).closest('tr'); + const menu = $(this.makeMenu(parent)); - this.activeLine = parent; - this.activeLine.addClass('active'); + if (parent.data('type') === 'disabled') return; + event.preventDefault(); - @can('download-files', $server) - if (parent.data('type') === 'file') { - $(menu).find('li[data-action="download"]').removeClass('hidden'); - } - @endcan + $(menu).appendTo('body'); + $(menu).data('invokedOn', $(event.target)).show().css({ + position: 'absolute', + left: event.pageX - 150, + top: event.pageY, + }); - @can('compress-files', $server) - if (parent.data('type') === 'folder') { - $(menu).find('li[data-action="compress"]').removeClass('hidden'); - } - @endcan + this.activeLine = parent; + this.activeLine.addClass('active'); - @can('decompress-files', $server) - if (_.without(['application/zip', 'application/gzip', 'application/x-gzip'], parent.data('mime')).length < 3) { - $(menu).find('li[data-action="decompress"]').removeClass('hidden'); - } - @endcan + @can('download-files', $server) + if (parent.data('type') === 'file') { + $(menu).find('li[data-action="download"]').removeClass('hidden'); + } + @endcan - // Handle Events - const Actions = new ActionsClass(parent, menu); - @can('move-files', $server) - $(menu).find('li[data-action="move"]').unbind().on('click', e => { - e.preventDefault(); - Actions.move(); - }); - @endcan + @can('compress-files', $server) + if (parent.data('type') === 'folder') { + $(menu).find('li[data-action="compress"]').removeClass('hidden'); + } + @endcan - @can('copy-files', $server) - $(menu).find('li[data-action="copy"]').unbind().on('click', e => { - e.preventDefault(); - Actions.copy(); - }); - @endcan + @can('decompress-files', $server) + if (_.without(['application/zip', 'application/gzip', 'application/x-gzip'], parent.data('mime')).length < 3) { + $(menu).find('li[data-action="decompress"]').removeClass('hidden'); + } + @endcan - @can('move-files', $server) - $(menu).find('li[data-action="rename"]').unbind().on('click', e => { - e.preventDefault(); - Actions.rename(); - }); - @endcan - - @can('compress-files', $server) - $(menu).find('li[data-action="compress"]').unbind().on('click', e => { - e.preventDefault(); - Actions.compress(); - }); - @endcan - - @can('decompress-files', $server) - $(menu).find('li[data-action="decompress"]').unbind().on('click', e => { - e.preventDefault(); - Actions.decompress(); - }); - @endcan - - @can('create-files', $server) - $(menu).find('li[data-action="folder"]').unbind().on('click', e => { - e.preventDefault(); - Actions.folder(); - }); - @endcan - - @can('download-files', $server) - $(menu).find('li[data-action="download"]').unbind().on('click', e => { - e.preventDefault(); - Actions.download(); - }); - @endcan - - $(menu).find('li[data-action="delete"]').unbind().on('click', e => { + // Handle Events + const Actions = new ActionsClass(parent, menu); + @can('move-files', $server) + $(menu).find('li[data-action="move"]').unbind().on('click', e => { e.preventDefault(); - Actions.delete(); + Actions.move(); }); + @endcan - $(window).on('click', () => { - $(menu).remove(); - if(!_.isNull(this.activeLine)) this.activeLine.removeClass('active'); + @can('copy-files', $server) + $(menu).find('li[data-action="copy"]').unbind().on('click', e => { + e.preventDefault(); + Actions.copy(); }); + @endcan + + @can('move-files', $server) + $(menu).find('li[data-action="rename"]').unbind().on('click', e => { + e.preventDefault(); + Actions.rename(); + }); + @endcan + + @can('compress-files', $server) + $(menu).find('li[data-action="compress"]').unbind().on('click', e => { + e.preventDefault(); + Actions.compress(); + }); + @endcan + + @can('decompress-files', $server) + $(menu).find('li[data-action="decompress"]').unbind().on('click', e => { + e.preventDefault(); + Actions.decompress(); + }); + @endcan + + @can('create-files', $server) + $(menu).find('li[data-action="folder"]').unbind().on('click', e => { + e.preventDefault(); + Actions.folder(); + }); + @endcan + + @can('download-files', $server) + $(menu).find('li[data-action="download"]').unbind().on('click', e => { + e.preventDefault(); + Actions.download(); + }); + @endcan + + $(menu).find('li[data-action="delete"]').unbind().on('click', e => { + e.preventDefault(); + Actions.delete(); + }); + + $(window).on('click', () => { + $(menu).remove(); + if(!_.isNull(this.activeLine)) this.activeLine.removeClass('active'); }); }