OLD | NEW |
| (Empty) |
1 // Copyright 2014 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', function() { | |
6 /** @const */ var List = cr.ui.List; | |
7 /** @const */ var ListItem = cr.ui.ListItem; | |
8 | |
9 /** | |
10 * Creates a new list item for the origin's data. | |
11 * @param {!Object} origin Data used to create the origin list item. | |
12 * @constructor | |
13 * @extends {cr.ui.ListItem} | |
14 */ | |
15 function OriginListItem(origin) { | |
16 var el = cr.doc.createElement('div'); | |
17 el.origin_ = origin.origin; | |
18 el.usage_ = origin.usage; | |
19 el.usageString_ = origin.usageString; | |
20 el.readableName_ = origin.readableName; | |
21 el.__proto__ = OriginListItem.prototype; | |
22 el.decorate(); | |
23 return el; | |
24 } | |
25 | |
26 OriginListItem.prototype = { | |
27 __proto__: ListItem.prototype, | |
28 | |
29 /** @override */ | |
30 decorate: function() { | |
31 ListItem.prototype.decorate.call(this); | |
32 | |
33 this.className = 'deletable-item origin-list-item'; | |
34 this.contentElement_ = this.ownerDocument.createElement('div'); | |
35 this.appendChild(this.contentElement_); | |
36 | |
37 var titleEl = this.ownerDocument.createElement('div'); | |
38 titleEl.className = 'title favicon-cell weaktrl'; | |
39 titleEl.textContent = this.readableName_; | |
40 titleEl.originPattern = this.origin_; | |
41 titleEl.style.backgroundImage = getFaviconImageSet(this.origin_); | |
42 this.contentElement_.appendChild(titleEl); | |
43 | |
44 this.contentElement_.onclick = function() { | |
45 chrome.send('maybeShowEditPage', [titleEl.originPattern]); | |
46 }; | |
47 | |
48 if (this.usageString_) { | |
49 var usageEl = this.ownerDocument.createElement('span'); | |
50 usageEl.className = 'local-storage-usage'; | |
51 usageEl.textContent = this.usageString_; | |
52 this.appendChild(usageEl); | |
53 } | |
54 } | |
55 }; | |
56 | |
57 /** | |
58 * @constructor | |
59 * @extends {cr.ui.List} | |
60 */ | |
61 var OriginList = cr.ui.define('list'); | |
62 | |
63 OriginList.prototype = { | |
64 __proto__: List.prototype, | |
65 | |
66 /** | |
67 * @override | |
68 * @param {!Object} entry | |
69 */ | |
70 createItem: function(entry) { | |
71 return new OriginListItem(entry); | |
72 }, | |
73 }; | |
74 | |
75 return { | |
76 OriginListItem: OriginListItem, | |
77 OriginList: OriginList, | |
78 }; | |
79 }); | |
OLD | NEW |