[devdocsgjs/main: 1728/1867] Applied seconds input settings patch




commit a2a1733fcc3f2a9869ff3d1b827185ec3ebeca55
Author: Shashank Jain <jain362012 gmail com>
Date:   Fri Jun 18 17:13:58 2021 +0530

    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) -> """
       <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>
 
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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]