From 6b649e2f48e0f02b2ca62d1610305e58418621f0 2020-11-26 03:27:53 From: Bradley M. Kuhn Date: 2020-11-26 03:27:53 Subject: [PATCH] Supporter page: Support a “Expand All” link for collapsible sections I wrap the entire section that has material that can be expanded in a div with class `expandable-section`. Once doing so, if you provide an anchor with the class of `expander`, that anchor will be created with text in the `data-expand-link-text` attribute. I've also added some CSS to make the link look a certain way, for good measure. --- diff --git a/www/conservancy/static/css/forms.css b/www/conservancy/static/css/forms.css index f4c89bba4f98bbb40c1d67d48488c2f0916bf253..6c4837e109f6a523a161553b1dce66501ded7ced 100644 --- a/www/conservancy/static/css/forms.css +++ b/www/conservancy/static/css/forms.css @@ -112,3 +112,8 @@ p.appeal-match-text { border: 1px solid #fff; background: #eee; } +a.expander { + font-size: 75%; + font-style: italic; + text-align: center; +} diff --git a/www/conservancy/static/js/supporter-page.js b/www/conservancy/static/js/supporter-page.js index 2f15550a2a551e2c9df46929cac419e7df0a4b16..543a62f73dadad1d43e796e4b5e1b0780f2a2092 100644 --- a/www/conservancy/static/js/supporter-page.js +++ b/www/conservancy/static/js/supporter-page.js @@ -1,5 +1,5 @@ /* Copyright (C) 2012-2013 Denver Gingerich, -** Copyright (C) 2013-2014 Bradley M. Kuhn, +** Copyright (C) 2013-2014, 2020 Bradley M. Kuhn, ** Copyright (C) 2016, 2020 Brett Smith. ** License: GPLv3-or-later ** Find a copy of GPL at https://sfconservancy.org/GPLv3 @@ -128,4 +128,17 @@ $(document).ready(function() { $readmore.hide().replaceWith($linkpara); } }); + $('a[data-expand-link-text]').each(function(index, element) { + var $element = $(element); + $element.append($element.data('expand-link-text')); + $element.removeAttr('data-expand-link-text'); + }); + $('.expandable-section').each(function(index) { + var $expandlink = $(this).children('.expander'); + var $ourexpandablesection = $(this); + $expandlink.addClass('active').trigger('click'); + $expandlink.on('click', function(event) { + $expandlink.fadeOut('slow'); + $ourexpandablesection.find('.read-more').each(function(index) { $(this).click(); }); }); + }); }); diff --git a/www/conservancy/templates/supporter/index.html b/www/conservancy/templates/supporter/index.html index 8e02d82359b8e34c9daa7c6b1d2fff61c4e945ea..eb74437e33f2dca95ced529846e471bda8c83b61 100644 --- a/www/conservancy/templates/supporter/index.html +++ b/www/conservancy/templates/supporter/index.html @@ -77,6 +77,7 @@ Please ensure all form data above is correct.
+