History

Settings: disable autofocus of search input

Fixes #1856.

Simon Legner committed 4 years ago

Commit 7e0dacb1 parent d7155c54 files · +12 −3Browse files

Unified · Split

4 files
  1. assets/javascripts/app/settings.coffee +1 −0
  2. assets/javascripts/templates/pages/settings_tmpl.coffee +3 −0
  3. assets/javascripts/views/content/settings_page.coffee +1 −0
  4. assets/javascripts/views/search/search.coffee +7 −3
assets/javascripts/app/settings.coffee+1−0
@@ -12,6 +12,7 @@ class app.Settings · 11 unmodified lines
12 'layout'12 'layout'
13 'size'13 'size'
14 'tips'14 'tips'
15 'noAutofocus'
15 'autoInstall'16 'autoInstall'
16 'spaceScroll'17 'spaceScroll'
17 'spaceTimeout'18 'spaceTimeout'
assets/javascripts/templates/pages/settings_tmpl.coffee+3−0
@@ -34,6 +34,9 @@ app.templates.settingsPage = (settings) -> """ · 33 unmodified lines
34 <input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar34 <input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar
35 <small>Tip: drag the edge of the sidebar to resize it.</small>35 <small>Tip: drag the edge of the sidebar to resize it.</small>
36 </label>36 </label>
37 <label class="_settings-label _hide-on-mobile">
38 <input type="checkbox" form="settings" name="noAutofocus" value="_no-autofocus"#{if settings.noAutofocus then ' checked' else ''}>Disable autofocus of search input
39 </label>
37 <label class="_settings-label">40 <label class="_settings-label">
38 <input type="checkbox" form="settings" name="autoInstall" value="_auto-install"#{if settings.autoInstall then ' checked' else ''}>Automatically download documentation for offline use41 <input type="checkbox" form="settings" name="autoInstall" value="_auto-install"#{if settings.autoInstall then ' checked' else ''}>Automatically download documentation for offline use
39 <small>Only enable this when bandwidth isn't a concern to you.</small>42 <small>Only enable this when bandwidth isn't a concern to you.</small>
assets/javascripts/views/content/settings_page.coffee+1−0
@@ -14,6 +14,7 @@ class app.views.SettingsPage extends app.View · 13 unmodified lines
14 settings.theme = app.settings.get('theme')14 settings.theme = app.settings.get('theme')
15 settings.smoothScroll = !app.settings.get('fastScroll')15 settings.smoothScroll = !app.settings.get('fastScroll')
16 settings.arrowScroll = app.settings.get('arrowScroll')16 settings.arrowScroll = app.settings.get('arrowScroll')
17 settings.noAutofocus = app.settings.get('noAutofocus')
17 settings.autoInstall = app.settings.get('autoInstall')18 settings.autoInstall = app.settings.get('autoInstall')
18 settings.analyticsConsent = app.settings.get('analyticsConsent')19 settings.analyticsConsent = app.settings.get('analyticsConsent')
19 settings.spaceScroll = app.settings.get('spaceScroll')20 settings.spaceScroll = app.settings.get('spaceScroll')
assets/javascripts/views/search/search.coffee+7−3
@@ -39,12 +39,16 @@ class app.views.Search extends app.View · 38 unmodified lines
39 return39 return
40 40
41 focus: =>41 focus: =>
42 @input.focus() unless document.activeElement is @input42 return if document.activeElement is @input
43 return if app.settings.get('noAutofocus')
44 @input.focus()
43 return45 return
44 46
45 autoFocus: =>47 autoFocus: =>
46 unless app.isMobile() or $.isAndroid() or $.isIOS()48 return if app.isMobile() or $.isAndroid() or $.isIOS()
47 @input.focus() unless document.activeElement?.tagName is 'INPUT'49 return if document.activeElement?.tagName is 'INPUT'
50 return if app.settings.get('noAutofocus')
51 @input.focus()
48 return52 return
49 53
50 onWindowFocus: (event) =>54 onWindowFocus: (event) =>