Spaces:
Running
Running
Update interface.js
Browse files- interface.js +21 -14
interface.js
CHANGED
|
@@ -80,6 +80,11 @@ const currentScriptTag = document.currentScript;
|
|
| 80 |
widgetContainer.style.paddingBottom = aspectPercent;
|
| 81 |
widgetContainer.setAttribute('data-original-aspect', aspectPercent);
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
// Add the 3D-viewer HTML + β¦Ώ toggle + tooltip + help HTML
|
| 84 |
widgetContainer.innerHTML = `
|
| 85 |
<div id="viewer-container-${instanceId}" class="viewer-container">
|
|
@@ -91,7 +96,7 @@ const currentScriptTag = document.currentScript;
|
|
| 91 |
<button id="reset-camera-btn-${instanceId}" class="widget-button reset-camera-btn">
|
| 92 |
<span class="reset-icon">β²</span>
|
| 93 |
</button>
|
| 94 |
-
|
| 95 |
<div id="menu-content-${instanceId}" class="menu-content">
|
| 96 |
<span id="help-close-${instanceId}" class="help-close">Γ</span>
|
| 97 |
<div class="help-text"></div>
|
|
@@ -188,18 +193,20 @@ const currentScriptTag = document.currentScript;
|
|
| 188 |
const canvasEl = document.getElementById(canvasId);
|
| 189 |
|
| 190 |
// βββ 8. Conditional display of tooltips-toggle button βββββββββββββββββββββββββ
|
| 191 |
-
if (
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
tooltipsToggleBtn.style.display = 'none';
|
| 198 |
-
}
|
| 199 |
-
|
| 200 |
-
.catch(() => {
|
| 201 |
-
tooltipsToggleBtn.style.display = 'none';
|
| 202 |
-
});
|
| 203 |
}
|
| 204 |
|
| 205 |
// βββ 9. Fullscreen / state-preservation logic βββββββββββββββββββββββββββββββ
|
|
@@ -434,9 +441,9 @@ const currentScriptTag = document.currentScript;
|
|
| 434 |
}
|
| 435 |
});
|
| 436 |
|
| 437 |
-
// β¦Ώ toggle button
|
| 438 |
let tooltipsVisible = !!config.showTooltipsDefault;
|
| 439 |
-
if (tooltipsToggleBtn.style.display !== 'none') {
|
| 440 |
if (!tooltipsVisible) {
|
| 441 |
tooltipsToggleBtn.style.opacity = '0.5';
|
| 442 |
}
|
|
|
|
| 80 |
widgetContainer.style.paddingBottom = aspectPercent;
|
| 81 |
widgetContainer.setAttribute('data-original-aspect', aspectPercent);
|
| 82 |
|
| 83 |
+
// Conditionally include the βtooltips-toggleβ button only if config.tooltips_url is defined and non-empty
|
| 84 |
+
const tooltipsButtonHTML = config.tooltips_url
|
| 85 |
+
? `<button id="tooltips-toggle-${instanceId}" class="widget-button tooltips-toggle">β¦Ώ</button>`
|
| 86 |
+
: '';
|
| 87 |
+
|
| 88 |
// Add the 3D-viewer HTML + β¦Ώ toggle + tooltip + help HTML
|
| 89 |
widgetContainer.innerHTML = `
|
| 90 |
<div id="viewer-container-${instanceId}" class="viewer-container">
|
|
|
|
| 96 |
<button id="reset-camera-btn-${instanceId}" class="widget-button reset-camera-btn">
|
| 97 |
<span class="reset-icon">β²</span>
|
| 98 |
</button>
|
| 99 |
+
${tooltipsButtonHTML}
|
| 100 |
<div id="menu-content-${instanceId}" class="menu-content">
|
| 101 |
<span id="help-close-${instanceId}" class="help-close">Γ</span>
|
| 102 |
<div class="help-text"></div>
|
|
|
|
| 193 |
const canvasEl = document.getElementById(canvasId);
|
| 194 |
|
| 195 |
// βββ 8. Conditional display of tooltips-toggle button βββββββββββββββββββββββββ
|
| 196 |
+
if (tooltipsToggleBtn) {
|
| 197 |
+
if (!config.tooltips_url) {
|
| 198 |
+
tooltipsToggleBtn.style.display = 'none';
|
| 199 |
+
} else {
|
| 200 |
+
fetch(config.tooltips_url)
|
| 201 |
+
.then(resp => {
|
| 202 |
+
if (!resp.ok) {
|
| 203 |
+
tooltipsToggleBtn.style.display = 'none';
|
| 204 |
+
}
|
| 205 |
+
})
|
| 206 |
+
.catch(() => {
|
| 207 |
tooltipsToggleBtn.style.display = 'none';
|
| 208 |
+
});
|
| 209 |
+
}
|
|
|
|
|
|
|
|
|
|
| 210 |
}
|
| 211 |
|
| 212 |
// βββ 9. Fullscreen / state-preservation logic βββββββββββββββββββββββββββββββ
|
|
|
|
| 441 |
}
|
| 442 |
});
|
| 443 |
|
| 444 |
+
// β¦Ώ toggle button: only if it exists in the DOM
|
| 445 |
let tooltipsVisible = !!config.showTooltipsDefault;
|
| 446 |
+
if (tooltipsToggleBtn && tooltipsToggleBtn.style.display !== 'none') {
|
| 447 |
if (!tooltipsVisible) {
|
| 448 |
tooltipsToggleBtn.style.opacity = '0.5';
|
| 449 |
}
|