| 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) |
| 178 this.style.width = input.getBoundingClientRect().width + 'px'; |
| 179 }, |
| 180 |
| 181 /** |
| 172 * The text field the autocomplete popup is currently attached to, if any. | 182 * The text field the autocomplete popup is currently attached to, if any. |
| 173 * @return {HTMLElement} | 183 * @return {HTMLElement} |
| 174 */ | 184 */ |
| 175 get targetInput() { | 185 get targetInput() { |
| 176 return this.targetInput_; | 186 return this.targetInput_; |
| 177 }, | 187 }, |
| 178 | 188 |
| 179 /** | 189 /** |
| 180 * Handles input field key events that should be interpreted as autocomplete | 190 * Handles input field key events that should be interpreted as autocomplete |
| 181 * commands. | 191 * commands. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 209 event.preventDefault(); | 219 event.preventDefault(); |
| 210 event.stopPropagation(); | 220 event.stopPropagation(); |
| 211 } | 221 } |
| 212 }, | 222 }, |
| 213 }; | 223 }; |
| 214 | 224 |
| 215 return { | 225 return { |
| 216 AutocompleteList: AutocompleteList | 226 AutocompleteList: AutocompleteList |
| 217 }; | 227 }; |
| 218 }); | 228 }); |
| OLD | NEW |