Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: chrome/browser/resources/options/autocomplete_list.js

Issue 6898001: WebUI Prefs: Resize autocomplete list on window resize (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Condense syncWidthToInput Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/options/browser_options.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/options/browser_options.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698