Skip to content

Commit

Permalink
filedrop: Fix file drag and drop
Browse files Browse the repository at this point in the history
This fixes an issue introduced in the upgrade to jQuery three. The filedrop
field was not updated correctly and drag and drop files was broken.
Additionally, this handles cases where files are dragged over the box but
not dropped. The style of the box is correctly reset after the drag leaves
the box.
  • Loading branch information
greezybacon committed Feb 12, 2019
1 parent 7b1eee8 commit e01314f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/filedrop.field.js
Expand Up @@ -11,6 +11,7 @@
progressUpdated: $.proxy(this.progressUpdated, this),
speedUpdated: $.proxy(this.speedUpdated, this),
dragOver: $.proxy(this.dragOver, this),
dragLeave: $.proxy(this.dragLeave, this),
drop: $.proxy(this.drop, this),
beforeSend: $.proxy(this.beforeSend, this),
beforeEach: $.proxy(this.beforeEach, this),
Expand All @@ -29,6 +30,9 @@
};

FileDropbox.prototype = {
dragLeave: function(e) {
this.$element.removeAttr('style');
},
drop: function(e) {
this.$element.removeAttr('style');
},
Expand Down Expand Up @@ -361,9 +365,9 @@

function drop(e) {
if( opts.drop.call(this, e) === false ) return false;
if(!e.dataTransfer)
if(!e.originalEvent.dataTransfer)
return;
files = e.dataTransfer.files;
files = e.originalEvent.dataTransfer.files;
if (files === null || files === undefined || files.length === 0) {
opts.error(errors[0]);
return false;
Expand Down

0 comments on commit e01314f

Please sign in to comment.