bloom-player 2.9.4 → 2.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bloomPlayer-Tbc3Emk_.css → bloomPlayer-fhe-RLAT.css} +1 -1
- package/dist/{bloomPlayer.CEAwsYWZ.js → bloomPlayer.y_DYVj0Z.js} +38 -38
- package/dist/bloomplayer.htm +2 -2
- package/package.json +5 -5
- package/src/{dragActivityRuntime.ts → shared/dragActivityRuntime.ts} +41 -28
- package/src/{scrolling.ts → shared/scrolling.ts} +6 -3
- /package/src/{event.ts → shared/event.ts} +0 -0
- /package/src/{narration.ts → shared/narration.ts} +0 -0
package/dist/bloomplayer.htm
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<head>
|
|
8
8
|
<meta charset="UTF-8" />
|
|
9
9
|
<!-- At build time, we replace this with the actual css file -->
|
|
10
|
-
<link rel="stylesheet" href="bloomPlayer-
|
|
10
|
+
<link rel="stylesheet" href="bloomPlayer-fhe-RLAT.css">
|
|
11
11
|
</head>
|
|
12
12
|
|
|
13
13
|
<!-- About the background-color here... the bloomPlayer.js will set the background color
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
<!-- At build time, we replace the target of this script tag to point at the
|
|
20
20
|
the bloom player bundle with the cache-busting hash in its name. -->
|
|
21
|
-
<script src="bloomPlayer.
|
|
21
|
+
<script src="bloomPlayer.y_DYVj0Z.js"></script>
|
|
22
22
|
</body>
|
|
23
23
|
|
|
24
24
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A library for displaying Bloom books in iframes or WebViews",
|
|
4
4
|
"author": "SIL Global",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "2.9.
|
|
6
|
+
"version": "2.9.6",
|
|
7
7
|
"private": false,
|
|
8
8
|
"// sideeffects might need to be ['*.css'] to avoid 'shaking' our CSS, if we ever get tree shaking working": "",
|
|
9
9
|
"sideEffects": false,
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"dist/bloomplayer.htm",
|
|
19
19
|
"dist/*.mp3",
|
|
20
20
|
"lib/*.js",
|
|
21
|
-
"src/event.ts",
|
|
22
|
-
"src/narration.ts",
|
|
23
|
-
"src/dragActivityRuntime.ts",
|
|
24
|
-
"src/scrolling.ts",
|
|
21
|
+
"src/shared/event.ts",
|
|
22
|
+
"src/shared/narration.ts",
|
|
23
|
+
"src/shared/dragActivityRuntime.ts",
|
|
24
|
+
"src/shared/scrolling.ts",
|
|
25
25
|
"dist/*.css",
|
|
26
26
|
"dist/*.tsv"
|
|
27
27
|
],
|
|
@@ -19,6 +19,10 @@ import {
|
|
|
19
19
|
urlPrefix,
|
|
20
20
|
} from "./narration";
|
|
21
21
|
|
|
22
|
+
// Probably not the most logical place to define this constant, but this file needs it,
|
|
23
|
+
// and if we define it here we don't have to share another file with bloom editor.
|
|
24
|
+
export const kLegacyCanvasElementSelector =
|
|
25
|
+
".bloom-textOverPicture, .bloom-canvas-element";
|
|
22
26
|
let targetPositions: {
|
|
23
27
|
x: number;
|
|
24
28
|
y: number;
|
|
@@ -36,7 +40,7 @@ let positionsToRestore: { x: string; y: string; elt: HTMLElement }[] = [];
|
|
|
36
40
|
// Save the current positions of all draggables (when entering Play tab, so we can restore them when leaving).
|
|
37
41
|
const savePositions = (page: HTMLElement) => {
|
|
38
42
|
positionsToRestore = [];
|
|
39
|
-
page.querySelectorAll("[data-
|
|
43
|
+
page.querySelectorAll("[data-draggable-id]").forEach((elt: HTMLElement) => {
|
|
40
44
|
positionsToRestore.push({
|
|
41
45
|
x: elt.style.left,
|
|
42
46
|
y: elt.style.top,
|
|
@@ -61,7 +65,7 @@ export function adjustDraggablesForLanguage(page: HTMLElement) {
|
|
|
61
65
|
if (page.getAttribute("data-activity") !== "drag-letter-to-target") {
|
|
62
66
|
return;
|
|
63
67
|
}
|
|
64
|
-
const draggables = Array.from(page.querySelectorAll("[data-
|
|
68
|
+
const draggables = Array.from(page.querySelectorAll("[data-draggable-id]"));
|
|
65
69
|
draggables.shift(); // The first one is always visible.
|
|
66
70
|
draggables.forEach((draggable: HTMLElement) => {
|
|
67
71
|
const shouldBeVisible = !!(
|
|
@@ -110,6 +114,11 @@ export function prepareActivity(
|
|
|
110
114
|
);
|
|
111
115
|
|
|
112
116
|
// Hide image titles, which might give too much away, or distract.
|
|
117
|
+
Array.from(document.getElementsByClassName("bloom-canvas")).forEach(
|
|
118
|
+
(container) => {
|
|
119
|
+
(container as HTMLElement).title = "";
|
|
120
|
+
},
|
|
121
|
+
);
|
|
113
122
|
Array.from(document.getElementsByClassName("bloom-imageContainer")).forEach(
|
|
114
123
|
(container) => {
|
|
115
124
|
(container as HTMLElement).title = "";
|
|
@@ -126,10 +135,10 @@ export function prepareActivity(
|
|
|
126
135
|
// Add event listeners to draggables to start dragging.
|
|
127
136
|
targetPositions = [];
|
|
128
137
|
originalPositions = new Map<HTMLElement, { x: number; y: number }>();
|
|
129
|
-
const draggables = Array.from(page.querySelectorAll("[data-
|
|
138
|
+
const draggables = Array.from(page.querySelectorAll("[data-draggable-id]"));
|
|
130
139
|
const targets: HTMLElement[] = [];
|
|
131
140
|
draggables.forEach((elt: HTMLElement) => {
|
|
132
|
-
const targetId = elt.getAttribute("data-
|
|
141
|
+
const targetId = elt.getAttribute("data-draggable-id");
|
|
133
142
|
const target = page.querySelector(
|
|
134
143
|
`[data-target-of="${targetId}"]`,
|
|
135
144
|
) as HTMLElement;
|
|
@@ -144,7 +153,7 @@ export function prepareActivity(
|
|
|
144
153
|
});
|
|
145
154
|
targets.push(target);
|
|
146
155
|
}
|
|
147
|
-
// if it has data-
|
|
156
|
+
// if it has data-draggable-id, it should be draggable, just not needed
|
|
148
157
|
// for the right answer.
|
|
149
158
|
originalPositions.set(elt, { x: elt.offsetLeft, y: elt.offsetTop });
|
|
150
159
|
elt.addEventListener("pointerdown", startDrag, { capture: true });
|
|
@@ -155,8 +164,8 @@ export function prepareActivity(
|
|
|
155
164
|
video.addEventListener("pointerdown", playVideo);
|
|
156
165
|
if (
|
|
157
166
|
video
|
|
158
|
-
.closest(
|
|
159
|
-
?.hasAttribute("data-
|
|
167
|
+
.closest(kLegacyCanvasElementSelector)
|
|
168
|
+
?.hasAttribute("data-draggable-id")
|
|
160
169
|
) {
|
|
161
170
|
// don't want to show controls on these, because they are typically too small,
|
|
162
171
|
// and the play time is short enough that just click-to-play is fine
|
|
@@ -169,7 +178,7 @@ export function prepareActivity(
|
|
|
169
178
|
const otherTextItems = Array.from(
|
|
170
179
|
page.getElementsByClassName("bloom-visibility-code-on"),
|
|
171
180
|
).filter((e) => {
|
|
172
|
-
var top = e.closest(
|
|
181
|
+
var top = e.closest(kLegacyCanvasElementSelector) as HTMLElement;
|
|
173
182
|
if (!top) {
|
|
174
183
|
// don't think this can happen with current game templates,
|
|
175
184
|
// but if there's some other text on the page, may as well play when clicked
|
|
@@ -276,7 +285,7 @@ export function undoPrepareActivity(page: HTMLElement) {
|
|
|
276
285
|
},
|
|
277
286
|
);
|
|
278
287
|
|
|
279
|
-
page.querySelectorAll("[data-
|
|
288
|
+
page.querySelectorAll("[data-draggable-id]").forEach((elt: HTMLElement) => {
|
|
280
289
|
elt.removeEventListener("pointerdown", startDrag, { capture: true });
|
|
281
290
|
});
|
|
282
291
|
|
|
@@ -389,28 +398,27 @@ function changePageButtonClicked(e: MouseEvent) {
|
|
|
389
398
|
|
|
390
399
|
export function playInitialElements(page: HTMLElement, playVideos: boolean) {
|
|
391
400
|
const initialFilter = (e) => {
|
|
392
|
-
const
|
|
393
|
-
if (!
|
|
394
|
-
// not
|
|
395
|
-
// video and image overlays.) Maybe not possible in a drag-activity, but just in case
|
|
401
|
+
const ce = e.closest(kLegacyCanvasElementSelector) as HTMLElement;
|
|
402
|
+
if (!ce) {
|
|
403
|
+
// not a canvas element at all. Maybe not possible in a drag-activity, but just in case
|
|
396
404
|
return false;
|
|
397
405
|
}
|
|
398
|
-
if (
|
|
406
|
+
if (ce.classList.contains("draggable-text")) {
|
|
399
407
|
return false; // draggable items are played only when clicked
|
|
400
408
|
}
|
|
401
|
-
if (
|
|
409
|
+
if (ce.hasAttribute("data-draggable-id")) {
|
|
402
410
|
return false; // another indication of a draggable item; in fact, the one above might be obsolete
|
|
403
411
|
}
|
|
404
|
-
if (
|
|
412
|
+
if (ce.classList.contains("drag-item-order-sentence")) {
|
|
405
413
|
return false; // This would give away the answer
|
|
406
414
|
}
|
|
407
|
-
if (
|
|
415
|
+
if (ce.classList.contains("bloom-wordChoice")) {
|
|
408
416
|
return false; // Only one of these should be played, after any instructions
|
|
409
417
|
}
|
|
410
418
|
// This might be redundant since they are not visible, but just in case
|
|
411
419
|
if (
|
|
412
|
-
|
|
413
|
-
|
|
420
|
+
ce.classList.contains("drag-item-correct") ||
|
|
421
|
+
ce.classList.contains("drag-item-wrong")
|
|
414
422
|
) {
|
|
415
423
|
return false; // These are only played after they become visible
|
|
416
424
|
}
|
|
@@ -493,9 +501,9 @@ const showCorrect = (e: MouseEvent) => {
|
|
|
493
501
|
return; // huh?? but makes TS happy
|
|
494
502
|
}
|
|
495
503
|
currentPage
|
|
496
|
-
.querySelectorAll("[data-
|
|
504
|
+
.querySelectorAll("[data-draggable-id]")
|
|
497
505
|
.forEach((elt: HTMLElement) => {
|
|
498
|
-
const targetId = elt.getAttribute("data-
|
|
506
|
+
const targetId = elt.getAttribute("data-draggable-id");
|
|
499
507
|
const target = currentPage?.querySelector(
|
|
500
508
|
`[data-target-of="${targetId}"]`,
|
|
501
509
|
) as HTMLElement;
|
|
@@ -606,7 +614,7 @@ const stopDrag = (e: PointerEvent) => {
|
|
|
606
614
|
// back to its original position.
|
|
607
615
|
// Enhance: animate?
|
|
608
616
|
const page = dragTarget.closest(".bloom-page") as HTMLElement;
|
|
609
|
-
const draggables = Array.from(page.querySelectorAll("[data-
|
|
617
|
+
const draggables = Array.from(page.querySelectorAll("[data-draggable-id]"));
|
|
610
618
|
draggables.forEach((elt: HTMLElement) => {
|
|
611
619
|
if (elt === dragTarget) {
|
|
612
620
|
return;
|
|
@@ -738,9 +746,9 @@ function playSound(someElt: HTMLElement, soundFile: string) {
|
|
|
738
746
|
|
|
739
747
|
function checkDraggables(page: HTMLElement) {
|
|
740
748
|
let allCorrect = true;
|
|
741
|
-
const draggables = Array.from(page.querySelectorAll("[data-
|
|
749
|
+
const draggables = Array.from(page.querySelectorAll("[data-draggable-id]"));
|
|
742
750
|
draggables.forEach((draggableToCheck: HTMLElement) => {
|
|
743
|
-
const targetId = draggableToCheck.getAttribute("data-
|
|
751
|
+
const targetId = draggableToCheck.getAttribute("data-draggable-id");
|
|
744
752
|
const target = page.querySelector(
|
|
745
753
|
`[data-target-of="${targetId}"]`,
|
|
746
754
|
) as HTMLElement;
|
|
@@ -1021,7 +1029,7 @@ function checkRandomSentences(page: HTMLElement) {
|
|
|
1021
1029
|
}
|
|
1022
1030
|
|
|
1023
1031
|
export const doShowAnswersInTargets = (showNow: boolean, page: HTMLElement) => {
|
|
1024
|
-
const draggables = Array.from(page.querySelectorAll("[data-
|
|
1032
|
+
const draggables = Array.from(page.querySelectorAll("[data-draggable-id]"));
|
|
1025
1033
|
if (showNow) {
|
|
1026
1034
|
draggables.forEach((draggable) => {
|
|
1027
1035
|
copyContentToTarget(draggable as HTMLElement);
|
|
@@ -1075,9 +1083,13 @@ export function copyContentToTarget(draggable: HTMLElement) {
|
|
|
1075
1083
|
Array.from(throwAway.querySelectorAll("[tabindex]")).forEach((e) => {
|
|
1076
1084
|
e.removeAttribute("tabindex");
|
|
1077
1085
|
});
|
|
1078
|
-
|
|
1079
|
-
"bloom-
|
|
1086
|
+
let imageContainer = throwAway.getElementsByClassName(
|
|
1087
|
+
"bloom-canvas",
|
|
1080
1088
|
)[0] as HTMLElement;
|
|
1089
|
+
if (!imageContainer)
|
|
1090
|
+
imageContainer = throwAway.getElementsByClassName(
|
|
1091
|
+
"bloom-imageContainer",
|
|
1092
|
+
)[0] as HTMLElement;
|
|
1081
1093
|
if (imageContainer) {
|
|
1082
1094
|
// We need another layer to manage clipping and centering. The one we were going to
|
|
1083
1095
|
// throw away becomes the wrapper, and we add a new throwAway outside it
|
|
@@ -1096,7 +1108,7 @@ export function copyContentToTarget(draggable: HTMLElement) {
|
|
|
1096
1108
|
}
|
|
1097
1109
|
|
|
1098
1110
|
export const getTarget = (draggable: HTMLElement): HTMLElement | undefined => {
|
|
1099
|
-
const targetId = draggable.getAttribute("data-
|
|
1111
|
+
const targetId = draggable.getAttribute("data-draggable-id");
|
|
1100
1112
|
if (!targetId) {
|
|
1101
1113
|
return undefined;
|
|
1102
1114
|
}
|
|
@@ -1179,6 +1191,7 @@ export function setupWordChooserSlider(page: HTMLElement) {
|
|
|
1179
1191
|
// // I'm not finding anything that works that way, and the code below finds a full URL
|
|
1180
1192
|
// sliderImgSrc = img.getAttribute("src")!;
|
|
1181
1193
|
// } else {
|
|
1194
|
+
// WOULD THIS NEED ADJUSTING FOR .bloom-canvas IF THIS CODE WERE RESURRECTED?
|
|
1182
1195
|
// // In bloom-player, for a forgotten and possibly obsolete reason, we use a background image
|
|
1183
1196
|
// // on the container. (I vaguely recall it may be important when animating the main image.)
|
|
1184
1197
|
// const imgContainer = imgTop.getElementsByClassName(
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import $ from "jquery";
|
|
2
2
|
import "jquery.nicescroll";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
IsRunningOnBloomDesktop,
|
|
5
|
+
kLegacyCanvasElementSelector,
|
|
6
|
+
} from "./dragActivityRuntime";
|
|
4
7
|
|
|
5
8
|
export const kSelectorForPotentialNiceScrollElements =
|
|
6
9
|
".bloom-translationGroup:not(.bloom-imageDescription) .bloom-editable.bloom-visibility-code-on, " +
|
|
@@ -20,7 +23,7 @@ export function addScrollbarsToPage(
|
|
|
20
23
|
// on a browser so obsolete that it doesn't have IntersectionObserver (e.g., IE or Safari before 12.2),
|
|
21
24
|
// we just won't get scrolling.
|
|
22
25
|
if ("IntersectionObserver" in window) {
|
|
23
|
-
// Attach overlaid scrollbar to all editables except
|
|
26
|
+
// Attach overlaid scrollbar to all editables except canvas elements (e.g. comics)
|
|
24
27
|
// Expected behavior for comic bubbles: "we want overflow to show, but not generate scroll bars"
|
|
25
28
|
let scrollBlocks: HTMLElement[] = [];
|
|
26
29
|
let countOfObserversExpectedToReport = 0;
|
|
@@ -104,7 +107,7 @@ export function addScrollbarsToPage(
|
|
|
104
107
|
countOfObserversThatHaveReported++;
|
|
105
108
|
ob.unobserve(entry.target); // don't want to keep getting them, or leak observers
|
|
106
109
|
const isBubble = !!entry.target.closest(
|
|
107
|
-
|
|
110
|
+
kLegacyCanvasElementSelector,
|
|
108
111
|
);
|
|
109
112
|
// In bloom desktop preview, we set width to 200% and then scale down by 50%.
|
|
110
113
|
// This can lead to intersection ratios very slightly less than 1, probably due
|
|
File without changes
|
|
File without changes
|