summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2013-01-21 14:58:55 +0100
committerJörn Friedrich Dreyer <jfd@butonic.de>2013-01-30 12:59:35 +0100
commit99dfaee1f616c6ffdba8007badc9b5afe427c653 (patch)
tree5561ff9ffb365e617fe0a4e61518ae0881568220 /apps
parent1d0ee61f3a136372b26e90fa35f726c77aa95416 (diff)
downloadnextcloud-server-99dfaee1f616c6ffdba8007badc9b5afe427c653.tar.gz
nextcloud-server-99dfaee1f616c6ffdba8007badc9b5afe427c653.zip
reset checkbox after getting selected files instead of ofter dragging, speed up revert
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/files.js31
1 files changed, 13 insertions, 18 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 34772915a62..288a87c7e3e 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -815,10 +815,19 @@ function updateBreadcrumb(breadcrumbHtml) {
var createDragShadow = function(event){
//select dragged file
- $(event.target).parents('tr').find('td input:first').prop('checked', true);
+ var isDragSelected = $(event.target).parents('tr').find('td input:first').prop('checked');
+ if (!isDragSelected) {
+ //select dragged file
+ $(event.target).parents('tr').find('td input:first').prop('checked',true);
+ }
var selectedFiles = getSelectedFiles();
+ if (!isDragSelected && selectedFiles.length == 1) {
+ //revert the selection
+ $(event.target).parents('tr').find('td input:first').prop('checked',false);
+ }
+
//also update class when we dragged more than one file
if (selectedFiles.length > 1) {
$(event.target).parents('tr').addClass('selected');
@@ -832,8 +841,7 @@ var createDragShadow = function(event){
var dir=$('#dir').val();
$(selectedFiles).each(function(i,elem){
- var selected= $(event.target).parents('tr').hasClass('selected');
- var newtr = $('<tr data-dir="'+dir+'" data-filename="'+elem.name+'" data-selected="'+selected+'">'
+ var newtr = $('<tr data-dir="'+dir+'" data-filename="'+elem.name+'">'
+'<td class="filename">'+elem.name+'</td><td class="size">'+humanFileSize(elem.size)+'</td>'
+'</tr>');
tbody.append(newtr);
@@ -851,16 +859,11 @@ var createDragShadow = function(event){
//options for file drag/drop
var dragOptions={
- revert: 'invalid', opacity: 0.7, zIndex: 100, appendTo: 'body', cursorAt: { left: -5, top: -5 },
+ revert: 'invalid', revertDuration: 300,
+ opacity: 0.7, zIndex: 100, appendTo: 'body', cursorAt: { left: -5, top: -5 },
helper: createDragShadow, cursor: 'move',
stop: function(event, ui) {
$('#fileList tr td.filename').addClass('ui-draggable');
- //reset selection
- $(ui.helper.find('tr')).each(function(i,row){
- var file = $(row).data('filename');
- var selected = $(row).data('selected');
- $('#fileList tr').filterAttr('data-file',file).find('td input:first').prop('checked',selected);
- });
}
}
@@ -899,10 +902,6 @@ var folderDropOptions={
}
});
});
- //reset checkbox if we dragged a single file
- if (files.length == 1) {
- $(event.target).parents('tr').find('td input:first').prop('checked', $(event.target).parents('tr').hasClass('selected'));
- }
},
tolerance: 'pointer'
}
@@ -941,10 +940,6 @@ var crumbDropOptions={
}
});
});
- //reset checkbox if we dragged a single file
- if (files.length == 1) {
- $(event.target).parents('tr').find('td input:first').prop('checked', $(event.target).parents('tr').hasClass('selected'));
- }
},
tolerance: 'pointer'
}