Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Side by Side Diff: chrome/browser/resources/chromeos/login/screen_signin.js

Issue 7382001: [ChromeOS] WebUI OOBE/Login refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync and address comments in set #1 Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Oobe signin screen implementation. 6 * @fileoverview Oobe signin screen implementation.
7 */ 7 */
8 8
9 cr.define('login', function() { 9 cr.define('login', function() {
10 /** 10 /**
(...skipping 14 matching lines...) Expand all
25 var screen = $('signin'); 25 var screen = $('signin');
26 SigninScreen.decorate(screen); 26 SigninScreen.decorate(screen);
27 Oobe.getInstance().registerScreen(screen); 27 Oobe.getInstance().registerScreen(screen);
28 }; 28 };
29 29
30 SigninScreen.prototype = { 30 SigninScreen.prototype = {
31 __proto__: HTMLDivElement.prototype, 31 __proto__: HTMLDivElement.prototype,
32 32
33 /** @inheritDoc */ 33 /** @inheritDoc */
34 decorate: function() { 34 decorate: function() {
35 $('email').addEventListener('keydown', this.handleKeyDown_.bind(this));
36 $('password').addEventListener('keydown', this.handleKeyDown_.bind(this));
35 }, 37 },
36 38
37 /** 39 /**
38 * Header text of the screen. 40 * Header text of the screen.
39 * @type {string} 41 * @type {string}
40 */ 42 */
41 get header() { 43 get header() {
42 return localStrings.getString('signinScreenTitle'); 44 return localStrings.getString('signinScreenTitle');
43 }, 45 },
44 46
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 * Clears input fields and switches to input mode. 88 * Clears input fields and switches to input mode.
87 */ 89 */
88 reset: function() { 90 reset: function() {
89 $('email').value = ''; 91 $('email').value = '';
90 $('password').value = ''; 92 $('password').value = '';
91 $('email').focus(); 93 $('email').focus();
92 this.state = SigninScreen.STATE_INPUT; 94 this.state = SigninScreen.STATE_INPUT;
93 }, 95 },
94 96
95 /** 97 /**
98 * Validates input fields.
99 */
100 checkInput: function() {
101 // Validate input.
102 if (! $('email').value) {
Nikita (slow) 2011/07/15 18:52:07 nit: nuke space between ! and $
xiyuan 2011/07/15 20:38:29 Done.
103 $('email').focus();
104 return false;
105 }
106
107 if (!$('password').value) {
108 $('password').focus();
109 return false;
110 }
111
112 return true;
113 },
114
115 /**
96 * Handles sign in button click. 116 * Handles sign in button click.
97 * @private 117 * @private
98 */ 118 */
99 handleSigninClick_: function(e) { 119 handleSigninClick_: function(e) {
120 if (!this.checkInput())
121 return;
122
100 this.state = SigninScreen.STATE_AUTHENTICATING; 123 this.state = SigninScreen.STATE_AUTHENTICATING;
101 124
102 chrome.send('authenticateUser', 125 chrome.send('authenticateUser',
103 [$('email').value, $('password').value]); 126 [$('email').value, $('password').value]);
127 },
128
129 /**
130 * Handles keyboard event.
131 * @private
132 */
133 handleKeyDown_: function(e) {
134 // Handle 'Enter' key for 'email' and 'password' field.
135 if (e.keyIdentifier == 'Enter') {
136 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.
137 $('password').focus();
138
139 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
140 this.handleSigninClick_();
141 }
104 } 142 }
105 }; 143 };
106 144
107 /** 145 /**
108 * Expose 'reset' method that resets sign-in screen. 146 * Expose 'reset' method that resets sign-in screen.
109 * @public 147 * @public
110 */ 148 */
111 SigninScreen.reset = function() { 149 SigninScreen.reset = function() {
112 $('signin').reset(); 150 $('signin').reset();
113 }; 151 };
114 152
115 return { 153 return {
116 SigninScreen: SigninScreen 154 SigninScreen: SigninScreen
117 }; 155 };
118 }); 156 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698