From 652d0963fcb06d067bc2ed6d94075f472025fe48 Mon Sep 17 00:00:00 2001 From: OdysseasKr Date: Wed, 9 Dec 2015 02:31:52 +0200 Subject: [PATCH] Add drag and drop support for text By adding the drag and drop support for media files, the default event handlers were overwritten. Thus drag and drop did not support text. Now, the drag and drop listeners revert to the default behaviour when the user does not drag a file. Resolves: #478 --- js/views/file_input_view.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/views/file_input_view.js b/js/views/file_input_view.js index 38e010100d79..15d3c667b37b 100644 --- a/js/views/file_input_view.js +++ b/js/views/file_input_view.js @@ -234,6 +234,8 @@ }, openDropped: function(e) { + if (e.originalEvent.dataTransfer.types[0] != "Files") return; + e.stopPropagation(); e.preventDefault(); this.file = e.originalEvent.dataTransfer.files[0]; @@ -242,12 +244,16 @@ }, showArea: function(e) { + if (e.originalEvent.dataTransfer.types[0] != "Files") return; + e.stopPropagation(); e.preventDefault(); this.$el.addClass("dropoff"); }, hideArea: function(e) { + if (e.originalEvent.dataTransfer.types[0] != "Files") return; + e.stopPropagation(); e.preventDefault(); this.$el.removeClass("dropoff");