loader/src/js/elements/tooltip/BaseTooltip.js
Llewellyn van der Merwe d9f5a1aebc
Implement enhanced UI elements with library detection and fallback
- Add modal implementation with automatic detection for four specific libraries.
- Introduce inline tooltips with library compatibility.
- Implement a default stand-alone fallback for environments without supported libraries.
2023-11-20 16:29:47 +02:00

25 lines
806 B
JavaScript

export class BaseTooltip {
/**
* Creates a new BaseTooltip instance.
*
* @param {HTMLElement} triggerElement - The elements that triggers the tooltip.
*/
constructor(triggerElement) {
this.triggerElement = triggerElement;
this.triggerElement.style.cursor = 'help';
}
/**
* Loads content into the tooltip. If the trigger elements already has a title,
* the new content is appended to it.
*
* @param {string} content - The content to load into the tooltip.
* @throws {Error} Throws an error if the trigger elements is not valid.
*/
load(content) {
const existingTitle = this.triggerElement.getAttribute('title');
const newTitle = existingTitle ? existingTitle + "\n" + content : content;
this.triggerElement.setAttribute('title', newTitle);
}
}