Do not show an error message when draging and dropping text

When the browser reports a drag of items other than files (for example,
text) and then triggers a drop event with no files no error message
should be shown to the user, as in that case there would be no highlight
of the drop zone and no indication that the drop would be valid (except
for the mouse cursor); the error message should be shown only when
the drop event with no files follows a file drag.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2018-06-08 20:37:43 +02:00
parent d4143af5ed
commit 85d9264a14
1 changed files with 10 additions and 0 deletions

View File

@ -1041,6 +1041,8 @@ OC.Uploader.prototype = _.extend({
//remaining time //remaining time
var lastUpdate, lastSize, bufferSize, buffer, bufferIndex, bufferIndex2, bufferTotal; var lastUpdate, lastSize, bufferSize, buffer, bufferIndex, bufferIndex2, bufferTotal;
var dragging = false;
// add progress handlers // add progress handlers
fileupload.on('fileuploadadd', function(e, data) { fileupload.on('fileuploadadd', function(e, data) {
self.log('progress handle fileuploadadd', e, data); self.log('progress handle fileuploadadd', e, data);
@ -1148,6 +1150,8 @@ OC.Uploader.prototype = _.extend({
filerow.addClass('dropping-to-dir'); filerow.addClass('dropping-to-dir');
filerow.find('.thumbnail').addClass('icon-filetype-folder-drag-accept'); filerow.find('.thumbnail').addClass('icon-filetype-folder-drag-accept');
} }
dragging = true;
}); });
var disableDropState = function() { var disableDropState = function() {
@ -1155,6 +1159,8 @@ OC.Uploader.prototype = _.extend({
$('.dropping-to-dir').removeClass('dropping-to-dir'); $('.dropping-to-dir').removeClass('dropping-to-dir');
$('.dir-drop').removeClass('dir-drop'); $('.dir-drop').removeClass('dir-drop');
$('.icon-filetype-folder-drag-accept').removeClass('icon-filetype-folder-drag-accept'); $('.icon-filetype-folder-drag-accept').removeClass('icon-filetype-folder-drag-accept');
dragging = false;
}; };
fileupload.on('fileuploaddragleave fileuploaddrop', disableDropState); fileupload.on('fileuploaddragleave fileuploaddrop', disableDropState);
@ -1164,6 +1170,10 @@ OC.Uploader.prototype = _.extend({
// file was being dragged (and thus caused "fileuploaddragover" // file was being dragged (and thus caused "fileuploaddragover"
// to be triggered). // to be triggered).
fileupload.on('fileuploaddropnofiles', function() { fileupload.on('fileuploaddropnofiles', function() {
if (!dragging) {
return;
}
disableDropState(); disableDropState();
OC.Notification.show(t('files', 'Uploading that item is not supported'), {type: 'error'}); OC.Notification.show(t('files', 'Uploading that item is not supported'), {type: 'error'});