Chromium Code Reviews| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 | 317 |
| 318 /** Hide the search drop down unless suspended. */ | 318 /** Hide the search drop down unless suspended. */ |
| 319 void hideDropDown() { | 319 void hideDropDown() { |
| 320 if (hideDropDownSuspend) return; | 320 if (hideDropDownSuspend) return; |
| 321 | 321 |
| 322 dropdown.style.visibility = 'hidden'; | 322 dropdown.style.visibility = 'hidden'; |
| 323 } | 323 } |
| 324 | 324 |
| 325 /** Activate search on Ctrl+3 and S. */ | 325 /** Activate search on Ctrl+3 and S. */ |
| 326 void shortcutHandler(KeyboardEvent event) { | 326 void shortcutHandler(KeyboardEvent event) { |
| 327 if (event.keyCode == 0x33/* 3 */ && event.ctrlKey || | 327 if (event.keyCode == 0x33/* 3 */ && event.ctrlKey) { |
| 328 event.keyCode == 0x53/* S */) { | 328 searchInput.focus(); |
| 329 event.preventDefault(); | |
| 330 } else if (event.target != searchInput && event.keyCode == 0x53/* S */) { | |
| 331 // Avoid preventing writing 's' in the search input. | |
|
Lasse Reichstein Nielsen
2012/10/05 14:06:21
Avoid preventing -> Allow (or "Don't prevent"). Tw
Johnni Winther
2012/10/05 14:34:01
Yes it does! Done.
| |
| 329 searchInput.focus(); | 332 searchInput.focus(); |
| 330 event.preventDefault(); | 333 event.preventDefault(); |
| 331 } | 334 } |
| 332 } | 335 } |
| 333 | 336 |
| 334 /** | 337 /** |
| 335 * Setup window shortcuts. | 338 * Setup window shortcuts. |
| 336 */ | 339 */ |
| 337 void setupShortcuts() { | 340 void setupShortcuts() { |
| 338 window.on.keyDown.add(shortcutHandler); | 341 window.on.keyDown.add(shortcutHandler); |
| 339 } | 342 } |
| 340 | 343 |
| 341 /** Setup search hooks. */ | 344 /** Setup search hooks. */ |
| 342 void setupSearch(var libraries) { | 345 void setupSearch(var libraries) { |
| 343 libraryList = libraries; | 346 libraryList = libraries; |
| 344 searchInput = query('#q'); | 347 searchInput = query('#q'); |
| 345 dropdown = query('#drop-down'); | 348 dropdown = query('#drop-down'); |
| 346 | 349 |
| 347 searchInput.on.keyDown.add(handleUpDown); | 350 searchInput.on.keyDown.add(handleUpDown); |
| 348 searchInput.on.keyUp.add(updateDropDown); | 351 searchInput.on.keyUp.add(updateDropDown); |
| 349 searchInput.on.change.add(updateDropDown); | 352 searchInput.on.change.add(updateDropDown); |
| 350 searchInput.on.reset.add(updateDropDown); | 353 searchInput.on.reset.add(updateDropDown); |
| 351 searchInput.on.focus.add((event) => showDropDown()); | 354 searchInput.on.focus.add((event) => showDropDown()); |
| 352 searchInput.on.blur.add((event) => hideDropDown()); | 355 searchInput.on.blur.add((event) => hideDropDown()); |
| 353 } | 356 } |
| OLD | NEW |