open filters on load if not empty or 'all'
This commit is contained in:
parent
e19bbe554e
commit
5d5e3bacbb
2 changed files with 5 additions and 4 deletions
|
@ -44,7 +44,7 @@ make' (GalleryInfo {title, prefix, filters, hidden}) infos = [b|@0
|
|||
</header>
|
||||
|
||||
<nav id=filters>
|
||||
<details>
|
||||
<details id=filters-details>
|
||||
<summary><h2>filters</h2></summary>
|
||||
<div>
|
||||
<h3>show only</h3>
|
||||
|
|
|
@ -86,7 +86,7 @@ function makeFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
function useFragment() {
|
||||
function useFragment(firstLoad) {
|
||||
let frag = document.location.hash.replace(/^#/, '');
|
||||
|
||||
if (frag == 'all') {
|
||||
|
@ -94,6 +94,7 @@ function useFragment() {
|
|||
} else if (frag) {
|
||||
let set = new Set(frag.split(';'));
|
||||
allBoxes.forEach(b => b.checked = set.has(b.id));
|
||||
if (firstLoad) document.getElementById('filters-details').open = true;
|
||||
} else {
|
||||
resetForm();
|
||||
}
|
||||
|
@ -108,8 +109,8 @@ function setup() {
|
|||
document.getElementById('clear').addEventListener('click', clear);
|
||||
document.getElementById('reset').addEventListener('click', reset);
|
||||
|
||||
window.addEventListener('popstate', useFragment);
|
||||
useFragment();
|
||||
window.addEventListener('popstate', () => useFragment(false));
|
||||
useFragment(true);
|
||||
}
|
||||
|
||||
window.addEventListener('load', setup);
|
||||
|
|
Loading…
Reference in a new issue