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

Side by Side Diff: chrome/browser/resources/options/autofill_edit_creditcard_overlay.js

Issue 6274010: DOMUI: Handle textInput in addition to keydown for the AF cc input field. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle delete too. Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 cr.define('options', function() { 5 cr.define('options', function() {
6 const OptionsPage = options.OptionsPage; 6 const OptionsPage = options.OptionsPage;
7 7
8 // The GUID of the loaded credit card. 8 // The GUID of the loaded credit card.
9 var guid_; 9 var guid_;
10 10
(...skipping 28 matching lines...) Expand all
39 OptionsPage.prototype.initializePage.call(this); 39 OptionsPage.prototype.initializePage.call(this);
40 40
41 var self = this; 41 var self = this;
42 $('autoFillEditCreditCardCancelButton').onclick = function(event) { 42 $('autoFillEditCreditCardCancelButton').onclick = function(event) {
43 self.dismissOverlay_(); 43 self.dismissOverlay_();
44 } 44 }
45 $('autoFillEditCreditCardApplyButton').onclick = function(event) { 45 $('autoFillEditCreditCardApplyButton').onclick = function(event) {
46 self.saveCreditCard_(); 46 self.saveCreditCard_();
47 self.dismissOverlay_(); 47 self.dismissOverlay_();
48 } 48 }
49 $('creditCardNumber').onkeydown = this.onKeyDown_.bind(this); 49 $('creditCardNumber').onkeydown = this.onTextInput_.bind(this);
50 $('creditCardNumber').addEventListener('textInput',
arv (Not doing code reviews) 2011/01/26 18:17:07 Should this be 'input' like everywhere else?
51 this.onTextInput_.bind(this));
50 52
51 self.guid_ = ''; 53 self.guid_ = '';
52 self.storedCCNumber_ = ''; 54 self.storedCCNumber_ = '';
53 self.hasEditedNumber_ = false; 55 self.hasEditedNumber_ = false;
54 self.clearInputFields_(); 56 self.clearInputFields_();
55 self.connectInputEvents_(); 57 self.connectInputEvents_();
56 self.setDefaultSelectOptions_(); 58 self.setDefaultSelectOptions_();
57 }, 59 },
58 60
59 /** 61 /**
60 * Handles the keydown event. 62 * Handles the textInput and keydown events.
61 * @private 63 * @private
62 */ 64 */
63 onKeyDown_: function(event) { 65 onTextInput_: function(event) {
66 // For some reason, the textInput event doesn't consider
arv (Not doing code reviews) 2011/01/26 18:17:07 The input event fires for all user changes to the
67 // backspace/deletion an input event, so we have to handle those here.
68 // 8 - backspace
69 // 46 - delete
70 if (event.type == 'keydown' && event.keyCode != '8' &&
arv (Not doing code reviews) 2011/01/26 18:17:07 FYI, keyCode is a Number so comparing it to a stri
71 event.keyCode != '46')
72 return;
73
64 // If the user hasn't edited the text yet, delete it all on edit. 74 // If the user hasn't edited the text yet, delete it all on edit.
65 if (!this.hasEditedNumber_ && 75 if (!this.hasEditedNumber_ &&
66 $('creditCardNumber').value != this.storedCCNumber_) { 76 $('creditCardNumber').value != this.storedCCNumber_) {
67 this.hasEditedNumber_ = true; 77 this.hasEditedNumber_ = true;
68 $('creditCardNumber').value = ''; 78 $('creditCardNumber').value = '';
69 } 79 }
70 }, 80 },
71 81
72 /** 82 /**
73 * Clears any uncommitted input, and dismisses the overlay. 83 * Clears any uncommitted input, and dismisses the overlay.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 AutoFillEditCreditCardOverlay.setTitle = function(title) { 235 AutoFillEditCreditCardOverlay.setTitle = function(title) {
226 $('autoFillCreditCardTitle').textContent = title; 236 $('autoFillCreditCardTitle').textContent = title;
227 }; 237 };
228 238
229 // Export 239 // Export
230 return { 240 return {
231 AutoFillEditCreditCardOverlay: AutoFillEditCreditCardOverlay 241 AutoFillEditCreditCardOverlay: AutoFillEditCreditCardOverlay
232 }; 242 };
233 243
234 }); 244 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698