MikaFil commited on
Commit
7501d3b
Β·
verified Β·
1 Parent(s): 26e5c74

Update interface.js

Browse files
Files changed (1) hide show
  1. 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
- <button id="tooltips-toggle-${instanceId}" class="widget-button tooltips-toggle">β¦Ώ</button>
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 (!config.tooltips_url) {
192
- tooltipsToggleBtn.style.display = 'none';
193
- } else {
194
- fetch(config.tooltips_url)
195
- .then(resp => {
196
- if (!resp.ok) {
 
 
 
 
 
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
  }