Upload files with drag&drop in the drive

This commit is contained in:
yflory
2017-06-14 12:47:37 +02:00
parent 494b44e2b1
commit 497ddeee6d
7 changed files with 85 additions and 101 deletions

View File

@@ -238,7 +238,13 @@ define([
reader.readAsArrayBuffer(file);
};
var createAreaHandlers = File.createDropArea = function ($area, $hoverArea, todo) {
var onFileDrop = File.onFileDrop = function (file, e) {
Array.prototype.slice.call(file).forEach(function (d) {
handleFile(d, e);
});
};
var createAreaHandlers = File.createDropArea = function ($area, $hoverArea) {
var counter = 0;
if (!$hoverArea) { $hoverArea = $area; }
$hoverArea
@@ -267,15 +273,14 @@ define([
var dropped = e.originalEvent.dataTransfer.files;
counter = 0;
$hoverArea.removeClass('hovering');
Array.prototype.slice.call(dropped).forEach(function (d) {
todo(d, e);
});
onFileDrop(dropped, e);
});
};
var createUploader = function ($area, $hover, $body) {
createAreaHandlers($area, null, handleFile);
if (!config.noHandlers) {
createAreaHandlers($area, null);
}
createTableContainer($body);
};

View File

@@ -586,19 +586,6 @@ define([
return pad;
});
if (!contains && href) {
var data = makePad(href, name);
getStore().pushData(data, function (e, id) {
if (e) {
if (e === 'E_OVER_LIMIT') {
common.alert(Messages.pinLimitNotPinned, null, true);
return;
}
else { return void cb(e); }
}
getStore().addPad(id, common.initialPath);
});
}
if (updateWeaker.length > 0) {
updateWeaker.forEach(function (obj) {
// If we have a stronger url, and if all the occurences of the weaker were
@@ -606,6 +593,20 @@ define([
getStore().restoreHref(obj.n);
});
}
if (!contains && href) {
var data = makePad(href, name);
getStore().pushData(data, function (e, id) {
if (e) {
if (e === 'E_OVER_LIMIT') {
common.alert(Messages.pinLimitNotPinned, null, true);
}
return void cb(e);
}
getStore().addPad(id, common.initialPath);
cb(err, recent);
});
return;
}
cb(err, recent);
});
};

View File

@@ -96,6 +96,10 @@ define([
} else {
styleToolbar($container);
}
$container.on('drop dragover', function (e) {
e.preventDefault();
e.stopPropagation();
});
return $toolbar;
};