OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |