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

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: 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
« ui/keyboard/keyboard_util.cc ('K') | « ui/keyboard/keyboard_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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('enableVirtualKeyboardOverride', [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 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1864 this.submitButton.disabled = this.passwordElement.value.length <= 0; 1872 this.submitButton.disabled = this.passwordElement.value.length <= 0;
1865 this.showError = false; 1873 this.showError = false;
1866 $('bubble').hide(); 1874 $('bubble').hide();
1867 }, 1875 },
1868 1876
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 if (this.passwordElement.value != e.detail.pin)
1883 this.passwordElement.value = e.detail.pin;
1875 this.updateInput_(); 1884 this.updateInput_();
1876 }, 1885 },
1877 1886
1878 /** 1887 /**
1888 * Handles pin focus event from the pin keyboard.
1889 * @param {Event} e Pin focus event.
1890 */
1891 handlePinFocused_: function(e) {
1892 this.mainInput.focus();
1893 },
1894
1895 /**
1896 * Handles pin clear event from the pin keyboard.
1897 * @param {Event} e Pin clear event.
1898 */
1899 handlePinCleared_: function(e) {
1900 // Clear the text based on the caret location or selected region of the
1901 // password element.
1902 var selectionStart = this.passwordElement.selectionStart;
1903 var selectionEnd = this.passwordElement.selectionEnd;
1904
1905 // If it is just a caret, remove the character infront of the caret.
1906 if (selectionStart == selectionEnd)
1907 selectionStart--;
jdufault 2016/10/26 17:56:16 Like above, can we just send a backspace key event
sammiequon 2016/10/27 00:22:40 As per offline, this cannot be achieved.
1908 this.passwordElement.value =
1909 this.passwordElement.value.substring(0, selectionStart) +
1910 this.passwordElement.value.substring(selectionEnd,
1911 this.passwordElement.value.length);
1912
1913 // Move the caret or selected region to the correct new place.
1914 this.passwordElement.setSelectionRange(selectionStart, selectionStart);
1915 this.handleInputChanged_(e);
1916 },
1917
1918 /**
1879 * Handles input event on the password element. 1919 * Handles input event on the password element.
1880 * @param {Event} e Input event. 1920 * @param {Event} e Input event.
1881 */ 1921 */
1882 handleInputChanged_: function(e) { 1922 handleInputChanged_: function(e) {
1883 if (this.pinKeyboard) 1923 if (this.pinKeyboard)
1884 this.pinKeyboard.value = this.passwordElement.value; 1924 this.pinKeyboard.value = this.passwordElement.value;
1885 if (this.submitButton)
1886 this.submitButton.disabled = this.passwordElement.value.length <= 0;
1887 this.updateInput_(); 1925 this.updateInput_();
1888 }, 1926 },
1889 1927
1890 /** 1928 /**
1929 * Handles mouse up event on the password element.
1930 * @param {Event} e Mouse up event.
1931 */
1932 handleInputMouseUp_: function(e) {
1933 // If the PIN keyboard is shown and the user clicks on the password
1934 // element, the virtual keyboard should pop up if it is enabled, so we
1935 // must disable the virtual keyboard override.
1936 if (this.isPinShown()) {
1937 chrome.send('enableVirtualKeyboardOverride', [false]);
1938 }
1939 },
1940
1941 /**
1891 * Handles click event on a user pod. 1942 * Handles click event on a user pod.
1892 * @param {Event} e Click event. 1943 * @param {Event} e Click event.
1893 */ 1944 */
1894 handleClickOnPod_: function(e) { 1945 handleClickOnPod_: function(e) {
1895 if (this.parentNode.disabled) 1946 if (this.parentNode.disabled)
1896 return; 1947 return;
1897 1948
1898 if (!this.isActionBoxMenuActive) { 1949 if (!this.isActionBoxMenuActive) {
1899 if (this.isAuthTypeOnlineSignIn) { 1950 if (this.isAuthTypeOnlineSignIn) {
1900 this.showSigninUI(); 1951 this.showSigninUI();
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after
3652 if (pod && pod.multiProfilesPolicyApplied) { 3703 if (pod && pod.multiProfilesPolicyApplied) {
3653 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3704 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3654 } 3705 }
3655 } 3706 }
3656 }; 3707 };
3657 3708
3658 return { 3709 return {
3659 PodRow: PodRow 3710 PodRow: PodRow
3660 }; 3711 };
3661 }); 3712 });
OLDNEW
« ui/keyboard/keyboard_util.cc ('K') | « ui/keyboard/keyboard_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698