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
|
|
|
*/
|
2019-07-31 04:23:13 -04:00
|
|
|
define(['base'], function(App) {
|
2018-11-05 05:06:39 -05:00
|
|
|
App.factory('MultiCurrencyPricing', function() {
|
|
|
|
const currencyCode = window.recomendedCurrency
|
|
|
|
|
|
|
|
return {
|
|
|
|
currencyCode,
|
|
|
|
|
|
|
|
plans: {
|
|
|
|
USD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$8',
|
|
|
|
annual: '$80'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '$15',
|
|
|
|
annual: '$180'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '$30',
|
|
|
|
annual: '$360'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
EUR: {
|
|
|
|
symbol: '€',
|
|
|
|
student: {
|
|
|
|
monthly: '€7',
|
|
|
|
annual: '€70'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '€14',
|
|
|
|
annual: '€168'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '€28',
|
|
|
|
annual: '€336'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
GBP: {
|
|
|
|
symbol: '£',
|
|
|
|
student: {
|
|
|
|
monthly: '£6',
|
|
|
|
annual: '£60'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '£12',
|
|
|
|
annual: '£144'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '£24',
|
|
|
|
annual: '£288'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
SEK: {
|
|
|
|
symbol: 'kr',
|
|
|
|
student: {
|
|
|
|
monthly: '60 kr',
|
|
|
|
annual: '600 kr'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '110 kr',
|
|
|
|
annual: '1320 kr'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '220 kr',
|
|
|
|
annual: '2640 kr'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
CAD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$9',
|
|
|
|
annual: '$90'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '$17',
|
|
|
|
annual: '$204'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '$34',
|
|
|
|
annual: '$408'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
NOK: {
|
|
|
|
symbol: 'kr',
|
|
|
|
student: {
|
|
|
|
monthly: '60 kr',
|
|
|
|
annual: '600 kr'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '110 kr',
|
|
|
|
annual: '1320 kr'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '220 kr',
|
|
|
|
annual: '2640 kr'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
DKK: {
|
|
|
|
symbol: 'kr',
|
|
|
|
student: {
|
|
|
|
monthly: '50 kr',
|
|
|
|
annual: '500 kr'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '90 kr',
|
|
|
|
annual: '1080 kr'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '180 kr',
|
|
|
|
annual: '2160 kr'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
AUD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$10',
|
|
|
|
annual: '$100'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '$18',
|
|
|
|
annual: '$216'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '$35',
|
|
|
|
annual: '$420'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
NZD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$10',
|
|
|
|
annual: '$100'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '$18',
|
|
|
|
annual: '$216'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '$35',
|
|
|
|
annual: '$420'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
CHF: {
|
|
|
|
symbol: 'Fr',
|
|
|
|
student: {
|
|
|
|
monthly: 'Fr 8',
|
|
|
|
annual: 'Fr 80'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: 'Fr 15',
|
|
|
|
annual: 'Fr 180'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: 'Fr 30',
|
|
|
|
annual: 'Fr 360'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
SGD: {
|
|
|
|
symbol: '$',
|
|
|
|
student: {
|
|
|
|
monthly: '$12',
|
|
|
|
annual: '$120'
|
|
|
|
},
|
|
|
|
collaborator: {
|
|
|
|
monthly: '$20',
|
|
|
|
annual: '$240'
|
|
|
|
},
|
|
|
|
professional: {
|
|
|
|
monthly: '$40',
|
|
|
|
annual: '$480'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2018-11-13 08:35:50 -05:00
|
|
|
App.controller('PlansController', function(
|
2018-11-05 05:06:39 -05:00
|
|
|
$scope,
|
|
|
|
$modal,
|
2019-10-23 08:22:50 -04:00
|
|
|
eventTracking,
|
2018-11-05 05:06:39 -05:00
|
|
|
MultiCurrencyPricing,
|
|
|
|
$http,
|
|
|
|
$filter,
|
2018-11-13 08:35:50 -05:00
|
|
|
ipCookie,
|
|
|
|
$location
|
2018-11-05 05:06:39 -05:00
|
|
|
) {
|
|
|
|
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()
|
2018-11-13 08:35:50 -05:00
|
|
|
$scope.currencyCode = newCurrency
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.signUpNowClicked = function(plan, location) {
|
|
|
|
if ($scope.ui.view === 'annual') {
|
|
|
|
plan = `${plan}_annual`
|
|
|
|
}
|
|
|
|
plan = eventLabel(plan, location)
|
2019-10-23 08:22:50 -04:00
|
|
|
eventTracking.sendMB('plans-page-start-trial')
|
|
|
|
eventTracking.send('subscription-funnel', 'sign_up_now_button', plan)
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
$scope.switchToMonthly = function(e, location) {
|
|
|
|
const uiView = 'monthly'
|
|
|
|
switchEvent(e, uiView + '-prices', location)
|
2018-11-13 08:35:50 -05:00
|
|
|
$scope.ui.view = uiView
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
$scope.switchToStudent = function(e, location) {
|
|
|
|
const uiView = 'student'
|
|
|
|
switchEvent(e, uiView + '-prices', location)
|
2018-11-13 08:35:50 -05:00
|
|
|
$scope.ui.view = uiView
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
$scope.switchToAnnual = function(e, location) {
|
|
|
|
const uiView = 'annual'
|
|
|
|
switchEvent(e, uiView + '-prices', location)
|
2018-11-13 08:35:50 -05:00
|
|
|
$scope.ui.view = uiView
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
$scope.openGroupPlanModal = function() {
|
2019-03-27 06:08:45 -04:00
|
|
|
const path = `${window.location.pathname}${window.location.search}`
|
|
|
|
history.replaceState(null, document.title, path + '#groups')
|
2018-11-13 08:35:50 -05:00
|
|
|
$modal
|
|
|
|
.open({
|
|
|
|
templateUrl: 'groupPlanModalPurchaseTemplate',
|
|
|
|
controller: 'GroupPlansModalPurchaseController'
|
|
|
|
})
|
|
|
|
.result.finally(() =>
|
|
|
|
history.replaceState(null, document.title, window.location.pathname)
|
|
|
|
)
|
2019-10-23 08:22:50 -04:00
|
|
|
eventTracking.send(
|
2018-11-05 05:06:39 -05:00
|
|
|
'subscription-funnel',
|
|
|
|
'plans-page',
|
|
|
|
'group-inquiry-potential'
|
|
|
|
)
|
|
|
|
}
|
2018-11-13 08:35:50 -05:00
|
|
|
if ($location.hash() === 'groups') {
|
|
|
|
$scope.openGroupPlanModal()
|
|
|
|
}
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2019-10-01 07:47:32 -04:00
|
|
|
$scope.openPayByInvoiceModal = function() {
|
|
|
|
const path = `${window.location.pathname}${window.location.search}`
|
|
|
|
history.replaceState(null, document.title, path + '#pay-by-invoice')
|
|
|
|
$modal
|
|
|
|
.open({
|
|
|
|
templateUrl: 'groupPlanModalInquiryTemplate'
|
|
|
|
})
|
|
|
|
.result.finally(() =>
|
|
|
|
history.replaceState(null, document.title, window.location.pathname)
|
|
|
|
)
|
2019-10-23 08:22:50 -04:00
|
|
|
eventTracking.send(
|
2019-10-01 07:47:32 -04:00
|
|
|
'subscription-funnel',
|
|
|
|
'plans-page',
|
|
|
|
'group-inquiry-potential'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
if ($location.hash() === 'pay-by-invoice') {
|
|
|
|
$scope.openPayByInvoiceModal()
|
|
|
|
}
|
|
|
|
|
2018-11-05 05:06:39 -05:00
|
|
|
var eventLabel = (label, location) => label
|
|
|
|
|
2018-11-13 08:35:50 -05:00
|
|
|
switchEvent = function(e, label, location) {
|
2018-11-05 05:06:39 -05:00
|
|
|
e.preventDefault()
|
|
|
|
const gaLabel = eventLabel(label, location)
|
2019-10-23 08:22:50 -04:00
|
|
|
eventTracking.send('subscription-funnel', 'plans-page', gaLabel)
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-03-27 06:08:45 -04:00
|
|
|
App.controller('GroupPlansModalPurchaseController', function(
|
|
|
|
$scope,
|
|
|
|
$modal,
|
|
|
|
$location
|
|
|
|
) {
|
2018-11-13 08:35:50 -05:00
|
|
|
$scope.options = {
|
|
|
|
plan_codes: [
|
|
|
|
{
|
|
|
|
display: 'Collaborator',
|
|
|
|
code: 'collaborator'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
display: 'Professional',
|
|
|
|
code: 'professional'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
currencies: [
|
|
|
|
{
|
|
|
|
display: 'USD ($)',
|
|
|
|
code: 'USD'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
display: 'GBP (£)',
|
|
|
|
code: 'GBP'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
display: 'EUR (€)',
|
|
|
|
code: 'EUR'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
currencySymbols: {
|
|
|
|
USD: '$',
|
|
|
|
EUR: '€',
|
|
|
|
GBP: '£'
|
|
|
|
},
|
|
|
|
sizes: [2, 3, 4, 5, 10, 20, 50],
|
|
|
|
usages: [
|
|
|
|
{
|
|
|
|
display: 'Enterprise',
|
|
|
|
code: 'enterprise'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
display: 'Educational',
|
|
|
|
code: 'educational'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.prices = window.groupPlans
|
|
|
|
|
|
|
|
let currency = 'USD'
|
|
|
|
if (['USD', 'GBP', 'EUR'].includes(window.recomendedCurrency)) {
|
|
|
|
currency = window.recomendedCurrency
|
|
|
|
}
|
|
|
|
|
2019-03-27 06:08:45 -04:00
|
|
|
// default selected
|
2018-11-13 08:35:50 -05:00
|
|
|
$scope.selected = {
|
|
|
|
plan_code: 'collaborator',
|
|
|
|
currency,
|
|
|
|
size: '10',
|
|
|
|
usage: 'educational'
|
|
|
|
}
|
2019-03-27 06:08:45 -04:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// plan
|
|
|
|
if ($location.search().plan) {
|
|
|
|
$scope.options.plan_codes.forEach(plan => {
|
|
|
|
if (plan.code === $location.search().plan) {
|
|
|
|
$scope.selected.plan_code = plan.code
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// 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
|
|
|
|
|
|
|
$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}`
|
2019-11-12 03:56:24 -05:00
|
|
|
window.location = `/user/subscription/new?planCode=${plan_code}¤cy=${currency}&itm_campaign=groups`
|
2018-11-13 08:35:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
$scope.payByInvoice = function() {
|
|
|
|
$modal.open({
|
|
|
|
templateUrl: 'groupPlanModalInquiryTemplate'
|
|
|
|
})
|
|
|
|
$scope.$close()
|
|
|
|
}
|
2018-11-05 05:06:39 -05:00
|
|
|
})
|
|
|
|
})
|