aero-ajax
Version:
Ajaxify your Aero site. Add the CSS class 'ajax' to any link on the site.
26 lines (20 loc) • 494 B
JavaScript
$.markActiveLinks = (url, element) => {
if(typeof url === 'object') {
element = url
url = undefined
}
if(url === undefined)
url = window.location.pathname
if(element === undefined)
element = document.body
let links = element.querySelectorAll('a')
for(let i = 0; i < links.length; i++) {
let link = links[i]
let href = link.getAttribute('href')
if(url === href)
link.classList.add('active')
else
link.classList.remove('active')
}
$.emit('ActiveLinksMarked')
}