OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 List libraryList; | 5 List libraryList; |
6 InputElement searchInput; | 6 InputElement searchInput; |
7 DivElement dropdown; | 7 DivElement dropdown; |
8 | 8 |
9 /** | 9 /** |
10 * Update the search drop down based on the current search text. | 10 * Update the search drop down based on the current search text. |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 if (index != _currentResultIndex) { | 257 if (index != _currentResultIndex) { |
258 _currentResultIndex = index; | 258 _currentResultIndex = index; |
259 if (index >= 0) { | 259 if (index >= 0) { |
260 currentResult = currentResults[_currentResultIndex]; | 260 currentResult = currentResults[_currentResultIndex]; |
261 } else { | 261 } else { |
262 currentResult = null; | 262 currentResult = null; |
263 } | 263 } |
264 } | 264 } |
265 } | 265 } |
266 | 266 |
267 int get currentResultIndex() => _currentResultIndex; | 267 int get currentResultIndex => _currentResultIndex; |
268 | 268 |
269 void set currentResult(Result result) { | 269 void set currentResult(Result result) { |
270 if (_currentResult != result) { | 270 if (_currentResult != result) { |
271 if (_currentResult != null) { | 271 if (_currentResult != null) { |
272 _currentResult.row.classes.remove('drop-down-link-select'); | 272 _currentResult.row.classes.remove('drop-down-link-select'); |
273 } | 273 } |
274 _currentResult = result; | 274 _currentResult = result; |
275 if (_currentResult != null) { | 275 if (_currentResult != null) { |
276 _currentResult.row.classes.add('drop-down-link-select'); | 276 _currentResult.row.classes.add('drop-down-link-select'); |
277 } | 277 } |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 Result get currentResult() => _currentResult; | 281 Result get currentResult => _currentResult; |
282 | 282 |
283 /** | 283 /** |
284 * Navigate the search drop down using up/down inside the search field. Follow | 284 * Navigate the search drop down using up/down inside the search field. Follow |
285 * the result link on enter. | 285 * the result link on enter. |
286 */ | 286 */ |
287 void handleUpDown(KeyboardEvent event) { | 287 void handleUpDown(KeyboardEvent event) { |
288 if (event.keyIdentifier == KeyName.UP) { | 288 if (event.keyIdentifier == KeyName.UP) { |
289 currentResultIndex--; | 289 currentResultIndex--; |
290 event.preventDefault(); | 290 event.preventDefault(); |
291 } else if (event.keyIdentifier == KeyName.DOWN) { | 291 } else if (event.keyIdentifier == KeyName.DOWN) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 dropdown = query('#drop-down'); | 335 dropdown = query('#drop-down'); |
336 | 336 |
337 searchInput.on.keyDown.add(handleUpDown); | 337 searchInput.on.keyDown.add(handleUpDown); |
338 searchInput.on.keyUp.add(updateDropDown); | 338 searchInput.on.keyUp.add(updateDropDown); |
339 searchInput.on.change.add(updateDropDown); | 339 searchInput.on.change.add(updateDropDown); |
340 searchInput.on.reset.add(updateDropDown); | 340 searchInput.on.reset.add(updateDropDown); |
341 searchInput.on.focus.add((event) => showDropDown()); | 341 searchInput.on.focus.add((event) => showDropDown()); |
342 searchInput.on.blur.add((event) => hideDropDown()); | 342 searchInput.on.blur.add((event) => hideDropDown()); |
343 window.on.keyDown.add(shortcutHandler); | 343 window.on.keyDown.add(shortcutHandler); |
344 } | 344 } |
OLD | NEW |