Feature/#12 search input with hotkey #15

Merged
Serraniel merged 10 commits from feature/#12-search-input-with-hotkey into develop 2020-07-29 14:01:12 +02:00
Showing only changes of commit c311c996e6 - Show all commits

View file

@ -1,4 +1,5 @@
const quickSearchID = 'ea-quickSearch';
const quickSearchLink = 'ea-quickSearchLink';
runAfterLoad(() => {
initSearch();
@ -22,9 +23,10 @@ function initSearch() {
entry.appendChild(quickSearchElement);
// Aniwatch CSS requires the search input to be in some kind of known menu container
let dummyNode = document.createElement('a');
dummyNode.appendChild(quickSearchElement);
entry.appendChild(dummyNode);
let linkElement = document.createElement('a');
linkElement.appendChild(quickSearchElement);
linkElement.id = quickSearchLink;
entry.appendChild(linkElement);
let menu = document.getElementById('materialize-menu-dropdown');
menu.insertAdjacentElement('beforeend', entry);
@ -39,7 +41,9 @@ function handleQuickSearch(event) {
url.pathname = '/search';
url.searchParams.append('q', document.getElementById(quickSearchID).value);
window.location.href = url.href;
let linkElement = document.getElementById(quickSearchLink);
linkElement.href = `${url.pathname}${url.search}`;
linkElement.click();
}
}