Spaces:
Running
Running
Update interface.js
Browse files- interface.js +11 -10
interface.js
CHANGED
|
@@ -94,7 +94,7 @@ const currentScriptTag = document.currentScript;
|
|
| 94 |
? `<button id="tooltips-toggle-${instanceId}" class="widget-button tooltips-toggle">β¦Ώ</button>`
|
| 95 |
: '';
|
| 96 |
|
| 97 |
-
// HTML du widget
|
| 98 |
widgetContainer.innerHTML = `
|
| 99 |
<div id="viewer-container-${instanceId}" class="viewer-container">
|
| 100 |
<div id="progress-dialog-${instanceId}" class="progress-dialog">
|
|
@@ -127,11 +127,8 @@ const currentScriptTag = document.currentScript;
|
|
| 127 |
const helpTextDiv = menuContent.querySelector('.help-text');
|
| 128 |
|
| 129 |
// ββ btnRight : false β boutons Γ gauche ββββββββββββββββββββββββββββββββββ
|
| 130 |
-
// Par dΓ©faut les boutons sont Γ droite (comportement original).
|
| 131 |
-
// Si config.btnRight === false, on ajoute la classe btn-left sur viewerContainerElem.
|
| 132 |
if (config.btnRight === false) {
|
| 133 |
viewerContainerElem.classList.add('btn-left');
|
| 134 |
-
// βοΈ Cacher le fullscreen et dΓ©caler les autres boutons
|
| 135 |
fullscreenToggle.style.display = 'none';
|
| 136 |
viewerContainerElem.classList.add('no-fullscreen');
|
| 137 |
}
|
|
@@ -198,7 +195,7 @@ const currentScriptTag = document.currentScript;
|
|
| 198 |
viewerContainerElem.style.display = 'block';
|
| 199 |
|
| 200 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 201 |
-
// 10) Overlay d'annotation
|
| 202 |
// Appended dans widgetContainer β fonctionne en fullscreen natif, fake et normal.
|
| 203 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 204 |
|
|
@@ -230,6 +227,7 @@ const currentScriptTag = document.currentScript;
|
|
| 230 |
annScroll.appendChild(annTitle);
|
| 231 |
annScroll.appendChild(annBody);
|
| 232 |
|
|
|
|
| 233 |
const annFooter = document.createElement('div');
|
| 234 |
annFooter.className = 'ann-footer';
|
| 235 |
const annLinkBtn = document.createElement('button');
|
|
@@ -307,11 +305,14 @@ const currentScriptTag = document.currentScript;
|
|
| 307 |
const { title, description, imgUrl, linkUrl, linkText } = evt.detail || {};
|
| 308 |
|
| 309 |
annTitle.textContent = title || '';
|
|
|
|
|
|
|
| 310 |
annBody.innerHTML = (description || '')
|
| 311 |
.replace(/\\n/g, '<br>')
|
| 312 |
.replace(/\n/g, '<br>');
|
| 313 |
-
|
| 314 |
-
|
|
|
|
| 315 |
|
| 316 |
// Image
|
| 317 |
if (imgUrl) {
|
|
@@ -324,7 +325,7 @@ const currentScriptTag = document.currentScript;
|
|
| 324 |
annImgWrap.style.display = 'none';
|
| 325 |
}
|
| 326 |
|
| 327 |
-
// Bouton lien
|
| 328 |
if (currentLinkUrl) {
|
| 329 |
annLinkBtn.textContent = linkText || 'En savoir plus';
|
| 330 |
annFooter.style.display = 'flex';
|
|
@@ -340,7 +341,7 @@ const currentScriptTag = document.currentScript;
|
|
| 340 |
annCloseBtn.addEventListener('click', (e) => { e.stopPropagation(); hideAnnotation(); });
|
| 341 |
annOverlay.addEventListener('click', (e) => { if (e.target === annOverlay) hideAnnotation(); });
|
| 342 |
|
| 343 |
-
// Lien externe
|
| 344 |
annLinkBtn.addEventListener('click', (e) => {
|
| 345 |
e.stopPropagation();
|
| 346 |
if (currentLinkUrl) window.open(currentLinkUrl, '_blank');
|
|
@@ -591,7 +592,7 @@ const currentScriptTag = document.currentScript;
|
|
| 591 |
});
|
| 592 |
}
|
| 593 |
|
| 594 |
-
// 16) Γchappement
|
| 595 |
document.addEventListener('keydown', (e) => {
|
| 596 |
if ((e.key === 'Escape' || e.key === 'Esc') && isFullscreen) exitFullscreen();
|
| 597 |
});
|
|
|
|
| 94 |
? `<button id="tooltips-toggle-${instanceId}" class="widget-button tooltips-toggle">β¦Ώ</button>`
|
| 95 |
: '';
|
| 96 |
|
| 97 |
+
// HTML du widget
|
| 98 |
widgetContainer.innerHTML = `
|
| 99 |
<div id="viewer-container-${instanceId}" class="viewer-container">
|
| 100 |
<div id="progress-dialog-${instanceId}" class="progress-dialog">
|
|
|
|
| 127 |
const helpTextDiv = menuContent.querySelector('.help-text');
|
| 128 |
|
| 129 |
// ββ btnRight : false β boutons Γ gauche ββββββββββββββββββββββββββββββββββ
|
|
|
|
|
|
|
| 130 |
if (config.btnRight === false) {
|
| 131 |
viewerContainerElem.classList.add('btn-left');
|
|
|
|
| 132 |
fullscreenToggle.style.display = 'none';
|
| 133 |
viewerContainerElem.classList.add('no-fullscreen');
|
| 134 |
}
|
|
|
|
| 195 |
viewerContainerElem.style.display = 'block';
|
| 196 |
|
| 197 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 198 |
+
// 10) Overlay d'annotation
|
| 199 |
// Appended dans widgetContainer β fonctionne en fullscreen natif, fake et normal.
|
| 200 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 201 |
|
|
|
|
| 227 |
annScroll.appendChild(annTitle);
|
| 228 |
annScroll.appendChild(annBody);
|
| 229 |
|
| 230 |
+
// β Footer avec bouton lien β
|
| 231 |
const annFooter = document.createElement('div');
|
| 232 |
annFooter.className = 'ann-footer';
|
| 233 |
const annLinkBtn = document.createElement('button');
|
|
|
|
| 305 |
const { title, description, imgUrl, linkUrl, linkText } = evt.detail || {};
|
| 306 |
|
| 307 |
annTitle.textContent = title || '';
|
| 308 |
+
|
| 309 |
+
// Support des sauts de ligne dans la description
|
| 310 |
annBody.innerHTML = (description || '')
|
| 311 |
.replace(/\\n/g, '<br>')
|
| 312 |
.replace(/\n/g, '<br>');
|
| 313 |
+
|
| 314 |
+
annScroll.scrollTop = 0;
|
| 315 |
+
currentLinkUrl = linkUrl || '';
|
| 316 |
|
| 317 |
// Image
|
| 318 |
if (imgUrl) {
|
|
|
|
| 325 |
annImgWrap.style.display = 'none';
|
| 326 |
}
|
| 327 |
|
| 328 |
+
// Bouton lien β affichΓ© uniquement si linkUrl est dΓ©fini
|
| 329 |
if (currentLinkUrl) {
|
| 330 |
annLinkBtn.textContent = linkText || 'En savoir plus';
|
| 331 |
annFooter.style.display = 'flex';
|
|
|
|
| 341 |
annCloseBtn.addEventListener('click', (e) => { e.stopPropagation(); hideAnnotation(); });
|
| 342 |
annOverlay.addEventListener('click', (e) => { if (e.target === annOverlay) hideAnnotation(); });
|
| 343 |
|
| 344 |
+
// Lien externe β ouvre dans un nouvel onglet
|
| 345 |
annLinkBtn.addEventListener('click', (e) => {
|
| 346 |
e.stopPropagation();
|
| 347 |
if (currentLinkUrl) window.open(currentLinkUrl, '_blank');
|
|
|
|
| 592 |
});
|
| 593 |
}
|
| 594 |
|
| 595 |
+
// 16) Γchappement
|
| 596 |
document.addEventListener('keydown', (e) => {
|
| 597 |
if ((e.key === 'Escape' || e.key === 'Esc') && isFullscreen) exitFullscreen();
|
| 598 |
});
|