|
11 | 11 | </button> |
12 | 12 | </div> |
13 | 13 | <div class="d-search-result"> |
14 | | - <div id="hits"></div> |
| 14 | + <div class="hit-container"> |
| 15 | + <div class="loading" style="display: none;"> |
| 16 | + <div class="lds-ring"><div></div><div></div><div></div><div></div></div> |
| 17 | + </div> |
| 18 | + <div id="hits"></div> |
| 19 | + </div> |
15 | 20 | <div class="allResults"><a href="javascript:;" class="orangeLink">See all results ></a></div> |
16 | 21 | </div> |
17 | 22 | </div> |
|
20 | 25 | var product = getCurrentUrlProductName(document.URL) |
21 | 26 | var lang = getCurrentUrlLang(document.URL, true) |
22 | 27 | var isNeedFilter = "{{site.searchNeedFilter}}" |
| 28 | + var isUserInput = true |
23 | 29 |
|
24 | 30 | const mySearch = instantsearch({ |
25 | 31 | indexName: '{{site.searchIndexName}}', |
|
116 | 122 | ]); |
117 | 123 | } |
118 | 124 |
|
| 125 | + mySearch.on('render', function() { |
| 126 | + if (mySearch.status === 'loading' || mySearch.status === 'stalled') { |
| 127 | + $(".hit-container .loading").show() |
| 128 | + } else { |
| 129 | + $(".hit-container .loading").hide() |
| 130 | + } |
| 131 | + }); |
| 132 | + |
119 | 133 | mySearch.start(); |
120 | 134 |
|
121 | 135 | $('#searchbox').on("keyup", function () { |
| 136 | + if (e.key== undefined && e.keyCode == undefined && e.code == undefined) { |
| 137 | + isUserInput = false |
| 138 | + } else { |
| 139 | + isUserInput = true |
| 140 | + } |
122 | 141 | let value = $(this).val() |
123 | 142 | if (value && value != "") { |
124 | 143 | $(".ais-SearchBox-reset").show() |
|
128 | 147 | }) |
129 | 148 |
|
130 | 149 | $('#searchbox').keydown(function (e) { |
| 150 | + if (e.key== undefined && e.keyCode == undefined && e.code == undefined) { |
| 151 | + isUserInput = false |
| 152 | + return |
| 153 | + } |
131 | 154 | if (e.keyCode == 13) { |
132 | 155 | let value = $(this).val() |
133 | 156 | if (value && value != "") { |
|
139 | 162 | } |
140 | 163 | }) |
141 | 164 |
|
| 165 | + $('#searchbox').on("input", function(e) { |
| 166 | + if (!isUserInput) { |
| 167 | + $("#searchbox").trigger($.Event("keydown", { key: "Enter", keyCode: 13, which: 13 })); |
| 168 | + } |
| 169 | + }) |
| 170 | + |
142 | 171 | $(".ais-SearchBox-reset").on("click", function () { |
143 | 172 | $('#searchbox').val("") |
144 | 173 | $(".d-search-result").hide() |
|
0 commit comments