#12 Improved page navigation
This commit is contained in:
parent
5230daaf17
commit
c311c996e6
|
@ -1,4 +1,5 @@
|
||||||
const quickSearchID = 'ea-quickSearch';
|
const quickSearchID = 'ea-quickSearch';
|
||||||
|
const quickSearchLink = 'ea-quickSearchLink';
|
||||||
|
|
||||||
runAfterLoad(() => {
|
runAfterLoad(() => {
|
||||||
initSearch();
|
initSearch();
|
||||||
|
@ -22,9 +23,10 @@ function initSearch() {
|
||||||
entry.appendChild(quickSearchElement);
|
entry.appendChild(quickSearchElement);
|
||||||
|
|
||||||
// Aniwatch CSS requires the search input to be in some kind of known menu container
|
// Aniwatch CSS requires the search input to be in some kind of known menu container
|
||||||
let dummyNode = document.createElement('a');
|
let linkElement = document.createElement('a');
|
||||||
dummyNode.appendChild(quickSearchElement);
|
linkElement.appendChild(quickSearchElement);
|
||||||
entry.appendChild(dummyNode);
|
linkElement.id = quickSearchLink;
|
||||||
|
entry.appendChild(linkElement);
|
||||||
|
|
||||||
let menu = document.getElementById('materialize-menu-dropdown');
|
let menu = document.getElementById('materialize-menu-dropdown');
|
||||||
menu.insertAdjacentElement('beforeend', entry);
|
menu.insertAdjacentElement('beforeend', entry);
|
||||||
|
@ -39,7 +41,9 @@ function handleQuickSearch(event) {
|
||||||
url.pathname = '/search';
|
url.pathname = '/search';
|
||||||
url.searchParams.append('q', document.getElementById(quickSearchID).value);
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue