summaryrefslogtreecommitdiff
path: root/web/source/frontend/index.js
diff options
context:
space:
mode:
authorLibravatar f0x52 <f0x@cthu.lu>2023-05-12 13:50:37 +0200
committerLibravatar GitHub <noreply@github.com>2023-05-12 13:50:37 +0200
commit66df97414329838533172c475ad91edbf36cc96d (patch)
treee2fc193b64bf9abf6b918f62405dc5449307d172 /web/source/frontend/index.js
parent[frogend/chore] remove break-all on profile fields (#1770) (diff)
downloadgotosocial-66df97414329838533172c475ad91edbf36cc96d.tar.xz
[frogend/bugfix] fix dynamicSpoiler elements (#1771)
Diffstat (limited to 'web/source/frontend/index.js')
-rw-r--r--web/source/frontend/index.js34
1 files changed, 16 insertions, 18 deletions
diff --git a/web/source/frontend/index.js b/web/source/frontend/index.js
index 2fa035adb..6fb1d5be7 100644
--- a/web/source/frontend/index.js
+++ b/web/source/frontend/index.js
@@ -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) => {