context-menu-item.js 646 B

1234567891011121314151617181920212223242526272829303132333435
  1. class ContextMenuItem {
  2. constructor(name, text, action, menuDom) {
  3. this.name = name;
  4. this.text = text;
  5. this.action = action;
  6. this.menuDom = menuDom;
  7. }
  8. render() {
  9. this.dom = DOM.create({ tag: DOM.Tags.Div, cls: 'context-menu-item', innerHTML: this.getText(), attr: { 'data-context-menu-item-name': this.getName() } }, this.menuDom)
  10. .on(DOM.Events.Click, this.getAction());
  11. return this;
  12. }
  13. dispose() {
  14. this.getDom().un(DOM.Events.Click, this.getAction());
  15. return this;
  16. }
  17. getDom() {
  18. return this.dom;
  19. }
  20. getText() {
  21. return this.text;
  22. }
  23. getName() {
  24. return this.name;
  25. }
  26. getAction() {
  27. return this.action;
  28. }
  29. }