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 Page = cr.ui.pageManager.Page; |
| 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
7 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
8 | 9 |
9 /** | 10 /** |
10 * AutofillEditAddressOverlay class | 11 * AutofillEditAddressOverlay class |
11 * Encapsulated handling of the 'Add Page' overlay page. | 12 * Encapsulated handling of the 'Add Page' overlay page. |
12 * @class | 13 * @class |
13 */ | 14 */ |
14 function AutofillEditAddressOverlay() { | 15 function AutofillEditAddressOverlay() { |
15 OptionsPage.call(this, 'autofillEditAddress', | 16 Page.call(this, 'autofillEditAddress', |
16 loadTimeData.getString('autofillEditAddressTitle'), | 17 loadTimeData.getString('autofillEditAddressTitle'), |
17 'autofill-edit-address-overlay'); | 18 'autofill-edit-address-overlay'); |
18 } | 19 } |
19 | 20 |
20 cr.addSingletonGetter(AutofillEditAddressOverlay); | 21 cr.addSingletonGetter(AutofillEditAddressOverlay); |
21 | 22 |
22 AutofillEditAddressOverlay.prototype = { | 23 AutofillEditAddressOverlay.prototype = { |
23 __proto__: OptionsPage.prototype, | 24 __proto__: Page.prototype, |
24 | 25 |
25 /** | 26 /** |
26 * The GUID of the loaded address. | 27 * The GUID of the loaded address. |
27 * @type {string} | 28 * @type {string} |
28 */ | 29 */ |
29 guid_: '', | 30 guid_: '', |
30 | 31 |
31 /** | 32 /** |
32 * The BCP 47 language code for the layout of input fields. | 33 * The BCP 47 language code for the layout of input fields. |
33 * @type {string} | 34 * @type {string} |
34 */ | 35 */ |
35 languageCode_: '', | 36 languageCode_: '', |
36 | 37 |
37 /** | 38 /** |
38 * The saved field values for the address. For example, if the user changes | 39 * The saved field values for the address. For example, if the user changes |
39 * from United States to Switzerland, then the State field will be hidden | 40 * from United States to Switzerland, then the State field will be hidden |
40 * and its value will be stored here. If the user changes back to United | 41 * and its value will be stored here. If the user changes back to United |
41 * States, then the State field will be restored to its previous value, as | 42 * States, then the State field will be restored to its previous value, as |
42 * stored in this object. | 43 * stored in this object. |
43 * @type {Object} | 44 * @type {Object} |
44 */ | 45 */ |
45 savedFieldValues_: {}, | 46 savedFieldValues_: {}, |
46 | 47 |
47 /** @override */ | 48 /** @override */ |
48 initializePage: function() { | 49 initializePage: function() { |
49 OptionsPage.prototype.initializePage.call(this); | 50 Page.prototype.initializePage.call(this); |
50 | 51 |
51 this.createMultiValueLists_(); | 52 this.createMultiValueLists_(); |
52 | 53 |
53 var self = this; | 54 var self = this; |
54 $('autofill-edit-address-cancel-button').onclick = function(event) { | 55 $('autofill-edit-address-cancel-button').onclick = function(event) { |
55 self.dismissOverlay_(); | 56 self.dismissOverlay_(); |
56 }; | 57 }; |
57 | 58 |
58 // TODO(jhawkins): Investigate other possible solutions. | 59 // TODO(jhawkins): Investigate other possible solutions. |
59 $('autofill-edit-address-apply-button').onclick = function(event) { | 60 $('autofill-edit-address-apply-button').onclick = function(event) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 * Clears any uncommitted input, resets the stored GUID and dismisses the | 146 * Clears any uncommitted input, resets the stored GUID and dismisses the |
146 * overlay. | 147 * overlay. |
147 * @private | 148 * @private |
148 */ | 149 */ |
149 dismissOverlay_: function() { | 150 dismissOverlay_: function() { |
150 this.setInputFields_({}); | 151 this.setInputFields_({}); |
151 this.inputFieldChanged_(); | 152 this.inputFieldChanged_(); |
152 this.guid_ = ''; | 153 this.guid_ = ''; |
153 this.languageCode_ = ''; | 154 this.languageCode_ = ''; |
154 this.savedInputFields_ = {}; | 155 this.savedInputFields_ = {}; |
155 OptionsPage.closeOverlay(); | 156 PageManager.closeOverlay(); |
156 }, | 157 }, |
157 | 158 |
158 /** | 159 /** |
159 * @return {Element} The element used to switch countries. | 160 * @return {Element} The element used to switch countries. |
160 * @private | 161 * @private |
161 */ | 162 */ |
162 getCountrySwitcher_: function() { | 163 getCountrySwitcher_: function() { |
163 return this.pageDiv.querySelector('[field=country]'); | 164 return this.pageDiv.querySelector('[field=country]'); |
164 }, | 165 }, |
165 | 166 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 var phoneList = instance.pageDiv.querySelector('[field=phone]'); | 424 var phoneList = instance.pageDiv.querySelector('[field=phone]'); |
424 instance.setMultiValueList_(phoneList, numbers); | 425 instance.setMultiValueList_(phoneList, numbers); |
425 phoneList.didReceiveValidationResult(); | 426 phoneList.didReceiveValidationResult(); |
426 }; | 427 }; |
427 | 428 |
428 // Export | 429 // Export |
429 return { | 430 return { |
430 AutofillEditAddressOverlay: AutofillEditAddressOverlay | 431 AutofillEditAddressOverlay: AutofillEditAddressOverlay |
431 }; | 432 }; |
432 }); | 433 }); |
OLD | NEW |