PageSourceSearch

https://www.lihus.fr/wp-content/themes/visibilite/assets/js/inc/search-form.js

js lihus.fr collected 2026-10-03 02:47:25 UTC 1,230 bytes, 37 lines download raw bytes

1const searchElement = {
2  form: document.querySelector("#search-forms"),
3  open: document.querySelector("#search-link"),
4  close: document.querySelector("#search-close"),
5};
6
7function toggleSearchForm(e) {
8  e.preventDefault();
9  searchElement.form.classList.toggle("hide");
10  if (!searchElement.form.classList.contains("hide")) {
11    const searchInput = searchElement.form.querySelector("input");
12    const submitButton = searchElement.form.querySelector(
13      "button[type='submit']"
14    );
15    const closeButton = searchElement.form.querySelector("#close-search-form");
16
17    searchInput.focus();
18
19    const focusableElements = [searchInput, submitButton, closeButton];
20
21    focusableElements.forEach((element, index) => {
22      element.addEventListener("keydown", (e) => {
23        if (e.key === "Tab") {
24          e.preventDefault();
25          const nextIndex =
26            (index + (e.shiftKey ? -1 : 1)) % focusableElements.length;
27          focusableElements[
28            (nextIndex + focusableElements.length) % focusableElements.length
29          ].focus();
30        }
31      });
32    });
33  }
34}
35
36searchElement.open.addEventListener("click", toggleSearchForm);
37searchElement.close.addEventListener("click", toggleSearchForm);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.