Skip to content

Commit

Permalink
fix paradox document blank toc entry (#72)
Browse files Browse the repository at this point in the history
* fix blank toc entry

* update the original script
  • Loading branch information
Roiocam authored Jan 24, 2024
1 parent 33cd0dc commit 5598c94
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
31 changes: 31 additions & 0 deletions content/assets/javascripts/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,37 @@ $(function() {
});
});

// Index Page toc
$(".toc").each(function() {
var tocRoot = $(this);
function findHeaderElements(element) {
var headerElements = element.find(".header").filter("a");
headerElements.each(function() {
var headerElement = $(this);
// if header hiding by group switch, hide they li parent
// otherwise display there li parent
if (headerElement.css("display") === "none" ) {
var parentLi = headerElement.closest('li');
if (parentLi) {
parentLi.hide();
}
} else {
var parentLi = headerElement.closest('li');
if (parentLi) {
parentLi.show();
}
}
});
// just in case there is a nested header
element.children().each(function() {
var childElement = $(this);
findHeaderElements(childElement);
});
}

findHeaderElements(tocRoot);
})

groupChangeListeners.forEach(listener => listener(group, supergroup, catalog));
}

Expand Down
31 changes: 31 additions & 0 deletions src/main/paradox/_template/assets/javascripts/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,37 @@ $(function() {
});
});

// Index Page toc
$(".toc").each(function() {
var tocRoot = $(this);
function findHeaderElements(element) {
var headerElements = element.find(".header").filter("a");
headerElements.each(function() {
var headerElement = $(this);
// if header hiding by group switch, hide they li parent
// otherwise display there li parent
if (headerElement.css("display") === "none" ) {
var parentLi = headerElement.closest('li');
if (parentLi) {
parentLi.hide();
}
} else {
var parentLi = headerElement.closest('li');
if (parentLi) {
parentLi.show();
}
}
});
// just in case there is a nested header
element.children().each(function() {
var childElement = $(this);
findHeaderElements(childElement);
});
}

findHeaderElements(tocRoot);
})

groupChangeListeners.forEach(listener => listener(group, supergroup, catalog));
}

Expand Down

0 comments on commit 5598c94

Please sign in to comment.