Tooltip.ts 851 B

12345678910111213141516171819202122232425262728
  1. module INSPECTOR {
  2. /**
  3. * Creates a tooltip for the given html element
  4. */
  5. export class Tooltip {
  6. /** The tooltip is displayed for this element */
  7. private _elem : HTMLElement;
  8. /** The tooltip div */
  9. private _infoDiv : HTMLDivElement;
  10. constructor(elem: HTMLElement, tip:string) {
  11. this._elem = elem;
  12. this._infoDiv = Helpers.CreateDiv('tooltip', this._elem) as HTMLDivElement;
  13. this._elem.addEventListener('mouseover', () => {
  14. this._infoDiv.textContent = tip;
  15. this._infoDiv.style.display = 'block'
  16. });
  17. this._elem.addEventListener('mouseout', () => { this._infoDiv.style.display = 'none'});
  18. }
  19. }
  20. }