History

Improve offline mode error page

Thibaut committed 11 years ago

Commit 1252b361 parent 74ea6814 files · +23 −8Browse files

Unified · Split

4 files
  1. assets/javascripts/app/db.coffee +7 −1
  2. assets/javascripts/templates/error_tmpl.coffee +13 −4
  3. assets/javascripts/views/content/offline_page.coffee +1 −1
  4. assets/stylesheets/components/_content.scss +2 −2
assets/javascripts/app/db.coffee+7−1
@@ -29,6 +29,7 @@ class app.DB · 28 unmodified lines
2929 @checkedBuggyIDB = true
3030 catch
3131 try db.close()
32+ @reason = 'apple'
3233 @onOpenError()
3334 return
3435
@@ -47,6 +48,7 @@ class app.DB · 12 unmodified lines
4748 app.onQuotaExceeded()
4849 else
4950 @useIndexedDB = false
51+ @reason or= 'cant_open'
5052 @runCallbacks()
5153 return
5254
@@ -251,7 +253,11 @@ class app.DB · 198 unmodified lines
251253
252254 useIndexedDB: ->
253255 try
254− !app.isSingleDoc() and !!window.indexedDB
256+ if !app.isSingleDoc() and window.indexedDB
257+ true
258+ else
259+ @reason = 'not_supported'
260+ false
255261 catch
256262 false
257263
assets/javascripts/templates/error_tmpl.coffee+13−4
@@ -22,10 +22,19 @@ app.templates.bootError = -> · 21 unmodified lines
2222 """ Check your Internet connection and try <a href="javascript:location.reload()">reloading</a>.<br>
2323 If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """
2424
25−app.templates.offlineError = ->
26− error """ Oops, the database failed to load. """,
27− """ DevDocs requires IndexedDB to cache documentations for offline access.<br>
28− Unfortunately IndexedDB is either not supported in your browser, disabled, or buggy. """
25+app.templates.offlineError = (reason) ->
26+ reason = switch reason
27+ when 'not_supported'
28+ """ Unfortunately your browser either doesn't support it or does not make it available. """
29+ when 'cant_open'
30+ """ Although your browser appears to support it, DevDocs couldn't open the database.<br>
31+ This could be because you're browsing in private mode and have disallowed offline storage on the domain. """
32+ when 'apple'
33+ """ Unfortunately Safari's implementation of IndexedDB is <a href="https://bugs.webkit.org/show_bug.cgi?id=136937">badly broken</a>.<br>
34+ This message will automatically go away when Apple fix their code. """
35+
36+ error """ Oops, offline mode is unavailable. """,
37+ """ DevDocs requires IndexedDB to cache documentations for offline access.<br>#{reason} """
2938
3039 app.templates.unsupportedBrowser = """
3140 <div class="_fail">
assets/javascripts/views/content/offline_page.coffee+1−1
@@ -14,7 +14,7 @@ class app.views.OfflinePage extends app.View · 13 unmodified lines
1414 app.docs.getInstallStatuses (statuses) =>
1515 return unless @activated
1616 if statuses is false
17− @html @tmpl('offlineError')
17+ @html @tmpl('offlineError', app.db.reason)
1818 else
1919 html = ''
2020 html += @renderDoc(doc, statuses[doc.slug]) for doc in app.docs.all()
assets/stylesheets/components/_content.scss+2−2
@@ -163,8 +163,8 @@ · 162 unmodified lines
163163 }
164164
165165 ._error-title {
166− margin: -5.5rem 0 .5rem;
167− line-height: 2;
166+ margin: -5.5rem 0 1rem;
167+ line-height: 2rem;
168168 font-size: 1.5rem;
169169 }
170170