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

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

Issue 2600683002: Run tools/clang-format-js on some of chrome/browser/resources/ (Closed)
Patch Set: hackhackhack Created 3 years, 11 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Redefine '$' here rather than including 'cr.js', since this is 5 // Redefine '$' here rather than including 'cr.js', since this is
6 // the only function needed. This allows this file to be loaded 6 // the only function needed. This allows this file to be loaded
7 // in a browser directly for layout and some testing purposes. 7 // in a browser directly for layout and some testing purposes.
8 var $ = function(id) { return document.getElementById(id); }; 8 var $ = function(id) {
9 return document.getElementById(id);
10 };
9 11
10 /** 12 /**
11 * WebUI for configuring instant.* preference values used by 13 * WebUI for configuring instant.* preference values used by
12 * Chrome's instant search system. 14 * Chrome's instant search system.
13 */ 15 */
14 var instantConfig = (function() { 16 var instantConfig = (function() {
15 'use strict'; 17 'use strict';
16 18
17 /** List of fields used to dynamically build form. **/ 19 /** List of fields used to dynamically build form. **/
18 var FIELDS = [ 20 var FIELDS = [
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 52
51 var label = createElementWithClass('label', 'row-label'); 53 var label = createElementWithClass('label', 'row-label');
52 label.setAttribute('for', field.key); 54 label.setAttribute('for', field.key);
53 label.textContent = field.label; 55 label.textContent = field.label;
54 row.appendChild(label); 56 row.appendChild(label);
55 57
56 var input = createElementWithClass('input', 'row-input'); 58 var input = createElementWithClass('input', 'row-input');
57 input.type = field.type; 59 input.type = field.type;
58 input.id = field.key; 60 input.id = field.key;
59 input.title = "Default Value: " + field.default; 61 input.title = "Default Value: " + field.default;
60 if (field.size) input.size = field.size; 62 if (field.size)
63 input.size = field.size;
61 input.min = field.min || 0; 64 input.min = field.min || 0;
62 if (field.max) input.max = field.max; 65 if (field.max)
63 if (field.step) input.step = field.step; 66 input.max = field.max;
67 if (field.step)
68 input.step = field.step;
64 row.appendChild(input); 69 row.appendChild(input);
65 70
66 var units = createElementWithClass('div', 'row-units'); 71 var units = createElementWithClass('div', 'row-units');
67 if (field.units) units.innerHTML = field.units; 72 if (field.units)
73 units.innerHTML = field.units;
68 row.appendChild(units); 74 row.appendChild(units);
69 75
70 $('instant-form').appendChild(row); 76 $('instant-form').appendChild(row);
71 } 77 }
72 } 78 }
73 79
74 /** 80 /**
75 * Initialize the form by adding 'onChange' listeners to all fields. 81 * Initialize the form by adding 'onChange' listeners to all fields.
76 */ 82 */
77 function initForm() { 83 function initForm() {
78 for (var i = 0; i < FIELDS.length; i++) { 84 for (var i = 0; i < FIELDS.length; i++) {
79 var field = FIELDS[i]; 85 var field = FIELDS[i];
80 $(field.key).onchange = (function(key) { 86 $(field.key).onchange = (function(key) {
81 setPreferenceValue(key); 87 setPreferenceValue(key);
82 }).bind(null, field.key); 88 }).bind(null, field.key);
83 } 89 }
84 } 90 }
85 91
86 /** 92 /**
87 * Request a preference setting's value. 93 * Request a preference setting's value.
88 * This method is asynchronous; the result is provided by a call to 94 * This method is asynchronous; the result is provided by a call to
89 * getPreferenceValueResult. 95 * getPreferenceValueResult.
90 * @param {string} prefName The name of the preference value being requested. 96 * @param {string} prefName The name of the preference value being requested.
91 */ 97 */
92 function getPreferenceValue(prefName) { 98 function getPreferenceValue(prefName) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 187 }
182 188
183 return { 189 return {
184 initialize: initialize, 190 initialize: initialize,
185 getDebugInfoResult: getDebugInfoResult, 191 getDebugInfoResult: getDebugInfoResult,
186 getPreferenceValueResult: getPreferenceValueResult 192 getPreferenceValueResult: getPreferenceValueResult
187 }; 193 };
188 })(); 194 })();
189 195
190 document.addEventListener('DOMContentLoaded', instantConfig.initialize); 196 document.addEventListener('DOMContentLoaded', instantConfig.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698