Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: ui/login/account_picker/user_pod_row.js

Issue 2260653002: Pin keyboard works with virtual keyboard. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fixed patch set 3 errors. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 this.tabIndex = UserPodTabOrder.POD_INPUT; 711 this.tabIndex = UserPodTabOrder.POD_INPUT;
712 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; 712 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT;
713 713
714 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); 714 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this));
715 this.addEventListener('click', this.handleClickOnPod_.bind(this)); 715 this.addEventListener('click', this.handleClickOnPod_.bind(this));
716 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); 716 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this));
717 717
718 if (this.pinKeyboard) { 718 if (this.pinKeyboard) {
719 this.pinKeyboard.addEventListener('submit', 719 this.pinKeyboard.addEventListener('submit',
720 this.handlePinSubmitted_.bind(this)); 720 this.handlePinSubmitted_.bind(this));
721 this.pinKeyboard.addEventListener('pin-change',
722 this.handlePinChanged_.bind(this));
721 } 723 }
722 724
723 this.actionBoxAreaElement.addEventListener('mousedown', 725 this.actionBoxAreaElement.addEventListener('mousedown',
724 stopEventPropagation); 726 stopEventPropagation);
725 this.actionBoxAreaElement.addEventListener('click', 727 this.actionBoxAreaElement.addEventListener('click',
726 this.handleActionAreaButtonClick_.bind(this)); 728 this.handleActionAreaButtonClick_.bind(this));
727 this.actionBoxAreaElement.addEventListener('keydown', 729 this.actionBoxAreaElement.addEventListener('keydown',
728 this.handleActionAreaButtonKeyDown_.bind(this)); 730 this.handleActionAreaButtonKeyDown_.bind(this));
729 731
730 this.actionBoxMenuTitleElement.addEventListener('keydown', 732 this.actionBoxMenuTitleElement.addEventListener('keydown',
(...skipping 17 matching lines...) Expand all
748 }, 750 },
749 751
750 /** 752 /**
751 * Initializes the pod after its properties set and added to a pod row. 753 * Initializes the pod after its properties set and added to a pod row.
752 */ 754 */
753 initialize: function() { 755 initialize: function() {
754 this.passwordElement.addEventListener('keydown', 756 this.passwordElement.addEventListener('keydown',
755 this.parentNode.handleKeyDown.bind(this.parentNode)); 757 this.parentNode.handleKeyDown.bind(this.parentNode));
756 this.passwordElement.addEventListener('keypress', 758 this.passwordElement.addEventListener('keypress',
757 this.handlePasswordKeyPress_.bind(this)); 759 this.handlePasswordKeyPress_.bind(this));
760 this.passwordElement.addEventListener('input',
761 this.handleInputChanged_.bind(this));
758 762
759 this.imageElement.addEventListener('load', 763 this.imageElement.addEventListener('load',
760 this.parentNode.handlePodImageLoad.bind(this.parentNode, this)); 764 this.parentNode.handlePodImageLoad.bind(this.parentNode, this));
761 765
762 var initialAuthType = this.user.initialAuthType || 766 var initialAuthType = this.user.initialAuthType ||
763 AUTH_TYPE.OFFLINE_PASSWORD; 767 AUTH_TYPE.OFFLINE_PASSWORD;
764 this.setAuthType(initialAuthType, null); 768 this.setAuthType(initialAuthType, null);
765 769
766 this.userClickAuthAllowed_ = false; 770 this.userClickAuthAllowed_ = false;
767 }, 771 },
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 873
870 /** 874 /**
871 * Gets the password label, which is used to show a message where the 875 * Gets the password label, which is used to show a message where the
872 * password field is normally. 876 * password field is normally.
873 * @type {!HTMLInputElement} 877 * @type {!HTMLInputElement}
874 */ 878 */
875 get passwordLabelElement() { 879 get passwordLabelElement() {
876 return this.querySelector('.password-label'); 880 return this.querySelector('.password-label');
877 }, 881 },
878 882
883 get pinContainer() {
884 return this.querySelector('.pin-container');
885 },
886
879 /** 887 /**
880 * Gets the pin-keyboard of the pod. 888 * Gets the pin-keyboard of the pod.
881 * @type {!HTMLElement} 889 * @type {!HTMLElement}
882 */ 890 */
883 get pinKeyboard() { 891 get pinKeyboard() {
884 return this.querySelector('pin-keyboard'); 892 return this.querySelector('pin-keyboard');
885 }, 893 },
886 894
887 /** 895 /**
888 * Gets user online sign in hint element. 896 * Gets user online sign in hint element.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 toggleTransitions: function(enable) { 1104 toggleTransitions: function(enable) {
1097 this.classList.toggle('flying-pin-pod', enable); 1105 this.classList.toggle('flying-pin-pod', enable);
1098 }, 1106 },
1099 1107
1100 updatePinClass_: function(element, enable) { 1108 updatePinClass_: function(element, enable) {
1101 element.classList.toggle('pin-enabled', enable); 1109 element.classList.toggle('pin-enabled', enable);
1102 element.classList.toggle('pin-disabled', !enable); 1110 element.classList.toggle('pin-disabled', !enable);
1103 }, 1111 },
1104 1112
1105 setPinVisibility: function(visible) { 1113 setPinVisibility: function(visible) {
1114 if (this.isPinShown() == visible)
1115 return;
1116
1117 // Do not show pin if virtual keyboard is there.
1118 if (visible && Oobe.getInstance().virtualKeyboardShown)
1119 return;
1120
1106 var elements = this.getElementsByClassName('pin-tag'); 1121 var elements = this.getElementsByClassName('pin-tag');
1107 for (var i = 0; i < elements.length; ++i) 1122 for (var i = 0; i < elements.length; ++i)
1108 this.updatePinClass_(elements[i], visible); 1123 this.updatePinClass_(elements[i], visible);
1109 this.updatePinClass_(this, visible); 1124 this.updatePinClass_(this, visible);
1110 1125
1111 // Set the focus to the input element after showing/hiding pin keyboard. 1126 // Set the focus to the input element after showing/hiding pin keyboard.
1112 if (this.pinKeyboard && visible) 1127 this.mainInput.focus();
1113 this.pinKeyboard.focus();
1114 }, 1128 },
1115 1129
1116 isPinShown: function() { 1130 isPinShown: function() {
1117 return this.classList.contains('pin-enabled'); 1131 return this.classList.contains('pin-enabled');
1118 }, 1132 },
1119 1133
1120 setUserPodIconType: function(userTypeClass) { 1134 setUserPodIconType: function(userTypeClass) {
1121 this.userTypeIconAreaElement.classList.add(userTypeClass); 1135 this.userTypeIconAreaElement.classList.add(userTypeClass);
1122 this.userTypeIconAreaElement.hidden = false; 1136 this.userTypeIconAreaElement.hidden = false;
1123 }, 1137 },
(...skipping 21 matching lines...) Expand all
1145 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); 1159 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING);
1146 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; 1160 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed;
1147 }, 1161 },
1148 1162
1149 /** 1163 /**
1150 * Gets main input element. 1164 * Gets main input element.
1151 * @type {(HTMLButtonElement|HTMLInputElement)} 1165 * @type {(HTMLButtonElement|HTMLInputElement)}
1152 */ 1166 */
1153 get mainInput() { 1167 get mainInput() {
1154 if (this.isAuthTypePassword) { 1168 if (this.isAuthTypePassword) {
1155 if (this.isPinShown() && this.pinKeyboard.inputElement)
1156 return this.pinKeyboard.inputElement;
1157 return this.passwordElement; 1169 return this.passwordElement;
1158 } else if (this.isAuthTypeOnlineSignIn) { 1170 } else if (this.isAuthTypeOnlineSignIn) {
1159 return this; 1171 return this;
1160 } else if (this.isAuthTypeUserClick) { 1172 } else if (this.isAuthTypeUserClick) {
1161 return this.passwordLabelElement; 1173 return this.passwordLabelElement;
1162 } 1174 }
1163 }, 1175 },
1164 1176
1165 /** 1177 /**
1166 * Whether action box button is in active state. 1178 * Whether action box button is in active state.
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 1814
1803 /** 1815 /**
1804 * Handles click event on submit button on the pin keyboard. 1816 * Handles click event on submit button on the pin keyboard.
1805 * @param {Event} e Click event. 1817 * @param {Event} e Click event.
1806 */ 1818 */
1807 handlePinSubmitted_: function(e) { 1819 handlePinSubmitted_: function(e) {
1808 if (this.parentNode.isFocused(this)) 1820 if (this.parentNode.isFocused(this))
1809 this.parentNode.setActivatedPod(this); 1821 this.parentNode.setActivatedPod(this);
1810 }, 1822 },
1811 1823
1824 handlePinChanged_: function(e) {
1825 this.passwordElement.value = e.detail.pin;
1826 },
1827
1828 handleInputChanged_: function(e) {
1829 if (this.pinKeyboard)
1830 this.pinKeyboard.value = this.passwordElement.value;
1831 },
1832
1812 /** 1833 /**
1813 * Handles click event on a user pod. 1834 * Handles click event on a user pod.
1814 * @param {Event} e Click event. 1835 * @param {Event} e Click event.
1815 */ 1836 */
1816 handleClickOnPod_: function(e) { 1837 handleClickOnPod_: function(e) {
1817 if (this.parentNode.disabled) 1838 if (this.parentNode.disabled)
1818 return; 1839 return;
1819 1840
1820 if (!this.isActionBoxMenuActive) { 1841 if (!this.isActionBoxMenuActive) {
1821 if (this.isAuthTypeOnlineSignIn) { 1842 if (this.isAuthTypeOnlineSignIn) {
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
2602 if (app) { 2623 if (app) {
2603 var activationEvent = cr.doc.createEvent('MouseEvents'); 2624 var activationEvent = cr.doc.createEvent('MouseEvents');
2604 var ctrlKey = opt_diagnosticMode; 2625 var ctrlKey = opt_diagnosticMode;
2605 activationEvent.initMouseEvent('click', true, true, null, 2626 activationEvent.initMouseEvent('click', true, true, null,
2606 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null); 2627 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null);
2607 app.dispatchEvent(activationEvent); 2628 app.dispatchEvent(activationEvent);
2608 } 2629 }
2609 }, 2630 },
2610 2631
2611 /** 2632 /**
2612 * Toggles pod PIN keyboard visiblity. 2633 * Function that hides the pin keyboard. Meant to be called when the virtual
2634 * keyboard is enabled and being toggled.
2635 * @param {boolean} hidden
2636 */
2637 setPinHidden: function(hidden) {
2638 this.setFocusedPodPinVisibility(!hidden);
2639 },
2640
2641 /**
2642 * Remove the pin keyboard from the pod with the given |username|.
2613 * @param {!user} username 2643 * @param {!user} username
2614 * @param {boolean} visible 2644 * @param {boolean} visible
2615 */ 2645 */
2616 setPinVisibility: function(username, visible) { 2646 removePinKeyboard: function(username) {
2617 var pod = this.getPodWithUsername_(username); 2647 var pod = this.getPodWithUsername_(username);
2618 if (!pod) { 2648 if (!pod) {
2619 console.warn('Attempt to change pin visibility to ' + visible + 2649 console.warn('Attempt to remove pin keyboard of missing pod.');
2620 ' for missing pod');
2621 return; 2650 return;
2622 } 2651 }
2623 2652 // Remove the child, so that the virtual keyboard cannot bring it up
2624 pod.setPinVisibility(visible); 2653 // again after three tries.
2654 if (pod.pinContainer)
2655 pod.removeChild(pod.pinContainer);
2656 pod.setPinVisibility(false);
2625 }, 2657 },
2626 2658
2627 /** 2659 /**
2628 * Removes user pod from pod row. 2660 * Removes user pod from pod row.
2629 * @param {!user} username 2661 * @param {!user} username
2630 */ 2662 */
2631 removeUserPod: function(username) { 2663 removeUserPod: function(username) {
2632 var podToRemove = this.getPodWithUsername_(username); 2664 var podToRemove = this.getPodWithUsername_(username);
2633 if (podToRemove == null) { 2665 if (podToRemove == null) {
2634 console.warn('Attempt to remove pod that does not exist'); 2666 console.warn('Attempt to remove pod that does not exist');
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
3156 } 3188 }
3157 } 3189 }
3158 3190
3159 // Clear any error messages for previous pod. 3191 // Clear any error messages for previous pod.
3160 if (!this.isFocused(podToFocus)) 3192 if (!this.isFocused(podToFocus))
3161 Oobe.clearErrors(); 3193 Oobe.clearErrors();
3162 3194
3163 var hadFocus = !!this.focusedPod_; 3195 var hadFocus = !!this.focusedPod_;
3164 this.focusedPod_ = podToFocus; 3196 this.focusedPod_ = podToFocus;
3165 if (podToFocus) { 3197 if (podToFocus) {
3166 this.setFocusedPodPinVisibility(true); 3198 if (!hadFocus)
3199 this.setFocusedPodPinVisibility(true);
3167 podToFocus.classList.remove('faded'); 3200 podToFocus.classList.remove('faded');
3168 podToFocus.classList.add('focused'); 3201 podToFocus.classList.add('focused');
3169 if (!podToFocus.multiProfilesPolicyApplied) { 3202 if (!podToFocus.multiProfilesPolicyApplied) {
3170 podToFocus.classList.toggle('signing-in', false); 3203 podToFocus.classList.toggle('signing-in', false);
3171 if (!opt_skipInputFocus) 3204 if (!opt_skipInputFocus)
3172 podToFocus.focusInput(); 3205 podToFocus.focusInput();
3173 } else { 3206 } else {
3174 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); 3207 podToFocus.userTypeBubbleElement.classList.add('bubble-shown');
3175 // Note it is not necessary to skip this focus request when 3208 // Note it is not necessary to skip this focus request when
3176 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| 3209 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied|
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
3563 if (pod && pod.multiProfilesPolicyApplied) { 3596 if (pod && pod.multiProfilesPolicyApplied) {
3564 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3597 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3565 } 3598 }
3566 } 3599 }
3567 }; 3600 };
3568 3601
3569 return { 3602 return {
3570 PodRow: PodRow 3603 PodRow: PodRow
3571 }; 3604 };
3572 }); 3605 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698