| 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; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 200 |
| 201 // Also update the 'Ok' button as needed. | 201 // Also update the 'Ok' button as needed. |
| 202 this.inputFieldChanged_(); | 202 this.inputFieldChanged_(); |
| 203 }, | 203 }, |
| 204 | 204 |
| 205 /** | 205 /** |
| 206 * Populates the country <select> list. | 206 * Populates the country <select> list. |
| 207 * @private | 207 * @private |
| 208 */ | 208 */ |
| 209 populateCountryList_: function() { | 209 populateCountryList_: function() { |
| 210 var countryData = loadTimeData.getValue('autofillCountryData'); | 210 var countryList = loadTimeData.getValue('autofillCountrySelectList'); |
| 211 var defaultCountryCode = loadTimeData.getString('defaultCountryCode'); | |
| 212 | |
| 213 // Build an array of the country names and their corresponding country | |
| 214 // codes, so that we can sort and insert them in order. | |
| 215 var countries = []; | |
| 216 for (var countryCode in countryData) { | |
| 217 var country = { | |
| 218 countryCode: countryCode, | |
| 219 name: countryData[countryCode].name | |
| 220 }; | |
| 221 countries.push(country); | |
| 222 } | |
| 223 | |
| 224 // Sort the countries in alphabetical order by name. | |
| 225 countries = countries.sort(function(a, b) { | |
| 226 return a.name < b.name ? -1 : 1; | |
| 227 }); | |
| 228 | |
| 229 // Insert the empty and default countries at the beginning of the array. | |
| 230 var emptyCountry = { | |
| 231 countryCode: '', | |
| 232 name: '' | |
| 233 }; | |
| 234 var defaultCountry = { | |
| 235 countryCode: defaultCountryCode, | |
| 236 name: countryData[defaultCountryCode].name | |
| 237 }; | |
| 238 var separator = { | |
| 239 countryCode: '', | |
| 240 name: '---', | |
| 241 disabled: true | |
| 242 }; | |
| 243 countries.unshift(emptyCountry, defaultCountry, separator); | |
| 244 | 211 |
| 245 // Add the countries to the country <select> list. | 212 // Add the countries to the country <select> list. |
| 246 var countryList = $('country'); | 213 var countrySelect = $('country'); |
| 247 for (var i = 0; i < countries.length; i++) { | 214 for (var i = 0; i < countryList.length; i++) { |
| 248 var country = new Option(countries[i].name, countries[i].countryCode); | 215 var option = new Option(countryList[i].name, |
| 249 country.disabled = countries[i].disabled; | 216 countryList[i].value); |
| 250 countryList.appendChild(country); | 217 option.disabled = countryList[i].value == 'separator'; |
| 218 countrySelect.appendChild(option); |
| 251 } | 219 } |
| 252 }, | 220 }, |
| 253 | 221 |
| 254 /** | 222 /** |
| 255 * Clears the value of each input field. | 223 * Clears the value of each input field. |
| 256 * @private | 224 * @private |
| 257 */ | 225 */ |
| 258 clearInputFields_: function() { | 226 clearInputFields_: function() { |
| 259 this.setMultiValueList_('full-name-list', []); | 227 this.setMultiValueList_('full-name-list', []); |
| 260 $('company-name').value = ''; | 228 $('company-name').value = ''; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 AutofillEditAddressOverlay.setValidatedPhoneNumbers = function(numbers) { | 284 AutofillEditAddressOverlay.setValidatedPhoneNumbers = function(numbers) { |
| 317 AutofillEditAddressOverlay.getInstance().setMultiValueList_('phone-list', | 285 AutofillEditAddressOverlay.getInstance().setMultiValueList_('phone-list', |
| 318 numbers); | 286 numbers); |
| 319 }; | 287 }; |
| 320 | 288 |
| 321 // Export | 289 // Export |
| 322 return { | 290 return { |
| 323 AutofillEditAddressOverlay: AutofillEditAddressOverlay | 291 AutofillEditAddressOverlay: AutofillEditAddressOverlay |
| 324 }; | 292 }; |
| 325 }); | 293 }); |
| OLD | NEW |