@intentius/behold 0.29.45 → 0.29.46
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/package.json +1 -1
- package/web/app.js +116 -1
- package/web/event-help-modal.js +44 -7
- package/web/float-place.js +85 -0
- package/web/float-place.test.js +117 -0
- package/web/index.html +6 -2
- package/web/kiosk-event-help-ui.js +44 -11
- package/web/kiosk-event-help.js +75 -2
- package/web/kiosk-modal-sticky.test.js +294 -0
- package/web/kiosk-popover.js +6 -22
- package/web/kiosk-watch.js +16 -9
- package/web/kiosk.html +9 -1
- package/web/kiosk.js +27 -4
- package/web/tooltip.js +5 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/behold",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.46",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
|
package/web/app.js
CHANGED
|
@@ -13,6 +13,7 @@ import { createRefreshQueue } from "./refresh-queue.js";
|
|
|
13
13
|
import { readViewQuery, writeViewQuery, settleView, settlePlace, refusalLine } from "./view-url.js";
|
|
14
14
|
import { quietCardLines, readEmbed, selectMessage, viewFromMessage, wheelPx, wheelZoomsBare } from "./embed.js";
|
|
15
15
|
import { WORDS as POP_WORDS, cardRoot as popCardRoot, placePopover, popReduce, popState, resourcePopover, rootPopover } from "./kiosk-popover.js";
|
|
16
|
+
import { shiftInto } from "./float-place.js"; // behold#764
|
|
16
17
|
import { cssString, hoverCss, hoverFromMessage, hoverLinks, hoverMessage, isLightBg, rootPaint, rootText } from "./kiosk-roots.js";
|
|
17
18
|
import { gateCards } from "./workspace-gates.js";
|
|
18
19
|
import { cornerOf, estateLine, hrefOf as tgHref, legend as tgLegend, markLine, rootRows as tgRootRows, waveCards } from "./terragucci.js";
|
|
@@ -4499,6 +4500,95 @@ function tgReadShow(svg) {
|
|
|
4499
4500
|
const hot = new Set(tgReadHot);
|
|
4500
4501
|
for (const el of svg.querySelectorAll("[data-tg-read]")) el.classList.toggle("tg-hot", hot.has(el.getAttribute("data-tg-read")));
|
|
4501
4502
|
for (const g of svg.querySelectorAll("g[data-tg-read-pill].tg-hot")) g.parentNode.appendChild(g);
|
|
4503
|
+
tgPillsKeepIn(svg);
|
|
4504
|
+
}
|
|
4505
|
+
/**
|
|
4506
|
+
* behold#764: a kiosk frame's shown pills stay inside what the frame shows. A pill is placed when the reads are drawn,
|
|
4507
|
+
* against the shot's viewBox then; the camera moves after, and a pointed card lights the pills of readers it has
|
|
4508
|
+
* panned out of view (331px over the frame's top on /tofu-fanout). A pill whose reader is out of view does not show
|
|
4509
|
+
* (tg-off): its leader would point at nothing. One whose reader shows slides in by as little as keeps it inside
|
|
4510
|
+
* (shiftInto), its leader and dot left on the reader's card. Run after each light and each camera move.
|
|
4511
|
+
*/
|
|
4512
|
+
function tgPillsKeepIn(svg) {
|
|
4513
|
+
if (!embedOpts.bare || !svg || !svg.getScreenCTM) return;
|
|
4514
|
+
const ctm = svg.getScreenCTM();
|
|
4515
|
+
const scale = ctm && ctm.a ? ctm.a : 1;
|
|
4516
|
+
const host = document.getElementById("graph");
|
|
4517
|
+
const pane = host ? host.getBoundingClientRect() : { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight };
|
|
4518
|
+
const coveredBelow = kioskShot && kioskShot.insets ? Math.max(0, kioskShot.insets.bottom || 0) : 0;
|
|
4519
|
+
const bottom = Math.min(pane.bottom, window.innerHeight - coveredBelow);
|
|
4520
|
+
const view = { left: Math.max(0, pane.left), top: Math.max(0, pane.top), width: Math.min(window.innerWidth, pane.right) - Math.max(0, pane.left), height: bottom - Math.max(0, pane.top) };
|
|
4521
|
+
for (const g of svg.querySelectorAll("g[data-tg-read-pill]")) {
|
|
4522
|
+
const lead = g.querySelector(":scope > line");
|
|
4523
|
+
const dot = g.querySelector(":scope > circle");
|
|
4524
|
+
const body = g.querySelector(":scope > rect");
|
|
4525
|
+
if (!lead || !dot || !body) continue;
|
|
4526
|
+
// Where the draw put it, kept on the group: each pass starts from there.
|
|
4527
|
+
if (!g.dataset.tgAt) {
|
|
4528
|
+
const m = /translate\(([-\d.e]+)[ ,]+([-\d.e]+)\)/.exec(g.getAttribute("transform") || "");
|
|
4529
|
+
if (!m) continue;
|
|
4530
|
+
g.dataset.tgAt = `${m[1]} ${m[2]} ${lead.getAttribute("x1")} ${lead.getAttribute("y1")} ${lead.getAttribute("x2")} ${lead.getAttribute("y2")}`;
|
|
4531
|
+
}
|
|
4532
|
+
const [cx, cy, lx1, ly1, lx2, ly2] = g.dataset.tgAt.split(" ").map(Number);
|
|
4533
|
+
const set = (x, y) => {
|
|
4534
|
+
g.setAttribute("transform", `translate(${x} ${y})`);
|
|
4535
|
+
const ax = cx + lx1 - x;
|
|
4536
|
+
const ay = cy + ly1 - y;
|
|
4537
|
+
const bx = Number(body.getAttribute("x"));
|
|
4538
|
+
const by = Number(body.getAttribute("y"));
|
|
4539
|
+
const near = tgNearestOn({ x: bx, y: by, x2: bx + Number(body.getAttribute("width")), y2: by + Number(body.getAttribute("height")) }, { x: ax, y: ay });
|
|
4540
|
+
const moved = x !== cx || y !== cy;
|
|
4541
|
+
lead.setAttribute("x1", String(ax));
|
|
4542
|
+
lead.setAttribute("y1", String(ay));
|
|
4543
|
+
lead.setAttribute("x2", String(moved ? near.x : lx2));
|
|
4544
|
+
lead.setAttribute("y2", String(moved ? near.y : ly2));
|
|
4545
|
+
dot.setAttribute("cx", String(ax));
|
|
4546
|
+
dot.setAttribute("cy", String(ay));
|
|
4547
|
+
};
|
|
4548
|
+
set(cx, cy);
|
|
4549
|
+
g.style.display = ""; // measured where it is drawn, then hidden again below if its reader is out of view
|
|
4550
|
+
if (!(view.width > 0 && view.height > 0)) continue;
|
|
4551
|
+
const d = dot.getBoundingClientRect();
|
|
4552
|
+
const dx0 = d.left + d.width / 2;
|
|
4553
|
+
const dy0 = d.top + d.height / 2;
|
|
4554
|
+
const off = dx0 < view.left || dx0 > view.left + view.width || dy0 < view.top || dy0 > view.top + view.height;
|
|
4555
|
+
g.classList.toggle("tg-off", off);
|
|
4556
|
+
// Gone at once, whatever its fade or flash is doing (an opacity rule lost to a running transition on the kiosk).
|
|
4557
|
+
g.style.display = off ? "none" : "";
|
|
4558
|
+
if (off) continue;
|
|
4559
|
+
const r = body.getBoundingClientRect();
|
|
4560
|
+
const { dx, dy } = shiftInto({ left: r.left, top: r.top, width: r.width, height: r.height }, view, 8);
|
|
4561
|
+
if (dx || dy) set(cx + dx / scale, cy + dy / scale);
|
|
4562
|
+
}
|
|
4563
|
+
// behold#748's outside mark, the same way: its box and tag slide in (its ring stays on the card, its leader's
|
|
4564
|
+
// card end too). It was 2px over the frame's top on /choudoufu-fanout at the end of the run.
|
|
4565
|
+
for (const g of svg.querySelectorAll("g[data-tg-outside]")) {
|
|
4566
|
+
const ring = g.firstElementChild;
|
|
4567
|
+
const lead = g.querySelector(":scope > line");
|
|
4568
|
+
const moving = [...g.children].filter((c) => c !== ring && c !== lead && c.localName !== "circle" && c.localName !== "title");
|
|
4569
|
+
if (!moving.length) continue;
|
|
4570
|
+
if (!g.dataset.tgAt) g.dataset.tgAt = lead ? `${lead.getAttribute("x2")} ${lead.getAttribute("y2")}` : "";
|
|
4571
|
+
for (const c of moving) c.removeAttribute("transform");
|
|
4572
|
+
if (lead && g.dataset.tgAt) {
|
|
4573
|
+
const [x2, y2] = g.dataset.tgAt.split(" ");
|
|
4574
|
+
lead.setAttribute("x2", x2);
|
|
4575
|
+
lead.setAttribute("y2", y2);
|
|
4576
|
+
}
|
|
4577
|
+
if (!(view.width > 0 && view.height > 0)) continue;
|
|
4578
|
+
const rs = moving.map((c) => c.getBoundingClientRect()).filter((r) => r.width > 0);
|
|
4579
|
+
if (!rs.length) continue;
|
|
4580
|
+
const left = Math.min(...rs.map((r) => r.left));
|
|
4581
|
+
const top = Math.min(...rs.map((r) => r.top));
|
|
4582
|
+
const box = { left, top, width: Math.max(...rs.map((r) => r.right)) - left, height: Math.max(...rs.map((r) => r.bottom)) - top };
|
|
4583
|
+
const { dx, dy } = shiftInto(box, view, 8);
|
|
4584
|
+
if (!dx && !dy) continue;
|
|
4585
|
+
for (const c of moving) c.setAttribute("transform", `translate(${dx / scale} ${dy / scale})`);
|
|
4586
|
+
if (lead && g.dataset.tgAt) {
|
|
4587
|
+
const [x2, y2] = g.dataset.tgAt.split(" ").map(Number);
|
|
4588
|
+
lead.setAttribute("x2", String(x2 + dx / scale));
|
|
4589
|
+
lead.setAttribute("y2", String(y2 + dy / scale));
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4502
4592
|
}
|
|
4503
4593
|
let tgReadWired = false;
|
|
4504
4594
|
function wireTgReadHover() {
|
|
@@ -4517,6 +4607,7 @@ function ensureTgReadStyle() {
|
|
|
4517
4607
|
st.id = "tg-read-style";
|
|
4518
4608
|
st.textContent = `#graph g[data-tg-read-pill] { opacity: 0; }
|
|
4519
4609
|
#graph g[data-tg-read-pill].tg-hot, #graph g[data-tg-read-pill].tg-shown { opacity: 1 !important; }
|
|
4610
|
+
#graph g[data-tg-read-pill].tg-off { opacity: 0 !important; animation: none; }
|
|
4520
4611
|
#graph g[data-tg-read-pill].tg-hot { transition: opacity .15s ease; }
|
|
4521
4612
|
#graph g[data-tg-read-pill].tg-flash { animation: tg-read-flash 6s linear both; }
|
|
4522
4613
|
#graph line[data-tg-read].tg-hot { stroke-width: 5; filter: drop-shadow(0 0 3px var(--bg)); }
|
|
@@ -5292,6 +5383,7 @@ function kioskPopRender() {
|
|
|
5292
5383
|
const content = !card || !answer ? null : kioskCompMode() ? rootPopover(answer, kioskRootOfComponent(id), resourcesByComponent[id]) : resourcePopover(answer, id);
|
|
5293
5384
|
if (!content) {
|
|
5294
5385
|
if (pop) pop.hidden = true;
|
|
5386
|
+
kioskTellPop(pop);
|
|
5295
5387
|
return;
|
|
5296
5388
|
}
|
|
5297
5389
|
if (!pop) {
|
|
@@ -5352,12 +5444,34 @@ function kioskPopRender() {
|
|
|
5352
5444
|
const touchOnly = typeof matchMedia === "function" && matchMedia("(hover: none)").matches;
|
|
5353
5445
|
add("p", "k-pop-hint", kioskPop.pinned ? (touchOnly ? POP_WORDS.tapPinnedHint : POP_WORDS.pinnedHint) : POP_WORDS.pinHint);
|
|
5354
5446
|
pop.hidden = false;
|
|
5447
|
+
// behold#764: measured at its own height, then capped (its body scrolls) when the frame's view is shorter.
|
|
5448
|
+
pop.style.maxHeight = "";
|
|
5355
5449
|
const cb = card.getBoundingClientRect();
|
|
5356
5450
|
const pb = pop.getBoundingClientRect();
|
|
5357
|
-
|
|
5451
|
+
// The part of the frame that shows: Watch's caption and track cover its bottom (the shot's insets), unless that leaves too little.
|
|
5452
|
+
const coveredBelow = kioskShot && kioskShot.insets ? Math.max(0, kioskShot.insets.bottom || 0) : 0;
|
|
5453
|
+
const height = window.innerHeight - coveredBelow >= 240 ? window.innerHeight - coveredBelow : window.innerHeight;
|
|
5454
|
+
const at = placePopover({ left: cb.left, top: cb.top, width: cb.width, height: cb.height }, { width: pb.width, height: pb.height }, { width: window.innerWidth, height });
|
|
5455
|
+
pop.style.maxHeight = at.maxHeight ? `${Math.floor(at.maxHeight)}px` : "";
|
|
5358
5456
|
pop.style.left = `${Math.round(at.left)}px`;
|
|
5359
5457
|
pop.style.top = `${Math.round(at.top)}px`;
|
|
5458
|
+
kioskTellPop(pop);
|
|
5459
|
+
}
|
|
5460
|
+
/** behold#764: tell the kiosk where the card's details popover is (or that none is open), so its modals never cover it. */
|
|
5461
|
+
function kioskTellPop(pop) {
|
|
5462
|
+
if (!embedOpts.bare || !embedOpts.host || window.parent === window) return;
|
|
5463
|
+
const r = pop && !pop.hidden ? pop.getBoundingClientRect() : null;
|
|
5464
|
+
const at = r && r.width ? { x: Math.round(r.left), y: Math.round(r.top), w: Math.round(r.width), h: Math.round(r.height) } : null;
|
|
5465
|
+
const key = JSON.stringify(at);
|
|
5466
|
+
if (key === kioskPopTold) return;
|
|
5467
|
+
kioskPopTold = key;
|
|
5468
|
+
try {
|
|
5469
|
+
window.parent.postMessage({ type: "behold:pop", at }, embedOpts.host);
|
|
5470
|
+
} catch {
|
|
5471
|
+
/* the parent went away */
|
|
5472
|
+
}
|
|
5360
5473
|
}
|
|
5474
|
+
var kioskPopTold = "null"; // var: kioskPopRender may run before this line is reached
|
|
5361
5475
|
/** Wire the frame's pointer once: the popover, and the hover links to the kiosk. Bare frames only. */
|
|
5362
5476
|
// --- behold#571: the kiosk's Watch mode -------------------------------------
|
|
5363
5477
|
// The kiosk sends a `behold:shot` (web/kiosk-shot.js) with each step: the
|
|
@@ -5570,6 +5684,7 @@ function kioskTellBoxes() {
|
|
|
5570
5684
|
boxesQueued = false;
|
|
5571
5685
|
const svg = currentSvg();
|
|
5572
5686
|
if (!svg) return;
|
|
5687
|
+
tgPillsKeepIn(svg); // behold#764: the camera moved; the shown pills stay in view
|
|
5573
5688
|
const waves = {};
|
|
5574
5689
|
const rect = (r) => ({ x: Math.round(r.left), y: Math.round(r.top), w: Math.round(r.width), h: Math.round(r.height) });
|
|
5575
5690
|
for (const r of svg.querySelectorAll("rect[data-group-id]")) {
|
package/web/event-help-modal.js
CHANGED
|
@@ -113,6 +113,10 @@ export const MODAL_STYLE = `
|
|
|
113
113
|
/* behold#744: a modal placed off the cards leaves the graph to the pointer (hover a card or a line), not under a sheet that swallows it. */
|
|
114
114
|
.eh-modal-wrap.eh-modal-placed { align-items: flex-start; justify-content: flex-start; pointer-events: none; }
|
|
115
115
|
.eh-modal-wrap.eh-modal-placed > .eh-modal { pointer-events: auto; }
|
|
116
|
+
/* behold#764: a card's details popover is open: no sheet over it, and a modal that cannot stand clear of it waits out of sight. */
|
|
117
|
+
.eh-modal-wrap.eh-modal-keep { background: transparent; pointer-events: none; }
|
|
118
|
+
.eh-modal-wrap.eh-modal-keep > .eh-modal { pointer-events: auto; }
|
|
119
|
+
.eh-modal-wrap.eh-modal-yield > .eh-modal { visibility: hidden; pointer-events: none; }
|
|
116
120
|
.eh-modal { position: relative; width: min(36em, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; padding: 1em 1.2em 1.1em; border-radius: 12px; background: var(--surface-pane-b, var(--panel)); color: var(--fg);
|
|
117
121
|
border: 2px solid var(--bar, var(--focus)); box-shadow: 0 16px 48px color-mix(in srgb, var(--shadow) 80%, transparent); font-size: 1.05em; }
|
|
118
122
|
.eh-modal-held { --bar: var(--bar-foreign, var(--foreign)); } .eh-modal-failed { --bar: var(--bar-degraded, var(--degraded)); } .eh-modal-applied { --bar: var(--bar-managed, var(--managed)); }
|
|
@@ -159,6 +163,11 @@ export function modalStyle(doc) {
|
|
|
159
163
|
* graph's frame) when given, else the window. When no spot clears `avoid`,
|
|
160
164
|
* the one that covers least of it.
|
|
161
165
|
*/
|
|
166
|
+
/** behold#764: whether box `a` covers any of rect `b` (both `{ left, top, width, height }`). */
|
|
167
|
+
export function coversRect(a, b) {
|
|
168
|
+
return !!a && !!b && a.left < b.left + b.width && a.left + a.width > b.left && a.top < b.top + b.height && a.top + a.height > b.top;
|
|
169
|
+
}
|
|
170
|
+
|
|
162
171
|
export function modalSpot(win, size, avoid, { prefer = [], bounds = null, margin = 16, step = 24 } = {}) {
|
|
163
172
|
const grow = (a) => ({ x0: a.left - 12, y0: a.top - 12, x1: a.left + a.width + 12, y1: a.top + a.height + 12 });
|
|
164
173
|
const rects = (avoid || []).filter((a) => a && a.width > 0 && a.height > 0).map(grow);
|
|
@@ -216,9 +225,12 @@ export function openEventModal(host, { mode, kind, data = {}, actions = {}, doc
|
|
|
216
225
|
wrap.appendChild(box);
|
|
217
226
|
host.appendChild(wrap);
|
|
218
227
|
|
|
219
|
-
|
|
228
|
+
// behold#764: who closed it, on its state for onClose: "viewer" (×, Escape, a click on the sheet), else the page
|
|
229
|
+
// (its time, its event, the next modal), so a closed "Waiting on…" stays closed for the wait it was about.
|
|
230
|
+
const close = (by = null) => {
|
|
220
231
|
if (st.closed) return;
|
|
221
232
|
st.closed = true;
|
|
233
|
+
st.closedBy = by === "viewer" ? "viewer" : "page";
|
|
222
234
|
clearTimer(timer);
|
|
223
235
|
if (watchTimer) clearTimer(watchTimer);
|
|
224
236
|
if (doc.removeEventListener) doc.removeEventListener("keydown", onKey);
|
|
@@ -227,11 +239,11 @@ export function openEventModal(host, { mode, kind, data = {}, actions = {}, doc
|
|
|
227
239
|
onClose(st);
|
|
228
240
|
};
|
|
229
241
|
const onKey = (e) => {
|
|
230
|
-
if (e && e.key === ESC) close();
|
|
242
|
+
if (e && e.key === ESC) close("viewer");
|
|
231
243
|
};
|
|
232
244
|
if (doc.addEventListener) doc.addEventListener("keydown", onKey);
|
|
233
245
|
wrap.addEventListener("click", (e) => {
|
|
234
|
-
if (e && e.target === wrap) close();
|
|
246
|
+
if (e && e.target === wrap) close("viewer");
|
|
235
247
|
});
|
|
236
248
|
// Hovered, it holds: its time to close starts again when the pointer leaves.
|
|
237
249
|
box.addEventListener("pointerenter", () => (st.hovered = true));
|
|
@@ -247,7 +259,7 @@ export function openEventModal(host, { mode, kind, data = {}, actions = {}, doc
|
|
|
247
259
|
const x = el("button", "eh-modal-close", "×");
|
|
248
260
|
x.type = "button";
|
|
249
261
|
x.setAttribute("aria-label", "Close");
|
|
250
|
-
x.addEventListener("click", close);
|
|
262
|
+
x.addEventListener("click", () => close("viewer"));
|
|
251
263
|
box.appendChild(x);
|
|
252
264
|
const line = modeLine(mode, kind, { at: data.at, now: t, resolved: st.resolved, outcome: st.outcome, replayAt: data.replayAt, action: data.action, fix: !!data.fix });
|
|
253
265
|
if (line) box.appendChild(el("p", `eh-modal-mode eh-modal-${mode}`, line));
|
|
@@ -331,17 +343,42 @@ export function openEventModal(host, { mode, kind, data = {}, actions = {}, doc
|
|
|
331
343
|
}
|
|
332
344
|
// behold#631: a modal that must keep things in view (a failed card and the cards it blocked) moves off them.
|
|
333
345
|
const placeClear = () => {
|
|
334
|
-
|
|
346
|
+
// behold#764: what it must never cover, whatever else it keeps off: the card's details popover a viewer has open.
|
|
347
|
+
const keep = typeof data.keepClear === "function" ? data.keepClear() : null;
|
|
348
|
+
if ((typeof data.avoid !== "function" && !keep) || !box.getBoundingClientRect || !doc.defaultView) {
|
|
349
|
+
// The popover closed: the modal steps back into sight, its sheet as it was.
|
|
350
|
+
if (st.kept && wrap.classList) {
|
|
351
|
+
wrap.classList.toggle("eh-modal-yield", false);
|
|
352
|
+
wrap.classList.toggle("eh-modal-keep", false);
|
|
353
|
+
// Moved off the popover alone (no `avoid` of its own): back to the middle.
|
|
354
|
+
wrap.classList.toggle("eh-modal-placed", false);
|
|
355
|
+
box.style.marginLeft = "";
|
|
356
|
+
box.style.marginTop = "";
|
|
357
|
+
}
|
|
358
|
+
st.kept = false;
|
|
359
|
+
st.yielded = false;
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
// Measured where it would stand: a modal that yielded is hidden, not gone.
|
|
335
363
|
const r = box.getBoundingClientRect();
|
|
336
364
|
if (!r.width) return;
|
|
337
365
|
const win = { w: doc.defaultView.innerWidth, h: doc.defaultView.innerHeight };
|
|
338
|
-
const
|
|
366
|
+
const avoid = [...(typeof data.avoid === "function" ? data.avoid() || [] : []), ...(keep ? [keep] : [])];
|
|
367
|
+
const spot = modalSpot(win, { w: r.width, h: r.height }, avoid, { prefer: typeof data.prefer === "function" ? data.prefer() || [] : [], bounds: typeof data.bounds === "function" ? data.bounds() : null });
|
|
339
368
|
wrap.classList.toggle("eh-modal-placed", !!spot);
|
|
369
|
+
wrap.classList.toggle("eh-modal-keep", !!keep);
|
|
370
|
+
st.kept = !!keep;
|
|
340
371
|
box.style.marginLeft = spot ? `${Math.round(spot.left)}px` : "";
|
|
341
372
|
box.style.marginTop = spot ? `${Math.round(spot.top)}px` : "";
|
|
373
|
+
// Where no spot clears the popover, the modal steps out of sight until it closes; its sheet never tints over it.
|
|
374
|
+
const at = spot ? { left: spot.left, top: spot.top } : { left: (win.w - r.width) / 2, top: (win.h - r.height) / 2 };
|
|
375
|
+
st.yielded = !!keep && coversRect({ ...at, width: r.width, height: r.height }, keep);
|
|
376
|
+
wrap.classList.toggle("eh-modal-yield", st.yielded);
|
|
342
377
|
};
|
|
343
378
|
const tick = () => {
|
|
344
379
|
if (st.closed) return;
|
|
380
|
+
// behold#764: out of sight behind a details popover, its time to close waits, as a hovered one's does.
|
|
381
|
+
if (st.closeAt !== null && st.yielded) st.closeAt = Math.max(st.closeAt, now() + 2_000);
|
|
345
382
|
if (st.closeAt !== null && !st.hovered && now() >= st.closeAt) return close();
|
|
346
383
|
render();
|
|
347
384
|
placeClear();
|
|
@@ -369,7 +406,7 @@ export function openEventModal(host, { mode, kind, data = {}, actions = {}, doc
|
|
|
369
406
|
Object.assign(data, next);
|
|
370
407
|
render();
|
|
371
408
|
},
|
|
372
|
-
close,
|
|
409
|
+
close: () => close(),
|
|
373
410
|
};
|
|
374
411
|
return api;
|
|
375
412
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// behold#764: where a floating dialog goes, kept inside what can be seen.
|
|
2
|
+
// On the fan-out kiosks wave 3's cards sit at the very top of the graph, and
|
|
3
|
+
// a dialog put above (or levelled with) one of them, or one taller than the
|
|
4
|
+
// space left, ran off the top of its window. Every floating thing of the
|
|
5
|
+
// kiosk (the frame's card popover, the job box and its log drawer, the
|
|
6
|
+
// approval callout, the event-help tips, the tooltip) places itself with
|
|
7
|
+
// these: beside its anchor on the first side it fits, else on the side with
|
|
8
|
+
// the most room, never past the view's edges less a margin; taller than the
|
|
9
|
+
// view, it gets a max height and its body scrolls.
|
|
10
|
+
//
|
|
11
|
+
// Pure: rects in, a position out. All boxes are `{ left, top, width, height }`
|
|
12
|
+
// in one window's pixels; the view is the part of that window that shows (a
|
|
13
|
+
// frame's window, or the kiosk's graph above its caption).
|
|
14
|
+
|
|
15
|
+
/** The room kept between a dialog and the view's edge, in px. */
|
|
16
|
+
export const FLOAT_MARGIN = 8;
|
|
17
|
+
|
|
18
|
+
const clamp = (v, lo, hi) => Math.max(lo, Math.min(v, Math.max(lo, hi)));
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The smallest move `{ dx, dy }` that puts `rect` inside `view` less `margin`.
|
|
22
|
+
* A rect bigger than the view keeps its top (or left) edge in: what a dialog
|
|
23
|
+
* starts with is what is read first.
|
|
24
|
+
*/
|
|
25
|
+
export function shiftInto(rect, view, margin = FLOAT_MARGIN) {
|
|
26
|
+
const x0 = view.left + margin;
|
|
27
|
+
const y0 = view.top + margin;
|
|
28
|
+
const x1 = view.left + view.width - margin;
|
|
29
|
+
const y1 = view.top + view.height - margin;
|
|
30
|
+
const left = clamp(rect.left, x0, x1 - rect.width);
|
|
31
|
+
const top = clamp(rect.top, y0, y1 - rect.height);
|
|
32
|
+
return { dx: left - rect.left, dy: top - rect.top };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Whether `rect` lies inside `view` less `margin` (half a pixel's slack for rounding). */
|
|
36
|
+
export function fitsIn(rect, view, margin = FLOAT_MARGIN) {
|
|
37
|
+
return rect.left >= view.left + margin - 0.5 && rect.top >= view.top + margin - 0.5 && rect.left + rect.width <= view.left + view.width - margin + 0.5 && rect.top + rect.height <= view.top + view.height - margin + 0.5;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Where a dialog of `size` (`{ width, height }`) goes beside `anchor` inside
|
|
42
|
+
* `view`. `sides` is the order to try ("right", "left", "below", "above"):
|
|
43
|
+
* the first side with room for the whole dialog wins. With none, the side
|
|
44
|
+
* with the most room for it, as a share of its size. Along its side the
|
|
45
|
+
* dialog starts level with the anchor's top (beside) or left (above, below),
|
|
46
|
+
* slid as little as keeps it in the view. A dialog taller than the view
|
|
47
|
+
* less its margins gets `maxHeight` (else null): the caller caps it there and
|
|
48
|
+
* lets its body scroll. `arrow` is how far along the dialog's near edge the
|
|
49
|
+
* anchor's middle is (its notch or leader points there), kept 12px off its
|
|
50
|
+
* corners. Returns `{ left, top, side, maxHeight, arrow }`.
|
|
51
|
+
*/
|
|
52
|
+
export function placeFloat(anchor, size, view, { sides = ["right", "left", "below", "above"], gap = 12, margin = FLOAT_MARGIN } = {}) {
|
|
53
|
+
const vx0 = view.left + margin;
|
|
54
|
+
const vy0 = view.top + margin;
|
|
55
|
+
const vx1 = view.left + view.width - margin;
|
|
56
|
+
const vy1 = view.top + view.height - margin;
|
|
57
|
+
const maxH = Math.max(0, vy1 - vy0);
|
|
58
|
+
const maxW = Math.max(0, vx1 - vx0);
|
|
59
|
+
const h = Math.min(size.height, maxH);
|
|
60
|
+
const w = Math.min(size.width, maxW);
|
|
61
|
+
const right = anchor.left + anchor.width;
|
|
62
|
+
const bottom = anchor.top + anchor.height;
|
|
63
|
+
const room = {
|
|
64
|
+
right: vx1 - (right + gap),
|
|
65
|
+
left: anchor.left - gap - vx0,
|
|
66
|
+
below: vy1 - (bottom + gap),
|
|
67
|
+
above: anchor.top - gap - vy0,
|
|
68
|
+
};
|
|
69
|
+
const need = (side) => (side === "right" || side === "left" ? w : h);
|
|
70
|
+
const at = (side) => {
|
|
71
|
+
if (side === "right") return { left: right + gap, top: clamp(anchor.top, vy0, vy1 - h) };
|
|
72
|
+
if (side === "left") return { left: anchor.left - gap - w, top: clamp(anchor.top, vy0, vy1 - h) };
|
|
73
|
+
if (side === "below") return { left: clamp(anchor.left, vx0, vx1 - w), top: bottom + gap };
|
|
74
|
+
return { left: clamp(anchor.left, vx0, vx1 - w), top: anchor.top - gap - h };
|
|
75
|
+
};
|
|
76
|
+
let side = sides.find((s) => room[s] >= need(s));
|
|
77
|
+
if (!side) side = [...sides].sort((a, b) => room[b] / need(b) - room[a] / need(a))[0];
|
|
78
|
+
const p = at(side);
|
|
79
|
+
const left = clamp(p.left, vx0, vx1 - w);
|
|
80
|
+
const top = clamp(p.top, vy0, vy1 - h);
|
|
81
|
+
const beside = side === "right" || side === "left";
|
|
82
|
+
const mid = beside ? anchor.top + anchor.height / 2 - top : anchor.left + anchor.width / 2 - left;
|
|
83
|
+
const arrow = Math.max(12, Math.min((beside ? h : w) - 12, mid));
|
|
84
|
+
return { left, top, side, maxHeight: size.height > maxH ? maxH : null, arrow };
|
|
85
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// behold#764: every floating dialog of the kiosk stays inside what can be seen.
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { FLOAT_MARGIN, fitsIn, placeFloat, shiftInto } from "./float-place.js";
|
|
4
|
+
import { placePopover } from "./kiosk-popover.js";
|
|
5
|
+
import { placeBeside } from "./kiosk-watch.js";
|
|
6
|
+
import { placeTip } from "./tooltip.js";
|
|
7
|
+
import { tipSpot } from "./kiosk-event-help-ui.js";
|
|
8
|
+
|
|
9
|
+
const box = (left, top, width, height) => ({ left, top, width, height });
|
|
10
|
+
const overlaps = (a, b) => a.left < b.left + b.width && a.left + a.width > b.left && a.top < b.top + b.height && a.top + a.height > b.top;
|
|
11
|
+
|
|
12
|
+
describe("shiftInto", () => {
|
|
13
|
+
const view = box(0, 0, 1000, 600);
|
|
14
|
+
it("leaves a rect inside alone, and moves one outside by as little as brings it in", () => {
|
|
15
|
+
expect(shiftInto(box(100, 100, 200, 100), view)).toEqual({ dx: 0, dy: 0 });
|
|
16
|
+
expect(shiftInto(box(100, -331, 262, 31), view)).toEqual({ dx: 0, dy: 339 });
|
|
17
|
+
expect(shiftInto(box(-105, 373, 390, 46), view)).toEqual({ dx: 113, dy: 0 });
|
|
18
|
+
expect(shiftInto(box(900, 580, 200, 40), view)).toEqual({ dx: -108, dy: -28 });
|
|
19
|
+
});
|
|
20
|
+
it("keeps the top and left edges in for a rect bigger than the view", () => {
|
|
21
|
+
expect(shiftInto(box(50, -94, 2000, 900), view)).toEqual({ dx: -42, dy: 102 });
|
|
22
|
+
});
|
|
23
|
+
it("works in a view that does not start at 0", () => {
|
|
24
|
+
expect(shiftInto(box(0, 0, 50, 50), box(100, 80, 400, 300), 4)).toEqual({ dx: 104, dy: 84 });
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("placeFloat", () => {
|
|
29
|
+
const view = box(0, 0, 1356, 686); // the kiosk's graph frame at 1366x768
|
|
30
|
+
const size = { width: 412, height: 141 };
|
|
31
|
+
const sides = [["right"], ["left"], ["below"], ["above"]];
|
|
32
|
+
|
|
33
|
+
it("a wave 3 card at the very top of the view: no side puts the dialog past the top", () => {
|
|
34
|
+
const card = box(574, 8, 110, 50);
|
|
35
|
+
for (const [s] of sides) {
|
|
36
|
+
const p = placeFloat(card, size, view, { sides: [s, "below"] });
|
|
37
|
+
expect(fitsIn({ ...p, ...size }, view)).toBe(true);
|
|
38
|
+
}
|
|
39
|
+
// Asked for above first, with no room there, it goes below.
|
|
40
|
+
expect(placeFloat(card, size, view, { sides: ["above", "below"] }).side).toBe("below");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("flips to the side with room: below when there is none above, beside when that fits better", () => {
|
|
44
|
+
expect(placeFloat(box(500, 20, 300, 60), { width: 300, height: 200 }, box(0, 0, 1000, 700), { sides: ["above", "below"] })).toMatchObject({ side: "below", top: 92 });
|
|
45
|
+
// A card as wide as the view, at its top: no room above or below for a tall dialog; to its side when that has room.
|
|
46
|
+
const p = placeFloat(box(20, 10, 600, 650), { width: 300, height: 400 }, box(0, 0, 1000, 700), { sides: ["above", "below", "right"] });
|
|
47
|
+
expect(p.side).toBe("right");
|
|
48
|
+
expect(fitsIn({ ...p, width: 300, height: 400 }, box(0, 0, 1000, 700))).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("never covers its anchor when a side has room, and keeps its leader's end on the anchor", () => {
|
|
52
|
+
const card = box(574, 84, 110, 50);
|
|
53
|
+
const p = placeFloat(card, size, view);
|
|
54
|
+
expect(overlaps({ ...p, ...size }, card)).toBe(false);
|
|
55
|
+
expect(p.side).toBe("right");
|
|
56
|
+
// The notch points at the card's middle, along the dialog's near edge.
|
|
57
|
+
expect(p.top + p.arrow).toBe(card.top + card.height / 2);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("a dialog taller than the view is capped there, its top inside the view", () => {
|
|
61
|
+
const p = placeFloat(box(400, 300, 300, 80), { width: 442, height: 900 }, view);
|
|
62
|
+
expect(p.maxHeight).toBe(686 - 2 * FLOAT_MARGIN);
|
|
63
|
+
expect(p.top).toBe(FLOAT_MARGIN);
|
|
64
|
+
expect(fitsIn({ left: p.left, top: p.top, width: 442, height: p.maxHeight }, view)).toBe(true);
|
|
65
|
+
expect(placeFloat(box(400, 300, 300, 80), size, view).maxHeight).toBeNull();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("stays inside the view for any anchor, at both kiosk sizes", () => {
|
|
69
|
+
for (const v of [box(0, 0, 1910, 981), box(0, 0, 1356, 686), box(5, 77, 1356, 400)]) {
|
|
70
|
+
for (let x = -200; x < v.width + 200; x += 97) {
|
|
71
|
+
for (let y = -200; y < v.height + 200; y += 89) {
|
|
72
|
+
for (const s of [size, { width: 535, height: 771 }, { width: 30, height: 20 }]) {
|
|
73
|
+
const p = placeFloat(box(x, y, 110, 50), s, v);
|
|
74
|
+
const h = p.maxHeight || s.height;
|
|
75
|
+
expect(fitsIn({ left: p.left, top: p.top, width: Math.min(s.width, v.width - 16), height: h }, v)).toBe(true);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe("the dialogs that use it", () => {
|
|
84
|
+
it("the card popover: right of a top-row card, inside the frame, capped when taller", () => {
|
|
85
|
+
const frame = { width: 1356, height: 686 };
|
|
86
|
+
const p = placePopover(box(574, 84, 110, 50), { width: 412, height: 141 }, frame);
|
|
87
|
+
expect(p).toMatchObject({ side: "right", left: 696, top: 84, maxHeight: null });
|
|
88
|
+
const tall = placePopover(box(574, 0, 110, 50), { width: 412, height: 900 }, frame);
|
|
89
|
+
expect(tall.top).toBe(8);
|
|
90
|
+
expect(tall.maxHeight).toBe(670);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("the job box's drawer, opened taller than the graph above the caption: kept below the view's top, capped (was 94px off it)", () => {
|
|
94
|
+
// 1366x768: the graph shows from 77px to the caption's top at 480px; the drawer opened is 569px tall.
|
|
95
|
+
const view = { x: 5, y: 77, w: 1356, h: 403 };
|
|
96
|
+
const p = placeBeside({ x: 120, y: 250, w: 920, h: 300 }, { w: 442, h: 569 }, view);
|
|
97
|
+
expect(p.y).toBeGreaterThanOrEqual(view.y + 8);
|
|
98
|
+
expect(p.maxHeight).toBe(403 - 16);
|
|
99
|
+
expect(p.y + p.maxHeight).toBeLessThanOrEqual(view.y + view.h - 8);
|
|
100
|
+
// Its old "below" spot was 18px under a wave box low in the view: now it never runs past the top for that either.
|
|
101
|
+
const low = placeBeside({ x: 0, y: 300, w: 1356, h: 160 }, { w: 442, h: 300 }, view);
|
|
102
|
+
expect(low.y).toBeGreaterThanOrEqual(view.y + 8);
|
|
103
|
+
expect(low.y + 300).toBeLessThanOrEqual(view.y + view.h - 8);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("the tooltip: inside the window when it fits neither below nor above", () => {
|
|
107
|
+
const p = placeTip({ left: 100, right: 140, top: 300, bottom: 320 }, { width: 200, height: 500 }, { width: 800, height: 600 });
|
|
108
|
+
expect(p.top).toBeGreaterThanOrEqual(8);
|
|
109
|
+
expect(p.top + 500).toBeLessThanOrEqual(600 - 8 + 0.5);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("an event-help tip under a card low in the window stays inside its bottom", () => {
|
|
113
|
+
const p = tipSpot({ left: 400, top: 10, width: 300, height: 700 }, { w: 240, h: 30 }, { w: 1440, h: 760 });
|
|
114
|
+
expect(p.below).toBe(true);
|
|
115
|
+
expect(p.y + 30).toBeLessThanOrEqual(760 - 8);
|
|
116
|
+
});
|
|
117
|
+
});
|
package/web/index.html
CHANGED
|
@@ -523,8 +523,12 @@
|
|
|
523
523
|
/* behold#571: the marks drawn over a card let the pointer through to it, so pointing anywhere on the card opens its popover. */
|
|
524
524
|
.bare #graph text[data-tg-root], .bare #graph g[data-tg-root] { pointer-events: none; }
|
|
525
525
|
/* behold#571: the kiosk frame's popover, beside the card it describes. */
|
|
526
|
-
#
|
|
527
|
-
|
|
526
|
+
/* behold#764: capped to the frame's view by placePopover (max-height), its body scrolls. */
|
|
527
|
+
/* behold#764: on the kiosk's raised surface (its modals' and callouts'), not --panel: in Batman --panel is within a
|
|
528
|
+
few steps of the cards and wave boxes under it, so the popover read as see-through over the graph. A focus-tinted
|
|
529
|
+
border and a deeper shadow set it apart in every theme. */
|
|
530
|
+
#k-pop { position: fixed; z-index: 50; max-width: min(30em, 46vw); overflow-y: auto; overscroll-behavior: contain; padding: 0.7em 0.9em 0.6em; background: var(--surface-pane-b, var(--panel)); color: var(--fg);
|
|
531
|
+
border: 1.5px solid color-mix(in srgb, var(--focus) 70%, var(--rule)); border-radius: 8px; box-shadow: 0 10px 34px color-mix(in srgb, var(--shadow) 80%, transparent);
|
|
528
532
|
font: 14px/1.4 var(--font-ui); pointer-events: auto; }
|
|
529
533
|
#k-pop[hidden] { display: none; }
|
|
530
534
|
/* behold#571: on a phone the popover takes the frame's width, less a margin. */
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// lights, the glows and the modals off; the trail stays, since it is the
|
|
20
20
|
// record.
|
|
21
21
|
|
|
22
|
-
import { EH_STORE, HIGHLIGHT_MS, LATE_ORDER, TIP_MS, cycleFacts, storyKey, ehSnapshot, ehStore, ehStored, highlightOpens, highlightShown, highlightTurn, modalQueue, modalShownElsewhere, newEvents, storyTrail, tipsQueue, tipsShown } from "./kiosk-event-help.js";
|
|
22
|
+
import { EH_STORE, HIGHLIGHT_MS, LATE_ORDER, TIP_MS, createDismissals, cycleFacts, dismissKey, stepWrittenAt, storyKey, ehSnapshot, ehStore, ehStored, highlightOpens, highlightShown, highlightTurn, modalQueue, modalShownElsewhere, newEvents, storyTrail, tipsQueue, tipsShown, waitingOpens } from "./kiosk-event-help.js";
|
|
23
23
|
|
|
24
24
|
/** How long after the page opens (or the cycle turns) what arrives is the story so far, not news: the reads land one by one. */
|
|
25
25
|
export const SETTLE_MS = 8_000;
|
|
@@ -114,7 +114,11 @@ export function tipSpot(rect, size, win, labels = []) {
|
|
|
114
114
|
if (y >= 8) spots.push({ x: spots[0].x, y, below: false });
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
// behold#764: below, kept inside the window's bottom when its height is known (a tip under a card low in the view).
|
|
118
|
+
const belowY = win.h ? Math.max(8, Math.min(rect.top + rect.height + 12, win.h - h - 8)) : rect.top + rect.height + 12;
|
|
119
|
+
spots.push(...along(belowY, true));
|
|
120
|
+
// An anchor too narrow for any spot along it to reach: the centred spot, still inside the window.
|
|
121
|
+
if (!spots.length) spots.push({ x: clampX(mid - w / 2), y: aboveY >= 8 ? aboveY : belowY, below: aboveY < 8 });
|
|
118
122
|
let best = null;
|
|
119
123
|
for (const p of spots) {
|
|
120
124
|
const c = covered(p);
|
|
@@ -138,7 +142,7 @@ export function toneOf(kind) {
|
|
|
138
142
|
* lights them across the panes as a hover does (null puts them out);
|
|
139
143
|
* `panel(kind)` builds the real panel the modal shows (the approval panel).
|
|
140
144
|
*/
|
|
141
|
-
export function startEventHelp({ doc = document, store = null, switchHost = null, trailHost, tipsHost, modalHost, get, light = () => {}, panel = () => null, openTrace = () => {}, now = () => Date.now(), shown = now, reduced = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches }) {
|
|
145
|
+
export function startEventHelp({ doc = document, store = null, session = null, switchHost = null, trailHost, tipsHost, modalHost, get, light = () => {}, panel = () => null, openTrace = () => {}, now = () => Date.now(), shown = now, reduced = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches }) {
|
|
142
146
|
if (doc.head && !doc.getElementById("eh-style")) {
|
|
143
147
|
const style = doc.createElement("style");
|
|
144
148
|
style.id = "eh-style";
|
|
@@ -147,6 +151,13 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
147
151
|
}
|
|
148
152
|
modalStyle(doc);
|
|
149
153
|
const st = { bootAt: now(), maxOrder: -Infinity, appliedAt: new Map(), on: ehStored(store), cycle: null, seen: null, trail: new Map(), failed: new Set(), tips: null, modals: null, modal: null, lastInput: -Infinity, lit: null, litUntil: 0, nodes: new Map(), glows: [] };
|
|
154
|
+
// behold#764: the story modals the viewer closed this visit (sessionStorage, `session`), which do not open again for the same thing.
|
|
155
|
+
st.closed = createDismissals(session);
|
|
156
|
+
/** The onClose of a story modal about `key` of `kind`: a close by the viewer is kept, so the same thing never reopens it. */
|
|
157
|
+
const closedBy = (kind, d, key) => (ms) => {
|
|
158
|
+
st.modal = null;
|
|
159
|
+
if (ms && ms.closedBy === "viewer") st.closed.add(dismissKey(kind, d, key));
|
|
160
|
+
};
|
|
150
161
|
const el = (tag, cls, text) => {
|
|
151
162
|
const n = doc.createElement(tag);
|
|
152
163
|
if (cls) n.className = cls;
|
|
@@ -212,6 +223,11 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
212
223
|
const now = (get && get()) || h;
|
|
213
224
|
return ((now && now.boxes && now.boxes.labels) || []).map((l) => fromFrame(now, l)).filter(Boolean);
|
|
214
225
|
};
|
|
226
|
+
/** behold#764: the card's details popover the frame has open (its `pop`, read fresh), in the window's coordinates, or null. */
|
|
227
|
+
const popRect = (at) => {
|
|
228
|
+
const h = (get && get()) || at;
|
|
229
|
+
return h && h.pop ? fromFrame(h, h.pop) : null;
|
|
230
|
+
};
|
|
215
231
|
/** behold#631: the graph's area above the bottom band (the track or trail, and the caption): where a chant modal may go. */
|
|
216
232
|
const graphArea = (h) => {
|
|
217
233
|
const F = frameRect(h);
|
|
@@ -254,7 +270,7 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
254
270
|
|
|
255
271
|
// ---- tips ----------------------------------------------------------------
|
|
256
272
|
const place = (node, rect, h) => {
|
|
257
|
-
const win = { w: doc.defaultView ? doc.defaultView.innerWidth : 1600 };
|
|
273
|
+
const win = { w: doc.defaultView ? doc.defaultView.innerWidth : 1600, h: doc.defaultView ? doc.defaultView.innerHeight : 0 };
|
|
258
274
|
// The frame's edge labels, in the window's coordinates (behold#695).
|
|
259
275
|
const F = h ? frameRect(h) : null;
|
|
260
276
|
const labels = F && h.boxes && Array.isArray(h.boxes.labels) ? h.boxes.labels.map((l) => ({ x: F.left + l.x, y: F.top + l.y, w: l.w, h: l.h })) : [];
|
|
@@ -428,6 +444,8 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
428
444
|
data = { title: "Applied", lines: [...(h.label ? [{ text: h.label }] : []), ...(r ? r.counts.map((c) => ({ text: c })) : [])], replayAt: t };
|
|
429
445
|
}
|
|
430
446
|
const kind = event.kind === "refused" ? "failed" : event.kind;
|
|
447
|
+
// behold#764: never over the card's details popover a viewer has open.
|
|
448
|
+
data.keepClear = () => popRect(h);
|
|
431
449
|
// behold#631: a chant failure's modal keeps clear of the failed card and the cards it blocked.
|
|
432
450
|
// It must leave the failed wave and the wave after it in view (`avoid`), and covers as few other cards as it can.
|
|
433
451
|
// behold#741: a terragucci story's modals do the same: off the cards they are about (a held wave's, a failed one's),
|
|
@@ -441,7 +459,7 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
441
459
|
data.bounds = () => graphArea(h);
|
|
442
460
|
}
|
|
443
461
|
// A chant kiosk counts down on the clock its track and caption use, so all three say the same second.
|
|
444
|
-
const api = openEventModal(modalHost, { mode, kind, data, doc, now: event.chant ? now : shown, reduced: reduced(), onClose: (
|
|
462
|
+
const api = openEventModal(modalHost, { mode, kind, data, doc, now: event.chant ? now : shown, reduced: reduced(), onClose: closedBy(kind, d, event.id) });
|
|
445
463
|
st.modal = { api, event, kind, step: d ? d.step : null, cycle: d ? d.cycle : null, pull: d ? d.pull : null };
|
|
446
464
|
};
|
|
447
465
|
/** behold#631: the "Waiting on…" modal's words: what is waited on, why it matters, and how long it usually takes. */
|
|
@@ -450,6 +468,7 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
450
468
|
lines: w.why ? [{ text: w.why }] : [],
|
|
451
469
|
progress: { fraction: w.fraction, words: w.words },
|
|
452
470
|
...offCards(h),
|
|
471
|
+
keepClear: () => popRect(h),
|
|
453
472
|
});
|
|
454
473
|
/**
|
|
455
474
|
* Where a modal about no one card goes (the "Waiting on…" one, a step's highlight): never over a card, since any
|
|
@@ -462,7 +481,9 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
462
481
|
const offCards = (at) => ({
|
|
463
482
|
avoid: () => {
|
|
464
483
|
const h = (get && get()) || at;
|
|
465
|
-
|
|
484
|
+
// behold#764: nor over the job box (the log drawer) or the approval callout beside a wave.
|
|
485
|
+
const overs = doc.querySelectorAll ? [...doc.querySelectorAll("#k-drawer.k-placed, #k-callout.k-placed")].filter((n) => !n.hidden && n.getBoundingClientRect).map((n) => n.getBoundingClientRect()).filter((r) => r.width > 0) : [];
|
|
486
|
+
return [...Object.keys((h.boxes && h.boxes.roots) || {}).map((r) => fromFrame(h, h.boxes.roots[r])).filter(Boolean), ...pillRects(h), ...overs];
|
|
466
487
|
},
|
|
467
488
|
prefer: () => {
|
|
468
489
|
const h = (get && get()) || at;
|
|
@@ -478,14 +499,16 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
478
499
|
});
|
|
479
500
|
const openWaiting = (w, h) => {
|
|
480
501
|
const d = h.demo;
|
|
481
|
-
const api = openEventModal(modalHost, { mode: "narrated", kind: "waiting", data: waitingData(w, h), doc, now, reduced: reduced(), onClose: (
|
|
502
|
+
const api = openEventModal(modalHost, { mode: "narrated", kind: "waiting", data: waitingData(w, h), doc, now, reduced: reduced(), onClose: closedBy("waiting", d, w.key) });
|
|
482
503
|
st.modal = { api, event: { kind: "waiting", subjects: { roots: [], wave: null } }, kind: "waiting", key: w.key, step: d ? d.step : null, cycle: d ? d.cycle : null, pull: d ? d.pull : null };
|
|
483
504
|
if (st.story) for (const n of st.nodes.values()) n.style.visibility = "hidden";
|
|
484
505
|
};
|
|
485
506
|
/** behold#757: a step's highlight, as a modal off the cards: up HIGHLIGHT_MS (longer while hovered), or until its step goes. */
|
|
486
507
|
const openHighlight = (hl, h) => {
|
|
487
508
|
const d = h.demo;
|
|
488
|
-
const data = { title: hl.title, lines: [{ text: hl.body }], closeAfter: HIGHLIGHT_MS, ...offCards(h) };
|
|
509
|
+
const data = { title: hl.title, lines: [{ text: hl.body }], closeAfter: HIGHLIGHT_MS, ...offCards(h), keepClear: () => popRect(h) };
|
|
510
|
+
// behold#764: once per cycle, step and title for the visit, a reload included: kept as it opens.
|
|
511
|
+
st.closed.add(dismissKey("highlight", d, hl.id));
|
|
489
512
|
const api = openEventModal(modalHost, { mode: h.replay ? "replay" : "narrated", kind: "highlight", data, doc, now, reduced: reduced(), onClose: () => (st.modal = null) });
|
|
490
513
|
st.modal = { api, event: { kind: "highlight", subjects: { roots: [], wave: null } }, kind: "highlight", key: hl.key, step: d ? d.step : null, cycle: d ? d.cycle : null, pull: d ? d.pull : null };
|
|
491
514
|
for (const n of st.nodes.values()) n.style.visibility = "hidden";
|
|
@@ -532,6 +555,10 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
532
555
|
st.trail.clear();
|
|
533
556
|
st.failed.clear();
|
|
534
557
|
}
|
|
558
|
+
// behold#764: a replay looping round to its start (its step's time goes back) is a new telling: what the viewer closed opens again.
|
|
559
|
+
const at = stepWrittenAt(h.demo);
|
|
560
|
+
if (at !== null && st.writtenAt !== undefined && st.writtenAt !== null && at < st.writtenAt) st.closed.clear();
|
|
561
|
+
st.writtenAt = at;
|
|
535
562
|
for (const f of facts) if ((f.kind === "failed" || f.kind === "refused") && Number.isInteger(f.subjects.wave)) st.failed.add(f.subjects.wave);
|
|
536
563
|
// While the page settles, everything is the story so far.
|
|
537
564
|
const settling = now() - st.bootAt < SETTLE_MS;
|
|
@@ -585,7 +612,10 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
585
612
|
}
|
|
586
613
|
// behold#757: the step's highlight, once per cycle, step and title, before the critical modals: one due now waits
|
|
587
614
|
// behind it in the queue, and opens when it closes if its step is still the step.
|
|
588
|
-
|
|
615
|
+
// behold#764: a highlight this visit already showed (before a reload) is not shown again; none opens over a details popover.
|
|
616
|
+
const pop = popRect(h);
|
|
617
|
+
if (st.hl.pending && st.closed.has(dismissKey("highlight", h.demo, st.hl.pending.id))) st.hl = highlightShown(st.hl);
|
|
618
|
+
if (highlightOpens({ pending: st.hl.pending, on: st.on, watch: !!h.watch, held: !!h.held, modal: st.modal ? st.modal.kind : null, pop })) {
|
|
589
619
|
if (st.modal) st.modal.api.close();
|
|
590
620
|
openHighlight(st.hl.pending, h);
|
|
591
621
|
st.hl = highlightShown(st.hl);
|
|
@@ -594,7 +624,9 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
594
624
|
// Its result is the Applied card beside the graph; a modal would say it twice, over the cards.
|
|
595
625
|
// On a held small stage in Watch no modal opens: nothing overlays the graph there, and the caption says each step.
|
|
596
626
|
const told = (e) => modalShownElsewhere(e, { watch: !!h.watch, held: !!h.held });
|
|
597
|
-
|
|
627
|
+
// behold#764: one the viewer closed stays closed; one due while a details popover is open waits for it to close.
|
|
628
|
+
const closedOne = (e) => st.closed.has(dismissKey(e.kind === "refused" ? "failed" : e.kind, h.demo, e.id));
|
|
629
|
+
st.modals = modalQueue(st.modals, { add: (h.chant ? news.filter((f) => f.kind !== "held" && f.kind !== "applied") : news).filter((e) => !told(e) && !closedOne(e)), now: now(), lastInput: st.lastInput, open: !!st.modal || !!pop });
|
|
598
630
|
// A modal opens only while its event is still the step's: one that waited out a viewer at the page and went by is history.
|
|
599
631
|
if (st.modals.next && stillNow(st.modals.next, h.demo)) {
|
|
600
632
|
openModal(st.modals.next, h);
|
|
@@ -603,7 +635,8 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
603
635
|
}
|
|
604
636
|
// behold#631: a quiet stretch on a chant kiosk: "Waiting on …", when no other modal is up or due.
|
|
605
637
|
const held = st.waitingHold && h.waiting && st.waitingHold.key === h.waiting.key && now() < st.waitingHold.until;
|
|
606
|
-
|
|
638
|
+
const closedWait = !!h.waiting && st.closed.has(dismissKey("waiting", h.demo, h.waiting.key));
|
|
639
|
+
if (waitingOpens({ waiting: h.waiting, on: st.on, held, modal: st.modal, due: !!(st.modals && st.modals.next), pop, closed: closedWait })) openWaiting(h.waiting, h);
|
|
607
640
|
else if (h.waiting && st.modal && st.modal.kind === "waiting") st.modal.api.update(waitingData(h.waiting, h));
|
|
608
641
|
};
|
|
609
642
|
const stillNow = (e, d) => (e.kind === "held" ? d.step === "waiting" : e.kind === "failed" || e.kind === "refused" ? d.step === "failed" : e.kind === "applied" ? d.step === "applied" : false);
|
package/web/kiosk-event-help.js
CHANGED
|
@@ -410,6 +410,79 @@ export function highlightShown(state) {
|
|
|
410
410
|
* small stage (nothing overlays the graph there), and no modal up but a
|
|
411
411
|
* "Waiting on…" one, which it replaces. A critical modal up keeps it waiting.
|
|
412
412
|
*/
|
|
413
|
-
export function highlightOpens({ pending = null, on = true, watch = false, held = false, modal = null } = {}) {
|
|
414
|
-
|
|
413
|
+
export function highlightOpens({ pending = null, on = true, watch = false, held = false, modal = null, pop = null } = {}) {
|
|
414
|
+
// behold#764: nor over the card's details popover a viewer has open (`pop`): it waits until that closes.
|
|
415
|
+
return !!pending && !!on && !!watch && !held && !pop && (!modal || modal === "waiting");
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// ---------------------------------------------------------------------------
|
|
419
|
+
// behold#764: a story modal a viewer closes stays closed. "Waiting on the
|
|
420
|
+
// pipeline…" came straight back on the next look after its ×: the tick opens
|
|
421
|
+
// one whenever a wait is up and no modal is. A close by the viewer (×, Escape,
|
|
422
|
+
// a click on the sheet) is kept for what the modal was about: its kind, the
|
|
423
|
+
// cycle (and beat), the pull request, the step, and its own key (the wait's
|
|
424
|
+
// chapter, segment and what it waits on; a fact's id; a highlight's id). A new
|
|
425
|
+
// wait (a later step, a new pull request, a new cycle) opens again. Kept for
|
|
426
|
+
// the visit in sessionStorage, so a reload does not bring it back either; a
|
|
427
|
+
// replay that loops round to its start forgets them, as it does a highlight.
|
|
428
|
+
// A step's highlight is kept here once it has opened, so it is once per
|
|
429
|
+
// cycle, step and title across a reload too.
|
|
430
|
+
|
|
431
|
+
/** Where the visit's closed modals are kept (sessionStorage). */
|
|
432
|
+
export const DISMISS_STORE = "behold.eventHelp.closed";
|
|
433
|
+
/** At most this many are kept: the newest. */
|
|
434
|
+
export const DISMISS_MAX = 64;
|
|
435
|
+
|
|
436
|
+
/** What a story modal is about, as one key: kind, cycle, beat, pull request, step and its own key. */
|
|
437
|
+
export function dismissKey(kind, demo, key) {
|
|
438
|
+
const d = demo || {};
|
|
439
|
+
return [kind, d.cycle ?? "", d.beat || "", d.pull ?? "", d.step || "", key ?? ""].join("|");
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/** When a step was written, in ms (a replay's `at`, a live step's `started_at`), or null. */
|
|
443
|
+
export const stepWrittenAt = (demo) => writtenAt(demo);
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* The visit's closed modals: `{ has(key), add(key), clear(), keys() }`, kept
|
|
447
|
+
* in `store` (sessionStorage) where it lets them be, in memory where it
|
|
448
|
+
* throws or is missing. Never localStorage: a closed modal is this visit's.
|
|
449
|
+
*/
|
|
450
|
+
export function createDismissals(store = null) {
|
|
451
|
+
let keys = [];
|
|
452
|
+
try {
|
|
453
|
+
const raw = store ? JSON.parse(store.getItem(DISMISS_STORE) || "[]") : [];
|
|
454
|
+
if (Array.isArray(raw)) keys = raw.filter((k) => typeof k === "string").slice(-DISMISS_MAX);
|
|
455
|
+
} catch {
|
|
456
|
+
keys = [];
|
|
457
|
+
}
|
|
458
|
+
const save = () => {
|
|
459
|
+
try {
|
|
460
|
+
if (store) store.setItem(DISMISS_STORE, JSON.stringify(keys));
|
|
461
|
+
} catch {
|
|
462
|
+
/* kept for this page only */
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
return {
|
|
466
|
+
has: (key) => keys.includes(key),
|
|
467
|
+
add(key) {
|
|
468
|
+
if (keys.includes(key)) return;
|
|
469
|
+
keys = [...keys, key].slice(-DISMISS_MAX);
|
|
470
|
+
save();
|
|
471
|
+
},
|
|
472
|
+
clear() {
|
|
473
|
+
if (!keys.length) return;
|
|
474
|
+
keys = [];
|
|
475
|
+
save();
|
|
476
|
+
},
|
|
477
|
+
keys: () => [...keys],
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* behold#764: whether the "Waiting on…" modal opens now: a wait is up, Tips
|
|
483
|
+
* on, no other modal up or due, the wait not just closed by news (`held`),
|
|
484
|
+
* no details popover open (`pop`), and the viewer has not closed this wait.
|
|
485
|
+
*/
|
|
486
|
+
export function waitingOpens({ waiting = null, on = true, held = false, modal = null, due = false, pop = null, closed = false } = {}) {
|
|
487
|
+
return !!waiting && !!on && !held && !modal && !due && !pop && !closed;
|
|
415
488
|
}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
// behold#764: "'waiting on pipeline' keeps popping back after shutting and
|
|
2
|
+
// covering the detail overlay". A story modal the viewer closes stays closed
|
|
3
|
+
// for what it was about, across redraws and a reload; and no story modal
|
|
4
|
+
// opens over a card's details popover the viewer has open.
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { coversRect, openEventModal } from "./event-help-modal.js";
|
|
7
|
+
import { DISMISS_MAX, DISMISS_STORE, createDismissals, dismissKey, ehStore, highlightOpens, waitingOpens } from "./kiosk-event-help.js";
|
|
8
|
+
import { startEventHelp } from "./kiosk-event-help-ui.js";
|
|
9
|
+
|
|
10
|
+
const HL = { title: "Same orchestration as the commercial platforms", body: "Fifteen OpenTofu states, applied in dependency order." };
|
|
11
|
+
const demo = (step, more = {}) => ({ cycle: 9, scenario: "fan-out", title: "t", step, label: `the ${step} line`, started_at: "2026-10-18T00:00:00Z", next: null, pull: 3, commit: null, ...more });
|
|
12
|
+
const WAIT = { key: "0|0|the pipeline to start the plan", what: "the pipeline to start the plan", why: "Pull request 106 is open.", fraction: 0.3, words: "usually about 21 s" };
|
|
13
|
+
/** A sessionStorage stand-in that outlives one page: what a reload keeps. */
|
|
14
|
+
const session = () => {
|
|
15
|
+
const m = new Map();
|
|
16
|
+
return { getItem: (k) => (m.has(k) ? m.get(k) : null), setItem: (k, v) => m.set(k, String(v)), map: m };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
describe("the closed modals' keys", () => {
|
|
20
|
+
it("say the kind, the cycle and beat, the pull request, the step and the modal's own key", () => {
|
|
21
|
+
expect(dismissKey("waiting", demo("pull-request"), WAIT.key)).toBe(`waiting|9||3|pull-request|${WAIT.key}`);
|
|
22
|
+
expect(dismissKey("waiting", demo("pull-request", { beat: "fix" }), "k")).not.toBe(dismissKey("waiting", demo("pull-request"), "k"));
|
|
23
|
+
// A new wait: a later step, a new pull request, a new cycle.
|
|
24
|
+
const k = dismissKey("waiting", demo("pull-request"), "k");
|
|
25
|
+
for (const d of [demo("merged"), demo("pull-request", { pull: 4 }), demo("pull-request", { cycle: 10 })]) expect(dismissKey("waiting", d, "k")).not.toBe(k);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("are kept in the store given (sessionStorage), so a new page reads them back", () => {
|
|
29
|
+
const store = session();
|
|
30
|
+
const a = createDismissals(store);
|
|
31
|
+
a.add("x");
|
|
32
|
+
a.add("x");
|
|
33
|
+
expect(JSON.parse(store.getItem(DISMISS_STORE))).toEqual(["x"]);
|
|
34
|
+
expect(createDismissals(store).has("x")).toBe(true);
|
|
35
|
+
a.clear();
|
|
36
|
+
expect(createDismissals(store).has("x")).toBe(false);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("keep the newest DISMISS_MAX, and live in memory where storage throws or holds junk", () => {
|
|
40
|
+
const store = session();
|
|
41
|
+
const a = createDismissals(store);
|
|
42
|
+
for (let i = 0; i < DISMISS_MAX + 5; i++) a.add(`k${i}`);
|
|
43
|
+
expect(a.keys()).toHaveLength(DISMISS_MAX);
|
|
44
|
+
expect(a.has("k0")).toBe(false);
|
|
45
|
+
expect(a.has(`k${DISMISS_MAX + 4}`)).toBe(true);
|
|
46
|
+
const broken = { getItem: () => { throw new Error("blocked"); }, setItem: () => { throw new Error("blocked"); } };
|
|
47
|
+
const b = createDismissals(broken);
|
|
48
|
+
b.add("y");
|
|
49
|
+
expect(b.has("y")).toBe(true);
|
|
50
|
+
store.setItem(DISMISS_STORE, "{not json");
|
|
51
|
+
expect(createDismissals(store).keys()).toEqual([]);
|
|
52
|
+
expect(createDismissals(null).has("z")).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe("when a story modal may open", () => {
|
|
57
|
+
it("the waiting one: not over a details popover, not for a wait the viewer closed, not over another modal", () => {
|
|
58
|
+
expect(waitingOpens({ waiting: WAIT })).toBe(true);
|
|
59
|
+
expect(waitingOpens({ waiting: WAIT, pop: { left: 0, top: 0, width: 10, height: 10 } })).toBe(false);
|
|
60
|
+
expect(waitingOpens({ waiting: WAIT, closed: true })).toBe(false);
|
|
61
|
+
expect(waitingOpens({ waiting: WAIT, modal: {} })).toBe(false);
|
|
62
|
+
expect(waitingOpens({ waiting: WAIT, due: true })).toBe(false);
|
|
63
|
+
expect(waitingOpens({ waiting: WAIT, on: false })).toBe(false);
|
|
64
|
+
expect(waitingOpens({ waiting: null })).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
it("a highlight: waits while a details popover is open", () => {
|
|
67
|
+
const pending = { key: "k", ...HL };
|
|
68
|
+
expect(highlightOpens({ pending, on: true, watch: true, pop: { left: 0, top: 0, width: 10, height: 10 } })).toBe(false);
|
|
69
|
+
expect(highlightOpens({ pending, on: true, watch: true, pop: null })).toBe(true);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe("Tips: a closed modal stays closed, and none covers the details popover", () => {
|
|
74
|
+
let t;
|
|
75
|
+
beforeEach(() => {
|
|
76
|
+
vi.useFakeTimers();
|
|
77
|
+
t = 1_000_000;
|
|
78
|
+
});
|
|
79
|
+
afterEach(() => vi.useRealTimers());
|
|
80
|
+
const FRAME = { getBoundingClientRect: () => ({ left: 5, top: 77, width: 1356, height: 686, right: 1361, bottom: 763 }) };
|
|
81
|
+
/** One page of the kiosk; `store` is its sessionStorage, which a reload keeps. */
|
|
82
|
+
const page = (store, { pop = null } = {}) => {
|
|
83
|
+
const doc = fakeDoc();
|
|
84
|
+
const view = { demo: demo("pull-request"), watch: true, waiting: WAIT, frame: FRAME, pop };
|
|
85
|
+
const api = startEventHelp({ doc, store: shelf(), session: store, tipsHost: doc.body, modalHost: doc.body, now: () => t, get: () => ({ ...view, strip: null, stripReady: true }), reduced: () => true });
|
|
86
|
+
const modal = (kind) => all(doc.body).find((n) => n.className && n.className.split(" ").includes(`eh-modal-${kind}`));
|
|
87
|
+
const step = (ms = 1_000, more = {}) => {
|
|
88
|
+
Object.assign(view, more);
|
|
89
|
+
t += ms;
|
|
90
|
+
vi.advanceTimersByTime(ms);
|
|
91
|
+
api.tick();
|
|
92
|
+
};
|
|
93
|
+
const closeX = (kind) => {
|
|
94
|
+
const x = all(modal(kind)).find((n) => n.className === "eh-modal-close");
|
|
95
|
+
x.handlers.click.forEach((fn) => fn({}));
|
|
96
|
+
};
|
|
97
|
+
return { api, doc, view, modal, step, closeX };
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
it("the Waiting modal, closed with ×, does not come back on the next looks at the same wait", () => {
|
|
101
|
+
const k = page(session());
|
|
102
|
+
k.step();
|
|
103
|
+
expect(k.modal("waiting")).toBeDefined();
|
|
104
|
+
k.closeX("waiting");
|
|
105
|
+
expect(k.modal("waiting")).toBeUndefined();
|
|
106
|
+
for (let i = 0; i < 60; i++) k.step(1_000);
|
|
107
|
+
expect(k.modal("waiting")).toBeUndefined();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("closed with Escape, it stays closed too; a new wait (a later step) opens again", () => {
|
|
111
|
+
const k = page(session());
|
|
112
|
+
k.step();
|
|
113
|
+
k.doc.fire("keydown", { key: "Escape" });
|
|
114
|
+
k.step(5_000);
|
|
115
|
+
expect(k.modal("waiting")).toBeUndefined();
|
|
116
|
+
k.step(1_000, { demo: demo("merged"), waiting: { ...WAIT, key: "0|2|the pipeline to apply" } });
|
|
117
|
+
expect(k.modal("waiting")).toBeDefined();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("a close by the page (news, the wait ending) is no viewer's: the same wait may open again", () => {
|
|
121
|
+
const k = page(session());
|
|
122
|
+
k.step();
|
|
123
|
+
k.step(1_000, { waiting: null });
|
|
124
|
+
expect(k.modal("waiting")).toBeUndefined();
|
|
125
|
+
k.step(1_000, { waiting: WAIT });
|
|
126
|
+
expect(k.modal("waiting")).toBeDefined();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("survives a reload: the next page, with the same session, does not reopen the wait the viewer closed", () => {
|
|
130
|
+
const store = session();
|
|
131
|
+
const first = page(store);
|
|
132
|
+
first.step();
|
|
133
|
+
first.closeX("waiting");
|
|
134
|
+
const again = page(store);
|
|
135
|
+
for (let i = 0; i < 10; i++) again.step(1_000);
|
|
136
|
+
expect(again.modal("waiting")).toBeUndefined();
|
|
137
|
+
// A fresh visit (a new session) opens it.
|
|
138
|
+
const fresh = page(session());
|
|
139
|
+
fresh.step();
|
|
140
|
+
expect(fresh.modal("waiting")).toBeDefined();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("a step's highlight is once per cycle, step and title across a reload too", () => {
|
|
144
|
+
const store = session();
|
|
145
|
+
const first = page(store);
|
|
146
|
+
first.step(1_000, { demo: demo("failed", { highlight: HL }), waiting: null });
|
|
147
|
+
expect(first.modal("highlight")).toBeDefined();
|
|
148
|
+
first.closeX("highlight");
|
|
149
|
+
const again = page(store);
|
|
150
|
+
again.step(1_000, { demo: demo("failed", { highlight: HL }), waiting: null });
|
|
151
|
+
again.step(1_000);
|
|
152
|
+
expect(again.modal("highlight")).toBeUndefined();
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("a replay looping round forgets what was closed: its wait opens again", () => {
|
|
156
|
+
const k = page(session());
|
|
157
|
+
k.step(1_000, { demo: demo("pull-request", { at: "2026-10-18T00:00:10Z" }) });
|
|
158
|
+
k.closeX("waiting");
|
|
159
|
+
k.step(1_000);
|
|
160
|
+
expect(k.modal("waiting")).toBeUndefined();
|
|
161
|
+
k.step(1_000, { demo: demo("pull-request", { at: "2026-10-18T00:00:00Z" }) });
|
|
162
|
+
expect(k.modal("waiting")).toBeDefined();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("opens no story modal while a card's details popover is open; the one held back opens once it closes", () => {
|
|
166
|
+
const k = page(session(), { pop: { x: 600, y: 80, w: 412, h: 141 } });
|
|
167
|
+
for (let i = 0; i < 5; i++) k.step(1_000);
|
|
168
|
+
expect(k.modal("waiting")).toBeUndefined();
|
|
169
|
+
k.step(1_000, { demo: demo("failed", { highlight: HL }), waiting: null });
|
|
170
|
+
expect(k.modal("highlight")).toBeUndefined();
|
|
171
|
+
k.step(1_000, { pop: null });
|
|
172
|
+
expect(k.modal("highlight")).toBeDefined();
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
describe("a modal already up when the details popover opens", () => {
|
|
177
|
+
/** A box the size of a modal, in the middle of a 1366x768 window. */
|
|
178
|
+
const layoutDoc = () => {
|
|
179
|
+
const doc = fakeDoc();
|
|
180
|
+
doc.defaultView = { innerWidth: 1366, innerHeight: 768 };
|
|
181
|
+
const make = doc.createElement;
|
|
182
|
+
doc.createElement = (tag) => {
|
|
183
|
+
const n = make(tag);
|
|
184
|
+
n.getBoundingClientRect = () => ({ left: 383, top: 284, width: 600, height: 200 });
|
|
185
|
+
return n;
|
|
186
|
+
};
|
|
187
|
+
return doc;
|
|
188
|
+
};
|
|
189
|
+
const classes = (n) => n.classes;
|
|
190
|
+
it("moves clear of it, its sheet no longer over it", () => {
|
|
191
|
+
const doc = layoutDoc();
|
|
192
|
+
let keep = null;
|
|
193
|
+
const timers = [];
|
|
194
|
+
openEventModal(doc.body, { mode: "narrated", kind: "waiting", data: { title: "Waiting on the pipeline", lines: [], keepClear: () => keep }, doc, now: () => 0, setTimer: (fn) => timers.push(fn), clearTimer() {} });
|
|
195
|
+
const wrap = doc.body.children[0];
|
|
196
|
+
const box = wrap.children[0];
|
|
197
|
+
expect(classes(wrap).has("eh-modal-keep")).toBe(false);
|
|
198
|
+
// The popover opens under the middle of the window, where the modal stands; the modal's next tick moves it.
|
|
199
|
+
keep = { left: 500, top: 300, width: 300, height: 140 };
|
|
200
|
+
timers.forEach((fn) => fn());
|
|
201
|
+
expect(classes(wrap).has("eh-modal-keep")).toBe(true);
|
|
202
|
+
expect(classes(wrap).has("eh-modal-placed")).toBe(true);
|
|
203
|
+
const at = { left: Number.parseFloat(box.style.marginLeft), top: Number.parseFloat(box.style.marginTop), width: 600, height: 200 };
|
|
204
|
+
expect(coversRect(at, keep)).toBe(false);
|
|
205
|
+
expect(classes(wrap).has("eh-modal-yield")).toBe(false);
|
|
206
|
+
// It closes: the modal goes back to the middle.
|
|
207
|
+
keep = null;
|
|
208
|
+
timers.forEach((fn) => fn());
|
|
209
|
+
expect(classes(wrap).has("eh-modal-keep")).toBe(false);
|
|
210
|
+
expect(classes(wrap).has("eh-modal-placed")).toBe(false);
|
|
211
|
+
expect(box.style.marginLeft).toBe("");
|
|
212
|
+
});
|
|
213
|
+
it("steps out of sight, its time held, where no spot clears it", () => {
|
|
214
|
+
const doc = layoutDoc();
|
|
215
|
+
const keep = { left: 0, top: 0, width: 1366, height: 768 };
|
|
216
|
+
let now = 0;
|
|
217
|
+
const timers = [];
|
|
218
|
+
const m = openEventModal(doc.body, { mode: "narrated", kind: "highlight", data: { title: "h", lines: [], closeAfter: 1_000, keepClear: () => keep }, doc, now: () => now, setTimer: (fn) => timers.push(fn), clearTimer() {} });
|
|
219
|
+
const wrap = doc.body.children[0];
|
|
220
|
+
expect(classes(wrap).has("eh-modal-yield")).toBe(true);
|
|
221
|
+
now = 5_000;
|
|
222
|
+
timers.forEach((fn) => fn());
|
|
223
|
+
expect(m.state.closed).toBe(false);
|
|
224
|
+
expect(m.state.closedBy).toBeUndefined();
|
|
225
|
+
m.close();
|
|
226
|
+
expect(m.state.closedBy).toBe("page");
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
/** Just enough of a DOM for Tips and its modal (kiosk-highlight.test.js's, with a classList that keeps its classes). */
|
|
231
|
+
function fakeDoc() {
|
|
232
|
+
const listeners = {};
|
|
233
|
+
const make = (tag) => {
|
|
234
|
+
const classes = new Set();
|
|
235
|
+
const n = {
|
|
236
|
+
tagName: tag.toUpperCase(),
|
|
237
|
+
children: [],
|
|
238
|
+
handlers: {},
|
|
239
|
+
textContent: "",
|
|
240
|
+
dataset: {},
|
|
241
|
+
classes,
|
|
242
|
+
style: { setProperty() {} },
|
|
243
|
+
classList: {
|
|
244
|
+
toggle: (c, on) => ((on === undefined ? !classes.has(c) : on) ? classes.add(c) : classes.delete(c)),
|
|
245
|
+
add: (...cs) => cs.forEach((c) => classes.add(c)),
|
|
246
|
+
remove: (...cs) => cs.forEach((c) => classes.delete(c)),
|
|
247
|
+
contains: (c) => classes.has(c),
|
|
248
|
+
},
|
|
249
|
+
appendChild(c) {
|
|
250
|
+
c.parent = n;
|
|
251
|
+
n.children.push(c);
|
|
252
|
+
return c;
|
|
253
|
+
},
|
|
254
|
+
append(...cs) {
|
|
255
|
+
cs.forEach((c) => typeof c === "object" && n.appendChild(c));
|
|
256
|
+
},
|
|
257
|
+
prepend(c) {
|
|
258
|
+
n.appendChild(c);
|
|
259
|
+
},
|
|
260
|
+
replaceChildren() {
|
|
261
|
+
n.children = [];
|
|
262
|
+
},
|
|
263
|
+
setAttribute() {},
|
|
264
|
+
addEventListener(ev, fn) {
|
|
265
|
+
(n.handlers[ev] ||= []).push(fn);
|
|
266
|
+
},
|
|
267
|
+
querySelector: () => null,
|
|
268
|
+
remove() {
|
|
269
|
+
if (n.parent) n.parent.children = n.parent.children.filter((x) => x !== n);
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
// className is the classList's words, as the DOM's is.
|
|
273
|
+
Object.defineProperty(n, "className", { get: () => [...classes].join(" "), set: (v) => { classes.clear(); String(v).split(/\s+/).filter(Boolean).forEach((c) => classes.add(c)); } });
|
|
274
|
+
return n;
|
|
275
|
+
};
|
|
276
|
+
return {
|
|
277
|
+
createElement: make,
|
|
278
|
+
head: make("head"),
|
|
279
|
+
body: make("body"),
|
|
280
|
+
getElementById: () => null,
|
|
281
|
+
querySelectorAll: () => [],
|
|
282
|
+
addEventListener: (ev, fn) => ((listeners[ev] ||= []).push(fn)),
|
|
283
|
+
removeEventListener(ev, fn) {
|
|
284
|
+
listeners[ev] = (listeners[ev] || []).filter((x) => x !== fn);
|
|
285
|
+
},
|
|
286
|
+
fire: (ev, e) => (listeners[ev] || []).forEach((fn) => fn(e)),
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
const all = (n) => (n ? [n, ...n.children.flatMap(all)] : []);
|
|
290
|
+
const shelf = () => {
|
|
291
|
+
const m = new Map();
|
|
292
|
+
ehStore({ setItem: (k, v) => m.set(k, v) }, true);
|
|
293
|
+
return { getItem: (k) => (m.has(k) ? m.get(k) : null), setItem: (k, v) => m.set(k, v) };
|
|
294
|
+
};
|
package/web/kiosk-popover.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import { PICK_HOLD_MS } from "./kiosk-runs.js";
|
|
14
14
|
import { clock } from "./terragucci.js";
|
|
15
|
+
import { placeFloat } from "./float-place.js";
|
|
15
16
|
|
|
16
17
|
/** How many attribute lines the popover shows before "and N more". */
|
|
17
18
|
export const MAX_LINES = 6;
|
|
@@ -208,28 +209,11 @@ export function popReduce(s, ev, now) {
|
|
|
208
209
|
* that side, as near the card's top (or left) as the frame allows. When no
|
|
209
210
|
* side fits, the side with the most room, kept inside the frame. All boxes
|
|
210
211
|
* are `{ left, top, width, height }` in the frame's pixels.
|
|
212
|
+
* behold#764: the shared placement (web/float-place.js), so a card at the
|
|
213
|
+
* frame's very top never puts it off the top, and a popover taller than the
|
|
214
|
+
* frame gets `maxHeight` and scrolls.
|
|
211
215
|
*/
|
|
212
216
|
export function placePopover(card, pop, frame, { gap = 12, margin = 8 } = {}) {
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
const bottom = card.top + card.height;
|
|
216
|
-
const room = {
|
|
217
|
-
right: frame.width - margin - (right + gap),
|
|
218
|
-
left: card.left - gap - margin,
|
|
219
|
-
below: frame.height - margin - (bottom + gap),
|
|
220
|
-
above: card.top - gap - margin,
|
|
221
|
-
};
|
|
222
|
-
const at = (side) => {
|
|
223
|
-
if (side === "right") return { left: right + gap, top: clamp(card.top, margin, frame.height - margin - pop.height), side };
|
|
224
|
-
if (side === "left") return { left: card.left - gap - pop.width, top: clamp(card.top, margin, frame.height - margin - pop.height), side };
|
|
225
|
-
if (side === "below") return { left: clamp(card.left, margin, frame.width - margin - pop.width), top: bottom + gap, side };
|
|
226
|
-
return { left: clamp(card.left, margin, frame.width - margin - pop.width), top: card.top - gap - pop.height, side };
|
|
227
|
-
};
|
|
228
|
-
if (room.right >= pop.width) return at("right");
|
|
229
|
-
if (room.left >= pop.width) return at("left");
|
|
230
|
-
if (room.below >= pop.height) return at("below");
|
|
231
|
-
if (room.above >= pop.height) return at("above");
|
|
232
|
-
const best = Object.entries({ right: room.right / pop.width, left: room.left / pop.width, below: room.below / pop.height, above: room.above / pop.height }).sort((a, b) => b[1] - a[1])[0][0];
|
|
233
|
-
const p = at(best);
|
|
234
|
-
return { left: clamp(p.left, margin, frame.width - margin - pop.width), top: clamp(p.top, margin, frame.height - margin - pop.height), side: best };
|
|
217
|
+
const view = { left: frame.left || 0, top: frame.top || 0, width: frame.width, height: frame.height };
|
|
218
|
+
return placeFloat(card, pop, view, { gap, margin });
|
|
235
219
|
}
|
package/web/kiosk-watch.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { STEP_WORDS, focusRoots, matchingPull, matchingRun, scenarioHead, introText, aboutRows, nextWords, demoStage } from "./kiosk.js";
|
|
15
15
|
import { defaultJob, defaultStep, logLineWords, setupLine } from "./kiosk-runs.js";
|
|
16
16
|
import { backendLine, coneLine, coneOf } from "./cone.js";
|
|
17
|
+
import { placeFloat } from "./float-place.js";
|
|
17
18
|
|
|
18
19
|
/** The two modes, Watch first: it is the default. */
|
|
19
20
|
export const MODES = [
|
|
@@ -356,20 +357,26 @@ export function tailLines(runDoc, n = 2) {
|
|
|
356
357
|
/**
|
|
357
358
|
* Where an overlay of `size` goes beside `box` inside `view` (all pixels,
|
|
358
359
|
* `{x, y, w, h}`): to the right of the box when it fits, else to its left,
|
|
359
|
-
* else under it; its top level with the box's, kept inside the
|
|
360
|
-
* right it moves past any of `avoid` (the reads' labels) it
|
|
361
|
-
* `{ x, y, side }`, `side` "right", "left" or "
|
|
360
|
+
* else under it, else over it; its top level with the box's, kept inside the
|
|
361
|
+
* view. On the right it moves past any of `avoid` (the reads' labels) it
|
|
362
|
+
* would cover. `{ x, y, side }`, `side` "right", "left", "below" or "above".
|
|
363
|
+
* behold#764: never past the view's top or bottom. The job box's log drawer,
|
|
364
|
+
* opened, is taller than the graph above the caption at 1366x768, and was
|
|
365
|
+
* lifted 94px off the top; now it keeps the view's top, with `maxHeight` (the
|
|
366
|
+
* caller caps it there and its log scrolls) when it is taller than the view.
|
|
367
|
+
* No side with room: the side with the most (web/float-place.js).
|
|
362
368
|
*/
|
|
363
369
|
export function placeBeside(box, size, view, gap = 18, avoid = []) {
|
|
364
|
-
const
|
|
370
|
+
const fit = placeFloat({ left: box.x, top: box.y, width: box.w, height: box.h }, { width: size.w, height: size.h }, { left: view.x, top: view.y, width: view.w, height: view.h }, { sides: ["left", "below", "above", "right"], gap, margin: 8 });
|
|
371
|
+
const cap = fit.maxHeight ? { maxHeight: fit.maxHeight } : {};
|
|
372
|
+
const h = fit.maxHeight || size.h;
|
|
373
|
+
const top = Math.max(view.y + 8, Math.min(box.y, view.y + view.h - h - 8));
|
|
365
374
|
// Clear of the graph's own labels beside the box: past the right edge of any it would cover.
|
|
366
|
-
const over = (x) => avoid.filter((a) => a.x < x + size.w && a.x + a.w > x && a.y < top +
|
|
375
|
+
const over = (x) => avoid.filter((a) => a.x < x + size.w && a.x + a.w > x && a.y < top + h && a.y + a.h > top);
|
|
367
376
|
let right = box.x + box.w + gap;
|
|
368
377
|
for (let i = 0; i < 4 && over(right).length; i++) right = Math.max(...over(right).map((a) => a.x + a.w)) + gap / 2;
|
|
369
|
-
if (right + size.w <= view.x + view.w - 8) return { x: right, y: top, side: "right" };
|
|
370
|
-
|
|
371
|
-
const x = Math.max(view.x + 8, Math.min(box.x, view.x + view.w - size.w - 8));
|
|
372
|
-
return { x, y: Math.min(box.y + box.h + gap, view.y + view.h - size.h - 8), side: "below" };
|
|
378
|
+
if (right + size.w <= view.x + view.w - 8) return { x: right, y: top, side: "right", ...cap };
|
|
379
|
+
return { x: fit.left, y: fit.top, side: fit.side, ...cap };
|
|
373
380
|
}
|
|
374
381
|
|
|
375
382
|
// ---------------------------------------------------------------------------
|
package/web/kiosk.html
CHANGED
|
@@ -353,6 +353,8 @@
|
|
|
353
353
|
.k-what { font: 600 0.92em var(--font-ui); color: var(--pending); background: transparent; border: 0; padding: 0.1em 0.2em; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
|
|
354
354
|
#k-what-pop { position: absolute; top: 1.8em; right: 0; width: min(34em, calc(100vw - 32px)); padding: var(--s3) var(--s4); background: var(--surface-pane-b); color: var(--fg); border: 1px solid var(--focus);
|
|
355
355
|
border-radius: 8px; box-shadow: 0 6px 24px color-mix(in srgb, var(--shadow) 70%, transparent); font-size: 1.15em; line-height: 1.45; }
|
|
356
|
+
/* behold#764: never past the window's bottom on a short screen: it scrolls. */
|
|
357
|
+
#k-what-pop { max-height: calc(100vh - 4em); overflow-y: auto; overscroll-behavior: contain; }
|
|
356
358
|
#k-what-pop[hidden] { display: none; }
|
|
357
359
|
#k-what-pop p { margin: 0; }
|
|
358
360
|
#k-what-pop .k-what-more { margin-top: var(--s2); }
|
|
@@ -518,7 +520,13 @@
|
|
|
518
520
|
.k-notch { position: absolute; width: 14px; height: 14px; background: inherit; border: inherit; transform: rotate(45deg); top: 1.4em; }
|
|
519
521
|
.k-side-right > .k-notch { left: -9px; border-top: 0; border-right: 0; }
|
|
520
522
|
.k-side-left > .k-notch { right: -9px; border-bottom: 0; border-left: 0; }
|
|
521
|
-
.k-side-below > .k-notch { display: none; }
|
|
523
|
+
.k-side-below > .k-notch, .k-side-above > .k-notch { display: none; }
|
|
524
|
+
/* behold#764: an overlay taller than the graph's view is capped (placeBeside's maxHeight, .k-capped): the callout and
|
|
525
|
+
the result scroll (their notch goes: a scroller clips it), the drawer's log shrinks to fit and scrolls. */
|
|
526
|
+
.k-over.k-capped { overflow-y: auto; overscroll-behavior: contain; }
|
|
527
|
+
.k-over.k-capped > .k-notch { display: none; }
|
|
528
|
+
#k-drawer.k-capped { overflow: hidden; }
|
|
529
|
+
#k-drawer.k-open .k-drawer-body { flex: 1 1 auto; }
|
|
522
530
|
/* The running job's log, a drawer from the active wave's box: folded to its last lines, open on a hover or a click. */
|
|
523
531
|
#k-drawer { width: min(34em, 46vw); background: var(--surface-pane-a); border: 2px solid color-mix(in srgb, var(--pending) 80%, var(--fg)); border-radius: 10px; box-shadow: 0 10px 34px color-mix(in srgb, var(--shadow) 75%, transparent); display: flex; flex-direction: column; }
|
|
524
532
|
.k-drawer-head { display: flex; align-items: center; gap: var(--s3); width: 100%; padding: var(--s3) var(--s4) var(--s1); background: transparent; border: 0; color: var(--fg); cursor: pointer; text-align: left; font: inherit; }
|
package/web/kiosk.js
CHANGED
|
@@ -2013,6 +2013,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2013
2013
|
const carvingNow = shownCaption() !== watch.caption || !!s.stageHeld;
|
|
2014
2014
|
const put = (node, n) => {
|
|
2015
2015
|
if (node.hidden) return;
|
|
2016
|
+
// behold#764: measured at its own height, then capped to the view (placeBeside's maxHeight); its body scrolls.
|
|
2017
|
+
node.style.maxHeight = "";
|
|
2016
2018
|
const size = { w: node.offsetWidth, h: node.offsetHeight };
|
|
2017
2019
|
const box = carvingNow ? null : boxOf(n);
|
|
2018
2020
|
// Before the frame says where the box is: the right of the view, under its top.
|
|
@@ -2021,13 +2023,16 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2021
2023
|
const labels = [...((s.boxes && s.boxes.labels) || []).map((r) => ({ x: r.x + view.x, y: r.y + view.y, w: r.w, h: r.h })), chrome];
|
|
2022
2024
|
const p = box ? placeBeside(box, size, view, 18, labels) : { x: view.x + view.w - size.w - 20, y: view.y + FRAME_CONTROLS.h + 8, side: "below" };
|
|
2023
2025
|
// The result card stands level with the middle of the graph it sums up.
|
|
2024
|
-
|
|
2026
|
+
const h = p.maxHeight || size.h;
|
|
2027
|
+
node.style.maxHeight = p.maxHeight ? `${Math.floor(p.maxHeight)}px` : "";
|
|
2028
|
+
node.classList.toggle("k-capped", !!p.maxHeight);
|
|
2029
|
+
if (box && node === watch.result) p.y = Math.max(view.y + 8, Math.min(box.y + box.h / 2 - h / 2, view.y + view.h - h - 8));
|
|
2025
2030
|
node.style.transform = `translate(${Math.round(p.x)}px, ${Math.round(p.y)}px)`;
|
|
2026
|
-
for (const k of ["right", "left", "below"]) node.classList.toggle(`k-side-${k}`, p.side === k);
|
|
2031
|
+
for (const k of ["right", "left", "below", "above"]) node.classList.toggle(`k-side-${k}`, p.side === k);
|
|
2027
2032
|
node.classList.add("k-placed");
|
|
2028
2033
|
const notch = node.querySelector(":scope > .k-notch");
|
|
2029
|
-
if (notch && box) notch.style.top = `${Math.round(Math.max(12, Math.min(
|
|
2030
|
-
taken.push({ x: p.x, y: p.y, x2: p.x + size.w, y2: p.y +
|
|
2034
|
+
if (notch && box) notch.style.top = `${Math.round(Math.max(12, Math.min(h - 26, box.y + 22 - p.y)))}px`;
|
|
2035
|
+
taken.push({ x: p.x, y: p.y, x2: p.x + size.w, y2: p.y + h });
|
|
2031
2036
|
};
|
|
2032
2037
|
put(watch.callout, s.held);
|
|
2033
2038
|
put(watch.drawer, drawerWave !== null ? drawerWave : s.shot && s.shot.waves[0]);
|
|
@@ -2056,6 +2061,13 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2056
2061
|
window.addEventListener("message", (e) => {
|
|
2057
2062
|
if (e.origin !== origin || !frame || e.source !== frame.contentWindow || !e.data) return;
|
|
2058
2063
|
if (e.data.type === "behold:viewer") return holdShot();
|
|
2064
|
+
// behold#764: the frame's card details popover opened, moved or closed: a modal yields to it, and one held back opens after.
|
|
2065
|
+
if (e.data.type === "behold:pop") {
|
|
2066
|
+
const a = e.data.at;
|
|
2067
|
+
s.framePop = a && [a.x, a.y, a.w, a.h].every(Number.isFinite) ? { x: a.x, y: a.y, w: a.w, h: a.h } : null;
|
|
2068
|
+
if (ehApi) ehApi.tick();
|
|
2069
|
+
return;
|
|
2070
|
+
}
|
|
2059
2071
|
if (e.data.type !== "behold:boxes") return;
|
|
2060
2072
|
s.boxes = e.data;
|
|
2061
2073
|
// A held small stage: nothing the step shows overlays the graph (watchOverlays), and a drawer the viewer opens
|
|
@@ -2113,6 +2125,14 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2113
2125
|
? startEventHelp({
|
|
2114
2126
|
doc: document,
|
|
2115
2127
|
store: shelf,
|
|
2128
|
+
// behold#764: the story modals a viewer closes, for this visit only (never localStorage).
|
|
2129
|
+
session: (() => {
|
|
2130
|
+
try {
|
|
2131
|
+
return typeof sessionStorage !== "undefined" ? sessionStorage : null;
|
|
2132
|
+
} catch {
|
|
2133
|
+
return null;
|
|
2134
|
+
}
|
|
2135
|
+
})(),
|
|
2116
2136
|
switchHost: eh.switchHost,
|
|
2117
2137
|
trailHost: eh.trailHost,
|
|
2118
2138
|
tipsHost: eh.tipsHost,
|
|
@@ -2152,6 +2172,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2152
2172
|
// which the approval card beside the graph wins over.
|
|
2153
2173
|
hideTrail: !!(storyOn(s) && s.trackOn && s.watchMode),
|
|
2154
2174
|
waiting: storyOn(s) && s.watchMode && !(watch && watch.callout && !watch.callout.hidden) ? s.waitingNow || null : null,
|
|
2175
|
+
// behold#764: the card's details popover the frame has open (`behold:pop`), which no modal covers.
|
|
2176
|
+
pop: s.framePop || null,
|
|
2155
2177
|
frame,
|
|
2156
2178
|
watch: s.watchMode,
|
|
2157
2179
|
// The caption shown now: the live carve's while it has the camera (web/kiosk-carve.js).
|
|
@@ -2560,6 +2582,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2560
2582
|
buffer = null;
|
|
2561
2583
|
frameDrawn = true;
|
|
2562
2584
|
s.boxes = null;
|
|
2585
|
+
s.framePop = null; // behold#764: the old frame's details popover went with it
|
|
2563
2586
|
lastFocus = undefined;
|
|
2564
2587
|
tellFrame(true);
|
|
2565
2588
|
tellShot(true);
|
package/web/tooltip.js
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
// its words go into the shared tooltip; they go back when the pointer or the
|
|
11
11
|
// focus leaves. An HTML element can ask for the tooltip with data-tip.
|
|
12
12
|
|
|
13
|
+
import { shiftInto } from "./float-place.js";
|
|
14
|
+
|
|
13
15
|
export const TIP_ID = "b-tip";
|
|
14
16
|
/** The room between the tooltip and what it describes, and between it and the window's edge, in px. */
|
|
15
17
|
export const TIP_GAP = 8;
|
|
@@ -29,8 +31,9 @@ export function placeTip(target, size, view, { gap = TIP_GAP, margin = TIP_MARGI
|
|
|
29
31
|
const side = fitsBelow || above < margin ? "below" : "above";
|
|
30
32
|
const top = side === "below" ? below : above;
|
|
31
33
|
const centred = (target.left + target.right) / 2 - size.width / 2;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
// behold#764: inside the window on every side (web/float-place.js), its bottom too when it fits neither way.
|
|
35
|
+
const { dx, dy } = shiftInto({ left: centred, top, width: size.width, height: size.height }, { left: 0, top: 0, width: view.width, height: view.height }, margin);
|
|
36
|
+
return { left: Math.round(centred + dx), top: Math.round(top + dy), side };
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
/** An id list (aria-describedby) with `id` in it once. */
|