Sha256: ae53fafbd9ef14775768f52f1d342296efd2c874c952bbe950ed2d42c53a0746

Contents?: true

Size: 614 Bytes

Versions: 3

Compression:

Stored size: 614 Bytes

Contents

import { Controller } from '@hotwired/stimulus'

export default class extends Controller {
  static targets = [ "list" ]
  connect() {
    this.element.classList.add("twiddle")

    // If a child facet-value is selected, then expand the node
    if (this.isChildSelected()) {
      this.element.classList.add('twiddle-open')
      this.element.querySelectorAll(':scope > .collapse')
        .forEach((collapsable) => collapsable.classList.add('show'))
    }
  }

  isChildSelected() {
    return this.element.querySelector('span.selected')
  }

  toggle() {
    this.element.classList.toggle("twiddle-open")
  }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-hierarchy-6.4.0 app/assets/javascripts/blacklight/hierarchy/blacklight_hierarchy_controller.js
blacklight-hierarchy-6.3.0 app/assets/javascripts/blacklight/hierarchy/blacklight_hierarchy_controller.js
blacklight-hierarchy-6.2.2 app/assets/javascripts/blacklight/hierarchy/blacklight_hierarchy_controller.js