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.3.4 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.3.3 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.3.2 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.2.7 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.3.1 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.3.0 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.2.6 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.2.5 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.12 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.0.15 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.2.4 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.11 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.2.3 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.10 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.2.2 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.9 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.0.14 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.2.1 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.0.13 app/javascript/alchemy_admin/page_publication_fields.js
alchemy_cms-7.1.8 app/javascript/alchemy_admin/page_publication_fields.js