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