Add helper to create tooltip singleton

This commit is contained in:
Stephen Abello
2021-08-25 14:32:23 +02:00
parent f5ae76360e
commit 0f204f94eb

View File

@@ -878,6 +878,25 @@ const CombodoTooltip = {
oContainerElem.find('[data-tooltip-content]' + (bForce ? '' : ':not([data-tooltip-instantiated="true"])')).each(function () {
CombodoTooltip.InitTooltipFromMarkup($(this), bForce);
});
},
/**
* Instantiate a singleton for tooltips of elements matching sSelector.
* Used to guarantee that tooltips from said selector elements won't show at same time.
* Require selector elements tooltips to be instantiated before.
*
* @param {string} sSelector jQuery selector used to get elements tooltips
*/
InitSingletonFromSelector: function (sSelector) {
let oTippyInstances = [];
$(sSelector).each(function(){
if($(this)[0]._tippy !== undefined){
oTippyInstances.push($(this)[0]._tippy);
}
});
let aOptions = {
moveTransition: 'transform 0.2s ease-out',
}
tippy.createSingleton(oTippyInstances, $.extend(aOptions, oTippyInstances[0].props));
}
};