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 /** | 10 /** |
(...skipping 18 matching lines...) Expand all Loading... | |
29 var WALLPAPER_LOAD_DELAY_MS = 500; | 29 var WALLPAPER_LOAD_DELAY_MS = 500; |
30 | 30 |
31 /** | 31 /** |
32 * Wallpaper load delay in milliseconds. TODO(nkostylev): Tune this constant. | 32 * Wallpaper load delay in milliseconds. TODO(nkostylev): Tune this constant. |
33 * @type {number} | 33 * @type {number} |
34 * @const | 34 * @const |
35 */ | 35 */ |
36 var WALLPAPER_BOOT_LOAD_DELAY_MS = 500; | 36 var WALLPAPER_BOOT_LOAD_DELAY_MS = 500; |
37 | 37 |
38 /** | 38 /** |
39 * Maximum time for which the pod row remains hidden until all user images | |
40 * have been loaded. | |
41 * @type {number} | |
42 * @const | |
43 */ | |
44 var POD_ROW_IMAGES_LOAD_TIMEOUT_MS = 3000; | |
45 | |
46 /** | |
39 * Oauth token status. These must match UserManager::OAuthTokenStatus. | 47 * Oauth token status. These must match UserManager::OAuthTokenStatus. |
40 * @enum {number} | 48 * @enum {number} |
41 * @const | 49 * @const |
42 */ | 50 */ |
43 var OAuthTokenStatus = { | 51 var OAuthTokenStatus = { |
44 UNKNOWN: 0, | 52 UNKNOWN: 0, |
45 INVALID: 1, | 53 INVALID: 1, |
46 VALID: 2 | 54 VALID: 2 |
47 }; | 55 }; |
48 | 56 |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
624 this.focusedPod_ = undefined; | 632 this.focusedPod_ = undefined; |
625 this.activatedPod_ = undefined; | 633 this.activatedPod_ = undefined; |
626 | 634 |
627 // Populate the pod row. | 635 // Populate the pod row. |
628 for (var i = 0; i < users.length; ++i) { | 636 for (var i = 0; i < users.length; ++i) { |
629 this.addUserPod(users[i], animated); | 637 this.addUserPod(users[i], animated); |
630 } | 638 } |
631 for (var i = 0, pod; pod = this.pods[i]; ++i) { | 639 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
632 this.podsWithPendingImages_.push(pod); | 640 this.podsWithPendingImages_.push(pod); |
633 } | 641 } |
642 // Make sure we eventually show the pod row, even if some image is stuck. | |
643 setTimeout(function() { | |
644 $('pod-row').classList.remove('images-loading'); | |
ygorshenin1
2012/08/14 14:39:27
$('pod-row') -> this ?
Ivan Korotkov
2012/08/14 15:00:03
It's not |this| in a timer callback and I guess sa
| |
645 }, POD_ROW_IMAGES_LOAD_TIMEOUT_MS); | |
646 | |
634 this.focusPod(this.preselectedPod); | 647 this.focusPod(this.preselectedPod); |
635 }, | 648 }, |
636 | 649 |
637 /** | 650 /** |
638 * Focuses a given user pod or clear focus when given null. | 651 * Focuses a given user pod or clear focus when given null. |
639 * @param {UserPod=} podToFocus User pod to focus (undefined clears focus). | 652 * @param {UserPod=} podToFocus User pod to focus (undefined clears focus). |
640 * @param {boolean=} opt_force If true, forces focus update even when | 653 * @param {boolean=} opt_force If true, forces focus update even when |
641 * podToFocus is already focused. | 654 * podToFocus is already focused. |
642 */ | 655 */ |
643 focusPod: function(podToFocus, opt_force) { | 656 focusPod: function(podToFocus, opt_force) { |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 | 895 |
883 /** | 896 /** |
884 * Called right before the pod row is shown. | 897 * Called right before the pod row is shown. |
885 */ | 898 */ |
886 handleBeforeShow: function() { | 899 handleBeforeShow: function() { |
887 for (var event in this.listeners_) { | 900 for (var event in this.listeners_) { |
888 this.ownerDocument.addEventListener( | 901 this.ownerDocument.addEventListener( |
889 event, this.listeners_[event][0], this.listeners_[event][1]); | 902 event, this.listeners_[event][0], this.listeners_[event][1]); |
890 } | 903 } |
891 $('login-header-bar').buttonsTabIndex = UserPodTabOrder.HEADER_BAR; | 904 $('login-header-bar').buttonsTabIndex = UserPodTabOrder.HEADER_BAR; |
892 $('pod-row').updateTitles(); | 905 this.updateTitles(); |
893 }, | 906 }, |
894 | 907 |
895 /** | 908 /** |
896 * Called when the element is hidden. | 909 * Called when the element is hidden. |
897 */ | 910 */ |
898 handleHide: function() { | 911 handleHide: function() { |
899 for (var event in this.listeners_) { | 912 for (var event in this.listeners_) { |
900 this.ownerDocument.removeEventListener( | 913 this.ownerDocument.removeEventListener( |
901 event, this.listeners_[event][0], this.listeners_[event][1]); | 914 event, this.listeners_[event][0], this.listeners_[event][1]); |
902 } | 915 } |
903 $('login-header-bar').buttonsTabIndex = 0; | 916 $('login-header-bar').buttonsTabIndex = 0; |
904 $('pod-row').hideTitles(); | 917 this.hideTitles(); |
905 }, | 918 }, |
906 | 919 |
907 /** | 920 /** |
908 * Called when a pod's user image finishes loading. | 921 * Called when a pod's user image finishes loading. |
909 */ | 922 */ |
910 handlePodImageLoad: function(pod) { | 923 handlePodImageLoad: function(pod) { |
911 var index = this.podsWithPendingImages_.indexOf(pod); | 924 var index = this.podsWithPendingImages_.indexOf(pod); |
912 if (index == -1) { | 925 if (index == -1) { |
913 return; | 926 return; |
914 } | 927 } |
915 | 928 |
916 this.podsWithPendingImages_.splice(index, 1); | 929 this.podsWithPendingImages_.splice(index, 1); |
917 if (this.podsWithPendingImages_.length == 0) { | 930 if (this.podsWithPendingImages_.length == 0) { |
931 this.classList.remove('images-loading'); | |
918 chrome.send('userImagesLoaded'); | 932 chrome.send('userImagesLoaded'); |
919 // Report back user pods being painted. | 933 // Report back user pods being painted. |
920 window.webkitRequestAnimationFrame(function() { | 934 window.webkitRequestAnimationFrame(function() { |
921 chrome.send('loginVisible'); | 935 chrome.send('loginVisible'); |
922 }); | 936 }); |
923 } | 937 } |
924 } | 938 } |
925 }; | 939 }; |
926 | 940 |
927 return { | 941 return { |
928 PodRow: PodRow | 942 PodRow: PodRow |
929 }; | 943 }; |
930 }); | 944 }); |
OLD | NEW |