Further split up the supporter JS into functions

This commit is contained in:
Ben Sturmfels 2024-05-09 14:06:39 +10:00
parent 8a9f796eb1
commit 73e30c30e8
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0

View file

@ -36,7 +36,7 @@ if (window.location.hash === "#renew") {
window.location.hash = "#renewal";
}
function init_sustainer_forms () {
function init_sustainer_form_validation () {
// Forms start in "invalid" form, with the errors shown, so that
// non-Javascript users see the errors by default and know what they must
// enter. Now we hide those for JavaScript users:
@ -85,7 +85,9 @@ function init_sustainer_forms () {
}
});
});
}
function init_sustainer_type_switching () {
var selectSupportType = function(event) {
var $selectedLink = $(event.target);
$(".supporter-type-selector a").removeClass("supporter-type-selector-selected");
@ -107,10 +109,10 @@ function init_sustainer_forms () {
};
function init_expanders () {
// Conservancy does a lot each year, so we initially hide the "Year in
// Review" text insideexpandable <details> sections to avoid a wall of
// text. If the URL fragment matches one of our expandable sections, we
// automatically expand it - that's a direct link.
// To avoid hitting visitors with a wall of text, we initially hide the
// "Year in Review" and similar text inside expandable <details>
// sections. If the URL fragment references one of these sections, we open
// that section.
let details = qs('details' + window.location.hash) // eg. #WritingAndSpeaking
if (window.location.hash && details) {
details.open = true;
@ -129,5 +131,6 @@ function init_expanders () {
});
}
init_sustainer_forms();
init_sustainer_form_validation();
init_sustainer_type_switching();
init_expanders();