/** * A tooltip is a kind of popover which is displayed as a hint regarding an action the user is looking at or performing. * Tooltips usually only contain text. */ class Tooltip extends Popover { /** * Creates and returns a new generic tooltip with the given HTML content. */ static createTooltip(id) { if (!id) { console.error("You must provide an ID when creating a tooltip."); } var tooltipElement = document.createElement("TOOLTIP"); tooltipElement.setAttribute("id", id); var tooltip = new Tooltip(tooltipElement); return tooltip; } /** * The constructor accepts a DOM element as a parameter. This is the content view of the popover. */ constructor(element = null) { super(element); //Tooltips should not disable the background when they are shown. this.disableBackground = false; //The delay in seconds that is awaited before auto-hiding the tooltip. this.hideDelay = 2; } /** * The build function is called in the constructor when no element was passed as the base. * Override it to create custom subviews or manipulate the root element. * Don't forget to return the element in the end! */ build(element) { return element; } /** * Updates the content of this tooltip. */ setText(text) { this.contentElement.innerHTML = "" + text + ""; if (this.pointingElement) { this.pointAtElement(this.pointingElement, this.side); } else if (this.pointingPosition) { this.pointToPosition(this.pointingPosition.x, this.pointingPosition.y, this.side); } } } UIKit.registerPopoverType(Tooltip, "tooltip");