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 // Add an empty option. |
248 var country = new Option(countries[i].name, countries[i].countryCode); | 215 countrySelect.appendChild(new Option('', '')); |
249 country.disabled = countries[i].disabled; | 216 for (var i = 0; i < countryList.length; i++) { |
250 countryList.appendChild(country); | 217 var option = new Option(countryList[i].name, |
| 218 countryList[i].value); |
| 219 option.disabled = countryList[i].value == 'separator'; |
| 220 countrySelect.appendChild(option); |
251 } | 221 } |
252 }, | 222 }, |
253 | 223 |
254 /** | 224 /** |
255 * Clears the value of each input field. | 225 * Clears the value of each input field. |
256 * @private | 226 * @private |
257 */ | 227 */ |
258 clearInputFields_: function() { | 228 clearInputFields_: function() { |
259 this.setMultiValueList_('full-name-list', []); | 229 this.setMultiValueList_('full-name-list', []); |
260 $('company-name').value = ''; | 230 $('company-name').value = ''; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 AutofillEditAddressOverlay.setValidatedPhoneNumbers = function(numbers) { | 286 AutofillEditAddressOverlay.setValidatedPhoneNumbers = function(numbers) { |
317 AutofillEditAddressOverlay.getInstance().setMultiValueList_('phone-list', | 287 AutofillEditAddressOverlay.getInstance().setMultiValueList_('phone-list', |
318 numbers); | 288 numbers); |
319 }; | 289 }; |
320 | 290 |
321 // Export | 291 // Export |
322 return { | 292 return { |
323 AutofillEditAddressOverlay: AutofillEditAddressOverlay | 293 AutofillEditAddressOverlay: AutofillEditAddressOverlay |
324 }; | 294 }; |
325 }); | 295 }); |
OLD | NEW |