Chromium Code Reviews| 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 function OriginListItem(origin) { | 9 function OriginListItem(origin) { |
| 10 var el = cr.doc.createElement('div'); | 10 var el = cr.doc.createElement('div'); |
| 11 el.origin_ = origin; | 11 |
| 12 if (origin.origin) { | |
| 13 el.origin_ = origin.origin; | |
| 14 el.usage_ = origin.usage; | |
| 15 el.usage_string_ = origin.usage_string; | |
| 16 } | |
| 17 else { | |
|
Bernhard Bauer
2014/07/22 08:51:47
Else goes on the same line as the closing brace.
Daniel Nishi
2014/07/22 22:30:56
Done.
| |
| 18 el.origin_ = origin; | |
| 19 } | |
| 20 | |
| 12 el.__proto__ = OriginListItem.prototype; | 21 el.__proto__ = OriginListItem.prototype; |
| 13 el.decorate(); | 22 el.decorate(); |
| 14 return el; | 23 return el; |
| 15 } | 24 } |
| 16 | 25 |
| 17 OriginListItem.prototype = { | 26 OriginListItem.prototype = { |
| 18 __proto__: ListItem.prototype, | 27 __proto__: ListItem.prototype, |
| 19 | 28 |
| 20 /** @override */ | 29 /** @override */ |
| 21 decorate: function() { | 30 decorate: function() { |
| 22 ListItem.prototype.decorate.call(this); | 31 ListItem.prototype.decorate.call(this); |
| 23 | 32 |
| 24 this.classList.add('deletable-item'); | 33 this.className = 'deletable-item origin-list-item'; |
| 25 | |
| 26 this.contentElement_ = this.ownerDocument.createElement('div'); | 34 this.contentElement_ = this.ownerDocument.createElement('div'); |
| 27 this.appendChild(this.contentElement_); | 35 this.appendChild(this.contentElement_); |
| 28 | 36 |
| 29 var titleEl = this.ownerDocument.createElement('div'); | 37 var titleEl = this.ownerDocument.createElement('div'); |
| 30 titleEl.className = 'title favicon-cell weaktrl'; | 38 titleEl.className = 'title favicon-cell weaktrl'; |
| 31 titleEl.textContent = this.origin_; | 39 titleEl.textContent = this.origin_; |
| 32 titleEl.style.backgroundImage = getFaviconImageSet(this.origin_); | 40 titleEl.style.backgroundImage = getFaviconImageSet(this.origin_); |
| 33 this.contentElement_.appendChild(titleEl); | 41 this.contentElement_.appendChild(titleEl); |
| 42 | |
| 43 if (this.usage_string_) { | |
| 44 var usageEl = this.ownerDocument.createElement('span'); | |
| 45 usageEl.className = 'usage'; | |
| 46 usageEl.textContent = this.usage_string_; | |
| 47 this.appendChild(usageEl); | |
| 48 } | |
| 34 } | 49 } |
| 35 }; | 50 }; |
| 36 | 51 |
| 37 var OriginList = cr.ui.define('list'); | 52 var OriginList = cr.ui.define('list'); |
| 38 | 53 |
| 39 OriginList.prototype = { | 54 OriginList.prototype = { |
| 40 __proto__: List.prototype, | 55 __proto__: List.prototype, |
| 41 | 56 |
| 42 /** @override */ | 57 /** @override */ |
| 43 createItem: function(entry) { | 58 createItem: function(entry) { |
| 44 return new OriginListItem(entry); | 59 return new OriginListItem(entry); |
| 45 }, | 60 }, |
| 46 }; | 61 }; |
| 47 | 62 |
| 48 return { | 63 return { |
| 49 OriginListItem: OriginListItem, | 64 OriginListItem: OriginListItem, |
| 50 OriginList: OriginList, | 65 OriginList: OriginList, |
| 51 }; | 66 }; |
| 52 }); | 67 }); |
| OLD | NEW |