mirror of
1
Fork 0

[frogend/bugfix] fix dynamicSpoiler elements (#1771)

This commit is contained in:
f0x52 2023-05-12 13:50:37 +02:00 committed by GitHub
parent b315aa10c8
commit 66df974143
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 19 deletions

View File

@ -104,31 +104,29 @@ function dynamicSpoiler(className, updateFunc) {
}
dynamicSpoiler("text-spoiler", (spoiler) => {
const button = spoiler.querySelector("button");
const button = spoiler.querySelector(".button");
if (button != undefined) {
return () => {
button.textContent = spoiler.open
? "Show less"
: "Show more";
};
}
return () => {
button.textContent = spoiler.open
? "Show less"
: "Show more";
};
});
dynamicSpoiler("video-spoiler", (spoiler) => {
const video = spoiler.querySelector(".plyr-video");
dynamicSpoiler("media-spoiler", (spoiler) => {
const eye = spoiler.querySelector(".eye.button");
const video = spoiler.querySelector(".plyr-video");
if (video != undefined) {
return () => {
if (spoiler.open) {
eye.setAttribute("aria-label", "Hide media");
} else {
eye.setAttribute("aria-label", "Show media");
return () => {
if (spoiler.open) {
eye.setAttribute("aria-label", "Hide media");
} else {
eye.setAttribute("aria-label", "Show media");
if (video) {
video.pause();
}
};
}
}
};
});
Array.from(document.getElementsByClassName("plyr-video")).forEach((video) => {

View File

@ -55,7 +55,7 @@
{{range $index, $media := .}}
{{with $media}}
<div class="media-wrapper">
<details class="{{.Type}}-spoiler" {{if not $.Sensitive}}open{{end}}>
<details class="{{.Type}}-spoiler media-spoiler" {{if not $.Sensitive}}open{{end}}>
<summary>
<div class="show sensitive button" aria-hidden="true">
Show sensitive media