« get me outta code hell

client: handle showing/hiding tooltips without internal listeners - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-11-26 19:48:53 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-26 19:57:05 -0400
commit511a26ddff981b866e7ccb6ecb0724c0a67d097e (patch)
tree23a1814621bc4a52230277c492f10a87b132d008
parent0581dd1fbb7cc36cf86d28c1bb0c53264f78b213 (diff)
client: handle showing/hiding tooltips without internal listeners
-rw-r--r--src/static/client3.js39
1 files changed, 5 insertions, 34 deletions
diff --git a/src/static/client3.js b/src/static/client3.js
index a0b0ed2c..58687ecc 100644
--- a/src/static/client3.js
+++ b/src/static/client3.js
@@ -443,11 +443,6 @@ const hoverableTooltipInfo = clientInfo.hoverableTooltipInfo = {
     currentTouchIdentifiers: new Set(),
     touchIdentifiersBanishedByScrolling: new Set(),
   },
-
-  event: {
-    whenTooltipShouldBeShown: [],
-    whenTooltipShouldBeHidden: [],
-  },
 };
 
 // Adds DOM event listeners, so must be called during addPageListeners step.
@@ -856,6 +851,9 @@ function hideCurrentlyShownTooltip(intendingToReplace = false) {
     beginTransitioningTooltipHidden(state.currentlyShownTooltip);
   }
 
+  tooltip.classList.remove('visible');
+  tooltip.inert = true;
+
   state.currentlyShownTooltip = null;
   state.currentlyActiveHoverable = null;
 
@@ -865,8 +863,6 @@ function hideCurrentlyShownTooltip(intendingToReplace = false) {
     state.tooltipWasJustHidden = false;
   });
 
-  dispatchInternalEvent(event, 'whenTooltipShouldBeHidden', {tooltip});
-
   return true;
 }
 
@@ -883,14 +879,14 @@ function showTooltipFromHoverable(hoverable) {
   }
 
   hoverable.classList.add('has-visible-tooltip');
+  tooltip.classList.add('visible');
+  tooltip.inert = false;
 
   state.currentlyShownTooltip = tooltip;
   state.currentlyActiveHoverable = hoverable;
 
   state.tooltipWasJustHidden = false;
 
-  dispatchInternalEvent(event, 'whenTooltipShouldBeShown', {hoverable, tooltip});
-
   return true;
 }
 
@@ -1979,30 +1975,6 @@ function getExternalIconTooltipReferences() {
       .map(span => span.querySelector('span.icons-tooltip'));
 }
 
-function addExternalIconTooltipInternalListeners() {
-  const info = externalIconTooltipInfo;
-
-  hoverableTooltipInfo.event.whenTooltipShouldBeShown.push(({tooltip}) => {
-    if (!info.iconContainers.includes(tooltip)) return;
-    showExternalIconTooltip(tooltip);
-  });
-
-  hoverableTooltipInfo.event.whenTooltipShouldBeHidden.push(({tooltip}) => {
-    if (!info.iconContainers.includes(tooltip)) return;
-    hideExternalIconTooltip(tooltip);
-  });
-}
-
-function showExternalIconTooltip(iconContainer) {
-  iconContainer.classList.add('visible');
-  iconContainer.inert = false;
-}
-
-function hideExternalIconTooltip(iconContainer) {
-  iconContainer.classList.remove('visible');
-  iconContainer.inert = true;
-}
-
 function addExternalIconTooltipPageListeners() {
   const info = externalIconTooltipInfo;
 
@@ -2016,7 +1988,6 @@ function addExternalIconTooltipPageListeners() {
 }
 
 clientSteps.getPageReferences.push(getExternalIconTooltipReferences);
-clientSteps.addInternalListeners.push(addExternalIconTooltipInternalListeners);
 clientSteps.addPageListeners.push(addExternalIconTooltipPageListeners);
 
 /*