Chromium Code Reviews| Index: chrome/browser/resources/chromeos/login/screen_signin.js |
| diff --git a/chrome/browser/resources/chromeos/login/screen_signin.js b/chrome/browser/resources/chromeos/login/screen_signin.js |
| index d456765cbc14b0f0873715f0004e3c99c7087e15..2ebb94132d0ec480c7fa584e9a4cf4e2ceda8d1a 100644 |
| --- a/chrome/browser/resources/chromeos/login/screen_signin.js |
| +++ b/chrome/browser/resources/chromeos/login/screen_signin.js |
| @@ -32,6 +32,8 @@ cr.define('login', function() { |
| /** @inheritDoc */ |
| decorate: function() { |
| + $('email').addEventListener('keydown', this.handleKeyDown_.bind(this)); |
| + $('password').addEventListener('keydown', this.handleKeyDown_.bind(this)); |
| }, |
| /** |
| @@ -93,14 +95,50 @@ cr.define('login', function() { |
| }, |
| /** |
| + * Validates input fields. |
| + */ |
| + checkInput: function() { |
| + // Validate input. |
| + if (! $('email').value) { |
|
Nikita (slow)
2011/07/15 18:52:07
nit: nuke space between ! and $
xiyuan
2011/07/15 20:38:29
Done.
|
| + $('email').focus(); |
| + return false; |
| + } |
| + |
| + if (!$('password').value) { |
| + $('password').focus(); |
| + return false; |
| + } |
| + |
| + return true; |
| + }, |
| + |
| + /** |
| * Handles sign in button click. |
| * @private |
| */ |
| handleSigninClick_: function(e) { |
| + if (!this.checkInput()) |
| + return; |
| + |
| this.state = SigninScreen.STATE_AUTHENTICATING; |
| chrome.send('authenticateUser', |
| [$('email').value, $('password').value]); |
| + }, |
| + |
| + /** |
| + * Handles keyboard event. |
| + * @private |
| + */ |
| + handleKeyDown_: function(e) { |
| + // Handle 'Enter' key for 'email' and 'password' field. |
| + if (e.keyIdentifier == 'Enter') { |
| + if (e.target.id == 'email' && e.target.value) |
|
Nikita (slow)
2011/07/15 18:52:07
nit: might be rewritten as
if (.. 'email') {
if
xiyuan
2011/07/15 20:38:29
I think javascript uses shortcut boolean operation
Nikita (slow)
2011/07/18 07:50:50
What I've meant was that you need to compare strin
xiyuan
2011/07/18 18:32:09
I see what you mean. Changed as suggested.
|
| + $('password').focus(); |
| + |
| + if (e.target.id == 'password') |
|
Fady Samuel
2011/07/15 20:11:34
Does this mean one doesn't need a password to logi
xiyuan
2011/07/15 20:38:29
The part to check empty password is in checkInput
|
| + this.handleSigninClick_(); |
| + } |
| } |
| }; |