Skip to content

Commit 85f57fe

Browse files
committed
Add option to automatically download documentation
1 parent bec78bf commit 85f57fe

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

assets/javascripts/app/app.coffee

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@
138138
@docs.sort()
139139
@initDoc(doc)
140140
@saveDocs()
141-
_onSuccess()
141+
if app.settings.get('autoInstall')
142+
doc.install(_onSuccess, onError)
143+
else
144+
_onSuccess()
142145
return
143146

144147
doc.load onSuccess, onError, writeCache: true

assets/javascripts/app/settings.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class app.Settings
1010
'layout'
1111
'size'
1212
'tips'
13+
'autoInstall'
1314
]
1415

1516
INTERNAL_KEYS = [

assets/javascripts/models/doc.coffee

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,6 @@ class app.models.Doc extends app.Model
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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ app.templates.settingsPage = (settings) -> """
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
</div>
1923
</div>
2024

assets/javascripts/views/content/settings_page.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class app.views.SettingsPage extends app.View
1717
settings.dark = app.settings.get('dark')
1818
settings.smoothScroll = !app.settings.get('fastScroll')
1919
settings.arrowScroll = app.settings.get('arrowScroll')
20+
settings.autoInstall = app.settings.get('autoInstall')
2021
settings[layout] = app.settings.hasLayout(layout) for layout in LAYOUTS
2122
settings
2223

0 commit comments

Comments
 (0)