From ec86b9572b5ed777af6f5cbc443451fe15daeed3 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 30 Dec 2012 16:44:35 -0500 Subject: dragging/dropping images in chrome --- static/js/src/drag.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'static/js/src/drag.js') diff --git a/static/js/src/drag.js b/static/js/src/drag.js index b48c365..48b3266 100644 --- a/static/js/src/drag.js +++ b/static/js/src/drag.js @@ -45,17 +45,21 @@ function dragTarget (target, callbacks) { } base.drop = function(e){ base.target.classList.remove('over'); - if (e.stopPropagation) { - e.stopPropagation(); // stops the browser from redirecting. - } - if (e.preventDefault) { - e.preventDefault(); - } + e.stopPropagation(); // stops the browser from redirecting. + e.preventDefault(); if ('drop' in callbacks) { - callbacks.drop(Drag.url); + if (e.dataTransfer) { + var url = e.dataTransfer.getData("url"); + if (url) { + callbacks.drop(url); + } + } else { + callbacks.drop(Drag.url); + } } return false; } + base.init(); }; -- cgit v1.2.3-70-g09d2