blob: 10e0b64729358601857af47053c13eeae6e79788 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('options.autoFillOptions', function() {
const DeletableItemList = options.DeletableItemList;
const DeletableItem = options.DeletableItem;
const List = cr.ui.List;
/**
* Creates a new AutoFill list item.
* @param {Array} entry An array of the form [guid, label].
* @constructor
* @extends {options.DeletableItem}
*/
function AutoFillListItem(entry) {
var el = cr.doc.createElement('div');
el.guid = entry[0];
el.label = entry[1];
el.__proto__ = AutoFillListItem.prototype;
el.decorate();
return el;
}
AutoFillListItem.prototype = {
__proto__: DeletableItem.prototype,
/** @inheritDoc */
decorate: function() {
DeletableItem.prototype.decorate.call(this);
// The stored label.
var label = this.ownerDocument.createElement('div');
label.className = 'autofill-list-item';
label.textContent = this.label;
this.contentElement.appendChild(label);
},
};
/**
* Create a new AutoFill list.
* @constructor
* @extends {options.DeletableItemList}
*/
var AutoFillList = cr.ui.define('list');
AutoFillList.prototype = {
__proto__: DeletableItemList.prototype,
/** @inheritDoc */
createItem: function(entry) {
return new AutoFillListItem(entry);
},
/** @inheritDoc */
activateItemAtIndex: function(index) {
AutoFillOptions.loadProfileEditor(this.dataModel.item(index)[0]);
},
/** @inheritDoc */
deleteItemAtIndex: function(index) {
AutoFillOptions.removeAutoFillProfile(this.dataModel.item(index)[0]);
},
};
return {
AutoFillListItem: AutoFillListItem,
AutoFillList: AutoFillList,
};
});
|