MCPcopy
hub / github.com/docsifyjs/docsify / bindEvents

Function bindEvents

src/plugins/search/component.js:174–206  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

172}
173
174function 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
208function updatePlaceholder(text, path) {
209 const $input = Docsify.dom.getNode('.search input[type="search"]');

Callers 1

initFunction · 0.85

Calls 1

doSearchFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…