| 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 OptionsPage = options.OptionsPage; | 6 /** @const */ var OptionsPage = options.OptionsPage; |
| 7 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 7 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
| 8 | 8 |
| 9 // The GUID of the loaded address. | 9 // The GUID of the loaded address. |
| 10 var guid; | 10 var guid; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * AutofillEditAddressOverlay class | 13 * AutofillEditAddressOverlay class |
| 14 * Encapsulated handling of the 'Add Page' overlay page. | 14 * Encapsulated handling of the 'Add Page' overlay page. |
| 15 * @class | 15 * @class |
| 16 */ | 16 */ |
| 17 function AutofillEditAddressOverlay() { | 17 function AutofillEditAddressOverlay() { |
| 18 OptionsPage.call(this, 'autofillEditAddress', | 18 OptionsPage.call(this, 'autofillEditAddress', |
| 19 templateData.autofillEditAddressTitle, | 19 loadTimeData.getString('autofillEditAddressTitle'), |
| 20 'autofill-edit-address-overlay'); | 20 'autofill-edit-address-overlay'); |
| 21 } | 21 } |
| 22 | 22 |
| 23 cr.addSingletonGetter(AutofillEditAddressOverlay); | 23 cr.addSingletonGetter(AutofillEditAddressOverlay); |
| 24 | 24 |
| 25 AutofillEditAddressOverlay.prototype = { | 25 AutofillEditAddressOverlay.prototype = { |
| 26 __proto__: OptionsPage.prototype, | 26 __proto__: OptionsPage.prototype, |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * Initializes the page. | 29 * Initializes the page. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 $('email-list').items.length <= 1; | 202 $('email-list').items.length <= 1; |
| 203 $('autofill-edit-address-apply-button').disabled = disabled; | 203 $('autofill-edit-address-apply-button').disabled = disabled; |
| 204 }, | 204 }, |
| 205 | 205 |
| 206 /** | 206 /** |
| 207 * Updates the postal code and state field labels appropriately for the | 207 * Updates the postal code and state field labels appropriately for the |
| 208 * selected country. | 208 * selected country. |
| 209 * @private | 209 * @private |
| 210 */ | 210 */ |
| 211 countryChanged_: function() { | 211 countryChanged_: function() { |
| 212 var countryCode = $('country').value; | 212 var countryCode = $('country').value || |
| 213 if (!countryCode) | 213 loadTimeData.getString('defaultCountryCode'); |
| 214 countryCode = templateData.defaultCountryCode; | |
| 215 | 214 |
| 216 var details = templateData.autofillCountryData[countryCode]; | 215 var details = loadTimeData.getValue('autofillCountryData')[countryCode]; |
| 217 var postal = $('postal-code-label'); | 216 var postal = $('postal-code-label'); |
| 218 postal.textContent = details['postalCodeLabel']; | 217 postal.textContent = details['postalCodeLabel']; |
| 219 $('state-label').textContent = details['stateLabel']; | 218 $('state-label').textContent = details['stateLabel']; |
| 220 | 219 |
| 221 // Also update the 'Ok' button as needed. | 220 // Also update the 'Ok' button as needed. |
| 222 this.inputFieldChanged_(); | 221 this.inputFieldChanged_(); |
| 223 }, | 222 }, |
| 224 | 223 |
| 225 /** | 224 /** |
| 226 * Populates the country <select> list. | 225 * Populates the country <select> list. |
| 227 * @private | 226 * @private |
| 228 */ | 227 */ |
| 229 populateCountryList_: function() { | 228 populateCountryList_: function() { |
| 230 var countryData = templateData.autofillCountryData; | 229 var countryData = loadTimeData.getValue('autofillCountryData'); |
| 231 var defaultCountryCode = templateData.defaultCountryCode; | 230 var defaultCountryCode = loadTimeData.getString('defaultCountryCode'); |
| 232 | 231 |
| 233 // Build an array of the country names and their corresponding country | 232 // Build an array of the country names and their corresponding country |
| 234 // codes, so that we can sort and insert them in order. | 233 // codes, so that we can sort and insert them in order. |
| 235 var countries = []; | 234 var countries = []; |
| 236 for (var countryCode in countryData) { | 235 for (var countryCode in countryData) { |
| 237 var country = { | 236 var country = { |
| 238 countryCode: countryCode, | 237 countryCode: countryCode, |
| 239 name: countryData[countryCode]['name'] | 238 name: countryData[countryCode]['name'] |
| 240 }; | 239 }; |
| 241 countries.push(country); | 240 countries.push(country); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 AutofillEditAddressOverlay.setValidatedPhoneNumbers = function(numbers) { | 335 AutofillEditAddressOverlay.setValidatedPhoneNumbers = function(numbers) { |
| 337 AutofillEditAddressOverlay.getInstance().setMultiValueList_('phone-list', | 336 AutofillEditAddressOverlay.getInstance().setMultiValueList_('phone-list', |
| 338 numbers); | 337 numbers); |
| 339 }; | 338 }; |
| 340 | 339 |
| 341 // Export | 340 // Export |
| 342 return { | 341 return { |
| 343 AutofillEditAddressOverlay: AutofillEditAddressOverlay | 342 AutofillEditAddressOverlay: AutofillEditAddressOverlay |
| 344 }; | 343 }; |
| 345 }); | 344 }); |
| OLD | NEW |