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

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

Issue 516403003: Focus the first input when adding a new Autofill cc or address (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: new function instead Created 6 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 */ var Page = cr.ui.pageManager.Page; 6 /** @const */ var Page = cr.ui.pageManager.Page;
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager;
8 8
9 /** 9 /**
10 * AutofillEditCreditCardOverlay class 10 * AutofillEditCreditCardOverlay class
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 var date = new Date(); 172 var date = new Date();
173 var year = parseInt(date.getFullYear()); 173 var year = parseInt(date.getFullYear());
174 for (var i = 0; i < 10; ++i) { 174 for (var i = 0; i < 10; ++i) {
175 var text = year + i; 175 var text = year + i;
176 if (expYear == String(text)) 176 if (expYear == String(text))
177 $('expiration-year').selectedIndex = i; 177 $('expiration-year').selectedIndex = i;
178 } 178 }
179 }, 179 },
180 180
181 /** 181 /**
182 * Called to prepare the overlay when a new card is being added.
183 * @private
184 */
185 prepForNewCard_: function() {
186 // Focus the first element.
187 this.pageDiv.querySelector('input').focus();
188 },
189
190 /**
182 * Loads the credit card data from |creditCard|, sets the input fields based 191 * Loads the credit card data from |creditCard|, sets the input fields based
183 * on this data and stores the GUID of the credit card. 192 * on this data and stores the GUID of the credit card.
184 * @private 193 * @private
185 */ 194 */
186 loadCreditCard_: function(creditCard) { 195 loadCreditCard_: function(creditCard) {
187 this.setInputFields_(creditCard); 196 this.setInputFields_(creditCard);
188 this.inputFieldChanged_(); 197 this.inputFieldChanged_();
189 this.guid_ = creditCard.guid; 198 this.guid_ = creditCard.guid;
190 }, 199 },
191 }; 200 };
192 201
202 AutofillEditCreditCardOverlay.prepForNewCard = function() {
203 AutofillEditCreditCardOverlay.getInstance().prepForNewCard_();
204 };
205
193 AutofillEditCreditCardOverlay.loadCreditCard = function(creditCard) { 206 AutofillEditCreditCardOverlay.loadCreditCard = function(creditCard) {
194 AutofillEditCreditCardOverlay.getInstance().loadCreditCard_(creditCard); 207 AutofillEditCreditCardOverlay.getInstance().loadCreditCard_(creditCard);
195 }; 208 };
196 209
197 AutofillEditCreditCardOverlay.setTitle = function(title) { 210 AutofillEditCreditCardOverlay.setTitle = function(title) {
198 $('autofill-credit-card-title').textContent = title; 211 $('autofill-credit-card-title').textContent = title;
199 }; 212 };
200 213
201 // Export 214 // Export
202 return { 215 return {
203 AutofillEditCreditCardOverlay: AutofillEditCreditCardOverlay 216 AutofillEditCreditCardOverlay: AutofillEditCreditCardOverlay
204 }; 217 };
205 }); 218 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698