| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. |
| 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 }); |
| OLD | NEW |