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

Side by Side Diff: chrome/browser/resources/policy.js

Issue 10010019: JS style nits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: couple more Created 8 years, 8 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
« no previous file with comments | « chrome/browser/resources/plugins.js ('k') | chrome/browser/resources/sessions.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * This variable structure is here to document the structure that the template 6 * This variable structure is here to document the structure that the template
7 * expects to correctly populate the page. 7 * expects to correctly populate the page.
8 */ 8 */
9 var policyDataFormat = { 9 var policyDataFormat = {
10 // Whether any of the policies in 'policies' have a value. 10 // Whether any of the policies in 'policies' have a value.
(...skipping 30 matching lines...) Expand all
41 }; 41 };
42 42
43 cr.define('policies', function() { 43 cr.define('policies', function() {
44 44
45 function Policy() { 45 function Policy() {
46 } 46 }
47 47
48 cr.addSingletonGetter(Policy); 48 cr.addSingletonGetter(Policy);
49 49
50 Policy.prototype = { 50 Policy.prototype = {
51
52 /** 51 /**
53 * True if none of the received policies are actually set, false otherwise. 52 * True if none of the received policies are actually set, false otherwise.
54 * @type {boolean} 53 * @type {boolean}
55 */ 54 */
56 noActivePolicies_: false, 55 noActivePolicies_: false,
57 56
58 /** 57 /**
59 * The current search term for filtering of the policy table. 58 * The current search term for filtering of the policy table.
60 * @type {string} 59 * @type {string}
61 * @private 60 * @private
62 */ 61 */
63 searchTerm_: '', 62 searchTerm_: '',
64 63
65 /** 64 /**
66 * Takes the |policyData| argument and populates the page with this data. It 65 * Takes the |policyData| argument and populates the page with this data. It
67 * expects an object structure like the policyDataFormat above. 66 * expects an object structure like the policyDataFormat above.
68 * @param {Object} policyData Detailed info about policies. 67 * @param {Object} policyData Detailed info about policies.
69 */ 68 */
70 renderTemplate: function(policyData) { 69 renderTemplate: function(policyData) {
71 this.noActivePolicies_ = !policyData.anyPoliciesSet; 70 this.noActivePolicies_ = !policyData.anyPoliciesSet;
72 71
73 if (this.noActivePolicies_) 72 if (this.noActivePolicies_)
74 $('no-policies').hidden = false; 73 $('no-policies').hidden = false;
75 if (policyData.status.displayStatusSection) 74 if (policyData.status.displayStatusSection)
76 $('status-section').hidden = false;; 75 $('status-section').hidden = false;
77 76
78 // This is the javascript code that processes the template: 77 // This is the javascript code that processes the template:
79 var input = new JsEvalContext(policyData); 78 var input = new JsEvalContext(policyData);
80 var output = $('data-template'); 79 var output = $('data-template');
81 jstProcess(input, output); 80 jstProcess(input, output);
82 81
83 var toggles = document.querySelectorAll('.policy-set * .toggler'); 82 var toggles = document.querySelectorAll('.policy-set * .toggler');
84 for (var i = 0; i < toggles.length; i++) { 83 for (var i = 0; i < toggles.length; i++) {
85 toggles[i].hidden = true; 84 toggles[i].hidden = true;
86 toggles[i].onclick = function() { 85 toggles[i].onclick = function() {
87 Policy.getInstance().toggleCellExpand_(this); 86 Policy.getInstance().toggleCellExpand_(this);
88 }; 87 };
89 } 88 }
90 89
91 var containers = document.querySelectorAll('.text-container'); 90 var containers = document.querySelectorAll('.text-container');
92 for (var i = 0; i < containers.length; i++) 91 for (var i = 0; i < containers.length; i++)
93 this.initTextContainer_(containers[i]) 92 this.initTextContainer_(containers[i]);
94 }, 93 },
95 94
96 /** 95 /**
97 * Filters the table of policies by name. 96 * Filters the table of policies by name.
98 * @param {string} term The search string. 97 * @param {string} term The search string.
99 */ 98 */
100 filterTable: function(term) { 99 filterTable: function(term) {
101 this.searchTerm_ = term.toLowerCase(); 100 this.searchTerm_ = term.toLowerCase();
102 var table = $('policy-table'); 101 var table = $('policy-table');
103 var showUnsent = $('toggle-unsent-policies').checked; 102 var showUnsent = $('toggle-unsent-policies').checked;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 * status data. 248 * status data.
250 */ 249 */
251 Policy.initialize = function() { 250 Policy.initialize = function() {
252 i18nTemplate.process(document, templateData); 251 i18nTemplate.process(document, templateData);
253 Policy.requestData(); 252 Policy.requestData();
254 253
255 // Set HTML event handlers. 254 // Set HTML event handlers.
256 $('fetch-policies-button').onclick = function(event) { 255 $('fetch-policies-button').onclick = function(event) {
257 this.disabled = true; 256 this.disabled = true;
258 Policy.triggerPolicyFetch(); 257 Policy.triggerPolicyFetch();
259 } 258 };
260 259
261 $('toggle-unsent-policies').onchange = function(event) { 260 $('toggle-unsent-policies').onchange = function(event) {
262 Policy.getInstance().updatePolicyVisibility(); 261 Policy.getInstance().updatePolicyVisibility();
263 }; 262 };
264 263
265 $('search-field').onsearch = function(event) { 264 $('search-field').onsearch = function(event) {
266 Policy.getInstance().filterTable(this.value); 265 Policy.getInstance().filterTable(this.value);
267 }; 266 };
268 }; 267 };
269 268
270 // Export 269 // Export
271 return { 270 return {
272 Policy: Policy 271 Policy: Policy
273 }; 272 };
274 }); 273 });
275 274
276 var Policy = policies.Policy; 275 var Policy = policies.Policy;
277 276
278 // Get data and have it displayed upon loading. 277 // Get data and have it displayed upon loading.
279 document.addEventListener('DOMContentLoaded', policies.Policy.initialize); 278 document.addEventListener('DOMContentLoaded', policies.Policy.initialize);
OLDNEW
« no previous file with comments | « chrome/browser/resources/plugins.js ('k') | chrome/browser/resources/sessions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698