mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
[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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user