Skip to content

Instantly share code, notes, and snippets.

@mranosa
Created February 5, 2013 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mranosa/4714648 to your computer and use it in GitHub Desktop.
Save mranosa/4714648 to your computer and use it in GitHub Desktop.
blah
'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