Showing the changes to assets/javascripts (7 of 12 files). Show all
Unified · Split
| @@ -14,3 +14,4 @@ app.config = · 13 unmodified lines | ||
| 14 | 14 | release: <%= Time.now.utc.httpdate.to_json %> |
| 15 | 15 | mathml_stylesheet: '<%= App.cdn_origin %>/mathml.css' |
| 16 | 16 | service_worker_path: '/service-worker.js' |
| 17 | + service_worker_enabled: <%= App.environment == 'production' || !ENV["ENABLE_SERVICE_WORKER"].nil? %> | |
| @@ -2,7 +2,7 @@ class app.ServiceWorker · 1 unmodified line | ||
| 2 | 2 | $.extend @prototype, Events |
| 3 | 3 | |
| 4 | 4 | @isEnabled: -> |
| 5 | − !!navigator.serviceWorker | |
| 5 | + !!navigator.serviceWorker and app.config.service_worker_enabled | |
| 6 | 6 | |
| 7 | 7 | constructor: -> |
| 8 | 8 | @registration = null |
| @@ -5,7 +5,6 @@ class app.Settings · 4 unmodified lines | ||
| 5 | 5 | 'manualUpdate' |
| 6 | 6 | 'fastScroll' |
| 7 | 7 | 'arrowScroll' |
| 8 | − 'bypassCache' | |
| 9 | 8 | 'docs' |
| 10 | 9 | 'dark' |
| 11 | 10 | 'layout' |
| @@ -92,11 +91,6 @@ class app.Settings · 80 unmodified lines | ||
| 92 | 91 | @set 'size', value |
| 93 | 92 | return |
| 94 | 93 | |
| 95 | − setBypassCache: (value) -> | |
| 96 | − @set 'bypassCache', value | |
| 97 | − app.serviceWorker?.updateInBackground() | |
| 98 | − return | |
| 99 | − | |
| 100 | 94 | dump: -> |
| 101 | 95 | @store.dump() |
| 102 | 96 | |
| @@ -44,7 +44,12 @@ canICloseTheTab = -> · 43 unmodified lines | ||
| 44 | 44 | if app.ServiceWorker.isEnabled() |
| 45 | 45 | """ Yes! Even offline, you can open a new tab, go to <a href="//devdocs.io">devdocs.io</a>, and everything will work as if you were online (provided you installed all the documentations you want to use beforehand). """ |
| 46 | 46 | else |
| 47 | − """ No. Service Workers aren't available in your browser (or are disabled), so loading <a href="//devdocs.io">devdocs.io</a> offline won't work.<br> | |
| 47 | + reason = "aren't available in your browser (or are disabled)" | |
| 48 | + | |
| 49 | + if app.config.env != 'production' | |
| 50 | + reason = "are disabled in your development instance of DevDocs (enable them by setting the ENABLE_SERVICE_WORKERS environment variable)" | |
| 51 | + | |
| 52 | + """ No. Service Workers #{reason}, so loading <a href="//devdocs.io">devdocs.io</a> offline won't work.<br> | |
| 48 | 53 | The current tab will continue to function even when you go offline (provided you installed all the documentations beforehand). """ |
| 49 | 54 | |
| 50 | 55 | app.templates.offlineDoc = (doc, status) -> |
| @@ -8,7 +8,7 @@ app.templates.intro = """ · 7 unmodified lines | ||
| 8 | 8 | <p>Thanks for downloading DevDocs. Here are a few things you should know: |
| 9 | 9 | <ol class="_intro-list"> |
| 10 | 10 | <li>Your local version of DevDocs won't self-update. Unless you're modifying the code, |
| 11 | − I recommend using the hosted version at <a href="https://devdocs.io">devdocs.io</a>. | |
| 11 | + we recommend using the hosted version at <a href="https://devdocs.io">devdocs.io</a>. | |
| 12 | 12 | <li>Run <code>thor docs:list</code> to see all available documentations. |
| 13 | 13 | <li>Run <code>thor docs:download <name></code> to download documentations. |
| 14 | 14 | <li>Run <code>thor docs:download --installed</code> to update all downloaded documentations. |
| @@ -15,10 +15,6 @@ app.templates.settingsPage = (settings) -> """ · 14 unmodified lines | ||
| 15 | 15 | <input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar |
| 16 | 16 | <small>Tip: drag the edge of the sidebar to resize it.</small> |
| 17 | 17 | </label> |
| 18 | − <label class="_settings-label"> | |
| 19 | − <input type="checkbox" form="settings" name="bypassCache" value="1"#{if settings.bypassCache then ' checked' else ''}>Bypass Service Worker cache | |
| 20 | − <small>When this is checked, the Service Worker will always fetch the latest version of requested files. Useful when making changes to the DevDocs source code.</small> | |
| 21 | − </label> | |
| 22 | 18 | </div> |
| 23 | 19 | </div> |
| 24 | 20 | |
| @@ -14,7 +14,6 @@ class app.views.SettingsPage extends app.View · 13 unmodified lines | ||
| 14 | 14 | settings.dark = app.settings.get('dark') |
| 15 | 15 | settings.smoothScroll = !app.settings.get('fastScroll') |
| 16 | 16 | settings.arrowScroll = app.settings.get('arrowScroll') |
| 17 | − settings.bypassCache = app.settings.get('bypassCache') | |
| 18 | 17 | settings[layout] = app.settings.hasLayout(layout) for layout in app.settings.LAYOUTS |
| 19 | 18 | settings |
| 20 | 19 | |
| @@ -33,10 +32,6 @@ class app.views.SettingsPage extends app.View · 12 unmodified lines | ||
| 33 | 32 | app.settings.set('fastScroll', !enable) |
| 34 | 33 | return |
| 35 | 34 | |
| 36 | − toggleBypassCache: (enable) -> | |
| 37 | − app.settings.setBypassCache(!!enable) | |
| 38 | − return | |
| 39 | − | |
| 40 | 35 | toggle: (name, enable) -> |
| 41 | 36 | app.settings.set(name, enable) |
| 42 | 37 | return |
| @@ -80,8 +75,6 @@ class app.views.SettingsPage extends app.View · 37 unmodified lines | ||
| 80 | 75 | @toggleSmoothScroll input.checked |
| 81 | 76 | when 'import' |
| 82 | 77 | @import input.files[0], input |
| 83 | − when 'bypassCache' | |
| 84 | − @toggleBypassCache input.checked | |
| 85 | 78 | else |
| 86 | 79 | @toggle input.name, input.checked |
| 87 | 80 | return |