Skip to content

Commit

Permalink
fix toggling of chronology facets
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Dec 21, 2024
1 parent f65db93 commit 9446880
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
10 changes: 6 additions & 4 deletions modules/app.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ declare
let $subsubFacets := $coll => ft:facets("chronology", (), ($label,$subLabel))
return
<xhtml:li>
{
if(($label,$subLabel) => string-join() = $activeLabelString)
then attribute class {'active'}
else ()
}
<xhtml:span class="datefacet toggle-toc-item">
{
if (map:size($subsubFacets) gt 0)
Expand All @@ -143,10 +148,7 @@ declare
)
else()
}
<xhtml:span class="label{
if(($label,$subLabel) => string-join() = $activeLabelString)
then ' active'
else ()}" data-value="{($label,$subLabel) => string-join(',')}">{$subLabel}</xhtml:span>
<xhtml:span class="label" data-value="{($label,$subLabel) => string-join(',')}">{$subLabel}</xhtml:span>
<xhtml:span class="count">{$count}</xhtml:span>
</xhtml:span>
{
Expand Down
9 changes: 7 additions & 2 deletions resources/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,17 @@ $('body').on('click touchstart', function (e) {
* hide/reveal sub items of the table of contents of the Guidelines and Wikipedia
*/
$('.toggle-toc-item')
.on('click', toggleTocItems)
.each(toggleTocItems);
.on('click', toggleTocItems) /* toggle on click */
.each(toggleTocItems); /* initially collapse all */
$('.toc a[href~="'+window.location.pathname+window.location.hash+'"]').parentsUntil(".guidelines").addClass("active");
$('.appendix a[href^="'+window.location.pathname+window.location.hash+'"]').parentsUntil(".appendix-div").addClass("active");
$(".toc .active").siblings(".toggle-toc-item").each(toggleTocItems);

/* initially open selected chronology facets */
/* … along the ancestor axis */
$('.datefacets li.active').parentsUntil('.datefacets', 'li').children('.toggle-toc-item').each(toggleTocItems);
/* … and the (direct) child axis */
$('.datefacets li.active').children('.toggle-toc-item').each(toggleTocItems);

/*
* used for Guidelines TOC as well as for Wikipedia
Expand Down
3 changes: 3 additions & 0 deletions resources/sass/layout/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ a.checkbox-only {
align-items: start;
cursor: pointer;
color: $primary;
&:has(.label.active) {
font-weight: 800;
}
.label {
flex: 1;
}
Expand Down

0 comments on commit 9446880

Please sign in to comment.