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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 return; | 154 return; |
| 155 | 155 |
| 156 this.detach(); | 156 this.detach(); |
| 157 this.targetInput_ = input; | 157 this.targetInput_ = input; |
| 158 this.style.width = input.getBoundingClientRect().width + 'px'; | 158 this.style.width = input.getBoundingClientRect().width + 'px'; |
| 159 this.hidden = false; // Necessary for positionPopupAroundElement to work. | 159 this.hidden = false; // Necessary for positionPopupAroundElement to work. |
| 160 cr.ui.positionPopupAroundElement(input, this, cr.ui.AnchorType.BELOW) | 160 cr.ui.positionPopupAroundElement(input, this, cr.ui.AnchorType.BELOW) |
| 161 // Start hidden; when the data model gets results the list will show. | 161 // Start hidden; when the data model gets results the list will show. |
| 162 this.hidden = true; | 162 this.hidden = true; |
| 163 | 163 |
| 164 input.addEventListener('keydown', this.textFieldKeyHandler_, true); | 164 input.addEventListener('keydown', this.textFieldKeyHandler_, true); |
|
Tyler Breisacher (Chromium)
2012/01/09 19:25:06
Event is added here with |true| for the "use captu
| |
| 165 input.addEventListener('input', this.textFieldInputHandler_); | 165 input.addEventListener('input', this.textFieldInputHandler_); |
| 166 }, | 166 }, |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * Detaches the autocomplete popup from its current input element, if any. | 169 * Detaches the autocomplete popup from its current input element, if any. |
| 170 */ | 170 */ |
| 171 detach: function() { | 171 detach: function() { |
| 172 var input = this.targetInput_ | 172 var input = this.targetInput_ |
| 173 if (!input) | 173 if (!input) |
| 174 return; | 174 return; |
| 175 | 175 |
| 176 input.removeEventListener('keydown', this.textFieldKeyHandler_); | 176 input.removeEventListener('keydown', this.textFieldKeyHandler_, true); |
| 177 input.removeEventListener('input', this.textFieldInputHandler_); | 177 input.removeEventListener('input', this.textFieldInputHandler_); |
| 178 this.targetInput_ = null; | 178 this.targetInput_ = null; |
| 179 this.suggestions = []; | 179 this.suggestions = []; |
| 180 }, | 180 }, |
| 181 | 181 |
| 182 /** | 182 /** |
| 183 * Makes sure that the suggestion list matches the width of the input it is. | 183 * Makes sure that the suggestion list matches the width of the input it is. |
| 184 * attached to. Should be called any time the input is resized. | 184 * attached to. Should be called any time the input is resized. |
| 185 */ | 185 */ |
| 186 syncWidthToInput: function() { | 186 syncWidthToInput: function() { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 event.preventDefault(); | 230 event.preventDefault(); |
| 231 event.stopPropagation(); | 231 event.stopPropagation(); |
| 232 } | 232 } |
| 233 }, | 233 }, |
| 234 }; | 234 }; |
| 235 | 235 |
| 236 return { | 236 return { |
| 237 AutocompleteList: AutocompleteList | 237 AutocompleteList: AutocompleteList |
| 238 }; | 238 }; |
| 239 }); | 239 }); |
| OLD | NEW |