ssa-gov/policy/js/fast-facts.js?v1
2025-02-19 12:17:21 -08:00

34 lines
No EOL
1.3 KiB
Text

// Fast Facts Special Chartbook View
const ffToggles=thisChart=>{
let thisInfo='';
infoItems.forEach(info=>{
if ($.inArray(thisChart, info.pages)!==-1) { thisInfo=thisChart; thisChart='#'+ info.id }
});
$('.ui-corner-top').removeClass('activeTab');
$('.chartSidebar, .chartArea').hide();
$('.current').removeClass('current');
$('.shaded').removeClass('shaded');
if (thisChart!='') { $(thisChart).show() }
else { $('.chartArea:first').show() }
sections.forEach(s=>{
if ($.inArray(thisChart, s.pages)!==-1) {
$('#'+s.id).addClass('activeTab');
$('#'+s.id+'Sidebar').show();
}
});
$('.chartSidebar a[href="'+thisChart+'"]').parent().addClass('current');
if (thisInfo!='') { $(thisInfo).addClass('shaded') }
if ($.inArray(thisInfo, belowFoldInfo)!==-1) { $(window).scrollTop($(thisInfo).offset().top) }
else { $(window).scrollTop($('#hDocInfo').offset().top) }
}
const fastfacts=()=>{
let thisChart=location.hash;
ffToggles(thisChart);
$('.chartNext,.chartPrevious, .ui-corner-top a, .chartSidebar a').on('click', function() {
thisChart=$(this).attr('href');
ffToggles(thisChart);
return false;
});
$('.abbr a').on('click', function() { $('#abbreviations').toggle(); return false });
}
$(function() { fastfacts() });