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

Version Path
decidim-core-0.27.9 app/packs/src/decidim/user_registrations.js
decidim-core-0.27.8 app/packs/src/decidim/user_registrations.js
decidim-core-0.27.7 app/packs/src/decidim/user_registrations.js
decidim-core-0.27.6 app/packs/src/decidim/user_registrations.js
decidim-core-0.26.10 app/packs/src/decidim/user_registrations.js
decidim-core-0.26.9 app/packs/src/decidim/user_registrations.js
decidim-core-0.27.5 app/packs/src/decidim/user_registrations.js
decidim-core-0.26.8 app/packs/src/decidim/user_registrations.js
decidim-core-0.27.4 app/packs/src/decidim/user_registrations.js
decidim-core-0.27.3 app/packs/src/decidim/user_registrations.js
decidim-core-0.26.7 app/packs/src/decidim/user_registrations.js
decidim-core-0.26.5 app/packs/src/decidim/user_registrations.js
decidim-core-0.27.2 app/packs/src/decidim/user_registrations.js
decidim-core-0.27.1 app/packs/src/decidim/user_registrations.js
decidim-core-0.26.4 app/packs/src/decidim/user_registrations.js
decidim-core-0.27.0 app/packs/src/decidim/user_registrations.js
decidim-core-0.26.3 app/packs/src/decidim/user_registrations.js
decidim-core-0.27.0.rc2 app/packs/src/decidim/user_registrations.js
decidim-core-0.27.0.rc1 app/packs/src/decidim/user_registrations.js
decidim-core-0.26.2 app/packs/src/decidim/user_registrations.js