create-pmos 0.442.0 → 0.444.0
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 +25 -25
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-board-test.js +8 -2
- package/workspace/briefing-premium-insights-test.js +40 -38
- package/workspace/briefing-premium-test.js +2 -1
- package/workspace/changelog.json +24 -0
- package/workspace/goals-clear-ui-test.js +263 -0
- package/workspace/guide/home.md +12 -2
- package/workspace/guide/metric-drafts.md +8 -2
- package/workspace/home-railcard-test.js +193 -0
- package/workspace/intel-report-ui-test.js +1 -1
- package/workspace/intelligence-gaps-ui-test.js +16 -14
- package/workspace/lib/board-premium.js +1 -1
- package/workspace/lib/engine/boards.js +9 -2
- package/workspace/lib/engine/records/index.js +9 -2
- package/workspace/lib/initiative-layout.js +3 -1
- package/workspace/lib/insights-premium.js +22 -1
- package/workspace/lib/metric-drafts.js +37 -10
- package/workspace/lib/metric-read-runs.js +20 -13
- package/workspace/lib/metric-reads.js +208 -23
- package/workspace/lib/metrics-cli.js +62 -5
- package/workspace/lib/routes-boards.js +40 -1
- package/workspace/lib/routes-goal-status.js +89 -6
- package/workspace/lib/routes-insights-premium.js +1 -1
- package/workspace/lib/routes-metric-drafts.js +26 -3
- package/workspace/live-pill-round-test.js +178 -0
- package/workspace/metric-drafts-ui-test.js +5 -2
- package/workspace/okr-goals-ui-test.js +27 -23
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +231 -0
- package/workspace/premium-board-actions-test.js +2 -2
- package/workspace/premium-rec-tab-test.js +2 -1
- package/workspace/premium-vw-item-test.js +10 -2
- package/workspace/premium-vw-jira-test.js +3 -0
- package/workspace/public/pm/bd-ini-panel.js +3 -2
- package/workspace/public/pm/cozy-adler.js +21 -0
- package/workspace/public/pm/cozy-divider.css +32 -0
- package/workspace/public/pm/cozy-divider.js +45 -0
- package/workspace/public/pm/cozy-insights.css +96 -0
- package/workspace/public/pm/cozy-live-pill.css +16 -17
- package/workspace/public/pm/cozy-live-pill.js +28 -17
- package/workspace/public/pm/cozy-panels.css +59 -0
- package/workspace/public/pm/cozy-panels.js +524 -0
- package/workspace/public/pm/cozy-today.css +15 -0
- package/workspace/public/pm/cozy-viewer.js +173 -69
- package/workspace/public/pm/cozy-vw-shell.css +4 -0
- package/workspace/public/pm/goals-clear.js +265 -0
- package/workspace/public/pm/home-app.js +73 -14
- package/workspace/public/pm/home-ini.js +9 -3
- package/workspace/public/pm/home-today.js +55 -12
- package/workspace/public/pm/ini-edit.js +401 -0
- package/workspace/public/pm/ini-groups.js +14 -8
- package/workspace/public/pm/ini-tasks.js +84 -26
- package/workspace/public/pm/ini-versions.js +18 -4
- package/workspace/public/pm/ini-view-model.js +45 -18
- package/workspace/public/pm/ini-view.css +117 -5
- package/workspace/public/pm/ini-view.js +51 -17
- package/workspace/public/pm/metric-drafts.js +4 -1
- package/workspace/public/pm/mission.js +11 -7
- package/workspace/public/pm/premium-board.js +8 -6
- package/workspace/public/pm/premium-insights.js +375 -59
- package/workspace/public/pm/task-card.css +2 -0
- package/workspace/public/pm/task-card.js +4 -1
- package/workspace/server.js +6 -2
- package/workspace/skills/metric-read.skill +7 -5
- package/workspace/stage-card-tasks-test.js +396 -0
- package/workspace/stage-card-test.js +12 -4
- package/workspace/task-delete-test.js +9 -1
- package/workspace/task-milestones-test.js +3 -3
- package/workspace/task-press-test.js +12 -4
- package/workspace/task-views-test.js +198 -5
- package/workspace/test-lists/batch18-live-pill-round.json +10 -0
- package/workspace/test-lists/batch18-panels.json +9 -0
- package/workspace/test-lists/goals-clear.json +15 -0
- package/workspace/test-lists/home-railcard.json +9 -0
- package/workspace/test-lists/stage-card-tasks.json +6 -0
- package/workspace/tk-tasks-test.js +2 -2
|
@@ -67,7 +67,8 @@
|
|
|
67
67
|
* word press, only where a decision has two answers (Return it | Keep it as is).
|
|
68
68
|
* czSections([{ id, title, count, open, render | html, tail? }], { key }) → the folding rows. A row folds and unfolds in place, and the fold
|
|
69
69
|
* is remembered per key and id (localStorage, a private window forgets it). render(): a string of markup, called once when drawn.
|
|
70
|
-
* widthOf(kind) · setWidth(px) · wide(on?) · railOn() for the page and the tests
|
|
70
|
+
* widthOf(kind) · setWidth(px) · wide(on?) · railOn() for the page and the tests; railCard(fn) · railSync(key?) · keepWide() for a page
|
|
71
|
+
* that draws a card for a rail tile (Home).
|
|
71
72
|
* The look is in cozy-vw-shell.css (loaded here once) over cozy.css (.cz-vw…). The old #dlg path (premium-viewer.js) is separate. */
|
|
72
73
|
import { czPlaceholder } from './cozy-placeholder.js';
|
|
73
74
|
|
|
@@ -97,7 +98,7 @@ const P = {
|
|
|
97
98
|
add: 'M12 5v14M5 12h14', back: 'M14 6l-6 6 6 6', more: 'M5 12h.01M12 12h.01M19 12h.01', close: 'M6 6l12 12M18 6L6 18',
|
|
98
99
|
wide: 'M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7', side: 'M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7',
|
|
99
100
|
chat: 'M5 6.5A2.5 2.5 0 0 1 7.5 4h9A2.5 2.5 0 0 1 19 6.5v7a2.5 2.5 0 0 1-2.5 2.5H11l-4 3.5V16h.5A2.5 2.5 0 0 1 5 13.5z',
|
|
100
|
-
fwd: 'M10 6l6 6-6 6', home: 'M4 11l8-7 8 7v9H4z', tab: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', chev: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5', list: 'M3.5 4.5h17v15h-17zM14 4.5v15',
|
|
101
|
+
place: 'M3.5 5h17v14h-17zM12 5v14', fwd: 'M10 6l6 6-6 6', home: 'M4 11l8-7 8 7v9H4z', tab: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', chev: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5', list: 'M3.5 4.5h17v15h-17zM14 4.5v15',
|
|
101
102
|
};
|
|
102
103
|
export const PHONE = 760;
|
|
103
104
|
const NARROW = 1100, MIN = 420, CHAT = 360, RAIL = 64, MAXF = 0.7, W2 = 760, FLOAT = 560;
|
|
@@ -112,7 +113,35 @@ const isPhone = () => typeof innerWidth === 'number' && innerWidth <= PHONE;
|
|
|
112
113
|
const onHome = () => typeof document !== 'undefined' && !!document.body && document.body.classList.contains('cz-home');
|
|
113
114
|
const kindKey = (k) => String(k || 'item').trim().toLowerCase().replace(/^file · .*/, 'file').replace(/[^a-z0-9]+/g, '-').slice(0, 40) || 'item';
|
|
114
115
|
|
|
115
|
-
|
|
116
|
+
/* Several Viewers (batch 18 item 15, canvas TbT6TwoViewers, TbT8Wide): each is one instance. V is the instance in use: the one a press, a
|
|
117
|
+
* key or the last open() went to, so the exported API always speaks of the Viewer used last. G is what the page has once: its list's rail,
|
|
118
|
+
* the listeners, the rail's card. Only the first instance (#czViewer) writes the browser history; another keeps its own ← → trail.
|
|
119
|
+
* Without cozy-panels.js (Board, Intelligence) the limit stays 1 and there is one Viewer, as before. */
|
|
120
|
+
const G = { subs: [], card: null, railKey: null, rail: false, lw: 0, hold: 0, tick: 0, limit: 1, beside: null, place: null, managed: null };
|
|
121
|
+
const mk = (i) => ({ i, el: null, cur: null, back: null, stack: [], fwd: [], wide: false, w: 0, drill: false, over: false, used: 0, ph: false, via: '' });
|
|
122
|
+
let V = mk(0);
|
|
123
|
+
const ALL = [V];
|
|
124
|
+
const shown = (x) => !!(x && x.el && !x.el.hidden && x.cur);
|
|
125
|
+
/** The open Viewer used last (or null). */
|
|
126
|
+
const mru = () => ALL.filter(shown).sort((a, b) => b.used - a.used)[0] || null;
|
|
127
|
+
/** A press, a key or an open on this instance: it is the one in use now. */
|
|
128
|
+
function use(x) { V = x; x.used = ++G.tick; return x; }
|
|
129
|
+
/** Run fn on instance x without making it the one used last (a resize). */
|
|
130
|
+
function on(x, fn) { const was = V; V = x; try { return fn(); } finally { V = was; } }
|
|
131
|
+
/** Where an open() goes: a drop beside (cozy-panels.js) takes a free instance, a new one under the limit, else the least recently used;
|
|
132
|
+
* a press inside a Viewer drills in that Viewer; anything else replaces the Viewer used last. */
|
|
133
|
+
function pick(o) {
|
|
134
|
+
const b = G.beside; G.beside = null;
|
|
135
|
+
if (b && Date.now() - b.t < 6000) {
|
|
136
|
+
const free = ALL.find((x) => !shown(x));
|
|
137
|
+
if (free) return free;
|
|
138
|
+
if (ALL.length < G.limit) { const n = mk(ALL.length); ALL.push(n); return n; }
|
|
139
|
+
return ALL.filter(shown).sort((a, c) => a.used - c.used)[0];
|
|
140
|
+
}
|
|
141
|
+
const p = H.press && Date.now() - H.press.t < 10000 ? H.press : null;
|
|
142
|
+
if (p && p.inst && shown(p.inst) && !o.fresh) return p.inst;
|
|
143
|
+
return mru() || ALL[0];
|
|
144
|
+
}
|
|
116
145
|
|
|
117
146
|
/** "PRD" over "PRD", or "File · plans/x.md" over "x.md": the kind is left out when it only repeats the title */
|
|
118
147
|
const sameAs = (kind, title) => { const k = String(kind || '').trim().toLowerCase().replace(/^file · /, ''), t = String(title || '').trim().toLowerCase(); return !!t && (k === t || k.split('/').pop() === t || k.split('/').pop().replace(/\.[a-z]+$/, '') === t); };
|
|
@@ -147,7 +176,9 @@ export function headHtml(it) {
|
|
|
147
176
|
: `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`)
|
|
148
177
|
+ (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title${chip ? ' has-chip' : ''}${o.wrap ? ' wrap' : ''}" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : chip ? `<span class="cz-vw-tt">${esc(o.title || '')}</span>` : esc(o.title || '')}${chip}</h3>${sub}</div>`)
|
|
149
178
|
+ disc + own + add + more
|
|
150
|
-
|
|
179
|
+
// ⧉ (batch 18 item 15, TbT7Place): where a page arranges panels, one placement press takes the place of ⤢ (Full screen is in it)
|
|
180
|
+
+ (phone ? '' : o.place ? ib('place', 'Arrange', P.place, ' aria-haspopup="menu" aria-expanded="false"')
|
|
181
|
+
: ib('wide', o.isWide ? 'Back to the side' : 'Open wide', o.isWide ? P.side : P.wide, ` aria-pressed="${o.isWide ? 'true' : 'false'}"`))
|
|
151
182
|
+ (phone ? '' : `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close">${svg(P.close, 18)}</button>`);
|
|
152
183
|
}
|
|
153
184
|
|
|
@@ -220,7 +251,7 @@ function room() {
|
|
|
220
251
|
const desk = host.parentNode, cs = getComputedStyle(desk);
|
|
221
252
|
const inner = desk.clientWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);
|
|
222
253
|
const gap = parseFloat(cs.columnGap || cs.gap) || 0;
|
|
223
|
-
const list = listEl(), lw = list && list.parentNode === desk && !
|
|
254
|
+
const list = listEl(), lw = list && list.parentNode === desk && !G.rail ? list.offsetWidth : list && list.parentNode === desk ? (G.lw || 316) : 0;
|
|
224
255
|
const right = inner - (lw ? lw + gap : 0);
|
|
225
256
|
const side = right - gap - CHAT;
|
|
226
257
|
const wideMax = Math.min(Math.round(innerWidth * MAXF), inner - (list ? RAIL + gap : 0) - gap - CHAT);
|
|
@@ -229,41 +260,70 @@ function room() {
|
|
|
229
260
|
export const widthOf = (kind) => { const n = parseInt(store.get('cz-vw-w:' + kindKey(kind)) || '', 10); return n > 0 ? n : null; };
|
|
230
261
|
function setRail(on) {
|
|
231
262
|
const list = listEl();
|
|
232
|
-
if (!on && !
|
|
233
|
-
if (on && !
|
|
234
|
-
|
|
235
|
-
|
|
263
|
+
if (!on && !G.rail) return;
|
|
264
|
+
if (on && !G.rail && list) G.lw = list.offsetWidth;
|
|
265
|
+
const was = G.rail;
|
|
266
|
+
G.rail = !!on && !!list;
|
|
267
|
+
document.body.classList.toggle('cz-vw-rail', G.rail);
|
|
268
|
+
if (!G.rail) G.railKey = null;
|
|
269
|
+
if (was !== G.rail) document.dispatchEvent(new CustomEvent('cz:vw-rail', { detail: { on: G.rail } })); // a page's rail card closes with the rail
|
|
236
270
|
if (!list) return;
|
|
237
271
|
let bar = list.querySelector(':scope > .cz-vw-railbar');
|
|
238
|
-
if (!
|
|
272
|
+
if (!G.rail) { if (bar) bar.remove(); return; }
|
|
239
273
|
if (!bar) {
|
|
240
274
|
bar = document.createElement('div'); bar.className = 'cz-vw-railbar';
|
|
241
275
|
bar.innerHTML = `<button type="button" class="cz-vw-ib" data-cz-vw-rail="show" aria-label="Show the list" title="Show the list">${svg(P.list, 18)}</button><div class="cz-vw-railtiles"></div>`;
|
|
242
276
|
bar.addEventListener('click', (e) => {
|
|
243
277
|
const b = e.target.closest('[data-cz-vw-rail]'); if (!b) return;
|
|
278
|
+
if (b.dataset.czVwRail === 'show' && G.managed && ALL.some((x) => shown(x) && G.managed('v' + x.i))) { setRail(false); return; } // cozy-panels.js lays it out
|
|
244
279
|
if (b.dataset.czVwRail === 'show') { V.wide = false; apply(Math.min(V.w, sideMax())); redraw(); return; }
|
|
245
|
-
// a group's tile: the
|
|
280
|
+
// a group's tile: the page's card of that group's rows, beside the tile (batch 18 item 14, FlA1); the rail and the Viewer stay
|
|
281
|
+
if (G.card) { G.card(b.dataset.czVwRail, b, e.detail === 0); return; }
|
|
282
|
+
// a page without a card: the list comes back, at that group
|
|
246
283
|
const src = list.querySelector('[data-cz-rail-tile="' + CSS.escape(b.dataset.czVwRail) + '"]');
|
|
247
284
|
V.wide = false; apply(Math.min(V.w, sideMax())); redraw();
|
|
248
285
|
if (src && src.scrollIntoView) src.scrollIntoView({ block: 'nearest' });
|
|
249
286
|
});
|
|
250
287
|
list.prepend(bar);
|
|
251
288
|
}
|
|
252
|
-
|
|
253
|
-
const tiles = [...list.querySelectorAll('[data-cz-rail-tile]')].slice(0, 8);
|
|
254
|
-
const box = bar.querySelector('.cz-vw-railtiles'); box.innerHTML = '';
|
|
255
|
-
tiles.forEach((t) => { // a copy of the tile itself (its tint, initials and dot), in a press that names the group
|
|
256
|
-
const nm = t.dataset.czRailName || t.textContent.trim();
|
|
257
|
-
const btn = document.createElement('button'); btn.type = 'button'; btn.className = 'cz-vw-railtile'; btn.dataset.czVwRail = t.dataset.czRailTile;
|
|
258
|
-
btn.setAttribute('aria-label', 'Show the list at ' + nm); btn.title = nm;
|
|
259
|
-
const c = t.cloneNode(true); c.removeAttribute('data-cz-rail-tile'); c.removeAttribute('data-cz-rail-name'); btn.appendChild(c); box.appendChild(btn);
|
|
260
|
-
});
|
|
289
|
+
railTiles(list, bar);
|
|
261
290
|
}
|
|
291
|
+
/** The rail's tiles: the groups of the list mark their tile with data-cz-rail-tile="<id>" and data-cz-rail-name, and the rail shows those
|
|
292
|
+
* tiles, nothing else. data-cz-rail-here: that group holds what is open, and its tile gets a blue bar (batch 18 item 14, FlA4After). */
|
|
293
|
+
function railTiles(list, bar) {
|
|
294
|
+
const tiles = [...list.querySelectorAll('[data-cz-rail-tile]')].slice(0, 8);
|
|
295
|
+
const box = bar.querySelector('.cz-vw-railtiles');
|
|
296
|
+
const sig = tiles.map((t) => t.outerHTML).join('') + '|' + !!G.card;
|
|
297
|
+
if (box.__sig !== sig) {
|
|
298
|
+
box.__sig = sig; box.innerHTML = '';
|
|
299
|
+
tiles.forEach((t) => { // a copy of the tile itself (its tint, initials and dot), in a press that names the group
|
|
300
|
+
const nm = t.dataset.czRailName || t.textContent.trim(), here = t.hasAttribute('data-cz-rail-here');
|
|
301
|
+
const btn = document.createElement('button'); btn.type = 'button'; btn.className = 'cz-vw-railtile' + (here ? ' here' : ''); btn.dataset.czVwRail = t.dataset.czRailTile;
|
|
302
|
+
btn.setAttribute('aria-label', (G.card ? nm + (here ? ' (open)' : '') + '. Show its initiatives' : 'Show the list at ' + nm)); btn.title = nm;
|
|
303
|
+
if (G.card) btn.setAttribute('aria-haspopup', 'dialog');
|
|
304
|
+
const c = t.cloneNode(true); c.removeAttribute('data-cz-rail-tile'); c.removeAttribute('data-cz-rail-name'); c.removeAttribute('data-cz-rail-here'); btn.appendChild(c); box.appendChild(btn);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
box.querySelectorAll('.cz-vw-railtile').forEach((b) => { const on = b.dataset.czVwRail === G.railKey; b.classList.toggle('on', on); if (G.card) b.setAttribute('aria-expanded', String(on)); });
|
|
308
|
+
}
|
|
309
|
+
/** A page that draws a card for a rail tile (Home): fn(key, tile, byKey) on a tile's press, in place of bringing the list back. */
|
|
310
|
+
export function railCard(fn) { G.card = typeof fn === 'function' ? fn : null; railSync(); }
|
|
311
|
+
/** The tile whose card is open (null: none): its ring and aria-expanded. The page calls it after a redraw of its list, so the rail's tiles
|
|
312
|
+
* follow the list (a new "here" bar, a dot). */
|
|
313
|
+
export function railSync(key) {
|
|
314
|
+
if (key !== undefined) G.railKey = key || null;
|
|
315
|
+
const list = listEl(), bar = G.rail && list && list.querySelector(':scope > .cz-vw-railbar');
|
|
316
|
+
if (bar) railTiles(list, bar);
|
|
317
|
+
}
|
|
318
|
+
/** The next open() keeps the Viewer as wide as it is and the rail folded (a pick from the rail's card, FlA4After). */
|
|
319
|
+
export function keepWide() { G.hold = Date.now() + 2000; }
|
|
262
320
|
const sideMax = () => { const r = room(); return r.float ? r.side : Math.max(MIN, r.side); };
|
|
263
321
|
/** Set the width in px: past what the chat leaves, the list folds to a rail first; never under 420 or over about 70%. */
|
|
264
322
|
function apply(px) {
|
|
265
323
|
const el = V.el; if (!el) return;
|
|
266
324
|
if (isPhone()) { el.style.width = ''; el.style.flexBasis = ''; el.classList.remove('cz-vw-w2'); setRail(false); return; }
|
|
325
|
+
// cozy-panels.js lays the panels out itself (two Viewers, a Viewer full or sliding over): it sizes this one, the rail is its own call
|
|
326
|
+
if (G.managed && G.managed('v' + V.i)) { el.style.width = ''; el.classList.toggle('cz-vw-w2', el.offsetWidth >= W2); return; } // its flex is the engine's; V.w keeps the width beside the chat
|
|
267
327
|
let r = room();
|
|
268
328
|
// a host that keeps its list (Home, HbCNarrow): with no room beside the chat the Viewer lies over the chat, at most the room right of the list
|
|
269
329
|
const over = !r.float && r.hasList && r.side < MIN && !V.wide && !!(el.parentNode && el.parentNode.hasAttribute('data-cz-vw-overlay'));
|
|
@@ -277,7 +337,7 @@ function apply(px) {
|
|
|
277
337
|
const fold = Math.min(r.side, Math.max(MIN, r.def));
|
|
278
338
|
if (w > fold && r.hasList && r.wideMax > fold) { setRail(true); r = room(); w = Math.min(w, r.wideMax); }
|
|
279
339
|
else if (r.side >= MIN && w <= fold && !V.wide) { setRail(false); r = room(); w = Math.min(w, Math.max(MIN, r.side)); }
|
|
280
|
-
else w = Math.min(w, Math.max(MIN,
|
|
340
|
+
else w = Math.min(w, Math.max(MIN, G.rail ? r.wideMax : r.side));
|
|
281
341
|
} else w = Math.min(w, r.wideMax);
|
|
282
342
|
V.w = w;
|
|
283
343
|
el.style.width = w + 'px'; el.style.flexBasis = w + 'px';
|
|
@@ -285,7 +345,7 @@ function apply(px) {
|
|
|
285
345
|
const g = el.querySelector('.cz-vw-grip'); if (g) { g.setAttribute('aria-valuenow', String(w)); g.setAttribute('aria-valuemin', String(MIN)); g.setAttribute('aria-valuemax', String(r.wideMax)); }
|
|
286
346
|
}
|
|
287
347
|
export function setWidth(px, keep = true) { apply(px); if (keep && V.cur) store.set('cz-vw-w:' + kindKey(V.cur.kind), V.w); }
|
|
288
|
-
export const railOn = () =>
|
|
348
|
+
export const railOn = () => G.rail;
|
|
289
349
|
/** Open wide (the list folds to a rail, the Viewer takes about 70%), or back to the side at the width this kind keeps. */
|
|
290
350
|
export function wide(on) {
|
|
291
351
|
if (!V.cur || isPhone()) return false;
|
|
@@ -295,23 +355,26 @@ export function wide(on) {
|
|
|
295
355
|
redraw();
|
|
296
356
|
return V.wide;
|
|
297
357
|
}
|
|
358
|
+
function resetW() { if (!V.cur) return; store.set('cz-vw-w:' + kindKey(V.cur.kind), null); V.wide = false; setRail(false); apply(room().def); redraw(); }
|
|
298
359
|
function grip(el) {
|
|
299
|
-
const g = document.createElement('div');
|
|
360
|
+
const g = document.createElement('div'), x = V;
|
|
300
361
|
g.className = 'cz-vw-grip'; g.setAttribute('role', 'separator'); g.setAttribute('aria-orientation', 'vertical'); g.tabIndex = 0;
|
|
301
362
|
g.setAttribute('aria-label', 'Drag to change the Viewer width. Double-click to reset.'); g.title = 'Drag to change the width. Double-click to reset.';
|
|
302
363
|
g.innerHTML = '<i></i>';
|
|
303
364
|
g.addEventListener('pointerdown', (e) => {
|
|
304
365
|
if (e.button !== 0) return;
|
|
366
|
+
use(x);
|
|
305
367
|
e.preventDefault(); g.setPointerCapture(e.pointerId); document.body.classList.add('cz-vw-drag');
|
|
306
368
|
const right = el.getBoundingClientRect().right;
|
|
307
|
-
const mv = (ev) => { V.wide = false; apply(right - ev.clientX); };
|
|
308
|
-
const up = () => { g.removeEventListener('pointermove', mv); g.removeEventListener('pointerup', up); g.removeEventListener('pointercancel', up); document.body.classList.remove('cz-vw-drag'); if (V.cur) store.set('cz-vw-w:' + kindKey(V.cur.kind), V.w); redraw(); };
|
|
369
|
+
const mv = (ev) => on(x, () => { V.wide = false; apply(right - ev.clientX); });
|
|
370
|
+
const up = () => { g.removeEventListener('pointermove', mv); g.removeEventListener('pointerup', up); g.removeEventListener('pointercancel', up); document.body.classList.remove('cz-vw-drag'); on(x, () => { if (V.cur) store.set('cz-vw-w:' + kindKey(V.cur.kind), V.w); redraw(); }); };
|
|
309
371
|
g.addEventListener('pointermove', mv); g.addEventListener('pointerup', up); g.addEventListener('pointercancel', up);
|
|
310
372
|
});
|
|
311
|
-
g.addEventListener('dblclick', () => {
|
|
373
|
+
g.addEventListener('dblclick', () => { use(x); resetW(); });
|
|
312
374
|
g.addEventListener('keydown', (e) => { // the grip is a separator: arrows move it 24 px, Home resets it
|
|
375
|
+
use(x);
|
|
313
376
|
const d = e.key === 'ArrowLeft' ? 24 : e.key === 'ArrowRight' ? -24 : 0;
|
|
314
|
-
if (d) { e.preventDefault(); V.wide = false; setWidth(V.w + d); redraw(); } else if (e.key === 'Home') { e.preventDefault();
|
|
377
|
+
if (d) { e.preventDefault(); V.wide = false; setWidth(V.w + d); redraw(); } else if (e.key === 'Home') { e.preventDefault(); resetW(); }
|
|
315
378
|
});
|
|
316
379
|
return g;
|
|
317
380
|
}
|
|
@@ -367,12 +430,14 @@ function discuss() {
|
|
|
367
430
|
function mount() {
|
|
368
431
|
if (V.el && V.el.isConnected) return V.el;
|
|
369
432
|
sheet();
|
|
370
|
-
const el = document.createElement('section');
|
|
371
|
-
el.className = 'cz-vw'; el.id = 'czViewer'; el.hidden = true;
|
|
372
|
-
el.setAttribute('aria-labelledby', 'czVwTitle');
|
|
433
|
+
const el = document.createElement('section'), x = V;
|
|
434
|
+
el.className = 'cz-vw'; el.id = V.i ? 'czViewer' + (V.i + 1) : 'czViewer'; el.hidden = true; el.dataset.czPanel = 'v' + V.i;
|
|
435
|
+
if (!V.i) el.setAttribute('aria-labelledby', 'czVwTitle'); // a second Viewer is named by its aria-label (the title id is the first one's)
|
|
436
|
+
el.tabIndex = -1;
|
|
373
437
|
el.innerHTML = '<header class="cz-vw-hd"></header><div class="cz-vw-body"></div>';
|
|
374
438
|
el.prepend(grip(el));
|
|
375
439
|
el.addEventListener('click', (e) => { // the header's presses, and the folds of czSections in the body
|
|
440
|
+
use(x);
|
|
376
441
|
const f = e.target.closest('[data-czs-fold]'); if (f && el.contains(f)) { toggleFold(f); return; }
|
|
377
442
|
if (e.target.closest('[data-cz-vw-rn]')) { startRename(); return; } // the title is the rename press (RnATask)
|
|
378
443
|
const b = e.target.closest('[data-cz-vw]'); if (!b || b.disabled || !el.querySelector('.cz-vw-hd').contains(b)) return;
|
|
@@ -385,19 +450,21 @@ function mount() {
|
|
|
385
450
|
else if (a === 'chip') { if (V.cur && V.cur.chip && typeof V.cur.chip.on === 'function') V.cur.chip.on(b); }
|
|
386
451
|
else if (a === 'add') { if (V.cur && V.cur.add && typeof V.cur.add.on === 'function') V.cur.add.on(b); }
|
|
387
452
|
else if (a === 'wide') wide();
|
|
453
|
+
else if (a === 'place') { if (G.place) G.place('v' + x.i, b); }
|
|
388
454
|
else if (a === 'discuss') discuss();
|
|
389
455
|
});
|
|
390
|
-
|
|
391
|
-
el
|
|
392
|
-
el.addEventListener('
|
|
393
|
-
el.addEventListener('
|
|
394
|
-
el.addEventListener('
|
|
456
|
+
el.addEventListener('focusin', () => use(x));
|
|
457
|
+
holdable(el, x);
|
|
458
|
+
el.addEventListener('submit', (e) => { use(x); if (e.target.closest('[data-cz-vw-ren]')) { e.preventDefault(); saveRename(); } });
|
|
459
|
+
el.addEventListener('keydown', (e) => { use(x); if (e.key === 'Escape' && e.target.closest('[data-cz-vw-ren]')) { e.preventDefault(); e.stopPropagation(); endRename(); } });
|
|
460
|
+
el.addEventListener('input', (e) => { use(x); if (e.target.id === 'czVwTitle' && V.cur && V.cur.renaming) V.cur.renValue = e.target.value; });
|
|
461
|
+
el.addEventListener('change', (e) => { use(x); if (e.target.matches('[data-cz-vw-jira]') && V.cur) V.cur.renJira = e.target.checked; });
|
|
395
462
|
place(el);
|
|
396
463
|
V.el = el;
|
|
397
|
-
if (typeof ResizeObserver !== 'undefined') new ResizeObserver(() => {
|
|
464
|
+
if (typeof ResizeObserver !== 'undefined') new ResizeObserver(() => on(x, () => {
|
|
398
465
|
// crossing the phone width redraws the header too (← and no grip on a phone, × on a desk) without reopening the item
|
|
399
466
|
if (isOpen() && !document.body.classList.contains('cz-vw-drag')) { const was = V.w, ph = V.ph; V.ph = isPhone(); apply(V.wide ? room().wideMax : V.w); if (V.w !== was || V.ph !== ph) redraw(); }
|
|
400
|
-
}).observe(document.documentElement);
|
|
467
|
+
})).observe(document.documentElement);
|
|
401
468
|
return el;
|
|
402
469
|
}
|
|
403
470
|
/** In the page's own place for it when there is one (data-cz-viewer-host), else at the end of the body, floating. */
|
|
@@ -406,10 +473,14 @@ function place(el) {
|
|
|
406
473
|
if (host) { if (el.parentNode !== host) host.appendChild(el); el.classList.remove('cz-vw-float'); }
|
|
407
474
|
else { if (el.parentNode !== document.body) document.body.appendChild(el); el.classList.add('cz-vw-float'); }
|
|
408
475
|
}
|
|
409
|
-
|
|
410
|
-
|
|
476
|
+
/** x: the instance that changed. The detail speaks of the Viewer used last (V): open is false only when no Viewer is open; panel names the
|
|
477
|
+
* one that changed and shut says it closed, for cozy-panels.js. */
|
|
478
|
+
function emit(x) {
|
|
479
|
+
x = x || V;
|
|
480
|
+
const d = { open: !!V.cur, id: V.cur ? V.cur.id : null, kind: V.cur ? V.cur.kind : null, title: V.cur ? V.cur.title : null, via: V.cur ? '' : x.via || '', // via 'history': the browser's Back closed it
|
|
481
|
+
panel: 'v' + x.i, shut: !shown(x) };
|
|
411
482
|
document.body.classList.toggle('cz-vw-on', d.open);
|
|
412
|
-
|
|
483
|
+
G.subs.forEach((f) => { try { f(d); } catch { /* a listener's fault stays its own */ } });
|
|
413
484
|
document.dispatchEvent(new CustomEvent('cz-viewer', { detail: d }));
|
|
414
485
|
}
|
|
415
486
|
/** Runs go now, or after the item's guard says so (it holds unsaved changes and asks Save or Discard first). */
|
|
@@ -427,7 +498,7 @@ function redraw() {
|
|
|
427
498
|
V.ph = isPhone();
|
|
428
499
|
const hd = V.el.querySelector('.cz-vw-hd');
|
|
429
500
|
const bk = V.stack[V.stack.length - 1], fw = V.fwd[V.fwd.length - 1];
|
|
430
|
-
hd.innerHTML = headHtml({ ...V.cur, canBack: V.stack.length > 0, backTo: bk ? bk.title || '' : '', fwdTo: fw ? fw.title || 'the next item' : '', isWide: V.wide ||
|
|
501
|
+
hd.innerHTML = headHtml({ ...V.cur, canBack: V.stack.length > 0, backTo: bk ? bk.title || '' : '', fwdTo: fw ? fw.title || 'the next item' : '', isWide: V.wide || G.rail, phone: V.ph, home: onHome(), place: !!G.place });
|
|
431
502
|
hd.classList.toggle('cz-vw-renon', !!V.cur.renaming);
|
|
432
503
|
}
|
|
433
504
|
|
|
@@ -458,26 +529,33 @@ async function saveRename() {
|
|
|
458
529
|
endRename(); emit();
|
|
459
530
|
}
|
|
460
531
|
/** The item's own presses change while it is shown (the charter's Save shows only after a change). */
|
|
461
|
-
|
|
532
|
+
function setChip0(id, chip) {
|
|
462
533
|
if (!V.cur || V.cur.id !== String(id)) return;
|
|
463
534
|
const was = V.cur.chip, on = !!(chip && (chip.n > 0 || chip.looking)), n = on ? chip.n || 0 : -1;
|
|
464
535
|
V.cur.chip = on ? chip : null;
|
|
465
536
|
if (V.cur.args) V.cur.args = { ...V.cur.args, chip: V.cur.chip };
|
|
466
537
|
if ((was ? was.n || 0 : -1) !== n || (was && chip && (was.label !== chip.label || !!was.looking !== !!chip.looking))) { if (!V.cur.renaming) redraw(); }
|
|
467
538
|
}
|
|
468
|
-
|
|
539
|
+
function setPresses0(id, list) { if (V.cur && V.cur.id === String(id)) { V.cur.presses = list || null; if (V.cur.args) V.cur.args = { ...V.cur.args, presses: list || null }; if (!V.cur.renaming) redraw(); } }
|
|
469
540
|
/** A task's check box changes while it is shown (a status move from the card, canvas XetX1Done). */
|
|
470
|
-
|
|
541
|
+
function setCheck0(id, check) { if (V.cur && V.cur.id === String(id)) { V.cur.check = check || null; if (V.cur.args) V.cur.args = { ...V.cur.args, check: check || null }; if (!V.cur.renaming) redraw(); } }
|
|
542
|
+
/** The item may be shown in any Viewer, not only the one used last: each one that shows it changes. */
|
|
543
|
+
const each = (id, fn) => ALL.filter((x) => x.cur && x.cur.id === String(id)).forEach((x) => on(x, fn));
|
|
544
|
+
export function setChip(id, chip) { each(id, () => setChip0(id, chip)); }
|
|
545
|
+
export function setPresses(id, list) { each(id, () => setPresses0(id, list)); }
|
|
546
|
+
export function setCheck(id, check) { each(id, () => setCheck0(id, check)); }
|
|
547
|
+
export function retitle(id, title) { each(id, () => retitle0(id, title)); }
|
|
471
548
|
/** The caller's own rename landed elsewhere (Undo, or a reload): the header shows the name. */
|
|
472
|
-
|
|
549
|
+
function retitle0(id, title) { if (V.cur && V.cur.id === String(id) && title) { V.cur.title = title; if (V.cur.args) V.cur.args = { ...V.cur.args, title }; if (!V.cur.renaming) redraw(); emit(); } }
|
|
473
550
|
|
|
474
551
|
/** Show one item in the Viewer, in place of the one shown. Returns the body element the content is in. */
|
|
475
552
|
export function open(it) {
|
|
476
553
|
const o = it || {};
|
|
554
|
+
use(o._inst || pick(o));
|
|
477
555
|
// an item with unsaved changes asks first; the open goes on when it says so (and keeps a drill-in asked for before it)
|
|
478
556
|
if (!o._asked && V.cur && typeof V.cur.guard === 'function') {
|
|
479
557
|
const dr = V.drill; let now = true, ran = false;
|
|
480
|
-
guarded(() => { ran = true; if (!now) {
|
|
558
|
+
const x = V; guarded(() => { ran = true; if (!now) { x.drill = dr; open({ ...o, _asked: true, _inst: x }); } });
|
|
481
559
|
now = false;
|
|
482
560
|
if (!ran) return null;
|
|
483
561
|
}
|
|
@@ -486,6 +564,7 @@ export function open(it) {
|
|
|
486
564
|
const was = isOpen(), pos = V.stack.length, how = stepOf(o);
|
|
487
565
|
if (how === 'nav') { V.stack = o._trail.stack; V.fwd = o._trail.fwd; }
|
|
488
566
|
else if (how === 'drill') { V.stack.push(V.cur.args); V.fwd = []; hq({ push: 1, s: H.s, i: V.stack.length }); }
|
|
567
|
+
else if (how === 'new' && V.i) { V.stack = []; V.fwd = []; } // a second Viewer keeps its trail without the browser history
|
|
489
568
|
else if (how === 'new') {
|
|
490
569
|
// a press starts a trail on its own entry; an open no press led to (the page drew it, or Back from another page restored it) takes the
|
|
491
570
|
// page's entry, so Back from it leaves the page as before. A new trail from a press takes the place of a pressed one.
|
|
@@ -506,7 +585,8 @@ export function open(it) {
|
|
|
506
585
|
body.className = 'cz-vw-body'; body.onclick = null; body.oninput = null; body.onchange = null; body.onkeydown = null; // what one item's render added to the body does not reach the next
|
|
507
586
|
const wasHidden = el.hidden;
|
|
508
587
|
el.hidden = false;
|
|
509
|
-
|
|
588
|
+
const hold = G.hold > Date.now() && !wasHidden && (V.wide || G.rail); G.hold = 0;
|
|
589
|
+
if (!hold && !(sameKind && !wasHidden && (V.wide || G.rail))) { const k = widthOf(o.kind); V.wide = false; apply(k || room().def); redraw(); }
|
|
510
590
|
if (typeof o.render === 'function') o.render(body); else if (o.html) body.innerHTML = o.html;
|
|
511
591
|
emit();
|
|
512
592
|
if (isPhone()) el.focus();
|
|
@@ -527,26 +607,29 @@ export function trail() {
|
|
|
527
607
|
* already left the trail (its Back at the first item), so the history is not moved again. */
|
|
528
608
|
export function close(o = {}) {
|
|
529
609
|
if (!V.el || V.el.hidden) return;
|
|
530
|
-
const pos = V.stack.length;
|
|
610
|
+
const pos = V.stack.length, x = V;
|
|
531
611
|
leave();
|
|
532
612
|
// the trail's entries come off, so Back never lands on a closed item; a trail on the page's own entry gives that entry back
|
|
533
|
-
if (!
|
|
534
|
-
|
|
613
|
+
if (!V.i) {
|
|
614
|
+
if (!o.quiet && H.s) { if (H.auto) { if (pos) hq({ go: -pos }); hq({ clear: 1 }); } else hq({ go: -(pos + 1) }); }
|
|
615
|
+
H.s = ''; H.auto = false;
|
|
616
|
+
}
|
|
535
617
|
V.via = o.quiet ? 'history' : '';
|
|
536
618
|
V.stack = []; V.fwd = []; V.wide = false; V.drill = false;
|
|
537
619
|
if (V.over) { V.over = false; document.body.classList.remove('cz-vw-over'); }
|
|
538
620
|
V.el.hidden = true;
|
|
539
621
|
V.el.querySelector('.cz-vw-body').innerHTML = '';
|
|
540
622
|
V.el.querySelectorAll('.cz-vw-menu,.cz-vw-trail').forEach((m) => m.remove());
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
623
|
+
const nx = mru(); // another Viewer is still open: it is the one in use now, and the list stays as it is
|
|
624
|
+
if (nx) V = nx; else setRail(false);
|
|
625
|
+
emit(x);
|
|
626
|
+
const b = x.back; x.back = null;
|
|
627
|
+
if (b && b.isConnected && !nx) { try { b.focus(); } catch { /* gone */ } }
|
|
545
628
|
}
|
|
546
629
|
export const isOpen = () => !!(V.el && !V.el.hidden && V.cur);
|
|
547
630
|
export const current = () => (V.cur ? { id: V.cur.id, kind: V.cur.kind, title: V.cur.title, url: V.cur.url } : null);
|
|
548
631
|
export const body = () => (isOpen() ? V.el.querySelector('.cz-vw-body') : null);
|
|
549
|
-
export function onChange(fn) { if (typeof fn === 'function')
|
|
632
|
+
export function onChange(fn) { if (typeof fn === 'function') G.subs.push(fn); }
|
|
550
633
|
/** Open the Viewer on a feature the design does not draw yet. */
|
|
551
634
|
export function placeholder(featureName, o = {}) {
|
|
552
635
|
return open({ id: 'placeholder:' + featureName, kind: o.kind || featureName, title: featureName, icon: o.icon || 'info', render: (el) => czPlaceholder(el, featureName) });
|
|
@@ -562,12 +645,12 @@ function stepOf(o) {
|
|
|
562
645
|
const p = H.press && Date.now() - H.press.t < 10000 ? H.press : null; // the press that led here: an open often waits for a module or a read
|
|
563
646
|
if (o.keep && V.cur) return 'keep';
|
|
564
647
|
if (V.cur && V.cur.args && !o.fresh && (o.back || V.drill)) return 'drill'; // asked for: a view of the same item drills in too (Stage, Documents)
|
|
565
|
-
if (V.cur && o.id != null && V.cur.id === String(o.id) && !(p &&
|
|
566
|
-
if (V.cur && V.cur.args && !o.fresh && p && p.
|
|
648
|
+
if (V.cur && o.id != null && V.cur.id === String(o.id) && !(p && p.inst !== V) && !o.fresh) return 'keep';
|
|
649
|
+
if (V.cur && V.cur.args && !o.fresh && p && p.inst === V) return 'drill';
|
|
567
650
|
return 'new';
|
|
568
651
|
}
|
|
569
652
|
/** The history follows the trail. A go() waits for its popstate before the next push or replace, so the order holds. */
|
|
570
|
-
function hq(op) { if (!canHist()) return; H.q.push(op); hRun(); }
|
|
653
|
+
function hq(op) { if (!canHist() || V.i) return; H.q.push(op); hRun(); }
|
|
571
654
|
function hRun() {
|
|
572
655
|
while (H.q.length && !H.wait) {
|
|
573
656
|
const op = H.q.shift();
|
|
@@ -591,11 +674,12 @@ function step(n, o = {}) {
|
|
|
591
674
|
if (at >= seq.length) return null;
|
|
592
675
|
const to = seq[at];
|
|
593
676
|
if (!o.quiet) hq({ go: n });
|
|
594
|
-
return open({ ...to, back: false, keep: false, _asked: true, _nav: true, _trail: { stack: seq.slice(0, at), fwd: seq.slice(at + 1).reverse() } });
|
|
677
|
+
return open({ ...to, back: false, keep: false, _asked: true, _nav: true, _inst: V, _trail: { stack: seq.slice(0, at), fwd: seq.slice(at + 1).reverse() } });
|
|
595
678
|
}
|
|
596
679
|
/** The browser moved (Back, Forward, a swipe, a long press on its own ←). An item with unsaved changes asks first: the browser goes back to
|
|
597
680
|
* where it was, and the move runs on Save or Discard. */
|
|
598
|
-
function popped(e) {
|
|
681
|
+
function popped(e) { use(ALL[0]); popped0(e); }
|
|
682
|
+
function popped0(e) {
|
|
599
683
|
if (H.wait) { H.wait = 0; hRun(); return; } // the history moving after ← → or a close: the Viewer is already there
|
|
600
684
|
const st = e && e.state && e.state.czvw;
|
|
601
685
|
if (!st) { if (isOpen()) follow(-(V.stack.length + 1)); return; } // before the trail: the page as it was
|
|
@@ -610,20 +694,20 @@ function follow(n) {
|
|
|
610
694
|
if (!ran) hq({ go: -n });
|
|
611
695
|
}
|
|
612
696
|
/* where a press was: inside the Viewer it drills in, outside it starts a new trail */
|
|
613
|
-
function pressAt(e) { const t = e.target;
|
|
697
|
+
function pressAt(e) { const t = e.target; const inst = t && t.nodeType === 1 && !t.closest('.cz-vw-trail') ? ALL.find((x) => x.el && x.el.contains(t)) || null : null; H.press = { t: Date.now(), inst }; }
|
|
614
698
|
/* the trail list: hover ← or → for a moment (a mouse), or hold it (a touch). It names every step, newest first, and the page it started on. */
|
|
615
699
|
let HOLD = { t: 0, fired: 0 };
|
|
616
|
-
function holdable(el) {
|
|
617
|
-
el.addEventListener('pointerover', (e) => { const b = e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]'); if (!b || e.pointerType === 'touch' || !
|
|
700
|
+
function holdable(el, x) {
|
|
701
|
+
el.addEventListener('pointerover', (e) => { const b = e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]'); if (!b || e.pointerType === 'touch' || !x.stack.length && !x.fwd.length) return; clearTimeout(HOLD.t); HOLD.t = setTimeout(() => on(x, () => trailMenu(b, x)), 500); });
|
|
618
702
|
el.addEventListener('pointerout', (e) => { if (e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]')) clearTimeout(HOLD.t); });
|
|
619
|
-
el.addEventListener('pointerdown', (e) => { const b = e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]'); if (!b) return; HOLD.fired = 0; if (e.pointerType === 'mouse' || !
|
|
703
|
+
el.addEventListener('pointerdown', (e) => { const b = e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]'); if (!b) return; HOLD.fired = 0; if (e.pointerType === 'mouse' || !x.stack.length && !x.fwd.length) return; clearTimeout(HOLD.t); HOLD.t = setTimeout(() => { HOLD.fired = Date.now(); on(x, () => trailMenu(b, x)); }, 500); });
|
|
620
704
|
['pointerup', 'pointercancel'].forEach((k) => el.addEventListener(k, () => clearTimeout(HOLD.t)));
|
|
621
705
|
el.addEventListener('contextmenu', (e) => { if (e.target.closest('[data-cz-vw="back"],[data-cz-vw="fwd"]')) e.preventDefault(); });
|
|
622
706
|
}
|
|
623
707
|
/** A hold that opened the trail list is not also a press. */
|
|
624
708
|
function held() { if (HOLD.fired && Date.now() - HOLD.fired < 800) { HOLD.fired = 0; return true; } return false; }
|
|
625
709
|
const PAGES = { '/premium.html': 'Home', '/premium-board.html': 'Board', '/premium-intelligence.html': 'Intelligence', '/premium-insights.html': 'Intelligence' };
|
|
626
|
-
function trailMenu(b) {
|
|
710
|
+
function trailMenu(b, x) {
|
|
627
711
|
if (!V.cur || !V.el) return;
|
|
628
712
|
const old = V.el.querySelector('.cz-vw-trail'); if (old) old.remove();
|
|
629
713
|
const seq = [...V.stack, V.cur.args, ...V.fwd.slice().reverse()], here = V.stack.length;
|
|
@@ -635,7 +719,7 @@ function trailMenu(b) {
|
|
|
635
719
|
+ `<button type="button" role="menuitem" class="pg" data-cz-vw-go="${-(here + 1)}"><span class="t">${svg(P.home, 15)}</span><span>${esc(PAGES[location.pathname] || document.title || 'The page')}</span></button>`;
|
|
636
720
|
const off = () => { m.remove(); document.removeEventListener('pointerdown', away, true); };
|
|
637
721
|
const away = (e) => { if (!m.contains(e.target)) off(); };
|
|
638
|
-
m.addEventListener('click', (e) => { const
|
|
722
|
+
m.addEventListener('click', (e) => { const g = e.target.closest('[data-cz-vw-go]'); if (!g) return; const n = +g.dataset.czVwGo; off(); if (x) use(x); if (n) guarded(() => step(n), b); });
|
|
639
723
|
m.addEventListener('keydown', (e) => {
|
|
640
724
|
const bs = [...m.querySelectorAll('button')], at = bs.indexOf(document.activeElement);
|
|
641
725
|
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); off(); b.focus(); }
|
|
@@ -653,13 +737,33 @@ if (typeof window !== 'undefined' && typeof window.addEventListener === 'functio
|
|
|
653
737
|
// Escape closes the Viewer first, unless a layer over it (a menu, a confirm) is open: that layer closes first. The listener is on
|
|
654
738
|
// window in the capture phase and is added before premium-shell.js adds its own, so the old dialog does not also close on the same key.
|
|
655
739
|
window.addEventListener('keydown', (e) => {
|
|
656
|
-
|
|
740
|
+
const x = mru();
|
|
741
|
+
if (e.key !== 'Escape' || !x || e.defaultPrevented) return;
|
|
657
742
|
if (document.querySelector('[data-esc-layer]')) return;
|
|
658
|
-
e.preventDefault(); e.stopImmediatePropagation(); guarded(close);
|
|
743
|
+
use(x); e.preventDefault(); e.stopImmediatePropagation(); guarded(close);
|
|
659
744
|
}, true);
|
|
660
745
|
window.addEventListener('click', pressAt, true);
|
|
661
746
|
window.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') pressAt(e); }, true);
|
|
662
747
|
window.addEventListener('popstate', popped);
|
|
663
748
|
try { H.adopt = !!(history.state && history.state.czvw); } catch { H.adopt = false; } // back here from another page, or a reload: the first open takes this entry
|
|
664
749
|
}
|
|
665
|
-
|
|
750
|
+
/* ── for cozy-panels.js (batch 18 item 15): the instances behind one object. A panel id is 'v' + the instance's number (v0 is #czViewer). ── */
|
|
751
|
+
const byP = (id) => ALL.find((x) => 'v' + x.i === id) || null;
|
|
752
|
+
export const panels = {
|
|
753
|
+
list: () => ALL.map((x) => ({ id: 'v' + x.i, open: shown(x), used: x.used, el: x.el, item: x.cur ? { id: x.cur.id, kind: x.cur.kind, title: x.cur.title } : null })),
|
|
754
|
+
/** limit: how many Viewers may be open at once · place(id, button): ⧉ was pressed · managed(id) → true: the panels engine sizes it */
|
|
755
|
+
config(c = {}) { if (c.limit) G.limit = c.limit; if ('place' in c) G.place = c.place; if ('managed' in c) G.managed = c.managed; ALL.filter(shown).forEach((x) => on(x, redraw)); },
|
|
756
|
+
/** The next open() goes into a Viewer of its own (a drop beside, TbT5DragRow). */
|
|
757
|
+
beside() { G.beside = { t: Date.now() }; }, unbeside() { G.beside = null; },
|
|
758
|
+
close(id) { const x = byP(id); if (shown(x)) { use(x); guarded(close); } },
|
|
759
|
+
use(id) { const x = byP(id); if (x) use(x); },
|
|
760
|
+
/** The width of a Viewer beside the chat (the first divider drives it): px; keep: remembered for its kind. */
|
|
761
|
+
size(id, px, keep) { const x = byP(id); if (shown(x)) on(x, () => { V.wide = false; setWidth(px, keep); redraw(); }); },
|
|
762
|
+
reset(id) { const x = byP(id); if (shown(x)) on(x, resetW); },
|
|
763
|
+
/** Lay each open Viewer out again (the engine changed what it manages). */
|
|
764
|
+
relayout() { ALL.filter(shown).forEach((x) => on(x, () => { apply(V.wide ? room().wideMax : V.w || room().def); redraw(); })); },
|
|
765
|
+
/** Back beside the chat after the engine laid it out: the width its kind keeps, else the default. */
|
|
766
|
+
rest() { ALL.filter(shown).forEach((x) => on(x, () => { const k = widthOf(V.cur.kind); V.wide = false; apply(k || room().def); redraw(); })); },
|
|
767
|
+
rail(v) { setRail(!!v); }, railOn: () => G.rail,
|
|
768
|
+
};
|
|
769
|
+
if (typeof window !== 'undefined') window.czViewer = { open, close, back, forward, trail, replaceUrl, drill, setPresses, setChip, setCheck, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, railCard, railSync, keepWide, ICONS };
|
|
@@ -222,3 +222,7 @@ body.cz-vw-rail [data-cz-vw-list] > :not(.cz-vw-railbar), body.cz-vw-rail #hmLis
|
|
|
222
222
|
.nv-facts dt { color: var(--cz-ink3); font-size: var(--fs-2); }
|
|
223
223
|
.nv-facts dd { margin: 0; overflow-wrap: anywhere; }
|
|
224
224
|
.nv-rev .czs-cv { align-self: center; font-size: var(--fs-4); }
|
|
225
|
+
/* a tile whose card is open has a ring; the tile of the group that holds what is open has a blue bar on its left (batch 18 item 14) */
|
|
226
|
+
.cz-vw-railtile { position: relative; }
|
|
227
|
+
.cz-vw-railtile.on { box-shadow: 0 0 0 2px var(--cz-blue); }
|
|
228
|
+
.cz-vw-railtile.here::before { content: ""; position: absolute; left: -10px; top: 50%; width: 4px; height: 20px; margin-top: -10px; border-radius: 2px; background: var(--cz-blue); }
|