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 cr.define('cr.ui', function() { | 5 cr.define('cr.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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 }; | 97 }; |
98 | 98 |
99 return f; | 99 return f; |
100 } | 100 } |
101 | 101 |
102 /** | 102 /** |
103 * Input elements do not grow and shrink with their content. This is a simple | 103 * Input elements do not grow and shrink with their content. This is a simple |
104 * (and not very efficient) way of handling shrinking to content with support | 104 * (and not very efficient) way of handling shrinking to content with support |
105 * for min width and limited by the width of the parent element. | 105 * for min width and limited by the width of the parent element. |
106 * @param {HTMLElement} el The element to limit the width for. | 106 * @param {HTMLElement} el The element to limit the width for. |
107 * @param {number} parentEl The parent element that should limit the size. | 107 * @param {HTMLElement} parentEl The parent element that should limit the |
| 108 * size. |
108 * @param {number} min The minimum width. | 109 * @param {number} min The minimum width. |
109 * @param {number} opt_scale Optional scale factor to apply to the width. | 110 * @param {number} opt_scale Optional scale factor to apply to the width. |
110 */ | 111 */ |
111 function limitInputWidth(el, parentEl, min, opt_scale) { | 112 function limitInputWidth(el, parentEl, min, opt_scale) { |
112 // Needs a size larger than borders | 113 // Needs a size larger than borders |
113 el.style.width = '10px'; | 114 el.style.width = '10px'; |
114 var doc = el.ownerDocument; | 115 var doc = el.ownerDocument; |
115 var win = doc.defaultView; | 116 var win = doc.defaultView; |
116 var computedStyle = win.getComputedStyle(el); | 117 var computedStyle = win.getComputedStyle(el); |
117 var parentComputedStyle = win.getComputedStyle(parentEl); | 118 var parentComputedStyle = win.getComputedStyle(parentEl); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 203 } |
203 | 204 |
204 return { | 205 return { |
205 decorate: decorate, | 206 decorate: decorate, |
206 define: define, | 207 define: define, |
207 limitInputWidth: limitInputWidth, | 208 limitInputWidth: limitInputWidth, |
208 toCssPx: toCssPx, | 209 toCssPx: toCssPx, |
209 swallowDoubleClick: swallowDoubleClick | 210 swallowDoubleClick: swallowDoubleClick |
210 }; | 211 }; |
211 }); | 212 }); |
OLD | NEW |