OLD | NEW |
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 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
9 | 9 |
10 /** | 10 /** |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 countrySelect.appendChild(new Option('', '')); | 318 countrySelect.appendChild(new Option('', '')); |
319 for (var i = 0; i < countryList.length; i++) { | 319 for (var i = 0; i < countryList.length; i++) { |
320 var option = new Option(countryList[i].name, | 320 var option = new Option(countryList[i].name, |
321 countryList[i].value); | 321 countryList[i].value); |
322 option.disabled = countryList[i].value == 'separator'; | 322 option.disabled = countryList[i].value == 'separator'; |
323 countrySelect.appendChild(option); | 323 countrySelect.appendChild(option); |
324 } | 324 } |
325 }, | 325 }, |
326 | 326 |
327 /** | 327 /** |
| 328 * Called to prepare the overlay when a new address is being added. |
| 329 * @private |
| 330 */ |
| 331 prepForNewAddress_: function() { |
| 332 // Focus the first element. |
| 333 this.pageDiv.querySelector('input').focus(); |
| 334 }, |
| 335 |
| 336 /** |
328 * Loads the address data from |address|, sets the input fields based on | 337 * Loads the address data from |address|, sets the input fields based on |
329 * this data, and stores the GUID and language code of the address. | 338 * this data, and stores the GUID and language code of the address. |
330 * @param {!Object} address Lots of info about an address from the browser. | 339 * @param {!Object} address Lots of info about an address from the browser. |
331 * @private | 340 * @private |
332 */ | 341 */ |
333 loadAddress_: function(address) { | 342 loadAddress_: function(address) { |
334 this.rebuildInputFields_(address.components); | 343 this.rebuildInputFields_(address.components); |
335 this.setInputFields_(address); | 344 this.setInputFields_(address); |
336 this.inputFieldChanged_(); | 345 this.inputFieldChanged_(); |
337 this.connectInputEvents_(); | 346 this.connectInputEvents_(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 | 409 |
401 if (input.tagName == 'LIST') { | 410 if (input.tagName == 'LIST') { |
402 options.autofillOptions.AutofillValuesList.decorate(input); | 411 options.autofillOptions.AutofillValuesList.decorate(input); |
403 input.autoExpands = true; | 412 input.autoExpands = true; |
404 } | 413 } |
405 } | 414 } |
406 } | 415 } |
407 }, | 416 }, |
408 }; | 417 }; |
409 | 418 |
| 419 AutofillEditAddressOverlay.prepForNewAddress = function() { |
| 420 AutofillEditAddressOverlay.getInstance().prepForNewAddress_(); |
| 421 }; |
| 422 |
410 AutofillEditAddressOverlay.loadAddress = function(address) { | 423 AutofillEditAddressOverlay.loadAddress = function(address) { |
411 AutofillEditAddressOverlay.getInstance().loadAddress_(address); | 424 AutofillEditAddressOverlay.getInstance().loadAddress_(address); |
412 }; | 425 }; |
413 | 426 |
414 AutofillEditAddressOverlay.loadAddressComponents = function(input) { | 427 AutofillEditAddressOverlay.loadAddressComponents = function(input) { |
415 AutofillEditAddressOverlay.getInstance().loadAddressComponents_(input); | 428 AutofillEditAddressOverlay.getInstance().loadAddressComponents_(input); |
416 }; | 429 }; |
417 | 430 |
418 AutofillEditAddressOverlay.setTitle = function(title) { | 431 AutofillEditAddressOverlay.setTitle = function(title) { |
419 $('autofill-address-title').textContent = title; | 432 $('autofill-address-title').textContent = title; |
420 }; | 433 }; |
421 | 434 |
422 AutofillEditAddressOverlay.setValidatedPhoneNumbers = function(numbers) { | 435 AutofillEditAddressOverlay.setValidatedPhoneNumbers = function(numbers) { |
423 var instance = AutofillEditAddressOverlay.getInstance(); | 436 var instance = AutofillEditAddressOverlay.getInstance(); |
424 var phoneList = instance.pageDiv.querySelector('[field=phone]'); | 437 var phoneList = instance.pageDiv.querySelector('[field=phone]'); |
425 instance.setMultiValueList_(phoneList, numbers); | 438 instance.setMultiValueList_(phoneList, numbers); |
426 phoneList.didReceiveValidationResult(); | 439 phoneList.didReceiveValidationResult(); |
427 }; | 440 }; |
428 | 441 |
429 // Export | 442 // Export |
430 return { | 443 return { |
431 AutofillEditAddressOverlay: AutofillEditAddressOverlay | 444 AutofillEditAddressOverlay: AutofillEditAddressOverlay |
432 }; | 445 }; |
433 }); | 446 }); |
OLD | NEW |