diff --git a/assets/javascripts/app/serviceworker.coffee b/assets/javascripts/app/serviceworker.coffee
index 188a7e42..40235566 100644
--- a/assets/javascripts/app/serviceworker.coffee
+++ b/assets/javascripts/app/serviceworker.coffee
@@ -9,8 +9,10 @@ class app.ServiceWorker
@notifyUpdate = true
navigator.serviceWorker.register(app.config.service_worker_path, {scope: '/'})
- .then((registration) => @updateRegistration(registration))
- .catch((error) -> console.error 'Could not register service worker:', error)
+ .then(
+ (registration) => @updateRegistration(registration),
+ (error) -> console.error('Could not register service worker:', error)
+ )
update: ->
return unless @registration
diff --git a/assets/javascripts/app/settings.coffee b/assets/javascripts/app/settings.coffee
index 0540bfb7..af298250 100644
--- a/assets/javascripts/app/settings.coffee
+++ b/assets/javascripts/app/settings.coffee
@@ -20,7 +20,6 @@ class app.Settings
]
LAYOUTS: ['_max-width', '_sidebar-hidden', '_native-scrollbars']
- SIDEBAR_HIDDEN_LAYOUT = '_sidebar-hidden'
@defaults:
count: 0
@@ -112,36 +111,21 @@ class app.Settings
return
initLayout: ->
- @toggleDark(@get('dark'))
+ @toggleDark(@get('dark') is 1)
@toggleLayout(layout, @hasLayout(layout)) for layout in @LAYOUTS
- @addResizerCSS()
+ @initSidebarWidth()
toggleDark: (enable) ->
classList = document.documentElement.classList
- classList[if enable then 'remove' else 'add']('_theme-default')
- classList[if enable then 'add' else 'remove']('_theme-dark')
+ classList.toggle('_theme-default', !enable)
+ classList.toggle('_theme-dark', enable)
toggleLayout: (layout, enable) ->
classList = document.body.classList
- classList[if enable then 'add' else 'remove'](layout) unless layout is SIDEBAR_HIDDEN_LAYOUT
- classList[if $.overlayScrollbarsEnabled() then 'add' else 'remove']('_overlay-scrollbars')
+ classList.toggle(layout, enable) unless layout is '_sidebar-hidden'
+ classList.toggle('_overlay-scrollbars', $.overlayScrollbarsEnabled())
- addResizerCSS: ->
+ initSidebarWidth: ->
size = @get('size')
- size = if size then size + 'px' else '20rem'
-
- css = """
- ._container { margin-left: #{size}; }
- ._header, ._list { width: #{size}; }
- ._list-hover.clone { min-width: #{size}; }
- ._notice, ._path, ._resizer { left: #{size}; }
- """
-
- style = document.createElement('style')
- style.type = 'text/css'
- style.appendChild(document.createTextNode(css))
- style.setAttribute('data-size', size)
- style.setAttribute('data-resizer', '')
-
- document.head.appendChild(style)
+ document.documentElement.style.setProperty('--sidebarWidth', size + 'px') if size
return
diff --git a/assets/javascripts/app/update_checker.coffee b/assets/javascripts/app/update_checker.coffee
index b98c6563..3558d6bc 100644
--- a/assets/javascripts/app/update_checker.coffee
+++ b/assets/javascripts/app/update_checker.coffee
@@ -3,7 +3,7 @@ class app.UpdateChecker
@lastCheck = Date.now()
$.on window, 'focus', @onFocus
- app.serviceWorker.on 'updateready', @onUpdateReady if app.serviceWorker
+ app.serviceWorker?.on 'updateready', @onUpdateReady
setTimeout @checkDocs, 0
diff --git a/assets/javascripts/templates/error_tmpl.coffee b/assets/javascripts/templates/error_tmpl.coffee
index 4b696d40..9cca1f9d 100644
--- a/assets/javascripts/templates/error_tmpl.coffee
+++ b/assets/javascripts/templates/error_tmpl.coffee
@@ -13,7 +13,7 @@ app.templates.notFoundPage = ->
app.templates.pageLoadError = ->
error """ The page failed to load. """,
""" It may be missing from the server (try reloading the app) or you could be offline (try installing the documentation for offline usage when online again).
- If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """,
+ If you're online and you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """,
""" #{back} · Reload
· Retry """
diff --git a/assets/javascripts/templates/pages/offline_tmpl.coffee b/assets/javascripts/templates/pages/offline_tmpl.coffee
index e8b262aa..436cf1ae 100644
--- a/assets/javascripts/templates/pages/offline_tmpl.coffee
+++ b/assets/javascripts/templates/pages/offline_tmpl.coffee
@@ -25,8 +25,8 @@ app.templates.offlinePage = (docs) -> """