Created
October 26, 2012 13:51
-
-
Save stecb/3958943 to your computer and use it in GitHub Desktop.
drop from url (for carrierwave)
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
- content_for :javascript_page do | |
:javascript | |
$(document).bind('drop', function(e) { | |
var url | |
, target = $(e.target) | |
, remote_avatar = $('#user_remote_avatar_url') | |
; | |
if (target.hasClass('dropzone')) { | |
url = $(e.originalEvent.dataTransfer.getData('text/html')).filter('img').attr('src'); | |
if (target.hasClass('attachments-drop"')) { | |
return; | |
} else { | |
var form = remote_avatar.val(url).parents('form'); | |
form.submit(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment