Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Enable dragging and dropping of text and hyperlinks #1897

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions js/jquery.fileupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@
},

_onDrop: function (e) {
e.preventDefault();
this._maybePreventDefault(e);
var that = this,
dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer,
data = {};
Expand All @@ -972,7 +972,7 @@
if (dataTransfer) {
dataTransfer.dropEffect = 'copy';
}
e.preventDefault();
this._maybePreventDefault(e);
},

_initEventHandlers: function () {
Expand Down Expand Up @@ -1024,6 +1024,26 @@
}
},

// Prevent default action when dragging and dropping files
_maybePreventDefault: function(e) {
var tagName = e.target.tagName.toLowerCase(),
dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer;

function containsFiles() {
var i;
for(i = 0; i < dataTransfer.types.length; i++){
if(dataTransfer.types[i] === "Files") {
return true;
}
}
return false;
}

if (containsFiles() || ["textarea", "input"].indexOf(tagName) == -1) {
e.preventDefault()
}
},

_create: function () {
var options = this.options;
// Initialize options set via HTML5 data-attributes:
Expand Down