[devdocsgjs/main: 421/1867] Add option to automatically download documentation




commit 85f57fe5d03698c37883c9797ca0f9676b049329
Author: Jasper van Merle <jaspervmerle gmail com>
Date:   Sat Oct 6 22:05:15 2018 +0200

    Add option to automatically download documentation

 assets/javascripts/app/app.coffee                       | 5 ++++-
 assets/javascripts/app/settings.coffee                  | 1 +
 assets/javascripts/models/doc.coffee                    | 4 +++-
 assets/javascripts/templates/pages/settings_tmpl.coffee | 4 ++++
 assets/javascripts/views/content/settings_page.coffee   | 1 +
 5 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/assets/javascripts/app/app.coffee b/assets/javascripts/app/app.coffee
index 979ea353..eb92b595 100644
--- a/assets/javascripts/app/app.coffee
+++ b/assets/javascripts/app/app.coffee
@@ -138,7 +138,10 @@
       @docs.sort()
       @initDoc(doc)
       @saveDocs()
-      _onSuccess()
+      if app.settings.get('autoInstall')
+        doc.install(_onSuccess, onError)
+      else
+        _onSuccess()
       return
 
     doc.load onSuccess, onError, writeCache: true
diff --git a/assets/javascripts/app/settings.coffee b/assets/javascripts/app/settings.coffee
index 8d309c41..ab5d128c 100644
--- a/assets/javascripts/app/settings.coffee
+++ b/assets/javascripts/app/settings.coffee
@@ -10,6 +10,7 @@ class app.Settings
     'layout'
     'size'
     'tips'
+    'autoInstall'
   ]
 
   INTERNAL_KEYS = [
diff --git a/assets/javascripts/models/doc.coffee b/assets/javascripts/models/doc.coffee
index 2d5f7e4a..c51e13fa 100644
--- a/assets/javascripts/models/doc.coffee
+++ b/assets/javascripts/models/doc.coffee
@@ -142,4 +142,6 @@ class app.models.Doc extends app.Model
     return
 
   isOutdated: (status) ->
-    status and status.installed and @mtime isnt status.mtime
+    return false if not status
+    isInstalled = status.installed or app.settings.get('autoInstall')
+    isInstalled and @mtime isnt status.mtime
diff --git a/assets/javascripts/templates/pages/settings_tmpl.coffee 
b/assets/javascripts/templates/pages/settings_tmpl.coffee
index 1d439edb..d4108749 100644
--- a/assets/javascripts/templates/pages/settings_tmpl.coffee
+++ b/assets/javascripts/templates/pages/settings_tmpl.coffee
@@ -15,6 +15,10 @@ app.templates.settingsPage = (settings) -> """
         <input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if 
settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar
         <small>Tip: drag the edge of the sidebar to resize it.</small>
       </label>
+      <label class="_settings-label">
+        <input type="checkbox" form="settings" name="autoInstall" value="_auto-install"#{if 
settings.autoInstall then ' checked' else ''}>Automatically download documentation for offline use
+        <small>Only enable this when bandwidth isn't a concern to you.</small>
+      </label>
     </div>
   </div>
 
diff --git a/assets/javascripts/views/content/settings_page.coffee 
b/assets/javascripts/views/content/settings_page.coffee
index d72e3eb3..c0fc59d1 100644
--- a/assets/javascripts/views/content/settings_page.coffee
+++ b/assets/javascripts/views/content/settings_page.coffee
@@ -17,6 +17,7 @@ class app.views.SettingsPage extends app.View
     settings.dark = app.settings.get('dark')
     settings.smoothScroll = !app.settings.get('fastScroll')
     settings.arrowScroll = app.settings.get('arrowScroll')
+    settings.autoInstall = app.settings.get('autoInstall')
     settings[layout] = app.settings.hasLayout(layout) for layout in LAYOUTS
     settings
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]