Fix handling of tabs in the plans page

Fixes #1768
This commit is contained in:
Joseph Schorr 2016-08-26 13:09:05 -04:00
parent 08e9a39099
commit b1e0620c1d
4 changed files with 708 additions and 693 deletions

View file

@ -9,52 +9,5 @@
});
}]);
function PlansCtrl($scope, $location, UserService, PlanService, $routeParams) {
// Monitor any user changes and place the current user into the scope.
UserService.updateUserIn($scope);
$('.plan-tabs a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
$location.search({'tab': e.target.getAttribute('data-target').substr(1)});
});
$scope.signedIn = function() {
$('#signinModal').modal('hide');
PlanService.handleNotedPlan();
};
$scope.qeStartTrial = function(plan) {
$scope.currentQEPlan = plan;
$('#tectonicManagerDialog').modal('show');
};
$scope.buyNow = function(plan) {
PlanService.notePlan(plan);
if ($scope.user && !$scope.user.anonymous) {
PlanService.handleNotedPlan();
} else {
$('#signinModal').modal({});
}
};
// Load the list of plans.
PlanService.getPlans(function(plans) {
$scope.plans = plans;
for (var i = 0; i < $scope.plans.length; ++i) {
var plan = plans[i];
if (plan.privateRepos > 20 && !plan.plans_page_hidden) {
$scope.dropdownPlan = plan.stripeId;
break
}
}
if ($scope && $routeParams['trial-plan']) {
$scope.buyNow($routeParams['trial-plan']);
}
if ($scope && $routeParams['tab'] == 'enterprise') {
$('#enterpriseTab').tab('show')
}
}, /* include the personal plan */ true);
}
function PlansCtrl($scope) {}
})();