From a249607308255027e71a4a5d607b54401980e6f8 Mon Sep 17 00:00:00 2001 From: Antonio Facciolo Date: Fri, 18 Mar 2022 11:46:42 +0100 Subject: [PATCH] check presence of page_public checkbox --- package/src/page_publication_fields.js | 29 +++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/package/src/page_publication_fields.js b/package/src/page_publication_fields.js index 9da85df92c..888863167a 100644 --- a/package/src/page_publication_fields.js +++ b/package/src/page_publication_fields.js @@ -7,21 +7,22 @@ export default function () { const publication_date_fields = dialog.querySelector( ".page-publication-date-fields" ) + const public_field = dialog.querySelector("#page_public") - dialog - .querySelector("#page_public") - .addEventListener("click", function (evt) { - const checkbox = evt.target - const now = new Date() + if(!public_field) return - 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 = "" - }) + 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 = "" + }) }) }