supporter: Only render the Annual form for upgraders.

This lets us do more with HTML and less with JavaScript, which is always
nice.
This commit is contained in:
Brett Smith 2017-01-01 10:53:58 -05:00
parent b4883ca6bd
commit 19e744788b
2 changed files with 16 additions and 13 deletions

View file

@ -19,7 +19,7 @@ var amountIsValid = function(amountInput) {
} }
var supportTypeSelector = function(supportTypeHash) { var supportTypeSelector = function(supportTypeHash) {
return $(".supporter-type-selector a[href=" + supportTypeHash + "]"); return $(supportTypeHash + "Selector");
}; };
var $window = $(window); var $window = $(window);
@ -84,12 +84,7 @@ $(document).ready(function() {
return supportTypeSelector(window.location.hash).click(); return supportTypeSelector(window.location.hash).click();
}; };
$window.bind("hashchange", selectSupportTypeFromHash); $window.bind("hashchange", selectSupportTypeFromHash);
var $selectorLink = selectSupportTypeFromHash(); if (selectSupportTypeFromHash().length === 0) {
if (parseFloat($("#annual form").data('upgradeFromAmount')) > 0) {
supportTypeSelector("#annual").click();
$(".supporter-type-selector").hide();
}
else if ($selectorLink.length === 0) {
supportTypeSelector("#annual").click(); supportTypeSelector("#annual").click();
} }
}); });

View file

@ -54,15 +54,23 @@
<h1 class="appeal"><img class="appeal-header" alt="Become a Conservancy Supporter!" src="/img/conservancy-supporter-header.png"/></h1> <h1 class="appeal"><img class="appeal-header" alt="Become a Conservancy Supporter!" src="/img/conservancy-supporter-header.png"/></h1>
<div class="supporter-type-selector"> {% if partial_amount > 0 %}
<strong>Become a Supporter Now:</strong> <a id="annualSelector" href="#annual">Annual</a> | <a id="monthlySelector" href="#monthly">Monthly</a> | <a id="renewalSelector" href="#renewal">Annual Renew</a></div> {% include "supporter/form_partial.html" with form_id="annual" min_amt=minimum_amount partial_amt=partial_amount article="an" only %}
{% else %}
<div class="supporter-type-selector">
<strong>Become a Supporter Now:</strong>
<a id="annualSelector" href="#annual">Annual</a>
| <a id="monthlySelector" href="#monthly">Monthly</a>
| <a id="renewalSelector" href="#renewal">Annual Renew</a>
</div>
{% include "supporter/form_partial.html" with form_id="annual" min_amt=minimum_amount partial_amt=partial_amount article="an" only %} {% include "supporter/form_partial.html" with form_id="annual" min_amt=120 article="an" only %}
{% include "supporter/form_partial.html" with form_id="monthly" min_amt=10 only %} {% include "supporter/form_partial.html" with form_id="monthly" min_amt=10 only %}
<a name="renew" class="hidden"></a> <a name="renew" class="hidden"></a>
{% include "supporter/form_partial.html" with form_id="renewal" min_amt=120 verb="renew" article="an" supptype="annual" only %} {% include "supporter/form_partial.html" with form_id="renewal" min_amt=120 verb="renew" article="an" supptype="annual" only %}
{% endif %}
<span id="form-correction-needed" class="form-error">Please ensure all form data above is correct.</span> <span id="form-correction-needed" class="form-error">Please ensure all form data above is correct.</span>