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

Side by Side Diff: pkg/dartdoc/lib/src/client/dropdown.dart

Issue 11038035: Avoid capture of 's' in dartdoc search input. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | no next file » | 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) 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 /** Used to prevent hiding the drop down when it is clicked. */ 315 /** Used to prevent hiding the drop down when it is clicked. */
316 bool hideDropDownSuspend = false; 316 bool hideDropDownSuspend = false;
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 bool searchInputFocused = false;
Jennifer Messerly 2012/10/04 20:31:17 this works, but there are a few other ways that mi
Johnni Winther 2012/10/05 12:51:37 Thanks. I've put this is in https://codereview.chr
326
325 /** Activate search on Ctrl+3 and S. */ 327 /** Activate search on Ctrl+3 and S. */
326 void shortcutHandler(KeyboardEvent event) { 328 void shortcutHandler(KeyboardEvent event) {
327 if (event.keyCode == 0x33/* 3 */ && event.ctrlKey || 329 if (event.keyCode == 0x33/* 3 */ && event.ctrlKey) {
328 event.keyCode == 0x53/* S */) { 330 searchInput.focus();
331 event.preventDefault();
332 } else if (!searchInputFocused && event.keyCode == 0x53/* S */) {
333 // Avoid preventing writing 's' in the search input.
329 searchInput.focus(); 334 searchInput.focus();
330 event.preventDefault(); 335 event.preventDefault();
331 } 336 }
332 } 337 }
333 338
334 /** 339 /**
335 * Setup window shortcuts. 340 * Setup window shortcuts.
336 */ 341 */
337 void setupShortcuts() { 342 void setupShortcuts() {
338 window.on.keyDown.add(shortcutHandler); 343 window.on.keyDown.add(shortcutHandler);
344 searchInput = query('#q');
345 searchInput.on.focus.add((event) => searchInputFocused = true);
Jennifer Messerly 2012/10/04 20:31:17 with changes described above, you won't need these
Johnni Winther 2012/10/05 12:51:37 Done.
346 searchInput.on.blur.add((event) => searchInputFocused = false);
339 } 347 }
340 348
341 /** Setup search hooks. */ 349 /** Setup search hooks. */
342 void setupSearch(var libraries) { 350 void setupSearch(var libraries) {
343 libraryList = libraries; 351 libraryList = libraries;
344 searchInput = query('#q'); 352 searchInput = query('#q');
345 dropdown = query('#drop-down'); 353 dropdown = query('#drop-down');
346 354
347 searchInput.on.keyDown.add(handleUpDown); 355 searchInput.on.keyDown.add(handleUpDown);
348 searchInput.on.keyUp.add(updateDropDown); 356 searchInput.on.keyUp.add(updateDropDown);
349 searchInput.on.change.add(updateDropDown); 357 searchInput.on.change.add(updateDropDown);
350 searchInput.on.reset.add(updateDropDown); 358 searchInput.on.reset.add(updateDropDown);
351 searchInput.on.focus.add((event) => showDropDown()); 359 searchInput.on.focus.add((event) => showDropDown());
352 searchInput.on.blur.add((event) => hideDropDown()); 360 searchInput.on.blur.add((event) => hideDropDown());
353 } 361 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698