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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
746 }, | 746 }, |
747 | 747 |
748 /** | 748 /** |
749 * Initializes the pod after its properties set and added to a pod row. | 749 * Initializes the pod after its properties set and added to a pod row. |
750 */ | 750 */ |
751 initialize: function() { | 751 initialize: function() { |
752 this.passwordElement.addEventListener('keydown', | 752 this.passwordElement.addEventListener('keydown', |
753 this.parentNode.handleKeyDown.bind(this.parentNode)); | 753 this.parentNode.handleKeyDown.bind(this.parentNode)); |
754 this.passwordElement.addEventListener('keypress', | 754 this.passwordElement.addEventListener('keypress', |
755 this.handlePasswordKeyPress_.bind(this)); | 755 this.handlePasswordKeyPress_.bind(this)); |
756 this.passwordElement.addEventListener('input', | |
757 this.handlePasswordInput_.bind(this)); | |
758 this.submitButton.addEventListener('click', | |
759 this.handleSubmitButtonClick_.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; |
769 | |
770 // Lazy load the assets need for the polymer submit button. | |
771 if (cr.ui.login.ResourceLoader.alreadyLoadedAssets('userpod-polymer')) | |
772 return; | |
773 | |
774 cr.ui.login.ResourceLoader.registerAssets({ | |
775 id: 'userpod-polymer', | |
776 html: [ | |
777 { url: 'chrome://oobe/custom_elements_userpod.html'}] | |
jdufault
2016/08/30 17:34:18
Cleanup formatting
sammiequon
2016/08/30 18:04:48
Done.
| |
778 }); | |
779 cr.ui.login.ResourceLoader.loadAssetsOnIdle('userpod-polymer', | |
780 function() {}); | |
765 }, | 781 }, |
766 | 782 |
767 /** | 783 /** |
768 * Resets tab order for pod elements to its initial state. | 784 * Resets tab order for pod elements to its initial state. |
769 */ | 785 */ |
770 resetTabOrder: function() { | 786 resetTabOrder: function() { |
771 // Note: the |mainInput| can be the pod itself. | 787 // Note: the |mainInput| can be the pod itself. |
772 this.mainInput.tabIndex = -1; | 788 this.mainInput.tabIndex = -1; |
773 this.tabIndex = UserPodTabOrder.POD_INPUT; | 789 this.tabIndex = UserPodTabOrder.POD_INPUT; |
774 }, | 790 }, |
775 | 791 |
776 /** | 792 /** |
777 * Handles keypress event (i.e. any textual input) on password input. | 793 * Handles keypress event (i.e. any textual input) on password input. |
778 * @param {Event} e Keypress Event object. | 794 * @param {Event} e Keypress Event object. |
779 * @private | 795 * @private |
780 */ | 796 */ |
781 handlePasswordKeyPress_: function(e) { | 797 handlePasswordKeyPress_: function(e) { |
782 // When tabbing from the system tray a tab key press is received. Suppress | 798 // When tabbing from the system tray a tab key press is received. Suppress |
783 // this so as not to type a tab character into the password field. | 799 // this so as not to type a tab character into the password field. |
784 if (e.keyCode == 9) { | 800 if (e.keyCode == 9) { |
785 e.preventDefault(); | 801 e.preventDefault(); |
786 return; | 802 return; |
787 } | 803 } |
788 this.customIconElement.cancelDelayedTooltipShow(); | 804 this.customIconElement.cancelDelayedTooltipShow(); |
789 }, | 805 }, |
790 | 806 |
791 /** | 807 /** |
808 * Handles input changes on password input. | |
809 * @param {Event} e Input Event object. | |
810 * @private | |
811 */ | |
812 handlePasswordInput_: function(e) { | |
813 this.submitButton.disabled = this.passwordElement.value.length <= 0; | |
814 this.setErrorDisplay(false); | |
815 }, | |
816 | |
817 /** | |
818 * Handles a click event on submit button. | |
819 * @param {Event} e Click event. | |
820 */ | |
821 handleSubmitButtonClick_: function(e) { | |
822 this.parentNode.setActivatedPod(this, e); | |
823 }, | |
824 | |
825 /** | |
792 * Top edge margin number of pixels. | 826 * Top edge margin number of pixels. |
793 * @type {?number} | 827 * @type {?number} |
794 */ | 828 */ |
795 set top(top) { | 829 set top(top) { |
796 this.style.top = cr.ui.toCssPx(top); | 830 this.style.top = cr.ui.toCssPx(top); |
797 }, | 831 }, |
798 | 832 |
799 /** | 833 /** |
800 * Top edge margin number of pixels. | 834 * Top edge margin number of pixels. |
801 */ | 835 */ |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
859 | 893 |
860 /** | 894 /** |
861 * Gets password field. | 895 * Gets password field. |
862 * @type {!HTMLInputElement} | 896 * @type {!HTMLInputElement} |
863 */ | 897 */ |
864 get passwordElement() { | 898 get passwordElement() { |
865 return this.querySelector('.password'); | 899 return this.querySelector('.password'); |
866 }, | 900 }, |
867 | 901 |
868 /** | 902 /** |
903 * Gets submit button. | |
904 * @type {!HTMLInputElement} | |
905 */ | |
906 get submitButton() { | |
907 return this.querySelector('.submit-button'); | |
908 }, | |
909 | |
910 /** | |
869 * Gets the password label, which is used to show a message where the | 911 * Gets the password label, which is used to show a message where the |
870 * password field is normally. | 912 * password field is normally. |
871 * @type {!HTMLInputElement} | 913 * @type {!HTMLInputElement} |
872 */ | 914 */ |
873 get passwordLabelElement() { | 915 get passwordLabelElement() { |
874 return this.querySelector('.password-label'); | 916 return this.querySelector('.password-label'); |
875 }, | 917 }, |
876 | 918 |
877 /** | 919 /** |
878 * Gets the pin-keyboard of the pod. | 920 * Gets the pin-keyboard of the pod. |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1088 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; | 1130 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; |
1089 } else if (this.user_.isApp) { | 1131 } else if (this.user_.isApp) { |
1090 this.setUserPodIconType('app'); | 1132 this.setUserPodIconType('app'); |
1091 } | 1133 } |
1092 }, | 1134 }, |
1093 | 1135 |
1094 isPinReady: function() { | 1136 isPinReady: function() { |
1095 return this.pinKeyboard && this.pinKeyboard.offsetHeight > 0; | 1137 return this.pinKeyboard && this.pinKeyboard.offsetHeight > 0; |
1096 }, | 1138 }, |
1097 | 1139 |
1140 setErrorDisplay: function(visible) { | |
1141 this.submitButton.classList.toggle('error-shown', visible); | |
1142 }, | |
1143 | |
1098 toggleTransitions: function(enable) { | 1144 toggleTransitions: function(enable) { |
1099 this.classList.toggle('flying-pin-pod', enable); | 1145 this.classList.toggle('flying-pin-pod', enable); |
1100 }, | 1146 }, |
1101 | 1147 |
1102 updatePinClass_: function(element, enable) { | 1148 updatePinClass_: function(element, enable) { |
1103 element.classList.toggle('pin-enabled', enable); | 1149 element.classList.toggle('pin-enabled', enable); |
1104 element.classList.toggle('pin-disabled', !enable); | 1150 element.classList.toggle('pin-disabled', !enable); |
1105 }, | 1151 }, |
1106 | 1152 |
1107 setPinVisibility: function(visible) { | 1153 setPinVisibility: function(visible) { |
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2576 /** | 2622 /** |
2577 * Add an existing user pod to this pod row. | 2623 * Add an existing user pod to this pod row. |
2578 * @param {!Object} user User info dictionary. | 2624 * @param {!Object} user User info dictionary. |
2579 */ | 2625 */ |
2580 addUserPod: function(user) { | 2626 addUserPod: function(user) { |
2581 var userPod = this.createUserPod(user); | 2627 var userPod = this.createUserPod(user); |
2582 this.appendChild(userPod); | 2628 this.appendChild(userPod); |
2583 userPod.initialize(); | 2629 userPod.initialize(); |
2584 }, | 2630 }, |
2585 | 2631 |
2632 /** | |
2633 * Performs visual changes on the user pod if there is an error. | |
2634 * @param {boolean} visible Whether to show or hide the display. | |
2635 */ | |
2636 setFocusedPodErrorDisplay: function(visible) { | |
2637 if (this.focusedPod_) | |
jdufault
2016/08/30 17:34:18
Move this so it's defined next to setFocusedPodPin
sammiequon
2016/08/30 18:04:48
Done.
| |
2638 this.focusedPod_.setErrorDisplay(visible); | |
2639 }, | |
2640 | |
2641 /** | |
2642 * Enables or disables transitions on the user pod. | |
2643 * @param {boolean} enable | |
2644 */ | |
2586 togglePinTransitions: function(enable) { | 2645 togglePinTransitions: function(enable) { |
2587 for (var i = 0; i < this.pods.length; ++i) | 2646 for (var i = 0; i < this.pods.length; ++i) |
2588 this.pods[i].toggleTransitions(enable); | 2647 this.pods[i].toggleTransitions(enable); |
2589 }, | 2648 }, |
2590 | 2649 |
2650 /** | |
2651 * Shows or hides the pin keyboard for the current focused pod. | |
2652 * @param {boolean} visible | |
2653 */ | |
2591 setFocusedPodPinVisibility: function(visible) { | 2654 setFocusedPodPinVisibility: function(visible) { |
2592 if (this.focusedPod_ && this.focusedPod_.user.showPin) | 2655 if (this.focusedPod_ && this.focusedPod_.user.showPin) |
2593 this.focusedPod_.setPinVisibility(visible); | 2656 this.focusedPod_.setPinVisibility(visible); |
2594 }, | 2657 }, |
2595 | 2658 |
2596 /** | 2659 /** |
2597 * Runs app with a given id from the list of loaded apps. | 2660 * Runs app with a given id from the list of loaded apps. |
2598 * @param {!string} app_id of an app to run. | 2661 * @param {!string} app_id of an app to run. |
2599 * @param {boolean=} opt_diagnosticMode Whether to run the app in | 2662 * @param {boolean=} opt_diagnosticMode Whether to run the app in |
2600 * diagnostic mode. Default is false. | 2663 * diagnostic mode. Default is false. |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3537 if (pod && pod.multiProfilesPolicyApplied) { | 3600 if (pod && pod.multiProfilesPolicyApplied) { |
3538 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3601 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
3539 } | 3602 } |
3540 } | 3603 } |
3541 }; | 3604 }; |
3542 | 3605 |
3543 return { | 3606 return { |
3544 PodRow: PodRow | 3607 PodRow: PodRow |
3545 }; | 3608 }; |
3546 }); | 3609 }); |
OLD | NEW |