MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / toggleSearch

Function toggleSearch

src/handlers/quickTools.js:340–405  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

338}
339
340function toggleSearch() {
341 const $footer = quickTools.$footer;
342 const $searchRow1 = quickTools.$searchRow1;
343 const $searchRow2 = quickTools.$searchRow2;
344 const $searchInput = quickTools.$searchInput.el;
345 const $toggler = quickTools.$toggler;
346 const { editor } = editorManager;
347 const selectedText = getSelectedText(editor);
348
349 if (!$footer.contains($searchRow1)) {
350 const { className } = quickTools.$toggler;
351 const $content = [...$footer.children];
352 const footerHeight = getFooterHeight();
353 activeSearchState = { className, content: $content, footerHeight };
354
355 $toggler.className = "floating icon clearclose";
356 $footer.content = [$searchRow1, $searchRow2];
357 setRefValue($searchInput, selectedText || "");
358
359 $searchInput.oninput = function () {
360 find(0, false);
361 };
362
363 $searchInput.onsearch = function () {
364 if (this.value) {
365 searchHistory.addToHistory(this.value);
366 find(1, false);
367 } else {
368 find(0, false);
369 }
370 };
371
372 // Setup history navigation for search inputs
373 setupHistoryNavigation();
374
375 setFooterHeight(2);
376 find(0, false);
377
378 actionStack.push({
379 id: "search-bar",
380 action: () => {
381 const restoreState = activeSearchState || {
382 className,
383 content: $content,
384 footerHeight,
385 };
386 removeSearch();
387 $footer.content = restoreState.content;
388 $toggler.className = restoreState.className;
389 setFooterHeight(restoreState.footerHeight);
390 activeSearchState = null;
391 },
392 });
393 } else {
394 const inputValue = getRefValue($searchInput);
395 if (inputValue !== selectedText) {
396 setRefValue($searchInput, selectedText || "");
397 find(0, false);

Callers 1

actionsFunction · 0.85

Calls 11

getSelectedTextFunction · 0.85
getFooterHeightFunction · 0.85
setRefValueFunction · 0.85
setupHistoryNavigationFunction · 0.85
setFooterHeightFunction · 0.85
removeSearchFunction · 0.85
getRefValueFunction · 0.85
addToHistoryMethod · 0.80
focusMethod · 0.80
findFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected