From b5cfd785360ced74970b06c9c1e6436bf7281b72 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 10 Jun 2026 07:18:13 -0300 Subject: client, content, css: group contributions filter notice & clear link --- src/static/css/features.css | 5 +++ src/static/js/client/group-contributions-table.js | 44 +++++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) (limited to 'src/static') diff --git a/src/static/css/features.css b/src/static/css/features.css index f0bd1425..90c297e6 100644 --- a/src/static/css/features.css +++ b/src/static/css/features.css @@ -1301,6 +1301,11 @@ background: var(--primary-color); } } + + .group-contributions-table ~ .filter-notice a { + text-decoration: underline; + text-decoration-style: dotted; + } } /* Image and media containers */ diff --git a/src/static/js/client/group-contributions-table.js b/src/static/js/client/group-contributions-table.js index 3b79f84d..80ee38a1 100644 --- a/src/static/js/client/group-contributions-table.js +++ b/src/static/js/client/group-contributions-table.js @@ -13,6 +13,9 @@ export const info = { chunkDTs: null, chunkDDs: null, chunkGroupDirectories: null, + + filterNotices: null, + filterNoticeClearLinks: null, }; export function getPageReferences() { @@ -38,19 +41,29 @@ export function getPageReferences() { info.chunkDTs = info.lists - .map(list => Array.from(list.querySelectorAll('dt'))); + .map(list => Array.from(list.querySelectorAll('dt'))) + .map(dts => dts + .filter(dt => !dt.classList.contains('filter-notice'))); info.chunkDDs = info.chunkDTs .map(dts => dts .map(dt => dt.nextElementSibling) - .map(el => el.tagName === 'DD' ? el : null)); + .map(el => el?.tagName === 'DD' ? el : null)); info.chunkGroupDirectories = info.chunkDTs .map(dts => dts .map(dt => dt.dataset.groups) .map(string => string ? string.split(' ') : [])); + + info.filterNotices = + info.lists + .map(list => list.querySelector('.filter-notice')); + + info.filterNoticeClearLinks = + info.filterNotices + .map(notice => notice.querySelector('a')); } export function addPageListeners() { @@ -67,6 +80,16 @@ export function addPageListeners() { }); }); }); + + stitchArrays({ + table: info.tables, + clearLink: info.filterNoticeClearLinks, + }).forEach(({table, clearLink}) => { + clearLink.addEventListener('click', domEvent => { + domEvent.preventDefault(); + handleClearLinkClicked(table); + }); + }); } function handleGroupLinkClicked(table, groupLink) { @@ -84,6 +107,16 @@ function handleGroupLinkClicked(table, groupLink) { updateVisibleChunks(table); } +function handleClearLinkClicked(table) { + const i = info.tables.indexOf(table); + + for (const link of info.groupLinks[i]) { + link.classList.remove('selected'); + } + + updateVisibleChunks(table); +} + function updateVisibleChunks(table) { const i = info.tables.indexOf(table); @@ -120,4 +153,11 @@ function updateVisibleChunks(table) { cssProp(chunkDD, 'display', null); } }); + + const filterNotice = info.filterNotices[i]; + if (selectedGroupDirectories.length >= 1) { + cssProp(filterNotice, 'display', null); + } else { + cssProp(filterNotice, 'display', 'none'); + } } -- cgit 1.3.0-6-gf8a5