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

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

Issue 11036058: Show top-level members (again). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comment. 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 | « pkg/dartdoc/lib/dartdoc.dart ('k') | 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;
326
327 /** Activate search on Ctrl+3 and S. */ 325 /** Activate search on Ctrl+3 and S. */
328 void shortcutHandler(KeyboardEvent event) { 326 void shortcutHandler(KeyboardEvent event) {
329 if (event.keyCode == 0x33/* 3 */ && event.ctrlKey) { 327 if (event.keyCode == 0x33/* 3 */ && event.ctrlKey) {
330 searchInput.focus(); 328 searchInput.focus();
331 event.preventDefault(); 329 event.preventDefault();
332 } else if (!searchInputFocused && event.keyCode == 0x53/* S */) { 330 } else if (event.target != searchInput && event.keyCode == 0x53/* S */) {
333 // Avoid preventing writing 's' in the search input. 331 // Allow writing 's' in the search input.
334 searchInput.focus(); 332 searchInput.focus();
335 event.preventDefault(); 333 event.preventDefault();
336 } 334 }
337 } 335 }
338 336
339 /** 337 /**
340 * Setup window shortcuts. 338 * Setup window shortcuts.
341 */ 339 */
342 void setupShortcuts() { 340 void setupShortcuts() {
343 window.on.keyDown.add(shortcutHandler); 341 window.on.keyDown.add(shortcutHandler);
344 searchInput = query('#q');
345 searchInput.on.focus.add((event) => searchInputFocused = true);
346 searchInput.on.blur.add((event) => searchInputFocused = false);
347 } 342 }
348 343
349 /** Setup search hooks. */ 344 /** Setup search hooks. */
350 void setupSearch(var libraries) { 345 void setupSearch(var libraries) {
351 libraryList = libraries; 346 libraryList = libraries;
352 searchInput = query('#q'); 347 searchInput = query('#q');
353 dropdown = query('#drop-down'); 348 dropdown = query('#drop-down');
354 349
355 searchInput.on.keyDown.add(handleUpDown); 350 searchInput.on.keyDown.add(handleUpDown);
356 searchInput.on.keyUp.add(updateDropDown); 351 searchInput.on.keyUp.add(updateDropDown);
357 searchInput.on.change.add(updateDropDown); 352 searchInput.on.change.add(updateDropDown);
358 searchInput.on.reset.add(updateDropDown); 353 searchInput.on.reset.add(updateDropDown);
359 searchInput.on.focus.add((event) => showDropDown()); 354 searchInput.on.focus.add((event) => showDropDown());
360 searchInput.on.blur.add((event) => hideDropDown()); 355 searchInput.on.blur.add((event) => hideDropDown());
361 } 356 }
OLDNEW
« no previous file with comments | « pkg/dartdoc/lib/dartdoc.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698