mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Port ability to set plans page tab view with URL hash
GitOrigin-RevId: 367829b46a1e984f19a131999938c554a960eccf
This commit is contained in:
parent
0cb51a3d52
commit
b3d5a2c7f0
1 changed files with 20 additions and 0 deletions
|
@ -90,6 +90,23 @@ function setUpGroupPlanPricingChange() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectViewFromHash() {
|
||||||
|
try {
|
||||||
|
const params = new URLSearchParams(window.location.hash.substring(1))
|
||||||
|
const view = params.get('view')
|
||||||
|
if (view) {
|
||||||
|
// make sure the selected view is valid
|
||||||
|
if (document.querySelector(`[data-ol-plans-v2-view-tab="${view}"]`)) {
|
||||||
|
selectTab(view)
|
||||||
|
// clear the hash so it doesn't persist when switching plans
|
||||||
|
window.location.hash = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document
|
document
|
||||||
.querySelector('[data-ol-plans-v2-m-a-switch]')
|
.querySelector('[data-ol-plans-v2-m-a-switch]')
|
||||||
.addEventListener('click', () => {
|
.addEventListener('click', () => {
|
||||||
|
@ -112,3 +129,6 @@ setUpMonthlyAnnualSwitching()
|
||||||
setUpGroupSubscriptionButtonAction()
|
setUpGroupSubscriptionButtonAction()
|
||||||
setUpStickyHeaderObserver()
|
setUpStickyHeaderObserver()
|
||||||
updateLinkTargets()
|
updateLinkTargets()
|
||||||
|
|
||||||
|
selectViewFromHash()
|
||||||
|
window.addEventListener('hashchange', selectViewFromHash)
|
||||||
|
|
Loading…
Reference in a new issue