| 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 /** | 5 /** |
| 6 * @typedef {{ | 6 * @typedef {{ |
| 7 * guid: string, | 7 * guid: string, |
| 8 * label: string, | 8 * label: string, |
| 9 * sublabel: string, | 9 * sublabel: string, |
| 10 * isLocal: boolean, | 10 * isLocal: boolean, |
| 11 * isCached: boolean | 11 * isCached: boolean |
| 12 * }} | 12 * }} |
| 13 * @see chrome/browser/ui/webui/options/autofill_options_handler.cc | 13 * @see chrome/browser/ui/webui/options/autofill_options_handler.cc |
| 14 */ | 14 */ |
| 15 var AutofillEntityMetadata; | 15 var AutofillEntityMetadata; |
| 16 | 16 |
| 17 cr.define('options.autofillOptions', function() { | 17 cr.define('options.autofillOptions', function() { |
| 18 /** @const */ var DeletableItem = options.DeletableItem; | 18 /** @const */ var DeletableItem = options.DeletableItem; |
| 19 /** @const */ var DeletableItemList = options.DeletableItemList; | 19 /** @const */ var DeletableItemList = options.DeletableItemList; |
| 20 /** @const */ var InlineEditableItem = options.InlineEditableItem; | 20 /** @const */ var InlineEditableItem = options.InlineEditableItem; |
| 21 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; | 21 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * @return {!HTMLButtonElement} | 24 * @return {!HTMLButtonElement} |
| 25 */ | 25 */ |
| 26 function AutofillEditProfileButton(edit) { | 26 function AutofillEditProfileButton(edit) { |
| 27 var editButtonEl = /** @type {HTMLButtonElement} */( | 27 var editButtonEl = |
| 28 document.createElement('button')); | 28 /** @type {HTMLButtonElement} */ (document.createElement('button')); |
| 29 editButtonEl.className = | 29 editButtonEl.className = |
| 30 'list-inline-button hide-until-hover custom-appearance'; | 30 'list-inline-button hide-until-hover custom-appearance'; |
| 31 editButtonEl.textContent = | 31 editButtonEl.textContent = |
| 32 loadTimeData.getString('autofillEditProfileButton'); | 32 loadTimeData.getString('autofillEditProfileButton'); |
| 33 editButtonEl.onclick = edit; | 33 editButtonEl.onclick = edit; |
| 34 | 34 |
| 35 editButtonEl.onmousedown = function(e) { | 35 editButtonEl.onmousedown = function(e) { |
| 36 // Don't select the row when clicking the button. | 36 // Don't select the row when clicking the button. |
| 37 e.stopPropagation(); | 37 e.stopPropagation(); |
| 38 // Don't focus on the button when clicking it. | 38 // Don't focus on the button when clicking it. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 148 } |
| 149 | 149 |
| 150 var guid = this.metadata_.guid; | 150 var guid = this.metadata_.guid; |
| 151 if (this.metadata_.isCached) { | 151 if (this.metadata_.isCached) { |
| 152 var localCopyText = this.ownerDocument.createElement('span'); | 152 var localCopyText = this.ownerDocument.createElement('span'); |
| 153 localCopyText.className = 'hide-until-hover deemphasized'; | 153 localCopyText.className = 'hide-until-hover deemphasized'; |
| 154 localCopyText.textContent = | 154 localCopyText.textContent = |
| 155 loadTimeData.getString('autofillDescribeLocalCopy'); | 155 loadTimeData.getString('autofillDescribeLocalCopy'); |
| 156 this.contentElement.appendChild(localCopyText); | 156 this.contentElement.appendChild(localCopyText); |
| 157 | 157 |
| 158 var clearLocalCopyButton = AutofillEditProfileButton( | 158 var clearLocalCopyButton = AutofillEditProfileButton(function() { |
| 159 function() { chrome.send('clearLocalCardCopy', [guid]); }); | 159 chrome.send('clearLocalCardCopy', [guid]); |
| 160 }); |
| 160 clearLocalCopyButton.textContent = | 161 clearLocalCopyButton.textContent = |
| 161 loadTimeData.getString('autofillClearLocalCopyButton'); | 162 loadTimeData.getString('autofillClearLocalCopyButton'); |
| 162 this.contentElement.appendChild(clearLocalCopyButton); | 163 this.contentElement.appendChild(clearLocalCopyButton); |
| 163 } | 164 } |
| 164 | 165 |
| 165 // The 'Edit' button. | 166 // The 'Edit' button. |
| 166 var metadata = this.metadata_; | 167 var metadata = this.metadata_; |
| 167 var editButtonEl = AutofillEditProfileButton( | 168 var editButtonEl = AutofillEditProfileButton( |
| 168 CreditCardListItem.prototype.loadCreditCardEditor.bind(this)); | 169 CreditCardListItem.prototype.loadCreditCardEditor.bind(this)); |
| 169 this.contentElement.appendChild(editButtonEl); | 170 this.contentElement.appendChild(editButtonEl); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 /** | 230 /** |
| 230 * @override | 231 * @override |
| 231 * @param {AutofillEntityMetadata} metadata | 232 * @param {AutofillEntityMetadata} metadata |
| 232 */ | 233 */ |
| 233 createItem: function(metadata) { | 234 createItem: function(metadata) { |
| 234 return new AddressListItem(metadata); | 235 return new AddressListItem(metadata); |
| 235 }, | 236 }, |
| 236 | 237 |
| 237 /** @override */ | 238 /** @override */ |
| 238 deleteItemAtIndex: function(index) { | 239 deleteItemAtIndex: function(index) { |
| 239 AutofillOptions.removeData(this.dataModel.item(index).guid, | 240 AutofillOptions.removeData( |
| 240 'Options_AutofillAddressDeleted'); | 241 this.dataModel.item(index).guid, 'Options_AutofillAddressDeleted'); |
| 241 }, | 242 }, |
| 242 }; | 243 }; |
| 243 | 244 |
| 244 /** | 245 /** |
| 245 * Create a new credit card list. | 246 * Create a new credit card list. |
| 246 * @constructor | 247 * @constructor |
| 247 * @extends {options.DeletableItemList} | 248 * @extends {options.DeletableItemList} |
| 248 */ | 249 */ |
| 249 var AutofillCreditCardList = cr.ui.define('list'); | 250 var AutofillCreditCardList = cr.ui.define('list'); |
| 250 | 251 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 263 /** | 264 /** |
| 264 * @override | 265 * @override |
| 265 * @param {AutofillEntityMetadata} metadata | 266 * @param {AutofillEntityMetadata} metadata |
| 266 */ | 267 */ |
| 267 createItem: function(metadata) { | 268 createItem: function(metadata) { |
| 268 return new CreditCardListItem(metadata); | 269 return new CreditCardListItem(metadata); |
| 269 }, | 270 }, |
| 270 | 271 |
| 271 /** @override */ | 272 /** @override */ |
| 272 deleteItemAtIndex: function(index) { | 273 deleteItemAtIndex: function(index) { |
| 273 AutofillOptions.removeData(this.dataModel.item(index).guid, | 274 AutofillOptions.removeData( |
| 274 'Options_AutofillCreditCardDeleted'); | 275 this.dataModel.item(index).guid, 'Options_AutofillCreditCardDeleted'); |
| 275 }, | 276 }, |
| 276 }; | 277 }; |
| 277 | 278 |
| 278 return { | 279 return { |
| 279 AutofillProfileList: AutofillProfileList, | 280 AutofillProfileList: AutofillProfileList, |
| 280 AddressListItem: AddressListItem, | 281 AddressListItem: AddressListItem, |
| 281 CreditCardListItem: CreditCardListItem, | 282 CreditCardListItem: CreditCardListItem, |
| 282 AutofillAddressList: AutofillAddressList, | 283 AutofillAddressList: AutofillAddressList, |
| 283 AutofillCreditCardList: AutofillCreditCardList, | 284 AutofillCreditCardList: AutofillCreditCardList, |
| 284 }; | 285 }; |
| 285 }); | 286 }); |
| OLD | NEW |