From 59e45ec4b19b41dab5d374a2355c4d7c6dc9f545 Mon Sep 17 00:00:00 2001 From: mlnkng Date: Mon, 1 Apr 2024 13:35:33 -0700 Subject: [PATCH] Fix tooltips for BS5 (#1777) --- lib/QubitDescription.class.php | 19 ++++++++++++++++++- plugins/arDominionB5Plugin/js/tooltip.js | 23 ++++++++++++++++++----- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/lib/QubitDescription.class.php b/lib/QubitDescription.class.php index 817430ee3c..6f7fe0b2b2 100644 --- a/lib/QubitDescription.class.php +++ b/lib/QubitDescription.class.php @@ -24,7 +24,24 @@ public static function addAssets(sfWebResponse $response) if (sfConfig::get('app_show_tooltips')) { $response->addJavaScript('description', 'last'); } else { - $response->addStylesheet('hide_tooltips', 'last'); + if (sfConfig::get('app_b5_theme')) { ?> + + addStylesheet('hide_tooltips', 'last'); + } } } } diff --git a/plugins/arDominionB5Plugin/js/tooltip.js b/plugins/arDominionB5Plugin/js/tooltip.js index ab5485310c..9b0e239226 100644 --- a/plugins/arDominionB5Plugin/js/tooltip.js +++ b/plugins/arDominionB5Plugin/js/tooltip.js @@ -1,5 +1,18 @@ -import Tooltip from "bootstrap/js/dist/tooltip"; - -document - .querySelectorAll("[data-bs-toggle=tooltip]") - .forEach((element) => new Tooltip(element)); +document.addEventListener("DOMContentLoaded", function () { + if ( + window.location.pathname.endsWith("/add") || + window.location.pathname.endsWith("/edit") + ) { + var elements = document.querySelectorAll('[id$="-help"]'); + elements.forEach(function (idElement) { + idElement.style.display = "none"; + parentElement = idElement.previousElementSibling; + if (parentElement != null) { + parentElement.setAttribute("data-bs-toggle", "tooltip"); + parentElement.setAttribute("data-bs-placement", "left"); + parentElement.setAttribute("title", idElement.textContent.trim()); + var tooltip = new bootstrap.Tooltip(parentElement); + } + }); + } +});