diff --git a/www/conservancy/static/js/supporter-page.js b/www/conservancy/static/js/supporter-page.js index 5e5f4e1844df783b67dc19930b574e5f1402913f..49da881af1f3a6b119a56bd9efc96138f6b68157 100644 --- a/www/conservancy/static/js/supporter-page.js +++ b/www/conservancy/static/js/supporter-page.js @@ -110,24 +110,49 @@ $(document).ready(function() { if (selectSupportTypeFromHash().length === 0) { supportTypeSelector("#annual").click(); } - var want_id = window.location.hash.substr(1) || "do not match any id"; + var $expandable_counts = []; + // First, build a count of expandable div sections + $('div.expandable-section').each(function(index, section) { + var $ourid = $(section).attr('id'); + if ($ourid == undefined) { $ourid = "__global"; } + $expandable_counts[$ourid] = 0; + }); $('div[data-read-more]').each(function(index, readmore) { var $readmore = $(readmore) var $header = $readmore.prev('h3'); if ($header.length && $header[0].id === want_id) { // Do nothing, leave it alone } else { + var $ourid = $readmore.closest(".expandable-section" ).attr('id'); + if ($ourid == undefined) { $ourid = "__global"; } + + // Set up the link for this specific section using the text from + // the data-read-more atrribute on the div specific to this section var $linkpara = $('

'); var $readlink = $linkpara.children('a'); $readlink.append($readmore.data('read-more')); $readlink.on('click', function(event) { + // When clicked, we'll restore the actual text and fade it in + // quickly, and also see if there are any remaining + // expandable sections left in this particular expandable + // section. If none are left, make the "Expand all" button + // (which lives in an 'a' anchor of the class 'expander') disappear. $linkpara.replaceWith($readmore); $readmore.fadeIn('fast'); + $expandable_counts[$ourid]--; + if ($expandable_counts[$ourid] <= 0) { + $readmore.closest(".expandable-section" ) + .children('a.expander').each(function(index, element){ + $(element).fadeOut('slow'); + }) + } }); $readmore.hide().replaceWith($linkpara); + $expandable_counts[$ourid]++; } }); + // Final two each's enable the "Expand All" link. $('a[data-expand-link-text]').each(function(index, element) { var $element = $(element); $element.append($element.data('expand-link-text')); diff --git a/www/conservancy/templates/supporter/index.html b/www/conservancy/templates/supporter/index.html index e3443c461df9cde9fa526dd21236caca804086fc..bd70a602b2334bf13bbed62da989295566bb3b5f 100644 --- a/www/conservancy/templates/supporter/index.html +++ b/www/conservancy/templates/supporter/index.html @@ -77,7 +77,7 @@ Please ensure all form data above is correct.
-
+
Tony Sebro speaks on stage in front of a slide comparing 1800’s Eschatology and Golden Era Hip Hop