1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
reyasume/_includes/assets/js/main.js

43 lines
1.0 KiB

(function(window, document) {
function findClosestParentMatching(child, selector) {
if (!child) {
return null;
} else if (child.matches(selector)) {
return child;
} else {
return findClosestParentMatching(child.parentElement, selector);
}
}
function showAll(button) {
parent = findClosestParentMatching(button, ".highlight-container");
if (!parent) {
return;
}
parent.classList.add("showing-all");
}
function showHighlights(button) {
parent = findClosestParentMatching(button, ".highlight-container");
if (!parent) {
return;
}
parent.classList.remove("showing-all");
}
function print() {
window.print();
}
document.addEventListener("click", function(event) {
if (event.target.matches(".show-all, .show-all *")) {
showAll(event.target);
} else if (event.target.matches(".show-highlights, .show-highlights *")) {
showHighlights(event.target);
} else if (event.target.matches("#print, #print *")) {
print();
}
});
})(window, document);