1
0
Эх сурвалжийг харах

Settings: disable autofocus of search input

Fixes #1856.
Simon Legner 3 жил өмнө
parent
commit
7e0dacb92b

+ 1 - 0
assets/javascripts/app/settings.coffee

@@ -12,6 +12,7 @@ class app.Settings
     'layout'
     'size'
     'tips'
+    'noAutofocus'
     'autoInstall'
     'spaceScroll'
     'spaceTimeout'

+ 3 - 0
assets/javascripts/templates/pages/settings_tmpl.coffee

@@ -34,6 +34,9 @@ app.templates.settingsPage = (settings) -> """
         <input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar
         <small>Tip: drag the edge of the sidebar to resize it.</small>
       </label>
+      <label class="_settings-label _hide-on-mobile">
+        <input type="checkbox" form="settings" name="noAutofocus" value="_no-autofocus"#{if settings.noAutofocus then ' checked' else ''}>Disable autofocus of search input
+      </label>
       <label class="_settings-label">
         <input type="checkbox" form="settings" name="autoInstall" value="_auto-install"#{if settings.autoInstall then ' checked' else ''}>Automatically download documentation for offline use
         <small>Only enable this when bandwidth isn't a concern to you.</small>

+ 1 - 0
assets/javascripts/views/content/settings_page.coffee

@@ -14,6 +14,7 @@ class app.views.SettingsPage extends app.View
     settings.theme = app.settings.get('theme')
     settings.smoothScroll = !app.settings.get('fastScroll')
     settings.arrowScroll = app.settings.get('arrowScroll')
+    settings.noAutofocus = app.settings.get('noAutofocus')
     settings.autoInstall = app.settings.get('autoInstall')
     settings.analyticsConsent = app.settings.get('analyticsConsent')
     settings.spaceScroll = app.settings.get('spaceScroll')

+ 7 - 3
assets/javascripts/views/search/search.coffee

@@ -39,12 +39,16 @@ class app.views.Search extends app.View
     return
 
   focus: =>
-    @input.focus() unless document.activeElement is @input
+    return if document.activeElement is @input
+    return if app.settings.get('noAutofocus')
+    @input.focus() 
     return
 
   autoFocus: =>
-    unless app.isMobile() or $.isAndroid() or $.isIOS()
-      @input.focus() unless document.activeElement?.tagName is 'INPUT'
+    return if app.isMobile() or $.isAndroid() or $.isIOS()
+    return if document.activeElement?.tagName is 'INPUT'
+    return if app.settings.get('noAutofocus')
+    @input.focus()
     return
 
   onWindowFocus: (event) =>