@@ -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');
// 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 = $('<p><a class="read-more"></a></p>');
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'));