Patch filedrop for jQuery 3 compatibility.

This entails removing the use of jQuery.event.props,
which has been removed from jQuery 3.
This commit is contained in:
Cory Lynch
2017-07-01 20:21:02 -04:00
committed by showell
parent 3d0b5b14be
commit 10fa6b75f9

View File

@@ -51,8 +51,6 @@
*/ */
;(function($) { ;(function($) {
jQuery.event.props.push("dataTransfer");
var default_opts = { var default_opts = {
fallback_id: '', fallback_id: '',
url: '', url: '',
@@ -113,6 +111,11 @@
}); });
function drop(e) { function drop(e) {
if (!e.originalEvent.dataTransfer) {
return;
}
files = e.originalEvent.dataTransfer.files;
function has_type(dom_stringlist, type) { function has_type(dom_stringlist, type) {
var j; var j;
@@ -124,19 +127,18 @@
return false; return false;
} }
if (e.dataTransfer.files.length === 0) { if (files.length === 0) {
var i; var i;
for (i = 0; i < opts.raw_droppable.length; i++) { for (i = 0; i < opts.raw_droppable.length; i++) {
var type = opts.raw_droppable[i]; var type = opts.raw_droppable[i];
if (has_type(e.dataTransfer.types, type)) { if (has_type(e.originalEvent.dataTransfer.types, type)) {
opts.rawDrop(e.dataTransfer.getData(type)); opts.rawDrop(e.originalEvent.dataTransfer.getData(type));
return false; return false;
} }
} }
} }
if( opts.drop.call(this, e) === false ) return false; if( opts.drop.call(this, e) === false ) return false;
files = e.dataTransfer.files;
if (files === null || files === undefined || files.length === 0) { if (files === null || files === undefined || files.length === 0) {
opts.error(errors[0]); opts.error(errors[0]);
return false; return false;