OLD | NEW |
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 base.exportTo('ui', function() { | 5 base.exportTo('ui', function() { |
6 | 6 |
7 /** | 7 /** |
8 * Decorates elements as an instance of a class. | 8 * Decorates elements as an instance of a class. |
9 * @param {string|!Element} source The way to find the element(s) to decorate. | 9 * @param {string|!Element} source The way to find the element(s) to decorate. |
10 * If this is a string then {@code querySeletorAll} is used to find the | 10 * If this is a string then {@code querySeletorAll} is used to find the |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 return Math.round(pixels) + 'px'; | 165 return Math.round(pixels) + 'px'; |
166 } | 166 } |
167 | 167 |
168 function createSpan(opt_text) { | 168 function createSpan(opt_text) { |
169 var spanEl = document.createElement('span'); | 169 var spanEl = document.createElement('span'); |
170 if (opt_text) | 170 if (opt_text) |
171 spanEl.textContent = opt_text; | 171 spanEl.textContent = opt_text; |
172 return spanEl; | 172 return spanEl; |
173 }; | 173 }; |
174 | 174 |
| 175 function createLabel(text, child) { |
| 176 var labelEl = document.createElement('label'); |
| 177 labelEl.textContent = text; |
| 178 labelEl.appendChild(child); |
| 179 return labelEl; |
| 180 }; |
| 181 |
175 return { | 182 return { |
176 decorate: decorate, | 183 decorate: decorate, |
177 define: define, | 184 define: define, |
178 limitInputWidth: limitInputWidth, | 185 limitInputWidth: limitInputWidth, |
179 toCssPx: toCssPx, | 186 toCssPx: toCssPx, |
180 createSpan: createSpan | 187 createSpan: createSpan, |
| 188 createLabel: createLabel |
181 }; | 189 }; |
182 }); | 190 }); |
OLD | NEW |