From d1fd6de6718246746e1682a89c5c8fe7108e7c7f Mon Sep 17 00:00:00 2001 From: Daniel Camargo Date: Wed, 9 Oct 2013 00:22:25 -0300 Subject: [PATCH] fixed the alert problem and another bug I found at sign in --- www/assets/js/app.js | 7 ++++--- www/assets/js/services.account.js | 15 +++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/www/assets/js/app.js b/www/assets/js/app.js index d954bc254..e862bc763 100644 --- a/www/assets/js/app.js +++ b/www/assets/js/app.js @@ -336,11 +336,12 @@ NGApp.controller('AppController', function ($scope, $route, $routeParams, $rootS }); -App.alert = function(txt, title) { +App.alert = function( txt, title, useNativeAlert ) { setTimeout(function() { - // @todo: #1546 - if (App.useNativeAlert && App.isPhoneGap) { + if (useNativeAlert && App.isPhoneGap) { navigator.notification.alert(txt, null, title || 'Crunchbutton'); + } else if ( useNativeAlert ) { + alert( txt ); } else { App.rootScope.$broadcast('notificationAlert', title || null, txt); } diff --git a/www/assets/js/services.account.js b/www/assets/js/services.account.js index 856ba0249..1ce811cce 100644 --- a/www/assets/js/services.account.js +++ b/www/assets/js/services.account.js @@ -42,13 +42,13 @@ NGApp.factory( 'AccountService', function( $http, $rootScope, PositionsService ) service.signin = function(){ if( !service.isValidEmailPhone() ){ - alert( 'Please enter a valid email or phone.' ); + App.alert( 'Please enter a valid email or phone.', null, true ); $rootScope.focus( '.signin-email' ); return; } if( !service.isValidPassword() ){ - alert( 'Please enter your password.' ); + App.alert( 'Please enter your password.', null, true ); $rootScope.focus( '.signin-password' ); return; } @@ -83,13 +83,13 @@ NGApp.factory( 'AccountService', function( $http, $rootScope, PositionsService ) service.signup = function(){ if( !service.isValidEmailPhone() ){ - alert( 'Please enter a valid email or phone.' ); + App.alert( 'Please enter a valid email or phone.', null, true ); $rootScope.focus( '.signup-email' ); return; } if( !service.isValidPassword() ){ - App.alert( 'Please enter a password.' ); + App.alert( 'Please enter a password.', null, true ); $rootScope.focus( '.signup-password' ); return; } @@ -161,7 +161,10 @@ NGApp.factory( 'AccountService', function( $http, $rootScope, PositionsService ) } service.isValidPassword = function(){ - return service.password != ''; + if( service.form.password ){ + return service.form.password != ''; + } + return false; } return service; @@ -204,7 +207,7 @@ NGApp.factory( 'AccountHelpService', function( $http, $rootScope, AccountService service.sendForm = function(){ if( !account.isValidEmailPhone() ){ - alert( 'Please enter a valid email or phone.' ); + App.alert( 'Please enter a valid email or phone.', null, true ); $rootScope.focus( '.help-email' ); return; }