| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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', function() { | 5 cr.define('options', function() { |
| 6 /** @const */ List = cr.ui.List; | 6 /** @const */ List = cr.ui.List; |
| 7 /** @const */ ListItem = cr.ui.ListItem; | 7 /** @const */ ListItem = cr.ui.ListItem; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Creates a new list item for the origin's data. | 10 * Creates a new list item for the origin's data. |
| 11 * @param {!Object} origin Data used to create the origin list item. | 11 * @param {!Object} origin Data used to create the origin list item. |
| 12 */ | 12 */ |
| 13 function OriginListItem(origin) { | 13 function OriginListItem(origin) { |
| 14 var el = cr.doc.createElement('div'); | 14 var el = cr.doc.createElement('div'); |
| 15 el.origin_ = origin.origin; | 15 el.origin_ = origin.origin; |
| 16 el.usage_ = origin.usage; | 16 el.usage_ = origin.usage; |
| 17 el.usageString_ = origin.usageString; | 17 el.usageString_ = origin.usageString; |
| 18 el.readableName_ = origin.readableName; |
| 18 el.__proto__ = OriginListItem.prototype; | 19 el.__proto__ = OriginListItem.prototype; |
| 19 el.decorate(); | 20 el.decorate(); |
| 20 return el; | 21 return el; |
| 21 } | 22 } |
| 22 | 23 |
| 23 OriginListItem.prototype = { | 24 OriginListItem.prototype = { |
| 24 __proto__: ListItem.prototype, | 25 __proto__: ListItem.prototype, |
| 25 | 26 |
| 26 /** @override */ | 27 /** @override */ |
| 27 decorate: function() { | 28 decorate: function() { |
| 28 ListItem.prototype.decorate.call(this); | 29 ListItem.prototype.decorate.call(this); |
| 29 | 30 |
| 30 this.className = 'deletable-item origin-list-item'; | 31 this.className = 'deletable-item origin-list-item'; |
| 31 this.contentElement_ = this.ownerDocument.createElement('div'); | 32 this.contentElement_ = this.ownerDocument.createElement('div'); |
| 32 this.appendChild(this.contentElement_); | 33 this.appendChild(this.contentElement_); |
| 33 | 34 |
| 34 var titleEl = this.ownerDocument.createElement('div'); | 35 var titleEl = this.ownerDocument.createElement('div'); |
| 35 titleEl.className = 'title favicon-cell weaktrl'; | 36 titleEl.className = 'title favicon-cell weaktrl'; |
| 36 titleEl.textContent = this.origin_; | 37 titleEl.textContent = this.readableName_; |
| 37 titleEl.originPattern = this.origin_; | 38 titleEl.originPattern = this.origin_; |
| 38 titleEl.style.backgroundImage = getFaviconImageSet(this.origin_); | 39 titleEl.style.backgroundImage = getFaviconImageSet(this.origin_); |
| 39 this.contentElement_.appendChild(titleEl); | 40 this.contentElement_.appendChild(titleEl); |
| 40 | 41 |
| 41 this.contentElement_.onclick = function() { | 42 this.contentElement_.onclick = function() { |
| 42 chrome.send('maybeShowEditPage', [titleEl.originPattern]); | 43 chrome.send('maybeShowEditPage', [titleEl.originPattern]); |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 if (this.usageString_) { | 46 if (this.usageString_) { |
| 46 var usageEl = this.ownerDocument.createElement('span'); | 47 var usageEl = this.ownerDocument.createElement('span'); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 60 createItem: function(entry) { | 61 createItem: function(entry) { |
| 61 return new OriginListItem(entry); | 62 return new OriginListItem(entry); |
| 62 }, | 63 }, |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 return { | 66 return { |
| 66 OriginListItem: OriginListItem, | 67 OriginListItem: OriginListItem, |
| 67 OriginList: OriginList, | 68 OriginList: OriginList, |
| 68 }; | 69 }; |
| 69 }); | 70 }); |
| OLD | NEW |