From 3d5ff7d5fa421b98ae114c27a1ffcbfad817c327 Mon Sep 17 00:00:00 2001 From: Shashank Jain Date: Thu, 10 Jun 2021 22:58:03 +0530 Subject: [PATCH 1/5] Changes the timelimit between spacebar and last keypress --- assets/javascripts/app/shortcuts.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/javascripts/app/shortcuts.coffee b/assets/javascripts/app/shortcuts.coffee index fb0c7220..edd3336e 100644 --- a/assets/javascripts/app/shortcuts.coffee +++ b/assets/javascripts/app/shortcuts.coffee @@ -59,7 +59,7 @@ class app.Shortcuts @trigger 'escape' false when 32 - if event.target.type is 'search' and (not @lastKeypress or @lastKeypress < Date.now() - 500) + if event.target.type is 'search' and (not @lastKeypress or @lastKeypress < Date.now() - 3000) @trigger 'pageDown' false when 33 From 7932a457af5090bf9a3e1e5b5812de17ad673901 Mon Sep 17 00:00:00 2001 From: Shashank Jain Date: Mon, 14 Jun 2021 21:15:33 +0530 Subject: [PATCH 2/5] Added a checkbox to enable scroll by space --- assets/javascripts/app/settings.coffee | 2 ++ assets/javascripts/app/shortcuts.coffee | 5 ++++- assets/javascripts/templates/pages/settings_tmpl.coffee | 3 +++ assets/javascripts/views/content/settings_page.coffee | 7 +++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/app/settings.coffee b/assets/javascripts/app/settings.coffee index d3fc93e1..6c51e261 100644 --- a/assets/javascripts/app/settings.coffee +++ b/assets/javascripts/app/settings.coffee @@ -13,6 +13,7 @@ class app.Settings 'size' 'tips' 'autoInstall' + 'spaceScroll' ] INTERNAL_KEYS = [ @@ -33,6 +34,7 @@ class app.Settings schema: 1 analyticsConsent: false theme: 'auto' + spaceScroll: 0 constructor: -> @store = new CookiesStore diff --git a/assets/javascripts/app/shortcuts.coffee b/assets/javascripts/app/shortcuts.coffee index edd3336e..8ee6e7ea 100644 --- a/assets/javascripts/app/shortcuts.coffee +++ b/assets/javascripts/app/shortcuts.coffee @@ -18,6 +18,9 @@ class app.Shortcuts swapArrowKeysBehavior: -> app.settings.get('arrowScroll') + spaceScroll: -> + app.settings.get('spaceScroll') + showTip: -> app.showTip('KeyNav') @showTip = null @@ -59,7 +62,7 @@ class app.Shortcuts @trigger 'escape' false 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' false when 33 diff --git a/assets/javascripts/templates/pages/settings_tmpl.coffee b/assets/javascripts/templates/pages/settings_tmpl.coffee index efc9c5a1..b8c7e904 100644 --- a/assets/javascripts/templates/pages/settings_tmpl.coffee +++ b/assets/javascripts/templates/pages/settings_tmpl.coffee @@ -56,6 +56,9 @@ app.templates.settingsPage = (settings) -> """ Use arrow keys to scroll the main content area With this checked, use shift + to navigate the sidebar. + diff --git a/assets/javascripts/views/content/settings_page.coffee b/assets/javascripts/views/content/settings_page.coffee index 2db7c6bc..020f8b6f 100644 --- a/assets/javascripts/views/content/settings_page.coffee +++ b/assets/javascripts/views/content/settings_page.coffee @@ -16,6 +16,7 @@ class app.views.SettingsPage extends app.View settings.arrowScroll = app.settings.get('arrowScroll') settings.autoInstall = app.settings.get('autoInstall') settings.analyticsConsent = app.settings.get('analyticsConsent') + settings.spaceScroll = app.settings.get('spaceScroll') settings.autoSupported = app.settings.autoSupported settings[layout] = app.settings.hasLayout(layout) for layout in app.settings.LAYOUTS settings @@ -40,6 +41,10 @@ class app.views.SettingsPage extends app.View resetAnalytics() unless enable return + toggleSpaceScroll: (enable) -> + app.settings.set('spaceScroll', if enable then 1 else 0) + return + toggle: (name, enable) -> app.settings.set(name, enable) return @@ -85,6 +90,8 @@ class app.views.SettingsPage extends app.View @import input.files[0], input when 'analyticsConsent' @toggleAnalyticsConsent input.checked + when 'spaceScroll' + @toggleSpaceScroll input.checked else @toggle input.name, input.checked return From 8bdc096075c2ffe5fcbb95e416f48da8e9b42643 Mon Sep 17 00:00:00 2001 From: shashank1207 <73484229+shashank1207@users.noreply.github.com> Date: Tue, 15 Jun 2021 18:42:26 +0530 Subject: [PATCH 3/5] Update assets/javascripts/app/shortcuts.coffee Co-authored-by: Oliver Eyton-Williams --- assets/javascripts/app/shortcuts.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/javascripts/app/shortcuts.coffee b/assets/javascripts/app/shortcuts.coffee index 8ee6e7ea..a79afd32 100644 --- a/assets/javascripts/app/shortcuts.coffee +++ b/assets/javascripts/app/shortcuts.coffee @@ -62,7 +62,7 @@ class app.Shortcuts @trigger 'escape' false when 32 - if event.target.type is 'search' and @spaceScroll() and (not @lastKeypress or @lastKeypress < Date.now() - 1000) + if event.target.type is 'search' and @spaceScroll() and (not @lastKeypress or @lastKeypress < Date.now() - 500) @trigger 'pageDown' false when 33 From 98fa6a9e5e7422a6c33b24ac17a2c2b8704ca7f2 Mon Sep 17 00:00:00 2001 From: shashank1207 <73484229+shashank1207@users.noreply.github.com> Date: Thu, 17 Jun 2021 21:06:05 +0530 Subject: [PATCH 4/5] changed defaults --- assets/javascripts/app/settings.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/javascripts/app/settings.coffee b/assets/javascripts/app/settings.coffee index 6c51e261..6ead5ba6 100644 --- a/assets/javascripts/app/settings.coffee +++ b/assets/javascripts/app/settings.coffee @@ -34,7 +34,7 @@ class app.Settings schema: 1 analyticsConsent: false theme: 'auto' - spaceScroll: 0 + spaceScroll: 1 constructor: -> @store = new CookiesStore From a2a1733fcc3f2a9869ff3d1b827185ec3ebeca55 Mon Sep 17 00:00:00 2001 From: Shashank Jain Date: Fri, 18 Jun 2021 17:13:58 +0530 Subject: [PATCH 5/5] Applied seconds input settings patch --- assets/javascripts/app/settings.coffee | 2 ++ assets/javascripts/app/shortcuts.coffee | 7 +++++-- assets/javascripts/templates/pages/settings_tmpl.coffee | 4 ++++ assets/javascripts/views/content/settings_page.coffee | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/app/settings.coffee b/assets/javascripts/app/settings.coffee index 6ead5ba6..b885fd5e 100644 --- a/assets/javascripts/app/settings.coffee +++ b/assets/javascripts/app/settings.coffee @@ -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 diff --git a/assets/javascripts/app/shortcuts.coffee b/assets/javascripts/app/shortcuts.coffee index a79afd32..28ddf0b8 100644 --- a/assets/javascripts/app/shortcuts.coffee +++ b/assets/javascripts/app/shortcuts.coffee @@ -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 diff --git a/assets/javascripts/templates/pages/settings_tmpl.coffee b/assets/javascripts/templates/pages/settings_tmpl.coffee index b8c7e904..1428c0c2 100644 --- a/assets/javascripts/templates/pages/settings_tmpl.coffee +++ b/assets/javascripts/templates/pages/settings_tmpl.coffee @@ -59,6 +59,10 @@ app.templates.settingsPage = (settings) -> """ + diff --git a/assets/javascripts/views/content/settings_page.coffee b/assets/javascripts/views/content/settings_page.coffee index 020f8b6f..f0adebf7 100644 --- a/assets/javascripts/views/content/settings_page.coffee +++ b/assets/javascripts/views/content/settings_page.coffee @@ -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