@panoramax/web-viewer 4.0.3-develop-dd0778d7 → 4.0.3-develop-cdb08f04
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/CHANGELOG.md +2 -0
- package/build/index.css +1 -1
- package/build/index.css.map +1 -1
- package/build/index.js +29 -9
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ui/AnnotationsSwitch.js +54 -9
- package/src/components/ui/Photo.css +3 -2
- package/src/components/ui/Photo.js +1 -0
- package/src/translations/en.json +1 -1
- package/src/translations/fr.json +1 -1
package/package.json
CHANGED
|
@@ -3,6 +3,10 @@ import { fa } from "../../utils/widgets";
|
|
|
3
3
|
import { faTags } from "@fortawesome/free-solid-svg-icons/faTags";
|
|
4
4
|
import { faTriangleExclamation } from "@fortawesome/free-solid-svg-icons/faTriangleExclamation";
|
|
5
5
|
import { hasAnnotations } from "../../utils/picture";
|
|
6
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
7
|
+
import { panel } from "../styles";
|
|
8
|
+
|
|
9
|
+
const DISABLE_ANNOTATIONS_PARAM = "pnx-disable-annotations";
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* AnnotationsSwitch component allows to switch on/off pictures annotations.
|
|
@@ -16,7 +20,14 @@ import { hasAnnotations } from "../../utils/picture";
|
|
|
16
20
|
*/
|
|
17
21
|
export default class AnnotationsSwitch extends LitElement {
|
|
18
22
|
/** @private */
|
|
19
|
-
static styles = css`
|
|
23
|
+
static styles = [ panel, css`
|
|
24
|
+
.pnx-panel {
|
|
25
|
+
padding: 5px;
|
|
26
|
+
margin-top: 5px;
|
|
27
|
+
width: max-content;
|
|
28
|
+
min-width: unset;
|
|
29
|
+
}
|
|
30
|
+
|
|
20
31
|
/* Custom button look */
|
|
21
32
|
pnx-button::part(btn) {
|
|
22
33
|
border-radius: 8px;
|
|
@@ -30,6 +41,13 @@ export default class AnnotationsSwitch extends LitElement {
|
|
|
30
41
|
width: 38px;
|
|
31
42
|
}
|
|
32
43
|
|
|
44
|
+
pnx-button[active]::part(btn),
|
|
45
|
+
pnx-button[active]:hover::part(btn) {
|
|
46
|
+
background-color: var(--widget-bg-active) !important;
|
|
47
|
+
border-color: var(--widget-bg-active) !important;
|
|
48
|
+
color: var(--widget-font-active) !important;
|
|
49
|
+
}
|
|
50
|
+
|
|
33
51
|
/* No-annotations badge */
|
|
34
52
|
.pnx-annotations-switch-empty {
|
|
35
53
|
position: absolute;
|
|
@@ -48,7 +66,7 @@ export default class AnnotationsSwitch extends LitElement {
|
|
|
48
66
|
pnx-button[active] .pnx-annotations-switch-empty {
|
|
49
67
|
color: var(--yellow);
|
|
50
68
|
}
|
|
51
|
-
|
|
69
|
+
`];
|
|
52
70
|
|
|
53
71
|
/**
|
|
54
72
|
* Component properties.
|
|
@@ -61,12 +79,14 @@ export default class AnnotationsSwitch extends LitElement {
|
|
|
61
79
|
size: {type: String},
|
|
62
80
|
_annotationsToggled: {state: true},
|
|
63
81
|
_warnNoAnnot: {state: true},
|
|
82
|
+
_warnNoAnnotTooltip: {state: true},
|
|
64
83
|
};
|
|
65
84
|
|
|
66
85
|
constructor() {
|
|
67
86
|
super();
|
|
68
87
|
this._annotationsToggled = false;
|
|
69
88
|
this._warnNoAnnot = false;
|
|
89
|
+
this._warnNoAnnotTooltip = false;
|
|
70
90
|
this.size = "xl";
|
|
71
91
|
}
|
|
72
92
|
|
|
@@ -74,9 +94,13 @@ export default class AnnotationsSwitch extends LitElement {
|
|
|
74
94
|
connectedCallback() {
|
|
75
95
|
super.connectedCallback();
|
|
76
96
|
|
|
97
|
+
// Check if annotations have been explicitly disabled
|
|
98
|
+
const annotsDisabled = localStorage.getItem(DISABLE_ANNOTATIONS_PARAM) === "true";
|
|
99
|
+
|
|
77
100
|
this._parent.onceReady().then(() => {
|
|
78
101
|
this._parent.psv.addEventListener("annotations-toggled", e => {
|
|
79
102
|
this._annotationsToggled = e.detail.visible;
|
|
103
|
+
this._persistAnnotationsLocalStorage(this._annotationsToggled);
|
|
80
104
|
});
|
|
81
105
|
|
|
82
106
|
this._warnNoAnnot = !hasAnnotations(this._parent.psv.getPictureMetadata());
|
|
@@ -88,36 +112,57 @@ export default class AnnotationsSwitch extends LitElement {
|
|
|
88
112
|
this._parent.onceFirstPicLoaded().then(() => {
|
|
89
113
|
this._annotationsToggled = this._parent.psv.areAnnotationsVisible() || false;
|
|
90
114
|
|
|
91
|
-
if(!this._annotationsToggled) {
|
|
115
|
+
if(!this._annotationsToggled && !annotsDisabled) {
|
|
92
116
|
this._parent.psv.toggleAllAnnotations(true);
|
|
93
117
|
this._annotationsToggled = true;
|
|
94
118
|
}
|
|
119
|
+
this._persistAnnotationsLocalStorage(this._annotationsToggled);
|
|
95
120
|
});
|
|
96
121
|
}
|
|
97
122
|
|
|
123
|
+
/** @private */
|
|
124
|
+
_persistAnnotationsLocalStorage(isAnnotToggled) {
|
|
125
|
+
console.log("save", isAnnotToggled);
|
|
126
|
+
localStorage.setItem(DISABLE_ANNOTATIONS_PARAM, isAnnotToggled ? "false": "true");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** @private */
|
|
98
130
|
_onClick() {
|
|
131
|
+
if(!this._annotationsToggled && this._warnNoAnnot) {
|
|
132
|
+
this._warnNoAnnotTooltip = true;
|
|
133
|
+
setTimeout(() => this._warnNoAnnotTooltip = false, 2000);
|
|
134
|
+
}
|
|
135
|
+
this._persistAnnotationsLocalStorage(!this._annotationsToggled);
|
|
99
136
|
this._parent.psv.toggleAllAnnotations(!this._annotationsToggled);
|
|
100
137
|
}
|
|
101
138
|
|
|
102
139
|
/** @private */
|
|
103
140
|
render() {
|
|
104
141
|
/* eslint-disable indent */
|
|
142
|
+
const panelClasses = {
|
|
143
|
+
"pnx-panel": true,
|
|
144
|
+
"pnx-hidden": !this._warnNoAnnotTooltip,
|
|
145
|
+
};
|
|
146
|
+
|
|
105
147
|
return html`
|
|
106
148
|
<pnx-button
|
|
107
|
-
kind="
|
|
149
|
+
kind="superflat"
|
|
108
150
|
size=${this.size}
|
|
109
151
|
style="vertical-align: middle"
|
|
110
152
|
class="pnx-print-hidden"
|
|
111
|
-
title=${
|
|
112
|
-
this._annotationsToggled ? this._parent._t?.pnx.semantics_hide_annotations : this._parent._t?.pnx.semantics_show_annotations,
|
|
113
|
-
this._warnNoAnnot ? this._parent._t?.pnx.semantics_zero_annotations : null
|
|
114
|
-
].filter(v => v).join(" ")}
|
|
153
|
+
title=${this._annotationsToggled ? this._parent._t?.pnx.semantics_hide_annotations : this._parent._t?.pnx.semantics_show_annotations}
|
|
115
154
|
active=${this._annotationsToggled ? "" : nothing}
|
|
116
155
|
@click=${this._onClick}
|
|
117
156
|
>
|
|
118
|
-
${fa(faTags, { styles: { "height": "
|
|
157
|
+
${fa(faTags, { styles: { "height": "20px" }})}
|
|
119
158
|
${this._warnNoAnnot ? fa(faTriangleExclamation, { classes: "pnx-annotations-switch-empty" }) : nothing}
|
|
120
159
|
</pnx-button>
|
|
160
|
+
<div
|
|
161
|
+
class=${classMap(panelClasses)}
|
|
162
|
+
@click=${() => this._warnNoAnnotTooltip = false}
|
|
163
|
+
>
|
|
164
|
+
${this._parent._t?.pnx.semantics_zero_annotations}
|
|
165
|
+
</div>
|
|
121
166
|
`;
|
|
122
167
|
}
|
|
123
168
|
}
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
display: none;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
/* No virtual tour arrows if photo is reduced */
|
|
47
|
-
pnx-mini .psv-virtual-tour-arrows
|
|
46
|
+
/* No virtual tour arrows or annotations if photo is reduced */
|
|
47
|
+
pnx-mini .psv-virtual-tour-arrows,
|
|
48
|
+
pnx-mini .pnx-psv-annotation {
|
|
48
49
|
display: none;
|
|
49
50
|
}
|
package/src/translations/en.json
CHANGED
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
"semantics_qualifiers": "Qualifiers",
|
|
193
193
|
"semantics_show_annotations": "Display picture annotations",
|
|
194
194
|
"semantics_hide_annotations": "Hide picture annotations",
|
|
195
|
-
"semantics_zero_annotations": "
|
|
195
|
+
"semantics_zero_annotations": "No annotation set on this picture",
|
|
196
196
|
"semantics_hashtags": "Picture hashtags",
|
|
197
197
|
"semantics_wikidata_properties": {
|
|
198
198
|
"P31": "instance of",
|
package/src/translations/fr.json
CHANGED
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
"semantics_qualifiers": "Qualificateurs",
|
|
193
193
|
"semantics_show_annotations": "Afficher les annotations de photo",
|
|
194
194
|
"semantics_hide_annotations": "Masquer les annotations de photo",
|
|
195
|
-
"semantics_zero_annotations": "
|
|
195
|
+
"semantics_zero_annotations": "Aucune annotation sur cette image",
|
|
196
196
|
"semantics_hashtags": "Mots-dièse de la photo",
|
|
197
197
|
"semantics_wikidata_properties": {
|
|
198
198
|
"P31": "instance de",
|