From 73e30c30e844f791bb5447655bfaa654c6981218 Mon Sep 17 00:00:00 2001 From: Ben Sturmfels Date: Thu, 9 May 2024 14:06:39 +1000 Subject: [PATCH] Further split up the supporter JS into functions --- conservancy/static/js/supporter-page.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/conservancy/static/js/supporter-page.js b/conservancy/static/js/supporter-page.js index ad0f27f0..b3f03930 100644 --- a/conservancy/static/js/supporter-page.js +++ b/conservancy/static/js/supporter-page.js @@ -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
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
+ // 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();