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

@ -20,11 +20,14 @@ class app.Shortcuts
spaceScroll: ->
app.settings.get('spaceScroll')
showTip: ->
app.showTip('KeyNav')
@showTip = null
spaceTimeout: ->
app.settings.get('spaceTimeout')
onKeydown: (event) =>
return if @buggyEvent(event)
result = if event.ctrlKey or event.metaKey
@ -62,7 +65,7 @@ class app.Shortcuts
@trigger 'escape'
false
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'
false
when 33

@ -59,6 +59,10 @@ app.templates.settingsPage = (settings) -> """
<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
</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>

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

Loading…
Cancel
Save