utils = @AnjLab.Uploads.Utils class @AnjLab.Uploads.UploadHandlerForm extends @AnjLab.Uploads.UploadHandler constructor: (options)-> super(options) @inputs = [] @uuids = [] @detachLoadEvents = {} attachLoadEvent: (iframe, callback)-> detach = => return if !@detachLoadEvents[iframe.id] @log('Received response for ' + iframe.id) # when we remove iframe from dom # the request stops, but in IE load # event fires return if !iframe.parentNode try # fixing Opera 10.53 # In Opera event is fired second time # when body.innerHTML changed from false # to server response approx. after 1 sec # when we upload file with iframe return if iframe.contentDocument?.body?.innerHTML == 'false' catch error #IE may throw an "access is denied" error when attempting to access contentDocument on the iframe in some cases @log("Error when attempting to access iframe during handling of upload response (#{error})", 'error') callback() delete @detachLoadEvents[iframe.id] @detachLoadEvents[iframe.id] = detach $(iframe).on 'load', detach # Returns json object received by iframe from server. getIframeContentJson: (iframe)-> # IE may throw an "access is denied" error when attempting to access contentDocument on the iframe in some cases try # iframe.contentWindow.document - for IE<7 doc = iframe.contentDocument || iframe.contentWindow.document innerHTML = doc.body.innerHTML @log "converting iframe's innerHTML to JSON" @log "innerHTML = #{innerHTML}" # plain text response may be wrapped in
 tag
      if innerHTML && innerHTML.match(/^
    # We can't use following code as the name attribute
    # won't be properly registered in IE6, and new window
    # on form submit will open
    # var iframe = document.createElement('iframe');
    # iframe.setAttribute('name', id);

    iframe = $("