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 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
7 /** @const */ var List = cr.ui.List; | 7 /** @const */ var List = cr.ui.List; |
8 /** @const */ var ListItem = cr.ui.ListItem; | 8 /** @const */ var ListItem = cr.ui.ListItem; |
9 | 9 |
10 /** | 10 /** |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 * Requests new suggestions. Called when new suggestions are needed. | 126 * Requests new suggestions. Called when new suggestions are needed. |
127 * @param {string} query the text to autocomplete from. | 127 * @param {string} query the text to autocomplete from. |
128 */ | 128 */ |
129 requestSuggestions: function(query) {}, | 129 requestSuggestions: function(query) {}, |
130 | 130 |
131 /** | 131 /** |
132 * Handles the Enter keydown event. | 132 * Handles the Enter keydown event. |
133 * By default, clears and hides the autocomplete popup. Note that the | 133 * By default, clears and hides the autocomplete popup. Note that the |
134 * keydown event bubbles up, so the input field can handle the event. | 134 * keydown event bubbles up, so the input field can handle the event. |
135 */ | 135 */ |
136 handleEnterKeydown: function() { this.suggestions = []; }, | 136 handleEnterKeydown: function() { |
| 137 this.suggestions = []; |
| 138 }, |
137 | 139 |
138 /** | 140 /** |
139 * Handles the selected suggestion. Called when a suggestion is selected. | 141 * Handles the selected suggestion. Called when a suggestion is selected. |
140 * By default, sets the target input element's value to the 'url' field | 142 * By default, sets the target input element's value to the 'url' field |
141 * of the selected suggestion. | 143 * of the selected suggestion. |
142 * @param {Object} selectedSuggestion | 144 * @param {Object} selectedSuggestion |
143 */ | 145 */ |
144 handleSelectedSuggestion: function(selectedSuggestion) { | 146 handleSelectedSuggestion: function(selectedSuggestion) { |
145 var input = this.targetInput_; | 147 var input = this.targetInput_; |
146 if (!input) | 148 if (!input) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 * syncWidthAndPositionToInput function bound to |this|. | 217 * syncWidthAndPositionToInput function bound to |this|. |
216 * @type {!Function|undefined} | 218 * @type {!Function|undefined} |
217 * @private | 219 * @private |
218 */ | 220 */ |
219 boundSyncWidthAndPositionToInput_: undefined, | 221 boundSyncWidthAndPositionToInput_: undefined, |
220 | 222 |
221 /** | 223 /** |
222 * @return {HTMLElement} The text field the autocomplete popup is currently | 224 * @return {HTMLElement} The text field the autocomplete popup is currently |
223 * attached to, if any. | 225 * attached to, if any. |
224 */ | 226 */ |
225 get targetInput() { return this.targetInput_; }, | 227 get targetInput() { |
| 228 return this.targetInput_; |
| 229 }, |
226 | 230 |
227 /** | 231 /** |
228 * Handles input field key events that should be interpreted as autocomplete | 232 * Handles input field key events that should be interpreted as autocomplete |
229 * commands. | 233 * commands. |
230 * @param {Event} event The keydown event. | 234 * @param {Event} event The keydown event. |
231 * @private | 235 * @private |
232 */ | 236 */ |
233 handleAutocompleteKeydown_: function(event) { | 237 handleAutocompleteKeydown_: function(event) { |
234 if (this.hidden) | 238 if (this.hidden) |
235 return; | 239 return; |
(...skipping 19 matching lines...) Expand all Loading... |
255 // an enclosing list item. | 259 // an enclosing list item. |
256 if (handled) { | 260 if (handled) { |
257 event.preventDefault(); | 261 event.preventDefault(); |
258 event.stopPropagation(); | 262 event.stopPropagation(); |
259 } | 263 } |
260 }, | 264 }, |
261 }; | 265 }; |
262 | 266 |
263 return {AutocompleteList: AutocompleteList}; | 267 return {AutocompleteList: AutocompleteList}; |
264 }); | 268 }); |
OLD | NEW |