mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
487ff4f505
GitOrigin-RevId: 66a0a423fe48a8a8a7ddd292ba218cd5038dfdb1
105 lines
2.9 KiB
JavaScript
105 lines
2.9 KiB
JavaScript
import '../../../../marketing'
|
|
|
|
import * as eventTracking from '../../../../infrastructure/event-tracking'
|
|
import {
|
|
setUpStickyHeaderObserver,
|
|
switchStickyHeader,
|
|
} from './plans-v2-sticky-header'
|
|
import {
|
|
disableMonthlyAnnualSwitching,
|
|
enableMonthlyAnnualSwitching,
|
|
hideMonthlyAnnualSwitchOnSmallScreen,
|
|
showMonthlyAnnualSwitchOnSmallScreen,
|
|
hideMonthlyAnnualTooltip,
|
|
showMonthlyAnnualTooltip,
|
|
setUpMonthlyAnnualSwitching,
|
|
underlineAnnualText,
|
|
switchUnderlineText,
|
|
} from './plans-v2-m-a-switch'
|
|
import {
|
|
changeGroupPlanModalEducationalDiscount,
|
|
changeGroupPlanModalNumberOfLicenses,
|
|
hideGroupPlansLicensePicker,
|
|
showGroupPlansLicensePicker,
|
|
updateMainGroupPlanPricing,
|
|
} from './plans-v2-group-plan'
|
|
import { setUpGroupSubscriptionButtonAction } from './plans-v2-subscription-button'
|
|
import { updateLinkTargets } from '../plans'
|
|
|
|
function selectTab(viewTab) {
|
|
document.querySelectorAll('[data-ol-plans-v2-view-tab]').forEach(el => {
|
|
if (el.getAttribute('data-ol-plans-v2-view-tab') === viewTab) {
|
|
el.classList.add('active')
|
|
} else {
|
|
el.classList.remove('active')
|
|
}
|
|
})
|
|
|
|
document.querySelectorAll('[data-ol-plans-v2-view]').forEach(el => {
|
|
el.hidden = el.getAttribute('data-ol-plans-v2-view') !== viewTab
|
|
})
|
|
|
|
switchUnderlineText()
|
|
switchStickyHeader(viewTab)
|
|
|
|
// group tab is special because group plan only has annual value
|
|
// so we need to perform some UI changes whenever user click the group tab
|
|
if (viewTab === 'group') {
|
|
disableMonthlyAnnualSwitching()
|
|
hideMonthlyAnnualTooltip()
|
|
updateMainGroupPlanPricing()
|
|
underlineAnnualText()
|
|
showGroupPlansLicensePicker()
|
|
hideMonthlyAnnualSwitchOnSmallScreen()
|
|
} else {
|
|
enableMonthlyAnnualSwitching()
|
|
showMonthlyAnnualTooltip()
|
|
hideGroupPlansLicensePicker()
|
|
showMonthlyAnnualSwitchOnSmallScreen()
|
|
}
|
|
}
|
|
|
|
function setUpTabSwitching() {
|
|
document.querySelectorAll('[data-ol-plans-v2-view-tab]').forEach(el => {
|
|
const viewTab = el.getAttribute('data-ol-plans-v2-view-tab')
|
|
|
|
el.querySelector('a').addEventListener('click', function (e) {
|
|
e.preventDefault()
|
|
eventTracking.send(
|
|
'subscription-funnel',
|
|
'plans-page',
|
|
`${viewTab}-prices`
|
|
)
|
|
selectTab(viewTab)
|
|
})
|
|
})
|
|
}
|
|
|
|
function setUpGroupPlanPricingChange() {
|
|
document
|
|
.querySelectorAll('[data-ol-plans-v2-license-picker-select]')
|
|
.forEach(el => {
|
|
el.addEventListener('change', () => {
|
|
updateMainGroupPlanPricing()
|
|
changeGroupPlanModalNumberOfLicenses()
|
|
})
|
|
})
|
|
|
|
document
|
|
.querySelectorAll(
|
|
'[data-ol-plans-v2-license-picker-educational-discount-input]'
|
|
)
|
|
.forEach(el =>
|
|
el.addEventListener('change', () => {
|
|
updateMainGroupPlanPricing()
|
|
changeGroupPlanModalEducationalDiscount()
|
|
})
|
|
)
|
|
}
|
|
|
|
setUpTabSwitching()
|
|
setUpGroupPlanPricingChange()
|
|
setUpMonthlyAnnualSwitching()
|
|
setUpGroupSubscriptionButtonAction()
|
|
setUpStickyHeaderObserver()
|
|
updateLinkTargets()
|