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

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

Issue 2100203003: Pin keyboard matches red lines (go/cros-quick-unlock-ux). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: 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
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 onNumberTap_: function(event, detail) { 44 onNumberTap_: function(event, detail) {
45 var numberValue = event.target.getAttribute('value'); 45 var numberValue = event.target.getAttribute('value');
46 this.value += numberValue; 46 this.value += numberValue;
47 }, 47 },
48 48
49 /** Fires a submit event with the current PIN value. */ 49 /** Fires a submit event with the current PIN value. */
50 firePinSubmitEvent_: function() { 50 firePinSubmitEvent_: function() {
51 this.fire('submit', { pin: this.value }); 51 this.fire('submit', { pin: this.value });
52 }, 52 },
53 53
54 /** Changes the color of the submit button if PIN is ready. */
55 changeSubmitColor_: function(pinLength) {
56 var button = this.querySelectorAll('.submit-button .icon-container')[0];
57 button.classList.toggle('ready-background', pinLength > 0);
58 },
59
54 /** 60 /**
55 * Fires an update event with the current PIN value. The event will only be 61 * Fires an update event with the current PIN value. The event will only be
56 * fired if the PIN value has actually changed. 62 * fired if the PIN value has actually changed.
57 * @param {string} value 63 * @param {string} value
58 * @param {string} previous 64 * @param {string} previous
59 */ 65 */
60 onPinValueChange_: function(value, previous) { 66 onPinValueChange_: function(value, previous) {
61 if (value != previous) 67 if (value != previous) {
62 this.fire('pin-change', { pin: value }); 68 this.fire('pin-change', { pin: value });
69 this.changeSubmitColor_(value.length);
jdufault 2016/06/27 19:17:52 The color should only be blue if value.length > 0,
70 }
63 }, 71 },
64 72
65 /** Called when the user wants to erase the last character of the entered 73 /** Called when the user wants to erase the last character of the entered
66 * PIN value. 74 * PIN value.
67 */ 75 */
68 onPinClear_: function() { 76 onPinClear_: function() {
69 this.value = this.value.substring(0, this.value.length - 1); 77 this.value = this.value.substring(0, this.value.length - 1);
70 }, 78 },
71 79
72 /** Called when a key event is pressed while the input element has focus. */ 80 /** Called when a key event is pressed while the input element has focus. */
73 onInputKeyDown_: function(event) { 81 onInputKeyDown_: function(event) {
74 // Up/down pressed, swallow the event to prevent the input value from 82 // Up/down pressed, swallow the event to prevent the input value from
75 // being incremented or decremented. 83 // being incremented or decremented.
76 if (event.keyCode == 38 || event.keyCode == 40) { 84 if (event.keyCode == 38 || event.keyCode == 40) {
77 event.preventDefault(); 85 event.preventDefault();
78 return; 86 return;
79 } 87 }
80 88
81 // Enter pressed. 89 // Enter pressed.
82 if (event.keyCode == 13) { 90 if (event.keyCode == 13) {
83 this.firePinSubmitEvent_(); 91 this.firePinSubmitEvent_();
84 event.preventDefault(); 92 event.preventDefault();
85 return; 93 return;
86 } 94 }
87 } 95 }
88 }); 96 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698