Skip to content

Commit

Permalink
Bug fix for highlight current page in nav bar. if page used custom url
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoBoer committed Nov 10, 2022
1 parent 94ccb2a commit 90c0b40
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions modules/site/parent_templates/site/common/js/application.js
Expand Up @@ -1489,15 +1489,8 @@ function parseContent(pageRef, sectionNum, contentNum, addHistory) {

// check if pageIndex exists & can be shown
var pageIndex;

//assign active class for current navbar
$("#nav li").not(':first-child').each(function(i, el){
if ($(el).hasClass("active") && i !== pageID){
$(el).removeClass("active")
} else if (i == pageID){
$(el).addClass("active")
}
})
// used to set active on nav item.
var activeIndex = pageID;

// pageID might be an ID - see if it matches either a linkID or a customLinkID
if (pageRefType != 'index') {
Expand All @@ -1506,13 +1499,22 @@ function parseContent(pageRef, sectionNum, contentNum, addHistory) {
if (pageID == $page.attr('linkID') || pageID == $page.attr('customLinkID')) {
// an ID match has been found
pageIndex = index;
activeIndex = index;
found = true;
pageRefType = 'id';

return false;
}
});
}
//assign active class for current navbar
$("#nav li").not(':first-child').each(function(i, el){
if ($(el).hasClass("active") && i !== activeIndex){
$(el).removeClass("active")
} else if (i == activeIndex){
$(el).addClass("active")
}
})

// check if it's a valid page index
if (pageRefType != 'id') {
Expand Down

0 comments on commit 90c0b40

Please sign in to comment.