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
$('.nav-tabs a.nav-link').click(event => {
const uriHash = (window.location.hash).split("&");
if (!uriHash) return;
const currentTab = uriHash[0];
const originalTargetId = event.currentTarget.href.split('#')[1];
if (history.replaceState) {
event.preventDefault();
history.replaceState(undefined, undefined, currentTab + '&' + originalTargetId);
openPage();
} else window.location.hash = currentTab + '&' + originalTargetId;
document.querySelectorAll(".nav-tabs a.nav-link").forEach(item => {
item.addEventListener("click", event => {
let uriHash;
if (window.location.hash) {
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) {
event.preventDefault();
history.replaceState(undefined, undefined, uriHash[0] + '&' + targetTab);
openPage();
} else
window.location.hash = uriHash[0] + '&' + targetTab;
});
});
let oldWidth = null;