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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 clearTimeout(this.loadWallpaperTimeout_); | 652 clearTimeout(this.loadWallpaperTimeout_); |
653 for (var i = 0, pod; pod = this.pods[i]; ++i) { | 653 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
654 pod.activeRemoveButton = false; | 654 pod.activeRemoveButton = false; |
655 if (pod != podToFocus) { | 655 if (pod != podToFocus) { |
656 pod.classList.remove('focused'); | 656 pod.classList.remove('focused'); |
657 pod.classList.remove('faded'); | 657 pod.classList.remove('faded'); |
658 pod.reset(false); | 658 pod.reset(false); |
659 } | 659 } |
660 } | 660 } |
661 | 661 |
| 662 var hadFocus = !!this.focusedPod_; |
662 this.focusedPod_ = podToFocus; | 663 this.focusedPod_ = podToFocus; |
663 if (podToFocus) { | 664 if (podToFocus) { |
664 podToFocus.classList.remove('faded'); | 665 podToFocus.classList.remove('faded'); |
665 podToFocus.classList.add('focused'); | 666 podToFocus.classList.add('focused'); |
666 podToFocus.reset(true); // Reset and give focus. | 667 podToFocus.reset(true); // Reset and give focus. |
667 this.scrollPodIntoView(podToFocus); | 668 this.scrollPodIntoView(podToFocus); |
668 this.loadWallpaperTimeout_ = window.setTimeout(function() { | 669 // Load wallpaper immediately if there no pod was focused previously, |
669 chrome.send('userSelectedDelayed', [podToFocus.user.username]); | 670 // otherwise delay loading to let user tab through pods without lag. |
670 }, WALLPAPER_LOAD_DELAY_MS); | 671 if (hadFocus) { |
| 672 this.loadWallpaperTimeout_ = window.setTimeout( |
| 673 this.loadWallpaper_.bind(this), WALLPAPER_LOAD_DELAY_MS); |
| 674 } else { |
| 675 this.loadWallpaper_(); |
| 676 } |
| 677 } else { |
| 678 // TODO(ivankr): reset wallpaper. |
671 } | 679 } |
672 }, | 680 }, |
673 | 681 |
| 682 loadWallpaper_: function() { |
| 683 if (this.focusedPod_) |
| 684 chrome.send('userSelectedDelayed', [this.focusedPod_.user.username]); |
| 685 }, |
| 686 |
674 /** | 687 /** |
675 * Returns the currently activated pod. | 688 * Returns the currently activated pod. |
676 * @type {UserPod} | 689 * @type {UserPod} |
677 */ | 690 */ |
678 get activatedPod() { | 691 get activatedPod() { |
679 return this.activatedPod_; | 692 return this.activatedPod_; |
680 }, | 693 }, |
681 set activatedPod(pod) { | 694 set activatedPod(pod) { |
682 if (pod && pod.activate()) | 695 if (pod && pod.activate()) |
683 this.activatedPod_ = pod; | 696 this.activatedPod_ = pod; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 chrome.send('loginVisible'); | 884 chrome.send('loginVisible'); |
872 }); | 885 }); |
873 } | 886 } |
874 } | 887 } |
875 }; | 888 }; |
876 | 889 |
877 return { | 890 return { |
878 PodRow: PodRow | 891 PodRow: PodRow |
879 }; | 892 }; |
880 }); | 893 }); |
OLD | NEW |