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 ArrayDataModel = cr.ui.ArrayDataModel; | |
7 const DeletableItemList = options.DeletableItemList; | |
8 const DeletableItem = options.DeletableItem; | |
9 const List = cr.ui.List; | |
10 | |
11 /** | |
12 * Creates a new AutoFill list item. | |
13 * @param {Array} entry An array of the form [guid, label]. | |
14 * @constructor | |
15 * @extends {cr.ui.ListItem} | |
16 */ | |
17 function AutoFillListItem(entry) { | |
18 var el = cr.doc.createElement('div'); | |
19 el.dataItem = entry; | |
arv (Not doing code reviews)
2010/12/22 18:14:07
How about storing guid and label simple value prop
James Hawkins
2010/12/22 21:22:31
Done.
| |
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() { | |
45 return this.dataItem[0]; | |
46 }, | |
47 set guid(guid) { | |
48 this.dataItem[0] = guid; | |
49 }, | |
50 | |
51 /** | |
52 * Get and set the label for the entry. | |
53 * @type {string} | |
54 */ | |
55 get label() { | |
56 return this.dataItem[1]; | |
57 }, | |
58 set label(label) { | |
59 this.dataItem[1] = label; | |
60 }, | |
61 }; | |
62 | |
63 /** | |
64 * Create a new AutoFill list. | |
65 * @constructor | |
66 * @extends {cr.ui.List} | |
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 var item = this.getListItemByIndex(index); | |
arv (Not doing code reviews)
2010/12/22 18:14:07
Shouldn't this be going through the dataModel?
James Hawkins
2010/12/22 21:22:31
Done.
| |
81 AutoFillOptions.loadProfileEditor(item.guid); | |
82 }, | |
83 | |
84 /** @inheritDoc */ | |
85 deleteItemAtIndex: function(index) { | |
86 var item = this.getListItemByIndex(index); | |
arv (Not doing code reviews)
2010/12/22 18:14:07
same here
James Hawkins
2010/12/22 21:22:31
Done.
| |
87 AutoFillOptions.removeAutoFillProfile(item.guid); | |
88 }, | |
89 | |
90 /** | |
91 * The length of the list. | |
92 */ | |
93 get length() { | |
arv (Not doing code reviews)
2010/12/22 18:14:07
What is this used for?
James Hawkins
2010/12/22 21:22:31
Copy/pasted from another implementation. Removed.
| |
94 return this.dataModel.length; | |
95 }, | |
96 }; | |
97 | |
98 return { | |
99 AutoFillListItem: AutoFillListItem, | |
100 AutoFillList: AutoFillList, | |
101 }; | |
102 }); | |
OLD | NEW |