Advertisement
Guest User

index.js

a guest
Oct 30th, 2014
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Created by Mike on 6/27/14.
  3.  */
  4. angular.module("scorePortalApp")
  5.     .controller('indexController',function($scope, $rootScope, loginService, indexInviteService,$splash){
  6.  
  7.         //Google Sign In
  8.         $scope.$on('event:google-plus-signin-success', function (event, authResult) {
  9.             // User successfully authorized the G+ App!
  10.             console.log('Signed in!');
  11.             loginService.authenticate(authResult).success(function(data, status, headers, config){
  12.                 $rootScope.$state.go('home');
  13.                 //$rootScope.$state.go(data.nextPage);
  14.             });
  15.         });
  16.         $scope.$on('event:google-plus-signin-failure', function (event, authResult) {
  17.             // User has not authorized the G+ App!
  18.             console.log('Not signed into Google Plus.');
  19.         });
  20.  
  21.         $scope.schools = ["Arcadia High School",
  22.             "Alhambra High School",
  23.             "San Gabriel High School",
  24.             "Mark Keppel High",
  25.             "San Marino High School",
  26.             "Leuzinger High School",
  27.             "Lawndale High School",
  28.             "John Glenn High School",
  29.             "La Mirada High School",
  30.             "Norwalk High School",
  31.             "Berkeley High School",
  32.             "Camino Nuevo Charter Academy No. 4",
  33.             "New Millennium Secondary",
  34.             "Los Angeles Leadership Academy",
  35.             "Celerity Nascent Charter",
  36.             "Academia Moderna",
  37.             "Los Angeles Academy of Arts & Enterprise Charter",
  38.             "Crenshaw Arts-Technology Charter High",
  39.             "Global Education Academy",
  40.             "New Los Angeles Charter",
  41.             "Los Angeles Big Picture High",
  42.             "Vista Charter Middle",
  43.             "Larchmont Charter",
  44.             "Watts Learning Center",
  45.             "Extera Public",
  46.             "TEACH Academy of Technologies",
  47.             "Academy of Science and Engineering",
  48.             "New Heights Charter",
  49.             "Apple Academy Charter Public",
  50.             "Ararat Charter",
  51.             "Goethe International Charter",
  52.             "City Charter Middle",
  53.             "N.E.W. Academy Canoga Park",
  54.             "James Jordan Middle",
  55.             "Discovery Charter Preparatory No. 2",
  56.             "Fenton Primary Center",
  57.             "North Valley Charter Academy",
  58.             "Crown Preparatory Academy",
  59.             "Center for Advanced Learning",
  60.             "Aspire Pacific Academy",
  61.             "Gateway High"];
  62.  
  63.         $scope.request = {
  64.             'firstName':'',
  65.             'lastName':'',
  66.             'email':'',
  67.             'schoolName':''
  68.         };
  69.  
  70.         $scope.elementStates = {
  71.             //Control Error Message Collapse
  72.             errorCollapse:true,
  73.             //Disable submit button on submitting
  74.             submitButtonEnable:true,
  75.             //fa-refresh icon
  76.             submitting:false,
  77.             //If form submit was successful
  78.             success:false
  79.         };
  80.  
  81.         $scope.requestInvite = function(){
  82.             //Disable Submit Button
  83.             $scope.elementStates.submitButtonEnable = false;
  84.             //Show Spinner
  85.             $scope.elementStates.submitting = true;
  86.             console.log($scope.elementStates);
  87.  
  88.             console.log($scope.request);
  89.             indexInviteService.requestInvite($scope.request)
  90.                 .success(function(data, status, headers, config){
  91.                     //Collapse Error
  92.                     $scope.elementStates.errorCollapse = true;
  93.                     //Show Success Message
  94.                     $scope.elementStates.success = true;
  95.                 })
  96.                 .error(function(data, status, headers, config){
  97.                     //Show Error
  98.                     $scope.elementStates.errorCollapse = false;
  99.                     //Re-Enable Submit Button
  100.                     $scope.elementStates.submitButtonEnable = true;
  101.                     //Disable Spinner Icon, Restore Text
  102.                     $scope.elementStates.submitting = false;
  103.                     //Form was not successfully submitted
  104.                     $scope.elementStates.success = false;
  105.                 });
  106.         };
  107.  
  108.         //TOS
  109.         $scope.showTos = function () {
  110.             $splash.open({
  111.                 type: 'tos'
  112.             });
  113.         };
  114. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement