Sha256: 54e7cb8ef0db2f41937dcf7cf57ce50871028f34339353111ffd9e50b4268977

Contents?: true

Size: 938 Bytes

Versions: 29

Compression:

Stored size: 938 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

29 entries across 29 versions & 1 rubygems

Version Path
alchemy_cms-6.1.10 package/src/page_publication_fields.js
alchemy_cms-6.1.9 package/src/page_publication_fields.js
alchemy_cms-6.1.8 package/src/page_publication_fields.js
alchemy_cms-6.1.7 package/src/page_publication_fields.js
alchemy_cms-6.1.6 package/src/page_publication_fields.js
alchemy_cms-7.0.0.pre.b package/src/page_publication_fields.js
alchemy_cms-6.1.5 package/src/page_publication_fields.js
alchemy_cms-6.0.14 package/src/page_publication_fields.js
alchemy_cms-6.1.4 package/src/page_publication_fields.js
alchemy_cms-7.0.0.pre.a package/src/page_publication_fields.js
alchemy_cms-6.0.13 package/src/page_publication_fields.js
alchemy_cms-6.1.3 package/src/page_publication_fields.js
alchemy_cms-6.1.2 package/src/page_publication_fields.js
alchemy_cms-6.1.1 package/src/page_publication_fields.js
alchemy_cms-6.1.0 package/src/page_publication_fields.js
alchemy_cms-6.0.12 package/src/page_publication_fields.js
alchemy_cms-6.0.11 package/src/page_publication_fields.js
alchemy_cms-6.0.10 package/src/page_publication_fields.js
alchemy_cms-6.0.9 package/src/page_publication_fields.js
alchemy_cms-6.0.8 package/src/page_publication_fields.js