mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°2847 - Tooltip: Improve mechanism to instantiate them only once
This commit is contained in:
@@ -70,7 +70,7 @@ const CombodoBackofficeToolbox = {
|
||||
// Processing
|
||||
$(document).ready(function(){
|
||||
// Enable tooltips based on existing HTML markup, won't work on markup added dynamically after DOM ready (AJAX, ...)
|
||||
$('[data-tooltip-content]').each(function(){
|
||||
$('[data-tooltip-content]:not([data-tooltip-instanciated="true"])').each(function(){
|
||||
CombodoGlobalToolbox.InitTooltipFromMarkup($(this));
|
||||
});
|
||||
});
|
||||
14
js/utils.js
14
js/utils.js
@@ -813,15 +813,22 @@ const CombodoGlobalToolbox = {
|
||||
*
|
||||
* Note: Content SHOULD be HTML entity encoded to avoid markup breaks (eg. when using a double quote in a sentence)
|
||||
*
|
||||
* @param oElem
|
||||
* @param {Object} oElem The jQuery object representing the element
|
||||
* @param {boolean} bForce When set to true, tooltip will be instanciate even if one already exists, overwritting it.
|
||||
* @constructor
|
||||
*/
|
||||
InitTooltipFromMarkup: function(oElem)
|
||||
InitTooltipFromMarkup: function(oElem, bForce = false)
|
||||
{
|
||||
const oOptions = {
|
||||
allowHTML: true, // Always true so line breaks can work. Don't worry content will be sanitized.
|
||||
};
|
||||
|
||||
// First, check if the tooltip isn't already instanciated
|
||||
if((oElem.attr('data-tooltip-instanciated') === 'true') && (bForce === false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Content must be reworked before getting into the tooltip
|
||||
// - Should we enable HTML content or keep text as is
|
||||
const bEnableHTML = oElem.attr('data-tooltip-html-enabled') === 'true';
|
||||
@@ -870,5 +877,8 @@ const CombodoGlobalToolbox = {
|
||||
];
|
||||
|
||||
tippy(oElem[0], oOptions);
|
||||
|
||||
// Mark tooltip as instanciated
|
||||
oElem.attr('data-tooltip-instanciated', 'true');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user