Fix for overzealous resizing, JS redundancies

This commit is contained in:
John Mulhausen 2017-03-01 22:13:14 -08:00
parent 5c03cf4ca4
commit 3e12e75626
1 changed files with 7 additions and 41 deletions

View File

@ -81,8 +81,10 @@ function checkNavSizes()
if (footerTop < sidebarBottom || (sidebarBottom < footerTop && sidebarBottom < $(window).height())) if (footerTop < sidebarBottom || (sidebarBottom < footerTop && sidebarBottom < $(window).height()))
{ {
// the footer is overlapping the sidebar // the footer is overlapping the sidebar
document.getElementsByClassName("sidebar")[0].style.height = (footerTop - headerOffset) + "px"; var sidebarHeight = ((footerTop - headerOffset) < $(window).height()) ? (footerTop - headerOffset) : $(window).height();
document.getElementsByClassName("toc-nav")[0].style.height = (footerTop) + "px"; var tocNavHeight = (footerTop < $(window).height()) ? footerTop : $(window).height();
document.getElementsByClassName("sidebar")[0].style.height = sidebarHeight + "px";
document.getElementsByClassName("toc-nav")[0].style.height = footerTop + "px";
highlightRightNav(currentHeading); highlightRightNav(currentHeading);
} }
} }
@ -142,46 +144,7 @@ function readCookie(name) {
function eraseCookie(name) { function eraseCookie(name) {
createCookie(name,"",-1); createCookie(name,"",-1);
} }
if (readCookie("night") == "true") {
document.getElementById('pagestyle').setAttribute('href', '/css/style-alt.css');
$('#switch-style').prop('checked', true);
} else {
document.getElementById('pagestyle').setAttribute('href', '/css/style.css');
$('#switch-style').prop('checked', false);
}
/* /*
*
* swapStyleSheet*********************************************************************
*
*/
// Cookie functions
function createCookie(name,value,days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
if (readCookie("night") == "true") { if (readCookie("night") == "true") {
document.getElementById('pagestyle').setAttribute('href', '/css/style-alt.css'); document.getElementById('pagestyle').setAttribute('href', '/css/style-alt.css');
$('#switch-style').prop('checked', true); $('#switch-style').prop('checked', true);
@ -189,6 +152,9 @@ if (readCookie("night") == "true") {
document.getElementById('pagestyle').setAttribute('href', '/css/style.css'); document.getElementById('pagestyle').setAttribute('href', '/css/style.css');
$('#switch-style').prop('checked', false); $('#switch-style').prop('checked', false);
} }
*/
/* /*
* *
* toggle menu ********************************************************************* * toggle menu *********************************************************************