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