2022-05-12 07:38:02 -04:00
|
|
|
import '../../../../marketing'
|
|
|
|
|
2022-05-19 05:13:25 -04:00
|
|
|
import * as eventTracking from '../../../../infrastructure/event-tracking'
|
2022-05-12 07:38:02 -04:00
|
|
|
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,
|
2022-05-19 07:57:36 -04:00
|
|
|
updateMainGroupPlanPricing,
|
2022-05-12 07:38:02 -04:00
|
|
|
} 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()
|
2022-05-19 07:57:36 -04:00
|
|
|
updateMainGroupPlanPricing()
|
2022-05-12 07:38:02 -04:00
|
|
|
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()
|
2022-05-19 05:13:25 -04:00
|
|
|
eventTracking.send(
|
|
|
|
'subscription-funnel',
|
|
|
|
'plans-page',
|
|
|
|
`${viewTab}-prices`
|
|
|
|
)
|
2022-05-12 07:38:02 -04:00
|
|
|
selectTab(viewTab)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function setUpGroupPlanPricingChange() {
|
|
|
|
document
|
|
|
|
.querySelectorAll('[data-ol-plans-v2-license-picker-select]')
|
|
|
|
.forEach(el => {
|
|
|
|
el.addEventListener('change', () => {
|
2022-05-19 07:57:36 -04:00
|
|
|
updateMainGroupPlanPricing()
|
|
|
|
changeGroupPlanModalNumberOfLicenses()
|
2022-05-12 07:38:02 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
document
|
|
|
|
.querySelectorAll(
|
|
|
|
'[data-ol-plans-v2-license-picker-educational-discount-input]'
|
|
|
|
)
|
|
|
|
.forEach(el =>
|
|
|
|
el.addEventListener('change', () => {
|
2022-05-19 07:57:36 -04:00
|
|
|
updateMainGroupPlanPricing()
|
|
|
|
changeGroupPlanModalEducationalDiscount()
|
2022-05-12 07:38:02 -04:00
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
setUpTabSwitching()
|
|
|
|
setUpGroupPlanPricingChange()
|
|
|
|
setUpMonthlyAnnualSwitching()
|
|
|
|
setUpGroupSubscriptionButtonAction()
|
|
|
|
setUpStickyHeaderObserver()
|
|
|
|
updateLinkTargets()
|