diff options
author | Morris Jobke <morris.jobke@gmail.com> | 2014-01-24 06:53:53 -0800 |
---|---|---|
committer | Morris Jobke <morris.jobke@gmail.com> | 2014-01-24 06:53:53 -0800 |
commit | 1fe60e435e98648c59c0334bd32ac3cc5a1f6c4f (patch) | |
tree | 1e9f455bd7f8fad4af92de057e460ed9bbbac01c | |
parent | 9f003a3546d3f309601c8a4db7245c7649d9c6af (diff) | |
parent | 8fb4ab097dd7cd8ae1ab8fc15ae48021f8d9c28e (diff) | |
download | nextcloud-server-1fe60e435e98648c59c0334bd32ac3cc5a1f6c4f.tar.gz nextcloud-server-1fe60e435e98648c59c0334bd32ac3cc5a1f6c4f.zip |
Merge pull request #6184 from owncloud/6051-ux-files-Move-File-Spinner
#6051 [ux][files] Move File Spinner
-rw-r--r-- | apps/files/js/files.js | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 76ac87d38ed..2fe4ab464c8 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -493,7 +493,7 @@ var createDragShadow = function(event) { var dir=$('#dir').val(); $(selectedFiles).each(function(i,elem) { - var newtr = $('<tr/>').attr('data-dir', dir).attr('data-filename', elem.name); + var newtr = $('<tr/>').attr('data-dir', dir).attr('data-filename', elem.name).attr('data-origin', elem.origin); newtr.append($('<td/>').addClass('filename').text(elem.name)); newtr.append($('<td/>').addClass('size').text(humanFileSize(elem.size))); tbody.append(newtr); @@ -511,13 +511,30 @@ var createDragShadow = function(event) { }; //options for file drag/drop +//start&stop handlers needs some cleaning up var dragOptions={ revert: 'invalid', revertDuration: 300, opacity: 0.7, zIndex: 100, appendTo: 'body', cursorAt: { left: 24, top: 18 }, helper: createDragShadow, cursor: 'move', - stop: function(event, ui) { - $('#fileList tr td.filename').addClass('ui-draggable'); - } + start: function(event, ui){ + var $selectedFiles = $('td.filename input:checkbox:checked'); + if($selectedFiles.length > 1){ + $selectedFiles.parents('tr').fadeTo(250, 0.2); + } + else{ + $(this).fadeTo(250, 0.2); + } + }, + stop: function(event, ui) { + var $selectedFiles = $('td.filename input:checkbox:checked'); + if($selectedFiles.length > 1){ + $selectedFiles.parents('tr').fadeTo(250, 1); + } + else{ + $(this).fadeTo(250, 1); + } + $('#fileList tr td.filename').addClass('ui-draggable'); + } }; // sane browsers support using the distance option if ( $('html.ie').length === 0) { @@ -525,6 +542,7 @@ if ( $('html.ie').length === 0) { } var folderDropOptions={ + hoverClass: "canDrop", drop: function( event, ui ) { //don't allow moving a file into a selected folder if ($(event.target).parents('tr').find('td input:first').prop('checked') === true) { @@ -537,6 +555,11 @@ var folderDropOptions={ $(files).each(function(i,row) { var dir = $(row).data('dir'); var file = $(row).data('filename'); + //slapdash selector, tracking down our original element that the clone budded off of. + var origin = $('tr[data-id=' + $(row).data('origin') + ']'); + var td = origin.children('td.filename'); + var oldBackgroundImage = td.css('background-image'); + td.css('background-image', 'url('+ OC.imagePath('core', 'loading.gif') + ')'); $.post(OC.filePath('files', 'ajax', 'move.php'), { dir: dir, file: file, target: dir+'/'+target }, function(result) { if (result) { if (result.status === 'success') { @@ -559,6 +582,7 @@ var folderDropOptions={ } else { OC.dialogs.alert(t('files', 'Error moving file'), t('files', 'Error')); } + td.css('background-image', oldBackgroundImage); }); }); }, @@ -583,6 +607,11 @@ var crumbDropOptions={ $(files).each(function(i,row) { var dir = $(row).data('dir'); var file = $(row).data('filename'); + //slapdash selector, tracking down our original element that the clone budded off of. + var origin = $('tr[data-id=' + $(row).data('origin') + ']'); + var td = origin.children('td.filename'); + var oldBackgroundImage = td.css('background-image'); + td.css('background-image', 'url('+ OC.imagePath('core', 'loading.gif') + ')'); $.post(OC.filePath('files', 'ajax', 'move.php'), { dir: dir, file: file, target: target }, function(result) { if (result) { if (result.status === 'success') { @@ -597,6 +626,7 @@ var crumbDropOptions={ } else { OC.dialogs.alert(t('files', 'Error moving file'), t('files', 'Error')); } + td.css('background-image', oldBackgroundImage); }); }); }, @@ -663,7 +693,8 @@ function getSelectedFilesTrash(property) { mime:$(element).data('mime'), type:$(element).data('type'), size:$(element).data('size'), - etag:$(element).data('etag') + etag:$(element).data('etag'), + origin: $(element).data('id') }; if (property) { files.push(file[property]); @@ -783,3 +814,4 @@ function onClickBreadcrumb(e) { FileList.changeDirectory(decodeURIComponent($targetDir)); } } + |