Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 2709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2720 */ | 2720 */ |
| 2721 isFocused: function(pod) { | 2721 isFocused: function(pod) { |
| 2722 return this.focusedPod_ == pod; | 2722 return this.focusedPod_ == pod; |
| 2723 }, | 2723 }, |
| 2724 | 2724 |
| 2725 /** | 2725 /** |
| 2726 * Focuses a given user pod or clear focus when given null. | 2726 * Focuses a given user pod or clear focus when given null. |
| 2727 * @param {UserPod=} podToFocus User pod to focus (undefined clears focus). | 2727 * @param {UserPod=} podToFocus User pod to focus (undefined clears focus). |
| 2728 * @param {boolean=} opt_force If true, forces focus update even when | 2728 * @param {boolean=} opt_force If true, forces focus update even when |
| 2729 * podToFocus is already focused. | 2729 * podToFocus is already focused. |
| 2730 * @param {boolean=} opt_skip_input_focus If true, dont focus on the input | |
|
dzhioev (left Google)
2015/07/17 18:48:50
nit: s/dont/don't/
bshe
2015/07/17 21:34:58
Done.
| |
| 2731 * box of user pod. | |
| 2730 */ | 2732 */ |
| 2731 focusPod: function(podToFocus, opt_force) { | 2733 focusPod: function(podToFocus, opt_force, opt_skip_input_focus) { |
|
dzhioev (left Google)
2015/07/17 18:48:50
nit: I'm not sure, but I think it should be called
bshe
2015/07/17 21:34:58
Done.
| |
| 2732 if (this.isFocused(podToFocus) && !opt_force) { | 2734 if (this.isFocused(podToFocus) && !opt_force) { |
| 2733 // Calling focusPod w/o podToFocus means reset. | 2735 // Calling focusPod w/o podToFocus means reset. |
| 2734 if (!podToFocus) | 2736 if (!podToFocus) |
| 2735 Oobe.clearErrors(); | 2737 Oobe.clearErrors(); |
| 2736 this.keyboardActivated_ = false; | |
| 2737 return; | 2738 return; |
| 2738 } | 2739 } |
| 2739 | 2740 |
| 2740 // Make sure there's only one focusPod operation happening at a time. | 2741 // Make sure there's only one focusPod operation happening at a time. |
| 2741 if (this.insideFocusPod_) { | 2742 if (this.insideFocusPod_) { |
| 2742 this.keyboardActivated_ = false; | |
| 2743 return; | 2743 return; |
| 2744 } | 2744 } |
| 2745 this.insideFocusPod_ = true; | 2745 this.insideFocusPod_ = true; |
| 2746 | 2746 |
| 2747 for (var i = 0, pod; pod = this.pods[i]; ++i) { | 2747 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
| 2748 if (!this.alwaysFocusSinglePod) { | 2748 if (!this.alwaysFocusSinglePod) { |
| 2749 pod.isActionBoxMenuActive = false; | 2749 pod.isActionBoxMenuActive = false; |
| 2750 } | 2750 } |
| 2751 if (pod != podToFocus) { | 2751 if (pod != podToFocus) { |
| 2752 pod.isActionBoxMenuHovered = false; | 2752 pod.isActionBoxMenuHovered = false; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2765 if (!this.isFocused(podToFocus)) | 2765 if (!this.isFocused(podToFocus)) |
| 2766 Oobe.clearErrors(); | 2766 Oobe.clearErrors(); |
| 2767 | 2767 |
| 2768 var hadFocus = !!this.focusedPod_; | 2768 var hadFocus = !!this.focusedPod_; |
| 2769 this.focusedPod_ = podToFocus; | 2769 this.focusedPod_ = podToFocus; |
| 2770 if (podToFocus) { | 2770 if (podToFocus) { |
| 2771 podToFocus.classList.remove('faded'); | 2771 podToFocus.classList.remove('faded'); |
| 2772 podToFocus.classList.add('focused'); | 2772 podToFocus.classList.add('focused'); |
| 2773 if (!podToFocus.multiProfilesPolicyApplied) { | 2773 if (!podToFocus.multiProfilesPolicyApplied) { |
| 2774 podToFocus.classList.toggle('signing-in', false); | 2774 podToFocus.classList.toggle('signing-in', false); |
| 2775 podToFocus.focusInput(); | 2775 if (!opt_skip_input_focus) |
| 2776 podToFocus.focusInput(); | |
| 2776 } else { | 2777 } else { |
| 2777 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); | 2778 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); |
| 2779 // Note it is not necessary to skip this focus request when | |
| 2780 // |opt_skip_input_focus| is true. When |multiProfilesPolicyApplied| | |
| 2781 // is false, it doesn't focus on the password input box by default. | |
| 2778 podToFocus.focus(); | 2782 podToFocus.focus(); |
| 2779 } | 2783 } |
| 2780 | 2784 |
| 2781 // focusPod() automatically loads wallpaper | 2785 // focusPod() automatically loads wallpaper |
| 2782 if (!podToFocus.user.isApp) | 2786 if (!podToFocus.user.isApp) |
| 2783 chrome.send('focusPod', [podToFocus.user.username]); | 2787 chrome.send('focusPod', [podToFocus.user.username]); |
| 2784 this.firstShown_ = false; | 2788 this.firstShown_ = false; |
| 2785 this.lastFocusedPod_ = podToFocus; | 2789 this.lastFocusedPod_ = podToFocus; |
| 2786 | 2790 |
| 2787 if (Oobe.getInstance().virtualKeyboardShown) | 2791 if (Oobe.getInstance().virtualKeyboardShown) |
| 2788 this.scrollFocusedPodIntoView(); | 2792 this.scrollFocusedPodIntoView(); |
| 2789 } | 2793 } |
| 2790 this.insideFocusPod_ = false; | 2794 this.insideFocusPod_ = false; |
| 2791 this.keyboardActivated_ = false; | |
| 2792 }, | 2795 }, |
| 2793 | 2796 |
| 2794 /** | 2797 /** |
| 2795 * Resets wallpaper to the last active user's wallpaper, if any. | 2798 * Resets wallpaper to the last active user's wallpaper, if any. |
| 2796 */ | 2799 */ |
| 2797 loadLastWallpaper: function() { | 2800 loadLastWallpaper: function() { |
| 2798 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp) | 2801 if (this.lastFocusedPod_ && !this.lastFocusedPod_.user.isApp) |
| 2799 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); | 2802 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); |
| 2800 }, | 2803 }, |
| 2801 | 2804 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2988 else | 2991 else |
| 2989 e.target.userTypeBubbleElement.classList.add('bubble-shown'); | 2992 e.target.userTypeBubbleElement.classList.add('bubble-shown'); |
| 2990 } else | 2993 } else |
| 2991 this.focusPod(e.target); | 2994 this.focusPod(e.target); |
| 2992 return; | 2995 return; |
| 2993 } | 2996 } |
| 2994 | 2997 |
| 2995 var pod = findAncestorByClass(e.target, 'pod'); | 2998 var pod = findAncestorByClass(e.target, 'pod'); |
| 2996 if (pod && pod.parentNode == this) { | 2999 if (pod && pod.parentNode == this) { |
| 2997 // Focus on a control of a pod but not on the action area button. | 3000 // Focus on a control of a pod but not on the action area button. |
| 2998 if (!pod.classList.contains('focused') && | 3001 if (!pod.classList.contains('focused')) { |
| 2999 !e.target.classList.contains('action-box-button')) { | 3002 if (e.target.classList.contains('action-box-area') || |
| 3000 this.focusPod(pod); | 3003 e.target.classList.contains('remove-warning-button')) { |
| 3004 // focusPod usually moves focus on the password input box which | |
| 3005 // triggers virtual keyboard to show up. But the focus may move to a | |
| 3006 // non text input element shortly by e.target.focus. Hence, a | |
| 3007 // virtual keyboard flicking might be observed. We need to manually | |
| 3008 // prevent focus on password input box to avoid virtual keyboard | |
| 3009 // flicking in this case. See crbug.com/396016 for details. | |
| 3010 this.focusPod(pod, false, true /* opt_skip_input_focus */); | |
| 3011 } else { | |
| 3012 this.focusPod(pod); | |
| 3013 } | |
| 3001 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3014 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3002 e.target.focus(); | 3015 e.target.focus(); |
| 3003 } | 3016 } |
| 3004 return; | 3017 return; |
| 3005 } | 3018 } |
| 3006 | 3019 |
| 3007 // Clears pod focus when we reach here. It means new focus is neither | 3020 // Clears pod focus when we reach here. It means new focus is neither |
| 3008 // on a pod nor on a button/input for a pod. | 3021 // on a pod nor on a button/input for a pod. |
| 3009 // Do not "defocus" user pod when it is a single pod. | 3022 // Do not "defocus" user pod when it is a single pod. |
| 3010 // That means that 'focused' class will not be removed and | 3023 // That means that 'focused' class will not be removed and |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 3022 * Handler of keydown event. | 3035 * Handler of keydown event. |
| 3023 * @param {Event} e KeyDown Event object. | 3036 * @param {Event} e KeyDown Event object. |
| 3024 */ | 3037 */ |
| 3025 handleKeyDown: function(e) { | 3038 handleKeyDown: function(e) { |
| 3026 if (this.disabled) | 3039 if (this.disabled) |
| 3027 return; | 3040 return; |
| 3028 var editing = e.target.tagName == 'INPUT' && e.target.value; | 3041 var editing = e.target.tagName == 'INPUT' && e.target.value; |
| 3029 switch (e.keyIdentifier) { | 3042 switch (e.keyIdentifier) { |
| 3030 case 'Left': | 3043 case 'Left': |
| 3031 if (!editing) { | 3044 if (!editing) { |
| 3032 this.keyboardActivated_ = true; | |
| 3033 if (this.focusedPod_ && this.focusedPod_.previousElementSibling) | 3045 if (this.focusedPod_ && this.focusedPod_.previousElementSibling) |
| 3034 this.focusPod(this.focusedPod_.previousElementSibling); | 3046 this.focusPod(this.focusedPod_.previousElementSibling); |
| 3035 else | 3047 else |
| 3036 this.focusPod(this.lastElementChild); | 3048 this.focusPod(this.lastElementChild); |
| 3037 | 3049 |
| 3038 e.stopPropagation(); | 3050 e.stopPropagation(); |
| 3039 } | 3051 } |
| 3040 break; | 3052 break; |
| 3041 case 'Right': | 3053 case 'Right': |
| 3042 if (!editing) { | 3054 if (!editing) { |
| 3043 this.keyboardActivated_ = true; | |
| 3044 if (this.focusedPod_ && this.focusedPod_.nextElementSibling) | 3055 if (this.focusedPod_ && this.focusedPod_.nextElementSibling) |
| 3045 this.focusPod(this.focusedPod_.nextElementSibling); | 3056 this.focusPod(this.focusedPod_.nextElementSibling); |
| 3046 else | 3057 else |
| 3047 this.focusPod(this.firstElementChild); | 3058 this.focusPod(this.firstElementChild); |
| 3048 | 3059 |
| 3049 e.stopPropagation(); | 3060 e.stopPropagation(); |
| 3050 } | 3061 } |
| 3051 break; | 3062 break; |
| 3052 case 'Enter': | 3063 case 'Enter': |
| 3053 if (this.focusedPod_) { | 3064 if (this.focusedPod_) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3149 if (pod && pod.multiProfilesPolicyApplied) { | 3160 if (pod && pod.multiProfilesPolicyApplied) { |
| 3150 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3161 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3151 } | 3162 } |
| 3152 } | 3163 } |
| 3153 }; | 3164 }; |
| 3154 | 3165 |
| 3155 return { | 3166 return { |
| 3156 PodRow: PodRow | 3167 PodRow: PodRow |
| 3157 }; | 3168 }; |
| 3158 }); | 3169 }); |
| OLD | NEW |