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 var OptionsPage = options.OptionsPage; | 6 var Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; |
7 var ArrayDataModel = cr.ui.ArrayDataModel; | 8 var ArrayDataModel = cr.ui.ArrayDataModel; |
8 | 9 |
9 ///////////////////////////////////////////////////////////////////////////// | 10 ///////////////////////////////////////////////////////////////////////////// |
10 // AutofillOptions class: | 11 // AutofillOptions class: |
11 | 12 |
12 /** | 13 /** |
13 * Encapsulated handling of Autofill options page. | 14 * Encapsulated handling of Autofill options page. |
14 * @constructor | 15 * @constructor |
15 */ | 16 */ |
16 function AutofillOptions() { | 17 function AutofillOptions() { |
17 OptionsPage.call(this, | 18 Page.call(this, |
18 'autofill', | 19 'autofill', |
19 loadTimeData.getString('autofillOptionsPageTabTitle'), | 20 loadTimeData.getString('autofillOptionsPageTabTitle'), |
20 'autofill-options'); | 21 'autofill-options'); |
21 } | 22 } |
22 | 23 |
23 cr.addSingletonGetter(AutofillOptions); | 24 cr.addSingletonGetter(AutofillOptions); |
24 | 25 |
25 AutofillOptions.prototype = { | 26 AutofillOptions.prototype = { |
26 __proto__: OptionsPage.prototype, | 27 __proto__: Page.prototype, |
27 | 28 |
28 /** | 29 /** |
29 * The address list. | 30 * The address list. |
30 * @type {DeletableItemList} | 31 * @type {DeletableItemList} |
31 * @private | 32 * @private |
32 */ | 33 */ |
33 addressList_: null, | 34 addressList_: null, |
34 | 35 |
35 /** | 36 /** |
36 * The credit card list. | 37 * The credit card list. |
37 * @type {DeletableItemList} | 38 * @type {DeletableItemList} |
38 * @private | 39 * @private |
39 */ | 40 */ |
40 creditCardList_: null, | 41 creditCardList_: null, |
41 | 42 |
42 initializePage: function() { | 43 initializePage: function() { |
43 OptionsPage.prototype.initializePage.call(this); | 44 Page.prototype.initializePage.call(this); |
44 | 45 |
45 this.createAddressList_(); | 46 this.createAddressList_(); |
46 this.createCreditCardList_(); | 47 this.createCreditCardList_(); |
47 | 48 |
48 var self = this; | 49 var self = this; |
49 $('autofill-add-address').onclick = function(event) { | 50 $('autofill-add-address').onclick = function(event) { |
50 self.showAddAddressOverlay_(); | 51 self.showAddAddressOverlay_(); |
51 }; | 52 }; |
52 $('autofill-add-creditcard').onclick = function(event) { | 53 $('autofill-add-creditcard').onclick = function(event) { |
53 self.showAddCreditCardOverlay_(); | 54 self.showAddCreditCardOverlay_(); |
54 }; | 55 }; |
55 $('autofill-options-confirm').onclick = function(event) { | 56 $('autofill-options-confirm').onclick = function(event) { |
56 OptionsPage.closeOverlay(); | 57 PageManager.closeOverlay(); |
57 }; | 58 }; |
58 <if expr="is_macosx"> | 59 <if expr="is_macosx"> |
59 $('autofill-use-mac-address-book-checkbox').onchange = function(event) { | 60 $('autofill-use-mac-address-book-checkbox').onchange = function(event) { |
60 if (this.checked) { | 61 if (this.checked) { |
61 setTimeout(function() { | 62 setTimeout(function() { |
62 // Prompt the user to give Chrome access to the user's Address | 63 // Prompt the user to give Chrome access to the user's Address |
63 // Book, if the user was not previously prompted. The dialog that | 64 // Book, if the user was not previously prompted. The dialog that |
64 // appears blocks the Chrome process, so wait for a small period of | 65 // appears blocks the Chrome process, so wait for a small period of |
65 // time to allow the checkbox to appear filled in. | 66 // time to allow the checkbox to appear filled in. |
66 chrome.send('accessAddressBook'); | 67 chrome.send('accessAddressBook'); |
(...skipping 28 matching lines...) Expand all Loading... |
95 }, | 96 }, |
96 | 97 |
97 /** | 98 /** |
98 * Shows the 'Add address' overlay, specifically by loading the | 99 * Shows the 'Add address' overlay, specifically by loading the |
99 * 'Edit address' overlay and modifying the overlay title. | 100 * 'Edit address' overlay and modifying the overlay title. |
100 * @private | 101 * @private |
101 */ | 102 */ |
102 showAddAddressOverlay_: function() { | 103 showAddAddressOverlay_: function() { |
103 var title = loadTimeData.getString('addAddressTitle'); | 104 var title = loadTimeData.getString('addAddressTitle'); |
104 AutofillEditAddressOverlay.setTitle(title); | 105 AutofillEditAddressOverlay.setTitle(title); |
105 OptionsPage.navigateToPage('autofillEditAddress'); | 106 PageManager.showPageByName('autofillEditAddress'); |
106 }, | 107 }, |
107 | 108 |
108 /** | 109 /** |
109 * Shows the 'Add credit card' overlay, specifically by loading the | 110 * Shows the 'Add credit card' overlay, specifically by loading the |
110 * 'Edit credit card' overlay and modifying the overlay title. | 111 * 'Edit credit card' overlay and modifying the overlay title. |
111 * @private | 112 * @private |
112 */ | 113 */ |
113 showAddCreditCardOverlay_: function() { | 114 showAddCreditCardOverlay_: function() { |
114 var title = loadTimeData.getString('addCreditCardTitle'); | 115 var title = loadTimeData.getString('addCreditCardTitle'); |
115 AutofillEditCreditCardOverlay.setTitle(title); | 116 AutofillEditCreditCardOverlay.setTitle(title); |
116 OptionsPage.navigateToPage('autofillEditCreditCard'); | 117 PageManager.showPageByName('autofillEditCreditCard'); |
117 }, | 118 }, |
118 | 119 |
119 /** | 120 /** |
120 * Updates the data model for the address list with the values from | 121 * Updates the data model for the address list with the values from |
121 * |entries|. | 122 * |entries|. |
122 * @param {Array} entries The list of addresses. | 123 * @param {Array} entries The list of addresses. |
123 */ | 124 */ |
124 setAddressList_: function(entries) { | 125 setAddressList_: function(entries) { |
125 this.addressList_.dataModel = new ArrayDataModel(entries); | 126 this.addressList_.dataModel = new ArrayDataModel(entries); |
126 }, | 127 }, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 /** | 169 /** |
169 * Shows the 'Edit address' overlay, using the data in |address| to fill the | 170 * Shows the 'Edit address' overlay, using the data in |address| to fill the |
170 * input fields. |address| is a list with one item, an associative array | 171 * input fields. |address| is a list with one item, an associative array |
171 * that contains the address data. | 172 * that contains the address data. |
172 * @private | 173 * @private |
173 */ | 174 */ |
174 showEditAddressOverlay_: function(address) { | 175 showEditAddressOverlay_: function(address) { |
175 var title = loadTimeData.getString('editAddressTitle'); | 176 var title = loadTimeData.getString('editAddressTitle'); |
176 AutofillEditAddressOverlay.setTitle(title); | 177 AutofillEditAddressOverlay.setTitle(title); |
177 AutofillEditAddressOverlay.loadAddress(address); | 178 AutofillEditAddressOverlay.loadAddress(address); |
178 OptionsPage.navigateToPage('autofillEditAddress'); | 179 PageManager.showPageByName('autofillEditAddress'); |
179 }, | 180 }, |
180 | 181 |
181 /** | 182 /** |
182 * Shows the 'Edit credit card' overlay, using the data in |credit_card| to | 183 * Shows the 'Edit credit card' overlay, using the data in |credit_card| to |
183 * fill the input fields. |address| is a list with one item, an associative | 184 * fill the input fields. |address| is a list with one item, an associative |
184 * array that contains the credit card data. | 185 * array that contains the credit card data. |
185 * @private | 186 * @private |
186 */ | 187 */ |
187 showEditCreditCardOverlay_: function(creditCard) { | 188 showEditCreditCardOverlay_: function(creditCard) { |
188 var title = loadTimeData.getString('editCreditCardTitle'); | 189 var title = loadTimeData.getString('editCreditCardTitle'); |
189 AutofillEditCreditCardOverlay.setTitle(title); | 190 AutofillEditCreditCardOverlay.setTitle(title); |
190 AutofillEditCreditCardOverlay.loadCreditCard(creditCard); | 191 AutofillEditCreditCardOverlay.loadCreditCard(creditCard); |
191 OptionsPage.navigateToPage('autofillEditCreditCard'); | 192 PageManager.showPageByName('autofillEditCreditCard'); |
192 }, | 193 }, |
193 }; | 194 }; |
194 | 195 |
195 AutofillOptions.setAddressList = function(entries) { | 196 AutofillOptions.setAddressList = function(entries) { |
196 AutofillOptions.getInstance().setAddressList_(entries); | 197 AutofillOptions.getInstance().setAddressList_(entries); |
197 }; | 198 }; |
198 | 199 |
199 AutofillOptions.setCreditCardList = function(entries) { | 200 AutofillOptions.setCreditCardList = function(entries) { |
200 AutofillOptions.getInstance().setCreditCardList_(entries); | 201 AutofillOptions.getInstance().setCreditCardList_(entries); |
201 }; | 202 }; |
(...skipping 18 matching lines...) Expand all Loading... |
220 AutofillOptions.getInstance().showEditCreditCardOverlay_(creditCard); | 221 AutofillOptions.getInstance().showEditCreditCardOverlay_(creditCard); |
221 }; | 222 }; |
222 | 223 |
223 // Export | 224 // Export |
224 return { | 225 return { |
225 AutofillOptions: AutofillOptions | 226 AutofillOptions: AutofillOptions |
226 }; | 227 }; |
227 | 228 |
228 }); | 229 }); |
229 | 230 |
OLD | NEW |