Syllabus/static/js/sandpoints.js

56 lines
2.1 KiB
JavaScript
Raw Normal View History

window.addEventListener('scroll', function(e) {
2020-08-26 14:09:27 +00:00
console.log(document.querySelector('body').clientWidth);
if (document.querySelector('body').clientWidth > 1024) {
let rightcolumn = document.querySelector('.rightcolumn');
let topicstitle = document.querySelector('.topicstitle')
let topicbar = document.querySelector('.topicbar')
let grid = document.querySelector('.grid')
let gridrect = topicstitle.getBoundingClientRect();
if (gridrect.top < 12 && !grid.classList.contains('moved')) {
grid.classList.add('moved');
topicbar.style.display = "inline";
topicstitle.style.visibility = "hidden";
grid.style.display = "none";
window.scrollBy({top: grid.clientHeight + topicstitle.clientHeight, behavior: 'smooth'})
}
}
})
2020-08-26 14:09:27 +00:00
window.addEventListener('DOMContentLoaded', (e) => {
2020-08-26 14:09:27 +00:00
if (document.querySelector('.syllabusgrid')) {
if (document.querySelector('body').clientWidth > 1024) {
document.querySelector('.syllabusgrid').classList.remove('syllabusgrid')
} else {
toggle('syllabus/');
}
2020-08-26 14:09:27 +00:00
}
let par = document.querySelector("#TableOfContents > ol:first-child > li:first-child");
let s = document.createElement("span");
s.appendChild(par.cloneNode(true))
par.remove()
document.querySelector("#TableOfContents > ol:first-child").insertBefore(s, document.querySelector("#TableOfContents > ol:first-child").firstChild)
})
var toggle = function(ts) {
let rightcolumn = document.querySelector('.rightcolumn');
let grid = document.querySelector('.grid');
2020-08-26 14:09:27 +00:00
if (grid) {
grid.classList.remove('grid')
grid.classList.add('mobilegrid')
}
if (rightcolumn.classList.contains('shown')) {
rightcolumn.classList.remove('shown');
rightcolumn.style.display = "none";
2020-08-26 14:09:27 +00:00
document.querySelector('.mobilegrid').style.display = "none";
} else {
rightcolumn.classList.add('shown');
rightcolumn.style.display = "grid";
2020-08-26 14:09:27 +00:00
document.querySelector('.mobilegrid').style.display = "block";
}
}