Chromium Code Reviews| Index: ui/webui/resources/js/chromeos/ui_account_tweaks.js |
| diff --git a/ui/webui/resources/js/chromeos/ui_account_tweaks.js b/ui/webui/resources/js/chromeos/ui_account_tweaks.js |
| index 9b4b85aef2be1de552a3688bcf88f9a21c2d71b2..e953c1ada20156165c881e3bb91ebbb6eb6b0e31 100644 |
| --- a/ui/webui/resources/js/chromeos/ui_account_tweaks.js |
| +++ b/ui/webui/resources/js/chromeos/ui_account_tweaks.js |
| @@ -75,7 +75,7 @@ cr.define('uiAccountTweaks', function() { |
| if (visibility == 'hidden') |
| element.hidden = true; |
| else if (visibility == 'disabled') |
| - UIAccountTweaks.disableElementsForSessionType(element, sessionType); |
| + UIAccountTweaks.disableNodeForSessionType(element, sessionType); |
| } |
| } |
| @@ -104,54 +104,47 @@ cr.define('uiAccountTweaks', function() { |
| } |
| /** |
| - * Disables and marks page elements for specified session type. |
| - * Adds #-disabled css class to all elements within given subtree, |
| - * disables interactive elements (input/select/button), and removes href |
| - * attribute from <a> elements. |
| + * Disables and marks page nodes for specified session type. |
| + * Adds #-disabled css class to all nodes within given subtree, |
| + * disables interactive nodes (input/select/button), and removes href |
| + * attribute from <a> nodes. |
| * |
| - * @param {Element} element Root element of DOM subtree that should be |
| - * disabled. |
| + * @param {!Node} node Root node of DOM subtree that should be disabled. |
|
arv (Not doing code reviews)
2014/07/24 16:44:24
!Element was more correct. Here is a case where th
Dan Beam
2014/07/25 01:52:32
see what you think of updated changes
|
| * @param {string} sessionType session type specificator. |
| */ |
| - UIAccountTweaks.disableElementsForSessionType = function(element, |
| - sessionType) { |
| - UIAccountTweaks.disableElementForSessionType_(element, sessionType); |
| + UIAccountTweaks.disableNodeForSessionType = function(node, sessionType) { |
| + UIAccountTweaks.disableNodeForSessionType_(node, sessionType); |
| // Walk the tree, searching each ELEMENT node. |
| - var walker = document.createTreeWalker(element, |
| + var walker = document.createTreeWalker(node, |
| NodeFilter.SHOW_ELEMENT, |
| null, |
| false); |
| - var node = walker.nextNode(); |
| - while (node) { |
| - UIAccountTweaks.disableElementForSessionType_(node, sessionType); |
| - node = walker.nextNode(); |
| + var temp = walker.nextNode(); |
| + while (temp) { |
| + UIAccountTweaks.disableNodeForSessionType_(temp, sessionType); |
| + temp = walker.nextNode(); |
| } |
| }; |
| /** |
| - * Disables single element for given session type. |
| + * Disables single node for given session type. |
| * Adds *sessionType*-disabled css class, adds disabled attribute for |
| - * appropriate elements (input/select/button), and removes href attribute from |
| - * <a> element. |
| + * appropriate nodes (input/select/button), and removes href attribute from |
| + * <a> node. |
| * |
| - * @private |
| - * @param {Element} element Element that should be disabled. |
| + * @param {Node} node Node to disable. |
| * @param {string} sessionType account session Type specificator. |
| + * @private |
| */ |
| - UIAccountTweaks.disableElementForSessionType_ = function(element, |
| - sessionType) { |
| - element.classList.add(sessionType + '-disabled'); |
| - if (element.nodeName == 'INPUT' || |
| - element.nodeName == 'SELECT' || |
| - element.nodeName == 'BUTTON') |
| - element.disabled = true; |
| - if (element.nodeName == 'A') { |
| - element.onclick = function() { |
| - return false; |
| - }; |
| - } |
| + UIAccountTweaks.disableNodeForSessionType_ = function(node, sessionType) { |
| + node.classList.add(sessionType + '-disabled'); |
|
arv (Not doing code reviews)
2014/07/24 16:44:24
Node does not have classList property. It is a pro
Dan Beam
2014/07/25 01:52:32
that's what i thought as well, but it didn't. i t
|
| + |
| + if (/^(INPUT|SELECT|BUTTON)$/.test(node.nodeName)) |
|
arv (Not doing code reviews)
2014/07/24 16:44:24
If you are refactoring this a switch would be the
Dan Beam
2014/07/25 01:52:32
reverted
|
| + node.disabled = true; |
|
arv (Not doing code reviews)
2014/07/24 16:44:24
Node does not have a disabled property. Is the typ
Dan Beam
2014/07/25 01:52:32
externs
|
| + else if (node.nodeName == 'A') |
| + node.onclick = function() { return false; }; |
| }; |
| // Export |