OLD | NEW |
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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 return p; | 163 return p; |
164 } | 164 } |
165 | 165 |
166 /** | 166 /** |
167 * @param {string} label | 167 * @param {string} label |
168 * @param {!WebInspector.Setting} setting | 168 * @param {!WebInspector.Setting} setting |
169 * @param {number=} maxLength | 169 * @param {number=} maxLength |
170 * @param {string=} width | 170 * @param {string=} width |
171 * @param {!WebInspector.Setting=} toggleSetting | |
172 * @param {string=} defaultText | 171 * @param {string=} defaultText |
173 */ | 172 */ |
174 WebInspector.SettingsUI.createSettingLabel = function(label, setting, maxLength,
width, toggleSetting, defaultText) | 173 WebInspector.SettingsUI.createSettingLabel = function(label, setting, maxLength,
width, defaultText) |
175 { | 174 { |
176 var p = document.createElement("p"); | 175 var p = document.createElement("p"); |
177 var labelElement = p.createChild("span"); | 176 var labelElement = p.createChild("span"); |
178 labelElement.textContent = label; | 177 labelElement.textContent = label; |
179 if (label) | 178 if (label) |
180 labelElement.style.marginRight = "5px"; | 179 labelElement.style.marginRight = "5px"; |
181 var spanElement = p.createChild("span"); | 180 var spanElement = p.createChild("span"); |
182 spanElement.textContent = setting.get(); | 181 spanElement.textContent = setting.get(); |
183 if (width) | 182 if (width) |
184 p.style.width = width; | 183 p.style.width = width; |
185 | 184 |
186 if (toggleSetting) | |
187 toggleSetting.addChangeListener(onSettingChange); | |
188 setting.addChangeListener(onSettingChange); | 185 setting.addChangeListener(onSettingChange); |
189 onSettingChange(); | 186 onSettingChange(); |
190 | 187 |
191 function onSettingChange() | 188 function onSettingChange() |
192 { | 189 { |
193 var text = toggleSetting && !toggleSetting.get() ? (defaultText || "") :
setting.get(); | 190 var text = setting.get() || defaultText; |
194 spanElement.title = text; | 191 spanElement.title = text; |
195 if (maxLength && text.length > maxLength) | 192 if (maxLength && text.length > maxLength) |
196 text = text.substring(0, maxLength - 2) + "..."; | 193 text = text.substring(0, maxLength - 2) + "..."; |
197 spanElement.textContent = text; | 194 spanElement.textContent = text; |
198 } | 195 } |
199 | 196 |
200 return p; | 197 return p; |
201 } | 198 } |
202 | 199 |
203 WebInspector.SettingsUI.createCustomSetting = function(name, element) | 200 WebInspector.SettingsUI.createCustomSetting = function(name, element) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 278 |
282 WebInspector.UISettingDelegate.prototype = { | 279 WebInspector.UISettingDelegate.prototype = { |
283 /** | 280 /** |
284 * @return {?Element} | 281 * @return {?Element} |
285 */ | 282 */ |
286 settingElement: function() | 283 settingElement: function() |
287 { | 284 { |
288 return null; | 285 return null; |
289 } | 286 } |
290 } | 287 } |
OLD | NEW |