Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: chrome/browser/resources/options2/chromeos/accounts_options.js

Issue 9464053: Hide/Disable several (meaningless) options in Settings uber-page for Guest. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Nit fixes + merge with TOT + gray out labels for disabled elements Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.
165 * It adds guest-disabled css class to all elements within given subtree,
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.
James Hawkins 2012/03/01 20:00:19 nit: Indent 4 spaces.
Denis Kuznetsov (DE-MUC) 2012/03/02 17:32:25 Done.
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
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 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698