@panoramax/web-viewer 5.0.0-develop-d26305dd → 5.0.0-develop-be5ba1a7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +1 -1
- package/build/cjs/index_photoviewer.js +1 -1
- package/build/esm/components/core/Basic.js +1 -1
- package/build/esm/translations/el.json +92 -1
- package/package.json +1 -1
- package/build/bundle.cjs +0 -3399
- package/build/bundle.cjs.map +0 -1
- package/build/bundle_photoviewer.cjs +0 -2510
- package/build/bundle_photoviewer.cjs.map +0 -1
- package/build/components/core/Basic.css +0 -56
- package/build/components/core/Basic.js +0 -378
- package/build/components/core/CoverageMap.css +0 -10
- package/build/components/core/CoverageMap.js +0 -169
- package/build/components/core/Editor.css +0 -33
- package/build/components/core/Editor.js +0 -398
- package/build/components/core/PhotoViewer.css +0 -70
- package/build/components/core/PhotoViewer.js +0 -650
- package/build/components/core/Viewer.css +0 -130
- package/build/components/core/Viewer.js +0 -711
- package/build/components/core/index.js +0 -10
- package/build/components/index.js +0 -11
- package/build/components/index_photoviewer.js +0 -6
- package/build/components/layout/BottomDrawer.js +0 -258
- package/build/components/layout/CorneredGrid.js +0 -143
- package/build/components/layout/Mini.js +0 -121
- package/build/components/layout/Tabs.js +0 -140
- package/build/components/layout/index.js +0 -9
- package/build/components/menus/LocationPrecisionDoc.js +0 -42
- package/build/components/menus/MapBackground.js +0 -110
- package/build/components/menus/MapFilters.js +0 -567
- package/build/components/menus/MapLayers.js +0 -238
- package/build/components/menus/MapLegend.js +0 -68
- package/build/components/menus/MiniPictureLegend.js +0 -73
- package/build/components/menus/PictureLegend.js +0 -379
- package/build/components/menus/PictureMetadata.js +0 -380
- package/build/components/menus/PlayerOptions.js +0 -93
- package/build/components/menus/QualityScoreDoc.js +0 -42
- package/build/components/menus/ReportForm.js +0 -132
- package/build/components/menus/SemanticsDoc.js +0 -38
- package/build/components/menus/SemanticsDownload.js +0 -33
- package/build/components/menus/SemanticsFilters.js +0 -153
- package/build/components/menus/SemanticsList.js +0 -413
- package/build/components/menus/SemanticsMetadata.js +0 -368
- package/build/components/menus/Share.js +0 -105
- package/build/components/menus/index.js +0 -22
- package/build/components/menus/index_photoviewer.js +0 -11
- package/build/components/styles.js +0 -557
- package/build/components/ui/AnnotationsSwitch.js +0 -159
- package/build/components/ui/Button.js +0 -77
- package/build/components/ui/ButtonGroup.css +0 -59
- package/build/components/ui/ButtonGroup.js +0 -69
- package/build/components/ui/CopyButton.js +0 -110
- package/build/components/ui/Grade.js +0 -54
- package/build/components/ui/GradeFilter.js +0 -122
- package/build/components/ui/IconSwitch.js +0 -193
- package/build/components/ui/LinkButton.js +0 -67
- package/build/components/ui/ListGroup.js +0 -66
- package/build/components/ui/ListItem.js +0 -90
- package/build/components/ui/Loader.js +0 -203
- package/build/components/ui/Map.css +0 -63
- package/build/components/ui/Map.js +0 -853
- package/build/components/ui/MapMore.js +0 -175
- package/build/components/ui/Photo.css +0 -50
- package/build/components/ui/Photo.js +0 -1502
- package/build/components/ui/Popup.js +0 -145
- package/build/components/ui/ProgressBar.js +0 -104
- package/build/components/ui/QualityScore.js +0 -147
- package/build/components/ui/SearchBar.js +0 -374
- package/build/components/ui/SemanticsEditor.js +0 -191
- package/build/components/ui/SemanticsTable.js +0 -88
- package/build/components/ui/Switch.js +0 -139
- package/build/components/ui/TogglableGroup.js +0 -157
- package/build/components/ui/index.js +0 -29
- package/build/components/ui/index_photoviewer.js +0 -21
- package/build/components/ui/widgets/CopyCoordinates.js +0 -75
- package/build/components/ui/widgets/GeoSearch.css +0 -21
- package/build/components/ui/widgets/GeoSearch.js +0 -150
- package/build/components/ui/widgets/Legend.js +0 -190
- package/build/components/ui/widgets/LevelSelect.css +0 -51
- package/build/components/ui/widgets/LevelSelect.js +0 -143
- package/build/components/ui/widgets/MapFiltersButton.js +0 -114
- package/build/components/ui/widgets/MapLayersButton.js +0 -79
- package/build/components/ui/widgets/OSMEditors.js +0 -155
- package/build/components/ui/widgets/PictureLegendActions.js +0 -99
- package/build/components/ui/widgets/Player.css +0 -7
- package/build/components/ui/widgets/Player.js +0 -154
- package/build/components/ui/widgets/SemanticsFiltersButton.js +0 -65
- package/build/components/ui/widgets/Zoom.js +0 -84
- package/build/components/ui/widgets/index.js +0 -16
- package/build/components/ui/widgets/index_photoviewer.js +0 -7
- package/build/img/arrow_360.svg +0 -14
- package/build/img/arrow_flat.svg +0 -11
- package/build/img/arrow_triangle.svg +0 -9
- package/build/img/arrow_turn.svg +0 -8
- package/build/img/bg_aerial.jpg +0 -0
- package/build/img/bg_streets.jpg +0 -0
- package/build/img/loader_base.jpg +0 -0
- package/build/img/logo_dead.svg +0 -91
- package/build/img/marker.svg +0 -17
- package/build/img/marker_blue.svg +0 -20
- package/build/img/osm.svg +0 -49
- package/build/img/panoramax.svg +0 -13
- package/build/img/switch_big.svg +0 -54
- package/build/img/switch_mini.svg +0 -48
- package/build/img/wd.svg +0 -1
- package/build/index_photoviewer.js +0 -4
- package/build/package.json +0 -148
- package/build/servers.js +0 -14
- package/build/translations/ar.json +0 -1
- package/build/translations/be.json +0 -257
- package/build/translations/br.json +0 -81
- package/build/translations/cy.json +0 -117
- package/build/translations/da.json +0 -300
- package/build/translations/de.json +0 -309
- package/build/translations/en.json +0 -294
- package/build/translations/eo.json +0 -235
- package/build/translations/es.json +0 -292
- package/build/translations/fi.json +0 -1
- package/build/translations/fr.json +0 -294
- package/build/translations/hr.json +0 -294
- package/build/translations/hu.json +0 -294
- package/build/translations/it.json +0 -306
- package/build/translations/ja.json +0 -182
- package/build/translations/ko.json +0 -1
- package/build/translations/nl.json +0 -305
- package/build/translations/nn.json +0 -1
- package/build/translations/pl.json +0 -169
- package/build/translations/pt.json +0 -296
- package/build/translations/pt_BR.json +0 -304
- package/build/translations/sv.json +0 -182
- package/build/translations/ti.json +0 -9
- package/build/translations/tr.json +0 -297
- package/build/translations/uk.json +0 -268
- package/build/translations/zh_Hant.json +0 -309
- package/build/utils/API.js +0 -928
- package/build/utils/InitParameters.js +0 -521
- package/build/utils/MapStyleComposer.js +0 -889
- package/build/utils/PanoraMapProtocol.js +0 -49
- package/build/utils/PhotoAdapter.js +0 -49
- package/build/utils/PresetsManager.js +0 -148
- package/build/utils/SemanticsMapProtocol.js +0 -144
- package/build/utils/URLHandler.js +0 -426
- package/build/utils/geocoder.js +0 -203
- package/build/utils/i18n.js +0 -128
- package/build/utils/index.js +0 -17
- package/build/utils/index_photoviewer.js +0 -14
- package/build/utils/indoor.js +0 -200
- package/build/utils/map.js +0 -788
- package/build/utils/picture.js +0 -507
- package/build/utils/semantics.js +0 -321
- package/build/utils/services.js +0 -148
- package/build/utils/utils.js +0 -433
- package/build/utils/widgets.js +0 -110
|
@@ -1,650 +0,0 @@
|
|
|
1
|
-
import { DEFAULTS as PSDefaults, SYSTEM as PSSystem } from "@photo-sphere-viewer/core";
|
|
2
|
-
import URLHandler from "../../utils/URLHandler.js";
|
|
3
|
-
import Basic from "./Basic.js";
|
|
4
|
-
import Photo, { PSV_ANIM_DURATION, PSV_DEFAULT_ZOOM } from "../ui/Photo.js";
|
|
5
|
-
import { createWebComp } from "../../utils/widgets.js";
|
|
6
|
-
import { DISABLE_ANNOTATIONS_PARAM, isInIframe, isNullId } from "../../utils/utils.js";
|
|
7
|
-
import { default as InitParameters, alterPSVState, alterPhotoViewerState } from "../../utils/InitParameters.js";
|
|
8
|
-
import PresetManager from "../../utils/PresetsManager.js";
|
|
9
|
-
import { deepQuerySelector } from "shadow-dom-selector";
|
|
10
|
-
import PhotoViewerStyles from "./PhotoViewer.css" with { type: "css" };
|
|
11
|
-
document.adoptedStyleSheets.push(PhotoViewerStyles);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export const PSV_ZOOM_DELTA = 20;
|
|
15
|
-
const PSV_MOVE_DELTA = Math.PI / 6;
|
|
16
|
-
export const KEYBOARD_SKIP_FOCUS_WIDGETS = ["pnx-mini", "pnx-widget-player", "pnx-widget-zoom"];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Photo Viewer is a component showing pictures (without any map).
|
|
21
|
-
*
|
|
22
|
-
* This component has a [CorneredGrid](#Panoramax.components.layout.CorneredGrid) layout, you can use directly any slot element to pass custom widgets.
|
|
23
|
-
*
|
|
24
|
-
* If you need a viewer with map, checkout [Viewer component](#Panoramax.components.core.Viewer).
|
|
25
|
-
*
|
|
26
|
-
* Make sure to set width/height through CSS for proper display.
|
|
27
|
-
* @class Panoramax.components.core.PhotoViewer
|
|
28
|
-
* @element pnx-photo-viewer
|
|
29
|
-
* @extends Panoramax.components.core.Basic
|
|
30
|
-
* @property {Panoramax.components.ui.Loader} loader The loader screen
|
|
31
|
-
* @property {Panoramax.utils.API} api The API manager
|
|
32
|
-
* @property {Panoramax.components.ui.Photo} psv The Photo Sphere Viewer component itself
|
|
33
|
-
* @property {Panoramax.components.layout.CorneredGrid} grid The grid layout manager
|
|
34
|
-
* @property {Panoramax.components.ui.Popup} popup The popup container
|
|
35
|
-
* @property {Panoramax.utils.URLHandler} urlHandler The URL query parameters manager
|
|
36
|
-
* @property {Panoramax.utils.PresetsManager} presetsManager The semantics presets manager
|
|
37
|
-
* @fires Panoramax.components.core.Basic#select
|
|
38
|
-
* @fires Panoramax.components.core.Basic#ready
|
|
39
|
-
* @fires Panoramax.components.core.Basic#broken
|
|
40
|
-
* @slot `top-left` The top-left corner
|
|
41
|
-
* @slot `top` The top middle corner
|
|
42
|
-
* @slot `top-right` The top-right corner
|
|
43
|
-
* @slot `bottom-left` The bottom-left corner
|
|
44
|
-
* @slot `bottom` The bottom middle corner
|
|
45
|
-
* @slot `bottom-right` The bottom-right corner
|
|
46
|
-
* @slot `editors` External links to map editors, or any tool that may be helpful. Defaults to OSM tools (iD & JOSM).
|
|
47
|
-
* @example
|
|
48
|
-
* ```html
|
|
49
|
-
* <!-- Basic example -->
|
|
50
|
-
* <pnx-photo-viewer
|
|
51
|
-
* endpoint="https://panoramax.openstreetmap.fr/"
|
|
52
|
-
* style="width: 300px; height: 250px"
|
|
53
|
-
* />
|
|
54
|
-
*
|
|
55
|
-
* <!-- With slotted widgets -->
|
|
56
|
-
* <pnx-photo-viewer
|
|
57
|
-
* endpoint="https://panoramax.openstreetmap.fr/"
|
|
58
|
-
* style="width: 300px; height: 250px"
|
|
59
|
-
* >
|
|
60
|
-
* <p slot="top-right">My custom text</p>
|
|
61
|
-
* <p slot="editors"><a href="https://my.own.tool/">Edit in my own tool</a></p>
|
|
62
|
-
* </pnx-photo-viewer>
|
|
63
|
-
*
|
|
64
|
-
* <!-- With only your custom widgets -->
|
|
65
|
-
* <pnx-photo-viewer
|
|
66
|
-
* endpoint="https://panoramax.openstreetmap.fr/"
|
|
67
|
-
* style="width: 300px; height: 250px"
|
|
68
|
-
* widgets="false"
|
|
69
|
-
* >
|
|
70
|
-
* <p slot="top-right">My custom text</p>
|
|
71
|
-
* </pnx-photo-viewer>
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export default class PhotoViewer extends Basic {
|
|
75
|
-
/**
|
|
76
|
-
* Component properties. All of [Basic properties](#Panoramax.components.core.Basic+properties) are available as well.
|
|
77
|
-
* @memberof Panoramax.components.core.PhotoViewer#
|
|
78
|
-
* @mixes Panoramax.components.core.Basic#properties
|
|
79
|
-
* @type {Object}
|
|
80
|
-
* @property {string} endpoint URL to API to use (must be a [STAC API](https://github.com/radiantearth/stac-api-spec/blob/main/overview.md))
|
|
81
|
-
* @property {object} [psv-options] [Any option to pass to Photo component](#Panoramax.components.ui.Photo) as an object.<br />Example: `psv-options="{'transitionDuration': 500, 'picturesNavigation': 'pic'}"`
|
|
82
|
-
* @property {string} [widgets=true] Use default set of widgets ? Set to false to avoid any widget to show up, and use slots to populate as you like.
|
|
83
|
-
* @property {string} [picture] The picture ID to display
|
|
84
|
-
* @property {string} [sequence] The sequence ID of the picture displayed
|
|
85
|
-
* @property {object} [fetch-options] Set custom options for fetch calls made against API ([same syntax as fetch options parameter](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters))
|
|
86
|
-
* @property {string} [lang] To override language used for labels. Defaults to using user's preferred languages.
|
|
87
|
-
* @property {string} [url-parameters=true] Should the component add and update URL query parameters to save viewer state ?
|
|
88
|
-
* @property {string} [keyboard-shortcuts=true] Should keyboard shortcuts be enabled ? Set to "false" to fully disable any keyboard shortcuts.
|
|
89
|
-
* @property {string} [skip-tags-menu-opening=false] Should the "Tags" menu automatically open when you toggle Annotations switch ? Set true to avoid auto-opening.
|
|
90
|
-
* @property {string} [share-base-url] Override the default base URL (current page) for the Share widget. Useful to lead to a public page when viewer is used in a closed tool.
|
|
91
|
-
*/
|
|
92
|
-
static properties = {
|
|
93
|
-
"psv-options": {converter: Basic.GetJSONConverter()},
|
|
94
|
-
widgets: {type: String},
|
|
95
|
-
"url-parameters": {type: String},
|
|
96
|
-
"keyboard-shortcuts": {type: String},
|
|
97
|
-
tabindex: {type: Number},
|
|
98
|
-
"skip-tags-menu-opening": {type: String},
|
|
99
|
-
"share-base-url": {type: String},
|
|
100
|
-
...Basic.properties
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
constructor() {
|
|
104
|
-
super();
|
|
105
|
-
|
|
106
|
-
// Defaults
|
|
107
|
-
this["psv-options"] = {};
|
|
108
|
-
this["url-parameters"] = this.getAttribute("url-parameters") || "true";
|
|
109
|
-
this["keyboard-shortcuts"] = this.getAttribute("keyboard-shortcuts") || "true";
|
|
110
|
-
this["skip-tags-menu-opening"] = (this.getAttribute("skip-tags-menu-opening") || "false") !== "true";
|
|
111
|
-
this["share-base-url"] = this.getAttribute("share-base-url") || null;
|
|
112
|
-
this.widgets = this.getAttribute("widgets") || "true";
|
|
113
|
-
|
|
114
|
-
// Init DOM containers
|
|
115
|
-
this.grid = createWebComp("pnx-cornered-grid");
|
|
116
|
-
this.psvContainer = document.createElement("div");
|
|
117
|
-
this.psvContainer.setAttribute("slot", "bg");
|
|
118
|
-
this.grid.appendChild(this.psvContainer);
|
|
119
|
-
this.popup = createWebComp("pnx-popup", {_parent: this, onclose: this._onPopupClose.bind(this)});
|
|
120
|
-
this.tabindex = 0;
|
|
121
|
-
|
|
122
|
-
// Cache for sequences metadata
|
|
123
|
-
// Used by semantics metadata component to avoid re-downloads
|
|
124
|
-
this._sequencesMetadata = {};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** @private */
|
|
128
|
-
_createInitParamsHandler() {
|
|
129
|
-
this._initParams = new InitParameters(
|
|
130
|
-
InitParameters.GetComponentProperties(PhotoViewer, this),
|
|
131
|
-
Object.assign({}, this.urlHandler?.currentURLParams(), this.urlHandler?.currentURLParams(true)),
|
|
132
|
-
{ disableAnnotations: localStorage.getItem(DISABLE_ANNOTATIONS_PARAM) },
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/** @private */
|
|
137
|
-
_initWidgets() {
|
|
138
|
-
if(this._initParams.getParentPostInit().widgets !== "false") {
|
|
139
|
-
if(!isInIframe()) {
|
|
140
|
-
this.grid.appendChild(createWebComp("pnx-widget-player", {
|
|
141
|
-
slot: this.isWidthMedium() ? "top-right": "top",
|
|
142
|
-
_parent: this,
|
|
143
|
-
class: "pnx-only-psv pnx-print-hidden",
|
|
144
|
-
size: this.isHeightSmall() || this.isWidthMedium() ? "md": "xl",
|
|
145
|
-
}));
|
|
146
|
-
|
|
147
|
-
this.grid.appendChild(createWebComp("pnx-annotations-switch", {
|
|
148
|
-
slot: this.isWidthMedium() ? "top-right": "top",
|
|
149
|
-
_parent: this,
|
|
150
|
-
class: "pnx-only-psv pnx-print-hidden",
|
|
151
|
-
size: this.isHeightSmall() || this.isWidthMedium() ? "md": "xl",
|
|
152
|
-
}));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if(isInIframe()) {
|
|
156
|
-
this.legend = createWebComp("pnx-widget-legend", {
|
|
157
|
-
slot: "bottom-right",
|
|
158
|
-
light: true,
|
|
159
|
-
_parent: this,
|
|
160
|
-
focus: this._initParams.getParentPostInit().focus,
|
|
161
|
-
picture: this._initParams.getParentPostInit().picture,
|
|
162
|
-
});
|
|
163
|
-
this.grid.appendChild(this.legend);
|
|
164
|
-
}
|
|
165
|
-
else if(!this.isWidthSmall()) {
|
|
166
|
-
this.legend = createWebComp("pnx-widget-legend", {
|
|
167
|
-
slot: !this.isWidthSmall() ? "top-left" : undefined,
|
|
168
|
-
_parent: this,
|
|
169
|
-
focus: this._initParams.getParentPostInit().focus,
|
|
170
|
-
picture: this._initParams.getParentPostInit().picture,
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
this.grid.appendChild(createWebComp("pnx-widget-zoom", {
|
|
174
|
-
slot: "bottom-right",
|
|
175
|
-
class: "pnx-print-hidden",
|
|
176
|
-
_parent: this
|
|
177
|
-
}));
|
|
178
|
-
this.grid.appendChild(this.legend);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
this.legend = createWebComp("pnx-picture-legend", { _parent: this });
|
|
182
|
-
this.bottomDrawer = createWebComp("pnx-bottom-drawer", {
|
|
183
|
-
slot: "bottom",
|
|
184
|
-
_parent: this,
|
|
185
|
-
class: this._initParams.getParentPostInit().willLoadPicture ? undefined: "pnx-hidden",
|
|
186
|
-
});
|
|
187
|
-
this.bottomDrawer.appendChild(this.legend);
|
|
188
|
-
this.grid.appendChild(this.bottomDrawer);
|
|
189
|
-
this.addEventListener("select", e => {
|
|
190
|
-
if(isNullId(e.detail.picId)) { this.bottomDrawer.classList.add("pnx-hidden"); }
|
|
191
|
-
else { this.bottomDrawer.classList.remove("pnx-hidden"); }
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/** @private */
|
|
198
|
-
connectedCallback() {
|
|
199
|
-
super.connectedCallback();
|
|
200
|
-
|
|
201
|
-
this.presetsManager = new PresetManager(this.lang);
|
|
202
|
-
|
|
203
|
-
if(this["url-parameters"] !== "false") {
|
|
204
|
-
this.urlHandler = new URLHandler(this);
|
|
205
|
-
this.onceReady().then(() => {
|
|
206
|
-
this.urlHandler.listenToChanges();
|
|
207
|
-
this.urlHandler._onParentChange();
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
this.onceAPIReady().then(this._postAPIInit.bind(this));
|
|
212
|
-
|
|
213
|
-
this._moveChildToGrid();
|
|
214
|
-
window.addEventListener("DOMContentLoaded", () => {
|
|
215
|
-
this._moveChildToGrid();
|
|
216
|
-
}, { once: true });
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/** @private */
|
|
220
|
-
disconnectedCallback() {
|
|
221
|
-
super.disconnectedCallback();
|
|
222
|
-
this.urlHandler?.destroy();
|
|
223
|
-
this.psv?.destroy();
|
|
224
|
-
document.body.removeEventListener("click", this._toggleKeyboardBasedOnFocus);
|
|
225
|
-
window.removeEventListener("keypress", this._toggleKeyboardBasedOnFocus);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// eslint-disable-next-line class-methods-use-this
|
|
229
|
-
getClassName() {
|
|
230
|
-
return "PhotoViewer";
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Waits for PhotoViewer to be completely ready (map & PSV loaded, first picture also if one is wanted)
|
|
235
|
-
* @returns {Promise} When viewer is ready
|
|
236
|
-
* @memberof Panoramax.components.core.PhotoViewer#
|
|
237
|
-
*/
|
|
238
|
-
async onceReady() {
|
|
239
|
-
return await this.oncePSVReady().then(() => {
|
|
240
|
-
if(this._initParams.getParentPostInit().willLoadPicture && !this.psv.getPictureMetadata()) { return this.onceFirstPicLoaded(); }
|
|
241
|
-
else { return Promise.resolve(); }
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/** @private */
|
|
246
|
-
render() {
|
|
247
|
-
return [this.loader, this.grid, this.popup];
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
getSubComponentsNames() {
|
|
251
|
-
return super.getSubComponentsNames().concat(["psv", "grid", "popup", "urlHandler"]);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Waiting for Photo Sphere Viewer to be available.
|
|
256
|
-
* @returns {Promise} When PSV is ready to use
|
|
257
|
-
* @memberof Panoramax.components.core.PhotoViewer#
|
|
258
|
-
*/
|
|
259
|
-
oncePSVReady() {
|
|
260
|
-
let waiter;
|
|
261
|
-
return new Promise(resolve => {
|
|
262
|
-
waiter = setInterval(() => {
|
|
263
|
-
if(this.psv && typeof this.psv === "object") {
|
|
264
|
-
if(this.psv.container) {
|
|
265
|
-
clearInterval(waiter);
|
|
266
|
-
resolve();
|
|
267
|
-
}
|
|
268
|
-
else if(this.psv.addEventListener) {
|
|
269
|
-
this.psv.addEventListener("ready", () => {
|
|
270
|
-
clearInterval(waiter);
|
|
271
|
-
resolve();
|
|
272
|
-
}, {once: true});
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}, 250);
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Waits for first picture to display on PSV.
|
|
281
|
-
* @returns {Promise}
|
|
282
|
-
* @fulfil {undefined} When picture is shown
|
|
283
|
-
* @memberof Panoramax.components.core.PhotoViewer#
|
|
284
|
-
*/
|
|
285
|
-
onceFirstPicLoaded() {
|
|
286
|
-
return this.oncePSVReady().then(() => {
|
|
287
|
-
if(this.psv.getPictureMetadata()) { return Promise.resolve(); }
|
|
288
|
-
else {
|
|
289
|
-
return new Promise(resolve => {
|
|
290
|
-
this.psv.addEventListener("picture-loaded", resolve, {once: true});
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/** @private */
|
|
297
|
-
_postAPIInit() {
|
|
298
|
-
this.loader.setAttribute("value", 30);
|
|
299
|
-
this._createInitParamsHandler();
|
|
300
|
-
|
|
301
|
-
const myPostInitParams = this._initParams.getParentPostInit();
|
|
302
|
-
|
|
303
|
-
this._initPSV();
|
|
304
|
-
this._initWidgets();
|
|
305
|
-
alterPhotoViewerState(this, myPostInitParams);
|
|
306
|
-
|
|
307
|
-
if(myPostInitParams.keyboardShortcuts) {
|
|
308
|
-
this._handleKeyboardManagement();
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if(myPostInitParams.willLoadPicture) {
|
|
312
|
-
if(this.psv.getPictureMetadata()) {
|
|
313
|
-
this.loader.dismiss();
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
this.psv.addEventListener("picture-loaded", () => this.loader.dismiss(), {once: true});
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
this.loader.dismiss();
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/** @private */
|
|
325
|
-
_initPSV() {
|
|
326
|
-
try {
|
|
327
|
-
this.psv = new Photo(this, this.psvContainer, {
|
|
328
|
-
shouldGoFast: this._psvShouldGoFast.bind(this),
|
|
329
|
-
keyboard: "always",
|
|
330
|
-
keyboardActions: {
|
|
331
|
-
...PSDefaults.keyboardActions,
|
|
332
|
-
"8": "ROTATE_UP",
|
|
333
|
-
"2": "ROTATE_DOWN",
|
|
334
|
-
"4": "ROTATE_LEFT",
|
|
335
|
-
"6": "ROTATE_RIGHT",
|
|
336
|
-
|
|
337
|
-
"PageUp": () => this.psv.goToNextPicture(),
|
|
338
|
-
"9": () => this.psv.goToNextPicture(),
|
|
339
|
-
|
|
340
|
-
"PageDown": () => this.psv.goToPrevPicture(),
|
|
341
|
-
"3": () => this.psv.goToPrevPicture(),
|
|
342
|
-
|
|
343
|
-
"5": () => this.moveCenter(),
|
|
344
|
-
"*": () => this.moveCenter(),
|
|
345
|
-
|
|
346
|
-
"Home": () => this._toggleFocus?.(),
|
|
347
|
-
"7": () => this._toggleFocus?.(),
|
|
348
|
-
|
|
349
|
-
"End": () => this.mini.toggleAttribute("collapsed"),
|
|
350
|
-
"1": () => this.mini.toggleAttribute("collapsed"),
|
|
351
|
-
|
|
352
|
-
" ": () => this.psv.toggleSequencePlaying(),
|
|
353
|
-
"0": () => this.psv.toggleSequencePlaying(),
|
|
354
|
-
},
|
|
355
|
-
...this._initParams.getPSVInit()
|
|
356
|
-
});
|
|
357
|
-
this.oncePSVReady().then(() => {
|
|
358
|
-
this.loader.setAttribute("value", 50);
|
|
359
|
-
alterPSVState(this.psv, this._initParams.getPSVPostInit());
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
// Show class when PSV is playing sequence
|
|
363
|
-
this.psv.addEventListener("sequence-playing", () => this.classList.add("pnx-playing"));
|
|
364
|
-
this.psv.addEventListener("sequence-stopped", () => this.classList.remove("pnx-playing"));
|
|
365
|
-
|
|
366
|
-
// One-click focusing
|
|
367
|
-
this.psv.addEventListener("dblclick", () => clearTimeout(this._gridFocus));
|
|
368
|
-
this.psv.addEventListener("click", e => {
|
|
369
|
-
clearTimeout(this._gridFocus);
|
|
370
|
-
|
|
371
|
-
if(e.data.target.tagName === "CANVAS") {
|
|
372
|
-
if(!this._hasMenuOpened() && (!this.isMapWide || (this.isMapWide && !this.isMapWide()))) {
|
|
373
|
-
this._gridFocus = setTimeout(() => {
|
|
374
|
-
if(this.grid.toggleAway()) {
|
|
375
|
-
this.classList.add("pnx-grid-toggled");
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
this.classList.remove("pnx-grid-toggled");
|
|
379
|
-
}
|
|
380
|
-
}, 250);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
this.psvContainer.addEventListener("mousemove", () => {
|
|
385
|
-
if(this.grid._hidden) {
|
|
386
|
-
clearTimeout(this._gridFocus);
|
|
387
|
-
this.grid.toggleAway(true);
|
|
388
|
-
this.classList.remove("pnx-grid-toggled");
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
catch(e) {
|
|
393
|
-
let err = !PSSystem.isWebGLSupported ? this._t.pnx.error_webgl : this._t.pnx.error_psv;
|
|
394
|
-
this.loader.dismiss(e, err);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/** @private */
|
|
399
|
-
// eslint-disable-next-line class-methods-use-this
|
|
400
|
-
_hasMenuOpened() {
|
|
401
|
-
// eslint-disable-next-line eqeqeq
|
|
402
|
-
return deepQuerySelector("pnx-togglable-group > div > .pnx-panel:not(.pnx-hidden)") != null;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/** @private */
|
|
406
|
-
_enableKeyboard() {
|
|
407
|
-
this.psv.startKeyboardControl();
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/** @private */
|
|
411
|
-
_disableKeyboard() {
|
|
412
|
-
this.psv.stopKeyboardControl();
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/** @private */
|
|
416
|
-
_toggleKeyboardBasedOnFocus(e) {
|
|
417
|
-
const target = e?.target || document.activeElement;
|
|
418
|
-
if(this.contains(target)) {
|
|
419
|
-
// Check if focus is not in a widget
|
|
420
|
-
for(let cn of this.grid.childNodes) {
|
|
421
|
-
if(
|
|
422
|
-
cn.getAttribute("slot") !== "bg"
|
|
423
|
-
&& !KEYBOARD_SKIP_FOCUS_WIDGETS.includes(cn.tagName.toLowerCase())
|
|
424
|
-
) {
|
|
425
|
-
if(cn.contains(target)) {
|
|
426
|
-
this._disableKeyboard();
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// Skip if popup is opened
|
|
433
|
-
if(this.popup.getAttribute("visible") !== null) {
|
|
434
|
-
this._disableKeyboard();
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
this._enableKeyboard();
|
|
439
|
-
}
|
|
440
|
-
else {
|
|
441
|
-
this._disableKeyboard();
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/** @private */
|
|
446
|
-
_handleKeyboardManagement() {
|
|
447
|
-
// General
|
|
448
|
-
window.addEventListener("click", e => this._toggleKeyboardBasedOnFocus(e));
|
|
449
|
-
window.addEventListener("keypress", this._toggleKeyboardBasedOnFocus.bind(this));
|
|
450
|
-
|
|
451
|
-
// Popup
|
|
452
|
-
this.popup.addEventListener("open", this._disableKeyboard.bind(this));
|
|
453
|
-
this.popup.addEventListener("close", this._enableKeyboard.bind(this));
|
|
454
|
-
this.psv.addEventListener("click", this._enableKeyboard.bind(this));
|
|
455
|
-
|
|
456
|
-
// Widgets
|
|
457
|
-
for(let cn of this.grid.childNodes) {
|
|
458
|
-
if(
|
|
459
|
-
cn.getAttribute("slot") !== "bg"
|
|
460
|
-
&& !KEYBOARD_SKIP_FOCUS_WIDGETS.includes(cn.tagName.toLowerCase())
|
|
461
|
-
) {
|
|
462
|
-
cn.addEventListener("focusin", this._disableKeyboard.bind(this));
|
|
463
|
-
cn.addEventListener("focusout", () => {
|
|
464
|
-
if(this.popup.getAttribute("visible") === null) {
|
|
465
|
-
this._enableKeyboard();
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* Given context, should tiles be loaded in PSV.
|
|
474
|
-
* @private
|
|
475
|
-
*/
|
|
476
|
-
_psvShouldGoFast() {
|
|
477
|
-
return (this.psv._sequencePlaying && this.psv.getTransitionDuration() < 1000);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
/** @private */
|
|
481
|
-
_moveChildToGrid() {
|
|
482
|
-
const slotContent = Array.from(this.querySelectorAll("[slot]"));
|
|
483
|
-
|
|
484
|
-
slotContent.forEach(n => {
|
|
485
|
-
// Add parent + translation for our components
|
|
486
|
-
if(n.tagName?.toLowerCase().startsWith("pnx-")) {
|
|
487
|
-
n._parent = this;
|
|
488
|
-
n._t = this._t;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
// Editors slot -> legend
|
|
492
|
-
if(n.getAttribute("slot") === "editors") {
|
|
493
|
-
this.onceReady().then(() => this.legend?.appendChild(n));
|
|
494
|
-
}
|
|
495
|
-
// Add to grid else
|
|
496
|
-
else {
|
|
497
|
-
this.grid.appendChild(n);
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Change full-page popup visibility and content
|
|
504
|
-
* @memberof Panoramax.components.core.PhotoViewer#
|
|
505
|
-
* @param {boolean} visible True to make it appear
|
|
506
|
-
* @param {string|Element[]} [content] The new popup content
|
|
507
|
-
*/
|
|
508
|
-
setPopup(visible, content = null) {
|
|
509
|
-
if(visible) { this.popup.setAttribute("visible", ""); }
|
|
510
|
-
else { this.popup.removeAttribute("visible"); }
|
|
511
|
-
|
|
512
|
-
this.popup.innerHTML = "";
|
|
513
|
-
if(typeof content === "string") { this.popup.innerHTML = content; }
|
|
514
|
-
else if(Array.isArray(content)) { content.forEach(c => this.popup.appendChild(c)); }
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
/** @private */
|
|
518
|
-
_onPopupClose() {
|
|
519
|
-
this.dispatchEvent(new CustomEvent("focus-changed", { detail: { focus: this.map && this.isMapWide() ? "map" : "pic" } }));
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
/** @private */
|
|
523
|
-
_showQualityScoreDoc() {
|
|
524
|
-
this.setPopup(true, [createWebComp("pnx-quality-score-doc", {_t: this._t})]);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/** @private */
|
|
528
|
-
_showReportForm() {
|
|
529
|
-
if(!this.psv.getPictureMetadata()) { throw new Error("No picture currently selected"); }
|
|
530
|
-
this.setPopup(true, [createWebComp("pnx-report-form", {_parent: this})]);
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
/** @private */
|
|
534
|
-
_showShareOptions() {
|
|
535
|
-
this.setPopup(true, [createWebComp("pnx-share-menu", {_parent: this, "base-url": this["share-base-url"]})]);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/** @private */
|
|
539
|
-
_showSemanticsDoc() {
|
|
540
|
-
this.setPopup(true, [createWebComp("pnx-semantics-doc", {_t: this._t})]);
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
/** @private */
|
|
544
|
-
_showSemanticsDownload() {
|
|
545
|
-
this.setPopup(true, [createWebComp("pnx-semantics-download", {_t: this._t})]);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* Move the view of main component to its center.
|
|
550
|
-
* For map, center view on selected picture.
|
|
551
|
-
* For picture, center view on image center.
|
|
552
|
-
* @memberof Panoramax.components.core.PhotoViewer#
|
|
553
|
-
*/
|
|
554
|
-
moveCenter() {
|
|
555
|
-
const meta = this.psv.getPictureMetadata();
|
|
556
|
-
if(!meta) { return; }
|
|
557
|
-
|
|
558
|
-
this._psvAnimate({
|
|
559
|
-
speed: PSV_ANIM_DURATION,
|
|
560
|
-
yaw: 0,
|
|
561
|
-
pitch: 0,
|
|
562
|
-
zoom: PSV_DEFAULT_ZOOM
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* Moves the view of main component slightly to the left.
|
|
568
|
-
* @memberof Panoramax.components.core.PhotoViewer#
|
|
569
|
-
*/
|
|
570
|
-
moveLeft() {
|
|
571
|
-
this._moveToDirection("left");
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
/**
|
|
575
|
-
* Moves the view of main component slightly to the right.
|
|
576
|
-
* @memberof Panoramax.components.core.PhotoViewer#
|
|
577
|
-
*/
|
|
578
|
-
moveRight() {
|
|
579
|
-
this._moveToDirection("right");
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* Moves the view of main component slightly to the top.
|
|
584
|
-
* @memberof Panoramax.components.core.PhotoViewer#
|
|
585
|
-
*/
|
|
586
|
-
moveUp() {
|
|
587
|
-
this._moveToDirection("up");
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
/**
|
|
591
|
-
* Moves the view of main component slightly to the bottom.
|
|
592
|
-
* @memberof Panoramax.components.core.PhotoViewer#
|
|
593
|
-
*/
|
|
594
|
-
moveDown() {
|
|
595
|
-
this._moveToDirection("down");
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* Moves map or picture viewer to given direction.
|
|
600
|
-
* @param {string} dir Direction to move to (up, left, down, right)
|
|
601
|
-
* @private
|
|
602
|
-
*/
|
|
603
|
-
_moveToDirection(dir) {
|
|
604
|
-
let pos = this.psv.getPosition();
|
|
605
|
-
switch(dir) {
|
|
606
|
-
case "up":
|
|
607
|
-
pos.pitch += PSV_MOVE_DELTA;
|
|
608
|
-
break;
|
|
609
|
-
case "left":
|
|
610
|
-
pos.yaw -= PSV_MOVE_DELTA;
|
|
611
|
-
break;
|
|
612
|
-
case "down":
|
|
613
|
-
pos.pitch -= PSV_MOVE_DELTA;
|
|
614
|
-
break;
|
|
615
|
-
case "right":
|
|
616
|
-
pos.yaw += PSV_MOVE_DELTA;
|
|
617
|
-
break;
|
|
618
|
-
}
|
|
619
|
-
this._psvAnimate({ speed: PSV_ANIM_DURATION, ...pos });
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* Overrided PSV animate function to ensure a single animation plays at once.
|
|
624
|
-
* @param {object} options PSV animate options
|
|
625
|
-
* @private
|
|
626
|
-
*/
|
|
627
|
-
_psvAnimate(options) {
|
|
628
|
-
if(this._lastPsvAnim) { this._lastPsvAnim.cancel(); }
|
|
629
|
-
this._lastPsvAnim = this.psv.animate(options);
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
/**
|
|
633
|
-
* Listen to events from this components or one of its sub-components.
|
|
634
|
-
*
|
|
635
|
-
* For example, you can listen to `psv` events using prefix `psv:`.
|
|
636
|
-
*
|
|
637
|
-
* ```js
|
|
638
|
-
* me.addEventListener("psv:picture-loading", doSomething);
|
|
639
|
-
* ```
|
|
640
|
-
* @param {string} type The event type to listen for
|
|
641
|
-
* @param {function} listener The event handler
|
|
642
|
-
* @param {object} [options] [Any original addEventListener available options](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#options)
|
|
643
|
-
* @memberof Panoramax.components.core.PhotoViewer#
|
|
644
|
-
*/
|
|
645
|
-
addEventListener(type, listener, options) {
|
|
646
|
-
super.addEventListener(type, listener, options);
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
customElements.define("pnx-photo-viewer", PhotoViewer);
|