           unless scope.$root.$$phase == "$apply" || scope.$root.$$phase == "$digest"
             scope.$apply() 
 
+        parse_int = (str) ->
+          int = parseInt(str)
+          if isNaN(int) then 0 else int
     }
 ]
            message = kt.translate 'errors.file_too_big', interpolations: {
              file: error.file.name
              size: (error.file.origSize / 1024.0 / 1024.0).toFixed(2)
              max: 0.5
            }
            window.alert message
          else


        scope.max_file_size = -> kd.info.config.max_file_size
        scope.$watch 'max_file_size()', (new_value) ->
          v = parse_int(new_value)
          setting = if v < 1
            "#{v * 1024}kb"
          else
            "#{v}mb"
          uploader.setOption "filters", {max_file_size: setting}
            

