Fixed URL hash handling with graph tabs (#1803)

Affects issues:
- Fixed 1736
This commit is contained in:
Antti Koponen 2021-03-19 09:48:42 +02:00 committed by GitHub
parent 3ca98bb634
commit 428331de5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,16 +61,23 @@ $('#accordionSidebar .nav-item a').click(event => {
}); });
// Persistent Bootstrap tabs // Persistent Bootstrap tabs
$('.nav-tabs a.nav-link').click(event => { document.querySelectorAll(".nav-tabs a.nav-link").forEach(item => {
const uriHash = (window.location.hash).split("&"); item.addEventListener("click", event => {
if (!uriHash) return; let uriHash;
const currentTab = uriHash[0]; if (window.location.hash) {
const originalTargetId = event.currentTarget.href.split('#')[1]; uriHash = (window.location.hash).split("&");
} else {
window.location.hash = document.querySelector(".sidebar a.nav-link").href.split("#")[1]
uriHash = [window.location.hash];
}
const targetTab = event.currentTarget.href.split('#')[1];
if (history.replaceState) { if (history.replaceState) {
event.preventDefault(); event.preventDefault();
history.replaceState(undefined, undefined, currentTab + '&' + originalTargetId); history.replaceState(undefined, undefined, uriHash[0] + '&' + targetTab);
openPage(); openPage();
} else window.location.hash = currentTab + '&' + originalTargetId; } else
window.location.hash = uriHash[0] + '&' + targetTab;
});
}); });
let oldWidth = null; let oldWidth = null;