Applied seconds input settings patch

pull/1573/head
Shashank Jain 4 years ago
parent 98fa6a9e5e
commit a2a1733fcc

@ -14,6 +14,7 @@ class app.Settings
'tips' 'tips'
'autoInstall' 'autoInstall'
'spaceScroll' 'spaceScroll'
'spaceTimeout'
] ]
INTERNAL_KEYS = [ INTERNAL_KEYS = [
@ -35,6 +36,7 @@ class app.Settings
analyticsConsent: false analyticsConsent: false
theme: 'auto' theme: 'auto'
spaceScroll: 1 spaceScroll: 1
spaceTimeout: 0.5
constructor: -> constructor: ->
@store = new CookiesStore @store = new CookiesStore

@ -25,6 +25,9 @@ class app.Shortcuts
app.showTip('KeyNav') app.showTip('KeyNav')
@showTip = null @showTip = null
spaceTimeout: ->
app.settings.get('spaceTimeout')
onKeydown: (event) => onKeydown: (event) =>
return if @buggyEvent(event) return if @buggyEvent(event)
result = if event.ctrlKey or event.metaKey result = if event.ctrlKey or event.metaKey
@ -62,7 +65,7 @@ class app.Shortcuts
@trigger 'escape' @trigger 'escape'
false false
when 32 when 32
if event.target.type is 'search' and @spaceScroll() and (not @lastKeypress or @lastKeypress < Date.now() - 500) if event.target.type is 'search' and @spaceScroll() and (not @lastKeypress or @lastKeypress < Date.now() - (@spaceTimeout() * 1000))
@trigger 'pageDown' @trigger 'pageDown'
false false
when 33 when 33

@ -59,6 +59,10 @@ app.templates.settingsPage = (settings) -> """
<label class="_settings-label"> <label class="_settings-label">
<input type="checkbox" form="settings" name="spaceScroll" value="1"#{if settings.spaceScroll then ' checked' else ''}>Use spacebar to scroll during search <input type="checkbox" form="settings" name="spaceScroll" value="1"#{if settings.spaceScroll then ' checked' else ''}>Use spacebar to scroll during search
</label> </label>
<label class="_settings-label">
<input type="number" form="settings" name="spaceTimeout" min="0" max="5" value="#{settings.spaceTimeout}"> Delay until you can scroll by pressing space
<small>Time in seconds</small>
</label>
</div> </div>
</div> </div>

@ -17,6 +17,7 @@ class app.views.SettingsPage extends app.View
settings.autoInstall = app.settings.get('autoInstall') settings.autoInstall = app.settings.get('autoInstall')
settings.analyticsConsent = app.settings.get('analyticsConsent') settings.analyticsConsent = app.settings.get('analyticsConsent')
settings.spaceScroll = app.settings.get('spaceScroll') settings.spaceScroll = app.settings.get('spaceScroll')
settings.spaceTimeout = app.settings.get('spaceTimeout')
settings.autoSupported = app.settings.autoSupported settings.autoSupported = app.settings.autoSupported
settings[layout] = app.settings.hasLayout(layout) for layout in app.settings.LAYOUTS settings[layout] = app.settings.hasLayout(layout) for layout in app.settings.LAYOUTS
settings settings
@ -45,6 +46,9 @@ class app.views.SettingsPage extends app.View
app.settings.set('spaceScroll', if enable then 1 else 0) app.settings.set('spaceScroll', if enable then 1 else 0)
return return
setScrollTimeout: (value) ->
app.settings.set('spaceTimeout', value)
toggle: (name, enable) -> toggle: (name, enable) ->
app.settings.set(name, enable) app.settings.set(name, enable)
return return
@ -92,6 +96,8 @@ class app.views.SettingsPage extends app.View
@toggleAnalyticsConsent input.checked @toggleAnalyticsConsent input.checked
when 'spaceScroll' when 'spaceScroll'
@toggleSpaceScroll input.checked @toggleSpaceScroll input.checked
when 'spaceTimeout'
@setScrollTimeout input.value
else else
@toggle input.name, input.checked @toggle input.name, input.checked
return return

Loading…
Cancel
Save