Open parent document parts when go to part from TOC
This commit is contained in:
parent
2c6a138503
commit
7832acd50c
1 changed files with 23 additions and 2 deletions
|
@ -26,9 +26,30 @@
|
|||
var docPartButton = docPart.previousElementSibling;
|
||||
var itemName = docPartButton.textContent;
|
||||
var link = document.createElement("a");
|
||||
link.setAttribute("href","#" + anchor);
|
||||
link.setAttribute("href", "javascript:goToDocumentPart(\"" + anchor + "\");" );
|
||||
link.innerText = itemName;
|
||||
newTOCElement.appendChild(link);
|
||||
tocElement.appendChild(newTOCElement);
|
||||
return newTOCElement;
|
||||
}
|
||||
}
|
||||
function goToDocumentPart(targetId){
|
||||
if (targetId ===""){
|
||||
return;
|
||||
}
|
||||
var targetNode = document.getElementById(targetId);
|
||||
if (targetNode === null){
|
||||
console.log("document has no target node to go to")
|
||||
return;
|
||||
}
|
||||
showParents(targetNode);
|
||||
document.getElementById(targetId).scrollIntoView();
|
||||
}
|
||||
function showParents(targetNode){
|
||||
if (targetNode != null && "complexDocument" !== targetNode.id){
|
||||
if (targetNode.style.display === "none") {
|
||||
targetNode.style.display = "block";
|
||||
}
|
||||
showParents(targetNode.parentElement);
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue