Sha256: dca423f7aa723e7988757b57a4b6d45e2a69129c9f25adc11baa6885e5d63076
Contents?: true
Size: 1.42 KB
Versions: 72
Compression:
Stored size: 1.42 KB
Contents
$(() => { const $userRegistrationForm = $("#register-form"); const $userGroupFields = $userRegistrationForm.find(".user-group-fields"); const inputSelector = 'input[name="user[sign_up_as]"]'; const newsletterSelector = 'input[type="checkbox"][name="user[newsletter]"]'; const $newsletterModal = $("#sign-up-newsletter-modal"); const setGroupFieldsVisibility = (value) => { if (value === "user") { $userGroupFields.hide(); } else { $userGroupFields.show(); } } const checkNewsletter = (check) => { $userRegistrationForm.find(newsletterSelector).prop("checked", check); $newsletterModal.data("continue", true); $newsletterModal.foundation("close"); $userRegistrationForm.submit(); } setGroupFieldsVisibility($userRegistrationForm.find(`${inputSelector}:checked`).val()); $userRegistrationForm.on("change", inputSelector, (event) => { const value = event.target.value; setGroupFieldsVisibility(value); }); $userRegistrationForm.on("submit", (event) => { const newsletterChecked = $userRegistrationForm.find(newsletterSelector); if (!$newsletterModal.data("continue")) { if (!newsletterChecked.prop("checked")) { event.preventDefault(); $newsletterModal.foundation("open"); } } }); $newsletterModal.find(".check-newsletter").on("click", (event) => { checkNewsletter($(event.target).data("check")); }); });
Version data entries
72 entries across 72 versions & 1 rubygems