Created
May 23, 2012 10:38
-
-
Save alexeypegov/2774506 to your computer and use it in GitHub Desktop.
dnd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Upload.initDnD = function () { | |
var d = $(document)[0]; | |
d.ondragenter = function (event) { | |
event.preventDefault(); | |
if (!window.drag_in_progress) { | |
window.drag_in_progress = true; | |
var drop = $(h('.drop', h('.text', 'Drop it to upload'))); | |
$('body').append(drop); | |
drop[0].ondragover = function(event) { | |
event.preventDefault(); | |
if (window.clear_drag) { | |
clearTimeout(window.clear_drag); | |
} | |
window.clear_drag = setTimeout(function () { | |
Upload.clearDnD(); | |
}, 300); | |
}; | |
drop[0].ondrop = function(event) { | |
event.preventDefault(); | |
Upload.clearDnD(); | |
new Upload().sendAsFormData(event.dataTransfer.files); | |
return false; | |
}; | |
return false; | |
} | |
return false; | |
}; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment