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

Side by Side Diff: client/web/link.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/library-panel.html ('k') | client/web/main.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.link; 5 library web.link;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'package:dartdoc_viewer/item.dart'; 8 import 'package:dartdoc_viewer/item.dart';
9 import 'package:dartdoc_viewer/search.dart' show searchIndex; 9 import 'package:dartdoc_viewer/search.dart' show searchIndex;
10 import 'package:polymer/polymer.dart'; 10 import 'package:polymer/polymer.dart';
11 import 'package:dartdoc_viewer/location.dart';
11 12
12 // TODO(jmesserly): just extend HtmlElement? 13 // TODO(jmesserly): just extend HtmlElement?
13 @CustomTag("dartdoc-link") 14 @CustomTag("dartdoc-link")
14 class LinkElement extends PolymerElement { 15 class LinkElement extends PolymerElement {
15 @published LinkableType type; 16 @published LinkableType type;
16 17
17 LinkElement.created() : super.created(); 18 LinkElement.created() : super.created();
18 19
19 enteredView() { 20 enteredView() {
20 super.enteredView(); 21 super.enteredView();
21 searchIndex.onLoad(typeChanged); 22 searchIndex.onLoad(typeChanged);
22 } 23 }
23 24
24 void typeChanged() { 25 void typeChanged() {
25 this.children.clear(); 26 this.children.clear();
26 if (type == null) return; 27 if (type == null) return;
27 28
28 Element child; 29 Element child;
29 final location = type.loc.withoutAnchor; 30 final location = type.loc.withoutAnchor;
30 if (searchIndex.map.containsKey(location)) { 31 if (searchIndex.map.containsKey(location)) {
31 child = new AnchorElement()..href = '#${type.loc.withAnchor}'; 32 child = new AnchorElement()..href = locationPrefixed(type.loc.withAnchor);
32 } else { 33 } else {
33 child = new Element.tag('i'); 34 child = new Element.tag('i');
34 } 35 }
35 this.append(child..text = type.simpleType); 36 this.append(child..text = type.simpleType);
36 } 37 }
37 } 38 }
OLDNEW
« no previous file with comments | « client/web/library-panel.html ('k') | client/web/main.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698