Release reviewed gh-pages candidate

This commit is contained in:
krahets
2026-11-18 03:53:03 +08:00
parent db62174014
commit 8966617032
825 changed files with 2894 additions and 2395 deletions

View File

@@ -4,38 +4,44 @@
const AUTO_SLIDE_INTERVAL_MS = 1500;
const LABELS = {
"zh": {
"play": "播放幻灯片",
"pause": "暂停幻灯片",
"previous": "上一页",
"next": "下一页"
"play": "播放步骤",
"pause": "暂停播放",
"paused": "已暂停",
"previous": "上一步",
"next": "下一步"
},
"zh-hant": {
"play": "播放投影片",
"pause": "暫停投影片",
"previous": "上一頁",
"next": "下一頁"
"play": "播放步驟",
"pause": "暫停播放",
"paused": "已暫停",
"previous": "上一步",
"next": "下一步"
},
"en": {
"play": "Play slideshow",
"pause": "Pause slideshow",
"paused": "Paused",
"previous": "Previous slide",
"next": "Next slide"
},
"ru": {
"play": "Запустить показ слайдов",
"pause": "Приостановить показ слайдов",
"paused": "Показ приостановлен",
"previous": "Предыдущий слайд",
"next": "Следующий слайд"
},
"ja": {
"play": "スライドショーを再生",
"pause": "スライドショーを一時停止",
"paused": "一時停止しました",
"previous": "前のスライド",
"next": "次のスライド"
},
"ko": {
"play": "슬라이드 재생",
"pause": "슬라이드 일시 정지",
"paused": "일시 정지됨",
"previous": "이전 슬라이드",
"next": "다음 슬라이드"
}
@@ -147,6 +153,13 @@
return { button, srOnly, icon, iconPath };
};
// Linked content tabs issue synthetic clicks in other figures. Only the
// sequence receiving the reader's own interaction may announce that change.
let interactionSet = null;
for (const type of ["click", "keydown"]) document.addEventListener(type, event => {
if (event.isTrusted) interactionSet = event.target.closest?.(".tabbed-set") || null;
}, true);
const initAnimationSet = (tabbedSet) => {
if (initializedSets.has(tabbedSet) || !isAnimationSet(tabbedSet)) {
return;
@@ -176,7 +189,11 @@
});
const pageIndicator = document.createElement("span");
pageIndicator.className = "animation-controls__page";
pageIndicator.setAttribute("aria-live", "polite");
pageIndicator.setAttribute("aria-live", "off");
const announcement = document.createElement("span");
announcement.className = "animation-controls__sr-only";
announcement.setAttribute("aria-live", "polite");
announcement.setAttribute("aria-atomic", "true");
const nextButton = createIconButton({
className: "animation-controls__next",
@@ -185,9 +202,13 @@
});
nav.append(prevButton, pageIndicator, nextButton);
controls.append(playButton, nav);
controls.append(playButton, nav, announcement);
tabbedContent.insertAdjacentElement("afterend", controls);
let announcementTimer = null, announcementOrigin = null;
let announcementCount = 0, announcementJump = false;
const frames = [...tabbedContent.querySelectorAll('ha-svg-figure[data-book-key]')];
const state = {
inputs,
currentIndex: getCheckedIndex(inputs),
@@ -206,8 +227,38 @@
playControl.iconPath.setAttribute("d", state.isPlaying ? FA_PAUSE_PATH : FA_PLAY_PATH);
};
const setText = (node, value) => {
if (node.textContent !== value) node.textContent = value;
};
const updatePageIndicator = () => {
pageIndicator.textContent = `${state.currentIndex + 1} / ${inputs.length}`;
pageIndicator.setAttribute("aria-hidden", state.isPlaying ? "true" : "false");
setText(pageIndicator, `${state.currentIndex + 1} / ${inputs.length}`);
prevButton.setAttribute("aria-disabled", String(state.currentIndex === 0));
nextButton.setAttribute("aria-disabled", String(state.currentIndex === inputs.length - 1));
};
const cancelAnnouncement = () => {
if (announcementTimer !== null) clearTimeout(announcementTimer);
announcementTimer = null; announcementOrigin = null; announcementCount = 0; announcementJump = false;
announcement.textContent = "";
};
const announce = (previous, jump = false) => {
if (announcementTimer !== null) clearTimeout(announcementTimer);
if (announcementOrigin === null) announcementOrigin = previous;
announcementCount++; announcementJump ||= jump;
announcement.textContent = "";
announcementTimer = setTimeout(() => {
const index = state.currentIndex;
const forward = !announcementJump && announcementCount === 1 && index === announcementOrigin + 1;
const moved = index !== announcementOrigin;
announcementTimer = null; announcementOrigin = null; announcementCount = 0; announcementJump = false;
if (!moved) return;
const prefix = /^zh/i.test(document.documentElement.lang)
? `第 ${index + 1} 步,共 ${inputs.length} 步。` : `${index + 1} / ${inputs.length}. `;
const frame = frames[index];
announcement.textContent = prefix + (frame?.dataset[forward ? "a11yForward" : "a11yState"] ||
inputs[index].getAttribute("aria-label") || "");
}, 250);
};
const stop = () => {
@@ -221,19 +272,22 @@
}
state.isPlaying = false;
updatePlayButton();
updatePageIndicator();
};
const syncCurrentIndex = () => {
state.currentIndex = getCheckedIndex(inputs);
};
const moveTo = (index) => {
state.currentIndex = setCheckedIndex(inputs, index);
const moveTo = (index, manual = false) => {
const previous = state.currentIndex;
state.currentIndex = setCheckedIndex(inputs, manual ? Math.max(0, Math.min(inputs.length - 1, index)) : index);
updatePageIndicator();
if (manual && state.currentIndex !== previous) announce(previous);
};
const step = (delta) => {
moveTo(state.currentIndex + delta);
const step = (delta, manual = false) => {
moveTo(state.currentIndex + delta, manual);
};
const start = () => {
@@ -241,7 +295,9 @@
return;
}
state.isPlaying = true;
cancelAnnouncement();
updatePlayButton();
updatePageIndicator();
state.timeoutId = window.setTimeout(() => {
step(1);
state.timeoutId = null;
@@ -254,6 +310,14 @@
playButton.addEventListener("click", () => {
if (state.isPlaying) {
stop();
cancelAnnouncement();
announcementTimer = setTimeout(() => {
announcementTimer = null;
const index = state.currentIndex;
const prefix = /^zh/i.test(document.documentElement.lang)
? `第 ${index + 1} 步,共 ${inputs.length} 步。` : `${index + 1} / ${inputs.length}. `;
announcement.textContent = labels.paused + "。" + prefix + (frames[index]?.dataset.a11yState || "");
}, 250);
return;
}
syncCurrentIndex();
@@ -261,25 +325,37 @@
});
prevButton.addEventListener("click", () => {
stop();
syncCurrentIndex();
step(-1);
step(-1, true);
});
nextButton.addEventListener("click", () => {
stop();
syncCurrentIndex();
step(1);
step(1, true);
});
inputs.forEach((input, index) => {
input.addEventListener("change", () => {
if (input.checked) {
stop();
const previous = state.currentIndex;
state.currentIndex = index;
updatePageIndicator();
if (interactionSet === tabbedSet) {
interactionSet = null;
if (index !== previous) announce(previous, true);
}
}
});
});
controllers.add(stop);
tabbedSet.addEventListener("focusin", event => {
if (state.isPlaying && event.target !== playButton) stop();
});
tabbedSet.addEventListener("figureinteractionpending", stop);
updatePlayButton();
updatePageIndicator();
};
@@ -301,4 +377,4 @@
initAutoSlide();
}
})();
/*! update cache: 20261115224006 */
/*! update cache: 20261117194953 */

View File

@@ -231,4 +231,4 @@ export function createFlowLinks(targets) {
dispose(){mesh.removeFromParent();geometry.dispose();material.dispose();},
};
}
/*! update cache: 20261115224006 */
/*! update cache: 20261117194953 */

File diff suppressed because one or more lines are too long

View File

@@ -15,4 +15,4 @@ window.MathJax = {
document$.subscribe(() => {
MathJax.typesetPromise();
});
/*! update cache: 20261115224006 */
/*! update cache: 20261117194953 */