const hasTouch='ontouchstart' in document.documentElement; // RELATED CONTENT BOXES const relatedContent=()=>{ // lock position for mobile if (hasTouch==true) {$('#related').removeClass('overlayORP'); } else { let w=$(window).height(); // browser window let d=$(document).height()-644; // document - footer let c=168+$('.rMenu').height()+$('#related').height(); // head, menu, box if ((d<=w)||(w<800)) { // if content is shorter than window or window less than 800, just move div to bottom of nav rail $('#related').removeClass('overlayORP'); if (w>=800) {$('#related').addClass('scrolledORP');} } $(window).scroll(function () { let s=$(window).scrollTop(); // what is the position of the scroll? let z=d-w // how much scroll is available? (doc height - window height) if (wz) { // is the scroll position higher than the amount available? // if so, move div to bottom of nav rail $('#related').removeClass('overlayORP'); $('#related').addClass('scrolledORP'); } else { // otherwise, overlay div at bottom of viewport $('#related').removeClass('scrolledORP'); $('#related').addClass('overlayORP'); } }); } } // FOOTNOTE POPUPS const footnotes=()=>{ // add markup to all footnote references $('sup a').append('
'); if (hasTouch==true) { $('sup a').on('click', function(e){ e.preventDefault(); if ($(this).find('div').is(':hidden')) { $(this).find('div').show(); let content=$(this).attr('href'); content=$(content).html(); $(this).find('div em').html(content); } else { $(this).find('div').hide(); }}); } else { // on hover, show the popup and add the matching footnote $('sup a').hover(function() { // show the popup $(this).find('div').fadeIn(); // use our href to find the appropriate content from the footnote list let content=$(this).attr('href'); content=$(content).html(); // copy the footnote content into the popup $(this).find('div em').html(content); }, function() { // hide the popup on mouseout $(this).find('div').fadeOut(); }); } } // UTILITY BAR const utilitiesORP=()=>{ let pageURL='https://www.ssa.gov'+window.location.pathname; let sendTitleORP=document.title.replace(/&/g, '%26').replace(/"/g, ''); let fileHTML=window.location.pathname.substring(window.location.pathname.lastIndexOf('/')+1); let fileAsPDF=fileHTML.replace(/html?/gi,'pdf'); let fileAsXLS=fileHTML.replace(/html?/gi,'xlsx'); $('a', '#emailORP').attr('href', 'mailto:?subject=From the SSA Office of Research, Statistics, and Policy Analysis website&body='+sendTitleORP+'%0D'+pageURL); $('a', '#printORP').attr('href', fileAsPDF); $('a', '#excelORP').attr('href', fileAsXLS); $('#utilitiesORP').css('visibility', 'visible'); } $(function () { if (hasTouch!=true&&$('body').hasClass('RS')) { footnotes() } if ($('#utilitiesORP').length) { utilitiesORP() } }); window.onload=event=>{ if ($('#related').length) { relatedContent() } };