Added a checkbox to enable scroll by space

pull/1573/head
Shashank Jain 4 years ago
parent 3d5ff7d5fa
commit 7932a457af

@ -13,6 +13,7 @@ class app.Settings
'size' 'size'
'tips' 'tips'
'autoInstall' 'autoInstall'
'spaceScroll'
] ]
INTERNAL_KEYS = [ INTERNAL_KEYS = [
@ -33,6 +34,7 @@ class app.Settings
schema: 1 schema: 1
analyticsConsent: false analyticsConsent: false
theme: 'auto' theme: 'auto'
spaceScroll: 0
constructor: -> constructor: ->
@store = new CookiesStore @store = new CookiesStore

@ -18,6 +18,9 @@ class app.Shortcuts
swapArrowKeysBehavior: -> swapArrowKeysBehavior: ->
app.settings.get('arrowScroll') app.settings.get('arrowScroll')
spaceScroll: ->
app.settings.get('spaceScroll')
showTip: -> showTip: ->
app.showTip('KeyNav') app.showTip('KeyNav')
@showTip = null @showTip = null
@ -59,7 +62,7 @@ class app.Shortcuts
@trigger 'escape' @trigger 'escape'
false false
when 32 when 32
if event.target.type is 'search' and (not @lastKeypress or @lastKeypress < Date.now() - 3000) if event.target.type is 'search' and @spaceScroll() and (not @lastKeypress or @lastKeypress < Date.now() - 1000)
@trigger 'pageDown' @trigger 'pageDown'
false false
when 33 when 33

@ -56,6 +56,9 @@ app.templates.settingsPage = (settings) -> """
<input type="checkbox" form="settings" name="arrowScroll" value="1"#{if settings.arrowScroll then ' checked' else ''}>Use arrow keys to scroll the main content area <input type="checkbox" form="settings" name="arrowScroll" value="1"#{if settings.arrowScroll then ' checked' else ''}>Use arrow keys to scroll the main content area
<small>With this checked, use <code class="_label">shift</code> + <code class="_label">&uarr;</code><code class="_label">&darr;</code><code class="_label">&larr;</code><code class="_label">&rarr;</code> to navigate the sidebar.</small> <small>With this checked, use <code class="_label">shift</code> + <code class="_label">&uarr;</code><code class="_label">&darr;</code><code class="_label">&larr;</code><code class="_label">&rarr;</code> to navigate the sidebar.</small>
</label> </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
</label>
</div> </div>
</div> </div>

@ -16,6 +16,7 @@ class app.views.SettingsPage extends app.View
settings.arrowScroll = app.settings.get('arrowScroll') settings.arrowScroll = app.settings.get('arrowScroll')
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.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
@ -40,6 +41,10 @@ class app.views.SettingsPage extends app.View
resetAnalytics() unless enable resetAnalytics() unless enable
return return
toggleSpaceScroll: (enable) ->
app.settings.set('spaceScroll', if enable then 1 else 0)
return
toggle: (name, enable) -> toggle: (name, enable) ->
app.settings.set(name, enable) app.settings.set(name, enable)
return return
@ -85,6 +90,8 @@ class app.views.SettingsPage extends app.View
@import input.files[0], input @import input.files[0], input
when 'analyticsConsent' when 'analyticsConsent'
@toggleAnalyticsConsent input.checked @toggleAnalyticsConsent input.checked
when 'spaceScroll'
@toggleSpaceScroll input.checked
else else
@toggle input.name, input.checked @toggle input.name, input.checked
return return

Loading…
Cancel
Save