Sha256: 3a8511bd4ac6a5f4536f38cf0090b74cfbaa2d84ada1ae11286679d7fb0a358e
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
const CORE_SITE_PATHNAMES_ARRAY = ['academics', 'admissions', 'tuition-and-aid', 'student-resources', 'community', 'about']; const NAV_GLOBAL_BOTTOM_ELEMENT = document.getElementById('navGlobalBottom'); const NAV_LINKS_NODELIST = NAV_GLOBAL_BOTTOM_ELEMENT.querySelectorAll('.header-global__nav-bottom--nav-link'); function findNavItem(path) { for (let i = 0, len = NAV_LINKS_NODELIST.length; i < len; i++) { let navText = NAV_LINKS_NODELIST[i].innerHTML.trim(); let navTextAsURL = navText.replace(' ', '-').toLowerCase() let navTextNoAmp = navTextAsURL.replace('&', 'and'); let navTextFormated = navTextNoAmp.replace('-kcc', ''); if ( navTextFormated === path ) NAV_LINKS_NODELIST[i].classList.add('header-global__nav-bottom--underlined'); } } function compareUsersLocation(path, userPath) { const userPathNoSlashes = userPath.replace(/^\/|\/$/g, ''); const noMatch = userPathNoSlashes != path; if (noMatch) return; findNavItem(userPathNoSlashes); } function loopOverPathnames(path) { for (let i = 0, len = CORE_SITE_PATHNAMES_ARRAY.length; i < len; i++) { //console.log(CORE_SITE_PATHNAMES_ARRAY[i]); compareUsersLocation(CORE_SITE_PATHNAMES_ARRAY[i], path); } } function underlineCurrentSite() { const location = window.location.pathname; const locationIsOrigin = location === '/' if ( locationIsOrigin ) return; loopOverPathnames(location); } export default underlineCurrentSite;
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kcc-gem-theme-1.64.51 | assets/js/theme/nav/megaNav/underlineCurrentSite.js |