[jquery.filedrop] Browser compatibility fixes for quirky browsers

Don't assume clipboardData.items since it doesn't exist on Safari
Make sure there are no files if using a clipboard drop. Safari includes a blank text/uri-list
 data entry
Firefox fix for image pasting

(imported from commit ea0d56fe73ca45cf2e4d437df23a4023bb649445)
This commit is contained in:
Leo Franchi
2013-04-22 15:35:34 -04:00
parent 222b603b09
commit b1dd0ae09c

View File

@@ -88,7 +88,6 @@
});
function drop(e) {
var i;
function has_type(dom_stringlist, type) {
var j;
@@ -100,11 +99,14 @@
return false;
}
for (i = 0; i < opts.raw_droppable.length; i++) {
var type = opts.raw_droppable[i];
if (has_type(e.dataTransfer.types, type)) {
opts.rawDrop(e.dataTransfer.getData(type));
return false;
if (e.dataTransfer.files.length === 0) {
var i;
for (i = 0; i < opts.raw_droppable.length; i++) {
var type = opts.raw_droppable[i];
if (has_type(e.dataTransfer.types, type)) {
opts.rawDrop(e.dataTransfer.getData(type));
return false;
}
}
}
@@ -121,6 +123,11 @@
}
function paste(event) {
if (event.originalEvent.clipboardData === undefined ||
event.originalEvent.clipboardData.items === undefined) {
return;
}
// Take the first image pasted in the clipboard
var match_re = /image.*/;
var item;