History

Add option to automatically download documentation (#886)

Add option to automatically download documentation

Jasper van Merle committed 7 years ago

Commit 0f9ff402 parents 536003c 8aa8ae15 files · +13 −2Browse files

Unified · Split

5 files
  1. assets/javascripts/app/app.coffee +4 −1
  2. assets/javascripts/app/settings.coffee +1 −0
  3. assets/javascripts/models/doc.coffee +3 −1
  4. assets/javascripts/templates/pages/settings_tmpl.coffee +4 −0
  5. assets/javascripts/views/content/settings_page.coffee +1 −0
assets/javascripts/app/app.coffee+4−1
@@ -140,7 +140,10 @@ · 139 unmodified lines
140140 @docs.sort()
141141 @initDoc(doc)
142142 @saveDocs()
143− _onSuccess()
143+ if app.settings.get('autoInstall')
144+ doc.install(_onSuccess, onError)
145+ else
146+ _onSuccess()
144147 return
145148
146149 doc.load onSuccess, onError, writeCache: true
assets/javascripts/app/settings.coffee+1−0
@@ -11,6 +11,7 @@ class app.Settings · 10 unmodified lines
1111 'layout'
1212 'size'
1313 'tips'
14+ 'autoInstall'
1415 ]
1516
1617 INTERNAL_KEYS = [
assets/javascripts/models/doc.coffee+3−1
@@ -142,4 +142,6 @@ class app.models.Doc extends app.Model · 141 unmodified lines
142142 return
143143
144144 isOutdated: (status) ->
145− status and status.installed and @mtime isnt status.mtime
145+ return false if not status
146+ isInstalled = status.installed or app.settings.get('autoInstall')
147+ isInstalled and @mtime isnt status.mtime
assets/javascripts/templates/pages/settings_tmpl.coffee+4−0
@@ -15,6 +15,10 @@ app.templates.settingsPage = (settings) -> """ · 14 unmodified lines
1515 <input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar
1616 <small>Tip: drag the edge of the sidebar to resize it.</small>
1717 </label>
18+ <label class="_settings-label">
19+ <input type="checkbox" form="settings" name="autoInstall" value="_auto-install"#{if settings.autoInstall then ' checked' else ''}>Automatically download documentation for offline use
20+ <small>Only enable this when bandwidth isn't a concern to you.</small>
21+ </label>
1822 <label class="_settings-label">
1923 <input type="checkbox" form="settings" name="analyticsConsent"#{if settings.analyticsConsent then ' checked' else ''}>Enable tracking cookies
2024 <small>With this checked, we enable Google Analytics and Gauges to collect anonymous traffic information.</small>
assets/javascripts/views/content/settings_page.coffee+1−0
@@ -14,6 +14,7 @@ class app.views.SettingsPage extends app.View · 13 unmodified lines
1414 settings.dark = app.settings.get('dark')
1515 settings.smoothScroll = !app.settings.get('fastScroll')
1616 settings.arrowScroll = app.settings.get('arrowScroll')
17+ settings.autoInstall = app.settings.get('autoInstall')
1718 settings.analyticsConsent = app.settings.get('analyticsConsent')
1819 settings[layout] = app.settings.hasLayout(layout) for layout in app.settings.LAYOUTS
1920 settings