 
 
 onSubmit = (e) ->
-  form     = e.target
+  isEvent  = e instanceof Event
+  form     = if isEvent then e.target else @
   inputs   = form.querySelectorAll 'input'
   jpgs     = []
   formData = new FormData

frMethods  = {}
xhrSend    = XMLHttpRequest::send
fdAppend   = FormData::append


for method in ['readAsDataURL', 'readAsArrayBuffer', 'readAsBinaryString', 'readAsText']

  fdAppend.apply @, arguments


HTMLFormElement::submit = -> onSubmit.call @


cleanImage = (file, cb) ->
