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', 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 | 8 |
8 ///////////////////////////////////////////////////////////////////////////// | 9 ///////////////////////////////////////////////////////////////////////////// |
9 // AccountsOptions class: | 10 // AccountsOptions class: |
10 | 11 |
11 /** | 12 /** |
12 * Encapsulated handling of ChromeOS accounts options page. | 13 * Encapsulated handling of ChromeOS accounts options page. |
13 * @constructor | 14 * @constructor |
14 */ | 15 */ |
15 function AccountsOptions(model) { | 16 function AccountsOptions(model) { |
16 OptionsPage.call(this, 'accounts', | 17 Page.call(this, 'accounts', loadTimeData.getString('accountsPageTabTitle'), |
17 loadTimeData.getString('accountsPageTabTitle'), | 18 'accountsPage'); |
18 'accountsPage'); | |
19 // Whether to show the whitelist. | 19 // Whether to show the whitelist. |
20 this.showWhitelist_ = false; | 20 this.showWhitelist_ = false; |
21 } | 21 } |
22 | 22 |
23 cr.addSingletonGetter(AccountsOptions); | 23 cr.addSingletonGetter(AccountsOptions); |
24 | 24 |
25 AccountsOptions.prototype = { | 25 AccountsOptions.prototype = { |
26 // Inherit AccountsOptions from OptionsPage. | 26 // Inherit AccountsOptions from Page. |
27 __proto__: OptionsPage.prototype, | 27 __proto__: Page.prototype, |
28 | 28 |
29 /** @override */ | 29 /** @override */ |
30 initializePage: function() { | 30 initializePage: function() { |
31 // Call base class implementation to starts preference initialization. | 31 Page.prototype.initializePage.call(this); |
32 OptionsPage.prototype.initializePage.call(this); | |
33 | 32 |
34 // Set up accounts page. | 33 // Set up accounts page. |
35 var userList = $('userList'); | 34 var userList = $('userList'); |
36 userList.addEventListener('remove', this.handleRemoveUser_); | 35 userList.addEventListener('remove', this.handleRemoveUser_); |
37 | 36 |
38 var userNameEdit = $('userNameEdit'); | 37 var userNameEdit = $('userNameEdit'); |
39 options.accounts.UserNameEdit.decorate(userNameEdit); | 38 options.accounts.UserNameEdit.decorate(userNameEdit); |
40 userNameEdit.addEventListener('add', this.handleAddUser_); | 39 userNameEdit.addEventListener('add', this.handleAddUser_); |
41 | 40 |
42 // If the current user is not the owner, do not show the user list. | 41 // If the current user is not the owner, do not show the user list. |
(...skipping 10 matching lines...) Expand all Loading... |
53 this.addEventListener('visibleChange', this.handleVisibleChange_); | 52 this.addEventListener('visibleChange', this.handleVisibleChange_); |
54 | 53 |
55 $('useWhitelistCheck').addEventListener('change', | 54 $('useWhitelistCheck').addEventListener('change', |
56 this.handleUseWhitelistCheckChange_.bind(this)); | 55 this.handleUseWhitelistCheckChange_.bind(this)); |
57 | 56 |
58 Preferences.getInstance().addEventListener( | 57 Preferences.getInstance().addEventListener( |
59 $('useWhitelistCheck').pref, | 58 $('useWhitelistCheck').pref, |
60 this.handleUseWhitelistPrefChange_.bind(this)); | 59 this.handleUseWhitelistPrefChange_.bind(this)); |
61 | 60 |
62 $('accounts-options-overlay-confirm').onclick = | 61 $('accounts-options-overlay-confirm').onclick = |
63 OptionsPage.closeOverlay.bind(OptionsPage); | 62 PageManager.closeOverlay.bind(PageManager); |
64 }, | 63 }, |
65 | 64 |
66 /** | 65 /** |
67 * Update user list control state. | 66 * Update user list control state. |
68 * @private | 67 * @private |
69 */ | 68 */ |
70 updateControls_: function() { | 69 updateControls_: function() { |
71 $('userList').disabled = | 70 $('userList').disabled = |
72 $('userNameEdit').disabled = !this.showWhitelist_ || | 71 $('userNameEdit').disabled = !this.showWhitelist_ || |
73 AccountsOptions.whitelistIsManaged() || | 72 AccountsOptions.whitelistIsManaged() || |
74 !$('useWhitelistCheck').checked; | 73 !$('useWhitelistCheck').checked; |
75 }, | 74 }, |
76 | 75 |
77 /** | 76 /** |
78 * Handler for OptionsPage's visible property change event. | 77 * Handler for Page's visible property change event. |
79 * @private | 78 * @private |
80 * @param {Event} e Property change event. | 79 * @param {Event} e Property change event. |
81 */ | 80 */ |
82 handleVisibleChange_: function(e) { | 81 handleVisibleChange_: function(e) { |
83 if (this.visible) { | 82 if (this.visible) { |
84 this.updateControls_(); | 83 this.updateControls_(); |
85 if (this.showWhitelist_) | 84 if (this.showWhitelist_) |
86 $('userList').redraw(); | 85 $('userList').redraw(); |
87 } | 86 } |
88 }, | 87 }, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 if (this.showWhitelist_) | 146 if (this.showWhitelist_) |
148 $('userList').updateAccountPicture(username); | 147 $('userList').updateAccountPicture(username); |
149 }; | 148 }; |
150 | 149 |
151 // Export | 150 // Export |
152 return { | 151 return { |
153 AccountsOptions: AccountsOptions | 152 AccountsOptions: AccountsOptions |
154 }; | 153 }; |
155 | 154 |
156 }); | 155 }); |
OLD | NEW |