mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Merge remote-tracking branch 'origin/main' into samehkhamis/kit-sweep-omnibar
This commit is contained in:
commit
1ef0aaa5cd
17 files changed
+886
-386
No files matched your search
@@ -0,0 +1,3 @@
|
||||
- The data credits line and its list are now a single-file component. The
|
||||
close button is the kit's, and a focused link keeps focus when the list
|
||||
redraws (manjunath22466, samehkhamis, #1844).
|
||||
@@ -0,0 +1,3 @@
|
||||
- The Québec CCTV camera window and its map marker are now a single-file
|
||||
component with the kit's close and buttons, and the window's labels follow
|
||||
the language at each update (manjunath22466, samehkhamis, #1845).
|
||||
@@ -0,0 +1,3 @@
|
||||
- The Omnibar's guided walk is now a single-file component with the kit's
|
||||
close and buttons, and a walk started while the page is still drawing no
|
||||
longer fails (manjunath22466, samehkhamis, #1846).
|
||||
+29
-6
@@ -116,8 +116,9 @@ no tip unless the site passes a `title`; attributes and classes pass through,
|
||||
so each site keeps its id, feature class and look. Every close, dismiss and
|
||||
clear button in the views is one (`src/ui/kit/closeButtons.test.mjs` pins
|
||||
it); Street Level's and the space mission's keep `bare`, since their skins
|
||||
set their own padding and border. The close buttons built in script (credits, the
|
||||
Quebec CCTV overlay, the guide) are not converted yet.
|
||||
set their own padding and border, and so does the credits list's. The
|
||||
Quebec CCTV overlay's close is one too, and so is the Omnibar guide's,
|
||||
which keeps its feature class and tip.
|
||||
`UiSearchField` takes `v-model`, a required `label` (the input's
|
||||
accessible name), `placeholder` and `tag` (`div`, given `role="search"` by
|
||||
the site, or `label`); attributes and classes go to the frame, and
|
||||
@@ -185,6 +186,12 @@ page declares no dark `color-scheme`. Selects and number fields are
|
||||
and keeps native spinners dark; ranges are `.gev-quantitative-slider`, with
|
||||
a feature supplying only its accent.
|
||||
|
||||
`t()` is not reactive. Words a view passes to a kit component as a prop
|
||||
(`UiCloseButton`'s `label`) follow a locale change on the view's next
|
||||
render, but words in a kit component's slot do not: the compiled slot does
|
||||
not render the child again. A view whose words must follow the locale at
|
||||
once passes the locale itself as a prop or key, as the credits line does.
|
||||
|
||||
## Phases
|
||||
|
||||
1. **Foundation.** Vue, Pinia and the Vite Vue plugin join the browser build
|
||||
@@ -252,8 +259,13 @@ a feature supplying only its accent.
|
||||
the whole panel from the `gev-cctv` store, including the camera picker,
|
||||
the inline pose editor, the frame preview, source badge and typed
|
||||
summary; `CctvControls` keeps its listeners, the frame requests and the
|
||||
live video surface), Layers (done: `LayerPanel` presents each row and
|
||||
renders `LayerRows` synchronously; keyed chips and list items keep focus
|
||||
live video surface; `QuebecCctvOverlay` teleports the Québec 511 player
|
||||
and its map preview to the end of the body, rendered synchronously by
|
||||
`createQuebecCctvOverlay()` from the view it computes, as the rail cards
|
||||
are; the owner keeps every decision and the parts the template never
|
||||
binds: each video's source, playback and refresh timer, the window's drag
|
||||
and the marker's per-frame visibility and place), Layers (done:
|
||||
`LayerPanel` presents each row and renders `LayerRows` synchronously; keyed chips and list items keep focus
|
||||
through the refresh their own click triggers, and clicks re-read the live
|
||||
descriptor before acting), Display (in progress: `DisplayPanel` renders
|
||||
the HUD, Sonar, Scope, Celestial, detection, bloom, sharpen and the
|
||||
@@ -298,7 +310,11 @@ a feature supplying only its accent.
|
||||
`gev-location` store, and the search field keeps its listeners; beside
|
||||
the voice control, the dock teleports each voice pointer reticle to the
|
||||
body where its `PointerReticle` presents it in the `gev-pointer-reticle`
|
||||
store), the phone shell (`PhoneTabBar` renders the tabs and open sheet the shell
|
||||
store; `startGuide()` renders the Omnibar's guided walk, `OmnibarGuide`,
|
||||
synchronously from the view it computes for each step, teleported to the
|
||||
end of the body, and keeps every decision and word, focus and its return,
|
||||
Escape, the entrance replay, and the callout's and spotlight rings' place
|
||||
each frame), the phone shell (`PhoneTabBar` renders the tabs and open sheet the shell
|
||||
publishes to the `gev-display` store, teleporting the tab bar and sheet
|
||||
backdrop to the end of the page from the first publish until the shell
|
||||
is destroyed; the shell takes their clicks from the document), the
|
||||
@@ -376,7 +392,14 @@ a feature supplying only its accent.
|
||||
choices, DISMISS and "Don't show this again" call the launcher's
|
||||
controls; a refused save hands the tick back to the view to revert. The
|
||||
launcher still reads the rendered card for its hit test, keyboard trap,
|
||||
focus and overflow measurement), then
|
||||
focus and overflow measurement), the attribution line (for a renderer
|
||||
without its own credit display, `mountCreditsView()` renders
|
||||
`CreditsView` synchronously, as the weather readout is, and the view
|
||||
teleports the line and its "Data attribution" list to the end of the
|
||||
body, where the page's rules select them; the owner keeps the credits
|
||||
shown, the list's open state and its focus, and words the view again
|
||||
when the locale changes; the list's close button is a bare
|
||||
`UiCloseButton`), then
|
||||
Cockpit (in progress: `CockpitBriefing` renders the briefing card's
|
||||
pages, cycle toggle, regional news and local conditions, and
|
||||
`CockpitContext` the Contact card's scope, navigation, counts, nearest
|
||||
|
||||
@@ -1586,6 +1586,8 @@
|
||||
"src/ui/creditLineHeight.js",
|
||||
"src/ui/creditLineHeight.test.mjs",
|
||||
"src/ui/creditsView.test.mjs",
|
||||
"src/ui/credits/CreditsView.vue",
|
||||
"src/ui/credits/CreditItem.vue",
|
||||
"src/cockpitSubjectProviders.js",
|
||||
"src/cockpitSubjectProviders.test.mjs",
|
||||
"src/cockpitProgress.js",
|
||||
@@ -1625,6 +1627,7 @@
|
||||
"src/tooling/wikidataPlaceTiles.test.mjs",
|
||||
"src/ui/omnibarIntent.test.mjs",
|
||||
"src/ui/omnibarRows.test.mjs",
|
||||
"src/ui/omnibarGuide.test.mjs",
|
||||
"src/ui/styles/omnibar-dock.css",
|
||||
"src/ui/styles/guide.css",
|
||||
"src/ui/commandDock.test.mjs",
|
||||
|
||||
@@ -300,6 +300,7 @@
|
||||
"src/exclusiveSurfaces.js",
|
||||
"src/geoDistance.js",
|
||||
"src/ui/omnibarGuide.js",
|
||||
"src/ui/views/panels/OmnibarGuide.vue",
|
||||
"src/cityPois.js",
|
||||
"src/search/photonSetting.js",
|
||||
"src/sources/requestDeadline.js",
|
||||
@@ -1096,6 +1097,11 @@
|
||||
"src/ui/cctvVideo.js",
|
||||
"src/ui/cctvPresentation.js",
|
||||
"src/ui/quebecCctvOverlay.js",
|
||||
"src/ui/views/panels/QuebecCctvOverlay.vue",
|
||||
"src/ui/kit/UiButton.vue",
|
||||
"src/ui/kit/UiCloseButton.vue",
|
||||
"src/ui/kit/UiIcon.vue",
|
||||
"src/ui/rail/classToggle.js",
|
||||
"src/i18n/index.js",
|
||||
"src/i18n/locale.js",
|
||||
"src/i18n/locales/ar.json",
|
||||
@@ -1635,6 +1641,7 @@
|
||||
"src/layers/wildlifeSightings/photoText.js",
|
||||
"src/data/iconOrientation.js",
|
||||
"src/ui/quebecCctvOverlay.js",
|
||||
"src/ui/views/panels/QuebecCctvOverlay.vue",
|
||||
"src/time/worldClock.js",
|
||||
"src/cockpitSubjects.js",
|
||||
"src/cockpitRadar.js",
|
||||
@@ -5459,6 +5466,7 @@
|
||||
"src/layers/wildlifeSightings/iconCollection.js",
|
||||
"src/layers/wildlifeSightings/view.js",
|
||||
"src/ui/quebecCctvOverlay.js",
|
||||
"src/ui/views/panels/QuebecCctvOverlay.vue",
|
||||
"src/time/viewerClock.js",
|
||||
"src/time/worldClock.js",
|
||||
"src/cockpitSubjects.js",
|
||||
@@ -5488,6 +5496,8 @@
|
||||
"src/render/cesium/viewers.js",
|
||||
"src/ui/creditLineHeight.js",
|
||||
"src/ui/creditsView.js",
|
||||
"src/ui/credits/CreditsView.vue",
|
||||
"src/ui/credits/CreditItem.vue",
|
||||
"src/data/planespottersPhoto.js",
|
||||
"src/maps/keylessTerrain.js",
|
||||
"src/render/cesium/vectorBase.js",
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import {
|
||||
LINK_SCHEMES,
|
||||
LOGO_SCHEMES,
|
||||
safeUrl,
|
||||
splitLink,
|
||||
} from '../../render/creditMarkup.js';
|
||||
|
||||
// One credit: its logo or its text, linked when it has a link. A credit is
|
||||
// plain data (`src/render/contract/credits.d.ts`): its text is set as text,
|
||||
// and a link or logo is kept only for a safe scheme.
|
||||
const props = defineProps({
|
||||
credit: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const href = computed(() =>
|
||||
props.credit.href ? safeUrl(props.credit.href, LINK_SCHEMES) : null,
|
||||
);
|
||||
// A logo is drawn in place of the text, which names it (its alt text).
|
||||
const logo = computed(() =>
|
||||
props.credit.logoUrl ? safeUrl(props.credit.logoUrl, LOGO_SCHEMES) : null,
|
||||
);
|
||||
// Only the credit's linked words are the link, as the source wrote it.
|
||||
const parts = computed(() =>
|
||||
href.value && !logo.value && props.credit.linkText
|
||||
? splitLink(props.credit)
|
||||
: null,
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span v-if="parts" class="gev-credit"
|
||||
>{{ parts[0]
|
||||
}}<a :href="href" target="_blank" rel="noopener noreferrer">{{
|
||||
parts[1]
|
||||
}}</a
|
||||
>{{ parts[2] }}</span
|
||||
><component
|
||||
:is="href ? 'a' : 'span'"
|
||||
v-else
|
||||
class="gev-credit"
|
||||
:href="href || undefined"
|
||||
:target="href ? '_blank' : undefined"
|
||||
:rel="href ? 'noopener noreferrer' : undefined"
|
||||
><img
|
||||
v-if="logo"
|
||||
class="gev-credit-logo"
|
||||
:src="logo"
|
||||
:alt="credit.text"
|
||||
/><template v-else>{{ credit.text }}</template></component
|
||||
>
|
||||
</template>
|
||||
@@ -0,0 +1,82 @@
|
||||
<script setup>
|
||||
import { t } from '../../i18n/index.js';
|
||||
import UiCloseButton from '../kit/UiCloseButton.vue';
|
||||
import CreditItem from './CreditItem.vue';
|
||||
|
||||
// The attribution line at the bottom left and the "Data attribution" list it
|
||||
// opens, both at the end of `to` (the page's body), where the page's rules
|
||||
// place them. The owner (src/ui/creditsView.js) computes the credits shown,
|
||||
// keeps the list's open state and its focus, and takes the clicks and keys;
|
||||
// `elements` receives the line's, the button's and the list's elements for
|
||||
// it.
|
||||
const props = defineProps({
|
||||
to: { type: Object, required: true },
|
||||
panelId: { type: String, required: true },
|
||||
/** The credits on the line, once each. */
|
||||
inline: { type: Array, required: true },
|
||||
/** The credits in the list, once each. */
|
||||
listed: { type: Array, required: true },
|
||||
open: { type: Boolean, default: false },
|
||||
/**
|
||||
* The locale its words are in: a change words them again. The template
|
||||
* never reads it; `t()` is not reactive, so a new value is what makes the
|
||||
* view render again in the new language.
|
||||
*/
|
||||
locale: { type: String, default: '' },
|
||||
elements: { type: Object, required: true },
|
||||
onExpand: { type: Function, default: () => {} },
|
||||
onClose: { type: Function, default: () => {} },
|
||||
onKeydown: { type: Function, default: () => {} },
|
||||
});
|
||||
|
||||
/** Between the line's credits, and before the list's button. */
|
||||
const SEPARATOR = ' · ';
|
||||
/** A credit's key: the same text and link are one credit. */
|
||||
const key = (credit) => `${credit.text}\u0000${credit.href ?? ''}`;
|
||||
/** Keep `name`'s element for the owner. */
|
||||
const keep = (name) => (element) => {
|
||||
props.elements[name] = element?.$el ?? element;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport :to="props.to"
|
||||
><div id="gev-credits" :ref="keep('bar')" class="gev-credits" tabindex="-1"
|
||||
><span :ref="keep('line')" class="gev-credits-line"
|
||||
><template v-for="(credit, i) in props.inline" :key="key(credit)"
|
||||
>{{ i ? SEPARATOR : '' }}<CreditItem :credit="credit" /></template
|
||||
>{{ props.inline.length && props.listed.length ? SEPARATOR : '' }}</span
|
||||
><button
|
||||
:ref="keep('expand')"
|
||||
type="button"
|
||||
class="gev-credits-expand"
|
||||
aria-haspopup="dialog"
|
||||
:aria-controls="props.panelId"
|
||||
:aria-expanded="String(props.open)"
|
||||
:hidden="props.listed.length === 0"
|
||||
@click="props.onExpand()"
|
||||
>{{ t('Data attribution') }}</button
|
||||
></div
|
||||
><div
|
||||
:id="props.panelId"
|
||||
:ref="keep('panel')"
|
||||
class="gev-credits-panel"
|
||||
role="dialog"
|
||||
:aria-labelledby="`${props.panelId}-title`"
|
||||
:hidden="!props.open"
|
||||
@keydown="props.onKeydown($event)"
|
||||
><div class="gev-credits-header"
|
||||
><span class="gev-credits-title" :id="`${props.panelId}-title`">{{
|
||||
t('Data provided by:')
|
||||
}}</span
|
||||
><UiCloseButton
|
||||
:ref="keep('close')"
|
||||
class="gev-credits-close"
|
||||
bare
|
||||
:label="t('Close data attribution')"
|
||||
@click="props.onClose()" /></div
|
||||
><ul class="gev-credits-list"
|
||||
><li v-for="credit in props.listed" :key="key(credit)"
|
||||
><CreditItem :credit="credit" /></li></ul></div
|
||||
></Teleport>
|
||||
</template>
|
||||
+55
-122
@@ -6,16 +6,14 @@
|
||||
* credits). Inline credits are shown on the line at the bottom left; the
|
||||
* rest are in the "Data attribution" list it opens. A credit is plain data
|
||||
* (`src/render/contract/credits.d.ts`): its text is set as text, and a link
|
||||
* or logo is kept only for a safe scheme.
|
||||
* or logo is kept only for a safe scheme. `CreditsView` renders the line and
|
||||
* the list; this owner keeps the credits shown, the list's open state and
|
||||
* its focus.
|
||||
*/
|
||||
import { h, render as renderVue } from 'vue';
|
||||
import { findCredits } from '../render/rendererOf.js';
|
||||
import {
|
||||
LINK_SCHEMES,
|
||||
LOGO_SCHEMES,
|
||||
safeUrl,
|
||||
splitLink,
|
||||
} from '../render/creditMarkup.js';
|
||||
import { onLocaleChange, t } from '../i18n/index.js';
|
||||
import { getLocale, onLocaleChange } from '../i18n/index.js';
|
||||
import CreditsView from './credits/CreditsView.vue';
|
||||
|
||||
const PANEL_ID = 'gev-credits-panel';
|
||||
|
||||
@@ -30,42 +28,6 @@ function distinct(list) {
|
||||
});
|
||||
}
|
||||
|
||||
/** One credit as DOM: its logo or its text, linked when it has a link. */
|
||||
function creditElement(doc, credit) {
|
||||
const href = credit.href ? safeUrl(credit.href, LINK_SCHEMES) : null;
|
||||
const logoUrl = credit.logoUrl ? safeUrl(credit.logoUrl, LOGO_SCHEMES) : null;
|
||||
// Only the credit's linked words are the link, as the source wrote it.
|
||||
if (href && !logoUrl && credit.linkText) {
|
||||
const [before, words, after] = splitLink(credit);
|
||||
const element = doc.createElement('span');
|
||||
element.className = 'gev-credit';
|
||||
const link = doc.createElement('a');
|
||||
link.href = href;
|
||||
link.target = '_blank';
|
||||
link.rel = 'noopener noreferrer';
|
||||
link.textContent = words;
|
||||
element.append(before, link, after);
|
||||
return element;
|
||||
}
|
||||
const element = doc.createElement(href ? 'a' : 'span');
|
||||
element.className = 'gev-credit';
|
||||
if (href) {
|
||||
element.href = href;
|
||||
element.target = '_blank';
|
||||
element.rel = 'noopener noreferrer';
|
||||
}
|
||||
// A logo is drawn in place of the text, which names it (its alt text).
|
||||
const logo = credit.logoUrl ? safeUrl(credit.logoUrl, LOGO_SCHEMES) : null;
|
||||
if (logo) {
|
||||
const image = doc.createElement('img');
|
||||
image.className = 'gev-credit-logo';
|
||||
image.src = logo;
|
||||
image.alt = credit.text;
|
||||
element.append(image);
|
||||
} else element.textContent = credit.text;
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show `viewer`'s renderer credits at the bottom left of `root`'s page.
|
||||
* @param {object} viewer The scene object, bound to its renderer.
|
||||
@@ -76,106 +38,77 @@ export function mountCreditsView(viewer, { root = document.body } = {}) {
|
||||
const credits = findCredits(viewer);
|
||||
if (!credits || !root) return () => {};
|
||||
const doc = root.ownerDocument;
|
||||
const bar = doc.createElement('div');
|
||||
bar.id = 'gev-credits';
|
||||
bar.className = 'gev-credits';
|
||||
// Takes focus back from an emptied list when the line has no link.
|
||||
bar.tabIndex = -1;
|
||||
const line = doc.createElement('span');
|
||||
line.className = 'gev-credits-line';
|
||||
const expand = doc.createElement('button');
|
||||
expand.type = 'button';
|
||||
expand.className = 'gev-credits-expand';
|
||||
expand.setAttribute('aria-haspopup', 'dialog');
|
||||
expand.setAttribute('aria-controls', PANEL_ID);
|
||||
expand.setAttribute('aria-expanded', 'false');
|
||||
// The view teleports the line and the list to the end of `root`; this
|
||||
// host, never in the page, holds only its place.
|
||||
const host = doc.createElement('div');
|
||||
const elements = {};
|
||||
let inline = [];
|
||||
let listed = [];
|
||||
let open = false;
|
||||
|
||||
const panel = doc.createElement('div');
|
||||
panel.id = PANEL_ID;
|
||||
panel.className = 'gev-credits-panel';
|
||||
panel.setAttribute('role', 'dialog');
|
||||
panel.hidden = true;
|
||||
const header = doc.createElement('div');
|
||||
header.className = 'gev-credits-header';
|
||||
const title = doc.createElement('span');
|
||||
title.className = 'gev-credits-title';
|
||||
title.id = `${PANEL_ID}-title`;
|
||||
panel.setAttribute('aria-labelledby', title.id);
|
||||
const close = doc.createElement('button');
|
||||
close.type = 'button';
|
||||
close.className = 'gev-credits-close';
|
||||
close.textContent = '×';
|
||||
header.append(title, close);
|
||||
const list = doc.createElement('ul');
|
||||
list.className = 'gev-credits-list';
|
||||
panel.append(header, list);
|
||||
bar.append(line, expand);
|
||||
root.append(bar, panel);
|
||||
// The view patches synchronously, so focus can move once it returns.
|
||||
const paint = () =>
|
||||
renderVue(
|
||||
h(CreditsView, {
|
||||
to: root,
|
||||
panelId: PANEL_ID,
|
||||
inline,
|
||||
listed,
|
||||
open,
|
||||
locale: getLocale(),
|
||||
elements,
|
||||
onExpand,
|
||||
onClose,
|
||||
onKeydown,
|
||||
}),
|
||||
host,
|
||||
);
|
||||
|
||||
const label = () => {
|
||||
expand.textContent = t('Data attribution');
|
||||
title.textContent = t('Data provided by:');
|
||||
close.setAttribute('aria-label', t('Close data attribution'));
|
||||
};
|
||||
|
||||
const setOpen = (open, { focus = false } = {}) => {
|
||||
panel.hidden = !open;
|
||||
expand.setAttribute('aria-expanded', String(open));
|
||||
if (open) close.focus();
|
||||
else if (focus) expand.focus();
|
||||
const setOpen = (next, { focus = false } = {}) => {
|
||||
open = next;
|
||||
paint();
|
||||
if (open) elements.close.focus();
|
||||
else if (focus) elements.expand.focus();
|
||||
};
|
||||
|
||||
const render = (all) => {
|
||||
const { bar, line, panel } = elements;
|
||||
const focused = panel.contains(doc.activeElement);
|
||||
const shown = distinct(Array.isArray(all) ? all : []);
|
||||
const inline = shown.filter((credit) => credit.inline);
|
||||
const listed = shown.filter((credit) => !credit.inline);
|
||||
line.replaceChildren();
|
||||
inline.forEach((credit, i) => {
|
||||
if (i) line.append(doc.createTextNode(' · '));
|
||||
line.append(creditElement(doc, credit));
|
||||
});
|
||||
if (inline.length && listed.length) line.append(doc.createTextNode(' · '));
|
||||
list.replaceChildren(
|
||||
...listed.map((credit) => {
|
||||
const item = doc.createElement('li');
|
||||
item.append(creditElement(doc, credit));
|
||||
return item;
|
||||
}),
|
||||
);
|
||||
expand.hidden = listed.length === 0;
|
||||
if (expand.hidden && !panel.hidden) {
|
||||
inline = shown.filter((credit) => credit.inline);
|
||||
listed = shown.filter((credit) => !credit.inline);
|
||||
paint();
|
||||
if (listed.length === 0 && open) {
|
||||
// Focus in the list goes back to the line, not to the page.
|
||||
setOpen(false);
|
||||
if (focused) (line.querySelector('a') ?? bar).focus();
|
||||
} else if (focused && !panel.contains(doc.activeElement)) {
|
||||
// A link that focus was on was redrawn: focus stays in the list.
|
||||
close.focus();
|
||||
elements.close.focus();
|
||||
}
|
||||
};
|
||||
|
||||
const onExpand = () => setOpen(panel.hidden);
|
||||
const onClose = () => setOpen(false, { focus: true });
|
||||
function onExpand() {
|
||||
setOpen(!open);
|
||||
}
|
||||
function onClose() {
|
||||
setOpen(false, { focus: true });
|
||||
}
|
||||
// Escape in the open list closes it (it takes focus as it opens).
|
||||
const onKey = (event) => {
|
||||
if (event.key !== 'Escape' || panel.hidden) return;
|
||||
function onKeydown(event) {
|
||||
if (event.key !== 'Escape' || !open) return;
|
||||
event.preventDefault();
|
||||
setOpen(false, { focus: true });
|
||||
};
|
||||
expand.addEventListener('click', onExpand);
|
||||
close.addEventListener('click', onClose);
|
||||
panel.addEventListener('keydown', onKey);
|
||||
label();
|
||||
}
|
||||
|
||||
paint();
|
||||
render(credits.list());
|
||||
const offChange = credits.on('change', render);
|
||||
const offLocale = onLocaleChange(label);
|
||||
// The view words its text again in the new locale, as it renders.
|
||||
const offLocale = onLocaleChange(paint);
|
||||
return () => {
|
||||
offChange();
|
||||
offLocale();
|
||||
expand.removeEventListener('click', onExpand);
|
||||
close.removeEventListener('click', onClose);
|
||||
panel.removeEventListener('keydown', onKey);
|
||||
bar.remove();
|
||||
panel.remove();
|
||||
renderVue(null, host);
|
||||
};
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import assert from 'node:assert/strict';
|
||||
import { mountCreditsView } from './creditsView.js';
|
||||
import { bindRenderer } from '../render/rendererOf.js';
|
||||
import { createStubRenderer } from '../render/stub/index.js';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
|
||||
function scene() {
|
||||
document.body.replaceChildren();
|
||||
@@ -118,10 +119,12 @@ test('focus in the list stays in it as it redraws, and goes to the line as it em
|
||||
const off = mountCreditsView(viewer);
|
||||
const panel = document.getElementById('gev-credits-panel');
|
||||
document.querySelector('.gev-credits-expand').click();
|
||||
panel.querySelector('li a').focus();
|
||||
const link = panel.querySelector('li a');
|
||||
link.focus();
|
||||
const removeOther = renderer.credits.addStatic({ text: 'NOAA' });
|
||||
assert.equal(panel.hidden, false);
|
||||
assert.ok(panel.contains(document.activeElement), 'still in the list');
|
||||
assert.equal(document.activeElement, link, 'the focused link keeps it');
|
||||
remove();
|
||||
removeOther();
|
||||
assert.equal(panel.hidden, true);
|
||||
@@ -152,3 +155,55 @@ test('a credit with linked words links only those words', () => {
|
||||
);
|
||||
off();
|
||||
});
|
||||
|
||||
test('the line and its list follow the locale', () => {
|
||||
const { viewer, renderer } = scene();
|
||||
renderer.credits.addStatic({ text: 'NOAA' });
|
||||
const off = mountCreditsView(viewer);
|
||||
const expand = document.querySelector('.gev-credits-expand');
|
||||
const close = document.querySelector('.gev-credits-close');
|
||||
try {
|
||||
setLocale('fr');
|
||||
assert.equal(expand.textContent, 'Attribution des données');
|
||||
assert.equal(
|
||||
document.getElementById('gev-credits-panel-title').textContent,
|
||||
'Données fournies par\u202f:',
|
||||
);
|
||||
assert.equal(
|
||||
close.getAttribute('aria-label'),
|
||||
"Fermer l'attribution des données",
|
||||
);
|
||||
} finally {
|
||||
setLocale('en');
|
||||
}
|
||||
assert.equal(expand.textContent, 'Data attribution');
|
||||
off();
|
||||
});
|
||||
|
||||
test('the line and its list are the last of the body, and its close button is the kit’s', () => {
|
||||
const { viewer, renderer } = scene();
|
||||
document.body.append(document.createElement('main'));
|
||||
renderer.credits.addStatic({ text: 'NOAA' });
|
||||
const off = mountCreditsView(viewer);
|
||||
const children = [...document.body.children];
|
||||
assert.deepEqual(
|
||||
children.slice(-2).map((element) => element.id),
|
||||
['gev-credits', 'gev-credits-panel'],
|
||||
'the page’s rules select them as children of the body',
|
||||
);
|
||||
const close = document.querySelector('.gev-credits-close');
|
||||
assert.ok(close.classList.contains('ui-button'), 'a UiCloseButton');
|
||||
assert.equal(close.type, 'button');
|
||||
assert.equal(close.textContent, '×');
|
||||
assert.equal(close.hasAttribute('title'), false, 'no tip');
|
||||
assert.equal(
|
||||
close.classList.contains('ui-close-button'),
|
||||
false,
|
||||
'bare: it keeps the browser’s padding',
|
||||
);
|
||||
off();
|
||||
assert.deepEqual(
|
||||
[...document.body.children].map((element) => element.tagName),
|
||||
['MAIN'],
|
||||
);
|
||||
});
|
||||
+80
-73
@@ -13,9 +13,11 @@
|
||||
// features (styles, HUD, compass, tilt, globe view, share, clear) have their
|
||||
// own. The walk works the same for all of them.
|
||||
|
||||
import { h, render as renderVue } from 'vue';
|
||||
import { t } from '../i18n/index.js';
|
||||
import { EXCLUSIVE_SURFACE_CLASSES } from '../exclusiveSurfaces.js';
|
||||
import { LABEL_LAYERS } from './contextLayerTabs.js';
|
||||
import OmnibarGuide from './views/panels/OmnibarGuide.vue';
|
||||
|
||||
const LEFT_RAIL = '.ui-rail--left .ui-rail__item';
|
||||
const RIGHT_RAIL = '.ui-rail--right .ui-rail__item';
|
||||
@@ -445,43 +447,71 @@ export function startGuide(steps, { title = '' } = {}) {
|
||||
active?.stop();
|
||||
const doc = globalThis.document;
|
||||
if (!doc?.body || screenIsOwned(doc) || !steps?.length) return;
|
||||
const root = doc.createElement('div');
|
||||
root.className = 'gev-guide';
|
||||
root.innerHTML =
|
||||
'<div class="gev-guide-ring"><i></i></div>' +
|
||||
'<div class="gev-guide-callout" role="dialog" aria-modal="false" tabindex="-1" aria-labelledby="gev-guide-title" aria-describedby="gev-guide-text">' +
|
||||
'<div class="gev-guide-head"><p id="gev-guide-title" class="gev-guide-title"></p>' +
|
||||
'<p class="gev-guide-count"></p>' +
|
||||
'<button type="button" class="gev-guide-close"><span aria-hidden="true">×</span></button></div>' +
|
||||
'<ol class="gev-guide-progress" aria-hidden="true"></ol>' +
|
||||
'<div class="gev-guide-body"><p id="gev-guide-text" class="gev-guide-text"></p>' +
|
||||
'<p class="gev-guide-hint"><span class="gev-guide-hint-dot"></span><span></span></p></div>' +
|
||||
'<div class="gev-guide-actions"><p class="gev-guide-keys"><kbd></kbd><span></span></p>' +
|
||||
'<span><button type="button" class="gev-guide-skip" hidden></button>' +
|
||||
'<button type="button" class="gev-guide-offer" hidden></button>' +
|
||||
'<button type="button" class="gev-guide-next"></button></span></div>' +
|
||||
// What the view renders: the owner writes it for each step, then paints.
|
||||
// The view never binds what is set on the elements: the guide's `visible`
|
||||
// class, the callout's entrance replay, place and side, and the rings'
|
||||
// boxes, set per frame.
|
||||
const endLabel = t('End guide');
|
||||
const view = {
|
||||
title: title ? t('Guide · {topic}', { topic: title }) : t('Guide'),
|
||||
endLabel,
|
||||
count: '',
|
||||
step: 0,
|
||||
progress: [],
|
||||
text: '',
|
||||
hint: t('Press the highlighted control'),
|
||||
hintHidden: false,
|
||||
// i18n-ignore: the Escape keycap, matching the keyboard shortcut.
|
||||
keyCap: 'Esc',
|
||||
keyText: t('to end'),
|
||||
keysHidden: false,
|
||||
skipLabel: '',
|
||||
skipHidden: true,
|
||||
offerLabel: '',
|
||||
offerHidden: true,
|
||||
nextLabel: t('Next'),
|
||||
nextHidden: false,
|
||||
nextQuiet: false,
|
||||
// Announces each step once; the dialog itself is not a live region, so
|
||||
// its buttons and progress are not read out on every change.
|
||||
'<p class="gev-guide-status" role="status" aria-live="polite"></p></div>';
|
||||
status: '',
|
||||
};
|
||||
const host = doc.createElement('div');
|
||||
const handlers = {
|
||||
onClose: () => stop(),
|
||||
onSkip: () => stop(),
|
||||
// Taking the offer carries the walk on with its steps.
|
||||
onOffer() {
|
||||
if (!current?.offer) return;
|
||||
const extra = current.offer.steps() || [];
|
||||
live.splice(index + 1, live.length, ...extra.filter(Boolean));
|
||||
next();
|
||||
},
|
||||
onNext() {
|
||||
if (current) next();
|
||||
},
|
||||
};
|
||||
let mounted = true;
|
||||
/** Render the view now: the guide goes to the end of the body. */
|
||||
function paint() {
|
||||
if (!mounted) return null;
|
||||
const vnode = h(OmnibarGuide, {
|
||||
to: doc.body,
|
||||
view: { ...view },
|
||||
...handlers,
|
||||
});
|
||||
renderVue(vnode, host);
|
||||
return vnode;
|
||||
}
|
||||
// Focus returns where it was when the walk ends, if that is still there.
|
||||
const returnFocus = doc.activeElement;
|
||||
doc.body.append(root);
|
||||
const ring = root.querySelector('.gev-guide-ring');
|
||||
const callout = root.querySelector('.gev-guide-callout');
|
||||
// The elements come from the rendered tree, which is in place as soon as the
|
||||
// render returns; template refs are filled after it, and later still when
|
||||
// the walk starts inside one of Vue's own post-render updates.
|
||||
const root = paint().component.subTree.children[0].el;
|
||||
const ring = root.querySelector(':scope > .gev-guide-ring');
|
||||
const callout = root.querySelector(':scope > .gev-guide-callout');
|
||||
const subRings = [];
|
||||
const endLabel = t('End guide');
|
||||
root.querySelector('.gev-guide-close').setAttribute('aria-label', endLabel);
|
||||
root.querySelector('.gev-guide-close').title = endLabel;
|
||||
// i18n-ignore: the Escape keycap, matching the keyboard shortcut.
|
||||
root.querySelector('.gev-guide-keys kbd').textContent = 'Esc';
|
||||
root.querySelector('.gev-guide-keys span').textContent = t('to end');
|
||||
root.querySelector('.gev-guide-title').textContent = title
|
||||
? t('Guide · {topic}', { topic: title })
|
||||
: t('Guide');
|
||||
root.querySelector('.gev-guide-next').textContent = t('Next');
|
||||
root.querySelector('.gev-guide-hint span:last-child').textContent = t(
|
||||
'Press the highlighted control',
|
||||
);
|
||||
|
||||
const live = steps.filter(Boolean);
|
||||
let index = -1;
|
||||
@@ -503,7 +533,8 @@ export function startGuide(steps, { title = '' } = {}) {
|
||||
doc.removeEventListener('click', onClick, true);
|
||||
doc.removeEventListener('keydown', onKey, true);
|
||||
const hadFocus = root.contains(doc.activeElement);
|
||||
root.remove();
|
||||
mounted = false;
|
||||
renderVue(null, host);
|
||||
if (hadFocus && returnFocus?.isConnected) returnFocus.focus?.();
|
||||
if (active?.stop === stop) active = null;
|
||||
};
|
||||
@@ -534,41 +565,29 @@ export function startGuide(steps, { title = '' } = {}) {
|
||||
// would not be skipped as things stand.
|
||||
const total =
|
||||
shown + live.slice(index + 1).filter((later) => !later.skip?.()).length;
|
||||
root.querySelector('.gev-guide-count').textContent = `${shown} / ${total}`;
|
||||
const progress = root.querySelector('.gev-guide-progress');
|
||||
progress.replaceChildren(
|
||||
...Array.from({ length: total }, (_, i) => {
|
||||
const dot = doc.createElement('li');
|
||||
if (i < shown - 1) dot.className = 'done';
|
||||
if (i === shown - 1) dot.className = 'current';
|
||||
return dot;
|
||||
}),
|
||||
view.count = `${shown} / ${total}`;
|
||||
view.step = shown;
|
||||
view.progress = Array.from({ length: total }, (_, i) =>
|
||||
i < shown - 1 ? 'done' : i === shown - 1 ? 'current' : null,
|
||||
);
|
||||
const text = step.text();
|
||||
root.querySelector('.gev-guide-text').textContent = text;
|
||||
root.querySelector('.gev-guide-status').textContent =
|
||||
`${shown} / ${total}: ${text}`;
|
||||
view.text = text;
|
||||
view.status = `${shown} / ${total}: ${text}`;
|
||||
// Steps that point at a control wait for it to be pressed; say so.
|
||||
const waits = Boolean(step.targets) && !step.offer;
|
||||
root.querySelector('.gev-guide-hint').hidden = !waits;
|
||||
const offer = root.querySelector('.gev-guide-offer');
|
||||
const skip = root.querySelector('.gev-guide-skip');
|
||||
offer.hidden = !step.offer;
|
||||
skip.hidden = !step.offer;
|
||||
root.querySelector('.gev-guide-keys').hidden = Boolean(step.offer);
|
||||
view.hintHidden = !waits;
|
||||
view.offerHidden = !step.offer;
|
||||
view.skipHidden = !step.offer;
|
||||
view.keysHidden = Boolean(step.offer);
|
||||
if (step.offer) {
|
||||
offer.textContent = step.offer.label();
|
||||
skip.textContent = t('Not now');
|
||||
view.offerLabel = step.offer.label();
|
||||
view.skipLabel = t('Not now');
|
||||
}
|
||||
const last = index === live.length - 1;
|
||||
const nextButton = root.querySelector('.gev-guide-next');
|
||||
nextButton.hidden = Boolean(step.offer);
|
||||
nextButton.textContent = last
|
||||
? t('Finish')
|
||||
: waits
|
||||
? t('Skip step')
|
||||
: t('Next');
|
||||
nextButton.classList.toggle('quiet', waits && !last);
|
||||
view.nextHidden = Boolean(step.offer);
|
||||
view.nextLabel = last ? t('Finish') : waits ? t('Skip step') : t('Next');
|
||||
view.nextQuiet = waits && !last;
|
||||
paint();
|
||||
// Replay the entrance so each step reads as new.
|
||||
callout.classList.remove('swap');
|
||||
void callout.offsetWidth;
|
||||
@@ -597,18 +616,6 @@ export function startGuide(steps, { title = '' } = {}) {
|
||||
event.stopPropagation();
|
||||
stop();
|
||||
}
|
||||
root.querySelector('.gev-guide-skip').addEventListener('click', stop);
|
||||
root.querySelector('.gev-guide-close').addEventListener('click', stop);
|
||||
root.querySelector('.gev-guide-next').addEventListener('click', () => {
|
||||
if (current) next();
|
||||
});
|
||||
// Taking the offer carries the walk on with its steps.
|
||||
root.querySelector('.gev-guide-offer').addEventListener('click', () => {
|
||||
if (!current?.offer) return;
|
||||
const extra = current.offer.steps() || [];
|
||||
live.splice(index + 1, live.length, ...extra.filter(Boolean));
|
||||
next();
|
||||
});
|
||||
doc.addEventListener('click', onClick, true);
|
||||
doc.addEventListener('keydown', onKey, true);
|
||||
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
// The guided walk's callout, rendered by startGuide() over happy-dom.
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createApp, h, onMounted } from 'vue';
|
||||
import { startGuide } from './omnibarGuide.js';
|
||||
|
||||
const settle = () => new Promise((resolve) => setTimeout(resolve, 0));
|
||||
const $ = (selector) => document.querySelector(selector);
|
||||
|
||||
function fixture(t) {
|
||||
document.body.replaceChildren();
|
||||
const target = document.body.appendChild(document.createElement('button'));
|
||||
const field = document.body.appendChild(document.createElement('input'));
|
||||
field.focus();
|
||||
t.after(() => $('.gev-guide-close')?.click());
|
||||
return { target, field };
|
||||
}
|
||||
|
||||
test('the walk is the last of the body, takes focus and gives it back', async (t) => {
|
||||
const { target, field } = fixture(t);
|
||||
startGuide([{ targets: () => [target], text: () => 'Press it' }], {
|
||||
title: 'Flights',
|
||||
});
|
||||
await settle();
|
||||
const guide = $('.gev-guide');
|
||||
assert.equal(document.body.lastElementChild, guide);
|
||||
assert.equal(guide.parentElement, document.body);
|
||||
assert.ok(guide.classList.contains('visible'));
|
||||
const callout = $('.gev-guide-callout');
|
||||
assert.equal(document.activeElement, callout);
|
||||
assert.equal(callout.getAttribute('role'), 'dialog');
|
||||
assert.equal(callout.getAttribute('aria-modal'), 'false');
|
||||
assert.equal(callout.getAttribute('tabindex'), '-1');
|
||||
assert.equal($('.gev-guide-title').textContent, 'Guide · Flights');
|
||||
const close = $('.gev-guide-close');
|
||||
assert.equal(close.getAttribute('type'), 'button');
|
||||
assert.equal(close.getAttribute('aria-label'), 'End guide');
|
||||
assert.equal(close.getAttribute('title'), 'End guide');
|
||||
assert.ok(close.classList.contains('ui-close-button'));
|
||||
close.focus();
|
||||
close.click();
|
||||
assert.equal($('.gev-guide'), null);
|
||||
assert.equal(document.activeElement, field);
|
||||
});
|
||||
|
||||
test('the status line says each step once, and each step draws new progress', async (t) => {
|
||||
const { target } = fixture(t);
|
||||
startGuide([
|
||||
{ targets: () => [target], text: () => 'Press it' },
|
||||
{ text: () => 'Then this' },
|
||||
{
|
||||
text: () => 'More?',
|
||||
offer: { label: () => 'Show more', steps: () => [] },
|
||||
},
|
||||
]);
|
||||
const status = $('.gev-guide-status');
|
||||
const said = [];
|
||||
// One change per step: its text replaced once, never cleared first.
|
||||
const observer = new MutationObserver(() => said.push(status.textContent));
|
||||
observer.observe(status, {
|
||||
childList: true,
|
||||
characterData: true,
|
||||
subtree: true,
|
||||
});
|
||||
t.after(() => observer.disconnect());
|
||||
await settle();
|
||||
const firstDots = [...document.querySelectorAll('.gev-guide-progress li')];
|
||||
assert.deepEqual(
|
||||
firstDots.map((dot) => dot.getAttribute('class')),
|
||||
['current', null, null],
|
||||
);
|
||||
const next = $('.gev-guide-next');
|
||||
assert.equal(next.textContent, 'Skip step');
|
||||
assert.ok(next.classList.contains('quiet'));
|
||||
assert.equal($('.gev-guide-hint').hidden, false);
|
||||
next.click();
|
||||
await settle();
|
||||
const secondDots = [...document.querySelectorAll('.gev-guide-progress li')];
|
||||
assert.deepEqual(
|
||||
secondDots.map((dot) => dot.getAttribute('class')),
|
||||
['done', 'current', null],
|
||||
);
|
||||
assert.ok(secondDots.every((dot) => !firstDots.includes(dot)));
|
||||
assert.equal(next.textContent, 'Next');
|
||||
assert.equal(next.classList.contains('quiet'), false);
|
||||
assert.equal($('.gev-guide-hint').hidden, true);
|
||||
next.click();
|
||||
await settle();
|
||||
// The closing offer: its two buttons, no Esc hint and no Next.
|
||||
assert.equal($('.gev-guide-keys').hidden, true);
|
||||
assert.equal(next.hidden, true);
|
||||
assert.equal($('.gev-guide-skip').hidden, false);
|
||||
assert.equal($('.gev-guide-skip').textContent, 'Not now');
|
||||
assert.equal($('.gev-guide-offer').textContent, 'Show more');
|
||||
assert.deepEqual(said, [
|
||||
'1 / 3: Press it',
|
||||
'2 / 3: Then this',
|
||||
'3 / 3: More?',
|
||||
]);
|
||||
$('.gev-guide-skip').click();
|
||||
assert.equal($('.gev-guide'), null);
|
||||
});
|
||||
|
||||
test('starting another walk ends the one in progress', async (t) => {
|
||||
fixture(t);
|
||||
startGuide([{ text: () => 'First' }]);
|
||||
startGuide([{ text: () => 'Second' }]);
|
||||
await settle();
|
||||
assert.equal(document.querySelectorAll('.gev-guide').length, 1);
|
||||
assert.equal($('.gev-guide-text').textContent, 'Second');
|
||||
});
|
||||
|
||||
test('a walk started while Vue mounts something else still starts and ends', async (t) => {
|
||||
const { target, field } = fixture(t);
|
||||
let stop = null;
|
||||
const app = createApp({
|
||||
setup() {
|
||||
onMounted(() => {
|
||||
stop = startGuide([
|
||||
{ targets: () => [target], text: () => 'Press it' },
|
||||
]);
|
||||
});
|
||||
return () => h('span');
|
||||
},
|
||||
});
|
||||
app.mount(document.body.appendChild(document.createElement('div')));
|
||||
t.after(() => app.unmount());
|
||||
await settle();
|
||||
assert.equal(typeof stop, 'function');
|
||||
assert.equal(document.activeElement, $('.gev-guide-callout'));
|
||||
assert.ok($('.gev-guide').classList.contains('visible'));
|
||||
stop();
|
||||
assert.equal($('.gev-guide'), null);
|
||||
assert.equal(document.activeElement, field);
|
||||
});
|
||||
+133
-163
@@ -1,3 +1,4 @@
|
||||
import { h, render as renderVue } from 'vue';
|
||||
import { fromDegrees } from '../geo/ellipsoid.js';
|
||||
import { horizonFrom } from '../geo/horizon.js';
|
||||
import { distance } from '../geo/vector.js';
|
||||
@@ -8,6 +9,7 @@ import {
|
||||
findQuery,
|
||||
} from '../render/rendererOf.js';
|
||||
import { t } from '../i18n/index.js';
|
||||
import QuebecCctvOverlay from './views/panels/QuebecCctvOverlay.vue';
|
||||
|
||||
function isQuebecCamera(camera) {
|
||||
return String(camera?.sourceKind || '').startsWith('quebec-');
|
||||
@@ -77,72 +79,77 @@ function mediaRefreshUrl(value) {
|
||||
* Attach the active Québec source to a floating browser player and map
|
||||
* preview. The browser contacts Québec 511 only after the viewer presses Play
|
||||
* for that camera; selecting it (by click, auto-hop, a scene or voice) only
|
||||
* shows its details and the play control.
|
||||
* shows its details and the play control. The panel and marker are the
|
||||
* `QuebecCctvOverlay` view, rendered synchronously on each change.
|
||||
*/
|
||||
export function createQuebecCctvOverlay(viewer) {
|
||||
if (!viewer || typeof document === 'undefined') return null;
|
||||
|
||||
const controller = new AbortController();
|
||||
const { signal } = controller;
|
||||
const panel = document.createElement('section');
|
||||
panel.className = 'qci-panel';
|
||||
panel.hidden = true;
|
||||
panel.setAttribute('role', 'region');
|
||||
panel.setAttribute('aria-label', t('CCTV camera'));
|
||||
|
||||
const header = document.createElement('header');
|
||||
header.className = 'qci-header';
|
||||
const title = document.createElement('strong');
|
||||
const close = document.createElement('button');
|
||||
close.type = 'button';
|
||||
close.textContent = '×';
|
||||
close.setAttribute('aria-label', t('Close camera preview'));
|
||||
header.append(title, close);
|
||||
|
||||
const coordinates = document.createElement('p');
|
||||
coordinates.className = 'qci-coordinates';
|
||||
const credit = document.createElement('p');
|
||||
credit.className = 'qci-credit';
|
||||
const live = document.createElement('video');
|
||||
live.className = 'qci-live';
|
||||
live.controls = true;
|
||||
live.muted = true;
|
||||
live.autoplay = true;
|
||||
live.loop = true;
|
||||
live.playsInline = true;
|
||||
live.setAttribute('aria-label', t('CCTV camera'));
|
||||
|
||||
const actions = document.createElement('div');
|
||||
actions.className = 'qci-actions';
|
||||
const play = document.createElement('button');
|
||||
play.type = 'button';
|
||||
play.className = 'qci-play';
|
||||
play.textContent = t('Play');
|
||||
const refresh = document.createElement('button');
|
||||
refresh.type = 'button';
|
||||
refresh.textContent = t('Refresh map still');
|
||||
actions.append(play, refresh);
|
||||
const note = document.createElement('p');
|
||||
note.className = 'qci-note';
|
||||
const sourceLink = document.createElement('a');
|
||||
sourceLink.target = '_blank';
|
||||
sourceLink.rel = 'noopener noreferrer';
|
||||
sourceLink.textContent = t("Open this image on the provider's site");
|
||||
panel.append(header, coordinates, credit, live, actions, note, sourceLink);
|
||||
|
||||
const marker = document.createElement('div');
|
||||
marker.className = 'qci-marker';
|
||||
marker.hidden = true;
|
||||
const still = document.createElement('video');
|
||||
still.className = 'qci-marker-still';
|
||||
still.muted = true;
|
||||
still.playsInline = true;
|
||||
still.preload = 'none';
|
||||
still.setAttribute('aria-hidden', 'true');
|
||||
const markerLabel = document.createElement('span');
|
||||
markerLabel.className = 'qci-marker-label';
|
||||
marker.append(still, markerLabel);
|
||||
document.body.append(panel, marker);
|
||||
// What the view renders. The owner writes it where it used to write the
|
||||
// elements, then paints; the view never binds the media sources, the
|
||||
// panel's dragged position or the marker's per-frame visibility and place.
|
||||
const view = {
|
||||
panelHidden: true,
|
||||
title: '',
|
||||
coordinates: '',
|
||||
credit: '',
|
||||
creditHidden: false,
|
||||
liveHidden: false,
|
||||
actionsHidden: false,
|
||||
playHidden: false,
|
||||
refreshHidden: false,
|
||||
note: '',
|
||||
noteHidden: false,
|
||||
sourceHref: null,
|
||||
sourceHidden: false,
|
||||
markerLinkOnly: false,
|
||||
stillHidden: false,
|
||||
markerLabel: '',
|
||||
};
|
||||
const host = document.createElement('div');
|
||||
let disposed = false;
|
||||
const handlers = {
|
||||
onClose: closeWindow,
|
||||
onPlay: startPlayback,
|
||||
onRefresh: refreshStill,
|
||||
onKeydown(event) {
|
||||
if (event.key === 'Escape') close.click();
|
||||
},
|
||||
onHeaderPointerdown: startDrag,
|
||||
onLiveError: markLiveUnavailable,
|
||||
onLiveLoadeddata() {
|
||||
liveUnavailable = false;
|
||||
view.note = t(
|
||||
'The map still uses a separate request and may show a different moment.',
|
||||
);
|
||||
view.noteHidden = false;
|
||||
paint();
|
||||
},
|
||||
onStillError: markStillUnavailable,
|
||||
onStillLoadeddata() {
|
||||
stillUnavailable = false;
|
||||
if (selected)
|
||||
view.markerLabel = markerLabelText(selected, Boolean(selectedMediaUrl));
|
||||
paint();
|
||||
still.pause();
|
||||
},
|
||||
};
|
||||
/** Render the view now: the panel and marker go to the end of the body. */
|
||||
function paint() {
|
||||
if (disposed) return null;
|
||||
const vnode = h(QuebecCctvOverlay, { view: { ...view }, ...handlers });
|
||||
renderVue(vnode, host);
|
||||
return vnode.component.exposed;
|
||||
}
|
||||
const elements = paint();
|
||||
const panel = elements.panel.value;
|
||||
const header = elements.header.value;
|
||||
const close = elements.close.value.$el;
|
||||
const live = elements.live.value;
|
||||
const marker = elements.marker.value;
|
||||
const still = elements.still.value;
|
||||
|
||||
let selected = null;
|
||||
let selectedPosition = null;
|
||||
@@ -166,13 +173,15 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
|
||||
function markLiveUnavailable() {
|
||||
liveUnavailable = true;
|
||||
note.textContent = t('Source unavailable');
|
||||
note.hidden = false;
|
||||
view.note = t('Source unavailable');
|
||||
view.noteHidden = false;
|
||||
paint();
|
||||
}
|
||||
|
||||
function markStillUnavailable() {
|
||||
stillUnavailable = true;
|
||||
markerLabel.textContent = t('Source unavailable');
|
||||
view.markerLabel = t('Source unavailable');
|
||||
paint();
|
||||
}
|
||||
|
||||
function startRender() {
|
||||
@@ -218,16 +227,17 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
playingCameraId = selected.id;
|
||||
liveUnavailable = false;
|
||||
stillUnavailable = false;
|
||||
play.hidden = true;
|
||||
refresh.hidden = false;
|
||||
live.hidden = false;
|
||||
still.hidden = false;
|
||||
marker.classList.remove('qci-marker-link-only');
|
||||
note.textContent = t(
|
||||
view.playHidden = true;
|
||||
view.refreshHidden = false;
|
||||
view.liveHidden = false;
|
||||
view.stillHidden = false;
|
||||
view.markerLinkOnly = false;
|
||||
view.note = t(
|
||||
'The map still uses a separate request and may show a different moment.',
|
||||
);
|
||||
note.hidden = false;
|
||||
markerLabel.textContent = markerLabelText(selected, true);
|
||||
view.noteHidden = false;
|
||||
view.markerLabel = markerLabelText(selected, true);
|
||||
paint();
|
||||
setMedia(live, selectedMediaUrl);
|
||||
setMedia(still, selectedMediaUrl);
|
||||
void live.play().catch(onPlayFailure(markLiveUnavailable));
|
||||
@@ -246,7 +256,8 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
stillUnavailable = false;
|
||||
stopMediaRefresh();
|
||||
stopRender();
|
||||
panel.hidden = true;
|
||||
view.panelHidden = true;
|
||||
paint();
|
||||
marker.hidden = true;
|
||||
setMedia(live, '');
|
||||
setMedia(still, '');
|
||||
@@ -263,7 +274,8 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
Number(camera.elevationM) || 10,
|
||||
);
|
||||
if (closedWindowCameraId === camera.id && !reselected) {
|
||||
panel.hidden = true;
|
||||
view.panelHidden = true;
|
||||
paint();
|
||||
updateMarker();
|
||||
return;
|
||||
}
|
||||
@@ -276,8 +288,8 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
playingCameraId = null;
|
||||
}
|
||||
const playing = Boolean(mediaUrl) && playingCameraId === camera.id;
|
||||
title.textContent = camera.name || t('CCTV camera');
|
||||
coordinates.textContent = [
|
||||
view.title = camera.name || t('CCTV camera');
|
||||
view.coordinates = [
|
||||
`${Number(camera.lat).toFixed(5)}, ${Number(camera.lon).toFixed(5)}`,
|
||||
Number.isFinite(camera.accuracyM) && camera.accuracyM > 0
|
||||
? `±${Math.round(camera.accuracyM)} m`
|
||||
@@ -286,14 +298,13 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' · ');
|
||||
credit.textContent = camera.credit || camera.provider || '';
|
||||
credit.hidden = !credit.textContent;
|
||||
live.hidden = !playing;
|
||||
play.hidden = !mediaUrl || playing;
|
||||
refresh.hidden = !playing;
|
||||
actions.hidden = !mediaUrl;
|
||||
note.hidden = !mediaUrl;
|
||||
note.textContent = mediaUrl
|
||||
view.credit = camera.credit || camera.provider || '';
|
||||
view.creditHidden = !view.credit;
|
||||
view.liveHidden = !playing;
|
||||
view.playHidden = !mediaUrl || playing;
|
||||
view.refreshHidden = !playing;
|
||||
view.actionsHidden = !mediaUrl;
|
||||
view.note = mediaUrl
|
||||
? !playing
|
||||
? t('Video plays from Québec 511, which sees your IP address.')
|
||||
: liveUnavailable
|
||||
@@ -304,15 +315,16 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
: sourceUrl
|
||||
? ''
|
||||
: t('Source unavailable');
|
||||
note.hidden = !note.textContent;
|
||||
sourceLink.href = sourceUrl || '#';
|
||||
sourceLink.hidden = !sourceUrl;
|
||||
markerLabel.textContent = stillUnavailable
|
||||
view.noteHidden = !view.note;
|
||||
view.sourceHref = sourceUrl || '#';
|
||||
view.sourceHidden = !sourceUrl;
|
||||
view.markerLabel = stillUnavailable
|
||||
? t('Source unavailable')
|
||||
: markerLabelText(camera, playing);
|
||||
marker.classList.toggle('qci-marker-link-only', !playing);
|
||||
still.hidden = !playing;
|
||||
panel.hidden = false;
|
||||
view.markerLinkOnly = !playing;
|
||||
view.stillHidden = !playing;
|
||||
view.panelHidden = false;
|
||||
paint();
|
||||
|
||||
if (changed || mediaUrl !== selectedMediaUrl) {
|
||||
selectedMediaUrl = mediaUrl;
|
||||
@@ -366,34 +378,6 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
);
|
||||
}
|
||||
|
||||
still.addEventListener(
|
||||
'loadeddata',
|
||||
() => {
|
||||
stillUnavailable = false;
|
||||
if (selected)
|
||||
markerLabel.textContent = markerLabelText(
|
||||
selected,
|
||||
Boolean(selectedMediaUrl),
|
||||
);
|
||||
still.pause();
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
still.addEventListener('error', markStillUnavailable, { signal });
|
||||
live.addEventListener('error', markLiveUnavailable, { signal });
|
||||
live.addEventListener(
|
||||
'loadeddata',
|
||||
() => {
|
||||
liveUnavailable = false;
|
||||
note.textContent = t(
|
||||
'The map still uses a separate request and may show a different moment.',
|
||||
);
|
||||
note.hidden = false;
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
refresh.addEventListener('click', refreshStill, { signal });
|
||||
play.addEventListener('click', startPlayback, { signal });
|
||||
const resetCanvasRect = () => {
|
||||
canvasRect = null;
|
||||
};
|
||||
@@ -403,49 +387,35 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
capture: true,
|
||||
passive: true,
|
||||
});
|
||||
panel.addEventListener(
|
||||
'keydown',
|
||||
(event) => {
|
||||
if (event.key === 'Escape') close.click();
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
close.addEventListener(
|
||||
'click',
|
||||
() => {
|
||||
closedWindowCameraId = selected?.id || null;
|
||||
panel.hidden = true;
|
||||
live.pause();
|
||||
stopMediaRefresh();
|
||||
// The floating player closes independently; keep the paused map still.
|
||||
updateMarker();
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
header.addEventListener(
|
||||
'pointerdown',
|
||||
(event) => {
|
||||
if (event.target.closest('button')) return;
|
||||
const rect = panel.getBoundingClientRect();
|
||||
const offsetX = event.clientX - rect.left;
|
||||
const offsetY = event.clientY - rect.top;
|
||||
header.setPointerCapture(event.pointerId);
|
||||
const move = (moveEvent) => {
|
||||
panel.style.left = `${Math.max(0, Math.min(window.innerWidth - panel.offsetWidth, moveEvent.clientX - offsetX))}px`;
|
||||
panel.style.top = `${Math.max(0, Math.min(window.innerHeight - panel.offsetHeight, moveEvent.clientY - offsetY))}px`;
|
||||
panel.style.right = 'auto';
|
||||
};
|
||||
const stop = () => {
|
||||
header.removeEventListener('pointermove', move);
|
||||
header.removeEventListener('pointerup', stop);
|
||||
header.removeEventListener('pointercancel', stop);
|
||||
};
|
||||
header.addEventListener('pointermove', move, { signal });
|
||||
header.addEventListener('pointerup', stop, { once: true, signal });
|
||||
header.addEventListener('pointercancel', stop, { once: true, signal });
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
function closeWindow() {
|
||||
closedWindowCameraId = selected?.id || null;
|
||||
view.panelHidden = true;
|
||||
paint();
|
||||
live.pause();
|
||||
stopMediaRefresh();
|
||||
// The floating player closes independently; keep the paused map still.
|
||||
updateMarker();
|
||||
}
|
||||
function startDrag(event) {
|
||||
if (event.target.closest('button')) return;
|
||||
const rect = panel.getBoundingClientRect();
|
||||
const offsetX = event.clientX - rect.left;
|
||||
const offsetY = event.clientY - rect.top;
|
||||
header.setPointerCapture(event.pointerId);
|
||||
const move = (moveEvent) => {
|
||||
panel.style.left = `${Math.max(0, Math.min(window.innerWidth - panel.offsetWidth, moveEvent.clientX - offsetX))}px`;
|
||||
panel.style.top = `${Math.max(0, Math.min(window.innerHeight - panel.offsetHeight, moveEvent.clientY - offsetY))}px`;
|
||||
panel.style.right = 'auto';
|
||||
};
|
||||
const stop = () => {
|
||||
header.removeEventListener('pointermove', move);
|
||||
header.removeEventListener('pointerup', stop);
|
||||
header.removeEventListener('pointercancel', stop);
|
||||
};
|
||||
header.addEventListener('pointermove', move, { signal });
|
||||
header.addEventListener('pointerup', stop, { once: true, signal });
|
||||
header.addEventListener('pointercancel', stop, { once: true, signal });
|
||||
}
|
||||
document.addEventListener(
|
||||
'visibilitychange',
|
||||
() => {
|
||||
@@ -469,8 +439,8 @@ export function createQuebecCctvOverlay(viewer) {
|
||||
stopRender();
|
||||
setMedia(live, '');
|
||||
setMedia(still, '');
|
||||
panel.remove();
|
||||
marker.remove();
|
||||
disposed = true;
|
||||
renderVue(null, host);
|
||||
selected = null;
|
||||
selectedPosition = null;
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { Window } from 'happy-dom';
|
||||
import { fromDegrees } from '../geo/ellipsoid.js';
|
||||
import { bindFakeDraw } from '../testSupport/fakeDrawPort.mjs';
|
||||
import { fakeCameraPort } from '../testSupport/fakeCameraPort.mjs';
|
||||
@@ -22,23 +22,36 @@ const CAMERA = Object.freeze({
|
||||
});
|
||||
|
||||
/**
|
||||
* Mount the overlay in a happy-dom window with recorded media loads, timers
|
||||
* and postRender listeners. `play` decides what each play() returns.
|
||||
* Mount the overlay in the registered happy-dom window (Vue binds the
|
||||
* document it loads with) with recorded media loads, timers and postRender
|
||||
* listeners. `play` decides what each play() returns.
|
||||
*/
|
||||
function mountOverlay(t, { play = () => Promise.resolve() } = {}) {
|
||||
const window = new Window({ url: 'http://localhost:4173/' });
|
||||
const previousWindow = globalThis.window;
|
||||
const previousDocument = globalThis.document;
|
||||
globalThis.window = window;
|
||||
globalThis.document = window.document;
|
||||
const { window } = globalThis;
|
||||
const media = window.HTMLMediaElement.prototype;
|
||||
const previous = {
|
||||
load: media.load,
|
||||
play: media.play,
|
||||
pause: media.pause,
|
||||
setInterval: window.setInterval,
|
||||
clearInterval: window.clearInterval,
|
||||
};
|
||||
t.after(() => {
|
||||
media.load = previous.load;
|
||||
media.play = previous.play;
|
||||
media.pause = previous.pause;
|
||||
window.setInterval = previous.setInterval;
|
||||
window.clearInterval = previous.clearInterval;
|
||||
delete window.document.hidden;
|
||||
});
|
||||
const loads = [];
|
||||
window.HTMLMediaElement.prototype.load = function () {
|
||||
media.load = function () {
|
||||
if (this.getAttribute('src')) loads.push(this.getAttribute('src'));
|
||||
};
|
||||
window.HTMLMediaElement.prototype.play = function () {
|
||||
media.play = function () {
|
||||
return play(this);
|
||||
};
|
||||
window.HTMLMediaElement.prototype.pause = function () {};
|
||||
media.pause = function () {};
|
||||
const intervals = new Map();
|
||||
let nextTimer = 1;
|
||||
window.setInterval = (fn) => {
|
||||
@@ -65,12 +78,7 @@ function mountOverlay(t, { play = () => Promise.resolve() } = {}) {
|
||||
});
|
||||
t.after(unbind);
|
||||
const overlay = createQuebecCctvOverlay(viewer);
|
||||
t.after(() => {
|
||||
overlay?.dispose();
|
||||
globalThis.window = previousWindow;
|
||||
globalThis.document = previousDocument;
|
||||
window.close();
|
||||
});
|
||||
t.after(() => overlay?.dispose());
|
||||
const [live, still] = window.document.querySelectorAll('video');
|
||||
return {
|
||||
window,
|
||||
@@ -203,3 +211,21 @@ test('the refresh timer reloads with a cache-buster, skips hidden tabs, and stop
|
||||
assert.equal(ui.renderListeners.size, 0);
|
||||
assert.equal(ui.window.document.querySelector('.qci-panel') === null, true);
|
||||
});
|
||||
|
||||
test('Escape in the window closes it and stops the refresh until the camera is picked again', (t) => {
|
||||
const ui = mountOverlay(t);
|
||||
ui.overlay.setCamera(CAMERA);
|
||||
ui.playButton().click();
|
||||
const panel = ui.window.document.querySelector('.qci-panel');
|
||||
panel.dispatchEvent(
|
||||
new ui.window.KeyboardEvent('keydown', { key: 'Escape', bubbles: true }),
|
||||
);
|
||||
assert.equal(panel.hidden, true);
|
||||
assert.equal(ui.intervals.size, 0);
|
||||
|
||||
ui.overlay.setCamera({ ...CAMERA });
|
||||
assert.equal(panel.hidden, true, 'a routine update keeps it closed');
|
||||
ui.overlay.setCamera({ ...CAMERA }, { reselected: true });
|
||||
assert.equal(panel.hidden, false, 'picking the camera again reopens it');
|
||||
assert.equal(ui.intervals.size, 1);
|
||||
});
|
||||
@@ -1,9 +1,10 @@
|
||||
/* Core's close, dismiss and clear buttons draw a bare glyph: no padding,
|
||||
* border or background of their own, and a pointer. The kit's
|
||||
* UiCloseButton wears it as .ui-close-button; the guide's close button,
|
||||
* built in script, shares the rule. It selects one class and loads before
|
||||
* the feature stylesheets, so each feature rule still sets its size, colour,
|
||||
* hover and any surface (a border, a chip, a tinted square). */
|
||||
* UiCloseButton wears it as .ui-close-button, and the guide's close (a
|
||||
* UiCloseButton too) shares the rule by its feature class. It selects one
|
||||
* class and loads before the feature stylesheets, so each feature rule still
|
||||
* sets its size, colour, hover and any surface (a border, a chip, a tinted
|
||||
* square). */
|
||||
.ui-close-button,
|
||||
.gev-guide-close {
|
||||
padding: 0;
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<script setup>
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiCloseButton from '../../kit/UiCloseButton.vue';
|
||||
|
||||
// The Omnibar's guided walk: the spotlight ring and the callout beside it,
|
||||
// teleported to the end of `to` (the page's body). `startGuide()` in
|
||||
// src/ui/omnibarGuide.js owns every decision and every word: it renders this
|
||||
// with the `view` it computes for each step and keeps the parts the template
|
||||
// never binds: the guide's `visible` class, the callout's entrance replay
|
||||
// (its `swap` class), place and side, the ring's and the extra rings' boxes,
|
||||
// and focus. It finds those elements in the rendered tree itself.
|
||||
defineProps({
|
||||
to: { type: Object, required: true },
|
||||
view: { type: Object, required: true },
|
||||
onClose: { type: Function, required: true },
|
||||
onSkip: { type: Function, required: true },
|
||||
onOffer: { type: Function, required: true },
|
||||
onNext: { type: Function, required: true },
|
||||
});
|
||||
|
||||
/** A progress segment's attributes: no class at all for one still to come. */
|
||||
const dot = (name) => (name ? { class: name } : {});
|
||||
</script>
|
||||
|
||||
<!-- Only line breaks inside tags: the markup has no whitespace between elements. -->
|
||||
<template><Teleport :to="to"
|
||||
><div class="gev-guide"
|
||||
><div class="gev-guide-ring"><i></i></div
|
||||
><div
|
||||
class="gev-guide-callout"
|
||||
role="dialog"
|
||||
aria-modal="false"
|
||||
tabindex="-1"
|
||||
aria-labelledby="gev-guide-title"
|
||||
aria-describedby="gev-guide-text"
|
||||
><div class="gev-guide-head"
|
||||
><p id="gev-guide-title" class="gev-guide-title">{{ view.title }}</p
|
||||
><p class="gev-guide-count">{{ view.count }}</p
|
||||
><UiCloseButton
|
||||
class="gev-guide-close"
|
||||
:label="view.endLabel"
|
||||
:title="view.endLabel"
|
||||
@click="onClose()" /></div
|
||||
><ol class="gev-guide-progress" aria-hidden="true"
|
||||
><li
|
||||
v-for="(name, i) in view.progress"
|
||||
:key="`${view.step}-${i}`"
|
||||
v-bind="dot(name)"></li></ol
|
||||
><div class="gev-guide-body"
|
||||
><p id="gev-guide-text" class="gev-guide-text">{{ view.text }}</p
|
||||
><p class="gev-guide-hint" :hidden="view.hintHidden"
|
||||
><span class="gev-guide-hint-dot"></span
|
||||
><span>{{ view.hint }}</span></p
|
||||
></div
|
||||
><div class="gev-guide-actions"
|
||||
><p class="gev-guide-keys" :hidden="view.keysHidden"
|
||||
><kbd>{{ view.keyCap }}</kbd><span>{{ view.keyText }}</span></p
|
||||
><span
|
||||
><UiButton
|
||||
class="gev-guide-skip"
|
||||
:hidden="view.skipHidden"
|
||||
@click="onSkip()"
|
||||
>{{ view.skipLabel }}</UiButton
|
||||
><UiButton
|
||||
class="gev-guide-offer"
|
||||
:hidden="view.offerHidden"
|
||||
@click="onOffer()"
|
||||
>{{ view.offerLabel }}</UiButton
|
||||
><UiButton
|
||||
class="gev-guide-next"
|
||||
:class="{ quiet: view.nextQuiet }"
|
||||
:hidden="view.nextHidden"
|
||||
@click="onNext()"
|
||||
>{{ view.nextLabel }}</UiButton
|
||||
></span
|
||||
></div
|
||||
><p class="gev-guide-status" role="status" aria-live="polite">{{
|
||||
view.status
|
||||
}}</p></div
|
||||
></div
|
||||
></Teleport
|
||||
></template>
|
||||
@@ -0,0 +1,110 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiCloseButton from '../../kit/UiCloseButton.vue';
|
||||
|
||||
// The Québec 511 camera's floating player and its map preview, teleported to
|
||||
// the end of the page. `createQuebecCctvOverlay()` owns every decision: it
|
||||
// renders this with the `view` it computes and keeps the imperative parts,
|
||||
// which the template never binds: each video's source, playback and load, the
|
||||
// panel's dragged position, and the marker's per-frame visibility and place.
|
||||
// The elements those parts need are exposed.
|
||||
defineProps({
|
||||
view: { type: Object, required: true },
|
||||
});
|
||||
const emit = defineEmits([
|
||||
'close',
|
||||
'play',
|
||||
'refresh',
|
||||
'keydown',
|
||||
'headerPointerdown',
|
||||
'liveError',
|
||||
'liveLoadeddata',
|
||||
'stillError',
|
||||
'stillLoadeddata',
|
||||
]);
|
||||
|
||||
const panel = ref(null);
|
||||
const header = ref(null);
|
||||
const close = ref(null);
|
||||
const live = ref(null);
|
||||
const marker = ref(null);
|
||||
const still = ref(null);
|
||||
defineExpose({ panel, header, close, live, marker, still });
|
||||
// Each video's load and failure go to the owner, which marks the source.
|
||||
const liveListeners = {
|
||||
error: () => emit('liveError'),
|
||||
loadeddata: () => emit('liveLoadeddata'),
|
||||
};
|
||||
const stillListeners = {
|
||||
error: () => emit('stillError'),
|
||||
loadeddata: () => emit('stillLoadeddata'),
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Only line breaks inside tags: the markup has no whitespace between elements. -->
|
||||
<template><Teleport to="body"
|
||||
><section
|
||||
ref="panel"
|
||||
class="qci-panel"
|
||||
:hidden="view.panelHidden"
|
||||
role="region"
|
||||
:aria-label="t('CCTV camera')"
|
||||
@keydown="emit('keydown', $event)"
|
||||
><header
|
||||
ref="header"
|
||||
class="qci-header"
|
||||
@pointerdown="emit('headerPointerdown', $event)"
|
||||
><strong>{{ view.title }}</strong
|
||||
><UiCloseButton
|
||||
ref="close"
|
||||
:label="t('Close camera preview')"
|
||||
@click="emit('close')" /></header
|
||||
><p class="qci-coordinates">{{ view.coordinates }}</p
|
||||
><p class="qci-credit" :hidden="view.creditHidden">{{ view.credit }}</p
|
||||
><video
|
||||
ref="live"
|
||||
class="qci-live"
|
||||
controls
|
||||
muted
|
||||
autoplay
|
||||
loop
|
||||
playsinline
|
||||
:hidden="view.liveHidden"
|
||||
:aria-label="t('CCTV camera')"
|
||||
v-on="liveListeners"></video
|
||||
><div class="qci-actions" :hidden="view.actionsHidden"
|
||||
><UiButton
|
||||
class="qci-play"
|
||||
:hidden="view.playHidden"
|
||||
@click="emit('play')"
|
||||
>{{ t('Play') }}</UiButton
|
||||
><UiButton :hidden="view.refreshHidden" @click="emit('refresh')">{{
|
||||
t('Refresh map still')
|
||||
}}</UiButton></div
|
||||
><p class="qci-note" :hidden="view.noteHidden">{{ view.note }}</p
|
||||
><a
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
:href="view.sourceHref"
|
||||
:hidden="view.sourceHidden"
|
||||
>{{ t("Open this image on the provider's site") }}</a
|
||||
></section
|
||||
><div
|
||||
ref="marker"
|
||||
class="qci-marker"
|
||||
:class="{ 'qci-marker-link-only': view.markerLinkOnly }"
|
||||
hidden
|
||||
><video
|
||||
ref="still"
|
||||
class="qci-marker-still"
|
||||
muted
|
||||
playsinline
|
||||
preload="none"
|
||||
:hidden="view.stillHidden"
|
||||
aria-hidden="true"
|
||||
v-on="stillListeners"></video
|
||||
><span class="qci-marker-label">{{ view.markerLabel }}</span></div
|
||||
></Teleport
|
||||
></template>
|
||||
Reference in new issue
Block a user