diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-04-23 17:32:22 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-30 20:48:18 -0300 |
commit | a84b339c3a7d6b5a9ccbb950ba16240beb04efb9 (patch) | |
tree | 322ec5c8120d1768cba25c7b4fe8863d22b07b14 /src/static/js | |
parent | bfe389e20902a27f0c2b29eb2abef8fcfe0fc62c (diff) |
client, css: links in summaries, hover dynamics, white underline
Diffstat (limited to 'src/static/js')
-rw-r--r-- | src/static/js/client.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/static/js/client.js b/src/static/js/client.js index fe45ba16..49326663 100644 --- a/src/static/js/client.js +++ b/src/static/js/client.js @@ -1045,6 +1045,54 @@ if ( }); } +// Links nested in summaries ------------------------------ + +const summaryNestedLinksInfo = initInfo('summaryNestedLinksInfo', { + summaries: null, + links: null, +}); + +function getSummaryNestedLinksReferences() { + const info = summaryNestedLinksInfo; + + info.summaries = + Array.from(document.getElementsByTagName('summary')); + + info.links = + info.summaries + .map(summary => + Array.from(summary.getElementsByTagName('a'))); + + filterMultipleArrays( + info.summaries, + info.links, + (_summary, links) => !empty(links)); +} + +function addSummaryNestedLinksPageListeners() { + const info = summaryNestedLinksInfo; + + for (const {summary, links} of stitchArrays({ + summary: info.summaries, + links: info.links, + })) { + for (const link of links) { + link.addEventListener('mouseover', () => { + link.classList.add('nested-hover'); + summary.classList.add('has-nested-hover'); + }); + + link.addEventListener('mouseout', () => { + link.classList.remove('nested-hover'); + summary.classList.remove('has-nested-hover'); + }); + } + } +} + +clientSteps.getPageReferences.push(getSummaryNestedLinksReferences); +clientSteps.getPageReferences.push(addSummaryNestedLinksPageListeners); + // Tooltip-style hover (infrastructure) ------------------- const hoverableTooltipInfo = initInfo('hoverableTooltipInfo', { |