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 var OptionsPage = options.OptionsPage; | 6 var Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; |
7 var ArrayDataModel = cr.ui.ArrayDataModel; | 8 var ArrayDataModel = cr.ui.ArrayDataModel; |
8 | 9 |
9 /** | 10 /** |
10 * SupervisedUserImportOverlay class. | 11 * SupervisedUserImportOverlay class. |
11 * Encapsulated handling of the 'Import existing supervised user' overlay | 12 * Encapsulated handling of the 'Import existing supervised user' overlay |
12 * page. | 13 * page. |
13 * @constructor | 14 * @constructor |
14 * @class | 15 * @class |
15 */ | 16 */ |
16 function SupervisedUserImportOverlay() { | 17 function SupervisedUserImportOverlay() { |
17 var title = loadTimeData.getString('supervisedUserImportTitle'); | 18 var title = loadTimeData.getString('supervisedUserImportTitle'); |
18 OptionsPage.call(this, 'supervisedUserImport', | 19 Page.call(this, 'supervisedUserImport', title, 'supervised-user-import'); |
19 title, 'supervised-user-import'); | |
20 }; | 20 }; |
21 | 21 |
22 cr.addSingletonGetter(SupervisedUserImportOverlay); | 22 cr.addSingletonGetter(SupervisedUserImportOverlay); |
23 | 23 |
24 SupervisedUserImportOverlay.prototype = { | 24 SupervisedUserImportOverlay.prototype = { |
25 // Inherit from OptionsPage. | 25 // Inherit from Page. |
26 __proto__: OptionsPage.prototype, | 26 __proto__: Page.prototype, |
27 | 27 |
28 /** @override */ | 28 /** @override */ |
29 canShowPage: function() { | 29 canShowPage: function() { |
30 return !BrowserOptions.getCurrentProfile().isSupervised; | 30 return !BrowserOptions.getCurrentProfile().isSupervised; |
31 }, | 31 }, |
32 | 32 |
33 /** @override */ | 33 /** @override */ |
34 initializePage: function() { | 34 initializePage: function() { |
35 // Call base class implementation to start preference initialization. | 35 Page.prototype.initializePage.call(this); |
36 OptionsPage.prototype.initializePage.call(this); | |
37 | 36 |
38 var supervisedUserList = $('supervised-user-list'); | 37 var supervisedUserList = $('supervised-user-list'); |
39 options.supervisedUserOptions.SupervisedUserList.decorate( | 38 options.supervisedUserOptions.SupervisedUserList.decorate( |
40 supervisedUserList); | 39 supervisedUserList); |
41 | 40 |
42 var avatarGrid = $('select-avatar-grid'); | 41 var avatarGrid = $('select-avatar-grid'); |
43 options.ProfilesIconGrid.decorate(avatarGrid); | 42 options.ProfilesIconGrid.decorate(avatarGrid); |
44 var avatarIcons = loadTimeData.getValue('avatarIcons'); | 43 var avatarIcons = loadTimeData.getValue('avatarIcons'); |
45 avatarGrid.dataModel = new ArrayDataModel(avatarIcons); | 44 avatarGrid.dataModel = new ArrayDataModel(avatarIcons); |
46 | 45 |
47 supervisedUserList.addEventListener('change', function(event) { | 46 supervisedUserList.addEventListener('change', function(event) { |
48 var supervisedUser = supervisedUserList.selectedItem; | 47 var supervisedUser = supervisedUserList.selectedItem; |
49 if (!supervisedUser) | 48 if (!supervisedUser) |
50 return; | 49 return; |
51 | 50 |
52 $('supervised-user-import-ok').disabled = | 51 $('supervised-user-import-ok').disabled = |
53 supervisedUserList.selectedItem.onCurrentDevice; | 52 supervisedUserList.selectedItem.onCurrentDevice; |
54 }); | 53 }); |
55 | 54 |
56 var self = this; | 55 var self = this; |
57 $('supervised-user-import-cancel').onclick = function(event) { | 56 $('supervised-user-import-cancel').onclick = function(event) { |
58 if (self.inProgress_) { | 57 if (self.inProgress_) { |
59 self.updateImportInProgress_(false); | 58 self.updateImportInProgress_(false); |
60 | 59 |
61 // 'cancelCreateProfile' is handled by CreateProfileHandler. | 60 // 'cancelCreateProfile' is handled by CreateProfileHandler. |
62 chrome.send('cancelCreateProfile'); | 61 chrome.send('cancelCreateProfile'); |
63 } | 62 } |
64 OptionsPage.closeOverlay(); | 63 PageManager.closeOverlay(); |
65 }; | 64 }; |
66 | 65 |
67 $('supervised-user-import-ok').onclick = | 66 $('supervised-user-import-ok').onclick = |
68 this.showAvatarGridOrSubmit_.bind(this); | 67 this.showAvatarGridOrSubmit_.bind(this); |
69 $('supervised-user-select-avatar-ok').onclick = | 68 $('supervised-user-select-avatar-ok').onclick = |
70 this.showAvatarGridOrSubmit_.bind(this); | 69 this.showAvatarGridOrSubmit_.bind(this); |
71 }, | 70 }, |
72 | 71 |
73 /** | 72 /** |
74 * @override | 73 * @override |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 224 |
226 /** | 225 /** |
227 * Closes the overlay if importing the supervised user was successful. Also | 226 * Closes the overlay if importing the supervised user was successful. Also |
228 * reset the cached list of supervised users in order to get an updated list | 227 * reset the cached list of supervised users in order to get an updated list |
229 * when the overlay is reopened. | 228 * when the overlay is reopened. |
230 * @private | 229 * @private |
231 */ | 230 */ |
232 onSuccess_: function() { | 231 onSuccess_: function() { |
233 this.updateImportInProgress_(false); | 232 this.updateImportInProgress_(false); |
234 options.SupervisedUserListData.resetPromise(); | 233 options.SupervisedUserListData.resetPromise(); |
235 OptionsPage.closeAllOverlays(); | 234 PageManager.closeAllOverlays(); |
236 }, | 235 }, |
237 }; | 236 }; |
238 | 237 |
239 // Forward public APIs to private implementations. | 238 // Forward public APIs to private implementations. |
240 [ | 239 [ |
241 'onSuccess', | 240 'onSuccess', |
242 ].forEach(function(name) { | 241 ].forEach(function(name) { |
243 SupervisedUserImportOverlay[name] = function() { | 242 SupervisedUserImportOverlay[name] = function() { |
244 var instance = SupervisedUserImportOverlay.getInstance(); | 243 var instance = SupervisedUserImportOverlay.getInstance(); |
245 return instance[name + '_'].apply(instance, arguments); | 244 return instance[name + '_'].apply(instance, arguments); |
246 }; | 245 }; |
247 }); | 246 }); |
248 | 247 |
249 // Export | 248 // Export |
250 return { | 249 return { |
251 SupervisedUserImportOverlay: SupervisedUserImportOverlay, | 250 SupervisedUserImportOverlay: SupervisedUserImportOverlay, |
252 }; | 251 }; |
253 }); | 252 }); |
OLD | NEW |