Code cleanup part #1: move all the services and directive JS code in the app.js file into its own files
This commit is contained in:
parent
3cae6609a7
commit
9b87999c1c
97 changed files with 7076 additions and 6870 deletions
51
static/js/directives/ui/signup-form.js
Normal file
51
static/js/directives/ui/signup-form.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* An element which displays the sign up form.
|
||||
*/
|
||||
angular.module('quay').directive('signupForm', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
templateUrl: '/static/directives/signup-form.html',
|
||||
replace: false,
|
||||
transclude: true,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
'inviteCode': '=inviteCode',
|
||||
|
||||
'userRegistered': '&userRegistered'
|
||||
},
|
||||
controller: function($scope, $location, $timeout, ApiService, KeyService, UserService, Config, UIService) {
|
||||
$('.form-signup').popover();
|
||||
|
||||
$scope.awaitingConfirmation = false;
|
||||
$scope.registering = false;
|
||||
|
||||
$scope.register = function() {
|
||||
UIService.hidePopover('#signupButton');
|
||||
$scope.registering = true;
|
||||
|
||||
if ($scope.inviteCode) {
|
||||
$scope.newUser['invite_code'] = $scope.inviteCode;
|
||||
}
|
||||
|
||||
ApiService.createNewUser($scope.newUser).then(function(resp) {
|
||||
$scope.registering = false;
|
||||
$scope.awaitingConfirmation = !!resp['awaiting_verification'];
|
||||
|
||||
if (Config.MIXPANEL_KEY) {
|
||||
mixpanel.alias($scope.newUser.username);
|
||||
}
|
||||
|
||||
$scope.userRegistered({'username': $scope.newUser.username});
|
||||
|
||||
if (!$scope.awaitingConfirmation) {
|
||||
document.location = '/';
|
||||
}
|
||||
}, function(result) {
|
||||
$scope.registering = false;
|
||||
UIService.showFormError('#signupButton', result);
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
});
|
Reference in a new issue