Files
habitica/website/client-old/js/controllers/newGroupCtrl.js
yugensoft c502b1997b Updated new-groups / group-plans static page #8674 (#8729)
* dummy

* Renamed internationalized strings to more meaningful names

* moved the new group creation state out to its own URL, so it can also be linked to by the static/plans page

* Added redirect-through-login functionality from the static/plans page new-group button
This includes a static non-modal login page (similar to how other sites have both a login page and login modal)
The login body has been abstracted out from its modal-specific view into mixins to accomplish this

* deleted bak files added by mistake

* deleted scripts added by mistake

* changed static/plans Create Group button text

* Added form link (https://github.com/HabitRPG/habitica/issues/8674#issuecomment-303518039)
Removed changes to non-EN locale files (https://github.com/HabitRPG/habitica/pull/8729#issuecomment-303555211)

* reverted key name changes as per https://github.com/HabitRPG/habitica/pull/8729#issuecomment-304515534

* changed $rootScope to $scope
https://github.com/HabitRPG/habitica/pull/8729#discussion_r120695874
2017-07-06 14:08:02 -07:00

54 lines
1.4 KiB
JavaScript

"use strict";
/*
A controller to manage the New Group page
*/
angular.module('habitrpg')
.controller("NewGroupCtrl", ['$scope', '$window', 'Groups', 'Payments',
function ($scope, $window, Groups, Payments) {
$scope.PAGES = {
CREATE_GROUP: 'create-group',
UPGRADE_GROUP: 'upgrade-group',
};
$scope.activePage = $scope.PAGES.CREATE_GROUP;
$scope.changePage = function (page) {
$scope.activePage = page;
$window.scrollTo(0, 0);
};
$scope.newGroup = {
type: 'guild',
privacy: 'private',
};
$scope.PAYMENTS = {
AMAZON: 'amazon',
STRIPE: 'stripe',
};
$scope.newGroupIsReady = function () {
return !!$scope.newGroup.name;
};
$scope.createGroup = function () {
$scope.changePage($scope.PAGES.UPGRADE_GROUP);
};
$scope.upgradeGroup = function (paymentType) {
var subscriptionKey = 'group_monthly'; // @TODO: Get from content API?
if (paymentType === $scope.PAYMENTS.STRIPE) Payments.showStripe({
subscription: subscriptionKey,
coupon: null,
groupToCreate: $scope.newGroup
});
if (paymentType === $scope.PAYMENTS.AMAZON) Payments.amazonPayments.init({
type: 'subscription',
subscription: subscriptionKey,
coupon: null,
groupToCreate: $scope.newGroup
});
};
}]);