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

Side by Side Diff: client/web/search.dart

Issue 149573008: Factor out the anchor prefix to easily allow switching to #! (Closed) Base URL: https://github.com/dart-lang/dartdoc-viewer.git@master
Patch Set: Fixes from review Created 6 years, 10 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
« no previous file with comments | « client/web/parameters.dart ('k') | client/web/type.dart » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library web.search; 5 library web.search;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'app.dart'; 9 import 'app.dart';
10 import 'package:dartdoc_viewer/item.dart'; 10 import 'package:dartdoc_viewer/item.dart';
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 var parentRefId = target.parent.dataset['ref-id']; 83 var parentRefId = target.parent.dataset['ref-id'];
84 if (refId == null) refId = parentRefId; 84 if (refId == null) refId = parentRefId;
85 } 85 }
86 if (refId == null || refId.isEmpty) { 86 if (refId == null || refId.isEmpty) {
87 // If nothing is focused, use the first search result. 87 // If nothing is focused, use the first search result.
88 refId = results.first.element; 88 refId = results.first.element;
89 } 89 }
90 var newLocation = new LinkableType(refId).location; 90 var newLocation = new LinkableType(refId).location;
91 var encoded = Uri.encodeFull(newLocation); 91 var encoded = Uri.encodeFull(newLocation);
92 viewer.handleLink(encoded); 92 viewer.handleLink(encoded);
93 window.history.pushState("#$encoded", viewer.title, "#$encoded"); 93 window.history.pushState(locationPrefixed(encoded),
94 viewer.title, locationPrefixed(encoded));
94 searchQuery = ""; 95 searchQuery = "";
95 results.clear(); 96 results.clear();
96 } 97 }
97 98
98 void enteredView() { 99 void enteredView() {
99 super.enteredView(); 100 super.enteredView();
100 101
101 registerObserver('onfocus', Element.focusEvent 102 registerObserver('onfocus', Element.focusEvent
102 .forTarget(this, useCapture: true).listen(onFocusCallback)); 103 .forTarget(this, useCapture: true).listen(onFocusCallback));
103 104
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 event.preventDefault(); 144 event.preventDefault();
144 } else if (event.keyCode == KeyCode.ESC) { 145 } else if (event.keyCode == KeyCode.ESC) {
145 searchQuery = ""; 146 searchQuery = "";
146 searchBox.value = ''; 147 searchBox.value = '';
147 event.preventDefault(); 148 event.preventDefault();
148 } 149 }
149 } 150 }
150 151
151 get searchBox => shadowRoot.querySelector('#q'); 152 get searchBox => shadowRoot.querySelector('#q');
152 } 153 }
OLDNEW
« no previous file with comments | « client/web/parameters.dart ('k') | client/web/type.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698