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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 */ | 116 */ |
117 UI.SettingsUI.createCustomSetting = function(name, element) { | 117 UI.SettingsUI.createCustomSetting = function(name, element) { |
118 var p = createElement('p'); | 118 var p = createElement('p'); |
119 var fieldsetElement = p.createChild('fieldset'); | 119 var fieldsetElement = p.createChild('fieldset'); |
120 fieldsetElement.createChild('label').textContent = name; | 120 fieldsetElement.createChild('label').textContent = name; |
121 fieldsetElement.appendChild(element); | 121 fieldsetElement.appendChild(element); |
122 return p; | 122 return p; |
123 }; | 123 }; |
124 | 124 |
125 /** | 125 /** |
| 126 * @param {!Common.Setting} setting |
| 127 * @return {?Element} |
| 128 */ |
| 129 UI.SettingsUI.createControlForSetting = function(setting) { |
| 130 if (!setting.extension()) |
| 131 return null; |
| 132 var descriptor = setting.extension().descriptor(); |
| 133 var uiTitle = Common.UIString(setting.title() || ''); |
| 134 switch (descriptor['settingType']) { |
| 135 case 'boolean': |
| 136 return UI.SettingsUI.createSettingCheckbox(uiTitle, setting); |
| 137 case 'enum': |
| 138 if (Array.isArray(descriptor['options'])) |
| 139 return UI.SettingsUI.createSettingSelect(uiTitle, descriptor['options'],
setting); |
| 140 console.error('Enum setting defined without options'); |
| 141 return null; |
| 142 default: |
| 143 console.error('Invalid setting type: ' + descriptor['settingType']); |
| 144 return null; |
| 145 } |
| 146 }; |
| 147 |
| 148 /** |
126 * @interface | 149 * @interface |
127 */ | 150 */ |
128 UI.SettingUI = function() {}; | 151 UI.SettingUI = function() {}; |
129 | 152 |
130 UI.SettingUI.prototype = { | 153 UI.SettingUI.prototype = { |
131 /** | 154 /** |
132 * @return {?Element} | 155 * @return {?Element} |
133 */ | 156 */ |
134 settingElement() {} | 157 settingElement() {} |
135 }; | 158 }; |
OLD | NEW |