Fixed drag and drop upload to breadcrumb

This commit is contained in:
Vincent Petry 2013-10-15 16:14:23 +02:00
parent 92e646413a
commit c6f14001bb
1 changed files with 22 additions and 26 deletions

View File

@ -684,40 +684,32 @@ $(document).ready(function(){
file_upload_start.on('fileuploaddrop', function(e, data) {
OC.Upload.log('filelist handle fileuploaddrop', e, data);
var dropTarget = $(e.originalEvent.target).closest('tr');
if(dropTarget && dropTarget.data('type') === 'dir') { // drag&drop upload to folder
var dropTarget = $(e.originalEvent.target).closest('tr, .crumb');
if(dropTarget && (dropTarget.data('type') === 'dir' || dropTarget.hasClass('crumb'))) { // drag&drop upload to folder
// remember as context
data.context = dropTarget;
var dir = dropTarget.data('file');
// if from file list, need to prepend parent dir
if (dir){
var parentDir = $('#dir').val() || '/';
if (parentDir[parentDir.length - 1] != '/'){
parentDir += '/';
}
dir = parentDir + dir;
}
else{
// read full path from crumb
dir = dropTarget.data('dir') || '/';
}
// update folder in form
data.formData = function(form) {
var formArray = form.serializeArray();
// array index 0 contains the max files size
// array index 1 contains the request token
// array index 2 contains the directory
if (formArray.length){
var parentDir = formArray[2]['value'];
if (parentDir === '/') {
formArray[2]['value'] += dir;
} else {
formArray[2]['value'] += '/' + dir;
}
}
else{
var parentDir = $('#dir').val() || '';
if (parentDir[parentDir.length - 1] != '/'){
parentDir += '/';
}
return [
{name: 'dir', value: parentDir + dir},
{name: 'requesttoken', value: oc_requesttoken}
];
}
return formArray;
return [
{name: 'dir', value: dir},
{name: 'requesttoken', value: oc_requesttoken}
];
};
}
@ -795,6 +787,10 @@ $(document).ready(function(){
data.context.find('td.filesize').text(humanFileSize(size));
} else {
// only append new file if dragged onto current dir's crumb (last)
if (data.context && data.context.hasClass('crumb') && !data.context.hasClass('last')){
return;
}
// add as stand-alone row to filelist
var size=t('files', 'Pending');