Open parent document parts when go to part from TOC
This commit is contained in:
parent
43ff4e44a8
commit
b49f169474
1 changed files with 23 additions and 2 deletions
|
@ -26,9 +26,30 @@
|
||||||
var docPartButton = docPart.previousElementSibling;
|
var docPartButton = docPart.previousElementSibling;
|
||||||
var itemName = docPartButton.textContent;
|
var itemName = docPartButton.textContent;
|
||||||
var link = document.createElement("a");
|
var link = document.createElement("a");
|
||||||
link.setAttribute("href","#" + anchor);
|
link.setAttribute("href", "javascript:goToDocumentPart(\"" + anchor + "\");" );
|
||||||
link.innerText = itemName;
|
link.innerText = itemName;
|
||||||
newTOCElement.appendChild(link);
|
newTOCElement.appendChild(link);
|
||||||
tocElement.appendChild(newTOCElement);
|
tocElement.appendChild(newTOCElement);
|
||||||
return 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