| 172 | } |
| 173 | |
| 174 | function bindEvents() { |
| 175 | const $search = Docsify.dom.find('div.search'); |
| 176 | const $input = Docsify.dom.find($search, 'input'); |
| 177 | const $inputWrap = Docsify.dom.find($search, '.input-wrap'); |
| 178 | |
| 179 | let timeId; |
| 180 | |
| 181 | /** |
| 182 | Prevent to Fold sidebar. |
| 183 | |
| 184 | When searching on the mobile end, |
| 185 | the sidebar is collapsed when you click the INPUT box, |
| 186 | making it impossible to search. |
| 187 | */ |
| 188 | Docsify.dom.on( |
| 189 | $search, |
| 190 | 'click', |
| 191 | e => |
| 192 | ['A', 'H2', 'P', 'EM'].indexOf(e.target.tagName) === -1 && |
| 193 | e.stopPropagation() |
| 194 | ); |
| 195 | Docsify.dom.on($input, 'input', e => { |
| 196 | clearTimeout(timeId); |
| 197 | timeId = setTimeout(_ => doSearch(e.target.value.trim()), 100); |
| 198 | }); |
| 199 | Docsify.dom.on($inputWrap, 'click', e => { |
| 200 | // Click input outside |
| 201 | if (e.target.tagName !== 'INPUT') { |
| 202 | $input.value = ''; |
| 203 | doSearch(); |
| 204 | } |
| 205 | }); |
| 206 | } |
| 207 | |
| 208 | function updatePlaceholder(text, path) { |
| 209 | const $input = Docsify.dom.getNode('.search input[type="search"]'); |