41 lines
No EOL
1.3 KiB
JavaScript
41 lines
No EOL
1.3 KiB
JavaScript
// ALT TABLE TOGGLES
|
|
const eachToggle=(thisChart, showTxt, hideTxt)=>{
|
|
if(thisChart.next().is(':visible')) {
|
|
thisChart.next().hide();
|
|
thisChart.html(showTxt);
|
|
} else {
|
|
thisChart.next().show();
|
|
thisChart.html(hideTxt);
|
|
}
|
|
}
|
|
const toggleAlt=()=>{
|
|
$('.altTable TABLE').hide();
|
|
$('.altText DIV').hide();
|
|
$('.altToggle').on('click', function() {
|
|
eachToggle($(this), 'Show as table', 'Hide table');
|
|
return false;
|
|
});
|
|
$('.altTextToggle').on('click', function() {
|
|
eachToggle($(this), 'Show text description', 'Hide text description');
|
|
return false;
|
|
});
|
|
}
|
|
|
|
// SCROLL CONTENT ON SMALL SCREENS
|
|
const eachScroll=(thisElement, findElement)=>{
|
|
let elementWidth=thisElement.find(findElement).width();
|
|
if (elementWidth>thisElement.width()) { thisElement.addClass('scrollInstruct');
|
|
} else { thisElement.removeClass('scrollInstruct') }
|
|
}
|
|
const scrollContent=()=>{
|
|
$('.table').each(function () { eachScroll($(this), 'tbody') });
|
|
$('.svgChart').each(function () {eachScroll($(this), 'img') });
|
|
$('.scrollChart').each(function () {eachScroll($(this), 'img') });
|
|
$('.scrollImage').each(function () {eachScroll($(this), 'img') });
|
|
}
|
|
|
|
$(function () {
|
|
toggleAlt();
|
|
scrollContent();
|
|
$(window).resize(function () { scrollContent() });
|
|
}); |