From b1dd0ae09c13d855ff30452685df5035448691b4 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Mon, 22 Apr 2013 15:35:34 -0400 Subject: [PATCH] [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) --- zephyr/static/third/jquery/jquery.filedrop.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/zephyr/static/third/jquery/jquery.filedrop.js b/zephyr/static/third/jquery/jquery.filedrop.js index 3f35b279d4..dc503e0f37 100644 --- a/zephyr/static/third/jquery/jquery.filedrop.js +++ b/zephyr/static/third/jquery/jquery.filedrop.js @@ -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;