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 OptionsPage = options.OptionsPage; |
7 | 7 |
8 ///////////////////////////////////////////////////////////////////////////// | 8 ///////////////////////////////////////////////////////////////////////////// |
9 // AccountsOptions class: | 9 // AccountsOptions class: |
10 | 10 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 * Returns whether the current user is owner or not. | 134 * Returns whether the current user is owner or not. |
135 */ | 135 */ |
136 AccountsOptions.currentUserIsOwner = function() { | 136 AccountsOptions.currentUserIsOwner = function() { |
137 return localStrings.getString('current_user_is_owner') == 'true'; | 137 return localStrings.getString('current_user_is_owner') == 'true'; |
138 }; | 138 }; |
139 | 139 |
140 /** | 140 /** |
141 * Returns whether we're currently in guest mode. | 141 * Returns whether we're currently in guest mode. |
142 */ | 142 */ |
143 AccountsOptions.loggedInAsGuest = function() { | 143 AccountsOptions.loggedInAsGuest = function() { |
144 return localStrings.getString('logged_in_as_guest') == 'true'; | 144 return localStrings.getString('loggedInAsGuest') == 'true'; |
145 }; | 145 }; |
146 | 146 |
147 /** | 147 /** |
148 * Returns whether the whitelist is managed by policy or not. | 148 * Returns whether the whitelist is managed by policy or not. |
149 */ | 149 */ |
150 AccountsOptions.whitelistIsManaged = function() { | 150 AccountsOptions.whitelistIsManaged = function() { |
151 return localStrings.getString('whitelist_is_managed') == 'true'; | 151 return localStrings.getString('whitelist_is_managed') == 'true'; |
152 }; | 152 }; |
153 | 153 |
154 /** | 154 /** |
155 * Update account picture. | 155 * Update account picture. |
156 * @param {string} username User for which to update the image. | 156 * @param {string} username User for which to update the image. |
157 */ | 157 */ |
158 AccountsOptions.updateAccountPicture = function(username) { | 158 AccountsOptions.updateAccountPicture = function(username) { |
159 if (this.showWhitelist_) | 159 if (this.showWhitelist_) |
160 $('userList').updateAccountPicture(username); | 160 $('userList').updateAccountPicture(username); |
161 }; | 161 }; |
162 | 162 |
163 /** | |
164 * Disable and mark page elements for Guest mode. | |
James Hawkins
2012/03/05 17:07:12
nit: Method documentation should be declarative (a
Denis Kuznetsov (DE-MUC)
2012/03/12 10:32:15
Done.
| |
165 * It adds guest-disabled css class to all elements within given subtree, | |
James Hawkins
2012/03/05 17:07:12
nit: Don't use pronouns (it) in comments; they're
Denis Kuznetsov (DE-MUC)
2012/03/12 10:32:15
Done.
| |
166 * disables interactive elements (input/select/button), and removes href | |
167 * attribute from <a> elements. | |
168 * | |
169 * @param {Element} element Root element of DOM subtree that should be | |
170 * disabled. | |
171 */ | |
172 AccountsOptions.disableElementsForGuest = function(element) { | |
173 AccountsOptions.disableElementForGuest_(element); | |
174 | |
175 // Walk the tree, searching each ELEMENT node. | |
176 var walker = document.createTreeWalker(element, | |
177 NodeFilter.SHOW_ELEMENT, | |
178 null, | |
179 false); | |
180 | |
181 var node = walker.nextNode(); | |
182 while (node) { | |
183 AccountsOptions.disableElementForGuest_(node); | |
184 node = walker.nextNode(); | |
185 } | |
186 }; | |
187 | |
188 /** | |
189 * Disables single element for Guest mode. | |
190 * It adds guest-disabled css class, adds disabled attribute for appropriate | |
James Hawkins
2012/03/05 17:07:12
nit: s/It adds/Adds/
Denis Kuznetsov (DE-MUC)
2012/03/12 10:32:15
Done.
| |
191 * elements (input/select/button), and removes href attribute from | |
192 * <a> element. | |
193 * | |
194 * @private | |
195 * @param {Element} element Element that should be disabled. | |
196 */ | |
197 AccountsOptions.disableElementForGuest_ = function(element) { | |
198 element.classList.add('guest-disabled'); | |
199 if (element.nodeName == 'INPUT' || | |
200 element.nodeName == 'SELECT' || | |
201 element.nodeName == 'BUTTON') | |
202 element.disabled = true; | |
203 if (element.nodeName == 'A') | |
204 element.removeAttribute('href'); | |
205 }; | |
206 | |
163 // Export | 207 // Export |
164 return { | 208 return { |
165 AccountsOptions: AccountsOptions | 209 AccountsOptions: AccountsOptions |
166 }; | 210 }; |
167 | 211 |
168 }); | 212 }); |
OLD | NEW |