diff --git a/public/dagi-filter.js b/public/dagi-filter.js index be45cb0a2..40c03e69a 100644 --- a/public/dagi-filter.js +++ b/public/dagi-filter.js @@ -173,6 +173,15 @@ '. The count covers all nodes, before the other filters.'; } + /** hiddenNotice's count in a few words, for a one-line notice (Live, + * #1055 owner report): short enough that the line, with the rule, fits + * a 360 px phone. '' for none. */ + function hiddenShort(n) { + n = Number(n) || 0; + if (n <= 0) return ''; + return (n === 1 ? '1 node' : n + ' nodes') + ' not on map'; + } + /** GET /api/config/dagi/polygons as Leaflet rings: every feature's * rings, each [lon0, lat0, dlon, dlat, …] in quantum degrees with the * closing vertex implicit, summed and swapped to [lat, lon]. The rings @@ -1020,6 +1029,7 @@ selectedEntry: selectedEntry, creditElement: creditElement, hiddenNotice: hiddenNotice, + hiddenShort: hiddenShort, hiddenCount: hiddenCount, notAppliedNotice: notAppliedNotice, search: search, diff --git a/public/live.css b/public/live.css index 6982592a1..f1e2944ed 100644 --- a/public/live.css +++ b/public/live.css @@ -568,8 +568,7 @@ transform: translate(-50%, -50%); } /* #1055 M2: the Danish areas (DAGI) filter beside Area, at the same 30 px - row height with the same 48 px hit area, so the row does not grow; and the - feed's "only adverts are shown" notice on a line of its own. */ + row height with the same 48 px hit area, so the row does not grow. */ .live-controls-body .live-dagi-filter-container { font-size: 11px; } .live-controls-body .live-dagi-filter-container .dagi-trigger { font-size: inherit; @@ -590,7 +589,53 @@ } /* The clear's hit area stays inside the 4 px gap, off the trigger's. */ .live-controls-body .live-dagi-filter-container .dagi-clear::after { width: calc(100% + 8px); } -.live-controls-body .live-scope-notice { flex: 0 0 100%; padding: 0; font-size: 11px; } +/* #1055 owner report: the notice is one line at the start of the scope row + (the rule, and the count for DAGI), not a paragraph on a row of its own; + the explanation (the line's title) opens under "why?" on its own line. */ +.live-controls-body .live-scope-notice { + flex: 0 1 auto; + min-width: 0; + max-width: 100%; + display: flex; + flex-wrap: wrap; + align-items: center; + column-gap: 6px; + padding: 0; + font-size: 11px; +} +.live-controls-body .live-scope-notice[hidden], +.live-scope-notice-why[hidden] { display: none; } +.live-controls-body .live-scope-notice:has(.live-scope-notice-why:not([hidden])) { flex-basis: 100%; } +.live-scope-notice-line { + flex: 0 1 auto; + min-width: 0; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.live-scope-notice-count:not(:empty)::before { content: " \00b7 "; /* the escape takes one space */ } +.live-scope-notice-why-btn { + flex: none; + position: relative; + padding: 0; + border: 0; + background: none; + color: var(--accent); + font: inherit; + text-decoration: underline; + cursor: pointer; +} +/* A 24px hit area inside the row, on a text-sized link. */ +.live-scope-notice-why-btn::after { + content: ""; + position: absolute; + top: 50%; + left: 50%; + width: max(100%, 24px); + height: 24px; + transform: translate(-50%, -50%); +} +.live-scope-notice-why { flex: 0 0 100%; white-space: normal; } /* #1055 M3: the area rule selector, two radios as one segmented control, next to the Area and DAGI filters. 30 px tall with the 48 px hit area of the controls beside it; 48 px on a touch screen (the pointer: coarse @@ -1036,6 +1081,15 @@ body.kiosk .live-node-detail:not(.hidden) ~ .live-kiosk-exit { display: none; } +/* #1055 owner report: the panel stops short of the map's right-hand button + column (zoom, layers, Fullscreen, Settings, Legend), which sits in the + same band above 640px. live.js publishes the column's measured width plus + a 6px gap as --live-map-rail (12px until it is measured). Fullscreen + keeps .live-header's own width: the controls are hidden there (#1572). */ +@media (min-width: 641px) { + body:not(.live-fullscreen) .live-header { max-width: calc(100vw - 12px - var(--live-map-rail, 12px)); } +} + /* ---- Medium breakpoint (#279) + collapse toggles (#1178, #1179) ---- */ @media (max-width: 768px) { .live-feed { width: 280px; max-height: 200px; } @@ -1090,13 +1144,13 @@ body.kiosk .live-node-detail:not(.hidden) ~ .live-kiosk-exit { display: none; } /* #664 — the gear (#liveControlsToggle) lives in the Leaflet top-right stack, outside #liveHeader. With region groups the expanded panel grew down over the gear and swallowed every tap, so it could not be closed. - While expanded, keep the panel out of the control rail (10px Leaflet - margin + 52px control + 6px gap) so no panel height can cover it. + While expanded, keep the panel out of the control rail (its measured + width, #1055: --live-map-rail) so no panel height can cover it; at + ≤ 640px the collapsed header sits above the rail and keeps its width. Not a max-height + scroll: overflow would clip the absolutely positioned region/area dropdown menus. */ body:not(.live-fullscreen) .live-header:has(.live-controls.is-expanded) { - --live-ctrl-rail: 68px; - max-width: calc(100vw - 12px - var(--live-ctrl-rail)); + max-width: calc(100vw - 12px - var(--live-map-rail, 68px)); } } @@ -1452,19 +1506,17 @@ body.live-fullscreen #liveFullscreenToggle:hover, gear ends under the VCR bar or below the .live-page clip. Lay the stack out as one row instead (y 74–174, gear still in the corner). The legend toggle is the last control of that row (#875), so nothing overlaps it. Short desktop windows (≤ 500px tall) get the row too. - The header stops short of the row (5 × 10px Leaflet margin + 52 + 48 + - 52 + 52 + 52px controls + 6px gap: zoom, layers, Fullscreen, Settings, - Legend) while expanded, so it cannot cover the controls either. At - ≤ 640px wide the legend control is hidden (#875), so the row is four - controls (250px) again. */ + The header stops short of the row while expanded, so it cannot cover the + controls either: --live-map-rail is the row's measured width (#1055), + four controls at ≤ 640px wide where the legend control is hidden (#875), + five above. */ @media (orientation: landscape) and (max-height: 500px) { .live-page .leaflet-top.leaflet-right { display: flex; align-items: flex-start; } body:not(.live-fullscreen) .live-header:has(.live-controls.is-expanded) { - --live-ctrl-rail: 312px; - max-width: calc(100vw - 12px - var(--live-ctrl-rail)); + max-width: calc(100vw - 12px - var(--live-map-rail, 312px)); } } /* #875: a narrow window (the bottom navigation takes 58px) 501-620px tall has @@ -1474,11 +1526,6 @@ body.live-fullscreen #liveFullscreenToggle:hover, @media (max-width: 768px) and (min-height: 501px) and (max-height: 620px) { .live-legend, .live-legend-toggle-ctl { display: none !important; } } -@media (orientation: landscape) and (max-height: 500px) and (max-width: 640px) { - body:not(.live-fullscreen) .live-header:has(.live-controls.is-expanded) { - --live-ctrl-rail: 250px; - } -} /* #875: just above the row breakpoint (501–540px) the five-control column is * 418px tall and its last control, Legend, ends under the credit that sits on @@ -1543,6 +1590,27 @@ body.live-fullscreen #liveFullscreenToggle:hover, /* #1055 M3: the area rule selector at the house size. */ .live-area-rule button { height: 48px; } } +/* #1087 review N2: the DAGI control and the area rule sit in one wrapper. + Above 640px it lays nothing out (display: contents), so both stay items + of the controls row. At 640px and below they share one row instead of + the selector taking a 48 px row of its own: the radios show their short + labels ("From", "Touches"; the full name is each radio's aria-label, and + the notice line names the rule in full), and the DAGI label gives way + (its ellipsis) before the selector would wrap. */ +.live-dagi-rule { display: contents; } +@media (max-width: 640px) { + .live-controls-body .live-dagi-rule:has(> .live-area-rule:not([hidden])) { + display: flex; + align-items: center; + gap: 8px; + min-width: 0; + max-width: 100%; + } + .live-dagi-rule > .live-dagi-filter-container { min-width: 0; } + .live-dagi-rule > .live-area-rule { flex: none; } + .live-area-rule-more { display: none; } + .live-area-rule button { padding: 2px 6px; } +} .live-controls.is-expanded.is-capped .live-controls-body :is(.live-region-filter-container, .live-area-filter-container):has(.region-dropdown-menu:not([hidden])) { flex: 0 0 100%; } .live-controls.is-expanded.is-capped .live-controls-body .region-dropdown-wrap:has(> .region-dropdown-menu:not([hidden])) { flex: 0 0 100%; } .live-controls.is-expanded.is-capped .live-controls-body .region-dropdown-menu { min-width: 0; max-width: 100%; } @@ -2014,6 +2082,12 @@ input.live-node-filter-input:focus { * 10px control margin + ~50px control + gap, the same rail .live-header uses. */ .live-legend[data-position="tr"], .live-legend[data-position="br"] { right: var(--live-ctrl-rail-legend, 68px); } +/* #1055 owner report: a legend in a bottom corner grew up to the nav band, + * under the open MESH LIVE panel, and hid its right end. It now stops under + * the panel (live.js publishes the panel's bottom as --live-panel-bottom) + * and scrolls the rest, as it does on a short window. */ +.live-legend[data-position="bl"], +.live-legend[data-position="br"] { --live-legend-top: max(64px, var(--live-panel-bottom, 0px)); } /* #875: in short landscape viewports the control stack is a row across the top * right (see #666), not a column, so the right-hand corners keep below it diff --git a/public/live.js b/public/live.js index e78c8dfcf..d0ab94337 100644 --- a/public/live.js +++ b/public/live.js @@ -327,24 +327,35 @@ // #1055 M2 (owner decision 1): Area and DAGI filter the Live feed by the // Packets rule (the ADVERT sender is a member), so the feed says so, as // Packets does; with DAGI it adds the count of nodes no area can hold. + // #1055 owner report: the panel shows that in one line (the rule, the + // count); the Packets wording is the line's title and opens under "why?". function renderLiveScopeNotice() { const el = document.getElementById('liveScopeNotice'); if (!el) return; const sel = liveScopeSelection(); const text = ScopeMemberFilter.advertsOnlyNotice(sel); + const rule = ScopeMemberFilter.advertsOnlyShort(sel); const gen = ++liveNoticeGeneration; - const show = function (t) { - if (el.textContent !== t) el.textContent = t; - el.hidden = !t; + const setText = function (id, t) { + const part = document.getElementById(id); + if (part && part.textContent !== t) part.textContent = t; }; - show(text); + const show = function (why, count) { + setText('liveScopeRule', rule); + setText('liveScopeCount', count); + setText('liveScopeWhy', why); + const line = document.getElementById('liveScopeLine'); + if (line && line.title !== why) line.title = why; + el.hidden = !why; + }; + show(text, ''); renderAreaRule(sel.area || sel.dagi); renderMemberLoading(sel.loading && text ? text : ''); if (!sel.dagi) return; DagiFilter.hiddenCount().then(function (n) { if (gen !== liveNoticeGeneration) return; const hidden = DagiFilter.hiddenNotice(n); - show(hidden ? text + ' ' + hidden : text); + show(hidden ? text + ' ' + hidden : text, DagiFilter.hiddenShort(n)); }); } @@ -368,15 +379,32 @@ } function feedEmptyText() { return memberLoadingText ? FEED_LOADING_TEXT : FEED_EMPTY_TEXT; } + // "why?" opens and closes the notice's explanation (a button, so Enter and + // Space work too); the line's title carries the same text on hover. + function wireLiveScopeWhy() { + const btn = document.getElementById('liveScopeWhyBtn'); + const why = document.getElementById('liveScopeWhy'); + if (!btn || !why) return; + btn.addEventListener('click', function () { + const open = btn.getAttribute('aria-expanded') !== 'true'; + btn.setAttribute('aria-expanded', open ? 'true' : 'false'); + why.hidden = !open; + }); + } + // #1055 M3: the selector shows while a filter is on, with the active rule - // checked. + // checked. Only the checked radio is a Tab stop (roving tabindex, the + // radio group pattern; #1087 review N3). function renderAreaRule(on) { const el = document.getElementById('liveAreaRule'); if (!el) return; el.hidden = !on; el.querySelectorAll('[data-rule]').forEach(function (b) { - const checked = b.dataset.rule === areaRule ? 'true' : 'false'; + const active = b.dataset.rule === areaRule; + const checked = active ? 'true' : 'false'; if (b.getAttribute('aria-checked') !== checked) b.setAttribute('aria-checked', checked); + const tab = active ? '0' : '-1'; + if (b.getAttribute('tabindex') !== tab) b.setAttribute('tabindex', tab); }); } @@ -393,7 +421,10 @@ rebuildFeedList(); } - // One click listener on the selector itself, so it goes with the page. + // The click and key listeners are on the selector itself, so they go with + // the page. The arrow keys check and focus the next radio, wrapping + // (#1087 review N3); Space and Enter click the focused one. + const AREA_RULE_KEYS = { ArrowLeft: -1, ArrowUp: -1, ArrowRight: 1, ArrowDown: 1 }; function wireAreaRule() { const el = document.getElementById('liveAreaRule'); if (!el) return; @@ -401,6 +432,17 @@ const b = e.target && e.target.closest ? e.target.closest('[data-rule]') : null; if (b && el.contains(b)) setLiveAreaRule(b.dataset.rule); }); + el.addEventListener('keydown', function (e) { + const step = AREA_RULE_KEYS[e.key]; + if (!step) return; + const radios = Array.prototype.slice.call(el.querySelectorAll('[data-rule]')); + const at = radios.indexOf(e.target); + if (at < 0) return; + e.preventDefault(); + const next = radios[(at + step + radios.length) % radios.length]; + setLiveAreaRule(next.dataset.rule); + next.focus(); + }); } // #1055 M2: one member set per selection (none fetched again for the same @@ -475,6 +517,10 @@ // Area AND DAGI under the active rule (#1055 M3). From: O(1), the first // observation names the sender for all. Touches: O(observations x hops) // Set lookups, as each observation has its own observer and path. + // Under Touches a WS observation is judged alone (without Realistic) while + // rebuildFeedList judges the whole hash group, so a transmission whose + // Area and DAGI are each touched only by different observations shows + // after a rebuild but not live (#1087 review N4). function passesLiveMemberFilters(packets) { return !memberScopes || memberScopes.acceptsGroup(packets); } @@ -957,6 +1003,54 @@ }; } + // #1055 owner report: the MESH LIVE panel stops short of the map's + // right-hand button column (zoom, layers, Fullscreen, Settings, Legend; a + // row in short landscape, #666). Its width is measured here, from the + // page's right edge to the leftmost shown control, plus the 6px gap the + // panel kept from the column since #664, and published as --live-map-rail + // on the page (live.css), so the reserve follows whatever controls are + // shown. An open layers list is a + // menu over the map, not the column, and does not count. The panel's + // bottom edge is published too (--live-panel-bottom), so a legend in a + // bottom corner stops under the panel instead of growing beneath it. + var PANEL_RAIL_GAP = 6; + var _panelReserveCleanup = null; + function initPanelReserveTracker() { + if (_panelReserveCleanup) { try { _panelReserveCleanup(); } catch (_) {} _panelReserveCleanup = null; } + var page = document.querySelector('.live-page'); + var rail = page && page.querySelector('#liveMap .leaflet-top.leaflet-right'); + var header = document.getElementById('liveHeader'); + if (!rail || !header) return; + var raf = 0; + function measure() { + raf = 0; + var box = page.getBoundingClientRect(); + var reserve = 0; + for (var c = rail.firstElementChild; c; c = c.nextElementSibling) { + if (!c.getClientRects().length || c.classList.contains('leaflet-control-layers-expanded')) continue; + reserve = Math.max(reserve, box.right - c.getBoundingClientRect().left + PANEL_RAIL_GAP); + } + page.style.setProperty('--live-map-rail', Math.ceil(reserve) + 'px'); + page.style.setProperty('--live-panel-bottom', Math.ceil(header.getBoundingClientRect().bottom - box.top) + 'px'); + } + function schedule() { if (!raf) raf = requestAnimationFrame(measure); } + var ro = null; + if (typeof ResizeObserver === 'function') { + try { ro = new ResizeObserver(schedule); ro.observe(rail); ro.observe(header); } catch (_) { ro = null; } + } + window.addEventListener('resize', schedule); + measure(); + _panelReserveCleanup = function() { + if (raf) cancelAnimationFrame(raf); + if (ro) { try { ro.disconnect(); } catch (_) {} ro = null; } + window.removeEventListener('resize', schedule); + }; + } + + // The capped body's least height (#672: 150 px in short landscape) and + // the least gutter under it (live.css --live-ctrl-gutter). + var CTRL_BOX_MIN = 150; + var CTRL_GUTTER_MIN = 12; var _controlsFitCleanup = null; function initControlsFitTracker() { if (_controlsFitCleanup) { try { _controlsFitCleanup(); } catch (_) {} _controlsFitCleanup = null; } @@ -966,6 +1060,7 @@ var page = document.querySelector('.live-page'); var bar = document.getElementById('vcrBar'); if (!root || !body || !page) return; + function creditEl() { return page.querySelector('#liveMap .leaflet-control-attribution'); } var raf = 0; function fit() { raf = 0; @@ -975,7 +1070,18 @@ } var top = body.getBoundingClientRect().top; var barH = bar && bar.getClientRects().length ? bar.getBoundingClientRect().height : 0; - var reserve = window.innerHeight - (page.getBoundingClientRect().bottom - barH); + var limit = page.getBoundingClientRect().bottom - barH; + // #1055: the map credit sits on the VCR bar; on a phone it wraps under + // the panel's x range, so a capped panel stops above it too, unless + // that leaves less than #672's minimum scroll box (short landscape): + // reaching the controls comes first. + var credit = creditEl(); + if (credit && credit.getClientRects().length && header) { + var cr = credit.getBoundingClientRect(), hr = header.getBoundingClientRect(); + if (cr.left < hr.right && cr.right > hr.left && cr.top < limit && + cr.top - top - CTRL_GUTTER_MIN >= CTRL_BOX_MIN) limit = cr.top; + } + var reserve = window.innerHeight - limit; page.style.setProperty('--live-ctrl-top', Math.round(top) + 'px'); page.style.setProperty('--live-ctrl-reserve', Math.max(0, Math.ceil(reserve)) + 'px'); // Measure under the cap; in-flow children only, so an open dropdown @@ -1021,7 +1127,7 @@ if (typeof ResizeObserver === 'function') { try { ro = new ResizeObserver(schedule); - [header, page, bar].concat([].slice.call(body.children)).forEach(function(el) { if (el) ro.observe(el); }); + [header, page, bar, creditEl()].concat([].slice.call(body.children)).forEach(function(el) { if (el) ro.observe(el); }); } catch (_) { ro = null; } } schedule(); @@ -1783,6 +1889,7 @@ */ function wireLiveControls() { resolveScopeParams(); + wireLiveScopeWhy(); const TOGGLES = [ { id: 'liveHeatToggle', restore: () => heatEnabled, onChange: (v) => { heatEnabled = v; @@ -2239,16 +2346,28 @@
- -