68 lines
2.1 KiB
JavaScript

jQuery(function ($) {
// Getting links from a page and turning them into a scroll-spy bespoke menu
let sections;
sections = document.querySelectorAll(".add-to-sidebar")
let url = window.location.href;
// Create the correct menu
let innerContent = "";
sections.forEach(link => {
let itemTitle = link.querySelector("h2:first-of-type, h3:first-of-type, h4:first-of-type, h5:first-of-type, h6:first-of-type");
if (itemTitle) {
link.setAttribute("id", itemTitle.innerText.replace(/\W/g,'_'))
let fullUrl = url.split("#")[0] + "#" + itemTitle.innerText.replace(/\W/g,'_');
innerContent += "<li><a href=\"" + fullUrl + " \" class=''>" + itemTitle.innerText + "</a></li>"
}
});
// Update existing menu with the created one
let menu;
menu = document.getElementById("menu-scroll-spy");
menu.innerHTML = innerContent
// Activate Scrollspy
$('body').scrollspy({
target: '#nav_menu-4'
});
$('.entry-content').scrollspy({
target: '#nav_menu-7'
});
// Refresh Scrollspy
$('[data-spy="scroll"]').each(function () {
$(this).scrollspy("refresh");
});
});
document.addEventListener("DOMContentLoaded", function(event) {
var elements = document.querySelectorAll('.view-team-member-button');
elements.forEach(function(element) {
element.addEventListener('click', function() {
for (elem of document.getElementsByClassName("view-team-member-bio")) {
elem.classList.remove("view-team-member-bio");
}
this.closest(".team-member-wrapper").classList.add('view-team-member-bio');
this.parentNode.classList.remove('visible');
})
});
});
document.addEventListener("DOMContentLoaded", function(event) {
var elements = document.querySelectorAll('.hide-team-member-button');
elements.forEach(function(element) {
element.addEventListener('click', function() {
this.parentNode.parentNode.classList.remove('view-team-member-bio');
})
});
});