 
       if file
         console.time('insert') if @debug
+
+        beforeunload = (e) ->
+          message = if _.isFunction(self.onbeforeunloadMessage) then self.onbeforeunloadMessage.call(null) else self.onbeforeunloadMessage
+          e.returnValue = message if e
+          return message
+        window.addEventListener "beforeunload", beforeunload, false
+
         self    = @
         result  =
           onPause: new ReactiveVar false

    @checkAccess = (http) ->
      if @protected
        user = false
        userFuncs = @getUser()
        {user, userId} = userFuncs
        user = user()


    else if @currentFile

      if @downloadCallback
        unless @downloadCallback.call _.extend(http, @getUser(http)), @currentFile
          responseType = '404'

      partiral   = false
