Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/data-processing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ jobs:
!data/partners.json
!data/publications.yaml
static/data/
!static/data/open_research_games.json
static/partials/
static/newsletters/
content/contributor-analysis/
Expand Down Expand Up @@ -662,6 +663,11 @@ jobs:
if [ -f /tmp/generated-resources/static/data/fred_citation.txt ]; then
cp /tmp/generated-resources/static/data/fred_citation.txt static/data/fred_citation.txt
fi
# Remove retired stale static games JSON (#1151); the portal now builds from data/open_research_games.json.
git rm -f --ignore-unmatch static/data/open_research_games.json || {
rm -f static/data/open_research_games.json
git add -A -- static/data/open_research_games.json
}
if [ -f /tmp/generated-resources/summaries.json ]; then
cp /tmp/generated-resources/summaries.json data/summaries.json
fi
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ jobs:
# =======================
- name: Build site
run: |
# Drop retired static/data/open_research_games.json if an older data-artifact unpacked it (#1151).
rm -f static/data/open_research_games.json
hugo --gc --minify --cleanDestinationDir --destination public
env:
HUGO_ENV: production
Expand Down
79 changes: 60 additions & 19 deletions assets/js/doors/steering.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,26 @@ document.querySelectorAll('#strategic .sc-title-card').forEach((card) => {
if (area) card.dataset.area = area[1];
});

window.__scManaged = true;
let trigger = null;
const backdrops = [...document.querySelectorAll('.sc-modal-backdrop')];

backdrops.forEach((backdrop) => {
const name = backdrop.querySelector('.sc-modal-name');
backdrop.setAttribute('role', 'dialog');
backdrop.setAttribute('aria-modal', 'true');
if (!backdrop.getAttribute('role')) backdrop.setAttribute('role', 'dialog');
if (!backdrop.getAttribute('aria-modal')) backdrop.setAttribute('aria-modal', 'true');
if (name) {
name.id = name.id || `${backdrop.id}-name`;
backdrop.setAttribute('aria-labelledby', name.id);
if (!backdrop.getAttribute('aria-labelledby')) backdrop.setAttribute('aria-labelledby', name.id);
}
const closeBtn = backdrop.querySelector('.sc-close-btn');
if (closeBtn) {
if (!closeBtn.hasAttribute('type')) closeBtn.setAttribute('type', 'button');
if (!closeBtn.getAttribute('aria-label')) closeBtn.setAttribute('aria-label', 'Close profile');
closeBtn.querySelector('svg')?.setAttribute('aria-hidden', 'true');
}
backdrop.querySelector('.sc-close-btn')?.setAttribute('aria-label', 'Close this profile');
backdrop.querySelectorAll('.sc-social-links a').forEach((link) => {
link.querySelector('svg')?.setAttribute('aria-hidden', 'true');
if (!link.getAttribute('aria-label')) {
const host = new URL(link.href, location.href);
link.setAttribute('aria-label', host.protocol === 'mailto:' ? 'Email' : host.hostname.replace(/^www\./, ''));
Expand All @@ -46,25 +53,52 @@ backdrops.forEach((backdrop) => {
});

document.querySelectorAll('.sc-card[onclick]').forEach((card) => {
const name = card.querySelector('.sc-card-name');
card.setAttribute('role', 'button');
card.tabIndex = 0;
card.setAttribute('aria-label', `Open the profile of ${name ? name.textContent.trim() : 'this person'}`);
card.addEventListener('click', () => { trigger = card; });
card.addEventListener('keydown', (event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
card.click();
const isButton = card.tagName === 'BUTTON';
if (!card.getAttribute('aria-haspopup')) card.setAttribute('aria-haspopup', 'dialog');
if (!isButton) {
const name = card.querySelector('.sc-card-name')?.textContent.trim();
const role = card.querySelector('.sc-card-role')?.textContent.trim();
card.setAttribute('role', 'button');
card.tabIndex = 0;
if (!card.getAttribute('aria-label')) {
const label = name ? (role ? `${name}, ${role}` : name) : 'View profile';
card.setAttribute('aria-label', label);
}
});
card.addEventListener('keydown', (event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
card.click();
}
});
}
card.addEventListener('click', () => { trigger = card; }, true);
});

// Into the dialog when it opens, back to the card when it closes, and Tab stays inside while open.
const closeOpenModal = (open) => {
if (!open) return;
open.classList.remove('active');
document.body.style.overflow = '';
};

// Into the dialog when it opens, back to the card when it closes, and Escape / Tab stay handled while open.
const focusDialog = (open) => {
const closeBtn = open.querySelector('.sc-close-btn');
if (!closeBtn || open.contains(document.activeElement)) return;
closeBtn.focus();
if (document.activeElement !== closeBtn) {
requestAnimationFrame(() => {
if (open.classList.contains('active') && !open.contains(document.activeElement)) closeBtn.focus();
});
}
};

const observer = new MutationObserver(() => {
const open = backdrops.find((backdrop) => backdrop.classList.contains('active'));
if (open) {
// The dialog can't take focus until its fade-in has made it visible.
if (!open.contains(document.activeElement)) setTimeout(() => open.querySelector('.sc-close-btn')?.focus(), 60);
if (!trigger && document.activeElement?.closest?.('.sc-card')) {
trigger = document.activeElement.closest('.sc-card');
}
focusDialog(open);
} else if (trigger) {
trigger.focus();
trigger = null;
Expand All @@ -73,10 +107,17 @@ const observer = new MutationObserver(() => {
backdrops.forEach((backdrop) => observer.observe(backdrop, { attributes: true, attributeFilter: ['class'] }));

document.addEventListener('keydown', (event) => {
if (event.key !== 'Tab') return;
const open = backdrops.find((backdrop) => backdrop.classList.contains('active'));
if (!open) return;
const stops = [...open.querySelectorAll('a[href],button')].filter((el) => el.getClientRects().length);
if (event.key === 'Escape') {
event.preventDefault();
closeOpenModal(open);
return;
}
if (event.key !== 'Tab') return;
const stops = [...open.querySelectorAll('a[href],button:not([disabled]),[tabindex]:not([tabindex="-1"])')]
.filter((el) => el.getClientRects().length);
if (!stops.length) return;
const first = stops[0];
const last = stops[stops.length - 1];
if (!open.contains(document.activeElement)) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/data_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"static/partials", "static/newsletters", "content/contributor-analysis",
"content/publications/citation_chart.webp",
)
EXCLUDED = {"data/partners.json", "data/publications.yaml"}
EXCLUDED = {"data/partners.json", "data/publications.yaml", "static/data/open_research_games.json"}


def git(root, *args):
Expand Down
Loading
Loading