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

Side by Side Diff: chrome/browser/resources/settings/people_page/users_add_user_dialog.js

Issue 2533173002: MD Settings: Listen to the Enter key in the Add User ChromeOS dialog. (Closed)
Patch Set: address comments Created 4 years 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
« no previous file with comments | « chrome/browser/resources/settings/people_page/users_add_user_dialog.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 6 * @fileoverview
7 * 'settings-users-add-user-dialog' is the dialog shown for adding new allowed 7 * 'settings-users-add-user-dialog' is the dialog shown for adding new allowed
8 * users to a ChromeOS device. 8 * users to a ChromeOS device.
9 */ 9 */
10 (function() { 10 (function() {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 var input = this.$.addUserInput.value; 50 var input = this.$.addUserInput.value;
51 var valid = NAME_ONLY_REGEX.test(input) || EMAIL_REGEX.test(input); 51 var valid = NAME_ONLY_REGEX.test(input) || EMAIL_REGEX.test(input);
52 52
53 this.$.add.disabled = !valid; 53 this.$.add.disabled = !valid;
54 this.$.addUserInput.invalid = !valid; 54 this.$.addUserInput.invalid = !valid;
55 return valid; 55 return valid;
56 }, 56 },
57 57
58 /** @private */ 58 /** @private */
59 addUser_: function() { 59 addUser_: function() {
60 assert(this.validate_()); 60 // May be submitted by the Enter key even if the input value is invalid.
61 if (!this.validate_())
62 return;
61 63
62 var input = this.$.addUserInput.value; 64 var input = this.$.addUserInput.value;
63 65
64 var nameOnlyMatches = NAME_ONLY_REGEX.exec(input); 66 var nameOnlyMatches = NAME_ONLY_REGEX.exec(input);
65 var userEmail; 67 var userEmail;
66 if (nameOnlyMatches) { 68 if (nameOnlyMatches) {
67 userEmail = nameOnlyMatches[1] + '@gmail.com'; 69 userEmail = nameOnlyMatches[1] + '@gmail.com';
68 } else { 70 } else {
69 var emailMatches = EMAIL_REGEX.exec(input); 71 var emailMatches = EMAIL_REGEX.exec(input);
70 // Assuming the input validated, one of these two must match. 72 // Assuming the input validated, one of these two must match.
71 assert(emailMatches); 73 assert(emailMatches);
72 userEmail = emailMatches[1] + '@' + emailMatches[2]; 74 userEmail = emailMatches[1] + '@' + emailMatches[2];
73 } 75 }
74 76
75 chrome.usersPrivate.addWhitelistedUser( 77 chrome.usersPrivate.addWhitelistedUser(
76 userEmail, 78 userEmail,
77 /* callback */ function(success) {}); 79 /* callback */ function(success) {});
78 this.$.addUserInput.value = ''; 80 this.$.addUserInput.value = '';
79 this.$.dialog.close(); 81 this.$.dialog.close();
80 }, 82 },
81 }); 83 });
82 84
83 })(); 85 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/people_page/users_add_user_dialog.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698