Sha256: b64d114338869f3d1cf0520a5083d67f137a5eb7e1b43c50baafc3decb9ec52b

Contents?: true

Size: 1.1 KB

Versions: 14

Compression:

Stored size: 1.1 KB

Contents

import classic from "ember-classic-decorator";
import { tagName } from "@ember-decorators/component";
import Component from "@ember/component";
import { bound } from "client-app/lib/decorators";
import { action } from "@ember/object";

@classic
@tagName("span")
export default class ActionsMenu extends Component {
  showMenu = false;

  willDestroyElement() {
    super.willDestroyElement(...arguments);
    this.removeOutsideClickHandler();
  }

  @bound
  outsideClickHandler(event) {
    if (
      this.element &&
      !this.element.contains(event.target) &&
      this.element !== event.target
    ) {
      this.set("showMenu", false);
      this.updateMenu();
    }
  }

  updateMenu() {
    if (this.showMenu) {
      this.addOutsideClickHandler();
    } else {
      this.removeOutsideClickHandler();
    }
  }

  addOutsideClickHandler() {
    document.addEventListener("click", this.outsideClickHandler);
  }

  removeOutsideClickHandler() {
    document.removeEventListener("click", this.outsideClickHandler);
  }

  @action
  expandMenu() {
    this.toggleProperty("showMenu");
    this.updateMenu();
  }
}

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
logster-2.20.0 client-app/app/components/actions-menu.js
logster-2.19.1 client-app/app/components/actions-menu.js
logster-2.19.0 client-app/app/components/actions-menu.js
logster-2.18.1 client-app/app/components/actions-menu.js
logster-2.18.0 client-app/app/components/actions-menu.js
logster-2.17.1 client-app/app/components/actions-menu.js
logster-2.17.0 client-app/app/components/actions-menu.js
logster-2.16.0 client-app/app/components/actions-menu.js
logster-2.15.0 client-app/app/components/actions-menu.js
logster-2.14.0 client-app/app/components/actions-menu.js
logster-2.13.1 client-app/app/components/actions-menu.js
logster-2.13.0 client-app/app/components/actions-menu.js
logster-2.12.2 client-app/app/components/actions-menu.js
logster-2.12.1 client-app/app/components/actions-menu.js