Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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('options', function() { | 5 cr.define('options', function() { |
| 6 const ArrayDataModel = cr.ui.ArrayDataModel; | 6 const ArrayDataModel = cr.ui.ArrayDataModel; |
| 7 const List = cr.ui.List; | 7 const List = cr.ui.List; |
| 8 const ListItem = cr.ui.ListItem; | 8 const ListItem = cr.ui.ListItem; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 if (!input) | 162 if (!input) |
| 163 return; | 163 return; |
| 164 | 164 |
| 165 input.removeEventListener('keydown', this.textFieldKeyHandler_); | 165 input.removeEventListener('keydown', this.textFieldKeyHandler_); |
| 166 input.removeEventListener('input', this.textFieldInputHandler_); | 166 input.removeEventListener('input', this.textFieldInputHandler_); |
| 167 this.targetInput_ = null; | 167 this.targetInput_ = null; |
| 168 this.suggestions = []; | 168 this.suggestions = []; |
| 169 }, | 169 }, |
| 170 | 170 |
| 171 /** | 171 /** |
| 172 * Makes sure that the suggestion list matches the width of the input it is. | |
| 173 * attached to. Should be called any time the input is resized. | |
| 174 */ | |
| 175 syncWidthToInput: function() { | |
| 176 var input = this.targetInput_ | |
| 177 if (!input) | |
|
csilv
2011/04/22 00:10:55
I'd prefer to make this more concise by saying:
i
| |
| 178 return; | |
| 179 | |
| 180 this.style.width = input.getBoundingClientRect().width + 'px'; | |
| 181 }, | |
| 182 | |
| 183 /** | |
| 172 * The text field the autocomplete popup is currently attached to, if any. | 184 * The text field the autocomplete popup is currently attached to, if any. |
| 173 * @return {HTMLElement} | 185 * @return {HTMLElement} |
| 174 */ | 186 */ |
| 175 get targetInput() { | 187 get targetInput() { |
| 176 return this.targetInput_; | 188 return this.targetInput_; |
| 177 }, | 189 }, |
| 178 | 190 |
| 179 /** | 191 /** |
| 180 * Handles input field key events that should be interpreted as autocomplete | 192 * Handles input field key events that should be interpreted as autocomplete |
| 181 * commands. | 193 * commands. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 204 event.preventDefault(); | 216 event.preventDefault(); |
| 205 event.stopPropagation(); | 217 event.stopPropagation(); |
| 206 } | 218 } |
| 207 }, | 219 }, |
| 208 }; | 220 }; |
| 209 | 221 |
| 210 return { | 222 return { |
| 211 AutocompleteList: AutocompleteList | 223 AutocompleteList: AutocompleteList |
| 212 }; | 224 }; |
| 213 }); | 225 }); |
| OLD | NEW |