| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.autofillOptions', function() { | 5 cr.define('options.autofillOptions', function() { |
| 6 const DeletableItem = options.DeletableItem; | 6 const DeletableItem = options.DeletableItem; |
| 7 const DeletableItemList = options.DeletableItemList; | 7 const DeletableItemList = options.DeletableItemList; |
| 8 const InlineEditableItem = options.InlineEditableItem; | 8 const InlineEditableItem = options.InlineEditableItem; |
| 9 const InlineEditableItemList = options.InlineEditableItemList; | 9 const InlineEditableItemList = options.InlineEditableItemList; |
| 10 | 10 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 */ | 311 */ |
| 312 var AutofillProfileList = cr.ui.define('list'); | 312 var AutofillProfileList = cr.ui.define('list'); |
| 313 | 313 |
| 314 AutofillProfileList.prototype = { | 314 AutofillProfileList.prototype = { |
| 315 __proto__: DeletableItemList.prototype, | 315 __proto__: DeletableItemList.prototype, |
| 316 | 316 |
| 317 decorate: function() { | 317 decorate: function() { |
| 318 DeletableItemList.prototype.decorate.call(this); | 318 DeletableItemList.prototype.decorate.call(this); |
| 319 | 319 |
| 320 this.addEventListener('blur', this.onBlur_); | 320 this.addEventListener('blur', this.onBlur_); |
| 321 this.addEventListener('dblclick', this.onDoubleClick_); | |
| 322 }, | 321 }, |
| 323 | 322 |
| 324 /** | 323 /** |
| 325 * When the list loses focus, unselect all items in the list. | 324 * When the list loses focus, unselect all items in the list. |
| 326 * @private | 325 * @private |
| 327 */ | 326 */ |
| 328 onBlur_: function() { | 327 onBlur_: function() { |
| 329 this.selectionModel.unselectAll(); | 328 this.selectionModel.unselectAll(); |
| 330 }, | 329 }, |
| 331 | |
| 332 /** | |
| 333 * When a list item is double clicked, open the corresponding profile for | |
| 334 * editing. | |
| 335 * @param {Event} event The double-click event. | |
| 336 * @private | |
| 337 */ | |
| 338 onDoubleClick_: function(event) { | |
| 339 if (this.disabled) | |
| 340 return; | |
| 341 | |
| 342 var target = this.getListItemAncestor(event.target); | |
| 343 if (target) | |
| 344 this.activateItemAtIndex_(this.getIndexOfListItem(target)); | |
| 345 }, | |
| 346 | |
| 347 /** | |
| 348 * Opens the item at |index| for editing. Subclasses should override. | |
| 349 * @param {Number} index The item index. | |
| 350 */ | |
| 351 activateItemAtIndex_: function(index) { | |
| 352 }, | |
| 353 }; | 330 }; |
| 354 | 331 |
| 355 /** | 332 /** |
| 356 * Create a new address list. | 333 * Create a new address list. |
| 357 * @constructor | 334 * @constructor |
| 358 * @extends {options.AutofillProfileList} | 335 * @extends {options.AutofillProfileList} |
| 359 */ | 336 */ |
| 360 var AutofillAddressList = cr.ui.define('list'); | 337 var AutofillAddressList = cr.ui.define('list'); |
| 361 | 338 |
| 362 AutofillAddressList.prototype = { | 339 AutofillAddressList.prototype = { |
| 363 __proto__: AutofillProfileList.prototype, | 340 __proto__: AutofillProfileList.prototype, |
| 364 | 341 |
| 365 decorate: function() { | 342 decorate: function() { |
| 366 AutofillProfileList.prototype.decorate.call(this); | 343 AutofillProfileList.prototype.decorate.call(this); |
| 367 }, | 344 }, |
| 368 | 345 |
| 369 /** @inheritDoc */ | 346 /** @inheritDoc */ |
| 370 activateItemAtIndex_: function(index) { | 347 activateItemAtIndex: function(index) { |
| 371 AutofillOptions.loadAddressEditor(this.dataModel.item(index)[0]); | 348 AutofillOptions.loadAddressEditor(this.dataModel.item(index)[0]); |
| 372 }, | 349 }, |
| 373 | 350 |
| 374 /** @inheritDoc */ | 351 /** @inheritDoc */ |
| 375 createItem: function(entry) { | 352 createItem: function(entry) { |
| 376 return new AddressListItem(entry); | 353 return new AddressListItem(entry); |
| 377 }, | 354 }, |
| 378 | 355 |
| 379 /** @inheritDoc */ | 356 /** @inheritDoc */ |
| 380 deleteItemAtIndex: function(index) { | 357 deleteItemAtIndex: function(index) { |
| 381 AutofillOptions.removeAddress(this.dataModel.item(index)[0]); | 358 AutofillOptions.removeAddress(this.dataModel.item(index)[0]); |
| 382 }, | 359 }, |
| 383 }; | 360 }; |
| 384 | 361 |
| 385 /** | 362 /** |
| 386 * Create a new credit card list. | 363 * Create a new credit card list. |
| 387 * @constructor | 364 * @constructor |
| 388 * @extends {options.DeletableItemList} | 365 * @extends {options.DeletableItemList} |
| 389 */ | 366 */ |
| 390 var AutofillCreditCardList = cr.ui.define('list'); | 367 var AutofillCreditCardList = cr.ui.define('list'); |
| 391 | 368 |
| 392 AutofillCreditCardList.prototype = { | 369 AutofillCreditCardList.prototype = { |
| 393 __proto__: AutofillProfileList.prototype, | 370 __proto__: AutofillProfileList.prototype, |
| 394 | 371 |
| 395 decorate: function() { | 372 decorate: function() { |
| 396 AutofillProfileList.prototype.decorate.call(this); | 373 AutofillProfileList.prototype.decorate.call(this); |
| 397 }, | 374 }, |
| 398 | 375 |
| 399 /** @inheritDoc */ | 376 /** @inheritDoc */ |
| 400 activateItemAtIndex_: function(index) { | 377 activateItemAtIndex: function(index) { |
| 401 AutofillOptions.loadCreditCardEditor(this.dataModel.item(index)[0]); | 378 AutofillOptions.loadCreditCardEditor(this.dataModel.item(index)[0]); |
| 402 }, | 379 }, |
| 403 | 380 |
| 404 /** @inheritDoc */ | 381 /** @inheritDoc */ |
| 405 createItem: function(entry) { | 382 createItem: function(entry) { |
| 406 return new CreditCardListItem(entry); | 383 return new CreditCardListItem(entry); |
| 407 }, | 384 }, |
| 408 | 385 |
| 409 /** @inheritDoc */ | 386 /** @inheritDoc */ |
| 410 deleteItemAtIndex: function(index) { | 387 deleteItemAtIndex: function(index) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 CreditCardListItem: CreditCardListItem, | 497 CreditCardListItem: CreditCardListItem, |
| 521 ValuesListItem: ValuesListItem, | 498 ValuesListItem: ValuesListItem, |
| 522 NameListItem: NameListItem, | 499 NameListItem: NameListItem, |
| 523 AutofillAddressList: AutofillAddressList, | 500 AutofillAddressList: AutofillAddressList, |
| 524 AutofillCreditCardList: AutofillCreditCardList, | 501 AutofillCreditCardList: AutofillCreditCardList, |
| 525 AutofillValuesList: AutofillValuesList, | 502 AutofillValuesList: AutofillValuesList, |
| 526 AutofillNameValuesList: AutofillNameValuesList, | 503 AutofillNameValuesList: AutofillNameValuesList, |
| 527 AutofillPhoneValuesList: AutofillPhoneValuesList, | 504 AutofillPhoneValuesList: AutofillPhoneValuesList, |
| 528 }; | 505 }; |
| 529 }); | 506 }); |
| OLD | NEW |