Chromium Code Reviews| 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 /** | 5 /** |
| 6 * @fileoverview This file contains methods that allow to tweak | 6 * @fileoverview This file contains methods that allow to tweak |
| 7 * internal page UI based on the status of current user (owner/user/guest). | 7 * internal page UI based on the status of current user (owner/user/guest). |
| 8 * It is assumed that required data is passed via i18n strings | 8 * It is assumed that required data is passed via i18n strings |
| 9 * (using loadTimeData dictionary) that are filled with call to | 9 * (using loadTimeData dictionary) that are filled with call to |
| 10 * AddAccountUITweaksLocalizedValues in ui_account_tweaks.cc. | 10 * AddAccountUITweaksLocalizedValues in ui_account_tweaks.cc. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 UIAccountTweaks.disableElementForSessionType_(element, sessionType); | 118 UIAccountTweaks.disableElementForSessionType_(element, sessionType); |
| 119 | 119 |
| 120 // Walk the tree, searching each ELEMENT node. | 120 // Walk the tree, searching each ELEMENT node. |
| 121 var walker = document.createTreeWalker(element, | 121 var walker = document.createTreeWalker(element, |
| 122 NodeFilter.SHOW_ELEMENT, | 122 NodeFilter.SHOW_ELEMENT, |
| 123 null, | 123 null, |
| 124 false); | 124 false); |
| 125 | 125 |
| 126 var node = walker.nextNode(); | 126 var node = walker.nextNode(); |
| 127 while (node) { | 127 while (node) { |
| 128 UIAccountTweaks.disableElementForSessionType_(node, sessionType); | 128 UIAccountTweaks.disableElementForGuest_( |
| 129 /** @type {Element} */(node), sessionType); | |
|
arv (Not doing code reviews)
2014/07/16 18:33:02
Sad :'(
apavlov
2014/07/16 18:56:14
On a side note, {Element} means "Element or null",
Dan Beam
2014/07/19 02:28:39
yep, thanks.
I just converted most of the code to
| |
| 129 node = walker.nextNode(); | 130 node = walker.nextNode(); |
| 130 } | 131 } |
| 131 }; | 132 }; |
| 132 | 133 |
| 133 /** | 134 /** |
| 134 * Disables single element for given session type. | 135 * Disables single element for given session type. |
| 135 * Adds *sessionType*-disabled css class, adds disabled attribute for | 136 * Adds *sessionType*-disabled css class, adds disabled attribute for |
| 136 * appropriate elements (input/select/button), and removes href attribute from | 137 * appropriate elements (input/select/button), and removes href attribute from |
| 137 * <a> element. | 138 * <a> element. |
| 138 * | 139 * |
| 139 * @private | |
| 140 * @param {Element} element Element that should be disabled. | 140 * @param {Element} element Element that should be disabled. |
| 141 * @param {string} sessionType account session Type specificator. | 141 * @param {string} sessionType account session Type specificator. |
| 142 * @private | |
| 142 */ | 143 */ |
| 143 UIAccountTweaks.disableElementForSessionType_ = function(element, | 144 UIAccountTweaks.disableElementForSessionType_ = function(element, |
| 144 sessionType) { | 145 sessionType) { |
| 145 element.classList.add(sessionType + '-disabled'); | 146 element.classList.add(sessionType + '-disabled'); |
| 146 if (element.nodeName == 'INPUT' || | 147 if (element.nodeName == 'INPUT' || |
| 147 element.nodeName == 'SELECT' || | 148 element.nodeName == 'SELECT' || |
| 148 element.nodeName == 'BUTTON') | 149 element.nodeName == 'BUTTON') { |
| 149 element.disabled = true; | 150 element.disabled = true; |
| 150 if (element.nodeName == 'A') { | 151 } else if (element.nodeName == 'A') { |
| 151 element.onclick = function() { | 152 element.onclick = function() { |
| 152 return false; | 153 return false; |
| 153 }; | 154 }; |
| 154 } | 155 } |
| 155 }; | 156 }; |
| 156 | 157 |
| 157 // Export | 158 // Export |
| 158 return { | 159 return { |
| 159 UIAccountTweaks: UIAccountTweaks | 160 UIAccountTweaks: UIAccountTweaks |
| 160 }; | 161 }; |
| 161 | 162 |
| 162 }); | 163 }); |
| OLD | NEW |