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

Side by Side Diff: Source/devtools/front_end/ui/SettingsUI.js

Issue 367093003: DevTools: More code reduce via using document.createElementWithClass and document.createChild. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 inputElement.style.width = width; 108 inputElement.style.width = width;
109 inputElement.placeholder = placeholder || ""; 109 inputElement.placeholder = placeholder || "";
110 110
111 if (validatorCallback || instant) { 111 if (validatorCallback || instant) {
112 inputElement.addEventListener("change", onInput, false); 112 inputElement.addEventListener("change", onInput, false);
113 inputElement.addEventListener("input", onInput, false); 113 inputElement.addEventListener("input", onInput, false);
114 } 114 }
115 inputElement.addEventListener("keydown", onKeyDown, false); 115 inputElement.addEventListener("keydown", onKeyDown, false);
116 116
117 var errorMessageLabel; 117 var errorMessageLabel;
118 if (validatorCallback) { 118 if (validatorCallback)
119 errorMessageLabel = p.createChild("div"); 119 errorMessageLabel = p.createChild("div", "field-error-message");
120 errorMessageLabel.classList.add("field-error-message");
121 }
122 120
123 function onInput() 121 function onInput()
124 { 122 {
125 if (validatorCallback) 123 if (validatorCallback)
126 validate(); 124 validate();
127 if (instant) 125 if (instant)
128 apply(); 126 apply();
129 } 127 }
130 128
131 function onKeyDown(event) 129 function onKeyDown(event)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 171 }
174 172
175 /** 173 /**
176 * @param {string} name 174 * @param {string} name
177 * @param {!Element} element 175 * @param {!Element} element
178 * @return {!Element} 176 * @return {!Element}
179 */ 177 */
180 WebInspector.SettingsUI.createCustomSetting = function(name, element) 178 WebInspector.SettingsUI.createCustomSetting = function(name, element)
181 { 179 {
182 var p = document.createElement("p"); 180 var p = document.createElement("p");
183 var fieldsetElement = document.createElement("fieldset"); 181 var fieldsetElement = p.createChild("fieldset");
184 fieldsetElement.createChild("label").textContent = name; 182 fieldsetElement.createChild("label").textContent = name;
185 fieldsetElement.appendChild(element); 183 fieldsetElement.appendChild(element);
186 p.appendChild(fieldsetElement);
187 return p; 184 return p;
188 } 185 }
189 186
190 /** 187 /**
191 * @param {!WebInspector.Setting} setting 188 * @param {!WebInspector.Setting} setting
192 * @return {!Element} 189 * @return {!Element}
193 */ 190 */
194 WebInspector.SettingsUI.createSettingFieldset = function(setting) 191 WebInspector.SettingsUI.createSettingFieldset = function(setting)
195 { 192 {
196 var fieldset = document.createElement("fieldset"); 193 var fieldset = document.createElement("fieldset");
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 255
259 WebInspector.UISettingDelegate.prototype = { 256 WebInspector.UISettingDelegate.prototype = {
260 /** 257 /**
261 * @return {?Element} 258 * @return {?Element}
262 */ 259 */
263 settingElement: function() 260 settingElement: function()
264 { 261 {
265 return null; 262 return null;
266 } 263 }
267 } 264 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ui/ProgressIndicator.js ('k') | Source/devtools/front_end/ui/SidebarTreeElement.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698