Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** |
| 11 const POD_WIDTH = 170 + 2 * (10 + 10); | 11 * Pod width. 170px Pod + 10px padding + 10px margin on both sides. |
| 12 * @type {number} | |
| 13 * @const | |
| 14 */ | |
| 15 var POD_WIDTH = 170 + 2 * (10 + 10); | |
| 16 | |
| 17 /** | |
| 18 * Wallpaper load delay in milliseconds. | |
| 19 * @type {number} | |
| 20 * @const | |
| 21 */ | |
| 22 var WALLPAPER_LOAD_DELAY_MS = 800; | |
| 12 | 23 |
| 13 /** | 24 /** |
| 14 * Oauth token status. These must match UserManager::OAuthTokenStatus. | 25 * Oauth token status. These must match UserManager::OAuthTokenStatus. |
| 15 * @enum {number} | 26 * @enum {number} |
| 27 * @const | |
| 16 */ | 28 */ |
| 17 const OAuthTokenStatus = { | 29 var OAuthTokenStatus = { |
| 18 UNKNOWN: 0, | 30 UNKNOWN: 0, |
| 19 INVALID: 1, | 31 INVALID: 1, |
| 20 VALID: 2 | 32 VALID: 2 |
| 21 }; | 33 }; |
| 22 | 34 |
| 23 /** | 35 /** |
| 24 * Tab order for user pods. Update these when adding new controls. | 36 * Tab order for user pods. Update these when adding new controls. |
| 25 * @enum {number} | 37 * @enum {number} |
| 38 * @const | |
| 26 */ | 39 */ |
| 27 const UserPodTabOrder = { | 40 var UserPodTabOrder = { |
| 28 POD_INPUT: 1, // Password input fields (and whole pods themselves). | 41 POD_INPUT: 1, // Password input fields (and whole pods themselves). |
| 29 HEADER_BAR: 2, // Buttons on the header bar (Shutdown, Add User). | 42 HEADER_BAR: 2, // Buttons on the header bar (Shutdown, Add User). |
| 30 REMOVE_USER: 3 // Remove ('X') buttons. | 43 REMOVE_USER: 3 // Remove ('X') buttons. |
| 31 }; | 44 }; |
| 32 | 45 |
| 33 // Focus and tab order are organized as follows: | 46 // Focus and tab order are organized as follows: |
| 34 // | 47 // |
| 35 // (1) all user pods have tab index 1 so they are traversed first; | 48 // (1) all user pods have tab index 1 so they are traversed first; |
| 36 // (2) when a user pod is activated, its tab index is set to -1 and its | 49 // (2) when a user pod is activated, its tab index is set to -1 and its |
| 37 // main input field gets focus and tab index 1; | 50 // main input field gets focus and tab index 1; |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 | 463 |
| 451 PodRow.prototype = { | 464 PodRow.prototype = { |
| 452 __proto__: HTMLDivElement.prototype, | 465 __proto__: HTMLDivElement.prototype, |
| 453 | 466 |
| 454 // Focused pod. | 467 // Focused pod. |
| 455 focusedPod_ : undefined, | 468 focusedPod_ : undefined, |
| 456 | 469 |
| 457 // Activated pod, i.e. the pod of current login attempt. | 470 // Activated pod, i.e. the pod of current login attempt. |
| 458 activatedPod_: undefined, | 471 activatedPod_: undefined, |
| 459 | 472 |
| 473 // When moving through users quickly at login screen, we need to set a | |
|
James Hawkins
2012/04/27 19:29:03
nit: Don't use pronouns, e.g. 'we', in comments; p
bshe
2012/04/30 15:11:00
Done.
| |
| 474 // timeout to prevent loading intermediate wallpapers. | |
| 475 loadWallpaperTimeout_: null, | |
| 476 | |
| 460 // Pods whose initial images haven't been loaded yet. | 477 // Pods whose initial images haven't been loaded yet. |
| 461 podsWithPendingImages_: [], | 478 podsWithPendingImages_: [], |
| 462 | 479 |
| 463 /** @inheritDoc */ | 480 /** @inheritDoc */ |
| 464 decorate: function() { | 481 decorate: function() { |
| 465 this.style.left = 0; | 482 this.style.left = 0; |
| 466 | 483 |
| 467 // Event listeners that are installed for the time period during which | 484 // Event listeners that are installed for the time period during which |
| 468 // the element is visible. | 485 // the element is visible. |
| 469 this.listeners_ = { | 486 this.listeners_ = { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 /** | 642 /** |
| 626 * Focuses a given user pod or clear focus when given null. | 643 * Focuses a given user pod or clear focus when given null. |
| 627 * @param {UserPod=} podToFocus User pod to focus (undefined clears focus). | 644 * @param {UserPod=} podToFocus User pod to focus (undefined clears focus). |
| 628 * @param {boolean=} opt_force If true, forces focus update even when | 645 * @param {boolean=} opt_force If true, forces focus update even when |
| 629 * podToFocus is already focused. | 646 * podToFocus is already focused. |
| 630 */ | 647 */ |
| 631 focusPod: function(podToFocus, opt_force) { | 648 focusPod: function(podToFocus, opt_force) { |
| 632 if (this.focusedPod_ == podToFocus && !opt_force) | 649 if (this.focusedPod_ == podToFocus && !opt_force) |
| 633 return; | 650 return; |
| 634 | 651 |
| 652 clearTimeout(this.loadWallpaperTimeout_); | |
| 635 for (var i = 0, pod; pod = this.pods[i]; ++i) { | 653 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
| 636 pod.activeRemoveButton = false; | 654 pod.activeRemoveButton = false; |
| 637 if (pod != podToFocus) { | 655 if (pod != podToFocus) { |
| 638 pod.classList.remove('focused'); | 656 pod.classList.remove('focused'); |
| 639 pod.classList.remove('faded'); | 657 pod.classList.remove('faded'); |
| 640 pod.reset(false); | 658 pod.reset(false); |
| 641 } | 659 } |
| 642 } | 660 } |
| 643 | 661 |
| 644 this.focusedPod_ = podToFocus; | 662 this.focusedPod_ = podToFocus; |
| 645 if (podToFocus) { | 663 if (podToFocus) { |
| 646 podToFocus.classList.remove('faded'); | 664 podToFocus.classList.remove('faded'); |
| 647 podToFocus.classList.add('focused'); | 665 podToFocus.classList.add('focused'); |
| 648 podToFocus.reset(true); // Reset and give focus. | 666 podToFocus.reset(true); // Reset and give focus. |
| 649 this.scrollPodIntoView(podToFocus); | 667 this.scrollPodIntoView(podToFocus); |
| 668 this.loadWallpaperTimeout_ = window.setTimeout(function() { | |
| 669 chrome.send('userSelectedDelayed', [podToFocus.user.username]); | |
| 670 }, WALLPAPER_LOAD_DELAY_MS); | |
| 650 } | 671 } |
| 651 }, | 672 }, |
| 652 | 673 |
| 653 /** | 674 /** |
| 654 * Returns the currently activated pod. | 675 * Returns the currently activated pod. |
| 655 * @type {UserPod} | 676 * @type {UserPod} |
| 656 */ | 677 */ |
| 657 get activatedPod() { | 678 get activatedPod() { |
| 658 return this.activatedPod_; | 679 return this.activatedPod_; |
| 659 }, | 680 }, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 847 if (this.podsWithPendingImages_.length == 0) { | 868 if (this.podsWithPendingImages_.length == 0) { |
| 848 chrome.send('userImagesLoaded'); | 869 chrome.send('userImagesLoaded'); |
| 849 } | 870 } |
| 850 } | 871 } |
| 851 }; | 872 }; |
| 852 | 873 |
| 853 return { | 874 return { |
| 854 PodRow: PodRow | 875 PodRow: PodRow |
| 855 }; | 876 }; |
| 856 }); | 877 }); |
| OLD | NEW |