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