create-pmos 0.444.0 → 0.445.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 +13 -13
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/adler-moments-test.js +8 -0
- package/workspace/adler-seasons-art-test.js +3 -0
- package/workspace/board-columns-test.js +168 -0
- package/workspace/board-programs-test.js +1 -1
- package/workspace/briefing-premium-board-test.js +83 -6
- package/workspace/briefing-premium-insights-test.js +43 -0
- package/workspace/calm-timeline-test.js +3 -1
- package/workspace/changelog.json +12 -0
- package/workspace/guide/jira.md +13 -1
- package/workspace/guide/ready-made-dashboards.md +2 -2
- package/workspace/lib/board-fold.js +33 -5
- package/workspace/lib/console-state.js +5 -1
- package/workspace/lib/factory-join.js +46 -14
- package/workspace/lib/freshness.js +14 -1
- package/workspace/lib/initiative-rows.js +38 -4
- package/workspace/lib/issues.js +8 -1
- package/workspace/lib/jira-cli.js +18 -2
- package/workspace/lib/jira-moves.js +119 -0
- package/workspace/lib/jira-tickets.js +23 -4
- package/workspace/lib/notes.js +4 -2
- package/workspace/lib/offloop.js +75 -29
- package/workspace/lib/page-build.js +97 -0
- package/workspace/lib/plan-items.js +24 -3
- package/workspace/lib/plan-tree.js +62 -9
- package/workspace/lib/ready-reports.js +22 -8
- package/workspace/lib/refresh.js +14 -2
- package/workspace/lib/routes-board-premium.js +9 -1
- package/workspace/lib/routes-boards.js +74 -15
- package/workspace/lib/routes-brief-page.js +3 -1
- package/workspace/lib/routes-calendar-import.js +13 -1
- package/workspace/lib/routes-ready-reports.js +28 -5
- package/workspace/lib/task-links.js +12 -1
- package/workspace/lib/workflows-store.js +14 -3
- package/workspace/milestone-pins-test.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +150 -6
- package/workspace/program-panel-test.js +6 -6
- package/workspace/public/pm/bd-cols.js +149 -0
- package/workspace/public/pm/bd-pane.js +41 -0
- package/workspace/public/pm/bd-span.js +29 -11
- package/workspace/public/pm/cozy-board.css +45 -0
- package/workspace/public/pm/cozy-insights.css +8 -0
- package/workspace/public/pm/cozy-live-pill.css +1 -0
- package/workspace/public/pm/cozy-live-pill.js +10 -1
- package/workspace/public/pm/cozy-panels.css +24 -3
- package/workspace/public/pm/cozy-panels.js +275 -108
- package/workspace/public/pm/cozy-viewer.js +3 -1
- package/workspace/public/pm/dash-view.js +5 -2
- package/workspace/public/pm/home-app.js +8 -8
- package/workspace/public/pm/ini-edit.js +5 -1
- package/workspace/public/pm/ini-tasks.js +134 -29
- package/workspace/public/pm/ini-view-model.js +4 -3
- package/workspace/public/pm/ini-view.css +74 -25
- package/workspace/public/pm/ini-view.js +4 -4
- package/workspace/public/pm/ini-wf-model.js +9 -0
- package/workspace/public/pm/ini-wf.js +14 -9
- package/workspace/public/pm/ins-pane.js +55 -0
- package/workspace/public/pm/jira-move.js +50 -0
- package/workspace/public/pm/live-model.js +3 -2
- package/workspace/public/pm/pn-narrow.js +76 -0
- package/workspace/public/pm/premium-board.js +77 -26
- package/workspace/public/pm/premium-insights.js +7 -1
- package/workspace/public/premium-board.html +2 -0
- package/workspace/ready-dash-ui-test.js +4 -4
- package/workspace/server.js +71 -20
- package/workspace/skills/jira-move.skill +35 -0
- package/workspace/stage-card-tasks-test.js +1 -0
- package/workspace/task-links-test.js +1 -0
- package/workspace/task-plans-test.js +1 -1
- package/workspace/task-views-test.js +161 -12
- package/workspace/test-lists/board-columns.json +5 -0
- package/workspace/test-lists/jira-moves.json +11 -0
- package/workspace/test-lists/page-speed-fold.json +5 -0
- package/workspace/test-lists/page-speed-reads.json +5 -0
- package/workspace/timeline-holds-test.js +1 -1
|
@@ -1,41 +1,61 @@
|
|
|
1
1
|
/* pm/cozy-panels.js — panels side by side, like a tablet (feedback batch 18 item 15, build 15-A; canvas In development TbT1Split to TbT9Divider,
|
|
2
|
-
* sticky "What to build").
|
|
2
|
+
* sticky "What to build"). Board and Intelligence too (panels on Board and Intelligence, build P-A; canvas In development BiB1–BiB9,
|
|
3
|
+
* BiI1–BiI4, brief feedback-batch/panels-board-intel/build-brief.md).
|
|
3
4
|
*
|
|
4
|
-
* Home is already a split: the chat, a divider, the Viewer.
|
|
5
|
+
* Home is already a split: the chat, a divider, the Viewer. On Board and Intelligence the page itself is the first panel: opening a Viewer
|
|
6
|
+
* splits the screen into the page, the divider and the Viewer, and nothing floats over the page unless it is placed as slide over.
|
|
5
7
|
* Side by side up to 2 panels on a laptop and up to 3 at 1600 px and wider, in one row. A phone keeps today's one panel (the engine is off).
|
|
6
8
|
* Divider between two panels (role separator). A drag snaps at ⅓, ½ and ⅔ of the room; a drag to an edge closes that side (a Viewer
|
|
7
|
-
* closes, the chat slides away
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* closes, the chat slides away; the page never closes: a drag to its edge makes the Viewer full screen). Double-click resets
|
|
10
|
+
* it to ½. ← and → move it 24 px, Home resets it.
|
|
11
|
+
* The first panel and one Viewer (today's split): the divider drives the Viewer's own width (cozy-viewer.js setWidth: on
|
|
12
|
+
* Home the list folds to a rail first, the width is kept per kind). Anything else is laid out here with shares of the row.
|
|
13
|
+
* Open beside drag a source row (Home: a list row, a Live pill row, a file or link chip in the chat; a page: its own rows) onto the
|
|
14
|
+
* panels. Over a Viewer, that Viewer turns blue and the drop replaces it; at the far edge (or, with no Viewer, the right
|
|
15
|
+
* half) a blue zone shows and the row opens in a panel of its own. ⌘/Ctrl-click or a middle click on a source does the same
|
|
16
|
+
* as a drop at the far edge (openBeside). When a new panel would go over the limit, it replaces the panel used least
|
|
17
|
+
* recently (a Viewer closes, the chat slides over); on a page with no room the new Viewer slides over instead. A plain
|
|
18
|
+
* click still replaces the active Viewer (the one used last). Task rows in a stage card keep their own drag (item 16).
|
|
19
|
+
* Active with 2 or more Viewers open, the one a plain click replaces (the one clicked, focused or scrolled in last) has a thin
|
|
20
|
+
* blue edge (.cz-pn-active, BiB8Active). A link inside a Viewer changes that same Viewer (cozy-viewer.js).
|
|
21
|
+
* ⧉ on every Viewer's header (and the chat's, icon-only, before ×): Full screen, Split, Slide over (TbT7Place).
|
|
15
22
|
* Slide over one panel at a time floats over the right side (the chat 400 px, a Viewer 560 px), with a grab bar. A drag or a swipe
|
|
16
|
-
* off the right edge puts it away; the Live pill brings it back (slideOver). Nothing pops open by itself.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
23
|
+
* off the right edge puts it away; the Live pill brings it back (slideOver). Nothing pops open by itself. The page panel
|
|
24
|
+
* never slides over and is never put away.
|
|
25
|
+
* Narrow a page gets the class cz-pn-narrow while its panel is narrower than fit() (the width its current view needs whole);
|
|
26
|
+
* the page's narrow form keys on it. A phone keeps the page's own media queries (no class).
|
|
27
|
+
* Remembered Home: each initiative reopens with its panels and shares (localStorage 'cz-pn:<initiative id>', like Android app pairs).
|
|
28
|
+
* A page: only the divider share (localStorage 'cz-pn:<key>'); the open Viewers are not restored. A private window
|
|
29
|
+
* forgets it, and the page falls back to today's split.
|
|
30
|
+
* Present Home: while a recording presents (BroadcastChannel 'pmos-present': present or show), the chat slides away by itself; on
|
|
31
|
+
* Stop (off, or the recording ends) it comes back.
|
|
21
32
|
*
|
|
22
|
-
* mountPanels(
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
33
|
+
* mountPanels(o) once, on the page.
|
|
34
|
+
* Home: { desk?, chat?, go?(item) → true, reopen?(item) }. go: the page opens a Live pill row in its chat (Home's own Live pill
|
|
35
|
+
* handler). reopen: the page opens a remembered Viewer item ({ id, kind, title }) again, or says false.
|
|
36
|
+
* A page: { desk?, page, sources, clicks?, fit?() → px, key? }. page: the page's main element, the first panel (never put away, never
|
|
37
|
+
* over). sources: the selector of the rows that can open beside (drag and ⌘-click). clicks: rows that open beside on ⌘-click
|
|
38
|
+
* only (a By stage card, whose drag moves the stage). fit(): the least width at which the page's current view is whole (about
|
|
39
|
+
* 880 for the Board's Track or Timeline and the Intelligence table, 360 for a list); the Viewer opens at the width its kind keeps
|
|
40
|
+
* (560 px at first) but never so wide that the page goes under fit(). key: the name the share is kept under ('board', 'intel').
|
|
41
|
+
* desk defaults to the page's parent; a Viewer host (data-cz-viewer-host) is added to it when it has none.
|
|
42
|
+
* window.czPanels = { list(), place(id, 'full'|'split'|'over'), slideOver(item?), openBeside(row|item), putAway(), away(), onChange(fn),
|
|
43
|
+
* scope(id) }
|
|
44
|
+
* panel ids: 'chat' or 'page' (the first panel), 'v0', 'v1', 'v2' (v0 is #czViewer). list() → [{ id, kind: 'chat'|'page'|'viewer',
|
|
45
|
+
* mode: 'split'|'over'|'away', full, active, title }]. slideOver(item): a Live pill row (item.sid, a session) opens in the chat, and the
|
|
46
|
+
* chat floats over when it is not in the row; a Viewer item ({ kind, title, render | html }) opens in a Viewer that floats over; no
|
|
47
|
+
* item brings back the panel put away. It returns false when it did nothing, so the caller falls back to its own open.
|
|
48
|
+
* openBeside(row): a source element opens beside (as a drop at the far edge); a Viewer item opens in a Viewer of its own. away() → the
|
|
49
|
+
* panel put away last, or null. scope(id) (Home): the page shows that initiative now (null: none); its panels are restored.
|
|
30
50
|
* The document gets the event 'cz-panels' with { panels: list(), over, away } after each change.
|
|
31
51
|
* The divider's look (Adler's sprout, the day's charm) is cozy-divider.js's (build 15-B); this module owns the element, its drag and keys. */
|
|
32
|
-
import { panels as P, open as openViewer, PHONE } from './cozy-viewer.js';
|
|
52
|
+
import { panels as P, open as openViewer, widthOf, PHONE } from './cozy-viewer.js';
|
|
33
53
|
import { dividerHtml } from './cozy-divider.js';
|
|
34
54
|
import { onRecording } from './rec-state.js';
|
|
35
55
|
|
|
36
56
|
const SHEET = new URL('./cozy-panels.css', import.meta.url).href;
|
|
37
|
-
const SNAP = [1 / 3, 1 / 2, 2 / 3], SNAPPX = 20, EDGE = 120, STEP = 24, WIDE = 1600, PANEL = 440, AWAYPX = 96;
|
|
38
|
-
const
|
|
57
|
+
const SNAP = [1 / 3, 1 / 2, 2 / 3], SNAPPX = 20, EDGE = 120, STEP = 24, WIDE = 1600, PANEL = 440, AWAYPX = 96, START = 560, MINV = 420, GAP = 22;
|
|
58
|
+
const HOME_SRC = '#hmList button[data-hm-sel], #czLiveList a[data-lv], #hmChat [data-file], #hmChat [data-ctx], #hmChat [data-att]';
|
|
39
59
|
const IC = {
|
|
40
60
|
full: 'M3.5 5h17v14h-17z', split: 'M3.5 5h17v14h-17zM12 5v14', over: 'M3.5 5h17v14h-17zM14 8h4v8h-4z',
|
|
41
61
|
place: 'M3.5 5h17v14h-17zM12 5v14', close: 'M6 6l12 12M18 6L6 18',
|
|
@@ -48,38 +68,47 @@ const store = {
|
|
|
48
68
|
};
|
|
49
69
|
const isPhone = () => innerWidth <= PHONE;
|
|
50
70
|
const maxRow = () => (innerWidth >= WIDE ? 3 : 2);
|
|
51
|
-
|
|
71
|
+
/* C is the first panel's id: 'chat' on Home, 'page' on a page (S.page). S.chat is its element either way. */
|
|
72
|
+
let C = 'chat';
|
|
73
|
+
const S = { on: false, page: false, desk: null, chat: null, src: HOME_SRC, clicks: '', fitFn: null, key: '', row: ['chat'], over: null, away: [], fr: [], used: {}, subs: [], go: null, reopen: null, pend: null, scope: null, auto: false, restoring: false, keepList: false, noClick: 0, divs: [] };
|
|
52
74
|
|
|
53
75
|
/* ── the panels and their elements ── */
|
|
54
76
|
const isV = (id) => /^v\d$/.test(id || '');
|
|
55
77
|
const vs = () => P.list().filter((p) => p.open);
|
|
56
|
-
const elOf = (id) => (id ===
|
|
78
|
+
const elOf = (id) => (id === C ? S.chat : (P.list().find((p) => p.id === id) || {}).el || null);
|
|
57
79
|
const visible = (id) => S.row.includes(id) || S.over === id;
|
|
80
|
+
/** The page panel stays: it never gives way, slides over or is put away (only a Viewer full screen hides it, until Split or a close). */
|
|
81
|
+
const pinned = (id) => S.page && id === C;
|
|
58
82
|
const drop = (id) => { S.row = S.row.filter((x) => x !== id); if (S.over === id) S.over = null; S.away = S.away.filter((x) => x !== id); };
|
|
59
83
|
const mark = (id) => { if (id) S.used[id] = performance.now(); };
|
|
60
84
|
const lru = (ids) => ids.slice().sort((a, b) => (S.used[a] || 0) - (S.used[b] || 0))[0];
|
|
61
|
-
/** Today's split, laid out by cozy-viewer.js: the
|
|
62
|
-
const simple = () => !S.over && !S.away.length && S.row[0] ===
|
|
85
|
+
/** Today's split, laid out by cozy-viewer.js: the first panel alone, or it then one Viewer, nothing over and nothing put away. */
|
|
86
|
+
const simple = () => (S.page || (!S.over && !S.away.length)) && S.row[0] === C && S.row.length <= 2; // a page: a Viewer over leaves the split as it is
|
|
63
87
|
const managed = () => S.on && !isPhone() && !simple();
|
|
88
|
+
const pageW = () => (S.fitFn ? Math.max(0, +S.fitFn() || 0) : 0);
|
|
64
89
|
|
|
65
90
|
/** The row and the open Viewers agree: a closed Viewer leaves, the row is never empty, and never over the limit. */
|
|
66
91
|
function sync() {
|
|
67
92
|
const open = vs().map((p) => p.id);
|
|
68
93
|
[...S.row, S.over, ...S.away].filter((id) => isV(id) && !open.includes(id)).forEach(drop);
|
|
94
|
+
if (S.page && S.over === C) S.over = null;
|
|
69
95
|
if (!S.row.length) {
|
|
70
96
|
if (S.over) { S.row = [S.over]; S.over = null; }
|
|
71
|
-
else { const v = [...S.away].reverse().find(isV); if (v) { drop(v); S.row = [v]; } else { drop(
|
|
97
|
+
else { const v = [...S.away].reverse().find(isV); if (v) { drop(v); S.row = [v]; } else { drop(C); S.row = [C]; } }
|
|
72
98
|
}
|
|
73
|
-
if (!open.length && !S.row.includes(
|
|
99
|
+
if (!open.length && !S.row.includes(C)) { drop(C); S.row.unshift(C); } // no Viewer: the chat (or the page) is the page, as today
|
|
100
|
+
if (S.page && S.row.includes(C) && S.row[0] !== C) { S.row = [C, ...S.row.filter((x) => x !== C)]; S.fr = []; } // the page is first
|
|
74
101
|
fit();
|
|
75
102
|
}
|
|
76
103
|
/** Over the limit (a new panel, a narrower window): the panel used least recently gives way. The chat slides over (or away when a panel
|
|
77
|
-
* is over already); a Viewer is put away when soft (a narrower window), else it closes. */
|
|
104
|
+
* is over already); a Viewer is put away when soft (a narrower window), else it closes. The page never gives way. */
|
|
78
105
|
function fit(keep, soft) {
|
|
79
106
|
while (S.row.length > maxRow()) {
|
|
80
|
-
const
|
|
107
|
+
const can = S.row.filter((x) => x !== keep && !pinned(x));
|
|
108
|
+
if (!can.length) break;
|
|
109
|
+
const id = lru(can);
|
|
81
110
|
S.row = S.row.filter((x) => x !== id);
|
|
82
|
-
if (id ===
|
|
111
|
+
if (id === C) { if (!S.over) S.over = C; else S.away.push(C); }
|
|
83
112
|
else if (soft) S.away.push(id);
|
|
84
113
|
else { S.away.push(id); setTimeout(() => P.close(id), 0); } // hidden until it closes
|
|
85
114
|
}
|
|
@@ -93,7 +122,7 @@ function shares() {
|
|
|
93
122
|
function layout() {
|
|
94
123
|
if (!S.on || !S.desk) return;
|
|
95
124
|
sync();
|
|
96
|
-
const B = document.body, phone = isPhone(), man = managed(), ids = [
|
|
125
|
+
const B = document.body, phone = isPhone(), man = managed(), ids = [C, ...vs().map((p) => p.id)];
|
|
97
126
|
const back = S.man && !man; // back to today's split: cozy-viewer.js decides the width and the rail again
|
|
98
127
|
if (back) { S.keepList = false; P.rail(false); }
|
|
99
128
|
S.man = man;
|
|
@@ -108,22 +137,27 @@ function layout() {
|
|
|
108
137
|
el.classList.toggle('cz-pn-away', !phone && S.away.includes(id));
|
|
109
138
|
el.style.order = !phone && man && at >= 0 ? String(at * 2) : '';
|
|
110
139
|
el.style.flex = !phone && man && at >= 0 ? `${fr[at]} 1 0px` : '';
|
|
140
|
+
if (S.page && id !== C) el.style.marginLeft = !phone && man && at > 0 ? GAP + 'px' : ''; // a page's row has no flex gap (stray body children)
|
|
111
141
|
grab(el, !phone && S.over === id);
|
|
112
142
|
});
|
|
113
143
|
const host = S.desk.querySelector('[data-cz-viewer-host]');
|
|
114
144
|
if (host) host.style.order = !phone && !man ? '2' : '';
|
|
145
|
+
if (host && S.page) host.style.marginLeft = !phone && !man ? GAP + 'px' : '';
|
|
115
146
|
if (S.chat) S.chat.style.order = !phone && !man ? '0' : S.chat.style.order;
|
|
116
|
-
divs(phone ? 0 :
|
|
117
|
-
if (man && !phone) {
|
|
147
|
+
divs(phone ? 0 : S.row.length - 1, man);
|
|
148
|
+
if (man && !phone && !S.page) {
|
|
118
149
|
const room = S.desk.clientWidth - 64 - (S.row.length - 1) * 22; // the desk less its padding and the gaps
|
|
119
150
|
const list = document.getElementById('hmList'), lw = list ? list.offsetWidth || 316 : 0;
|
|
120
|
-
const fold = !S.keepList && (!S.row.includes(
|
|
151
|
+
const fold = !S.keepList && (!S.row.includes(C) || room - lw < S.row.length * PANEL);
|
|
121
152
|
if (fold !== P.railOn()) P.rail(fold);
|
|
122
153
|
}
|
|
123
154
|
if (back) P.rest(); else P.relayout();
|
|
155
|
+
if (S.page && !man && !phone) S.row.filter(isV).forEach((id) => P.size(id, startW(id), false)); // the page keeps its view whole (fit)
|
|
124
156
|
tools();
|
|
157
|
+
active();
|
|
158
|
+
narrow();
|
|
125
159
|
emit();
|
|
126
|
-
if (S.scope && !S.restoring) store.set('cz-pn:' + S.scope, snapshot());
|
|
160
|
+
if (S.scope && !S.restoring && !S.page) store.set('cz-pn:' + S.scope, snapshot());
|
|
127
161
|
}
|
|
128
162
|
function emit() {
|
|
129
163
|
const d = { panels: list(), over: S.over, away: S.away.slice() };
|
|
@@ -131,14 +165,50 @@ function emit() {
|
|
|
131
165
|
document.dispatchEvent(new CustomEvent('cz-panels', { detail: d }));
|
|
132
166
|
}
|
|
133
167
|
function list() {
|
|
134
|
-
const one = S.row.length === 1;
|
|
135
|
-
return [
|
|
168
|
+
const one = S.row.length === 1, act = activeId();
|
|
169
|
+
return [C, ...vs().map((p) => p.id)].map((id) => {
|
|
136
170
|
const v = P.list().find((p) => p.id === id);
|
|
137
|
-
const title = id
|
|
138
|
-
return { id, kind: id ===
|
|
171
|
+
const title = id !== C ? (v && v.item && v.item.title) || '' : S.page ? (document.title || '').replace(/^PMOS · /, '') || 'Page' : ((document.getElementById('hmCh') || {}).textContent || '').trim() || 'Chat';
|
|
172
|
+
return { id, kind: id === C ? C : 'viewer', mode: S.over === id ? 'over' : S.away.includes(id) ? 'away' : 'split', full: one && S.row[0] === id, active: id === act, title };
|
|
139
173
|
});
|
|
140
174
|
}
|
|
141
175
|
|
|
176
|
+
/* ── the start width on a page (rule 0): the Viewer's kind keeps its width, but the page stays whole; a moved divider's share wins ── */
|
|
177
|
+
function room() {
|
|
178
|
+
const cs = getComputedStyle(S.desk);
|
|
179
|
+
return S.desk.clientWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);
|
|
180
|
+
}
|
|
181
|
+
function startW(id) {
|
|
182
|
+
const v = P.list().find((p) => p.id === id), r = room() - GAP, m = store.get('cz-pn:' + S.key);
|
|
183
|
+
if (m && m.v === 2 && m.share > 0 && m.share < 1) return Math.round(r * m.share);
|
|
184
|
+
const want = (v && v.item && widthOf(v.item.kind)) || START;
|
|
185
|
+
return Math.max(MINV, Math.min(want, r - pageW()));
|
|
186
|
+
}
|
|
187
|
+
/** The page panel narrower than its view needs: cz-pn-narrow, its narrow form (P-B). Not on a phone: the page's media queries keep it. */
|
|
188
|
+
function narrow() {
|
|
189
|
+
if (!S.page || !S.chat) return;
|
|
190
|
+
const w = S.chat.getBoundingClientRect().width;
|
|
191
|
+
S.chat.classList.toggle('cz-pn-narrow', !isPhone() && w > 0 && w < pageW());
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* ── the active Viewer (BiB8Active): the one a plain click replaces, marked only while 2 or more Viewers show ── */
|
|
195
|
+
function activeId() {
|
|
196
|
+
const open = vs().filter((p) => visible(p.id));
|
|
197
|
+
if (open.length < 2) return null;
|
|
198
|
+
return open.slice().sort((a, b) => b.used - a.used)[0].id;
|
|
199
|
+
}
|
|
200
|
+
function active() {
|
|
201
|
+
const a = activeId();
|
|
202
|
+
P.list().forEach((p) => { if (p.el) p.el.classList.toggle('cz-pn-active', !isPhone() && p.id === a); });
|
|
203
|
+
}
|
|
204
|
+
/** A press, a focus or a scroll in a Viewer makes it the one a plain click replaces. */
|
|
205
|
+
function used(id) {
|
|
206
|
+
if (!isV(id)) return;
|
|
207
|
+
const was = activeId();
|
|
208
|
+
P.use(id);
|
|
209
|
+
if (activeId() !== was) { active(); emit(); }
|
|
210
|
+
}
|
|
211
|
+
|
|
142
212
|
/* ── the dividers (TbT2Divider, TbT9Divider) ── */
|
|
143
213
|
function divs(n, man) {
|
|
144
214
|
while (S.divs.length > n) S.divs.pop().remove();
|
|
@@ -179,9 +249,14 @@ function snap(x, g) {
|
|
|
179
249
|
for (const q of SNAP) { const at = g.L + q * total; if (Math.abs(x - at) < SNAPPX) return { x: at, q }; }
|
|
180
250
|
return { x, q: 0 };
|
|
181
251
|
}
|
|
182
|
-
/** The divider k at x: the two panels share their room again (laid out here), or the Viewer takes the width (today's split).
|
|
252
|
+
/** The divider k at x: the two panels share their room again (laid out here), or the Viewer takes the width (today's split). On a page
|
|
253
|
+
* the share is what is kept (rule 7), not the kind's width. */
|
|
183
254
|
function setAt(k, x, g, keep) {
|
|
184
|
-
if (!managed()) {
|
|
255
|
+
if (!managed()) {
|
|
256
|
+
const w = g.R - x - g.gap / 2;
|
|
257
|
+
if (S.page) { if (keep) store.set('cz-pn:' + S.key, { v: 2, share: Math.min(0.95, Math.max(0.05, w / (g.R - g.L - g.gap))) }); P.size(g.b, w, false); if (keep) layout(); return; }
|
|
258
|
+
P.size(g.b, w, keep); return;
|
|
259
|
+
}
|
|
185
260
|
const wa = Math.max(60, x - g.ra.left - g.gap / 2), wb = Math.max(60, g.rb.right - x - g.gap / 2), fr = shares(), s = fr[k] + fr[k + 1];
|
|
186
261
|
fr[k] = s * wa / (wa + wb); fr[k + 1] = s - fr[k];
|
|
187
262
|
[g.a, g.b].forEach((id, i) => { const el = elOf(id); if (el) el.style.flex = `${fr[k + i]} 1 0px`; });
|
|
@@ -207,7 +282,8 @@ function dragDiv(d, e) {
|
|
|
207
282
|
d.classList.remove('drag', 'snap'); document.body.classList.remove('cz-pn-drag', 'cz-vw-drag');
|
|
208
283
|
[g.a, g.b].forEach((id) => { const el = elOf(id); if (el) el.classList.remove('cz-pn-shut'); });
|
|
209
284
|
if (!last) return;
|
|
210
|
-
if (last.shut
|
|
285
|
+
if (last.shut && pinned(last.shut)) place(g.b, 'full'); // the page never closes: the Viewer takes the screen
|
|
286
|
+
else if (last.shut) shut(last.shut); else setAt(k, last.x, g, true);
|
|
211
287
|
};
|
|
212
288
|
d.addEventListener('pointermove', mv); d.addEventListener('pointerup', up); d.addEventListener('pointercancel', up);
|
|
213
289
|
}
|
|
@@ -217,13 +293,17 @@ function nudge(k, dx) {
|
|
|
217
293
|
}
|
|
218
294
|
function resetDiv(k) {
|
|
219
295
|
const g = geo(k); if (!g) return;
|
|
220
|
-
if (!managed()) {
|
|
296
|
+
if (!managed()) {
|
|
297
|
+
if (S.page) { store.set('cz-pn:' + S.key, { v: 2, share: 0.5 }); layout(); return; }
|
|
298
|
+
P.reset(g.b); layout(); return;
|
|
299
|
+
}
|
|
221
300
|
S.fr = S.row.map(() => 1 / S.row.length); layout();
|
|
222
301
|
}
|
|
223
|
-
/** A panel leaves the row: a Viewer closes, the chat slides away (the Live pill brings it back). */
|
|
302
|
+
/** A panel leaves the row: a Viewer closes, the chat slides away (the Live pill brings it back). The page never leaves. */
|
|
224
303
|
function shut(id) {
|
|
225
304
|
if (isV(id)) { P.close(id); return; }
|
|
226
|
-
|
|
305
|
+
if (pinned(id)) return;
|
|
306
|
+
drop(C); S.away.push(C); S.fr = []; layout();
|
|
227
307
|
}
|
|
228
308
|
|
|
229
309
|
/* ── the ⧉ menu (TbT7Place) ── */
|
|
@@ -260,21 +340,26 @@ function openMenu(id, anchor) {
|
|
|
260
340
|
}
|
|
261
341
|
|
|
262
342
|
/* ── placing a panel ── */
|
|
263
|
-
function known(id) { return id ===
|
|
343
|
+
function known(id) { return id === C || vs().some((p) => p.id === id); }
|
|
264
344
|
function place(id, mode) {
|
|
265
345
|
if (!S.on || isPhone() || !known(id) || !['full', 'split', 'over'].includes(mode)) return false;
|
|
346
|
+
if (pinned(id) && mode !== 'split') return false; // the page changes only through its own controls: it never slides over
|
|
266
347
|
mark(id);
|
|
267
348
|
const was = S.row.slice();
|
|
268
349
|
drop(id);
|
|
269
350
|
if (mode === 'full') {
|
|
270
|
-
// the others give way: the chat
|
|
271
|
-
|
|
272
|
-
|
|
351
|
+
// the others give way: the chat (or the page) steps away (the Live pill, Split or a close brings it back), the other Viewers close
|
|
352
|
+
// (the row is set first: a Viewer that closes lays the panels out again, and must find this one already full)
|
|
353
|
+
const others = [...S.row, S.over, ...S.away].filter((x) => x && x !== id);
|
|
354
|
+
S.row = [id]; S.over = null; S.away = others.includes(C) ? [C] : []; S.fr = [];
|
|
355
|
+
layout();
|
|
356
|
+
others.filter(isV).forEach((x) => P.close(x));
|
|
357
|
+
return true;
|
|
273
358
|
} else if (mode === 'split') {
|
|
274
359
|
if (!S.row.length) { // it was full: the panel put away comes back beside it
|
|
275
|
-
const back = S.over || S.away.pop() || null; if (back) drop(back);
|
|
276
|
-
S.row = !back ? [id] : back ===
|
|
277
|
-
} else if (id ===
|
|
360
|
+
const back = (S.over && !pinned(S.over) ? S.over : null) || S.away.pop() || null; if (back) drop(back);
|
|
361
|
+
S.row = !back ? [id] : back === C ? [C, id] : [id, back];
|
|
362
|
+
} else if (id === C) S.row.unshift(id); else S.row.push(id);
|
|
278
363
|
fit(id);
|
|
279
364
|
} else {
|
|
280
365
|
if (S.over) { const o = S.over; S.over = null; S.away.push(o); }
|
|
@@ -287,11 +372,13 @@ function place(id, mode) {
|
|
|
287
372
|
return true;
|
|
288
373
|
}
|
|
289
374
|
function putAway() {
|
|
290
|
-
if (!S.over) return false;
|
|
375
|
+
if (!S.over || pinned(S.over)) return false;
|
|
291
376
|
const id = S.over; S.over = null; S.away.push(id);
|
|
292
377
|
layout();
|
|
293
378
|
return true;
|
|
294
379
|
}
|
|
380
|
+
/** The panel put away last that the Live pill can bring back (never the page hidden behind a full screen Viewer). */
|
|
381
|
+
const lastAway = () => [...S.away].reverse().find((x) => !pinned(x)) || null;
|
|
295
382
|
function slideOver(item) {
|
|
296
383
|
if (!S.on || isPhone()) return false;
|
|
297
384
|
const pend = S.pend && Date.now() - S.pend.t < 6000 ? S.pend : null;
|
|
@@ -299,9 +386,9 @@ function slideOver(item) {
|
|
|
299
386
|
// a Live pill row: the page opens the chat (Home's own handler); the chat comes where it can be seen
|
|
300
387
|
if (!S.go || !S.go(item)) return false;
|
|
301
388
|
if (item.kind === 'rec') return true;
|
|
302
|
-
mark(
|
|
303
|
-
if (pend) { S.pend = null; P.unbeside(); drop(
|
|
304
|
-
else if (!visible(
|
|
389
|
+
mark(C);
|
|
390
|
+
if (pend) { S.pend = null; P.unbeside(); drop(C); if (pend.side === 'left') S.row.unshift(C); else S.row.push(C); S.fr = []; fit(C); layout(); }
|
|
391
|
+
else if (!visible(C)) place(C, 'over');
|
|
305
392
|
return true;
|
|
306
393
|
}
|
|
307
394
|
if (item && (typeof item.render === 'function' || item.html)) { // a Viewer of its own, floating over
|
|
@@ -309,32 +396,49 @@ function slideOver(item) {
|
|
|
309
396
|
openViewer({ ...item, fresh: true });
|
|
310
397
|
return true;
|
|
311
398
|
}
|
|
312
|
-
const back =
|
|
399
|
+
const back = lastAway();
|
|
313
400
|
if (!back) return false;
|
|
401
|
+
S.away = S.away.filter((x) => x !== back);
|
|
314
402
|
if (S.over) S.away.push(S.over);
|
|
315
|
-
S.over = back; mark(back);
|
|
403
|
+
S.over = back; mark(back); P.use(back);
|
|
316
404
|
layout();
|
|
317
405
|
return true;
|
|
318
406
|
}
|
|
407
|
+
/** Where a new panel beside goes: the right of the row. On a laptop page that already shows a Viewer, it slides over (rule 5, "on a
|
|
408
|
+
* laptop the second item slides over"); at 1600 px and wider the Viewer used least recently gives way (fit). */
|
|
409
|
+
function besideTo() { return S.page && maxRow() === 2 && S.row.length >= 2 ? { mode: 'over', t: Date.now() } : { side: 'right', t: Date.now() }; }
|
|
410
|
+
/** ⌘/Ctrl-click, a middle click or the API: a source row opens beside (as a drop at the far edge); a Viewer item opens in a Viewer of its own. */
|
|
411
|
+
function openBeside(x) {
|
|
412
|
+
if (!S.on || isPhone() || !x) return false;
|
|
413
|
+
S.pend = besideTo(); P.beside();
|
|
414
|
+
if (x.nodeType === 1) { S.noMod = Date.now(); x.click(); }
|
|
415
|
+
else if (typeof x.render === 'function' || x.html) openViewer({ ...x, fresh: true });
|
|
416
|
+
else { S.pend = null; P.unbeside(); return false; }
|
|
417
|
+
setTimeout(() => { if (S.pend && Date.now() - S.pend.t > 5500) { S.pend = null; P.unbeside(); } }, 6000);
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
319
420
|
|
|
320
421
|
/* ── a new or closed Viewer ── */
|
|
321
422
|
function onViewer(d) {
|
|
322
423
|
if (!S.on || !d || !d.panel) return;
|
|
323
424
|
if (d.shut) { drop(d.panel); S.fr = []; layout(); return; }
|
|
324
425
|
mark(d.panel);
|
|
325
|
-
if (S.row.includes(d.panel) || S.over === d.panel || S.away.includes(d.panel)) {
|
|
426
|
+
if (S.row.includes(d.panel) || S.over === d.panel || S.away.includes(d.panel)) {
|
|
427
|
+
if (S.away.includes(d.panel)) { drop(d.panel); if (S.over) S.away.push(S.over); S.over = d.panel; } // a plain click into the Viewer put away: it slides back over
|
|
428
|
+
layout(); return;
|
|
429
|
+
}
|
|
326
430
|
const pend = S.pend && Date.now() - S.pend.t < 6000 ? S.pend : null; S.pend = null;
|
|
327
431
|
if (pend && pend.mode === 'over') { if (S.over) S.away.push(S.over); S.over = d.panel; }
|
|
328
|
-
else if (pend && pend.side === 'left') S.row.unshift(d.panel);
|
|
432
|
+
else if (pend && pend.side === 'left' && !S.page) S.row.unshift(d.panel);
|
|
329
433
|
else S.row.push(d.panel);
|
|
330
434
|
S.fr = [];
|
|
331
435
|
fit(d.panel);
|
|
332
436
|
layout();
|
|
333
437
|
}
|
|
334
438
|
|
|
335
|
-
/* ── the chat's own ⧉ and × (TbT1Split): only while a Viewer is open, when there is something to arrange ── */
|
|
439
|
+
/* ── the chat's own ⧉ and × (TbT1Split): only while a Viewer is open, when there is something to arrange. A page has its own controls. ── */
|
|
336
440
|
function tools() {
|
|
337
|
-
if (!S.chat) return;
|
|
441
|
+
if (!S.chat || S.page) return;
|
|
338
442
|
let t = S.chat.querySelector(':scope > .cz-pn-ct');
|
|
339
443
|
const want = S.on && !isPhone() && vs().length > 0;
|
|
340
444
|
document.body.classList.toggle('cz-pn-ctl', want);
|
|
@@ -345,8 +449,8 @@ function tools() {
|
|
|
345
449
|
+ `<button type="button" class="cz-vw-ib" data-cz-pn-chat="away" aria-label="Put the chat away" title="Put the chat away. The Live pill brings it back.">${svg(IC.close)}</button>`;
|
|
346
450
|
t.addEventListener('click', (e) => {
|
|
347
451
|
const b = e.target.closest('[data-cz-pn-chat]'); if (!b) return;
|
|
348
|
-
if (b.dataset.czPnChat === 'place') openMenu(
|
|
349
|
-
else if (S.over ===
|
|
452
|
+
if (b.dataset.czPnChat === 'place') openMenu(C, b);
|
|
453
|
+
else if (S.over === C) putAway(); else shut(C);
|
|
350
454
|
});
|
|
351
455
|
S.chat.appendChild(t);
|
|
352
456
|
}
|
|
@@ -374,7 +478,7 @@ function grab(el, want) {
|
|
|
374
478
|
el.prepend(g);
|
|
375
479
|
}
|
|
376
480
|
|
|
377
|
-
/* ── open beside: drag a row
|
|
481
|
+
/* ── open beside: drag a row onto the panels (TbT5DragRow, BiB4DragRow, BiB9DropOn) ── */
|
|
378
482
|
let D = null;
|
|
379
483
|
function area() {
|
|
380
484
|
const r0 = rect(S.row[0]), r1 = rect(S.row[S.row.length - 1]);
|
|
@@ -389,20 +493,46 @@ function dragStart() {
|
|
|
389
493
|
document.body.classList.add('cz-pn-dragrow');
|
|
390
494
|
D.on = true;
|
|
391
495
|
}
|
|
496
|
+
/** What a drop at (x, y) does: { on: <Viewer id> } replaces that Viewer; { side } opens beside on that side; null does nothing. With the
|
|
497
|
+
* box the blue zone covers. A Viewer that slides over is on top, so it is asked first. */
|
|
498
|
+
function target(x, y) {
|
|
499
|
+
const a = area(); if (!a) return null;
|
|
500
|
+
const vh = Math.min(a.bottom, innerHeight), top = Math.max(a.top, 0);
|
|
501
|
+
const strip = (side) => ({ side, box: { left: side === 'left' ? a.left : a.right - EDGE, top, width: EDGE, height: vh - top } });
|
|
502
|
+
const inBox = (r) => r && x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;
|
|
503
|
+
const ro = S.over && isV(S.over) ? rect(S.over) : null;
|
|
504
|
+
if (inBox(ro)) return { on: S.over, box: ro };
|
|
505
|
+
const inside = x >= a.left && x <= a.right && y >= top && y <= vh;
|
|
506
|
+
if (!inside) return null;
|
|
507
|
+
if (x > a.right - EDGE && S.row.some(isV)) return strip('right');
|
|
508
|
+
if (x < a.left + EDGE && !S.page && S.row.some(isV)) return strip('left');
|
|
509
|
+
const v = S.row.filter(isV).find((id) => inBox(rect(id)));
|
|
510
|
+
if (v) return { on: v, box: rect(v) };
|
|
511
|
+
if (S.page) { // over the page: with no Viewer the right half opens one; the page itself changes only through its own controls
|
|
512
|
+
if (S.row.some(isV)) return null;
|
|
513
|
+
const mid = (a.left + a.right) / 2;
|
|
514
|
+
return x >= mid ? { side: 'right', box: { left: mid, top, width: a.right - mid, height: vh - top } } : null;
|
|
515
|
+
}
|
|
516
|
+
const mid = (a.left + a.right) / 2, side = x < mid ? 'left' : 'right';
|
|
517
|
+
return { side, box: { left: side === 'left' ? a.left : mid, top, width: side === 'left' ? mid - a.left : a.right - mid, height: vh - top } };
|
|
518
|
+
}
|
|
392
519
|
function dragMove(e) {
|
|
393
520
|
D.ghost.style.left = (e.clientX + 14) + 'px'; D.ghost.style.top = (e.clientY + 10) + 'px';
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
D.
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
D.zone.dataset.side = D.side;
|
|
521
|
+
const t = target(e.clientX, e.clientY);
|
|
522
|
+
D.t = t;
|
|
523
|
+
D.zone.hidden = !t;
|
|
524
|
+
if (t) {
|
|
525
|
+
Object.assign(D.zone.style, { top: t.box.top + 'px', height: t.box.height + 'px', left: t.box.left + 'px', width: t.box.width + 'px' });
|
|
526
|
+
D.zone.dataset.side = t.side || '';
|
|
527
|
+
D.zone.dataset.on = t.on || '';
|
|
402
528
|
}
|
|
403
529
|
}
|
|
404
530
|
/** A selector that finds the row again: the list may draw itself anew while the row is dragged. */
|
|
405
531
|
function again(src) {
|
|
532
|
+
if (S.page) {
|
|
533
|
+
const a = [...src.attributes].find((x) => /^data-/.test(x.name) && x.value);
|
|
534
|
+
return a ? `[${a.name}="${CSS.escape(a.value)}"]` : null;
|
|
535
|
+
}
|
|
406
536
|
for (const k of ['hmSel', 'lv', 'file', 'ctx', 'att']) {
|
|
407
537
|
if (src.dataset[k] == null) continue;
|
|
408
538
|
const attr = 'data-' + k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase());
|
|
@@ -412,16 +542,22 @@ function again(src) {
|
|
|
412
542
|
}
|
|
413
543
|
function dragEnd(d) {
|
|
414
544
|
d.ghost.remove(); d.zone.remove(); document.body.classList.remove('cz-pn-dragrow');
|
|
415
|
-
if (!
|
|
545
|
+
const t = d.t; if (!t) return;
|
|
416
546
|
S.noClick = Date.now(); // the press that ends a drag is not also a click
|
|
417
|
-
S.
|
|
547
|
+
const click = () => { S.noClick = 0; const src = d.src.isConnected ? d.src : d.sel && (S.page ? S.chat.querySelector(d.sel) || document.querySelector(d.sel) : document.querySelector(d.sel)); if (src) { S.noMod = Date.now(); src.click(); } };
|
|
548
|
+
if (t.on) { // onto a Viewer: that Viewer shows the row (BiB9DropOn)
|
|
549
|
+
S.pend = null; P.unbeside(); mark(t.on); P.use(t.on);
|
|
550
|
+
setTimeout(click, 0);
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
S.pend = t.side === 'right' ? besideTo() : { side: t.side, t: Date.now() };
|
|
418
554
|
if (!d.src.matches('#czLiveList a[data-lv]')) P.beside();
|
|
419
|
-
setTimeout(() => {
|
|
555
|
+
setTimeout(() => { click(); setTimeout(() => { if (S.pend && Date.now() - S.pend.t > 5500) { S.pend = null; P.unbeside(); } }, 6000); }, 0);
|
|
420
556
|
}
|
|
421
557
|
function dragWire() {
|
|
422
558
|
document.addEventListener('pointerdown', (e) => {
|
|
423
559
|
if (!S.on || isPhone() || e.button !== 0 || e.pointerType === 'touch') return;
|
|
424
|
-
const src = e.target.closest && e.target.closest(
|
|
560
|
+
const src = e.target.closest && e.target.closest(S.src); if (!src) return;
|
|
425
561
|
D = { src, sel: again(src), x0: e.clientX, y0: e.clientY, pid: e.pointerId, on: false };
|
|
426
562
|
}, true);
|
|
427
563
|
document.addEventListener('pointermove', (e) => {
|
|
@@ -431,14 +567,29 @@ function dragWire() {
|
|
|
431
567
|
}, true);
|
|
432
568
|
document.addEventListener('pointerup', (e) => { if (!D || e.pointerId !== D.pid) return; const d = D; D = null; if (d.on) dragEnd(d); }, true);
|
|
433
569
|
document.addEventListener('pointercancel', () => { if (D && D.on) { D.ghost.remove(); D.zone.remove(); document.body.classList.remove('cz-pn-dragrow'); } D = null; }, true);
|
|
434
|
-
document.addEventListener('dragstart', (e) => { if (S.on && e.target.closest && e.target.closest(
|
|
435
|
-
document.addEventListener('click', (e) => {
|
|
570
|
+
document.addEventListener('dragstart', (e) => { if (S.on && e.target.closest && e.target.closest(S.src)) e.preventDefault(); }, true); // a link drags our way
|
|
571
|
+
document.addEventListener('click', (e) => {
|
|
572
|
+
if (e.isTrusted && S.noClick && Date.now() - S.noClick < 500) { e.preventDefault(); e.stopPropagation(); S.noClick = 0; return; }
|
|
573
|
+
// ⌘/Ctrl-click on a page's source row opens it beside (the row's own handler opens it; the engine says where)
|
|
574
|
+
if (!S.page || !S.on || isPhone() || !(e.metaKey || e.ctrlKey) || (S.noMod && Date.now() - S.noMod < 300)) return;
|
|
575
|
+
const src = e.target.closest && e.target.closest(besideSel()); if (!src) return;
|
|
576
|
+
S.pend = besideTo(); P.beside();
|
|
577
|
+
if (src.matches('a[href]')) e.preventDefault(); // not a new browser tab
|
|
578
|
+
}, true);
|
|
579
|
+
// a middle click on a source row opens it beside too
|
|
580
|
+
document.addEventListener('auxclick', (e) => {
|
|
581
|
+
if (!S.page || !S.on || isPhone() || e.button !== 1) return;
|
|
582
|
+
const src = e.target.closest && e.target.closest(besideSel()); if (!src) return;
|
|
583
|
+
e.preventDefault(); openBeside(src);
|
|
584
|
+
}, true);
|
|
585
|
+
document.addEventListener('mousedown', (e) => { if (S.page && e.button === 1 && e.target.closest && e.target.closest(besideSel())) e.preventDefault(); }, true); // no autoscroll
|
|
436
586
|
}
|
|
587
|
+
const besideSel = () => [S.src, S.clicks].filter(Boolean).join(', ');
|
|
437
588
|
|
|
438
|
-
/* ── remembered per initiative (rule 7) ── */
|
|
589
|
+
/* ── remembered per initiative on Home (rule 7) ── */
|
|
439
590
|
function snapshot() {
|
|
440
591
|
return {
|
|
441
|
-
v: 1, n: S.row.length, fr: S.fr.slice(), chat: S.over ===
|
|
592
|
+
v: 1, n: S.row.length, fr: S.fr.slice(), chat: S.over === C ? 'over' : S.away.includes(C) ? 'away' : 'split', chatAt: Math.max(0, S.row.indexOf(C)),
|
|
442
593
|
items: vs().map((p) => ({ ...(p.item || {}), at: S.row.indexOf(p.id), over: S.over === p.id })).filter((x) => x.id),
|
|
443
594
|
};
|
|
444
595
|
}
|
|
@@ -462,8 +613,8 @@ async function restore(id) {
|
|
|
462
613
|
if (S.scope !== id) return;
|
|
463
614
|
}
|
|
464
615
|
if (vs().length) {
|
|
465
|
-
if (m.chat === 'away' && visible(
|
|
466
|
-
else if (m.chat === 'over' && S.over !==
|
|
616
|
+
if (m.chat === 'away' && visible(C)) { drop(C); S.away.push(C); }
|
|
617
|
+
else if (m.chat === 'over' && S.over !== C) { drop(C); if (S.over) S.away.push(S.over); S.over = C; }
|
|
467
618
|
if (S.row.length === m.n && Array.isArray(m.fr) && m.fr.length === m.n) S.fr = m.fr.slice();
|
|
468
619
|
}
|
|
469
620
|
} finally {
|
|
@@ -473,50 +624,66 @@ async function restore(id) {
|
|
|
473
624
|
}
|
|
474
625
|
function scope(id) {
|
|
475
626
|
id = id || null;
|
|
476
|
-
if (id === S.scope) return;
|
|
627
|
+
if (S.page || id === S.scope) return;
|
|
477
628
|
S.scope = id;
|
|
478
629
|
if (id) restore(id);
|
|
479
630
|
}
|
|
480
631
|
|
|
481
|
-
/* ── Present: the chat slides away while a recording presents, and comes back on Stop (rule 8) ── */
|
|
632
|
+
/* ── Present (Home): the chat slides away while a recording presents, and comes back on Stop (rule 8) ── */
|
|
482
633
|
function presentOn() {
|
|
483
|
-
if (S.auto || isPhone() || !vs().length || !visible(
|
|
484
|
-
drop(
|
|
634
|
+
if (S.page || S.auto || isPhone() || !vs().length || !visible(C)) return;
|
|
635
|
+
drop(C); S.away.push(C); S.auto = true; layout();
|
|
485
636
|
}
|
|
486
637
|
function presentOff() {
|
|
487
638
|
if (!S.auto) return;
|
|
488
639
|
S.auto = false;
|
|
489
|
-
if (S.away.includes(
|
|
640
|
+
if (S.away.includes(C)) { drop(C); S.row.unshift(C); S.fr = []; fit(C, true); }
|
|
490
641
|
layout();
|
|
491
642
|
}
|
|
492
643
|
|
|
493
644
|
export function mountPanels(o = {}) {
|
|
494
645
|
if (S.on || typeof document === 'undefined') return window.czPanels;
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
646
|
+
if (o.page) {
|
|
647
|
+
S.page = true; C = 'page'; S.row = [C];
|
|
648
|
+
S.chat = o.page; S.desk = o.desk || o.page.parentNode;
|
|
649
|
+
S.src = o.sources || ''; S.clicks = o.clicks || ''; S.fitFn = typeof o.fit === 'function' ? o.fit : null;
|
|
650
|
+
S.key = o.key || o.page.id || 'page';
|
|
651
|
+
if (!S.desk) return null;
|
|
652
|
+
if (!S.desk.querySelector('[data-cz-viewer-host]')) { const h = document.createElement('div'); h.className = 'cz-pn-host'; h.setAttribute('data-cz-viewer-host', ''); S.desk.appendChild(h); }
|
|
653
|
+
document.body.classList.add('cz-pn-page');
|
|
654
|
+
document.querySelectorAll('.cz-vw.cz-vw-float').forEach((el) => { document.querySelector('[data-cz-viewer-host]').appendChild(el); el.classList.remove('cz-vw-float'); }); // opened before the mount
|
|
655
|
+
} else {
|
|
656
|
+
S.desk = o.desk || document.querySelector('[data-cz-viewer-host]') && document.querySelector('[data-cz-viewer-host]').parentNode;
|
|
657
|
+
S.chat = o.chat || document.getElementById('hmChat');
|
|
658
|
+
if (!S.desk || !S.chat) return null;
|
|
659
|
+
S.go = typeof o.go === 'function' ? o.go : null;
|
|
660
|
+
S.reopen = typeof o.reopen === 'function' ? o.reopen : null;
|
|
661
|
+
}
|
|
662
|
+
// the sheet sets the desk's padding: a Viewer opened before it lands (?focus= on load) is sized again once it has, so the page stays whole
|
|
663
|
+
if (!document.querySelector(`link[href="${SHEET}"]`)) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = SHEET; l.onload = () => layout(); document.head.appendChild(l); }
|
|
501
664
|
S.on = true;
|
|
502
665
|
P.config({ limit: 3, place: (id, b) => openMenu(id, b), managed: (id) => managed() && (S.row.includes(id) || S.over === id || S.away.includes(id)) });
|
|
503
666
|
document.addEventListener('cz-viewer', (e) => onViewer(e.detail));
|
|
504
667
|
document.addEventListener('cz:vw-rail', (e) => { if (managed() && e.detail && !e.detail.on) S.keepList = true; }); // the rail's list button: the list stays
|
|
505
|
-
['pointerdown', 'focusin'].forEach((k) => document.addEventListener(k, (e) => {
|
|
668
|
+
['pointerdown', 'focusin', 'wheel'].forEach((k) => document.addEventListener(k, (e) => {
|
|
506
669
|
const t = e.target; if (!t || !t.closest) return;
|
|
507
|
-
const p = t.closest('[data-cz-panel]');
|
|
508
|
-
|
|
670
|
+
const p = t.closest('[data-cz-panel]');
|
|
671
|
+
if (p) { mark(p.dataset.czPanel); used(p.dataset.czPanel); } else if (S.chat.contains(t)) mark(C);
|
|
672
|
+
}, { capture: true, passive: true }));
|
|
509
673
|
dragWire();
|
|
510
674
|
let rz = 0;
|
|
511
675
|
addEventListener('resize', () => { cancelAnimationFrame(rz); rz = requestAnimationFrame(() => { fit(null, true); S.keepList = false; layout(); }); });
|
|
512
|
-
if (typeof
|
|
513
|
-
|
|
514
|
-
|
|
676
|
+
if (S.page && typeof ResizeObserver !== 'undefined') new ResizeObserver(() => narrow()).observe(S.chat);
|
|
677
|
+
if (!S.page) {
|
|
678
|
+
if (typeof BroadcastChannel === 'function') {
|
|
679
|
+
const ch = new BroadcastChannel('pmos-present');
|
|
680
|
+
ch.addEventListener('message', (e) => { const t = e.data && e.data.t; if (t === 'present' || t === 'show') presentOn(); else if (t === 'off') presentOff(); });
|
|
681
|
+
}
|
|
682
|
+
onRecording((s) => { if (!s || !s.on) presentOff(); });
|
|
515
683
|
}
|
|
516
|
-
onRecording((s) => { if (!s || !s.on) presentOff(); });
|
|
517
684
|
window.czPanels = {
|
|
518
|
-
list, place, slideOver, putAway, scope,
|
|
519
|
-
away:
|
|
685
|
+
list, place, slideOver, putAway, scope, openBeside,
|
|
686
|
+
away: lastAway,
|
|
520
687
|
onChange(fn) { if (typeof fn === 'function') S.subs.push(fn); },
|
|
521
688
|
};
|
|
522
689
|
layout();
|