| Server IP : 87.98.154.146 / Your IP : 216.73.216.50 Web Server : Apache System : Linux webm004.cluster126.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : ohklomafyi ( 52085) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/ohklomafyi/www/wp-content/themes/oceanwp/assets/src/js/theme/search/ |
Upload File : |
class Search {
#elements;
mobileOverlayInput;
constructor() {
this.#setElements();
this.#start();
this.#setupEventListeners();
}
#setElements = () => {
this.#elements = {
forms: document.querySelectorAll("form.header-searchform"),
};
};
#start = () => {
this.mobileOverlayInput = document.querySelector(
".mobile-search-overlay-input"
);
this.#elements.forms.forEach((form) => {
if (form.querySelector("input")?.value) {
form.classList.add("search-filled");
}
});
if (!!this.mobileOverlayInput?.value) {
this.mobileOverlayInput.closest("form").classList.add("search-filled");
}
};
#setupEventListeners = () => {
this.#elements.forms.forEach((form) => {
form
.querySelector("input")
?.addEventListener("keyup", this.#onInputKeyup);
form.querySelector("input")?.addEventListener("blur", this.#onInputKeyup);
});
this.mobileOverlayInput?.addEventListener("keyup", this.#onInputKeyup);
this.mobileOverlayInput?.addEventListener("blur", this.#onInputKeyup);
};
#onInputKeyup = (event) => {
const input = event.currentTarget;
const form = input.closest("form");
if (input.value) {
form.classList.add("search-filled");
} else {
form.classList.remove("search-filled");
}
};
}
export default Search;