Sha256: 409020d7ca9230c996829ab7bacbb34eec8f506786e800ad6b1b5ea7d3aa27c0

Contents?: true

Size: 939 Bytes

Versions: 46

Compression:

Stored size: 939 Bytes

Contents

// Handles the page publication date fields
export default function () {
  document.addEventListener("DialogReady.Alchemy", function (evt) {
    const dialog = evt.detail.body
    const public_on_field = dialog.querySelector("#page_public_on")
    const public_until_field = dialog.querySelector("#page_public_until")
    const publication_date_fields = dialog.querySelector(
      ".page-publication-date-fields"
    )
    const public_field = dialog.querySelector("#page_public")

    if (!public_field) return

    public_field.addEventListener("click", function (evt) {
      const checkbox = evt.target
      const now = new Date()

      if (checkbox.checked) {
        publication_date_fields.classList.remove("hidden")
        public_on_field._flatpickr.setDate(now)
      } else {
        publication_date_fields.classList.add("hidden")
        public_on_field.value = ""
      }
      public_until_field.value = ""
    })
  })
}

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
alchemy_cms-7.1.7 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.0.12 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.0.11 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.6 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.5 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.0.10 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.4 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.0.9 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.3 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.2 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.1 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.0 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.0.pre.rc1 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.0.pre.b2 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.0.pre.b1 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.0.8 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.0.7 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.0.6 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.0.5 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.0.4 app/javascript/alchemy_admin/page_publication_fields.js