Begin jQuery removal

This commit is contained in:
Ben Sturmfels 2024-05-07 10:46:34 +10:00
parent 83550a56a3
commit 83b05a3ae2
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
3 changed files with 43 additions and 63 deletions

View file

@ -3,8 +3,6 @@
* ensure appropriate caching headers are used * ensure appropriate caching headers are used
* remove jQuery * remove jQuery
* consider removing `events` and `worldmap` modules * consider removing `events` and `worldmap` modules
* split the template/content files out from `conservancy/static` into their own
`content` directory (avoid mixing static and non-static content)
* ask Denver about why so many license files * ask Denver about why so many license files
* serve a 400 in Apache for a hostname we don't explicitly support * serve a 400 in Apache for a hostname we don't explicitly support
* use `<detail>` elements for supporter page hidden sections, rather than * use `<detail>` elements for supporter page hidden sections, rather than
@ -15,6 +13,8 @@
# Done # Done
* split the template/content files out from `conservancy/static` into their own
`content` directory (avoid mixing static and non-static content)
* remove `ForceCanonicalHostnameMiddleware` by ensuring canonical redirect and * remove `ForceCanonicalHostnameMiddleware` by ensuring canonical redirect and
HTTPS redirect is done by Apache HTTPS redirect is done by Apache
* standardise settings to replace `settings.py` and `djangocommonsettings.py` * standardise settings to replace `settings.py` and `djangocommonsettings.py`

View file

@ -5,7 +5,11 @@
** Find a copy of GPL at https://sfconservancy.org/GPLv3 ** Find a copy of GPL at https://sfconservancy.org/GPLv3
*/ */
$(document).ready(function() { function qs (selector) {
return document.querySelector(selector);
}
function init () {
/* When the browser doesn't support any video source, replace it /* When the browser doesn't support any video source, replace it
with the HTML inside the <video> element. */ with the HTML inside the <video> element. */
var showVideoInnerHTML = function(event) { var showVideoInnerHTML = function(event) {
@ -19,45 +23,28 @@ $(document).ready(function() {
$('source', video).last().on('error', showVideoInnerHTML); $('source', video).last().on('error', showVideoInnerHTML);
}); });
/* Set up donation form elements used across the whole site. */
$('.toggle-content').hide();
$('.toggle-control')
.addClass('clickable')
.bind('click', function() {
var $control = $(this);
var $parent = $control.parents('.toggle-unit');
$parent.toggleClass('expanded');
$parent.find('.toggle-content').slideToggle();
// if control has HTML5 data attributes, use to update text
if ($parent.hasClass('expanded')) {
$control.html($control.attr('data-expanded-text'));
} else {
$control.html($control.attr('data-text'));
}
});
$('input[name=on0]:radio').on('change', function(event, duration) { $('input[name=on0]:radio').on('change', function(event, duration) {
var $input = $(this); var input = $(this);
var wantShirt = $input.val() == "wantGiftYes"; var wantShirt = input.val() == "wantGiftYes";
var $form = $input.parents('form').last(); var form = input.parents('form').last();
var $tShirtSelector = $('.t-shirt-size-selector', $form); var tShirtSelector = $('.t-shirt-size-selector', form);
$('input', $tShirtSelector).prop('disabled', wantShirt); $('input', tShirtSelector).prop('disabled', wantShirt);
$('input[name=no_shipping]', $form).val(wantShirt ? '2' : '0'); $('input[name=no_shipping]', form).val(wantShirt ? '2' : '0');
if (wantShirt) { if (wantShirt) {
$tShirtSelector.slideDown(duration); tShirtSelector.slideDown(duration);
} else { } else {
$tShirtSelector.slideUp(duration); tShirtSelector.slideUp(duration);
} }
}).filter(':checked').trigger('change', 0); }).filter(':checked').trigger('change', 0);
// Open mobile/search menu. // Open mobile/search menu.
$('#menu-icon').on('click', function(event) { qs('#menu-icon').addEventListener('click', function(event) {
$('#navbar').toggleClass('mobile'); qs('#navbar').classList.toggle('mobile');
}); });
$('#search-icon').on('click', function(event) { qs('#search-icon').addEventListener('click', function(event) {
$('#navbar').toggleClass('mobile'); qs('#navbar').classList.toggle('mobile');
$('#search-query').focus(); qs('#search-query').focus();
}); });
}); }
init();

View file

@ -309,40 +309,33 @@ reach for reproducibility. </p>
<details> <details>
<summary>Support Now!</summary> <summary>Support Now!</summary>
<h3 class="donate-box-highlight">Become a Sustainer Now:</h3> <p class="mv2">Become a Sustainer Now:</p>
<p>Support us now!</p> <ul>
<li class="mb2"><a href="#annual"><span class="donate-box-highlight">Annual sustainer</span> via PayPal, ACH, or credit card</a></li>
<li class="mb2"><a href="#monthly"><span class="donate-box-highlight">Monthly sustainer</span> via PayPal, ACH, or credit card</a></li>
<li class="mb2"><a href="#renewal"><span class="donate-box-highlight">Renewing Annual sustainer</span> via PayPal, ACH, or credit card</a></li>
</ul>
<h4><a href="#annual"><span class="donate-box-highlight">Annual sustainer</span> via PayPal, ACH, or credit card.</a></h4> <p class="mv2">Other annual sustainers methods:</p>
<h4><a href="#monthly"><span class="donate-box-highlight">Monthly sustainer</span> via PayPal, ACH, or credit card.</a></h4>
<h4><a href="#renewal"><span class="donate-box-highlight">Renewing Annual sustainer</span> via PayPal, ACH, or credit card.</a></h4>
<span class="donate-box-highlight">Other annual sustainers methods:</span> <details class="mv2">
<div class="toggle-unit"> <summary class="f6 pt0 pb1">Wire Transfer</summary>
<h4 class="toggle-control" data-text="Wire Transfer"
data-expanded-text="Wire Transfer:">Wire Transfer</h4>
<div class="toggle-content">
Contact <a href="mailto:donate@sfconservancy.org">Conservancy Contact <a href="mailto:donate@sfconservancy.org">Conservancy
by email</a><br/> for wire transfer instructions.<br/> by email</a> for wire transfer instructions. Include currency &amp; country.<br/>
Include currency &amp; country.<br/> </details>
</div><!-- /.toggle-content -->
</div><!-- /.toggle.unit -->
<div class="toggle-unit"> <details class="mv2">
<h4 class="toggle-control" data-text="Paper Check" <summary class="f6 pt0 pb1">Paper Check</summary>
data-expanded-text="Paper Check:">Paper Check</h4> <p>Send paper check for $120 to:</p>
<div class="toggle-content"> <p>Software Freedom Conservancy, Inc.<br/>
Send paper check for $120 to:<br/>
Software Freedom Conservancy, Inc.<br/>
137 MONTAGUE ST STE 380<br/> 137 MONTAGUE ST STE 380<br/>
BROOKLYN, NY 11201-3548 &nbsp; USA<br/> BROOKLYN, NY 11201-3548 &nbsp; USA</p>
Please write <q>SUSTAINER</q>, t-shirt size, if you are renewing, and if <p>Please write <q>SUSTAINER</q>, T-shirt size, if you are renewing, and if
you want public acknowledgment in memo line. you want public acknowledgment in memo line.</p>
</div><!-- /.toggle-content --> </details>
</div><!-- /.toggle.unit -->
<p><a href="/donate">Even More Ways to Donate</a></p> <p class="mv2"><a href="/donate">Even More Ways to Donate</a></p>
<!-- Flattr end -->
</details> </details>
</div> </div>
{% endblock %} {% endblock %}