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

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

Issue 8396032: Make user remove button focusable, and set up the correct tab order. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code Review Created 9 years, 1 month 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 User pod row implementation. 6 * @fileoverview User pod row implementation.
7 */ 7 */
8 8
9 cr.define('login', function() { 9 cr.define('login', function() {
10 // Pod width. 170px Pod + 10px padding + 10px margin on both sides. 10 // Pod width. 170px Pod + 10px padding + 10px margin on both sides.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 if (!this.hasAttribute('tabindex')) 42 if (!this.hasAttribute('tabindex'))
43 this.tabIndex = 0; 43 this.tabIndex = 0;
44 44
45 this.addEventListener('mousedown', 45 this.addEventListener('mousedown',
46 this.handleMouseDown_.bind(this)); 46 this.handleMouseDown_.bind(this));
47 47
48 this.enterButtonElement.addEventListener('click', 48 this.enterButtonElement.addEventListener('click',
49 this.activate.bind(this)); 49 this.activate.bind(this));
50 this.signinButtonElement.addEventListener('click', 50 this.signinButtonElement.addEventListener('click',
51 this.activate.bind(this)); 51 this.activate.bind(this));
52 this.removeUserButtonElement.addEventListener('click',
53 this.handleRemoveButtonClick_.bind(this));
52 this.removeUserButtonElement.addEventListener('mouseout', 54 this.removeUserButtonElement.addEventListener('mouseout',
53 this.handleRemoveButtonMouseOut_.bind(this)); 55 this.handleRemoveButtonMouseOut_.bind(this));
54 }, 56 },
55 57
56 /** 58 /**
57 * Initializes the pod after its properties set and added to a pod row. 59 * Initializes the pod after its properties set and added to a pod row.
58 */ 60 */
59 initialize: function() { 61 initialize: function() {
60 if (!this.isGuest) { 62 if (!this.isGuest) {
61 this.passwordEmpty = true; 63 this.passwordEmpty = true;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 if (this.isGuest) { 170 if (this.isGuest) {
169 this.imageElement.title = userDict.name; 171 this.imageElement.title = userDict.name;
170 this.enterButtonElement.hidden = false; 172 this.enterButtonElement.hidden = false;
171 this.passwordElement.hidden = true; 173 this.passwordElement.hidden = true;
172 this.signinButtonElement.hidden = true; 174 this.signinButtonElement.hidden = true;
173 } else { 175 } else {
174 var needSignin = this.needGaiaSignin; 176 var needSignin = this.needGaiaSignin;
175 this.imageElement.title = userDict.emailAddress; 177 this.imageElement.title = userDict.emailAddress;
176 this.enterButtonElement.hidden = true; 178 this.enterButtonElement.hidden = true;
177 this.passwordElement.hidden = needSignin; 179 this.passwordElement.hidden = needSignin;
180 this.removeUserButtonElement.setAttribute(
181 'aria-label', localStrings.getStringF('removeButtonAccessibleName',
182 userDict.emailAddress));
178 this.passwordElement.setAttribute('aria-label', 183 this.passwordElement.setAttribute('aria-label',
179 localStrings.getStringF( 184 localStrings.getStringF(
180 'passwordFieldAccessibleName', 185 'passwordFieldAccessibleName',
181 userDict.emailAddress)); 186 userDict.emailAddress));
182 this.signinButtonElement.hidden = !needSignin; 187 this.signinButtonElement.hidden = !needSignin;
183 } 188 }
184 }, 189 },
185 190
186 /** 191 /**
187 * Whether we are a guest pod or not. 192 * Whether we are a guest pod or not.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 this.activeRemoveButton = true; 317 this.activeRemoveButton = true;
313 }, 318 },
314 319
315 /** 320 /**
316 * Handles mousedown event. 321 * Handles mousedown event.
317 */ 322 */
318 handleMouseDown_: function(e) { 323 handleMouseDown_: function(e) {
319 if (!this.parentNode.rowEnabled) 324 if (!this.parentNode.rowEnabled)
320 return; 325 return;
321 var handled = false; 326 var handled = false;
322 if (e.target == this.removeUserButtonElement) { 327 if (!this.signinButtonElement.hidden) {
323 this.handleRemoveButtonClick_(e);
324 handled = true;
325 } else if (!this.signinButtonElement.hidden) {
326 this.parentNode.showSigninUI(this.user.emailAddress); 328 this.parentNode.showSigninUI(this.user.emailAddress);
327 handled = true; 329 handled = true;
328 } 330 }
329 if (handled) { 331 if (handled) {
330 // Prevent default so that we don't trigger 'focus' event. 332 // Prevent default so that we don't trigger 'focus' event.
331 e.preventDefault(); 333 e.preventDefault();
332 } 334 }
333 } 335 }
334 }; 336 };
335 337
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 */ 398 */
397 addUserPod: function(user, animated) { 399 addUserPod: function(user, animated) {
398 var userPod = this.createUserPod(user); 400 var userPod = this.createUserPod(user);
399 if (animated) { 401 if (animated) {
400 userPod.classList.add('init'); 402 userPod.classList.add('init');
401 userPod.nameElement.classList.add('init'); 403 userPod.nameElement.classList.add('init');
402 } 404 }
403 405
404 this.appendChild(userPod); 406 this.appendChild(userPod);
405 userPod.initialize(); 407 userPod.initialize();
408 var index = this.findIndex_(userPod);
409 userPod.removeUserButtonElement.tabIndex = 100 + index;
406 }, 410 },
407 411
408 /** 412 /**
409 * Ensures the given pod is visible. 413 * Ensures the given pod is visible.
410 * @param {UserPod} pod Pod to scroll into view. 414 * @param {UserPod} pod Pod to scroll into view.
411 */ 415 */
412 scrollPodIntoView: function(pod) { 416 scrollPodIntoView: function(pod) {
413 var podIndex = this.findIndex_(pod); 417 var podIndex = this.findIndex_(pod);
414 if (podIndex == -1) 418 if (podIndex == -1)
415 return; 419 return;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 */ 467 */
464 loadPods: function(users, animated) { 468 loadPods: function(users, animated) {
465 // Clear existing pods. 469 // Clear existing pods.
466 this.innerHTML = ''; 470 this.innerHTML = '';
467 this.focusedPod_ = undefined; 471 this.focusedPod_ = undefined;
468 this.activatedPod_ = undefined; 472 this.activatedPod_ = undefined;
469 473
470 // Popoulate the pod row. 474 // Popoulate the pod row.
471 for (var i = 0; i < users.length; ++i) { 475 for (var i = 0; i < users.length; ++i) {
472 this.addUserPod(users[i], animated); 476 this.addUserPod(users[i], animated);
477 this.pods[i].tabIndex = i + 1;
dmazzoni 2011/10/26 16:14:49 I'm pretty sure everything in the page with the sa
473 } 478 }
474 }, 479 },
475 480
476 /** 481 /**
477 * Focuses a given user pod or clear focus when given null. 482 * Focuses a given user pod or clear focus when given null.
478 * @param {UserPod} pod User pod to focus or null to clear focus. 483 * @param {UserPod} pod User pod to focus or null to clear focus.
479 */ 484 */
480 focusPod: function(pod) { 485 focusPod: function(pod) {
481 if (this.focusedPod_ == pod) 486 if (this.focusedPod_ == pod)
482 return; 487 return;
483 488
484 if (pod) { 489 if (pod) {
490 var focusedTabIndex = 0;
485 for (var i = 0; i < this.pods.length; ++i) { 491 for (var i = 0; i < this.pods.length; ++i) {
486 this.pods[i].activeRemoveButton = false; 492 this.pods[i].activeRemoveButton = false;
487 if (this.pods[i] == pod) { 493 if (this.pods[i] == pod) {
488 pod.classList.remove("faded"); 494 pod.classList.remove("faded");
489 pod.classList.add("focused"); 495 pod.classList.add("focused");
490 pod.tabIndex = -1; // Make it not keyboard focusable. 496 pod.tabIndex = -1; // Make it not keyboard focusable.
497 focusedTabIndex = i + 1;
491 } else { 498 } else {
492 this.pods[i].classList.remove('focused'); 499 this.pods[i].classList.remove('focused');
493 this.pods[i].classList.add('faded'); 500 this.pods[i].classList.add('faded');
494 this.pods[i].tabIndex = 0; 501 this.pods[i].tabIndex = i + 1;
495 } 502 }
496 } 503 }
504 pod.mainInput.tabIndex = focusedTabIndex;
497 pod.focusInput(); 505 pod.focusInput();
498 506
499 this.focusedPod_ = pod; 507 this.focusedPod_ = pod;
500 this.scrollPodIntoView(pod); 508 this.scrollPodIntoView(pod);
501 } else { 509 } else {
502 for (var i = 0; i < this.pods.length; ++i) { 510 for (var i = 0; i < this.pods.length; ++i) {
503 this.pods[i].classList.remove('focused'); 511 this.pods[i].classList.remove('focused');
504 this.pods[i].classList.remove('faded'); 512 this.pods[i].classList.remove('faded');
505 this.pods[i].activeRemoveButton = false; 513 this.pods[i].activeRemoveButton = false;
506 this.pods[i].tabIndex = 0; 514 this.pods[i].tabIndex = i + 1;
507 } 515 }
508 this.focusedPod_ = undefined; 516 this.focusedPod_ = undefined;
509 } 517 }
510 }, 518 },
511 519
512 /** 520 /**
513 * Returns the currently activated pod. 521 * Returns the currently activated pod.
514 */ 522 */
515 get activated() { 523 get activated() {
516 return this.activatedPod_; 524 return this.activatedPod_;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 this.ownerDocument.removeEventListener( 678 this.ownerDocument.removeEventListener(
671 event, this.listeners_[event][0], this.listeners_[event][1]); 679 event, this.listeners_[event][0], this.listeners_[event][1]);
672 } 680 }
673 } 681 }
674 }; 682 };
675 683
676 return { 684 return {
677 PodRow: PodRow 685 PodRow: PodRow
678 }; 686 };
679 }); 687 });
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/resources/chromeos/login/user_pod_template.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698