Showing the changes to assets/javascripts (4 of 4 files). Show all
Unified · Split
| @@ -14,6 +14,7 @@ class app.Settings · 13 unmodified lines | |||
| 14 | 'tips' | 14 | 'tips' |
| 15 | 'autoInstall' | 15 | 'autoInstall' |
| 16 | 'spaceScroll' | 16 | 'spaceScroll' |
| 17 | 'spaceTimeout' | ||
| 17 | ] | 18 | ] |
| 18 | 19 | ||
| 19 | INTERNAL_KEYS = [ | 20 | INTERNAL_KEYS = [ |
| @@ -35,6 +36,7 @@ class app.Settings · 15 unmodified lines | |||
| 35 | analyticsConsent: false | 36 | analyticsConsent: false |
| 36 | theme: 'auto' | 37 | theme: 'auto' |
| 37 | spaceScroll: 1 | 38 | spaceScroll: 1 |
| 39 | spaceTimeout: 0.5 | ||
| 38 | 40 | ||
| 39 | constructor: -> | 41 | constructor: -> |
| 40 | @store = new CookiesStore | 42 | @store = new CookiesStore |
| @@ -20,11 +20,14 @@ class app.Shortcuts · 19 unmodified lines | |||
| 20 | 20 | ||
| 21 | spaceScroll: -> | 21 | spaceScroll: -> |
| 22 | app.settings.get('spaceScroll') | 22 | app.settings.get('spaceScroll') |
| 23 | 23 | ||
| 24 | showTip: -> | 24 | showTip: -> |
| 25 | app.showTip('KeyNav') | 25 | app.showTip('KeyNav') |
| 26 | @showTip = null | 26 | @showTip = null |
| 27 | 27 | ||
| 28 | spaceTimeout: -> | ||
| 29 | app.settings.get('spaceTimeout') | ||
| 30 | |||
| 28 | onKeydown: (event) => | 31 | onKeydown: (event) => |
| 29 | return if @buggyEvent(event) | 32 | return if @buggyEvent(event) |
| 30 | result = if event.ctrlKey or event.metaKey | 33 | result = if event.ctrlKey or event.metaKey |
| @@ -62,7 +65,7 @@ class app.Shortcuts · 31 unmodified lines | |||
| 62 | @trigger 'escape' | 65 | @trigger 'escape' |
| 63 | false | 66 | false |
| 64 | when 32 | 67 | when 32 |
| 65 | if event.target.type is 'search' and @spaceScroll() and (not @lastKeypress or @lastKeypress < Date.now() - 500) | 68 | if event.target.type is 'search' and @spaceScroll() and (not @lastKeypress or @lastKeypress < Date.now() - (@spaceTimeout() * 1000)) |
| 66 | @trigger 'pageDown' | 69 | @trigger 'pageDown' |
| 67 | false | 70 | false |
| 68 | when 33 | 71 | when 33 |
| @@ -59,6 +59,10 @@ app.templates.settingsPage = (settings) -> """ · 58 unmodified lines | |||
| 59 | <label class="_settings-label"> | 59 | <label class="_settings-label"> |
| 60 | <input type="checkbox" form="settings" name="spaceScroll" value="1"#{if settings.spaceScroll then ' checked' else ''}>Use spacebar to scroll during search | 60 | <input type="checkbox" form="settings" name="spaceScroll" value="1"#{if settings.spaceScroll then ' checked' else ''}>Use spacebar to scroll during search |
| 61 | </label> | 61 | </label> |
| 62 | <label class="_settings-label"> | ||
| 63 | <input type="number" form="settings" name="spaceTimeout" min="0" max="5" value="#{settings.spaceTimeout}"> Delay until you can scroll by pressing space | ||
| 64 | <small>Time in seconds</small> | ||
| 65 | </label> | ||
| 62 | </div> | 66 | </div> |
| 63 | </div> | 67 | </div> |
| 64 | 68 | ||
| @@ -17,6 +17,7 @@ class app.views.SettingsPage extends app.View · 16 unmodified lines | |||
| 17 | settings.autoInstall = app.settings.get('autoInstall') | 17 | settings.autoInstall = app.settings.get('autoInstall') |
| 18 | settings.analyticsConsent = app.settings.get('analyticsConsent') | 18 | settings.analyticsConsent = app.settings.get('analyticsConsent') |
| 19 | settings.spaceScroll = app.settings.get('spaceScroll') | 19 | settings.spaceScroll = app.settings.get('spaceScroll') |
| 20 | settings.spaceTimeout = app.settings.get('spaceTimeout') | ||
| 20 | settings.autoSupported = app.settings.autoSupported | 21 | settings.autoSupported = app.settings.autoSupported |
| 21 | settings[layout] = app.settings.hasLayout(layout) for layout in app.settings.LAYOUTS | 22 | settings[layout] = app.settings.hasLayout(layout) for layout in app.settings.LAYOUTS |
| 22 | settings | 23 | settings |
| @@ -45,6 +46,9 @@ class app.views.SettingsPage extends app.View · 22 unmodified lines | |||
| 45 | app.settings.set('spaceScroll', if enable then 1 else 0) | 46 | app.settings.set('spaceScroll', if enable then 1 else 0) |
| 46 | return | 47 | return |
| 47 | 48 | ||
| 49 | setScrollTimeout: (value) -> | ||
| 50 | app.settings.set('spaceTimeout', value) | ||
| 51 | |||
| 48 | toggle: (name, enable) -> | 52 | toggle: (name, enable) -> |
| 49 | app.settings.set(name, enable) | 53 | app.settings.set(name, enable) |
| 50 | return | 54 | return |
| @@ -92,6 +96,8 @@ class app.views.SettingsPage extends app.View · 41 unmodified lines | |||
| 92 | @toggleAnalyticsConsent input.checked | 96 | @toggleAnalyticsConsent input.checked |
| 93 | when 'spaceScroll' | 97 | when 'spaceScroll' |
| 94 | @toggleSpaceScroll input.checked | 98 | @toggleSpaceScroll input.checked |
| 99 | when 'spaceTimeout' | ||
| 100 | @setScrollTimeout input.value | ||
| 95 | else | 101 | else |
| 96 | @toggle input.name, input.checked | 102 | @toggle input.name, input.checked |
| 97 | return | 103 | return |