Sha256: 13cf5c9ac7feb67d75a0f3546eb1690ac96c93e04bb6befffbbaccfe76209868

Contents?: true

Size: 970 Bytes

Versions: 4

Compression:

Stored size: 970 Bytes

Contents

import ApplicationController from './application_controller'

export default class extends ApplicationController {
  static outlets = ['mobile-sidebar']

  initialize () {
    this.boundStopAnimating = this.stopAnimating.bind(this)
  }

  connect () {
    this.element.addEventListener('transitionend', this.boundStopAnimating)
  }

  disconnect () {
    this.element.removeEventListener('transitionend', this.boundStopAnimating)
  }

  animate () {
    this.element.classList.add('animate')
  }

  stopAnimating () {
    this.element.classList.remove('animate')
  }

  hideMobileSidebar (e) {
    const sidebarController = this.mobileSidebarOutlet

    if (!sidebarController.isExpanded) {
      return
    }

    const clickInHeader = e.target.closest('.app-header')
    const clickInSidebar = e.target.closest('.app-sidebar')

    if (!clickInHeader && !clickInSidebar) {
      e.stopPropagation()
      e.preventDefault()

      sidebarController.hide()
    }
  }
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trestle-0.10.1 frontend/js/controllers/wrapper_controller.js
trestle-0.10.0 frontend/js/controllers/wrapper_controller.js
trestle-0.10.0.pre2 frontend/js/controllers/wrapper_controller.js
trestle-0.10.0.pre frontend/js/controllers/wrapper_controller.js