mirror of
https://github.com/suk-ws/ph-Bookshelf.git
synced 2024-12-05 09:26:52 +08:00
32 lines
668 B
JavaScript
32 lines
668 B
JavaScript
const WITH_SUMMARY_CLASS = "with-summary"
|
|
|
|
let bookRoot;
|
|
|
|
function summaryOnOrOff () {
|
|
|
|
if (bookRoot.classList.contains(WITH_SUMMARY_CLASS)) {
|
|
bookRoot.classList.remove(WITH_SUMMARY_CLASS);
|
|
} else {
|
|
bookRoot.classList.add(WITH_SUMMARY_CLASS);
|
|
}
|
|
|
|
}
|
|
|
|
window.onload = function () {
|
|
|
|
bookRoot = document.getElementsByClassName("book")[0];
|
|
|
|
if (window.innerWidth > 600) {
|
|
bookRoot.classList.add(WITH_SUMMARY_CLASS);
|
|
}
|
|
|
|
};
|
|
|
|
for (let node of document.getElementsByClassName("fold")) {
|
|
node.childNodes[0].addEventListener("click", function () {
|
|
if (node.classList.contains("on")) {
|
|
node.classList.remove("on");
|
|
} else node.classList.add("on");
|
|
});
|
|
}
|