mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-11 14:20:54 +01:00
Prevent adding new history entries when switching tabs. (#1617)
Affects issues: - Close #1318
This commit is contained in:
parent
d0491a0dec
commit
5ab0e8ffdb
@ -51,13 +51,26 @@ for (let tab of tabs) {
|
||||
|
||||
window.addEventListener('hashchange', openPage);
|
||||
|
||||
//Sidebar navigation tabs
|
||||
$('#accordionSidebar .nav-item a').click(event => {
|
||||
if(history.replaceState) {
|
||||
event.preventDefault();
|
||||
history.replaceState(undefined, undefined, '#' + event.currentTarget.href.split('#')[1]);
|
||||
openPage();
|
||||
}
|
||||
});
|
||||
|
||||
// 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];
|
||||
window.location.hash = currentTab + '&' + originalTargetId;
|
||||
if(history.replaceState) {
|
||||
event.preventDefault();
|
||||
history.replaceState(undefined, undefined, currentTab + '&' + originalTargetId);
|
||||
openPage();
|
||||
} else window.location.hash = currentTab + '&' + originalTargetId;
|
||||
});
|
||||
|
||||
let oldWidth = null;
|
||||
|
Loading…
Reference in New Issue
Block a user