mirror of
https://github.com/kieraneglin/pinchflat.git
synced 2026-01-23 10:26:07 +00:00
* [WIP] Got query kinda working, now to refactor other queries * Refactored all query methods to use dynamic snippets * Refactored tab layout to grab tabs by name * Removed standalone show buttons from in-app tables * Removed unneeded comment
20 lines
543 B
JavaScript
20 lines
543 B
JavaScript
window.setTabByName = (tabName) => {
|
|
window.location.hash = `tab-${tabName}`
|
|
|
|
return tabName
|
|
}
|
|
|
|
// The conditionals and currIndex stuff ensures that
|
|
// the tab index is always set to 0 if the hash is empty
|
|
// AND other hash values are ignored
|
|
window.getTabFromHash = (currentTabName, defaultTabName) => {
|
|
if (window.location.hash === '' || window.location.hash === '#') {
|
|
return defaultTabName
|
|
}
|
|
|
|
if (window.location.hash.startsWith('#tab-')) {
|
|
return window.location.hash.replace('#tab-', '')
|
|
}
|
|
|
|
return currentTabName
|
|
}
|