2018-11-05 05:06:39 -05:00
|
|
|
/* eslint-disable
|
|
|
|
camelcase,
|
2018-11-13 08:35:50 -05:00
|
|
|
max-len
|
2018-11-05 05:06:39 -05:00
|
|
|
*/
|
2020-05-19 05:02:56 -04:00
|
|
|
import App from '../base'
|
|
|
|
App.factory('MultiCurrencyPricing', function() {
|
|
|
|
const currencyCode = window.recomendedCurrency
|
|
|
|
|
|
|
|
return {
|
|
|
|
currencyCode,
|
|
|
|
|
|
|
|
plans: {
|
|
|
|
USD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$8',
|
|
|
|
annual: '$80'
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '$15',
|
|
|
|
annual: '$180'
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
professional: {
|
|
|
|
monthly: '$30',
|
|
|
|
annual: '$360'
|
|
|
|
}
|
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
EUR: {
|
|
|
|
symbol: '€',
|
|
|
|
student: {
|
|
|
|
monthly: '€7',
|
|
|
|
annual: '€70'
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '€14',
|
|
|
|
annual: '€168'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '€28',
|
|
|
|
annual: '€336'
|
|
|
|
}
|
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
GBP: {
|
|
|
|
symbol: '£',
|
|
|
|
student: {
|
|
|
|
monthly: '£6',
|
|
|
|
annual: '£60'
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '£12',
|
|
|
|
annual: '£144'
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
professional: {
|
|
|
|
monthly: '£24',
|
|
|
|
annual: '£288'
|
|
|
|
}
|
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
SEK: {
|
|
|
|
symbol: 'kr',
|
|
|
|
student: {
|
|
|
|
monthly: '60 kr',
|
|
|
|
annual: '600 kr'
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '110 kr',
|
|
|
|
annual: '1320 kr'
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
professional: {
|
|
|
|
monthly: '220 kr',
|
|
|
|
annual: '2640 kr'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
CAD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$9',
|
|
|
|
annual: '$90'
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '$17',
|
|
|
|
annual: '$204'
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
professional: {
|
|
|
|
monthly: '$34',
|
|
|
|
annual: '$408'
|
|
|
|
}
|
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
NOK: {
|
|
|
|
symbol: 'kr',
|
|
|
|
student: {
|
|
|
|
monthly: '60 kr',
|
|
|
|
annual: '600 kr'
|
2018-11-05 05:06:39 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '110 kr',
|
|
|
|
annual: '1320 kr'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '220 kr',
|
|
|
|
annual: '2640 kr'
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
2020-05-07 09:17:23 -04:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
DKK: {
|
|
|
|
symbol: 'kr',
|
|
|
|
student: {
|
|
|
|
monthly: '50 kr',
|
|
|
|
annual: '500 kr'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '90 kr',
|
|
|
|
annual: '1080 kr'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '180 kr',
|
|
|
|
annual: '2160 kr'
|
|
|
|
}
|
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
AUD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$10',
|
|
|
|
annual: '$100'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '$18',
|
|
|
|
annual: '$216'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '$35',
|
|
|
|
annual: '$420'
|
|
|
|
}
|
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
NZD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$10',
|
|
|
|
annual: '$100'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '$18',
|
|
|
|
annual: '$216'
|
2018-11-13 08:35:50 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
professional: {
|
|
|
|
monthly: '$35',
|
|
|
|
annual: '$420'
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
CHF: {
|
|
|
|
symbol: 'Fr',
|
|
|
|
student: {
|
|
|
|
monthly: 'Fr 8',
|
|
|
|
annual: 'Fr 80'
|
2018-11-13 08:35:50 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: 'Fr 15',
|
|
|
|
annual: 'Fr 180'
|
2018-11-13 08:35:50 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
professional: {
|
|
|
|
monthly: 'Fr 30',
|
|
|
|
annual: 'Fr 360'
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
|
|
|
|
SGD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$12',
|
|
|
|
annual: '$120'
|
2018-11-13 08:35:50 -05:00
|
|
|
},
|
2020-05-19 05:02:56 -04:00
|
|
|
collaborator: {
|
|
|
|
monthly: '$20',
|
|
|
|
annual: '$240'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '$40',
|
|
|
|
annual: '$480'
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
|
|
|
})
|
2018-11-13 08:35:50 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
App.controller('PlansController', function(
|
|
|
|
$scope,
|
|
|
|
$modal,
|
|
|
|
eventTracking,
|
|
|
|
MultiCurrencyPricing,
|
|
|
|
$http,
|
|
|
|
$filter,
|
|
|
|
ipCookie,
|
|
|
|
$location
|
|
|
|
) {
|
|
|
|
let switchEvent
|
|
|
|
$scope.showPlans = true
|
|
|
|
|
|
|
|
$scope.plans = MultiCurrencyPricing.plans
|
|
|
|
|
|
|
|
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
|
|
|
|
|
|
|
$scope.trial_len = 7
|
|
|
|
|
|
|
|
$scope.planQueryString = '_free_trial_7_days'
|
|
|
|
|
|
|
|
$scope.ui = { view: 'monthly' }
|
|
|
|
|
|
|
|
$scope.changeCurreny = function(e, newCurrency) {
|
|
|
|
e.preventDefault()
|
|
|
|
$scope.currencyCode = newCurrency
|
|
|
|
}
|
|
|
|
|
|
|
|
// because ternary logic in angular bindings is hard
|
|
|
|
$scope.getCollaboratorPlanCode = function() {
|
|
|
|
const { view } = $scope.ui
|
|
|
|
if (view === 'annual') {
|
|
|
|
return 'collaborator-annual'
|
|
|
|
} else {
|
|
|
|
return `collaborator${$scope.planQueryString}`
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
2018-11-13 08:35:50 -05:00
|
|
|
|
2020-05-19 05:02:56 -04:00
|
|
|
$scope.signUpNowClicked = function(plan, location) {
|
|
|
|
if ($scope.ui.view === 'annual') {
|
|
|
|
plan = `${plan}_annual`
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
plan = eventLabel(plan, location)
|
|
|
|
eventTracking.sendMB('plans-page-start-trial')
|
|
|
|
eventTracking.send('subscription-funnel', 'sign_up_now_button', plan)
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.switchToMonthly = function(e, location) {
|
|
|
|
const uiView = 'monthly'
|
|
|
|
switchEvent(e, uiView + '-prices', location)
|
|
|
|
$scope.ui.view = uiView
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.switchToStudent = function(e, location) {
|
|
|
|
const uiView = 'student'
|
|
|
|
switchEvent(e, uiView + '-prices', location)
|
|
|
|
$scope.ui.view = uiView
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.switchToAnnual = function(e, location) {
|
|
|
|
const uiView = 'annual'
|
|
|
|
switchEvent(e, uiView + '-prices', location)
|
|
|
|
$scope.ui.view = uiView
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.openGroupPlanModal = function() {
|
|
|
|
const path = `${window.location.pathname}${window.location.search}`
|
|
|
|
history.replaceState(null, document.title, path + '#groups')
|
|
|
|
$modal
|
|
|
|
.open({
|
|
|
|
templateUrl: 'groupPlanModalPurchaseTemplate',
|
|
|
|
controller: 'GroupPlansModalPurchaseController'
|
|
|
|
})
|
|
|
|
.result.finally(() =>
|
|
|
|
history.replaceState(null, document.title, window.location.pathname)
|
|
|
|
)
|
|
|
|
eventTracking.send(
|
|
|
|
'subscription-funnel',
|
|
|
|
'plans-page',
|
|
|
|
'group-inquiry-potential'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($location.hash() === 'groups') {
|
|
|
|
$scope.openGroupPlanModal()
|
|
|
|
}
|
|
|
|
|
|
|
|
var eventLabel = (label, location) => label
|
|
|
|
|
|
|
|
switchEvent = function(e, label, location) {
|
|
|
|
e.preventDefault()
|
|
|
|
const gaLabel = eventLabel(label, location)
|
|
|
|
eventTracking.send('subscription-funnel', 'plans-page', gaLabel)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
App.controller('GroupPlansModalPurchaseController', function(
|
|
|
|
$scope,
|
|
|
|
$modal,
|
|
|
|
$location
|
|
|
|
) {
|
|
|
|
$scope.options = {
|
|
|
|
plan_codes: [
|
|
|
|
{
|
|
|
|
display: 'Collaborator',
|
|
|
|
code: 'collaborator'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
display: 'Professional',
|
|
|
|
code: 'professional'
|
2019-03-27 06:08:45 -04:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
],
|
|
|
|
currencies: [
|
|
|
|
{
|
|
|
|
display: 'USD ($)',
|
|
|
|
code: 'USD'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
display: 'GBP (£)',
|
|
|
|
code: 'GBP'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
display: 'EUR (€)',
|
|
|
|
code: 'EUR'
|
2019-03-27 06:08:45 -04:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
],
|
|
|
|
currencySymbols: {
|
|
|
|
USD: '$',
|
|
|
|
EUR: '€',
|
|
|
|
GBP: '£'
|
|
|
|
},
|
|
|
|
sizes: [2, 3, 4, 5, 10, 20, 50],
|
|
|
|
usages: [
|
|
|
|
{
|
|
|
|
display: 'Enterprise',
|
|
|
|
code: 'enterprise'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
display: 'Educational',
|
|
|
|
code: 'educational'
|
2019-03-27 06:08:45 -04:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.prices = window.groupPlans
|
|
|
|
|
|
|
|
let currency = 'USD'
|
|
|
|
if (['USD', 'GBP', 'EUR'].includes(window.recomendedCurrency)) {
|
|
|
|
currency = window.recomendedCurrency
|
|
|
|
}
|
|
|
|
|
|
|
|
// default selected
|
|
|
|
$scope.selected = {
|
|
|
|
plan_code: 'collaborator',
|
|
|
|
currency,
|
|
|
|
size: '10',
|
|
|
|
usage: 'educational'
|
|
|
|
}
|
|
|
|
// selected via query
|
|
|
|
if ($location.search()) {
|
|
|
|
// usage
|
|
|
|
if ($location.search().usage) {
|
|
|
|
$scope.options.usages.forEach(usage => {
|
|
|
|
if (usage.code === $location.search().usage) {
|
|
|
|
$scope.selected.usage = usage.code
|
|
|
|
}
|
|
|
|
})
|
2019-03-27 06:08:45 -04:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
// plan
|
|
|
|
if ($location.search().plan) {
|
|
|
|
$scope.options.plan_codes.forEach(plan => {
|
|
|
|
if (plan.code === $location.search().plan) {
|
|
|
|
$scope.selected.plan_code = plan.code
|
|
|
|
}
|
|
|
|
})
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
// number
|
|
|
|
if ($location.search().number) {
|
|
|
|
// $location.search().number is a string,
|
|
|
|
// but $scope.options.sizes are numbers
|
|
|
|
// and $scope.selected.size is a string
|
|
|
|
const groupCount = parseInt($location.search().number, 10)
|
|
|
|
if ($scope.options.sizes.indexOf(groupCount) !== -1) {
|
|
|
|
$scope.selected.size = $location.search().number
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// currency
|
|
|
|
if ($location.search().currency) {
|
|
|
|
$scope.options.currencies.forEach(currency => {
|
|
|
|
if (currency.code === $location.search().currency) {
|
|
|
|
$scope.selected.currency = currency.code
|
|
|
|
}
|
|
|
|
})
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$scope.recalculatePrice = function() {
|
|
|
|
let { usage, plan_code, currency, size } = $scope.selected
|
|
|
|
const price = $scope.prices[usage][plan_code][currency][size]
|
|
|
|
const currencySymbol = $scope.options.currencySymbols[currency]
|
|
|
|
$scope.displayPrice = `${currencySymbol}${price}`
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.$watch('selected', $scope.recalculatePrice, true)
|
|
|
|
$scope.recalculatePrice()
|
|
|
|
|
|
|
|
$scope.purchase = function() {
|
|
|
|
let { plan_code, size, usage, currency } = $scope.selected
|
|
|
|
plan_code = `group_${plan_code}_${size}_${usage}`
|
|
|
|
window.location = `/user/subscription/new?planCode=${plan_code}¤cy=${currency}&itm_campaign=groups`
|
|
|
|
}
|
2018-11-05 05:06:39 -05:00
|
|
|
})
|