Created
February 5, 2013 14:06
-
-
Save mranosa/4714648 to your computer and use it in GitHub Desktop.
blah
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
InspectormanApp.controller('MainCtrl', function($scope, $timeout, NotificationService, | |
StringValidator, ProgressBarService, | |
$location, NavService) { | |
$scope.username = ''; | |
$scope.password = ''; | |
$scope.isLoading = false; | |
$scope.login = function(){ | |
//initial validation | |
if(!formEntriesValid($scope.username, $scope.password)) { | |
wobbleForm(); | |
return; | |
} | |
//TODO get user object then load everything | |
//show loading bar | |
$scope.isLoading = true; | |
//animate | |
console.log('Initialize everything...'); | |
ProgressBarService.start(); | |
ProgressBarService.animateProgress(45, function(){ | |
$timeout(function() { | |
console.log('Loading user info...'); | |
ProgressBarService.animateProgress(70, function(){ | |
$timeout(function() { | |
console.log('Loading user forms...'); | |
ProgressBarService.animateProgress(100, function(){ | |
console.log('Done!'); | |
$timeout(function() { | |
console.log(NavService); | |
NavService.showNav(); | |
NavService.dashboarActive(); | |
$timeout(function() { | |
$location.path('/dashboard'); | |
}, 1000); | |
}, 500); | |
}); | |
}, 2000); | |
}); | |
}, 2000); | |
}); | |
}; | |
function formEntriesValid(username, password){ | |
if(StringValidator.isEmpty(username) || StringValidator.isEmpty(password) || | |
StringValidator.isBlank(username) || StringValidator.isBlank(password)) { | |
NotificationService.warning('Empty Fields!', 'All Items are required.'); | |
return false; | |
} | |
return true; | |
} | |
function wobbleForm(){ | |
$('#login').addClass("wobble"); | |
$timeout(function() { | |
$('#login').removeClass("wobble"); | |
}, 1000); | |
} | |
//start the love | |
$scope.init(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment