 
     @options = extend { }, @defaultOptions, elementOptions, options ? { }
     
-    @options.url = @element.attr "action" unless @options.url?
+    @options.url = @element.action unless @options.url?
 
     throw new Error "No URL provided." unless @options.url
 
-    @previewsContainer = if @options.previewsContainer then o @options.previewsContainer else @element
+    @previewsContainer = if @options.previewsContainer then createElement(@options.previewsContainer) else @element
 
     @init()
 
 
 
-
-
   init: ->
-    if @elementTagName == "form" and @element.attr("enctype") != "multipart/form-data"
-      @element.attr "enctype", "multipart/form-data"
-
-    if @element.hasClass("dropzone") and @element.find(".message").length == 0
-      @element.append o """<div class="default message"><span>Drop files here to upload</span></div>"""
-
-    capableBrowser = yes
-
-    if window.File and window.FileReader and window.FileList and window.Blob and window.FormData
-      # The browser supports the API, but may be blacklisted.
-      for regex in @blacklistedBrowsers
-        if regex.test navigator.userAgent
-          capableBrowser = no
-          continue
-    else
-      capableBrowser = no
-
-
-    # If the browser failed, just call the fallback and leave
-    return @options.fallback.call this unless capableBrowser
+    # In case it isn't set already
+    @element.setAttribute("enctype", "multipart/form-data") if @element.tagName == "form"
+
+    if @element.classList.contains("dropzone") and !@element.querySelector(".message")
+      @element.appendChild createElement """<div class="default message"><span>Drop files here to upload</span></div>"""
 
     if @options.clickable
-      @hiddenFileInput = o """<input type="file" multiple />"""
+      @hiddenFileInput = document.createElement "input"
+      @hiddenFileInput.setAttribute "type", "file"
+      @hiddenFileInput.setAttribute "multiple", "multiple"
+      @hiddenFileInput.addEventListener "change", =>
+        files = @hiddenFileInput.files
+        if files.length
+          @emit "selectedfiles", files
+          @handleFiles files
 
     @files = [] # All files
     @filesQueue = [] # The files that still have to be processed
     @filesProcessing = [] # The files currently processed
     @URL = window.URL ? window.webkitURL
-    @setupEventListeners()
+
+
+    # Setup all event listeners on the Dropzone object itself.
+    # They're not in @setupEventListeners() because they shouldn't be removed
+    # again when the dropzone gets disabled.
+    @on eventName, @options[eventName] for eventName in @events
+
+
+    noPropagation = (e) ->
+      e.stopPropagation()
+      if e.preventDefault
+        e.preventDefault()
+      else
+        e.returnValue = false
+
+    # Create the listeners
+    @listeners =
+      "dragstart": (e) =>
+        @emit "dragstart", e
+      "dragenter": (e) =>
+        noPropagation e
+        @emit "dragenter", e
+      "dragover": (e) =>
+        noPropagation e
+        @emit "dragover", e
+      "dragleave": (e) =>
+        @emit "dragleave", e
+      "drop": (e) =>
+        noPropagation e
+        @drop e
+        @emit "drop", e
+      "dragend": (e) =>
+        @emit "dragend", e
+      "click": (evt) =>
+        return unless @options.clickable
+        # Only the actual dropzone or the message element should trigger file selection
+        if evt.target == @element or evt.target == @element.querySelector ".message"
+          @hiddenFileInput.click() # Forward the click
+
+
+    @enable()
+
     @options.init.call @
 
   # Returns a form that can be used as fallback if the browser does not support DragnDrop

  ]


  # Since the whole Drag'n'Drop API is pretty new, some browsers implement it,
  # but not correctly.
  # So I created a blacklist of userAgents. Yes, yes. Browser sniffing, I know.
  # But what to do when browsers *theoretically* support an API, but crash
  # when using it.
  # 
  # This is a list of regular expressions tested against navigator.userAgent
  # 
  # ** It should only be used on browser that *do* support the API, but
  # incorrectly **
  # 
  blacklistedBrowsers: [
    # The mac os version of opera 12 seems to have a problem with the File drag'n'drop API.
    /opera.*Macintosh.*version\/12/i
    # /MSIE\ 10/i
  ]



  defaultOptions:
    url: null

    "<strong>#{Math.round(size)/10}</strong> #{string}"

  drop: (e) ->
    return unless e.dataTransfer
    files = e.dataTransfer.files
    @emit "selectedfiles", files
    @handleFiles files if files.length

