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_prevent_focus_input If true, do not focus on input |
| 2731 * box. |
2730 */ | 2732 */ |
2731 focusPod: function(podToFocus, opt_force) { | 2733 focusPod: function(podToFocus, opt_force, opt_prevent_focus_input) { |
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; | 2738 this.keyboardActivated_ = false; |
2737 return; | 2739 return; |
2738 } | 2740 } |
2739 | 2741 |
2740 // Make sure there's only one focusPod operation happening at a time. | 2742 // Make sure there's only one focusPod operation happening at a time. |
2741 if (this.insideFocusPod_) { | 2743 if (this.insideFocusPod_) { |
(...skipping 23 matching lines...) Expand all Loading... |
2765 if (!this.isFocused(podToFocus)) | 2767 if (!this.isFocused(podToFocus)) |
2766 Oobe.clearErrors(); | 2768 Oobe.clearErrors(); |
2767 | 2769 |
2768 var hadFocus = !!this.focusedPod_; | 2770 var hadFocus = !!this.focusedPod_; |
2769 this.focusedPod_ = podToFocus; | 2771 this.focusedPod_ = podToFocus; |
2770 if (podToFocus) { | 2772 if (podToFocus) { |
2771 podToFocus.classList.remove('faded'); | 2773 podToFocus.classList.remove('faded'); |
2772 podToFocus.classList.add('focused'); | 2774 podToFocus.classList.add('focused'); |
2773 if (!podToFocus.multiProfilesPolicyApplied) { | 2775 if (!podToFocus.multiProfilesPolicyApplied) { |
2774 podToFocus.classList.toggle('signing-in', false); | 2776 podToFocus.classList.toggle('signing-in', false); |
2775 podToFocus.focusInput(); | 2777 if (!opt_prevent_focus_input) { |
| 2778 podToFocus.focusInput(); |
| 2779 } |
2776 } else { | 2780 } else { |
2777 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); | 2781 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); |
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; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2990 } else | 2994 } else |
2991 this.focusPod(e.target); | 2995 this.focusPod(e.target); |
2992 return; | 2996 return; |
2993 } | 2997 } |
2994 | 2998 |
2995 var pod = findAncestorByClass(e.target, 'pod'); | 2999 var pod = findAncestorByClass(e.target, 'pod'); |
2996 if (pod && pod.parentNode == this) { | 3000 if (pod && pod.parentNode == this) { |
2997 // Focus on a control of a pod but not on the action area button. | 3001 // Focus on a control of a pod but not on the action area button. |
2998 if (!pod.classList.contains('focused') && | 3002 if (!pod.classList.contains('focused') && |
2999 !e.target.classList.contains('action-box-button')) { | 3003 !e.target.classList.contains('action-box-button')) { |
3000 this.focusPod(pod); | 3004 if (e.target == pod.actionBoxAreaElement) { |
| 3005 this.focusPod(pod, false, true); |
| 3006 } else { |
| 3007 this.focusPod(pod); |
| 3008 } |
3001 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3009 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
3002 e.target.focus(); | 3010 e.target.focus(); |
3003 } | 3011 } |
3004 return; | 3012 return; |
3005 } | 3013 } |
3006 | 3014 |
3007 // Clears pod focus when we reach here. It means new focus is neither | 3015 // 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. | 3016 // on a pod nor on a button/input for a pod. |
3009 // Do not "defocus" user pod when it is a single pod. | 3017 // Do not "defocus" user pod when it is a single pod. |
3010 // That means that 'focused' class will not be removed and | 3018 // That means that 'focused' class will not be removed and |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3149 if (pod && pod.multiProfilesPolicyApplied) { | 3157 if (pod && pod.multiProfilesPolicyApplied) { |
3150 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3158 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
3151 } | 3159 } |
3152 } | 3160 } |
3153 }; | 3161 }; |
3154 | 3162 |
3155 return { | 3163 return { |
3156 PodRow: PodRow | 3164 PodRow: PodRow |
3157 }; | 3165 }; |
3158 }); | 3166 }); |
OLD | NEW |