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

Unified Diff: chrome/browser/resources/options/autofill_edit_creditcard_overlay.js

Issue 6258022: DOMUI: Fix AF CC field some more. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another fix. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/options/options_page.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/options/autofill_edit_creditcard_overlay.js
diff --git a/chrome/browser/resources/options/autofill_edit_creditcard_overlay.js b/chrome/browser/resources/options/autofill_edit_creditcard_overlay.js
index 100f9316682959ef080daa23369a836c367aea7d..c5c4a5de6215c8505e03a60a4cc16c649fdee559 100644
--- a/chrome/browser/resources/options/autofill_edit_creditcard_overlay.js
+++ b/chrome/browser/resources/options/autofill_edit_creditcard_overlay.js
@@ -46,9 +46,6 @@ cr.define('options', function() {
self.saveCreditCard_();
self.dismissOverlay_();
}
- $('creditCardNumber').onkeydown = this.onTextInput_.bind(this);
- $('creditCardNumber').addEventListener('textInput',
- this.onTextInput_.bind(this));
self.guid_ = '';
self.storedCCNumber_ = '';
@@ -59,27 +56,6 @@ cr.define('options', function() {
},
/**
- * Handles the textInput and keydown events.
- * @private
- */
- onTextInput_: function(event) {
- // For some reason, the textInput event doesn't consider
- // backspace/deletion an input event, so we have to handle those here.
- // 8 - backspace
- // 46 - delete
- if (event.type == 'keydown' && event.keyCode != '8' &&
- event.keyCode != '46')
- return;
-
- // If the user hasn't edited the text yet, delete it all on edit.
- if (!this.hasEditedNumber_ &&
- $('creditCardNumber').value != this.storedCCNumber_) {
- this.hasEditedNumber_ = true;
- $('creditCardNumber').value = '';
- }
- },
-
- /**
* Clears any uncommitted input, and dismisses the overlay.
* @private
*/
@@ -118,22 +94,31 @@ cr.define('options', function() {
* @private
*/
connectInputEvents_: function() {
- var self = this;
$('nameOnCard').oninput = $('creditCardNumber').oninput =
$('expirationMonth').onchange = $('expirationYear').onchange =
- function(event) {
- self.inputFieldChanged_();
- }
+ this.inputFieldChanged_.bind(this);
},
/**
* Checks the values of each of the input fields and disables the 'Ok'
* button if all of the fields are empty.
+ * @param {Event} opt_event Optional data for the 'input' event.
* @private
*/
- inputFieldChanged_: function() {
- var disabled = !$('nameOnCard').value && !$('creditCardNumber').value;
+ inputFieldChanged_: function(opt_event) {
+ var ccNumber = $('creditCardNumber');
+ var disabled = !$('nameOnCard').value && !ccNumber.value;
$('autoFillEditCreditCardApplyButton').disabled = disabled;
+
+ if (opt_event && opt_event.target == ccNumber) {
+ // If the user hasn't edited the text yet, delete it all on edit.
+ if (!this.hasEditedNumber_ && this.storedCCNumber_.length &&
+ ccNumber.value != this.storedCCNumber_) {
+ ccNumber.value = '';
+ }
+
+ this.hasEditedNumber_ = true;
+ }
},
/**
« no previous file with comments | « no previous file | chrome/browser/resources/options/options_page.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698