On a phone, magpie web's pages sat in a strip under the header that scrolled sideways, with nothing to show that more pages lay past its edge. Agents, Library and the rest looked missing. The pages are now a tab bar at the foot, as an iPhone app's (HIG): each tab its mark over its word, the page open marked. Five tabs at most: with more pages than that, the fifth is More, and its menu lists the rest with their marks and a tick on the open one. More is marked while one of them is open, and it carries the dot when one of them has one. phonetabs.js does this. app.js loads it lazily only on a phone, so the core script doesn't grow. A status line comes up over the bar. The bar is only for the window, never the tray panel (body.panel). Agents still isn't shown in gateway mode on a machine with no agents, as designed (Settings > General > Gateway mode brings it back). Library has been shown in gateway mode sincef285426ac. Tests: phone-tabs.test.cjs (new) runs at 390x844 in chromium and webkit, in en, zh, zh-TW, ja and de, with gateway mode on and off. It checks: - five tabs with More fifth, at the foot, 44px tall; - nothing scrolls sideways; - every page is reached from the bar or from More, and More's menu opens above the bar; - the bar covers no page content and no status line; - a desktop browser has no More. reader.cjs gets openPage() (the tab, or More's menu). mobile-web, phone-no-sideways, routing-held-dot and name-suffix-saved open pages through it. phone-web checks the bar at the foot. old-webkit lists phonetabs.js as lazy. market-more waits for the view's own foot, not the window's, which is now above the bar. group-from-model-add wheels Add wholly into the view before its press, because at 600x420 WebKit took a press on Add's half-hidden middle as one on the header. Run on mote: - The whole GUI suite once (450 files, concurrency 3). 33 red files were then run on this change's base and on the branch. The reds only on the branch were the four tests that tapped tabs now under More, phone-web's old label check, market-more, group-from-model-add (webkit 600x420), and the panel tests agent-menu-label, zcode-models and panel-fit-tabs (webkit). The panel tests are web:true at 360-380px, so the bar's padding reached the panel. It is now scoped :not(.panel). - After the fixes: phone-web, market-more, group-from-model-add, agent-menu-label, zcode-models, panel-fit-tabs, phone-tabs, mobile-web, phone-no-sideways, routing-held-dot, name-suffix-saved, old-webkit and i18n-keys. All are green except reds already filed on main: #5919 (old-webkit :has), #5869 (phone-no-sideways de 375) and #5215 (tray-cell-click, a web:false panel test). mobile-web's 900/1280 desktop screenshots need git, so they were run with BASE_REF set to a commit of the base's assets: 30/30 pass in both engines, so the desktop is unchanged. - gofmt, go vet for darwin, linux (nogui) and windows, and go test ./internal/gui. - Again at the pushed head, rebased on origin/mainca7a39291: the 13 GUI files above (239 pass; reds only #5919, #5869 and mobile-web's git-less desktop compare), gofmt, vet on all three, and go test ./internal/gui ok. TestCoreScriptBudget was over at the old base662546e78and passes here: app.js is ~430 bytes smaller. - Rebased again on388ca9ad4(two agent commits touching app.js and i18n.js): the budget tests, i18n-keys, phone-tabs and phone-web pass (34 of 34). Then onto0baa223ec(Kun; a one-line app.js change) with no further run before the push. Broken by hand: - Without layoutNav's import of phonetabs.js, phone-tabs is 20 of 24 red. - Without :not(.panel), panel-fit-tabs (webkit, 5 languages) and agent-menu-label go red. Not tried: a real iPhone's Safari, or the LAN share opened on a real phone.
54 lines
3.0 KiB
JavaScript
54 lines
3.0 KiB
JavaScript
// magpie web on a phone (app.js phoneWeb): the pages are a tab bar at the
|
|
// window's foot, as an iPhone app's (app.css). Five fit; with more, the
|
|
// fifth is More, a menu of the rest, marked while one of them is open
|
|
// (geraldpppppp on X: Agents and the Library were past the edge of a
|
|
// strip that scrolled sideways, and nothing said it did). Imported by
|
|
// layoutNav the first time the page is a phone's.
|
|
const nav = $("#nav");
|
|
const more = el("button", "nav-more");
|
|
more.type = "button";
|
|
more.setAttribute("aria-haspopup", "menu");
|
|
more.setAttribute("aria-expanded", "false");
|
|
more.innerHTML = '<svg class="nav-ic" viewBox="0 0 20 20" width="16" height="16" aria-hidden="true"><g fill="currentColor"><circle cx="4.5" cy="10" r="1.5"/><circle cx="10" cy="10" r="1.5"/><circle cx="15.5" cy="10" r="1.5"/></g></svg>';
|
|
const word = el("span");
|
|
more.append(word);
|
|
let over = [];
|
|
|
|
function fit() {
|
|
for (const b of nav.querySelectorAll(".tb-over")) b.classList.remove("tb-over");
|
|
// what the bar has: the pages shown, gateway mode's, a plugin's and
|
|
// the switched-off ones left out (app.js navHides, app.css)
|
|
const pages = phoneWeb() ? [...nav.querySelectorAll(":scope > button[data-view]")].filter((b) => getComputedStyle(b).display !== "none") : [];
|
|
over = pages.length > 5 ? pages.slice(4) : [];
|
|
for (const b of over) b.classList.add("tb-over");
|
|
if (!over.length) more.remove();
|
|
else if (nav.lastElementChild !== more) nav.append(more);
|
|
// "More" alone is the heatmap's 多; the tab's is its own word
|
|
const said = t("More pages");
|
|
word.textContent = said === "More pages" ? "More" : said;
|
|
more.setAttribute("aria-label", said);
|
|
const open = over.find((b) => b.classList.contains("on"));
|
|
more.classList.toggle("on", !!open);
|
|
if (open) more.setAttribute("aria-current", "page"); else more.removeAttribute("aria-current");
|
|
more.classList.toggle("has-dot", over.some((b) => b.classList.contains("has-dot")));
|
|
watch.takeRecords(); // its own changes aren't news
|
|
}
|
|
const watch = new MutationObserver(fit);
|
|
// a page shown or left out, the one open, a dot, a language's words
|
|
watch.observe(nav, { childList: true, attributes: true, subtree: true, attributeFilter: ["class", "hidden", "data-replaced"] });
|
|
matchMedia("(max-width: 760px), (pointer: coarse) and (max-width: 1024px)").addEventListener?.("change", fit);
|
|
|
|
more.onclick = () => {
|
|
if (more.classList.contains("open")) return closeProtoMenu();
|
|
const open = over.find((b) => b.classList.contains("on"));
|
|
openProtoMenu(more, over.map((b) => ({ v: b.dataset.view, name: b.textContent.trim(), literalName: true })), open?.dataset.view ?? "",
|
|
(v) => over.find((b) => b.dataset.view === v)?.click(), "More pages", "nav-more-menu", "right");
|
|
// each page with its tab's mark, as an iPhone's More list has
|
|
const box = document.querySelector(".nav-more-menu");
|
|
box?.querySelectorAll(".pm-item").forEach((item, i) => {
|
|
const ic = over[i]?.querySelector(".nav-ic");
|
|
if (ic) item.querySelector(".pm-words").before(ic.cloneNode(true));
|
|
});
|
|
};
|
|
fit();
|