[M] Move history stuff to navigation.ts

This commit is contained in:
Hykilpikonna
2019-10-14 16:40:27 -04:00
parent e3df5b8e3b
commit c6e3806024
2 changed files with 25 additions and 15 deletions
-14
View File
@@ -98,20 +98,6 @@ export default class App extends Vue
{
// Show splash
console.log(Constants.SPLASH);
// Set history state (TODO: Dynamically detect initial url
window.history.replaceState({lastTab: 'overall'}, '', '/overall');
// Create history state listener
window.onpopstate = e =>
{
if (e.state)
{
// Restore previous tab
console.log(`onPopState: Current: ${this.selectedTab}, Previous: ${e.state.lastTab}`);
this.selectedTab = e.state.lastTab;
}
};
}
/**
+25 -1
View File
@@ -9,10 +9,34 @@ import Constants from '@/constants';
})
export default class Navigation extends Vue
{
public activeIndex: string = 'overall';
// @ts-ignore
@Prop() activeIndex: string;
@Prop() courses: any;
/**
* This is called when the instance is created.
*/
public created()
{
// Show splash TODO: Remove
console.log('Created Navigation');
// Set history state (TODO: Dynamically detect initial url
window.history.replaceState({lastTab: 'overall'}, '', '/overall');
// Create history state listener
window.onpopstate = e =>
{
if (e.state)
{
// Restore previous tab
console.log(`onPopState: Current: ${this.activeIndex}, Previous: ${e.state.lastTab}`);
this.activeIndex = e.state.lastTab;
}
};
}
/**
* This function is called when the selection changes.
*