AbstractTreeTool.ts 875 B

12345678910111213141516171819202122232425262728293031323334
  1. module INSPECTOR {
  2. export abstract class AbstractTreeTool {
  3. protected _elem: HTMLElement;
  4. /** Is the tool enabled ? */
  5. protected _on : boolean = false;
  6. constructor() {
  7. this._elem = Inspector.DOCUMENT.createElement('i');
  8. this._elem.className = 'treeTool fa';
  9. this._addEvents();
  10. }
  11. public toHtml() : HTMLElement {
  12. return this._elem;
  13. }
  14. protected _addEvents() {
  15. this._elem.addEventListener('click', (e) => {
  16. this.action();
  17. e.stopPropagation();
  18. });
  19. }
  20. /**
  21. * Action launched when clicked on this element
  22. * Should be overrided
  23. */
  24. protected action() {
  25. this._on = !this._on;
  26. }
  27. }
  28. }