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

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

Issue 2444443002: cros: Allow pin keyboard to keep focus without popping up the pin keyboard. (Closed)
Patch Set: Fixed patch set 2 errors. Created 4 years, 1 month 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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
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('pin-change', 717 this.pinKeyboard.addEventListener('pin-change',
718 this.handlePinChanged_.bind(this)); 718 this.handlePinChanged_.bind(this));
719 this.pinKeyboard.addEventListener('pin-focus',
720 this.handlePinFocused_.bind(this));
721 this.pinKeyboard.addEventListener('pin-clear',
722 this.handlePinCleared_.bind(this));
719 } 723 }
720 724
721 this.actionBoxAreaElement.addEventListener('mousedown', 725 this.actionBoxAreaElement.addEventListener('mousedown',
722 stopEventPropagation); 726 stopEventPropagation);
723 this.actionBoxAreaElement.addEventListener('click', 727 this.actionBoxAreaElement.addEventListener('click',
724 this.handleActionAreaButtonClick_.bind(this)); 728 this.handleActionAreaButtonClick_.bind(this));
725 this.actionBoxAreaElement.addEventListener('keydown', 729 this.actionBoxAreaElement.addEventListener('keydown',
726 this.handleActionAreaButtonKeyDown_.bind(this)); 730 this.handleActionAreaButtonKeyDown_.bind(this));
727 731
728 this.actionBoxMenuTitleElement.addEventListener('keydown', 732 this.actionBoxMenuTitleElement.addEventListener('keydown',
(...skipping 19 matching lines...) Expand all
748 /** 752 /**
749 * 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.
750 */ 754 */
751 initialize: function() { 755 initialize: function() {
752 this.passwordElement.addEventListener('keydown', 756 this.passwordElement.addEventListener('keydown',
753 this.parentNode.handleKeyDown.bind(this.parentNode)); 757 this.parentNode.handleKeyDown.bind(this.parentNode));
754 this.passwordElement.addEventListener('keypress', 758 this.passwordElement.addEventListener('keypress',
755 this.handlePasswordKeyPress_.bind(this)); 759 this.handlePasswordKeyPress_.bind(this));
756 this.passwordElement.addEventListener('input', 760 this.passwordElement.addEventListener('input',
757 this.handleInputChanged_.bind(this)); 761 this.handleInputChanged_.bind(this));
762 this.passwordElement.addEventListener('mouseup',
763 this.handleInputMouseUp_.bind(this));
758 764
759 if (this.submitButton) { 765 if (this.submitButton) {
760 this.submitButton.addEventListener('click', 766 this.submitButton.addEventListener('click',
761 this.handleSubmitButtonClick_.bind(this)); 767 this.handleSubmitButtonClick_.bind(this));
762 } 768 }
763 769
764 this.imageElement.addEventListener('load', 770 this.imageElement.addEventListener('load',
765 this.parentNode.handlePodImageLoad.bind(this.parentNode, this)); 771 this.parentNode.handlePodImageLoad.bind(this.parentNode, this));
766 772
767 var initialAuthType = this.user.initialAuthType || 773 var initialAuthType = this.user.initialAuthType ||
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 for (var i = 0; i < elements.length; ++i) 1166 for (var i = 0; i < elements.length; ++i)
1161 this.updatePinClass_(elements[i], visible); 1167 this.updatePinClass_(elements[i], visible);
1162 this.updatePinClass_(this, visible); 1168 this.updatePinClass_(this, visible);
1163 1169
1164 // Set the focus to the input element after showing/hiding pin keyboard. 1170 // Set the focus to the input element after showing/hiding pin keyboard.
1165 this.mainInput.focus(); 1171 this.mainInput.focus();
1166 1172
1167 // Change the password placeholder based on pin keyboard visibility. 1173 // Change the password placeholder based on pin keyboard visibility.
1168 this.passwordElement.placeholder = loadTimeData.getString(visible ? 1174 this.passwordElement.placeholder = loadTimeData.getString(visible ?
1169 'pinKeyboardPlaceholderPinPassword' : 'passwordHint'); 1175 'pinKeyboardPlaceholderPinPassword' : 'passwordHint');
1176
1177 chrome.send('setForceDisableVirtualKeyboard', [visible]);
1170 }, 1178 },
1171 1179
1172 isPinShown: function() { 1180 isPinShown: function() {
1173 return this.classList.contains('pin-enabled'); 1181 return this.classList.contains('pin-enabled');
1174 }, 1182 },
1175 1183
1176 setUserPodIconType: function(userTypeClass) { 1184 setUserPodIconType: function(userTypeClass) {
1177 this.userTypeIconAreaElement.classList.add(userTypeClass); 1185 this.userTypeIconAreaElement.classList.add(userTypeClass);
1178 this.userTypeIconAreaElement.hidden = false; 1186 this.userTypeIconAreaElement.hidden = false;
1179 }, 1187 },
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 /** 1877 /**
1870 * Handles pin change event from the pin keyboard. 1878 * Handles pin change event from the pin keyboard.
1871 * @param {Event} e Pin change event. 1879 * @param {Event} e Pin change event.
1872 */ 1880 */
1873 handlePinChanged_: function(e) { 1881 handlePinChanged_: function(e) {
1874 this.passwordElement.value = e.detail.pin; 1882 this.passwordElement.value = e.detail.pin;
1875 this.updateInput_(); 1883 this.updateInput_();
1876 }, 1884 },
1877 1885
1878 /** 1886 /**
1887 * Handles pin focus event from the pin keyboard.
1888 * @param {Event} e Pin focus event.
1889 */
1890 handlePinFocused_: function(e) {
1891 this.mainInput.focus();
1892 },
1893
1894 /**
1895 * Handles pin clear event from the pin keyboard.
1896 * @param {Event} e Pin clear event.
1897 */
1898 handlePinCleared_: function(e) {
jdufault 2016/10/31 22:28:49 Could this be handled by the pin-change event? Wh
sammiequon 2016/11/02 18:08:41 Done.
1899 // Clear the text based on the caret location or selected region of the
jdufault 2016/10/31 22:28:49 Add these comments in the other implementation.
sammiequon 2016/11/02 18:07:54 Done.
1900 // password element.
1901 var selectionStart = this.passwordElement.selectionStart;
1902 var selectionEnd = this.passwordElement.selectionEnd;
1903
1904 // If it is just a caret, remove the character in front of the caret.
1905 if (selectionStart == selectionEnd)
1906 selectionStart--;
1907 this.passwordElement.value =
1908 this.passwordElement.value.substring(0, selectionStart) +
1909 this.passwordElement.value.substring(selectionEnd);
1910
1911 // Move the caret or selected region to the correct new place.
1912 this.passwordElement.setSelectionRange(selectionStart, selectionStart);
1913 this.handleInputChanged_(e);
1914 },
1915
1916 /**
1879 * Handles input event on the password element. 1917 * Handles input event on the password element.
1880 * @param {Event} e Input event. 1918 * @param {Event} e Input event.
1881 */ 1919 */
1882 handleInputChanged_: function(e) { 1920 handleInputChanged_: function(e) {
1883 if (this.pinKeyboard) 1921 if (this.pinKeyboard)
1884 this.pinKeyboard.value = this.passwordElement.value; 1922 this.pinKeyboard.value = this.passwordElement.value;
1885 if (this.submitButton)
1886 this.submitButton.disabled = this.passwordElement.value.length <= 0;
1887 this.updateInput_(); 1923 this.updateInput_();
1888 }, 1924 },
1889 1925
1890 /** 1926 /**
1927 * Handles mouse up event on the password element.
1928 * @param {Event} e Mouse up event.
1929 */
1930 handleInputMouseUp_: function(e) {
1931 // If the PIN keyboard is shown and the user clicks on the password
1932 // element, the virtual keyboard should pop up if it is enabled, so we
1933 // must disable the virtual keyboard override.
1934 if (this.isPinShown()) {
1935 chrome.send('setForceDisableVirtualKeyboard', [false]);
1936 }
1937 },
1938
1939 /**
1891 * Handles click event on a user pod. 1940 * Handles click event on a user pod.
1892 * @param {Event} e Click event. 1941 * @param {Event} e Click event.
1893 */ 1942 */
1894 handleClickOnPod_: function(e) { 1943 handleClickOnPod_: function(e) {
1895 if (this.parentNode.disabled) 1944 if (this.parentNode.disabled)
1896 return; 1945 return;
1897 1946
1898 if (!this.isActionBoxMenuActive) { 1947 if (!this.isActionBoxMenuActive) {
1899 if (this.isAuthTypeOnlineSignIn) { 1948 if (this.isAuthTypeOnlineSignIn) {
1900 this.showSigninUI(); 1949 this.showSigninUI();
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after
3652 if (pod && pod.multiProfilesPolicyApplied) { 3701 if (pod && pod.multiProfilesPolicyApplied) {
3653 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3702 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3654 } 3703 }
3655 } 3704 }
3656 }; 3705 };
3657 3706
3658 return { 3707 return {
3659 PodRow: PodRow 3708 PodRow: PodRow
3660 }; 3709 };
3661 }); 3710 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698