Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 }); |
| OLD | NEW |