2014-07-08 07:02:26 -04:00
|
|
|
define [
|
|
|
|
"base"
|
2014-09-04 14:03:04 -04:00
|
|
|
"libs/recurly-3.0.5"
|
|
|
|
], (App, recurly) ->
|
2014-09-01 12:48:09 -04:00
|
|
|
App.controller "PlansController", ($scope, $modal, event_tracking, abTestManager) ->
|
2014-07-21 06:33:10 -04:00
|
|
|
|
2014-09-04 14:03:04 -04:00
|
|
|
recurly.configure(window.recurlyPublicToken);
|
|
|
|
|
|
|
|
pricing = recurly.Pricing()
|
|
|
|
window.pricing = pricing
|
|
|
|
|
|
|
|
$scope.currencyCode = pricing.items.currency
|
|
|
|
pricing.on "set.currency", (currency)->
|
|
|
|
$scope.currencyCode = pricing.items.currency
|
2014-09-01 12:48:09 -04:00
|
|
|
|
|
|
|
buckets = [
|
|
|
|
{ bucketName:"30d", queryString: "_free_trial", trial_len:30 }
|
|
|
|
{ bucketName:"14d", queryString: "_free_trial_14_days", trial_len:14 }
|
|
|
|
]
|
|
|
|
bucket = abTestManager.getABTestBucket "trial_len", buckets
|
|
|
|
|
|
|
|
$scope.trial_len = bucket.trial_len
|
|
|
|
$scope.planQueryString = bucket.queryString
|
|
|
|
|
2014-07-08 07:02:26 -04:00
|
|
|
$scope.ui =
|
2014-07-21 06:33:10 -04:00
|
|
|
view: "monthly"
|
|
|
|
|
2014-09-04 14:03:04 -04:00
|
|
|
$scope.plans =
|
2014-09-05 06:40:14 -04:00
|
|
|
USD:
|
2014-09-04 14:03:04 -04:00
|
|
|
symbol: "$"
|
|
|
|
student:
|
|
|
|
monthly: "$8"
|
|
|
|
annual: "$80"
|
|
|
|
collaborator:
|
|
|
|
monthly: "$15"
|
|
|
|
annual: "$180"
|
|
|
|
professional:
|
|
|
|
monthly: "$30"
|
|
|
|
annual: "$360"
|
|
|
|
|
2014-09-05 06:40:14 -04:00
|
|
|
EUR:
|
2014-09-04 14:03:04 -04:00
|
|
|
symbol: "€"
|
|
|
|
student:
|
|
|
|
monthly: "€8"
|
|
|
|
annual: "€80"
|
|
|
|
collaborator:
|
|
|
|
monthly: "€15"
|
|
|
|
annual: "€180"
|
|
|
|
professional:
|
|
|
|
monthly: "€30"
|
|
|
|
annual: "€360"
|
2014-09-05 06:40:14 -04:00
|
|
|
GBP:
|
2014-09-04 14:03:04 -04:00
|
|
|
symbol: "£"
|
|
|
|
student:
|
|
|
|
monthly: "£8"
|
|
|
|
annual: "£80"
|
|
|
|
collaborator:
|
|
|
|
monthly: "£15"
|
|
|
|
annual: "£180"
|
|
|
|
professional:
|
|
|
|
monthly: "£30"
|
|
|
|
annual: "£360"
|
|
|
|
|
|
|
|
$scope.changeCurreny = (newCurrency)->
|
|
|
|
$scope.currencyCode = newCurrency
|
|
|
|
|
2014-07-21 06:33:10 -04:00
|
|
|
$scope.signUpNowClicked = (plan, annual)->
|
|
|
|
if $scope.ui.view == "annual"
|
|
|
|
plan = "#{plan}_annual"
|
2014-09-02 06:07:21 -04:00
|
|
|
else
|
|
|
|
abTestManager.processTestWithStep("trial_len", bucket.bucketName, 0)
|
2014-07-21 06:33:10 -04:00
|
|
|
event_tracking.send 'subscription-funnel', 'sign_up_now_button', plan
|
|
|
|
|
|
|
|
$scope.switchToMonthly = ->
|
|
|
|
$scope.ui.view = "monthly"
|
|
|
|
event_tracking.send 'subscription-funnel', 'plans-page', 'monthly-prices'
|
|
|
|
|
|
|
|
$scope.switchToStudent = ->
|
|
|
|
$scope.ui.view = "student"
|
|
|
|
event_tracking.send 'subscription-funnel', 'plans-page', 'student-prices'
|
|
|
|
|
|
|
|
$scope.switchToAnnual = ->
|
|
|
|
$scope.ui.view = "annual"
|
|
|
|
event_tracking.send 'subscription-funnel', 'plans-page', 'student-prices'
|
2014-07-25 07:32:26 -04:00
|
|
|
|
|
|
|
$scope.openGroupPlanModal = () ->
|
|
|
|
$modal.open {
|
|
|
|
templateUrl: "groupPlanModalTemplate"
|
|
|
|
}
|