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

Side by Side Diff: chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js

Issue 2119713003: Pin keyboard use enter to submit when focus is not on a button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Rebased. Created 4 years, 5 months 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
« no previous file with comments | « chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.html ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 6 * @fileoverview
7 * 'pin-keyboard' is a keyboard that can be used to enter PINs or more generally 7 * 'pin-keyboard' is a keyboard that can be used to enter PINs or more generally
8 * numeric values. 8 * numeric values.
9 * 9 *
10 * Properties: 10 * Properties:
(...skipping 17 matching lines...) Expand all
28 properties: { 28 properties: {
29 /** The value stored in the keyboard's input element. */ 29 /** The value stored in the keyboard's input element. */
30 value: { 30 value: {
31 type: String, 31 type: String,
32 notify: true, 32 notify: true,
33 value: '', 33 value: '',
34 observer: 'onPinValueChange_' 34 observer: 'onPinValueChange_'
35 } 35 }
36 }, 36 },
37 37
38 // The current focused element.
39 focusedElement_: undefined,
40
38 /** Transfers focus to the input element. */ 41 /** Transfers focus to the input element. */
39 focus: function() { 42 focus: function() {
40 this.$$('#pin-input').focus(); 43 var pinInput = this.$$('#pin-input');
44 pinInput.focus();
45 this.focusedElement_ = pinInput;
46 },
47
48 /** Called when a pin keyboard has a key pressed. */
49 onButtonKeyUp_: function(event, detail) {
50 // Only if tab has been pressed do we want change the focus.
51 if (event.target.receivedFocusFromKeyboard)
52 this.focusedElement_ = event.target;
41 }, 53 },
42 54
43 /** Called when a keypad number has been tapped. */ 55 /** Called when a keypad number has been tapped. */
44 onNumberTap_: function(event, detail) { 56 onNumberTap_: function(event, detail) {
45 var numberValue = event.target.getAttribute('value'); 57 var numberValue = event.target.getAttribute('value');
46 this.value += numberValue; 58 this.value += numberValue;
59
60 // If the tabbed element is clicked we want to keep the focus, otherwise
61 // transfer focus to the input.
62 if (this.focusedElement_ != event.target)
63 this.focus();
jdufault 2016/07/06 19:07:05 Can this just be // Only focus buttons if the u
47 }, 64 },
48 65
49 /** Fires a submit event with the current PIN value. */ 66 /** Fires a submit event with the current PIN value. */
50 firePinSubmitEvent_: function() { 67 firePinSubmitEvent_: function() {
51 this.fire('submit', { pin: this.value }); 68 this.fire('submit', { pin: this.value });
52 }, 69 },
53 70
54 /** 71 /**
55 * Fires an update event with the current PIN value. The event will only be 72 * Fires an update event with the current PIN value. The event will only be
56 * fired if the PIN value has actually changed. 73 * fired if the PIN value has actually changed.
(...skipping 30 matching lines...) Expand all
87 }, 104 },
88 105
89 /** 106 /**
90 * Changes the color of the submit button if PIN is ready. 107 * Changes the color of the submit button if PIN is ready.
91 * @param {string} value 108 * @param {string} value
92 */ 109 */
93 computeSubmitClass_: function(value) { 110 computeSubmitClass_: function(value) {
94 return value.length > 0 ? 'ready-background' : ''; 111 return value.length > 0 ? 'ready-background' : '';
95 } 112 }
96 }); 113 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698