fablecut 1.22.1 → 1.23.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/CLAUDE.md +19 -0
- package/README.md +1 -0
- package/app.js +197 -77
- package/compact.css +702 -0
- package/compact.js +785 -0
- package/index.html +27 -10
- package/layout.js +72 -0
- package/manifest.json +1 -1
- package/mcp-server.js +1 -1
- package/package.json +2 -1
- package/style.css +7 -0
- package/touch.js +815 -0
package/compact.js
ADDED
|
@@ -0,0 +1,785 @@
|
|
|
1
|
+
/* The compact editor: what phones and tablets see around the same panels.
|
|
2
|
+
|
|
3
|
+
layout.js says which layout is on; compact.css arranges the page for it.
|
|
4
|
+
This script adds the few things desktop has no need for: undo / redo
|
|
5
|
+
buttons, a tool bar that follows the selection, and the sheet that shows
|
|
6
|
+
one panel at a time. The panels themselves are the desktop ones, left where
|
|
7
|
+
they are in the page, so a field keeps its text and focus when the layout
|
|
8
|
+
changes. Every button here calls the function or clicks the control desktop
|
|
9
|
+
uses: there is one way to do each edit. On a desktop layout nothing here shows.
|
|
10
|
+
|
|
11
|
+
Loaded after app.js, whose top-level names it uses. */
|
|
12
|
+
(() => {
|
|
13
|
+
"use strict";
|
|
14
|
+
const L = self.FableCutLayout, app = document.getElementById("app");
|
|
15
|
+
if (!L || !app) return;
|
|
16
|
+
const phone = () => L.mode === "phone";
|
|
17
|
+
const compact = () => L.mode !== "desktop";
|
|
18
|
+
|
|
19
|
+
/* ── Icons: 16-unit grid, 1.4 stroke, like the rest of the editor's ── */
|
|
20
|
+
const P = {
|
|
21
|
+
back: "M10 3 5 8l5 5", down: "M3 5.5 8 10.5l5-5", close: "M3.5 3.5l9 9M12.5 3.5l-9 9", check: "M3 8.5l3.3 3.3L13 4.5",
|
|
22
|
+
undo: "M5.5 3 2.5 6l3 3M2.5 6h6.7a3.6 3.6 0 0 1 0 7.2H6.5", redo: "M10.5 3l3 3-3 3M13.5 6H6.8a3.6 3.6 0 0 0 0 7.2h2.7",
|
|
23
|
+
media: "M1.75 3h12.5v10H1.75zM4.75 3v10M11.25 3v10M1.75 6.3h3M1.75 9.7h3M11.25 6.3h3M11.25 9.7h3",
|
|
24
|
+
audio: "M6 12V3.6l7-1.4v8.6M6 12a1.8 1.8 0 1 1-3.6 0A1.8 1.8 0 0 1 6 12M13 10.8a1.8 1.8 0 1 1-3.6 0a1.8 1.8 0 0 1 3.6 0",
|
|
25
|
+
text: "M3 4.6V3h10v1.6M8 3v10M6.2 13h3.6", shapes: "M2 2.2h7v7H2zM14 10.2a3.8 3.8 0 1 1-7.6 0a3.8 3.8 0 0 1 7.6 0",
|
|
26
|
+
words: "M1.75 3.2h12.5v9.6H1.75zM4 10h3.6M9.4 10H12M4 7.2h1.8M7.6 7.2H12",
|
|
27
|
+
adjust: "M2 4.5h6.6M12.4 4.5H14M2 11.5h1.6M7.4 11.5H14M12.4 4.5a1.9 1.9 0 1 1-3.8 0a1.9 1.9 0 0 1 3.8 0M7.4 11.5a1.9 1.9 0 1 1-3.8 0a1.9 1.9 0 0 1 3.8 0",
|
|
28
|
+
marker: "M8 1.8 12.8 6.6 8 11.4 3.2 6.6zM8 11.4v3", range: "M3 2.5v11M13 2.5v11M5.2 8h5.6M6.8 6.2 5.2 8l1.6 1.8M9.2 6.2 10.8 8 9.2 9.8",
|
|
29
|
+
canvas: "M4.5 1.5v10h10M1.5 4.5h10v10", mixer: "M3.5 2v12M8 2v12M12.5 2v12M2 9.5h3M6.5 5h3M11 10.8h3",
|
|
30
|
+
color: "M11.2 5.8a3.2 3.2 0 1 1-6.4 0a3.2 3.2 0 0 1 6.4 0M8.8 10a3.2 3.2 0 1 1-6.4 0a3.2 3.2 0 0 1 6.4 0M13.6 10a3.2 3.2 0 1 1-6.4 0a3.2 3.2 0 0 1 6.4 0",
|
|
31
|
+
list: "M1.75 3.25h12.5M1.75 8h8.5M1.75 12.75h10.5", all: "M2 2h5v5H2zM9 2h5v5H9zM2 9h5v5H2zM9 9h5v5H9z",
|
|
32
|
+
split: "M8 1.5v13M5.2 5.2 2.4 8l2.8 2.8M10.8 5.2 13.6 8l-2.8 2.8", trash: "M2.5 4h11M6 4V2.2h4V4M3.8 4l.7 9.8h7L12.2 4M6.6 6.5v4.8M9.4 6.5v4.8",
|
|
33
|
+
trimIn: "M6 3H3v10h3M13.2 8H7M9.4 5.6 7 8l2.4 2.4", trimOut: "M10 3h3v10h-3M2.8 8H9M6.6 5.6 9 8l-2.4 2.4",
|
|
34
|
+
edit: "M2.8 13.2l.7-3.1 7.3-7.3 2.4 2.4-7.3 7.3zM9.2 4.4l2.4 2.4", volume: "M2 6v4h2.4L8 13V3L4.4 6zM10.2 5.8a3 3 0 0 1 0 4.4M12.2 3.8a6 6 0 0 1 0 8.4",
|
|
35
|
+
speed: "M2.6 12a6.2 6.2 0 1 1 10.8 0M8 10.2 11 6.4M8 10.2v.1", filter: "M14 8A6 6 0 1 1 2 8a6 6 0 0 1 12 0M8 2v12M8 5l4.8-.8M8 8h6M8 11l4.8.8",
|
|
36
|
+
animate: "M4 4.6 6.4 7 4 9.4 1.6 7zM12 6.6 14.4 9 12 11.4 9.6 9zM6.4 7.4 9.6 8.6", mask: "M2 3h12v10H2zM10.8 8a2.8 2.8 0 1 1-5.6 0a2.8 2.8 0 0 1 5.6 0",
|
|
37
|
+
trans: "M2 3.5 7 8l-5 4.5zM14 3.5 9 8l5 4.5z", cutout: "M8 8.2a2.6 2.6 0 1 0 0-5.2a2.6 2.6 0 0 0 0 5.2M3.2 13.6a4.9 4.9 0 0 1 9.6 0M1.5 4V1.5H4M12 1.5h2.5V4",
|
|
38
|
+
track: "M8 1.5v3M8 11.5v3M1.5 8h3M11.5 8h3M10.6 8a2.6 2.6 0 1 1-5.2 0a2.6 2.6 0 0 1 5.2 0", source: "M1.75 3h12.5v8H1.75zM5 14h6M8 11v3M6.8 5.2v3.6L10 7z",
|
|
39
|
+
select: "M2 5V2h3M11 2h3v3M14 11v3h-3M5 14H2v-3M5.4 8.2l1.9 1.9 3.5-3.9", view: "M1.5 4.5v7M14.5 4.5v7M4 8h8M5.8 6.2 4 8l1.8 1.8M10.2 6.2 12 8l-1.8 1.8",
|
|
40
|
+
snap: "M3.5 2.5V8a4.5 4.5 0 0 0 9 0V2.5M3.5 5.2h2.6M9.9 5.2h2.6M6.1 2.5V8a1.9 1.9 0 0 0 3.8 0V2.5", scopes: "M1.75 2.5h12.5v11H1.75zM4 11V8.5M6.6 11V5.5M9.3 11V7M12 11V4.5",
|
|
41
|
+
style: "M2.5 12.5 6 3.5l3.5 9M3.7 9.5h4.6M11 5.5l2.5 0M12.25 4.2v2.6M11.2 11.5h2.6", ripple: "M2 3.5h4v9H2zM13.5 8H8M10.2 5.8 8 8l2.2 2.2",
|
|
42
|
+
clip: "M1.75 4.5h12.5v7H1.75zM5 4.5v7M11 4.5v7", plus: "M8 3v10M3 8h10", prevKey: "M9.5 4 5.5 8l4 4M3 4v8", nextKey: "M6.5 4l4 4-4 4M13 4v8",
|
|
43
|
+
};
|
|
44
|
+
const dots = `<svg class="m-ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M3 6.6a1.4 1.4 0 1 0 0 2.8a1.4 1.4 0 0 0 0-2.8M8 6.6a1.4 1.4 0 1 0 0 2.8a1.4 1.4 0 0 0 0-2.8M13 6.6a1.4 1.4 0 1 0 0 2.8a1.4 1.4 0 0 0 0-2.8"/></svg>`;
|
|
45
|
+
const ico = (n) => n === "more" ? dots
|
|
46
|
+
: `<svg class="m-ico" viewBox="0 0 16 16" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="1.35" stroke-linecap="round" stroke-linejoin="round" d="${P[n] || P.clip}"/></svg>`;
|
|
47
|
+
const make = (tag, cls, html = "") => { const e = document.createElement(tag); e.className = cls; e.innerHTML = html; return e; };
|
|
48
|
+
const button = (cls, icon, label, run, text) => {
|
|
49
|
+
const b = make("button", cls, ico(icon) + (text ? `<span>${text}</span>` : ""));
|
|
50
|
+
b.type = "button"; b.setAttribute("aria-label", label);
|
|
51
|
+
b.addEventListener("click", run);
|
|
52
|
+
return b;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/* ── Top bar: back, name, undo, redo, more, export ── */
|
|
56
|
+
const topbar = app.querySelector(".topbar");
|
|
57
|
+
// the button on the left of the desktop top bar that leaves the project (a hosted editor may add its own)
|
|
58
|
+
const leave = () => topbar.querySelector(":scope > button:not(.m-btn):not(.hidden)");
|
|
59
|
+
// (inside a composition it steps out of it, as Esc does)
|
|
60
|
+
const back = button("m-btn m-back", "back", "Projects", () => { if (state.compCtx) { exitComp(1); refresh(); return; } const b = leave(); if (b) b.click(); });
|
|
61
|
+
const nameEl = make("span", "m-name");
|
|
62
|
+
const bUndo = button("m-btn", "undo", "Undo", () => undo()), bRedo = button("m-btn", "redo", "Redo", () => redo());
|
|
63
|
+
const bMore = button("m-btn m-more", "more", "More", () => toggleSheet("more"));
|
|
64
|
+
const bExport = make("button", "btn primary m-export", "Export");
|
|
65
|
+
bExport.type = "button";
|
|
66
|
+
bExport.addEventListener("click", () => $("btnExport").click());
|
|
67
|
+
const acts = make("div", "m-acts");
|
|
68
|
+
acts.append(bUndo, bRedo, bMore, bExport);
|
|
69
|
+
topbar.prepend(back, nameEl);
|
|
70
|
+
topbar.insertBefore(acts, topbar.querySelector(".topbar-right"));
|
|
71
|
+
|
|
72
|
+
/* ── The sheet's head: grip, title, previous / next keyframe, done ── */
|
|
73
|
+
const head = make("div", "m-head"), grip = make("div", "m-grip"), titleEl = make("b", "m-title"), chips = make("div", "m-chips");
|
|
74
|
+
const keyNav = make("span", "m-keys");
|
|
75
|
+
const bScopes = button("m-btn m-scopes-btn", "scopes", "Scopes", () => { app.classList.toggle("m-scopes"); bScopes.classList.toggle("on", app.classList.contains("m-scopes")); scopes.last = 0; });
|
|
76
|
+
const bFine = make("button", "m-fine", "Fine");
|
|
77
|
+
bFine.type = "button"; bFine.title = "Wheels move five times slower"; bFine.setAttribute("aria-pressed", "false");
|
|
78
|
+
bFine.addEventListener("click", () => { runtime.fineWheels = !runtime.fineWheels; bFine.classList.toggle("on", runtime.fineWheels); bFine.setAttribute("aria-pressed", runtime.fineWheels); });
|
|
79
|
+
keyNav.append(bFine, bScopes, button("m-btn", "prevKey", "Previous keyframe", () => goToKeyframe(-1)), button("m-btn", "nextKey", "Next keyframe", () => goToKeyframe(1)));
|
|
80
|
+
const row = make("div", "m-head-row");
|
|
81
|
+
row.append(titleEl, keyNav, button("m-btn m-done", "down", "Close", () => closeSheet()));
|
|
82
|
+
head.append(grip, row, chips);
|
|
83
|
+
const list = make("div", "m-list");
|
|
84
|
+
const tools = make("nav", "m-tools");
|
|
85
|
+
tools.setAttribute("aria-label", "Tools");
|
|
86
|
+
const rail = make("nav", "m-rail");
|
|
87
|
+
rail.setAttribute("aria-label", "Panels");
|
|
88
|
+
app.append(list, head, tools, rail);
|
|
89
|
+
|
|
90
|
+
/* ── Sheets ──
|
|
91
|
+
One at a time, named on #app as data-sheet; compact.css shows the panel
|
|
92
|
+
that goes with the name. `panel` sheets are the desktop panels; `list`
|
|
93
|
+
sheets are rows made here (menus a toolbar holds on desktop). */
|
|
94
|
+
const SHEETS = {
|
|
95
|
+
media: { title: "Media", open: () => { if (colorState.ws === "color") setWorkspace("edit"); } },
|
|
96
|
+
inspector: { title: "Edit", open: () => setSideTab("inspector"), keys: true, chips: true },
|
|
97
|
+
mixer: { title: "Mixer", open: () => setSideTab("mixer") },
|
|
98
|
+
// a phone's Color sheet is the Color workspace: live scopes, and a layer's mask on the picture
|
|
99
|
+
color: { title: "Color", open: () => { if (phone()) setWorkspace("color"); setSideTab("color"); }, keys: true },
|
|
100
|
+
transcript: { title: "Transcript and captions", open: () => setSideTab("transcript") },
|
|
101
|
+
canvas: { title: "Canvas" },
|
|
102
|
+
tools: { title: "All timeline tools" },
|
|
103
|
+
more: { title: "More", list: moreRows },
|
|
104
|
+
range: { title: "Range (IN and OUT)", list: rangeRows },
|
|
105
|
+
markers: { title: "Markers", list: markerRows },
|
|
106
|
+
view: { title: "Timeline view", list: viewRows },
|
|
107
|
+
play: { title: "Playback", list: playRows },
|
|
108
|
+
track: { title: "Track", list: trackRows },
|
|
109
|
+
trim: { title: "Trim mode", list: trimRows },
|
|
110
|
+
};
|
|
111
|
+
let sheet = null;
|
|
112
|
+
const defaultSheetH = () => {
|
|
113
|
+
// exactly what it replaces (tracks and tool bar), so the preview does not move when a sheet opens
|
|
114
|
+
const top = els.ruler.getBoundingClientRect().bottom, h = window.innerHeight;
|
|
115
|
+
return Math.round(Math.max(h - top, h * 0.36));
|
|
116
|
+
};
|
|
117
|
+
function openSheet(name, opts = {}) {
|
|
118
|
+
const def = SHEETS[name];
|
|
119
|
+
if (!def) return;
|
|
120
|
+
if (!sheet && phone() && !L.landscape) app.style.setProperty("--m-sheet-h", defaultSheetH() + "px");
|
|
121
|
+
if (phone() && name !== "color" && colorState.ws === "color") setWorkspace("edit");
|
|
122
|
+
const at = sheet === name ? list.scrollTop : 0; // a row that stays open redraws the list where it was
|
|
123
|
+
sheet = name;
|
|
124
|
+
app.dataset.sheet = name;
|
|
125
|
+
titleEl.textContent = opts.title || def.title;
|
|
126
|
+
keyNav.hidden = !def.keys;
|
|
127
|
+
if (def.open) def.open();
|
|
128
|
+
list.innerHTML = "";
|
|
129
|
+
app.classList.toggle("m-has-list", !!def.list);
|
|
130
|
+
if (def.list) for (const r of def.list()) list.append(r);
|
|
131
|
+
list.scrollTop = at;
|
|
132
|
+
fillChips();
|
|
133
|
+
if (opts.section) showSection(opts.section);
|
|
134
|
+
refresh();
|
|
135
|
+
}
|
|
136
|
+
function closeSheet() {
|
|
137
|
+
if (!sheet) return;
|
|
138
|
+
if (head.contains(document.activeElement) || isTypingTarget(document.activeElement)) document.activeElement.blur();
|
|
139
|
+
sheet = null;
|
|
140
|
+
if (phone() && colorState.ws === "color") setWorkspace("edit");
|
|
141
|
+
app.classList.remove("m-has-list");
|
|
142
|
+
delete app.dataset.sheet;
|
|
143
|
+
state.dirtyTimeline = true;
|
|
144
|
+
refresh();
|
|
145
|
+
}
|
|
146
|
+
const toggleSheet = (n, o) => (sheet === n ? closeSheet() : openSheet(n, o));
|
|
147
|
+
|
|
148
|
+
/* Inspector: its sections as chips, so a long list is one tap away */
|
|
149
|
+
const sections = () => [...document.querySelectorAll("#inspector .insp-section")].filter((s) => s.querySelector("h3"));
|
|
150
|
+
const secName = (s) => s.querySelector("h3").textContent.replace(/\s+/g, " ").trim();
|
|
151
|
+
function fillChips() {
|
|
152
|
+
const on = sheet && SHEETS[sheet].chips && compact();
|
|
153
|
+
chips.innerHTML = "";
|
|
154
|
+
head.classList.toggle("has-chips", !!on);
|
|
155
|
+
if (!on) return;
|
|
156
|
+
for (const s of sections()) {
|
|
157
|
+
const b = make("button", "m-chip");
|
|
158
|
+
b.type = "button"; b.textContent = secName(s).replace(/ — .*/, "");
|
|
159
|
+
b.addEventListener("click", () => showSection(secName(s)));
|
|
160
|
+
chips.append(b);
|
|
161
|
+
}
|
|
162
|
+
markChip();
|
|
163
|
+
}
|
|
164
|
+
function showSection(want) {
|
|
165
|
+
const s = sections().find((x) => (want instanceof RegExp ? want.test(secName(x)) : secName(x) === want));
|
|
166
|
+
if (!s) return;
|
|
167
|
+
els.inspector.scrollTop += s.getBoundingClientRect().top - els.inspector.getBoundingClientRect().top - 8;
|
|
168
|
+
markChip();
|
|
169
|
+
}
|
|
170
|
+
function markChip() {
|
|
171
|
+
const top = els.inspector.getBoundingClientRect().top + 24;
|
|
172
|
+
const all = sections(), cur = all.filter((s) => s.getBoundingClientRect().top <= top).pop() || all[0];
|
|
173
|
+
[...chips.children].forEach((c, i) => {
|
|
174
|
+
const on = all[i] === cur;
|
|
175
|
+
if (on && !c.classList.contains("on")) chips.scrollTo({ left: c.offsetLeft - 60, behavior: "smooth" });
|
|
176
|
+
c.classList.toggle("on", on);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
els.inspector.addEventListener("scroll", () => { if (sheet === "inspector") markChip(); }, { passive: true });
|
|
180
|
+
|
|
181
|
+
/* Drag the grip: taller, shorter, or away */
|
|
182
|
+
head.addEventListener("pointerdown", (e) => {
|
|
183
|
+
if (!phone() || L.landscape || e.target.closest("button, .m-chips")) return;
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
const y0 = e.clientY, h0 = head.getBoundingClientRect().top, H = window.innerHeight;
|
|
186
|
+
let h = H - h0;
|
|
187
|
+
const move = (ev) => {
|
|
188
|
+
h = Math.max(90, Math.min(H - 190, H - (h0 + ev.clientY - y0))); // always leaves the preview in view
|
|
189
|
+
app.style.setProperty("--m-sheet-h", Math.round(h) + "px");
|
|
190
|
+
};
|
|
191
|
+
const up = () => {
|
|
192
|
+
window.removeEventListener("pointermove", move);
|
|
193
|
+
window.removeEventListener("pointerup", up);
|
|
194
|
+
window.removeEventListener("pointercancel", up);
|
|
195
|
+
if (h < H * 0.24) closeSheet();
|
|
196
|
+
};
|
|
197
|
+
window.addEventListener("pointermove", move);
|
|
198
|
+
window.addEventListener("pointerup", up);
|
|
199
|
+
window.addEventListener("pointercancel", up);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
/* ── Rows of the list sheets ── */
|
|
203
|
+
const item = (icon, label, run, o = {}) => {
|
|
204
|
+
const b = button("m-item" + (o.on ? " on" : ""), icon, label, () => { run(); if (o.stay) openSheet(sheet); else closeSheet(); }, escapeHtml(label) + (o.hint ? `<small>${escapeHtml(o.hint)}</small>` : ""));
|
|
205
|
+
b.disabled = !!o.off;
|
|
206
|
+
return b;
|
|
207
|
+
};
|
|
208
|
+
function moreRows() {
|
|
209
|
+
// whatever the desktop top bar holds (and whatever Studio adds to it), by name
|
|
210
|
+
const out = [item("list", "Search everything", () => $("btnSearch").click())];
|
|
211
|
+
for (const b of topbar.querySelectorAll(".topbar-right button, .topbar > button")) {
|
|
212
|
+
if (b.matches(".m-btn, #btnExport, #btnSearch, #btnProjectsDash") || b.closest(".hidden") || b.classList.contains("hidden")) continue;
|
|
213
|
+
const size = b.dataset.trackSize && { s: "Small", m: "Medium", l: "Large" }[b.dataset.trackSize];
|
|
214
|
+
const label = b.id === "btnHelp" ? "Gestures and shortcuts" : size ? `Track height: ${size}` : b.dataset.ws ? `${b.textContent.trim()} workspace` : cmdkName(b);
|
|
215
|
+
const icon = b.id === "btnSettings" ? "adjust" : b.id === "btnHelp" ? "words" : b.dataset.ws ? "color" : size ? "view" : b.id === "btnLayoutReset" ? "all" : "clip";
|
|
216
|
+
if (label && !b.dataset.ws) out.push(item(icon, label, () => b.click(), { on: b.classList.contains("on") && !!size }));
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
function rangeRows() {
|
|
221
|
+
const has = project.inPoint != null || project.outPoint != null, both = project.inPoint != null && project.outPoint != null;
|
|
222
|
+
return [
|
|
223
|
+
item("trimIn", "Mark IN at the playhead", markIn, { stay: true, hint: project.inPoint != null ? fmt(project.inPoint) : "" }),
|
|
224
|
+
item("trimOut", "Mark OUT at the playhead", markOut, { stay: true, hint: project.outPoint != null ? fmt(project.outPoint) : "" }),
|
|
225
|
+
item("close", "Clear IN and OUT", () => { clearMarkIn(); clearMarkOut(); }, { stay: true, off: !has }),
|
|
226
|
+
item("range", "Play only this range", () => $("btnWorkAreaPlay").click(), { stay: true, on: state.workAreaPlay, off: !both }),
|
|
227
|
+
item("split", "Split clips at IN and OUT", splitAtWorkArea, { off: !has }),
|
|
228
|
+
item("trash", "Lift: remove it, leave the gap", () => liftExtract(false), { off: !both }),
|
|
229
|
+
item("ripple", "Extract: remove it, close the gap", () => liftExtract(true), { off: !both }),
|
|
230
|
+
item("clip", "Keep only this range", trimToWorkArea, { off: !has }),
|
|
231
|
+
item("view", "Zoom to it", zoomToWorkArea, { off: !both }),
|
|
232
|
+
];
|
|
233
|
+
}
|
|
234
|
+
function markerRows() {
|
|
235
|
+
return [
|
|
236
|
+
item("marker", "Add or remove at the playhead", toggleMarker, { stay: true }),
|
|
237
|
+
item("prevKey", "Previous marker", () => goToMarker(-1), { stay: true }),
|
|
238
|
+
item("nextKey", "Next marker", () => goToMarker(1), { stay: true }),
|
|
239
|
+
...(project.markers || []).map((m) => item("marker", m.label || "Marker", () => seekToMarker(m), { stay: true, hint: fmt(m.t) })),
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
function viewRows() {
|
|
243
|
+
return [
|
|
244
|
+
item("view", "Fit the whole timeline", zoomToFit), item("clip", "Zoom to the selected clip", zoomToSelection, { off: !state.selIds.size }),
|
|
245
|
+
item("snap", "Snapping", () => $("btnSnap").click(), { stay: true, on: state.snap }),
|
|
246
|
+
item("marker", "What clips snap to…", () => setTimeout(() => openSnapMenu(tools), 0)),
|
|
247
|
+
item("list", "Show empty tracks", () => { runtime.keepEmptyTracks = !runtime.keepEmptyTracks; state.dirtyTimeline = true; }, { stay: true, on: !!runtime.keepEmptyTracks }),
|
|
248
|
+
item("plus", "Add a video track", () => addTimelineTrack("video")), item("plus", "Add an audio track", () => addTimelineTrack("audio")),
|
|
249
|
+
item("range", "Close the gap at the playhead", closeGapAtPlayhead), item("range", "Find the next gap", goToNextGap, { stay: true }),
|
|
250
|
+
];
|
|
251
|
+
}
|
|
252
|
+
function playRows() {
|
|
253
|
+
return [
|
|
254
|
+
item("trimIn", "Go to the start", gotoTransportHome), item("trimOut", "Go to the end", gotoTransportEnd),
|
|
255
|
+
item("prevKey", "Previous cut", () => goToEditPoint(-1), { stay: true }), item("nextKey", "Next cut", () => goToEditPoint(1), { stay: true }),
|
|
256
|
+
item("back", "Back 1 second", () => setTime(state.time - 1), { stay: true }), item("clip", "Forward 1 second", () => setTime(state.time + 1), { stay: true }),
|
|
257
|
+
item("speed", "Preview speed", () => cyclePreviewRate(1), { stay: true, hint: state.previewRate + "×" }),
|
|
258
|
+
item("undo", "Play backwards", () => shuttle(-1)), item("speed", "Slow play, ¼ speed", () => { setPreviewRate(INCH_RATE); transportStart(); }), ...(phone() ? [item("mixer", "Sound meter beside the picture", () => showMeter(!app.classList.contains("m-meter")), { stay: true, on: app.classList.contains("m-meter") })] : []), // (a tablet has the Mixer's)
|
|
259
|
+
item("audio", "Audio hold", () => $("btnAudioHold").click(), { stay: true, on: state.audioHold }),
|
|
260
|
+
];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* the picture has no room to spare on a phone, so the meter is there when asked for */
|
|
264
|
+
const METER_KEY = "fablecut-phone-meter";
|
|
265
|
+
function showMeter(on) {
|
|
266
|
+
app.classList.toggle("m-meter", on);
|
|
267
|
+
try { if (on) localStorage.setItem(METER_KEY, "1"); else localStorage.removeItem(METER_KEY); } catch { }
|
|
268
|
+
if (on) requestAnimationFrame(fitVuMeter);
|
|
269
|
+
}
|
|
270
|
+
try { if (localStorage.getItem(METER_KEY)) app.classList.add("m-meter"); } catch { }
|
|
271
|
+
|
|
272
|
+
/* one track: what its four header buttons and right-click do on desktop, as rows */
|
|
273
|
+
let trackId = null;
|
|
274
|
+
function trackRows() {
|
|
275
|
+
const id = trackId, on = isTrackEnabled(id), target = isTrackTargeted(id), locked = isTrackLocked(id), solo = state.soloId === id, rm = canRemoveTrack(id);
|
|
276
|
+
const audio = id[0] === "A";
|
|
277
|
+
return [
|
|
278
|
+
item("check", "Edits reach this track", () => toggleTrackTargeted(id), { stay: true, on: target, hint: target ? "on" : "off" }),
|
|
279
|
+
item(audio ? "volume" : "source", audio ? "Sound" : "Picture", () => toggleTrackEnabled(id), { stay: true, on, hint: on ? "on" : "off" }),
|
|
280
|
+
item("select", "Solo: only this track", () => toggleTrackSolo(id), { stay: true, on: solo, hint: solo ? "on" : "off" }),
|
|
281
|
+
item("mask", "Locked: nothing on it changes", () => toggleTrackLocked(id), { stay: true, on: locked, hint: locked ? "on" : "off" }),
|
|
282
|
+
item("plus", "Add a video track", () => addTimelineTrack("video")), item("plus", "Add an audio track", () => addTimelineTrack("audio")),
|
|
283
|
+
item("trash", "Remove this track", () => removeTimelineTrack(id), { off: !rm.ok, hint: rm.ok ? "" : rm.reason }),
|
|
284
|
+
];
|
|
285
|
+
}
|
|
286
|
+
// (capture: on a phone the letter opens the sheet instead of switching the target)
|
|
287
|
+
els.trackHeaders.addEventListener("click", (e) => {
|
|
288
|
+
const h = e.target.closest(".track-head");
|
|
289
|
+
if (!compact() || !h) return;
|
|
290
|
+
if (!phone() && e.pointerType === "mouse" && e.target.closest("button")) return; // a tablet with a mouse keeps the small buttons
|
|
291
|
+
e.preventDefault(); e.stopPropagation();
|
|
292
|
+
trackId = h.dataset.track;
|
|
293
|
+
if (phone()) { openSheet("track", { title: "Track " + trackId }); return; }
|
|
294
|
+
const on = isTrackEnabled(trackId), id = trackId, rm = canRemoveTrack(id), r = h.getBoundingClientRect();
|
|
295
|
+
popMenu(r.right, r.top, [[isTrackTargeted(id) ? "Edits skip this track" : "Edits reach this track", () => toggleTrackTargeted(id)],
|
|
296
|
+
[(on ? "Turn off its " : "Turn on its ") + (id[0] === "A" ? "sound" : "picture"), () => toggleTrackEnabled(id)], [state.soloId === id ? "End solo" : "Solo: only this track", () => toggleTrackSolo(id)],
|
|
297
|
+
[isTrackLocked(id) ? "Unlock" : "Lock: nothing on it changes", () => toggleTrackLocked(id)], ["Add a video track", () => addTimelineTrack("video")], ["Add an audio track", () => addTimelineTrack("audio")],
|
|
298
|
+
["Remove this track", () => removeTimelineTrack(id), !rm.ok]]);
|
|
299
|
+
}, true);
|
|
300
|
+
const TRIM_HELP = {
|
|
301
|
+
select: "Grips trim this clip; the rest stays put", ripple: "Grips trim; everything after it follows", roll: "Grips move the cut between two clips",
|
|
302
|
+
slip: "Drag the selected clip: another part of its source", slide: "Drag the selected clip: its neighbours make room",
|
|
303
|
+
};
|
|
304
|
+
function trimRows() {
|
|
305
|
+
return Object.keys(EDIT_TOOLS).map((k) => item({ select: "select", ripple: "ripple", roll: "split", slip: "range", slide: "clip" }[k], EDIT_TOOLS[k].label, () => setEditTool(k), { on: state.tool === k, hint: TRIM_HELP[k] }));
|
|
306
|
+
}
|
|
307
|
+
function selectMode(on) {
|
|
308
|
+
runtime.selectMode = !!on;
|
|
309
|
+
app.classList.toggle("m-selecting", !!on);
|
|
310
|
+
if (!on && state.selIds.size > 1) selectClip(null);
|
|
311
|
+
shown = "";
|
|
312
|
+
refresh();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/* ── Tool bar: what it offers follows the selection ── */
|
|
316
|
+
const insp = (label, icon, section) => ({ label, icon, run: () => openSheet("inspector", { section }) });
|
|
317
|
+
const T = {
|
|
318
|
+
media: { label: "Media", icon: "media", run: () => { openSheet("media"); setBinTab("project"); } },
|
|
319
|
+
audio: { label: "Audio", icon: "audio", run: () => { openSheet("media", { title: "Audio" }); setBinTab("music"); } },
|
|
320
|
+
text: { label: "Text", icon: "text", run: () => { addTitle(); openSheet("inspector", { section: /^Text$/ }); } },
|
|
321
|
+
graphics: { label: "Graphics", icon: "shapes", run: () => { openSheet("media", { title: "Graphics" }); setBinTab("elements"); } },
|
|
322
|
+
captions: { label: "Captions", icon: "words", run: () => openSheet("transcript") },
|
|
323
|
+
adjust: { label: "Adjust", icon: "adjust", run: () => { addAdjust(); openSheet("inspector", { section: /^Filter/ }); } },
|
|
324
|
+
mixer: { label: "Mixer", icon: "mixer", run: () => openSheet("mixer") },
|
|
325
|
+
markers: { label: "Markers", icon: "marker", run: () => openSheet("markers") },
|
|
326
|
+
range: { label: "Range", icon: "range", run: () => openSheet("range") },
|
|
327
|
+
canvas: { label: "Canvas", icon: "canvas", run: () => openSheet("canvas") },
|
|
328
|
+
sequences: { label: "Sequences", icon: "list", run: () => $("btnSequences").click() },
|
|
329
|
+
view: { label: "View", icon: "view", run: () => openSheet("view") },
|
|
330
|
+
select: { label: "Select", icon: "select", run: () => selectMode(true) },
|
|
331
|
+
selAll: { label: "All", icon: "all", run: () => setSelection(project.clips.map((c) => c.id)) },
|
|
332
|
+
selNone: { label: "None", icon: "close", run: () => setSelection([]) },
|
|
333
|
+
trim: { label: "Trim mode", icon: "ripple", run: () => openSheet("trim") },
|
|
334
|
+
all: { label: "All tools", icon: "all", run: () => openSheet("tools") },
|
|
335
|
+
split: { label: "Split", icon: "split", run: () => splitAtPlayhead() },
|
|
336
|
+
del: { label: "Delete", icon: "trash", run: () => $("btnDelete").click() },
|
|
337
|
+
ripple: { label: "Ripple del.", icon: "ripple", run: () => $("btnRippleDelete").click() },
|
|
338
|
+
trimIn: { label: "Trim start", icon: "trimIn", run: () => trimToPlayhead("in") },
|
|
339
|
+
trimOut: { label: "Trim end", icon: "trimOut", run: () => trimToPlayhead("out") },
|
|
340
|
+
color: { label: "Color", icon: "color", run: () => openSheet("color") },
|
|
341
|
+
trans: { label: "Transition", icon: "trans", run: () => { addTransitionAtPlayhead(); openSheet("inspector", { section: /^Transition/ }); } },
|
|
342
|
+
edit: { label: "Edit", icon: "edit", run: () => openSheet("inspector") },
|
|
343
|
+
// a volume point at the playhead (there already: takes it away), then drag it on the clip
|
|
344
|
+
volKey: { label: "Vol. point", icon: "animate", run: () => {
|
|
345
|
+
const c = getClip(state.selId);
|
|
346
|
+
if (!c) return;
|
|
347
|
+
if (isGroupLocked(c)) { toastLocked(); return; }
|
|
348
|
+
const snap = undoSnapshot();
|
|
349
|
+
if (!toggleKfAtPlayhead(c, "volume")) { toast("Move the playhead over the clip to add or remove a point"); return; }
|
|
350
|
+
pushUndo(snap);
|
|
351
|
+
mirrorVolume(c);
|
|
352
|
+
state.dirtyTimeline = true; scheduleSave(); renderInspector();
|
|
353
|
+
} },
|
|
354
|
+
volume: insp("Volume", "volume", /^Audio \/ Time/), speed: insp("Speed", "speed", /^Audio \/ Time/),
|
|
355
|
+
filter: insp("Filters", "filter", /^Filter/), animate: insp("Animate", "animate", /^Motion$/), transform: insp("Position", "canvas", /^Transform/),
|
|
356
|
+
crop: insp("Crop", "canvas", /^Layout/), mask: insp("Masks", "mask", /^Masks/), cutout: insp("Cut-out", "cutout", /^Keying/),
|
|
357
|
+
track: insp("Tracking", "track", /^Tracking/), words: { label: "Edit text", icon: "text", run: () => editText() }, style: insp("Style", "style", /^Title/), font: insp("Font", "style", /^Font/),
|
|
358
|
+
shape: insp("Shape", "shapes", /^Shape layer/), duck: insp("Auto-duck", "volume", /^Auto-duck/), fx: insp("Effects", "filter", /^Audio effects/),
|
|
359
|
+
silence: insp("Silence", "words", /^Silence/), beats: insp("Beats", "marker", /^Beats/),
|
|
360
|
+
source: { label: "Source", icon: "source", run: () => { const c = getClip(state.selId); if (c) loadSourceFromClip(c, { timelineTime: state.time }); } },
|
|
361
|
+
openComp: { label: "Open", icon: "source", run: () => { const c = getClip(state.selId); if (c && c.compId) enterComp(c.compId, c); } },
|
|
362
|
+
fields: insp("Fields", "text", /^(Template|Composition)/),
|
|
363
|
+
menu: { label: "More", icon: "more", run: (e) => { const c = getClip(state.selId), r = e.currentTarget.getBoundingClientRect(); if (c) showClipCtxMenu(r.left, r.top, c); } },
|
|
364
|
+
};
|
|
365
|
+
const BARS = {
|
|
366
|
+
none: ["media", "audio", "text", "graphics", "captions", "adjust", "select", "mixer", "canvas", "markers", "range", "view", "sequences", "all"],
|
|
367
|
+
video: ["split", "del", "trimIn", "trimOut", "trim", "speed", "volume", "filter", "color", "transform", "crop", "animate", "trans", "mask", "cutout", "track", "silence", "source", "ripple", "menu", "edit"],
|
|
368
|
+
image: ["split", "del", "filter", "color", "transform", "crop", "animate", "trans", "mask", "cutout", "ripple", "menu", "edit"],
|
|
369
|
+
audio: ["split", "del", "trimIn", "trimOut", "trim", "volume", "volKey", "speed", "fx", "duck", "beats", "silence", "trans", "ripple", "menu", "edit"],
|
|
370
|
+
text: ["words", "style", "font", "split", "del", "transform", "animate", "trans", "mask", "ripple", "menu", "edit"],
|
|
371
|
+
shape: ["shape", "split", "del", "transform", "animate", "trans", "mask", "ripple", "menu", "edit"],
|
|
372
|
+
adjust: ["filter", "color", "split", "del", "trans", "mask", "ripple", "menu", "edit"],
|
|
373
|
+
comp: ["openComp", "fields", "split", "del", "filter", "color", "transform", "animate", "trans", "mask", "ripple", "menu", "edit"],
|
|
374
|
+
multi: ["split", "del", "ripple", "menu", "edit"],
|
|
375
|
+
select: ["selAll", "selNone", "del", "ripple", "split", "menu", "edit"],
|
|
376
|
+
trans: ["del", "trans", "edit"],
|
|
377
|
+
};
|
|
378
|
+
const kindBar = (c) => BARS[c.kind] ? c.kind : c.kind === "svg" ? "image" : "multi";
|
|
379
|
+
function context() {
|
|
380
|
+
if (runtime.selectMode) return "select";
|
|
381
|
+
const c = getClip(state.selId);
|
|
382
|
+
if (!c) return "none";
|
|
383
|
+
if (state.transFocus) return "trans";
|
|
384
|
+
return state.selIds.size > 1 && selectedClips().some((x) => !withLinked([c]).includes(x)) ? "multi" : kindBar(c);
|
|
385
|
+
}
|
|
386
|
+
let shown = "";
|
|
387
|
+
function renderTools() {
|
|
388
|
+
const ctx = context();
|
|
389
|
+
if (ctx === shown) return;
|
|
390
|
+
shown = ctx;
|
|
391
|
+
tools.innerHTML = "";
|
|
392
|
+
tools.dataset.ctx = ctx;
|
|
393
|
+
if (ctx === "select") tools.append(button("m-tool m-desel", "check", "Done selecting", () => selectMode(false), "Done"));
|
|
394
|
+
else if (ctx !== "none") tools.append(button("m-tool m-desel", "down", "Deselect", () => selectClip(null)));
|
|
395
|
+
for (const k of BARS[ctx]) {
|
|
396
|
+
const t = T[k], b = button("m-tool", t.icon, t.label, t.run, t.label);
|
|
397
|
+
b.dataset.tool = k;
|
|
398
|
+
tools.append(b);
|
|
399
|
+
}
|
|
400
|
+
tools.scrollTo(0, 0);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/* ── Source monitor on a phone: what its desktop head and transport hold, as one row under the picture ── */
|
|
404
|
+
const src = make("div", "m-src");
|
|
405
|
+
src.append(
|
|
406
|
+
button("btn m-src-btn", "down", "Back to the timeline", () => setMonitorMode("program"), "Timeline"),
|
|
407
|
+
button("btn m-src-btn", "trimIn", "Mark IN", () => markIn(), "IN"), button("btn m-src-btn", "trimOut", "Mark OUT", () => markOut(), "OUT"),
|
|
408
|
+
button("btn m-src-btn", "plus", "Insert at the playhead", () => insertSourceAtPlayhead(), "Insert"),
|
|
409
|
+
button("btn m-src-btn", "clip", "Replace at the playhead", () => replaceSourceAtPlayhead(), "Replace"));
|
|
410
|
+
els.sourceScrub.after(src);
|
|
411
|
+
|
|
412
|
+
/* ── The keys a monitor tool reads (Enter, Backspace, Esc, Shift, Alt, Ctrl) as buttons. They stand in the
|
|
413
|
+
transport's place while such a tool is in use, so the picture doesn't move ── */
|
|
414
|
+
const mods = { shift: false, alt: false, ctrl: false };
|
|
415
|
+
const prec = make("div", "m-prec");
|
|
416
|
+
els.btnPlay.closest(".transport").append(prec);
|
|
417
|
+
const key = (k) => document.body.dispatchEvent(new KeyboardEvent("keydown", { key: k, bubbles: true, cancelable: true }));
|
|
418
|
+
const keyBtn = (icon, label, k) => { const b = button("m-prec-btn", icon, label, () => { key(k); refresh(); }, label); return b; };
|
|
419
|
+
const modBtn = (label, m, hint) => { const b = make("button", "m-prec-btn m-mod" + (mods[m] ? " on" : ""), label); b.type = "button"; b.title = hint; b.setAttribute("aria-pressed", mods[m]); b.addEventListener("click", () => { mods[m] = !mods[m]; precSig = ""; refresh(); }); return b; };
|
|
420
|
+
let precSig = "";
|
|
421
|
+
function toolInUse() {
|
|
422
|
+
const c = getClip(state.selId);
|
|
423
|
+
if (trackUi.run) return "run";
|
|
424
|
+
if (isSourceMode() || state.playing) return "";
|
|
425
|
+
if ((maskUi.tool === "pen" && c && maskUi.clip === c.id) || (shapeUi.tool === "pen" && c && shapeUi.clip === c.id)) return "pen";
|
|
426
|
+
if ((maskUi.tool === "draw" && c && maskUi.clip === c.id) || drawingLayerMask(c)) return "draw";
|
|
427
|
+
if (colorState.pick || colorState.curvePick || colorState.qualPick || trackUi.tool === "point") return "pick";
|
|
428
|
+
if (runtime.anchorTool) return "anchor";
|
|
429
|
+
if (maskEditActive(c) || maskEditing(c) || shapeEditActive(c)) return "edit";
|
|
430
|
+
if (motionPathActive(c) && pathUi.clip === c.id && pathUi.key >= 0) return "path";
|
|
431
|
+
return "";
|
|
432
|
+
}
|
|
433
|
+
function renderPrec() {
|
|
434
|
+
const use = toolInUse(), sig = use + JSON.stringify(mods);
|
|
435
|
+
if (sig === precSig) return;
|
|
436
|
+
precSig = sig;
|
|
437
|
+
app.classList.toggle("m-tooling", !!use);
|
|
438
|
+
prec.innerHTML = "";
|
|
439
|
+
if (!use) { mods.shift = mods.alt = mods.ctrl = false; return; }
|
|
440
|
+
if (use === "pen") prec.append(keyBtn("undo", "Undo point", "Backspace"), keyBtn("close", "Cancel", "Escape"), keyBtn("check", "Done", "Enter"));
|
|
441
|
+
else if (use === "draw" || use === "pick") prec.append(make("span", "m-prec-say", use === "draw" ? "Draw around it with a finger" : "Tap the picture"), keyBtn("close", "Cancel", "Escape"));
|
|
442
|
+
else if (use === "run") prec.append(make("span", "m-prec-say", "Tracking…"), keyBtn("close", "Stop", "Escape"));
|
|
443
|
+
else if (use === "path") {
|
|
444
|
+
const done = button("m-prec-btn", "check", "Done", () => { pathUi.key = -1; state.dirtyTimeline = true; precSig = ""; refresh(); }, "Done");
|
|
445
|
+
prec.append(modBtn("Pull handles", "alt", "Drag the point to pull curve handles out of it, or one handle alone"), make("span", "m-prec-say", "Two taps: a corner"), done);
|
|
446
|
+
}
|
|
447
|
+
else if (use === "anchor") prec.append(modBtn("Snap", "shift", "Snaps to the picture's centre"), keyBtn("check", "Done", "Escape"));
|
|
448
|
+
else prec.append(modBtn("Snap", "shift", "Turns in 15° steps, keeps proportions"), modBtn("Break handles", "alt", "Moves one handle of a pair, or pulls new ones from a point"), modBtn("Add point", "ctrl", "The next tap on the outline adds a point"), keyBtn("check", "Done", "Escape"));
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/* ── The Project tab's right-click menu (new folder, new composition, proxies) has a button too ── */
|
|
452
|
+
const binMore = button("btn tiny m-bin-more", "more", "New folder, new composition", (e) => { const r = e.currentTarget.getBoundingClientRect(); openProjectTabMenu(r.left, r.bottom); });
|
|
453
|
+
els.binTools.append(binMore);
|
|
454
|
+
|
|
455
|
+
/* a file's or folder's menu on a finger: the row's last button opens it, so nothing is removed by a near miss */
|
|
456
|
+
const popMenu = (x, y, rows) => {
|
|
457
|
+
const menu = make("div", "ctx-menu");
|
|
458
|
+
for (const [label, run, off] of rows) {
|
|
459
|
+
const b = make("button", "ctx-item", `<span>${escapeHtml(label)}</span>`);
|
|
460
|
+
b.type = "button"; b.disabled = !!off;
|
|
461
|
+
b.addEventListener("click", () => { hideTrackCtxMenu(); run(); });
|
|
462
|
+
menu.append(b);
|
|
463
|
+
}
|
|
464
|
+
showPopover(menu, x, y);
|
|
465
|
+
};
|
|
466
|
+
/** Pick a folder by name (`bar` and what is in it are left out); null is the top level. */
|
|
467
|
+
function moveToFolder(x, y, now, run, bar = null) {
|
|
468
|
+
const rows = [], walk = (parent, depth) => {
|
|
469
|
+
for (const f of folderChildren(parent)) {
|
|
470
|
+
if (f.id === bar) continue;
|
|
471
|
+
rows.push(["\u2003".repeat(depth) + f.name, () => run(f.id), f.id === now]);
|
|
472
|
+
walk(f.id, depth + 1);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
walk(null, 0);
|
|
476
|
+
popMenu(x, y, [["No folder", () => run(null), now == null], ...rows]);
|
|
477
|
+
}
|
|
478
|
+
function folderMenu(x, y, id) {
|
|
479
|
+
const f = getFolder(id);
|
|
480
|
+
if (!f) return;
|
|
481
|
+
popMenu(x, y, [["Rename", () => startFolderRename(id)], ["New subfolder", () => addFolder(id)],
|
|
482
|
+
["Move to folder…", () => moveToFolder(x, y, f.parentId || null, (p) => moveFolderToParent(id, p), id), project.folders.length < 2],
|
|
483
|
+
["Delete the folder, keep its media", () => deleteFolder(id)]]);
|
|
484
|
+
}
|
|
485
|
+
els.binList.addEventListener("click", (e) => {
|
|
486
|
+
const x = compact() && e.target.closest(".bin-del"), row = x && x.closest(".bin-item, .bin-folder");
|
|
487
|
+
if (!row) return;
|
|
488
|
+
e.preventDefault(); e.stopPropagation();
|
|
489
|
+
const r = x.getBoundingClientRect(), m = row.dataset.mediaId && getMedia(row.dataset.mediaId);
|
|
490
|
+
if (m) showMediaMenu(r.left, r.bottom, m); else if (row.dataset.folderId) folderMenu(r.left, r.bottom, row.dataset.folderId);
|
|
491
|
+
}, true);
|
|
492
|
+
|
|
493
|
+
/* Search presses the desktop tabs; here their panel may be out of sight, so it comes up as its sheet */
|
|
494
|
+
document.addEventListener("click", (e) => {
|
|
495
|
+
const b = compact() && e.target.closest && e.target.closest("#sideTabs [data-side], #binTabs button, #binSubTabs button, #wsSwitch [data-ws]");
|
|
496
|
+
if (!b) return;
|
|
497
|
+
const want = b.dataset.side || (b.dataset.ws === "color" ? "color" : b.dataset.ws ? null : "media");
|
|
498
|
+
if (want && sheet !== want) openSheet(want);
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
/* Title styles: a mouse previews one by hovering. Here a tap previews it, "Use it" (or a second tap) takes it */
|
|
502
|
+
document.addEventListener("click", (e) => {
|
|
503
|
+
const opt = compact() && e.target.closest && e.target.closest(".style-opt:not(.media-opt)");
|
|
504
|
+
if (!opt || !runtime.styleMenu || opt.classList.contains("m-try")) return;
|
|
505
|
+
e.preventDefault(); e.stopPropagation();
|
|
506
|
+
const menu = opt.parentNode;
|
|
507
|
+
for (const o of menu.querySelectorAll(".m-try, .m-use")) if (o.classList.contains("m-use")) o.remove(); else o.classList.remove("m-try");
|
|
508
|
+
opt.classList.add("m-try");
|
|
509
|
+
opt.dispatchEvent(new MouseEvent("mouseenter"));
|
|
510
|
+
const use = make("button", "btn primary m-use", `Use ${escapeHtml(opt.textContent)}`);
|
|
511
|
+
use.type = "button";
|
|
512
|
+
use.addEventListener("click", () => opt.click());
|
|
513
|
+
menu.append(use);
|
|
514
|
+
}, true);
|
|
515
|
+
|
|
516
|
+
/* ── The editor's hints name the mouse and keys; on a finger they name the touch ──
|
|
517
|
+
(a word inside quotes or with a file ending is a name, and stays) */
|
|
518
|
+
const SAY = [
|
|
519
|
+
[/^Pen: click[^]*$/, "Tap to add points, drag to curve them. Tap the first point to close the shape, or use the buttons under the picture."],
|
|
520
|
+
[/^On the monitor: [^]*$/, "On the picture: drag inside to move it, drag its points, corners and knob. The buttons under the picture do the rest."],
|
|
521
|
+
[/^Drag it on the monitor: [^]*$/, "Drag it on the picture: inside moves, handles resize, the knob rotates. The buttons under the picture do the rest."],
|
|
522
|
+
[/ You can switch tabs; export continues\.$/, " Keep this page open until it's done; a phone may pause it in the background."],
|
|
523
|
+
[/^Draw: drag around/, "Drag around"], [/ — Esc stops/, ""], [/ ?Esc (cancels|deselects|stops)\.?/g, ""], [/press Esc to stop/, "press Stop"], [/Ctrl\+Z puts/, "Undo puts"], [/\(I \/ O\)/, "(IN / OUT)"],
|
|
524
|
+
[/\bin the monitor\b/g, "in the picture"], [/\bon the monitor\b/g, "on the picture"],
|
|
525
|
+
[/\b([Dd])ouble-click\b/g, "$1ouble-tap"], [/\bright-click\b/g, "hold"], [/\bRight-click\b/g, "Hold"], [/\bCtrl-click\b/g, "tap"],
|
|
526
|
+
[/\bClick\b(?!\S*\.\w)/g, "Tap"], [/\bclick\b(?!\S*\.\w)/g, "tap"],
|
|
527
|
+
];
|
|
528
|
+
const words = (s) => String(s).split(/("[^"]*"|“[^”]*”)/).map((part, i) => (i % 2 ? part : SAY.reduce((t, [a, b]) => t.replace(a, b), part))).join("");
|
|
529
|
+
const NOTES = ".cl-note, .hint, .comp-open-hint, .tr-note, .tr-empty, .bin-pop-hint, .bin-empty p";
|
|
530
|
+
function reword(root) {
|
|
531
|
+
for (const n of root.querySelectorAll(NOTES)) {
|
|
532
|
+
const w = document.createTreeWalker(n, NodeFilter.SHOW_TEXT);
|
|
533
|
+
for (let t = w.nextNode(); t; t = w.nextNode()) { const s = words(t.data); if (s !== t.data) t.data = s; }
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
if (typeof MutationObserver !== "undefined") {
|
|
537
|
+
const seen = new MutationObserver((list) => { if (compact()) for (const r of new Set(list.map((m) => m.target))) if (r.isConnected) reword(r); });
|
|
538
|
+
for (const r of [els.inspector, els.colorPage, els.transcriptPage, els.tracks, els.binList, document.body]) if (r) seen.observe(r, { childList: true });
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/* ── The shortcuts dialog begins with what fingers do ── */
|
|
542
|
+
const GESTURES = () => [
|
|
543
|
+
["Timeline", [
|
|
544
|
+
[phone() ? "Drag" : "Drag the ruler", "Move through time; it plays on from there"], ["Pinch", phone() ? "Zoom the timeline around the playhead" : "Zoom the timeline around your fingers"], ["Tap a clip", "Select it: the tools below follow"],
|
|
545
|
+
["Hold a clip, then move", "Pick it up: another place, another track"], ["Hold a clip, let go", "Its menu"], ["White grips", "Trim the selected clip (Trim mode has ripple, roll, slip and slide)"],
|
|
546
|
+
["Small squares, yellow line", "Fades and volume of the selected sound"], ["Two taps on a clip", "Open it in Source; a composition opens"], ["Select", "Tap several clips, or drag a box over them"],
|
|
547
|
+
["Hold a marker", "Move it; let go for its name and colour"], ...(phone() ? [["Tap a track's letter", "Sound or picture on and off, lock, solo, new tracks"]] : []),
|
|
548
|
+
]],
|
|
549
|
+
["Picture", [
|
|
550
|
+
["Tap, then drag", "Select what is there, and move it"], ["Two fingers on it", "Size, turn and move at once"], ["Two fingers beside it", "Zoom the view; one finger then moves it"],
|
|
551
|
+
["Two taps", "On a title: its text. Elsewhere: the whole picture again"], ["Picking a colour or point", "A magnifier shows the spot; lift to take it"],
|
|
552
|
+
["Pen, masks, paths", "Their keys (Undo point, Snap, Add point, Done) stand where Play was"],
|
|
553
|
+
]],
|
|
554
|
+
["Panels", [
|
|
555
|
+
["Drag a slider sideways", "Changes it from where it was; up and down scrolls"], ["Tap a number", "Type it"], ["Hold a name", "Reset it, or its keyframes"], ["Two taps on a slider, fader or wheel", "Back to its default, where it has one"],
|
|
556
|
+
["Hold a file, then move", "Carry it to the timeline or a folder"], ["Hold a word, then drag", "Select words in the transcript; drag the ends to adjust"], ["Color wheels", "Drag the dot; the rest of the wheel scrolls"],
|
|
557
|
+
["Back", "Closes what is open, one thing at a time"], ...(phone() ? [["Drag a sheet's bar", "Taller, shorter, or away"]] : []),
|
|
558
|
+
]],
|
|
559
|
+
];
|
|
560
|
+
function fillHelp() {
|
|
561
|
+
const box = $("helpKeys"), title = $("helpOverlay").querySelector("h2");
|
|
562
|
+
box.querySelectorAll(".m-gestures").forEach((s) => s.remove());
|
|
563
|
+
title.textContent = compact() ? "Gestures and shortcuts" : "Keyboard shortcuts";
|
|
564
|
+
if (!compact()) return;
|
|
565
|
+
const secs = GESTURES().map(([name, rows]) => {
|
|
566
|
+
const s = make("section", "keys-sec m-gestures", `<h3>Touch: ${name}</h3><table class="keys">${rows.map(([a, b]) => `<tr><td>${escapeHtml(a)}</td><td>${escapeHtml(b)}</td></tr>`).join("")}</table>`);
|
|
567
|
+
return s;
|
|
568
|
+
});
|
|
569
|
+
box.prepend(...secs);
|
|
570
|
+
}
|
|
571
|
+
$("btnHelp").addEventListener("click", () => { if (compact() && document.activeElement === $("helpFilter")) $("helpFilter").blur(); }); // its field would bring the keyboard up over the list
|
|
572
|
+
|
|
573
|
+
/* ── Importing: which file it is at, and afterwards what couldn't be used and why ── */
|
|
574
|
+
const imp = make("div", "m-import");
|
|
575
|
+
imp.setAttribute("role", "status");
|
|
576
|
+
imp.hidden = true;
|
|
577
|
+
document.body.append(imp);
|
|
578
|
+
window.addEventListener("fablecut:importing", (e) => {
|
|
579
|
+
const { i, n, name, notes } = e.detail;
|
|
580
|
+
if (!compact()) return;
|
|
581
|
+
imp.hidden = i >= n && !notes.length;
|
|
582
|
+
imp.innerHTML = i < n
|
|
583
|
+
? `<p><b>Adding ${n > 1 ? `${i + 1} of ${n}` : "your file"}</b><span>${escapeHtml(name)}</span></p><div class="m-import-bar"><i style="width:${Math.round((i + .3) / n * 100)}%"></i></div>`
|
|
584
|
+
: `<p><b>${notes.length === 1 ? "One file needs a look" : `${notes.length} files need a look`}</b></p>${notes.slice(0, 8).map((q) => `<p><b>${escapeHtml(q.name)}</b><span>${escapeHtml(q.why)}.</span></p>`).join("")}`;
|
|
585
|
+
if (i >= n && notes.length) { const ok = make("button", "btn primary", "OK"); ok.type = "button"; ok.addEventListener("click", () => { imp.hidden = true; }); imp.append(ok); }
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
/* ── While an export runs the screen stays on (a phone that locks stops it) ── */
|
|
589
|
+
let lock = null;
|
|
590
|
+
const exporting = () => !els.exportOverlay.classList.contains("hidden") || state.exporting;
|
|
591
|
+
async function keepAwake() {
|
|
592
|
+
if (!exporting()) { if (lock) { const l = lock; lock = null; l.release().catch(() => { }); } return; }
|
|
593
|
+
if (lock || document.hidden || !navigator.wakeLock) return;
|
|
594
|
+
try {
|
|
595
|
+
const l = await navigator.wakeLock.request("screen");
|
|
596
|
+
if (!exporting()) { l.release().catch(() => { }); return; }
|
|
597
|
+
lock = l;
|
|
598
|
+
l.addEventListener("release", () => { if (lock === l) lock = null; }); // the system takes it back when the page is hidden
|
|
599
|
+
} catch { }
|
|
600
|
+
}
|
|
601
|
+
if (typeof MutationObserver !== "undefined") new MutationObserver(() => { if (compact() || lock) keepAwake(); }).observe(els.exportOverlay, { attributes: true, attributeFilter: ["class"] });
|
|
602
|
+
let leftAt = 0;
|
|
603
|
+
document.addEventListener("visibilitychange", () => {
|
|
604
|
+
if (!compact()) return;
|
|
605
|
+
if (document.hidden) { leftAt = exporting() ? performance.now() : 0; if (runtime.saveTimer && typeof flushSave === "function") flushSave(); return; } // an edit still waiting is written while there is time
|
|
606
|
+
if (!exporting()) return;
|
|
607
|
+
keepAwake();
|
|
608
|
+
if (leftAt && performance.now() - leftAt > 20000) toast("The export goes on from where it was");
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
/* ── A phone's or tablet's Back button (or its edge swipe) ──
|
|
612
|
+
It closes what is open, one thing at a time, and only then leaves. One spare entry in the page's
|
|
613
|
+
history stands under the editor for it; it is put back after each use. */
|
|
614
|
+
let spare = false;
|
|
615
|
+
const guard = () => { if (spare || !compact() || document.querySelector(".fcs-gate")) return; spare = true; history.pushState({ fablecut: 1 }, ""); };
|
|
616
|
+
window.addEventListener("click", (e) => { if (e.isTrusted) guard(); }, true); // browsers count only entries made by a person's touch
|
|
617
|
+
const esc = () => { const t = document.activeElement && document.activeElement !== document.body ? document.activeElement : document.body; t.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true })); };
|
|
618
|
+
const seen = (sel) => [...document.querySelectorAll(sel)].filter((el) => !el.hidden && !el.classList.contains("hidden") && el.getClientRects().length).pop();
|
|
619
|
+
function stepBack() {
|
|
620
|
+
if (!imp.hidden) { imp.hidden = true; return true; }
|
|
621
|
+
const panel = seen(".fcs-agent-pop, .fcs-ver, .fcs-rep, .fcs-me-pop, .fcs-folder-pop, .fcs-ask, .fcs-up-shade, .fcs-ready");
|
|
622
|
+
if (panel) { esc(); if (seen("." + [...panel.classList].join("."))) { const x = panel.querySelector(".x, [data-act*=close], [data-up*=close]"); if (x) x.click(); else panel.hidden = true; } return true; }
|
|
623
|
+
if (seen(".ctx-menu, .fc-select-list")) { hideTrackCtxMenu(); esc(); return true; }
|
|
624
|
+
if (runtime.styleMenu) { closeStylePicker(); return true; }
|
|
625
|
+
if (!els.exportOverlay.classList.contains("hidden")) { toast("The export is running. Cancel stops it"); return true; }
|
|
626
|
+
const dlg = seen(".overlay");
|
|
627
|
+
if (dlg) {
|
|
628
|
+
esc();
|
|
629
|
+
if (!dlg.classList.contains("hidden")) { const b = [...dlg.querySelectorAll("button")].find((q) => /^(close|cancel|✕)$/i.test((q.textContent || "").trim()) || /close/i.test(q.id)); if (b) b.click(); else dlg.classList.add("hidden"); }
|
|
630
|
+
return true;
|
|
631
|
+
}
|
|
632
|
+
if (toolInUse()) { esc(); if (toolInUse() === "path") pathUi.key = -1; precSig = ""; refresh(); return true; }
|
|
633
|
+
if (sheet && (phone() || !RAIL.some(([n]) => n === sheet))) { closeSheet(); return true; } // a tablet's side panel is part of the layout; its lists are not
|
|
634
|
+
if (isSourceMode()) { setMonitorMode("program"); return true; }
|
|
635
|
+
if (runtime.selectMode) { selectMode(false); return true; }
|
|
636
|
+
if (state.compCtx) { exitComp(1); refresh(); return true; }
|
|
637
|
+
if (state.selId) { selectClip(null); return true; }
|
|
638
|
+
return false;
|
|
639
|
+
}
|
|
640
|
+
let askedAt = -Infinity;
|
|
641
|
+
window.addEventListener("popstate", () => {
|
|
642
|
+
if (!spare) return;
|
|
643
|
+
spare = false;
|
|
644
|
+
if (!compact() || document.querySelector(".fcs-gate")) return;
|
|
645
|
+
if (stepBack()) { guard(); return; }
|
|
646
|
+
const home = window.__fcStudio && leave();
|
|
647
|
+
if (home) { home.click(); return; } // Studio: to its Projects page
|
|
648
|
+
if (performance.now() - askedAt < 3500) { history.back(); return; }
|
|
649
|
+
askedAt = performance.now();
|
|
650
|
+
toast("Back again to leave the editor");
|
|
651
|
+
guard();
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
/* ── Tablet: the rail that picks the one side panel ── */
|
|
655
|
+
const RAIL = [["media", "Media", "media"], ["inspector", "Edit", "edit"], ["color", "Color", "color"], ["mixer", "Mixer", "mixer"], ["transcript", "Words", "words"]];
|
|
656
|
+
for (const [name, label, icon] of RAIL) {
|
|
657
|
+
const b = button("m-tool", icon, label, () => toggleSheet(name), label);
|
|
658
|
+
b.dataset.panel = name;
|
|
659
|
+
rail.append(b);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/* Phone, upright: the preview gets the height its picture needs at full width, the timeline the rest */
|
|
663
|
+
function fitPreview() {
|
|
664
|
+
if (!phone() || L.landscape) return;
|
|
665
|
+
const W = window.innerWidth, H = window.innerHeight;
|
|
666
|
+
const pic = W * (project.height || 9) / (project.width || 16) + 16;
|
|
667
|
+
const prev = splitAt ? H * splitAt : Math.max(H * 0.3, Math.min(H * 0.46, pic));
|
|
668
|
+
app.style.setProperty("--m-tl", Math.round(Math.max(150, H - 48 - 50 - 62 - prev)) + "px");
|
|
669
|
+
}
|
|
670
|
+
/* …unless the bar between them was dragged: that share of the screen is kept. Two taps hand it back. */
|
|
671
|
+
const SPLIT_KEY = "fablecut-phone-split";
|
|
672
|
+
let splitAt = 0;
|
|
673
|
+
try { splitAt = clamp(+localStorage.getItem(SPLIT_KEY) || 0, 0, 0.6); } catch { }
|
|
674
|
+
const keepSplit = (v) => { splitAt = v; try { if (v) localStorage.setItem(SPLIT_KEY, v.toFixed(3)); else localStorage.removeItem(SPLIT_KEY); } catch { } fitPreview(); };
|
|
675
|
+
const split = make("div", "m-split");
|
|
676
|
+
split.title = "Drag to resize the preview";
|
|
677
|
+
els.timelineScroll.closest(".timeline-panel").before(split);
|
|
678
|
+
split.addEventListener("pointerdown", (e) => {
|
|
679
|
+
e.preventDefault();
|
|
680
|
+
const y0 = e.clientY, H = window.innerHeight, h0 = els.monitorStage.getBoundingClientRect().height;
|
|
681
|
+
split.setPointerCapture(e.pointerId);
|
|
682
|
+
const move = (ev) => { splitAt = clamp((h0 + ev.clientY - y0) / H, 0.18, 0.6); fitPreview(); state.dirtyTimeline = true; };
|
|
683
|
+
const up = () => { split.removeEventListener("pointermove", move); split.removeEventListener("pointerup", up); split.removeEventListener("pointercancel", up); if (splitAt) keepSplit(splitAt); };
|
|
684
|
+
split.addEventListener("pointermove", move); split.addEventListener("pointerup", up); split.addEventListener("pointercancel", up);
|
|
685
|
+
});
|
|
686
|
+
split.addEventListener("dblclick", () => keepSplit(0));
|
|
687
|
+
|
|
688
|
+
/* Nothing on the timeline yet: one big way in. What is picked goes to the bin and, one after the other, onto V1 */
|
|
689
|
+
const start = make("div", "m-start");
|
|
690
|
+
start.append(button("btn primary m-add", "plus", "Add clips", () => { addToTimeline = true; els.fileInput.click(); }, "Add clips"));
|
|
691
|
+
start.append(make("p", "dim", "Videos, photos or music from this device"));
|
|
692
|
+
els.timelineScroll.closest(".timeline").append(start);
|
|
693
|
+
let addToTimeline = false;
|
|
694
|
+
els.fileInput.addEventListener("cancel", () => { addToTimeline = false; });
|
|
695
|
+
window.addEventListener("fablecut:imported", async (e) => {
|
|
696
|
+
if (!addToTimeline) return;
|
|
697
|
+
addToTimeline = false;
|
|
698
|
+
// what is inside each file (sound or none) is read just after the import: a moment for it
|
|
699
|
+
const gen = e.detail.gen; // the project they were imported into
|
|
700
|
+
for (let i = 0; i < 40 && state.connected && e.detail.media.some((m) => !m.transient && m.size == null); i++) await new Promise((r) => setTimeout(r, 100));
|
|
701
|
+
if (gen !== runtime.projectGen) return;
|
|
702
|
+
// an empty project takes the first picture's shape (a phone clip is upright), at most 1080 on its short side
|
|
703
|
+
const pic = e.detail.media.find((m) => m.width && m.height);
|
|
704
|
+
if (pic && !project.clips.length) {
|
|
705
|
+
const k = Math.min(1, 1080 / Math.min(pic.width, pic.height)), even = (v) => Math.max(2, Math.round(v * k / 2) * 2);
|
|
706
|
+
setCanvasSize(even(pic.width), even(pic.height));
|
|
707
|
+
}
|
|
708
|
+
let at = 0, placed = 0;
|
|
709
|
+
const snap = undoSnapshot(), steps = runtime.undo.slice();
|
|
710
|
+
for (const m of e.detail.media) {
|
|
711
|
+
const c = m.kind === "audio" ? addClipFromMedia(m, null, 0) : addClipFromMedia(m, "V1", at);
|
|
712
|
+
if (c) placed++;
|
|
713
|
+
if (c && m.kind !== "audio") at = c.start + c.duration;
|
|
714
|
+
}
|
|
715
|
+
if (placed) { runtime.undo.splice(0, runtime.undo.length, ...steps); pushUndo(snap); } // one import, one undo
|
|
716
|
+
selectClip(null); setTime(0);
|
|
717
|
+
closeSheet();
|
|
718
|
+
});
|
|
719
|
+
/* the clips start half a view in: a narrower or wider timeline has to be laid out again */
|
|
720
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
721
|
+
let w = 0;
|
|
722
|
+
new ResizeObserver(() => {
|
|
723
|
+
const now = els.timelineScroll.clientWidth;
|
|
724
|
+
if (now === w || !compact()) return;
|
|
725
|
+
w = now; state.dirtyTimeline = true; noteActivity();
|
|
726
|
+
}).observe(els.timelineScroll);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/* two taps on a title: its text, ready to type */
|
|
730
|
+
function editText() {
|
|
731
|
+
openSheet("inspector", { section: /^Text$/ });
|
|
732
|
+
const t = els.inspector.querySelector("textarea");
|
|
733
|
+
if (t) { t.focus(); t.select(); }
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
let queued = false;
|
|
737
|
+
function refresh() {
|
|
738
|
+
if (queued) return;
|
|
739
|
+
queued = true;
|
|
740
|
+
requestAnimationFrame(() => {
|
|
741
|
+
queued = false;
|
|
742
|
+
if (!compact()) return;
|
|
743
|
+
const inComp = !!state.compCtx;
|
|
744
|
+
nameEl.textContent = inComp ? "In " + project.name.split(" › ").pop() : project.name;
|
|
745
|
+
back.hidden = !inComp && !leave();
|
|
746
|
+
back.setAttribute("aria-label", inComp ? "Back to the timeline around it" : "Projects");
|
|
747
|
+
start.hidden = project.clips.length > 0;
|
|
748
|
+
fitPreview();
|
|
749
|
+
bUndo.disabled = !runtime.undo.length; bRedo.disabled = !runtime.redo.length;
|
|
750
|
+
renderTools();
|
|
751
|
+
renderPrec();
|
|
752
|
+
if (sheet === "inspector" && chips.children.length !== sections().length) fillChips();
|
|
753
|
+
for (const b of rail.children) b.classList.toggle("on", b.dataset.panel === sheet);
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
window.addEventListener("fablecut:selection", refresh);
|
|
757
|
+
for (const ev of ["pointerup", "click", "keyup", "change"]) window.addEventListener(ev, refresh); // an edit may have ended (a button acts on click): undo / redo and the tool's keys follow
|
|
758
|
+
|
|
759
|
+
/* ── Layout changes: an open sheet stays open where the new layout has one ── */
|
|
760
|
+
function onLayout() {
|
|
761
|
+
fillHelp();
|
|
762
|
+
if (compact()) {
|
|
763
|
+
reword(els.binList);
|
|
764
|
+
if (sheet && !(sheet in SHEETS)) closeSheet();
|
|
765
|
+
if (L.mode === "tablet" && !sheet) openSheet("media");
|
|
766
|
+
if (sheet && SHEETS[sheet].list) { // its rows depend on the layout; the one with the focus keeps it
|
|
767
|
+
const on = list.contains(document.activeElement) ? document.activeElement.getAttribute("aria-label") : "";
|
|
768
|
+
openSheet(sheet, { title: titleEl.textContent });
|
|
769
|
+
const row = on && [...list.querySelectorAll("button")].find((b) => b.getAttribute("aria-label") === on);
|
|
770
|
+
if (row) row.focus({ preventScroll: true });
|
|
771
|
+
}
|
|
772
|
+
if (phone() && sheet && !L.landscape) app.style.setProperty("--m-sheet-h", Math.round(window.innerHeight * 0.5) + "px");
|
|
773
|
+
shown = "";
|
|
774
|
+
refresh();
|
|
775
|
+
} else delete app.dataset.sheet;
|
|
776
|
+
if (compact() && sheet) app.dataset.sheet = sheet;
|
|
777
|
+
}
|
|
778
|
+
window.addEventListener("fablecut:layout", onLayout);
|
|
779
|
+
onLayout();
|
|
780
|
+
|
|
781
|
+
/* the transport's own ⋯ (phone): everything that does not fit the row */
|
|
782
|
+
$("btnSpeed").after(button("btn icon m-play-more", "more", "More playback controls", () => toggleSheet("play")));
|
|
783
|
+
|
|
784
|
+
self.FableCutCompact = { modal: [".ctx-menu", ".style-menu", ".fc-select-list"], mods, words, stepBack, moveToFolder, folderMenu, usedAddPoint: () => { if (mods.ctrl) { mods.ctrl = false; precSig = ""; refresh(); } }, selectMode, editText, openSheet, closeSheet, toggleSheet, refresh, get sheet() { return sheet; } };
|
|
785
|
+
})();
|