Skip to content

Expandasearch #3433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions phpmyfaq/assets/src/search/expandasearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

export const handleExpandaSearch = (): void => {
console.log("expandasearch");

let s: HTMLElement | null = document.getElementById('expandaSearch');
let n: HTMLElement | null = document.querySelector('#pmf-top-navbar ul');
let c: HTMLElement | null = document.querySelector('.searchContainer .bi-close');
Expand All @@ -29,9 +29,11 @@ export const handleExpandaSearch = (): void => {
if (s && s.querySelector('button')) s.querySelector('button').disabled = false;
if (s && s.querySelector('input')) s.querySelector('input').focus();
document.querySelector('div.searchContainer')!.style.width = "90%";
redoTimeout();
}

function hideSearch(e?: MouseEvent): void {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better naming would be awesome, so please use event instead of just an e

if (document.querySelector('ul.autocomplete')) return;
if (s && s.querySelector('button') && s.querySelector('button').disabled) return;
if (e) e.stopPropagation();
if (s) s.classList.add('searchClosed');
Expand All @@ -48,6 +50,11 @@ export const handleExpandaSearch = (): void => {

if (s) s.addEventListener('click', showSearch);
if (c) c.addEventListener('click', hideSearch);
if (s) s.addEventListener('click', showSearch);
function redoTimeout() {
clearTimeout(t);
t = setTimeout(hideSearch, 3000);
}

document.querySelector('.search input').addEventListener("keyup", redoTimeout);
document.addEventListener('keydown', checkEsc);
};