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'; |
11 import 'package:dartdoc_viewer/search.dart'; | 11 import 'package:dartdoc_viewer/search.dart'; |
12 import 'package:dartdoc_viewer/location.dart'; | 12 import 'package:dartdoc_viewer/location.dart'; |
13 import 'package:polymer/polymer.dart'; | 13 import 'package:polymer/polymer.dart'; |
14 | 14 |
15 /** | 15 /** |
16 * Component implementing the Dartdoc_viewer search. | 16 * Component implementing the Dartdoc_viewer search. |
17 */ | 17 */ |
18 @CustomTag("search-box") | 18 @CustomTag("search-box") |
19 class Search extends PolymerElement { | 19 class Search extends PolymerElement { |
20 @published String searchQuery; | 20 @published String searchQuery = ''; |
21 | 21 |
22 @observable bool isFocused = false; | 22 @observable bool isFocused = false; |
23 @observable ObservableList<SearchResult> results = toObservable([]); | 23 @observable ObservableList<SearchResult> results = toObservable([]); |
24 @observable String dropdownOpen; | 24 @observable String dropdownOpen; |
25 int currentIndex = -1; | 25 int currentIndex = -1; |
26 | 26 |
27 Search.created() : super.created(); | 27 Search.created() : super.created(); |
28 | 28 |
29 get syntax => defaultSyntax; | 29 get syntax => defaultSyntax; |
30 get applyAuthorStyles => true; | 30 get applyAuthorStyles => true; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 event.preventDefault(); | 143 event.preventDefault(); |
144 } else if (event.keyCode == KeyCode.ESC) { | 144 } else if (event.keyCode == KeyCode.ESC) { |
145 searchQuery = ""; | 145 searchQuery = ""; |
146 searchBox.value = ''; | 146 searchBox.value = ''; |
147 event.preventDefault(); | 147 event.preventDefault(); |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 get searchBox => shadowRoot.querySelector('#q'); | 151 get searchBox => shadowRoot.querySelector('#q'); |
152 } | 152 } |
OLD | NEW |