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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 this.tabIndex = UserPodTabOrder.POD_INPUT; | 709 this.tabIndex = UserPodTabOrder.POD_INPUT; |
710 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; | 710 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; |
711 | 711 |
712 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); | 712 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); |
713 this.addEventListener('click', this.handleClickOnPod_.bind(this)); | 713 this.addEventListener('click', this.handleClickOnPod_.bind(this)); |
714 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); | 714 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); |
715 | 715 |
716 if (this.pinKeyboard) { | 716 if (this.pinKeyboard) { |
717 this.pinKeyboard.addEventListener('submit', | 717 this.pinKeyboard.addEventListener('submit', |
718 this.handlePinSubmitted_.bind(this)); | 718 this.handlePinSubmitted_.bind(this)); |
| 719 this.pinKeyboard.addEventListener('pin-change', |
| 720 this.handlePinChanged_.bind(this)); |
719 } | 721 } |
720 | 722 |
721 this.actionBoxAreaElement.addEventListener('mousedown', | 723 this.actionBoxAreaElement.addEventListener('mousedown', |
722 stopEventPropagation); | 724 stopEventPropagation); |
723 this.actionBoxAreaElement.addEventListener('click', | 725 this.actionBoxAreaElement.addEventListener('click', |
724 this.handleActionAreaButtonClick_.bind(this)); | 726 this.handleActionAreaButtonClick_.bind(this)); |
725 this.actionBoxAreaElement.addEventListener('keydown', | 727 this.actionBoxAreaElement.addEventListener('keydown', |
726 this.handleActionAreaButtonKeyDown_.bind(this)); | 728 this.handleActionAreaButtonKeyDown_.bind(this)); |
727 | 729 |
728 this.actionBoxMenuTitleElement.addEventListener('keydown', | 730 this.actionBoxMenuTitleElement.addEventListener('keydown', |
(...skipping 17 matching lines...) Expand all Loading... |
746 }, | 748 }, |
747 | 749 |
748 /** | 750 /** |
749 * Initializes the pod after its properties set and added to a pod row. | 751 * Initializes the pod after its properties set and added to a pod row. |
750 */ | 752 */ |
751 initialize: function() { | 753 initialize: function() { |
752 this.passwordElement.addEventListener('keydown', | 754 this.passwordElement.addEventListener('keydown', |
753 this.parentNode.handleKeyDown.bind(this.parentNode)); | 755 this.parentNode.handleKeyDown.bind(this.parentNode)); |
754 this.passwordElement.addEventListener('keypress', | 756 this.passwordElement.addEventListener('keypress', |
755 this.handlePasswordKeyPress_.bind(this)); | 757 this.handlePasswordKeyPress_.bind(this)); |
| 758 this.passwordElement.addEventListener('input', |
| 759 this.handleInputChanged_.bind(this)); |
756 | 760 |
757 this.imageElement.addEventListener('load', | 761 this.imageElement.addEventListener('load', |
758 this.parentNode.handlePodImageLoad.bind(this.parentNode, this)); | 762 this.parentNode.handlePodImageLoad.bind(this.parentNode, this)); |
759 | 763 |
760 var initialAuthType = this.user.initialAuthType || | 764 var initialAuthType = this.user.initialAuthType || |
761 AUTH_TYPE.OFFLINE_PASSWORD; | 765 AUTH_TYPE.OFFLINE_PASSWORD; |
762 this.setAuthType(initialAuthType, null); | 766 this.setAuthType(initialAuthType, null); |
763 | 767 |
764 this.userClickAuthAllowed_ = false; | 768 this.userClickAuthAllowed_ = false; |
765 }, | 769 }, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 | 871 |
868 /** | 872 /** |
869 * Gets the password label, which is used to show a message where the | 873 * Gets the password label, which is used to show a message where the |
870 * password field is normally. | 874 * password field is normally. |
871 * @type {!HTMLInputElement} | 875 * @type {!HTMLInputElement} |
872 */ | 876 */ |
873 get passwordLabelElement() { | 877 get passwordLabelElement() { |
874 return this.querySelector('.password-label'); | 878 return this.querySelector('.password-label'); |
875 }, | 879 }, |
876 | 880 |
| 881 get pinContainer() { |
| 882 return this.querySelector('.pin-container'); |
| 883 }, |
| 884 |
877 /** | 885 /** |
878 * Gets the pin-keyboard of the pod. | 886 * Gets the pin-keyboard of the pod. |
879 * @type {!HTMLElement} | 887 * @type {!HTMLElement} |
880 */ | 888 */ |
881 get pinKeyboard() { | 889 get pinKeyboard() { |
882 return this.querySelector('pin-keyboard'); | 890 return this.querySelector('pin-keyboard'); |
883 }, | 891 }, |
884 | 892 |
885 /** | 893 /** |
886 * Gets user online sign in hint element. | 894 * Gets user online sign in hint element. |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 toggleTransitions: function(enable) { | 1106 toggleTransitions: function(enable) { |
1099 this.classList.toggle('flying-pin-pod', enable); | 1107 this.classList.toggle('flying-pin-pod', enable); |
1100 }, | 1108 }, |
1101 | 1109 |
1102 updatePinClass_: function(element, enable) { | 1110 updatePinClass_: function(element, enable) { |
1103 element.classList.toggle('pin-enabled', enable); | 1111 element.classList.toggle('pin-enabled', enable); |
1104 element.classList.toggle('pin-disabled', !enable); | 1112 element.classList.toggle('pin-disabled', !enable); |
1105 }, | 1113 }, |
1106 | 1114 |
1107 setPinVisibility: function(visible) { | 1115 setPinVisibility: function(visible) { |
| 1116 if (this.isPinShown() == visible) |
| 1117 return; |
| 1118 |
| 1119 // Do not show pin if virtual keyboard is there. |
| 1120 if (visible && Oobe.getInstance().virtualKeyboardShown) |
| 1121 return; |
| 1122 |
1108 var elements = this.getElementsByClassName('pin-tag'); | 1123 var elements = this.getElementsByClassName('pin-tag'); |
1109 for (var i = 0; i < elements.length; ++i) | 1124 for (var i = 0; i < elements.length; ++i) |
1110 this.updatePinClass_(elements[i], visible); | 1125 this.updatePinClass_(elements[i], visible); |
1111 this.updatePinClass_(this, visible); | 1126 this.updatePinClass_(this, visible); |
1112 | 1127 |
1113 // Set the focus to the input element after showing/hiding pin keyboard. | 1128 // Set the focus to the input element after showing/hiding pin keyboard. |
1114 if (this.pinKeyboard && visible) | 1129 this.mainInput.focus(); |
1115 this.pinKeyboard.focus(); | |
1116 }, | 1130 }, |
1117 | 1131 |
1118 isPinShown: function() { | 1132 isPinShown: function() { |
1119 return this.classList.contains('pin-enabled'); | 1133 return this.classList.contains('pin-enabled'); |
1120 }, | 1134 }, |
1121 | 1135 |
1122 setUserPodIconType: function(userTypeClass) { | 1136 setUserPodIconType: function(userTypeClass) { |
1123 this.userTypeIconAreaElement.classList.add(userTypeClass); | 1137 this.userTypeIconAreaElement.classList.add(userTypeClass); |
1124 this.userTypeIconAreaElement.hidden = false; | 1138 this.userTypeIconAreaElement.hidden = false; |
1125 }, | 1139 }, |
(...skipping 21 matching lines...) Expand all Loading... |
1147 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); | 1161 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); |
1148 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; | 1162 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; |
1149 }, | 1163 }, |
1150 | 1164 |
1151 /** | 1165 /** |
1152 * Gets main input element. | 1166 * Gets main input element. |
1153 * @type {(HTMLButtonElement|HTMLInputElement)} | 1167 * @type {(HTMLButtonElement|HTMLInputElement)} |
1154 */ | 1168 */ |
1155 get mainInput() { | 1169 get mainInput() { |
1156 if (this.isAuthTypePassword) { | 1170 if (this.isAuthTypePassword) { |
1157 if (this.isPinShown() && this.pinKeyboard.inputElement) | |
1158 return this.pinKeyboard.inputElement; | |
1159 return this.passwordElement; | 1171 return this.passwordElement; |
1160 } else if (this.isAuthTypeOnlineSignIn) { | 1172 } else if (this.isAuthTypeOnlineSignIn) { |
1161 return this; | 1173 return this; |
1162 } else if (this.isAuthTypeUserClick) { | 1174 } else if (this.isAuthTypeUserClick) { |
1163 return this.passwordLabelElement; | 1175 return this.passwordLabelElement; |
1164 } | 1176 } |
1165 }, | 1177 }, |
1166 | 1178 |
1167 /** | 1179 /** |
1168 * Whether action box button is in active state. | 1180 * Whether action box button is in active state. |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 | 1816 |
1805 /** | 1817 /** |
1806 * Handles click event on submit button on the pin keyboard. | 1818 * Handles click event on submit button on the pin keyboard. |
1807 * @param {Event} e Click event. | 1819 * @param {Event} e Click event. |
1808 */ | 1820 */ |
1809 handlePinSubmitted_: function(e) { | 1821 handlePinSubmitted_: function(e) { |
1810 if (this.parentNode.isFocused(this)) | 1822 if (this.parentNode.isFocused(this)) |
1811 this.parentNode.setActivatedPod(this); | 1823 this.parentNode.setActivatedPod(this); |
1812 }, | 1824 }, |
1813 | 1825 |
| 1826 handlePinChanged_: function(e) { |
| 1827 this.passwordElement.value = e.detail.pin; |
| 1828 }, |
| 1829 |
| 1830 handleInputChanged_: function(e) { |
| 1831 if (this.pinKeyboard) |
| 1832 this.pinKeyboard.value = this.passwordElement.value; |
| 1833 }, |
| 1834 |
1814 /** | 1835 /** |
1815 * Handles click event on a user pod. | 1836 * Handles click event on a user pod. |
1816 * @param {Event} e Click event. | 1837 * @param {Event} e Click event. |
1817 */ | 1838 */ |
1818 handleClickOnPod_: function(e) { | 1839 handleClickOnPod_: function(e) { |
1819 if (this.parentNode.disabled) | 1840 if (this.parentNode.disabled) |
1820 return; | 1841 return; |
1821 | 1842 |
1822 if (!this.isActionBoxMenuActive) { | 1843 if (!this.isActionBoxMenuActive) { |
1823 if (this.isAuthTypeOnlineSignIn) { | 1844 if (this.isAuthTypeOnlineSignIn) { |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2604 if (app) { | 2625 if (app) { |
2605 var activationEvent = cr.doc.createEvent('MouseEvents'); | 2626 var activationEvent = cr.doc.createEvent('MouseEvents'); |
2606 var ctrlKey = opt_diagnosticMode; | 2627 var ctrlKey = opt_diagnosticMode; |
2607 activationEvent.initMouseEvent('click', true, true, null, | 2628 activationEvent.initMouseEvent('click', true, true, null, |
2608 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null); | 2629 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null); |
2609 app.dispatchEvent(activationEvent); | 2630 app.dispatchEvent(activationEvent); |
2610 } | 2631 } |
2611 }, | 2632 }, |
2612 | 2633 |
2613 /** | 2634 /** |
2614 * Toggles pod PIN keyboard visiblity. | 2635 * Function that hides the pin keyboard. Meant to be called when the virtual |
| 2636 * keyboard is enabled and being toggled. |
| 2637 * @param {boolean} hidden |
| 2638 */ |
| 2639 setPinHidden: function(hidden) { |
| 2640 this.setFocusedPodPinVisibility(!hidden); |
| 2641 }, |
| 2642 |
| 2643 /** |
| 2644 * Remove the pin keyboard from the pod with the given |username|. |
2615 * @param {!user} username | 2645 * @param {!user} username |
2616 * @param {boolean} visible | 2646 * @param {boolean} visible |
2617 */ | 2647 */ |
2618 setPinVisibility: function(username, visible) { | 2648 removePinKeyboard: function(username) { |
2619 var pod = this.getPodWithUsername_(username); | 2649 var pod = this.getPodWithUsername_(username); |
2620 if (!pod) { | 2650 if (!pod) { |
2621 console.warn('Attempt to change pin visibility to ' + visible + | 2651 console.warn('Attempt to remove pin keyboard of missing pod.'); |
2622 ' for missing pod'); | |
2623 return; | 2652 return; |
2624 } | 2653 } |
2625 | 2654 // Remove the child, so that the virtual keyboard cannot bring it up |
2626 pod.setPinVisibility(visible); | 2655 // again after three tries. |
| 2656 if (pod.pinContainer) |
| 2657 pod.removeChild(pod.pinContainer); |
| 2658 pod.setPinVisibility(false); |
2627 }, | 2659 }, |
2628 | 2660 |
2629 /** | 2661 /** |
2630 * Removes user pod from pod row. | 2662 * Removes user pod from pod row. |
2631 * @param {!user} username | 2663 * @param {!user} username |
2632 */ | 2664 */ |
2633 removeUserPod: function(username) { | 2665 removeUserPod: function(username) { |
2634 var podToRemove = this.getPodWithUsername_(username); | 2666 var podToRemove = this.getPodWithUsername_(username); |
2635 if (podToRemove == null) { | 2667 if (podToRemove == null) { |
2636 console.warn('Attempt to remove pod that does not exist'); | 2668 console.warn('Attempt to remove pod that does not exist'); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2934 }, | 2966 }, |
2935 | 2967 |
2936 /** | 2968 /** |
2937 * Called when window was resized. | 2969 * Called when window was resized. |
2938 */ | 2970 */ |
2939 onWindowResize: function() { | 2971 onWindowResize: function() { |
2940 var layout = this.calculateLayout_(); | 2972 var layout = this.calculateLayout_(); |
2941 if (layout.columns != this.columns || layout.rows != this.rows) | 2973 if (layout.columns != this.columns || layout.rows != this.rows) |
2942 this.placePods_(); | 2974 this.placePods_(); |
2943 | 2975 |
2944 this.scrollFocusedPodIntoView(); | 2976 // Wrap this in a set timeout so the function is called after the pod is |
| 2977 // finished transitioning so that we work with the final pod dimensions. |
| 2978 setTimeout(function(podrow) { |
| 2979 podrow.scrollFocusedPodIntoView(); |
| 2980 }, 200, this); |
2945 }, | 2981 }, |
2946 | 2982 |
2947 /** | 2983 /** |
2948 * Returns width of podrow having |columns| number of columns. | 2984 * Returns width of podrow having |columns| number of columns. |
2949 * @private | 2985 * @private |
2950 */ | 2986 */ |
2951 columnsToWidth_: function(columns) { | 2987 columnsToWidth_: function(columns) { |
2952 var isDesktopUserManager = Oobe.getInstance().displayType == | 2988 var isDesktopUserManager = Oobe.getInstance().displayType == |
2953 DISPLAY_TYPE.DESKTOP_USER_MANAGER; | 2989 DISPLAY_TYPE.DESKTOP_USER_MANAGER; |
2954 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] : | 2990 var margin = isDesktopUserManager ? DESKTOP_MARGIN_BY_COLUMNS[columns] : |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3537 if (pod && pod.multiProfilesPolicyApplied) { | 3573 if (pod && pod.multiProfilesPolicyApplied) { |
3538 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3574 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
3539 } | 3575 } |
3540 } | 3576 } |
3541 }; | 3577 }; |
3542 | 3578 |
3543 return { | 3579 return { |
3544 PodRow: PodRow | 3580 PodRow: PodRow |
3545 }; | 3581 }; |
3546 }); | 3582 }); |
OLD | NEW |