Move the planCode logic for Collaborator into a helper function.

This commit is contained in:
Shane Kilkelly 2016-11-02 09:56:33 +00:00
parent 4623f3cbe7
commit a63f7685b8
2 changed files with 16 additions and 2 deletions

View file

@ -100,8 +100,7 @@ block content
li
br
a.btn.btn-info(
ng-href="#{baseUrl}/user/subscription/new?planCode=collaborator{{ (ui.view == 'annual' ? '-annual' : '') + (plansVariant == 'default' ? planQueryString : '_'+plansVariant)}}&currency={{currencyCode}}", ng-click="signUpNowClicked('collaborator')"
ng-href="#{baseUrl}/user/subscription/new?planCode={{ getCollaboratorPlanCode() }}&currency={{currencyCode}}", ng-click="signUpNowClicked('collaborator')"
)
span(ng-show="ui.view != 'annual'") #{translate("start_free_trial")}
span(ng-show="ui.view == 'annual'") #{translate("buy_now")}

View file

@ -338,6 +338,21 @@ define [
$scope.changeCurreny = (newCurrency)->
$scope.currencyCode = newCurrency
# because ternary logic in angular bindings is hard
$scope.getCollaboratorPlanCode = () ->
view = $scope.ui.view
variant = $scope.plansVariant
if view == "annual"
if variant == "default"
return "collaborator-annual"
else
return "collaborator-annual_#{variant}"
else
if variant == "default"
return "collaborator#{$scope.planQueryString}"
else
return "collaborator_#{variant}"
$scope.signUpNowClicked = (plan, annual)->
event_tracking.sendMB 'plans-page-start-trial', {plan}
if $scope.ui.view == "annual"