From 156fedd87a6d2afe8a5a2dbbd86e1af40a9eaded Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Mar 2026 13:09:33 +0100 Subject: [PATCH] Restore old code until we found pb of js regression --- htdocs/core/js/lib_initTooltips.js | 53 +++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/htdocs/core/js/lib_initTooltips.js b/htdocs/core/js/lib_initTooltips.js index 7ae8af231c6..7fdc870480c 100644 --- a/htdocs/core/js/lib_initTooltips.js +++ b/htdocs/core/js/lib_initTooltips.js @@ -45,6 +45,10 @@ function initAjaxTooltips(root, baseUrl) { const $storeElem = jQuery("#dialogforpopup"); const currentToken = jQuery("meta[name=anti-csrf-currenttoken]").attr("content"); + /* New code for ajax tooltips */ + /* Commented and restored the old one, because the new one generates 3 troubles: + tooltips flashes when appearing + Double output + the tooltip "tocomplete" also appears and disappears quickly + Pb seems due to the addition of ".ajaxTooltip" after "mouseover" or "mouseout" $elements.each(function () { const $el = jQuery(this); @@ -61,6 +65,8 @@ function initAjaxTooltips(root, baseUrl) { $el.off("mouseover.ajaxTooltip mouseout.ajaxTooltip"); $el.on("mouseover.ajaxTooltip", function (event) { + console.log("on mouseover.ajaxTooltip we will create timer for ajax call"); + event.stopImmediatePropagation(); clearTimeout($storeElem.data("openTimeoutId")); @@ -86,11 +92,57 @@ function initAjaxTooltips(root, baseUrl) { }); $el.on("mouseout.ajaxTooltip", function (event) { + console.log("mouse out of a .classforajaxtooltip"); + event.stopImmediatePropagation(); clearTimeout($storeElem.data("openTimeoutId")); $elements.tooltip("close"); }); }); + */ + /* Old code for ajax tooltip */ + //$elements = jQuery(".classforajaxtooltip"); + $elements.tooltip({ + tooltipClass: "mytooltip", + show: { collision: "flipfit", effect:"toggle", delay: 0, duration: 20 }, + hide: { delay: 250, duration: 20 } + }); + + $elements.off("mouseover mouseout"); + + $elements.on("mouseover", function(event) { + console.log("we will create timer for ajax call"); + event.stopImmediatePropagation(); + clearTimeout($storeElem.data("openTimeoutId")); + + var params = JSON.parse($(this).attr("data-params")); + params.token = currentToken; + var elemfortooltip = $(this); + + $storeElem.data("openTimeoutId", setTimeout(function() { + $elements.tooltip("close"); + $.ajax({ + url: baseUrl + "/core/ajax/ajaxtooltip.php", + type: "post", + async: true, + data: params, + success: function(response){ + // Setting content option + console.log("ajax success"); + if (elemfortooltip.is(":hover")) { + elemfortooltip.tooltip("option","content",response); + elemfortooltip.tooltip("open"); + } + } + }); + }, openDelay)); + }); + $elements.on("mouseout", function(event) { + console.log("mouse out of a .classforajaxtooltip"); + event.stopImmediatePropagation(); + clearTimeout($storeElem.data("openTimeoutId")); + $elements.tooltip("close"); + }); } /** @@ -141,7 +193,6 @@ function initTooltipDialogs(root, dialogWidth) { $trigger.off("click.tooltipDialog"); $trigger.on("click.tooltipDialog", function () { - const dolid = jQuery(this).attr("dolid"); if (!dolid) return false;