Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.browser_options', function() { | 5 cr.define('options.browser_options', function() { |
| 6 /** @const */ var DeletableItem = options.DeletableItem; | 6 /** @const */ var DeletableItem = options.DeletableItem; |
| 7 /** @const */ var DeletableItemList = options.DeletableItemList; | 7 /** @const */ var DeletableItemList = options.DeletableItemList; |
| 8 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 8 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * Creates a new profile list item. | 11 * Creates a new profile list item. |
| 12 * @param {Object} profileInfo The profile this item respresents. | 12 * @param {Object} profileInfo The profile this item represents. |
| 13 * @constructor | 13 * @constructor |
| 14 * @extends {cr.ui.DeletableItem} | 14 * @extends {cr.ui.DeletableItem} |
| 15 */ | 15 */ |
| 16 function ProfileListItem(profileInfo) { | 16 function ProfileListItem(profileInfo) { |
| 17 var el = cr.doc.createElement('div'); | 17 var el = cr.doc.createElement('div'); |
| 18 el.profileInfo_ = profileInfo; | 18 el.profileInfo_ = profileInfo; |
| 19 ProfileListItem.decorate(el); | 19 ProfileListItem.decorate(el); |
| 20 return el; | 20 return el; |
| 21 } | 21 } |
| 22 | 22 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 45 get isManaged() { | 45 get isManaged() { |
| 46 return this.profileInfo_.isManaged; | 46 return this.profileInfo_.isManaged; |
| 47 }, | 47 }, |
| 48 | 48 |
| 49 /** @override */ | 49 /** @override */ |
| 50 decorate: function() { | 50 decorate: function() { |
| 51 DeletableItem.prototype.decorate.call(this); | 51 DeletableItem.prototype.decorate.call(this); |
| 52 | 52 |
| 53 var profileInfo = this.profileInfo_; | 53 var profileInfo = this.profileInfo_; |
| 54 | 54 |
| 55 var containerEl = this.ownerDocument.createElement('div'); | |
| 56 containerEl.className = 'profile-container'; | |
|
Patrick Dubroy
2014/04/03 10:48:39
Could you just give this class to `this.contentEle
Marc Treib
2014/04/03 11:41:56
No: this.contentElement will not shrink, and so th
Patrick Dubroy
2014/04/03 11:48:38
Ok.
| |
| 57 | |
| 55 var iconEl = this.ownerDocument.createElement('img'); | 58 var iconEl = this.ownerDocument.createElement('img'); |
| 56 iconEl.className = 'profile-img'; | 59 iconEl.className = 'profile-img'; |
| 57 iconEl.style.content = getProfileAvatarIcon(profileInfo.iconURL); | 60 iconEl.style.content = getProfileAvatarIcon(profileInfo.iconURL); |
| 58 this.contentElement.appendChild(iconEl); | 61 containerEl.appendChild(iconEl); |
| 59 | 62 |
| 60 var nameEl = this.ownerDocument.createElement('div'); | 63 var nameEl = this.ownerDocument.createElement('div'); |
| 61 nameEl.className = 'profile-name'; | 64 nameEl.className = 'profile-name'; |
| 62 if (profileInfo.isCurrentProfile) | 65 if (profileInfo.isCurrentProfile) |
| 63 nameEl.classList.add('profile-item-current'); | 66 nameEl.classList.add('profile-item-current'); |
| 64 this.contentElement.appendChild(nameEl); | 67 containerEl.appendChild(nameEl); |
| 65 | 68 |
| 66 var displayName = profileInfo.name; | 69 var displayName = profileInfo.name; |
| 67 if (profileInfo.isCurrentProfile) { | 70 if (profileInfo.isCurrentProfile) { |
| 68 displayName = loadTimeData.getStringF('profilesListItemCurrent', | 71 displayName = loadTimeData.getStringF('profilesListItemCurrent', |
| 69 profileInfo.name); | 72 profileInfo.name); |
| 70 } | 73 } |
| 71 nameEl.textContent = displayName; | 74 nameEl.textContent = displayName; |
| 72 | 75 |
| 76 if (profileInfo.isManaged) { | |
| 77 var supervisedEl = this.ownerDocument.createElement('div'); | |
| 78 supervisedEl.className = 'profile-supervised'; | |
| 79 supervisedEl.textContent = | |
| 80 '(' + loadTimeData.getStringF('managedUserLabel') + ')'; | |
| 81 containerEl.appendChild(supervisedEl); | |
| 82 } | |
| 83 | |
| 84 this.contentElement.appendChild(containerEl); | |
| 85 | |
| 73 // Ensure that the button cannot be tabbed to for accessibility reasons. | 86 // Ensure that the button cannot be tabbed to for accessibility reasons. |
| 74 this.closeButtonElement.tabIndex = -1; | 87 this.closeButtonElement.tabIndex = -1; |
| 75 }, | 88 }, |
| 76 }; | 89 }; |
| 77 | 90 |
| 78 var ProfileList = cr.ui.define('list'); | 91 var ProfileList = cr.ui.define('list'); |
| 79 | 92 |
| 80 ProfileList.prototype = { | 93 ProfileList.prototype = { |
| 81 __proto__: DeletableItemList.prototype, | 94 __proto__: DeletableItemList.prototype, |
| 82 | 95 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 109 }, | 122 }, |
| 110 | 123 |
| 111 /** | 124 /** |
| 112 * Sets whether items in this list are deletable. | 125 * Sets whether items in this list are deletable. |
| 113 */ | 126 */ |
| 114 set canDeleteItems(value) { | 127 set canDeleteItems(value) { |
| 115 this.canDeleteItems_ = value; | 128 this.canDeleteItems_ = value; |
| 116 }, | 129 }, |
| 117 | 130 |
| 118 /** | 131 /** |
| 119 * If false, items in this list will not be deltable. | 132 * If false, items in this list will not be deletable. |
| 120 * @private | 133 * @private |
| 121 */ | 134 */ |
| 122 canDeleteItems_: true, | 135 canDeleteItems_: true, |
| 123 }; | 136 }; |
| 124 | 137 |
| 125 return { | 138 return { |
| 126 ProfileList: ProfileList | 139 ProfileList: ProfileList |
| 127 }; | 140 }; |
| 128 }); | 141 }); |
| OLD | NEW |