pinchflat/assets/js/tabs.js
Kieran a2a0f48065
[Enhancement] Add media count to sources page (#251)
* [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
2024-05-21 08:53:22 -07:00

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
}