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

Side by Side Diff: ui/webui/resources/js/chromeos/ui_account_tweaks.js

Issue 369643002: Lay groudwork to Closure compile JavaScript (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asdf Created 6 years, 5 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 | Annotate | Revision Log
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 /** 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 UIAccountTweaks.disableElementForGuest_(element); 80 UIAccountTweaks.disableElementForGuest_(element);
81 81
82 // Walk the tree, searching each ELEMENT node. 82 // Walk the tree, searching each ELEMENT node.
83 var walker = document.createTreeWalker(element, 83 var walker = document.createTreeWalker(element,
84 NodeFilter.SHOW_ELEMENT, 84 NodeFilter.SHOW_ELEMENT,
85 null, 85 null,
86 false); 86 false);
87 87
88 var node = walker.nextNode(); 88 var node = walker.nextNode();
89 while (node) { 89 while (node) {
90 UIAccountTweaks.disableElementForGuest_(node); 90 UIAccountTweaks.disableElementForGuest_(/** @type {Element} */(node));
91 node = walker.nextNode(); 91 node = walker.nextNode();
92 } 92 }
93 }; 93 };
94 94
95 /** 95 /**
96 * Disables single element for Guest mode. 96 * Disables single element for Guest mode.
97 * Adds guest-disabled css class, adds disabled attribute for appropriate 97 * Adds guest-disabled css class, adds disabled attribute for appropriate
98 * elements (input/select/button), and removes href attribute from 98 * elements (input/select/button), and removes href attribute from
99 * <a> element. 99 * <a> element.
100 * 100 *
101 * @param {Element} element Element that should be disabled.
101 * @private 102 * @private
102 * @param {Element} element Element that should be disabled.
103 */ 103 */
104 UIAccountTweaks.disableElementForGuest_ = function(element) { 104 UIAccountTweaks.disableElementForGuest_ = function(element) {
105 element.classList.add('guest-disabled'); 105 element.classList.add('guest-disabled');
106 if (element.nodeName == 'INPUT' || 106 if (element.nodeName == 'INPUT' ||
107 element.nodeName == 'SELECT' || 107 element.nodeName == 'SELECT' ||
108 element.nodeName == 'BUTTON') 108 element.nodeName == 'BUTTON') {
109 element.disabled = true; 109 element.disabled = true;
110 if (element.nodeName == 'A') { 110 } else if (element.nodeName == 'A') {
111 element.onclick = function() { 111 element.onclick = function() {
112 return false; 112 return false;
113 }; 113 };
114 } 114 }
115 }; 115 };
116 116
117 // Export 117 // Export
118 return { 118 return {
119 UIAccountTweaks: UIAccountTweaks 119 UIAccountTweaks: UIAccountTweaks
120 }; 120 };
121 121
122 }); 122 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698