Sha256: 6dcbd6a031369c6ff639b0fddb7989a4c54edeb2919aaa335754f149d12177fa

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

import ApplicationController from "signum/controllers/application_controller"

export default class extends ApplicationController {
  static targets = ["alertbellicon", "bellicon", "submenu", "item"]

  connect() {
    this.bounditemActivity = this.itemActivity.bind(this)
    window.addEventListener("nd-item-activity", this.bounditemActivity)

    setTimeout(() => {
      this.manageBellIcon()
    }, 300)
  }

  disconnect() {
    window.removeEventListener("nd-item-activity", this.bounditemActivity)
  }

  show(event) {
    if (this.submenuTarget.children.length > 0) {
      this.submenuTarget.classList.remove("hidden")
    } else {
      this.submenuTarget.classList.add("hidden")
    }
  }

  hide(event) {
    this.submenuTarget.classList.add("hidden")
  }

  itemActivity(event) {
    this.manageBellIcon()

    if (this.submenuTarget.children.length == 0) {
      this.hide(event)
    }
  }

  manageBellIcon() {
    if (this.submenuTarget.children.length > 0) {
      this.alertbelliconTarget.classList.remove("hidden")
      this.belliconTarget.classList.add("hidden")
    } else {
      this.alertbelliconTarget.classList.add("hidden")
      this.belliconTarget.classList.remove("hidden")
    }
  }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
signum-0.5.1 app/components/signum/notification_drawer/component_controller.js
signum-0.5.0 app/components/signum/notification_drawer/component_controller.js
signum-0.4.13 app/components/signum/notification_drawer/component_controller.js
signum-0.4.12 app/components/signum/notification_drawer/component_controller.js
signum-0.4.11 app/components/signum/notification_drawer/component_controller.js
signum-0.4.10 app/components/signum/notification_drawer/component_controller.js
signum-0.4.8 app/components/signum/notification_drawer/component_controller.js