| 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.type; | 5 library web.type; |
| 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/location.dart'; |
| 9 import 'package:dartdoc_viewer/search.dart' show searchIndex; | 10 import 'package:dartdoc_viewer/search.dart' show searchIndex; |
| 10 import 'package:polymer/polymer.dart'; | 11 import 'package:polymer/polymer.dart'; |
| 11 | 12 |
| 12 // TODO(jmesserly): just extend HtmlElement? | 13 // TODO(jmesserly): just extend HtmlElement? |
| 13 @CustomTag('dartdoc-type') | 14 @CustomTag('dartdoc-type') |
| 14 class TypeElement extends PolymerElement { | 15 class TypeElement extends PolymerElement { |
| 15 @published NestedType type; | 16 @published NestedType type; |
| 16 | 17 |
| 17 Element _child; | 18 Element _child; |
| 18 | 19 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 if (type == null || type.isDynamic) return; | 31 if (type == null || type.isDynamic) return; |
| 31 this.append(_child = createInner(type)); | 32 this.append(_child = createInner(type)); |
| 32 } | 33 } |
| 33 | 34 |
| 34 /// Creates an HTML element for a parameterized type. | 35 /// Creates an HTML element for a parameterized type. |
| 35 static Element createInner(NestedType type) { | 36 static Element createInner(NestedType type) { |
| 36 var span = new SpanElement()..classes.add('type'); | 37 var span = new SpanElement()..classes.add('type'); |
| 37 if (searchIndex.map.containsKey(type.outer.qualifiedName)) { | 38 if (searchIndex.map.containsKey(type.outer.qualifiedName)) { |
| 38 var outer = new AnchorElement() | 39 var outer = new AnchorElement() |
| 39 ..text = type.outer.simpleType | 40 ..text = type.outer.simpleType |
| 40 ..href = '#${type.outer.location}'; | 41 ..href = locationPrefixed(type.outer.location); |
| 41 span.append(outer); | 42 span.append(outer); |
| 42 } else { | 43 } else { |
| 43 span.appendText(type.outer.simpleType); | 44 span.appendText(type.outer.simpleType); |
| 44 } | 45 } |
| 45 if (type.inner.isNotEmpty) { | 46 if (type.inner.isNotEmpty) { |
| 46 span.appendText('<'); | 47 span.appendText('<'); |
| 47 for (var element in type.inner) { | 48 for (var element in type.inner) { |
| 48 if (element != type.inner.first) span.appendText(', '); | 49 if (element != type.inner.first) span.appendText(', '); |
| 49 span.append(createInner(element)); | 50 span.append(createInner(element)); |
| 50 } | 51 } |
| 51 span.appendText('>'); | 52 span.appendText('>'); |
| 52 } | 53 } |
| 53 return span; | 54 return span; |
| 54 } | 55 } |
| 55 } | 56 } |
| OLD | NEW |