Sha256: d04b22e1aebddc150b815efed06f9f9b0b9a095b6ff4162cba9265ecca614444

Contents?: true

Size: 790 Bytes

Versions: 3

Compression:

Stored size: 790 Bytes

Contents

// Visibility toggle for items in an exhibit, based on Blacklight's bookmark toggle
// See: https://github.com/projectblacklight/blacklight/blob/main/app/javascript/blacklight/bookmark_toggle.js

import CheckboxSubmit from 'checkbox_submit'

const VisibilityToggle = (e) => {
  if (e.target.matches('[data-checkboxsubmit-target="checkbox"]')) {
    const form = e.target.closest('form')
    if (form) {
      new CheckboxSubmit(form).clicked(e)

      // Add/remove the "private" label to the document row when visibility is toggled
      const docRow = form.closest('tr')
      if (docRow) docRow.classList.toggle('blacklight-private')
    }
  }
}

VisibilityToggle.selector = 'form.visibility-toggle'

document.addEventListener('click', VisibilityToggle)

export default VisibilityToggle

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-spotlight-3.6.0.beta4 app/javascript/spotlight/admin/visibility_toggle.es6
blacklight-spotlight-3.6.0.beta3 app/javascript/spotlight/admin/visibility_toggle.es6
blacklight-spotlight-3.6.0.beta1 app/javascript/spotlight/admin/visibility_toggle.es6