Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 cr.define('options.autoFillOptions', function() { | |
| 6 const DeletableItemList = options.DeletableItemList; | |
| 7 const DeletableItem = options.DeletableItem; | |
| 8 const List = cr.ui.List; | |
| 9 | |
| 10 /** | |
| 11 * Creates a new AutoFill list item. | |
| 12 * @param {Array} entry An array of the form [guid, label]. | |
| 13 * @constructor | |
| 14 * @extends {options.DeletableItem} | |
| 15 */ | |
| 16 function AutoFillListItem(entry) { | |
| 17 var el = cr.doc.createElement('div'); | |
| 18 el.guid = entry[0]; | |
| 19 el.label = entry[1]; | |
| 20 el.__proto__ = AutoFillListItem.prototype; | |
| 21 el.decorate(); | |
| 22 | |
| 23 return el; | |
| 24 } | |
| 25 | |
| 26 AutoFillListItem.prototype = { | |
| 27 __proto__: DeletableItem.prototype, | |
| 28 | |
| 29 /** @inheritDoc */ | |
| 30 decorate: function() { | |
| 31 DeletableItem.prototype.decorate.call(this); | |
| 32 | |
| 33 // The stored label. | |
| 34 var label = this.ownerDocument.createElement('div'); | |
| 35 label.className = 'autofill-list-item'; | |
| 36 label.textContent = this.label; | |
| 37 this.contentElement.appendChild(label); | |
| 38 }, | |
| 39 | |
| 40 /** | |
| 41 * Get and set the GUID for the entry. | |
| 42 * @type {string} | |
| 43 */ | |
| 44 get guid() { | |
|
arv (Not doing code reviews)
2010/12/22 23:00:35
No need for getter and setters for these since the
James Hawkins
2010/12/22 23:13:08
Done.
| |
| 45 return this.guid; | |
|
arv (Not doing code reviews)
2010/12/22 23:00:35
This will not work. It will cause infinite recursi
James Hawkins
2010/12/22 23:13:08
Done.
| |
| 46 }, | |
| 47 set guid(guid) { | |
| 48 this.guid = guid; | |
| 49 }, | |
| 50 | |
| 51 /** | |
| 52 * Get and set the label for the entry. | |
| 53 * @type {string} | |
| 54 */ | |
| 55 get label() { | |
| 56 return this.label; | |
| 57 }, | |
| 58 set label(label) { | |
| 59 this.label = label; | |
| 60 }, | |
| 61 }; | |
| 62 | |
| 63 /** | |
| 64 * Create a new AutoFill list. | |
| 65 * @constructor | |
| 66 * @extends {options.DeletableItemList} | |
| 67 */ | |
| 68 var AutoFillList = cr.ui.define('list'); | |
| 69 | |
| 70 AutoFillList.prototype = { | |
| 71 __proto__: DeletableItemList.prototype, | |
| 72 | |
| 73 /** @inheritDoc */ | |
| 74 createItem: function(entry) { | |
| 75 return new AutoFillListItem(entry); | |
| 76 }, | |
| 77 | |
| 78 /** @inheritDoc */ | |
| 79 activateItemAtIndex: function(index) { | |
| 80 AutoFillOptions.loadProfileEditor(this.dataModel.item(index)[0]); | |
| 81 }, | |
| 82 | |
| 83 /** @inheritDoc */ | |
| 84 deleteItemAtIndex: function(index) { | |
| 85 AutoFillOptions.removeAutoFillProfile(this.dataModel.item(index)[0]); | |
| 86 }, | |
| 87 }; | |
| 88 | |
| 89 return { | |
| 90 AutoFillListItem: AutoFillListItem, | |
| 91 AutoFillList: AutoFillList, | |
| 92 }; | |
| 93 }); | |
| OLD | NEW |