| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.managedUserOptions', function() { | 5 cr.define('options.supervisedUserOptions', function() { |
| 6 /** @const */ var List = cr.ui.List; | 6 /** @const */ var List = cr.ui.List; |
| 7 /** @const */ var ListItem = cr.ui.ListItem; | 7 /** @const */ var ListItem = cr.ui.ListItem; |
| 8 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 8 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * Create a new managed user list item. | 11 * Create a new supervised user list item. |
| 12 * @param {Object} entry The managed user this item represents. | 12 * @param {Object} entry The supervised user this item represents. |
| 13 * It has the following form: | 13 * It has the following form: |
| 14 * managedUser = { | 14 * supervisedUser = { |
| 15 * id: "Managed User ID", | 15 * id: "Supervised User ID", |
| 16 * name: "Managed User Name", | 16 * name: "Supervised User Name", |
| 17 * iconURL: "chrome://path/to/icon/image", | 17 * iconURL: "chrome://path/to/icon/image", |
| 18 * onCurrentDevice: true or false, | 18 * onCurrentDevice: true or false, |
| 19 * needAvatar: true or false | 19 * needAvatar: true or false |
| 20 * } | 20 * } |
| 21 * @constructor | 21 * @constructor |
| 22 * @extends {cr.ui.ListItem} | 22 * @extends {cr.ui.ListItem} |
| 23 */ | 23 */ |
| 24 function ManagedUserListItem(entry) { | 24 function SupervisedUserListItem(entry) { |
| 25 var el = cr.doc.createElement('div'); | 25 var el = cr.doc.createElement('div'); |
| 26 el.managedUser_ = entry; | 26 el.supervisedUser_ = entry; |
| 27 el.__proto__ = ManagedUserListItem.prototype; | 27 el.__proto__ = SupervisedUserListItem.prototype; |
| 28 el.decorate(); | 28 el.decorate(); |
| 29 return el; | 29 return el; |
| 30 } | 30 } |
| 31 | 31 |
| 32 ManagedUserListItem.prototype = { | 32 SupervisedUserListItem.prototype = { |
| 33 __proto__: ListItem.prototype, | 33 __proto__: ListItem.prototype, |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * @type {string} the ID of this managed user list item. | 36 * @type {string} the ID of this supervised user list item. |
| 37 */ | 37 */ |
| 38 get id() { | 38 get id() { |
| 39 return this.managedUser_.id; | 39 return this.supervisedUser_.id; |
| 40 }, | 40 }, |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * @type {string} the name of this managed user list item. | 43 * @type {string} the name of this supervised user list item. |
| 44 */ | 44 */ |
| 45 get name() { | 45 get name() { |
| 46 return this.managedUser_.name; | 46 return this.supervisedUser_.name; |
| 47 }, | 47 }, |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * @type {string} the path to the avatar icon of this managed | 50 * @type {string} the path to the avatar icon of this supervised |
| 51 * user list item. | 51 * user list item. |
| 52 */ | 52 */ |
| 53 get iconURL() { | 53 get iconURL() { |
| 54 return this.managedUser_.iconURL; | 54 return this.supervisedUser_.iconURL; |
| 55 }, | 55 }, |
| 56 | 56 |
| 57 /** @override */ | 57 /** @override */ |
| 58 decorate: function() { | 58 decorate: function() { |
| 59 ListItem.prototype.decorate.call(this); | 59 ListItem.prototype.decorate.call(this); |
| 60 var managedUser = this.managedUser_; | 60 var supervisedUser = this.supervisedUser_; |
| 61 | 61 |
| 62 // Add the avatar. | 62 // Add the avatar. |
| 63 var iconElement = this.ownerDocument.createElement('img'); | 63 var iconElement = this.ownerDocument.createElement('img'); |
| 64 iconElement.className = 'profile-img'; | 64 iconElement.className = 'profile-img'; |
| 65 iconElement.style.content = getProfileAvatarIcon(managedUser.iconURL); | 65 iconElement.style.content = getProfileAvatarIcon(supervisedUser.iconURL); |
| 66 this.appendChild(iconElement); | 66 this.appendChild(iconElement); |
| 67 | 67 |
| 68 // Add the profile name. | 68 // Add the profile name. |
| 69 var nameElement = this.ownerDocument.createElement('div'); | 69 var nameElement = this.ownerDocument.createElement('div'); |
| 70 nameElement.className = 'profile-name'; | 70 nameElement.className = 'profile-name'; |
| 71 nameElement.textContent = managedUser.name; | 71 nameElement.textContent = supervisedUser.name; |
| 72 this.appendChild(nameElement); | 72 this.appendChild(nameElement); |
| 73 | 73 |
| 74 if (managedUser.onCurrentDevice) { | 74 if (supervisedUser.onCurrentDevice) { |
| 75 iconElement.className += ' profile-img-disabled'; | 75 iconElement.className += ' profile-img-disabled'; |
| 76 nameElement.className += ' profile-name-disabled'; | 76 nameElement.className += ' profile-name-disabled'; |
| 77 | 77 |
| 78 // Add "(already on this device)" message. | 78 // Add "(already on this device)" message. |
| 79 var alreadyOnDeviceElement = this.ownerDocument.createElement('div'); | 79 var alreadyOnDeviceElement = this.ownerDocument.createElement('div'); |
| 80 alreadyOnDeviceElement.className = | 80 alreadyOnDeviceElement.className = |
| 81 'profile-name-disabled already-on-this-device'; | 81 'profile-name-disabled already-on-this-device'; |
| 82 alreadyOnDeviceElement.textContent = | 82 alreadyOnDeviceElement.textContent = |
| 83 loadTimeData.getString('managedUserAlreadyOnThisDevice'); | 83 loadTimeData.getString('supervisedUserAlreadyOnThisDevice'); |
| 84 this.appendChild(alreadyOnDeviceElement); | 84 this.appendChild(alreadyOnDeviceElement); |
| 85 } | 85 } |
| 86 }, | 86 }, |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 /** | 89 /** |
| 90 * Create a new managed users list. | 90 * Create a new supervised users list. |
| 91 * @constructor | 91 * @constructor |
| 92 * @extends {cr.ui.List} | 92 * @extends {cr.ui.List} |
| 93 */ | 93 */ |
| 94 var ManagedUserList = cr.ui.define('list'); | 94 var SupervisedUserList = cr.ui.define('list'); |
| 95 | 95 |
| 96 ManagedUserList.prototype = { | 96 SupervisedUserList.prototype = { |
| 97 __proto__: List.prototype, | 97 __proto__: List.prototype, |
| 98 | 98 |
| 99 /** @override */ | 99 /** @override */ |
| 100 createItem: function(entry) { | 100 createItem: function(entry) { |
| 101 return new ManagedUserListItem(entry); | 101 return new SupervisedUserListItem(entry); |
| 102 }, | 102 }, |
| 103 | 103 |
| 104 /** @override */ | 104 /** @override */ |
| 105 decorate: function() { | 105 decorate: function() { |
| 106 List.prototype.decorate.call(this); | 106 List.prototype.decorate.call(this); |
| 107 this.selectionModel = new ListSingleSelectionModel(); | 107 this.selectionModel = new ListSingleSelectionModel(); |
| 108 this.autoExpands = true; | 108 this.autoExpands = true; |
| 109 }, | 109 }, |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 return { | 112 return { |
| 113 ManagedUserListItem: ManagedUserListItem, | 113 SupervisedUserListItem: SupervisedUserListItem, |
| 114 ManagedUserList: ManagedUserList, | 114 SupervisedUserList: SupervisedUserList, |
| 115 }; | 115 }; |
| 116 }); | 116 }); |
| OLD | NEW |