Fix single documentation search on Android
Unified · Split
| @@ -352,6 +352,10 @@ isIE = null · 351 unmodified lines | |||
| 352 | $.isIE = -> | 352 | $.isIE = -> |
| 353 | isIE ?= navigator.userAgent?.indexOf('MSIE') >= 0 || navigator.userAgent?.indexOf('rv:11.0') >= 0 | 353 | isIE ?= navigator.userAgent?.indexOf('MSIE') >= 0 || navigator.userAgent?.indexOf('rv:11.0') >= 0 |
| 354 | 354 | ||
| 355 | isChromeForAndroid = null | ||
| 356 | $.isChromeForAndroid = -> | ||
| 357 | isChromeForAndroid ?= navigator.userAgent?.indexOf('Android') >= 0 && /Chrome\/([.0-9])+ Mobile/.test(navigator.userAgent) | ||
| 358 | |||
| 355 | isAndroid = null | 359 | isAndroid = null |
| 356 | $.isAndroid = -> | 360 | $.isAndroid = -> |
| 357 | isAndroid ?= navigator.userAgent?.indexOf('Android') >= 0 | 361 | isAndroid ?= navigator.userAgent?.indexOf('Android') >= 0 |
| @@ -8,6 +8,7 @@ class app.views.SearchScope extends app.View · 7 unmodified lines | |||
| 8 | @events: | 8 | @events: |
| 9 | click: 'onClick' | 9 | click: 'onClick' |
| 10 | keydown: 'onKeydown' | 10 | keydown: 'onKeydown' |
| 11 | textInput: 'onTextInput' | ||
| 11 | 12 | ||
| 12 | @routes: | 13 | @routes: |
| 13 | after: 'afterRoute' | 14 | after: 'afterRoute' |
| @@ -88,6 +89,11 @@ class app.views.SearchScope extends app.View · 74 unmodified lines | |||
| 88 | @trigger 'change', null, previousDoc | 89 | @trigger 'change', null, previousDoc |
| 89 | return | 90 | return |
| 90 | 91 | ||
| 92 | doScopeSearch: (event) => | ||
| 93 | @search @input.value[0...@input.selectionStart] | ||
| 94 | $.stopEvent(event) if @doc | ||
| 95 | return | ||
| 96 | |||
| 91 | onClick: (event) => | 97 | onClick: (event) => |
| 92 | if event.target is @tag | 98 | if event.target is @tag |
| 93 | @reset() | 99 | @reset() |
| @@ -99,12 +105,17 @@ class app.views.SearchScope extends app.View · 5 unmodified lines | |||
| 99 | if @doc and @input.selectionEnd is 0 | 105 | if @doc and @input.selectionEnd is 0 |
| 100 | @reset() | 106 | @reset() |
| 101 | $.stopEvent(event) | 107 | $.stopEvent(event) |
| 102 | else if not @doc and @input.value | 108 | else if not @doc and @input.value and not $.isChromeForAndroid() |
| 103 | return if event.ctrlKey or event.metaKey or event.altKey or event.shiftKey | 109 | return if event.ctrlKey or event.metaKey or event.altKey or event.shiftKey |
| 104 | if event.which is 9 or # tab | 110 | if event.which is 9 or # tab |
| 105 | (event.which is 32 and app.isMobile()) # space | 111 | (event.which is 32 and app.isMobile()) # space |
| 106 | @search @input.value[0...@input.selectionStart] | 112 | @doScopeSearch(event) |
| 107 | $.stopEvent(event) if @doc | 113 | return |
| 114 | |||
| 115 | onTextInput: (event) => | ||
| 116 | return unless $.isChromeForAndroid() | ||
| 117 | if not @doc and @input.value and event.data == ' ' | ||
| 118 | @doScopeSearch(event) | ||
| 108 | return | 119 | return |
| 109 | 120 | ||
| 110 | extractHashValue: -> | 121 | extractHashValue: -> |