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