Created
April 14, 2011 19:22
-
-
Save jsvensson/920259 to your computer and use it in GitHub Desktop.
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
quickDrop = { | |
doBrowserWarning: function() { | |
var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; | |
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; | |
// Show warning box if unsupported browser | |
// Only work for Chrome atm since that what I develop in | |
// Will test Firefox when the basic functionality is in. | |
if (!isChrome) | |
$("#browserwarning").fadeIn(500); | |
}, | |
initHandlers: function() { | |
// The body listens for a dragged file entering | |
$("#body").bind("dragenter", this.onDragEnter); | |
// The overlay listens for the dragleave event | |
// The ondragover event needs to be canceled in Google Chrome | |
// and Safari to allow firing the ondrop event. | |
// ref: http://help.dottoro.com/ljrkqflw.php | |
$("#overlay").bind("dragleave", this.onDragLeave); | |
$("#overlay").bind("dragover", this.noopHandler); | |
// File gets dropped | |
$("#overlay").bind("drop", this.onDrop); | |
}, | |
noopHandler: function(evt) { | |
evt.stopPropagation(); | |
evt.preventDefault(); | |
}, | |
onDragEnter: function(evt) { | |
$("#overlay").fadeIn(150); | |
}, | |
onDragLeave: function(evt) { | |
$("#overlay").fadeOut(150); | |
}, | |
onDrop: function(evt) { | |
this.noopHandler(evt); | |
$("#overlay").fadeOut(150); | |
}, | |
setStatus: function(msg) { | |
$("#status").html(msg); | |
} | |
}; | |
$(document).ready(function() { | |
quickDrop.doBrowserWarning(); | |
quickDrop.initHandlers(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment