You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
devdocs/assets/javascripts/app/appcache.coffee

38 lines
805 B

11 years ago
class app.AppCache
$.extend @prototype, Events
@isEnabled: ->
try
applicationCache and applicationCache.status isnt applicationCache.UNCACHED
catch
constructor: ->
@cache = applicationCache
@onUpdateReady() if @cache.status is @cache.UPDATEREADY
$.on @cache, 'progress', @onProgress
$.on @cache, 'updateready', @onUpdateReady
update: ->
@notifyUpdate = true
try @cache.update() catch
return
updateInBackground: ->
@notifyUpdate = false
11 years ago
try @cache.update() catch
return
reload: ->
$.on @cache, 'updateready noupdate error', -> window.location = '/'
@updateInBackground()
11 years ago
return
onProgress: (event) =>
@trigger 'progress', event
return
onUpdateReady: =>
@trigger 'updateready' if @notifyUpdate
11 years ago
return