OLD | NEW |
| (Empty) |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 import 'dart:html'; | |
6 import 'dart:async'; | |
7 | |
8 import 'package:observatory/app.dart'; | |
9 import 'package:observatory/repositories.dart' show ScriptRepository; | |
10 import 'package:observatory/service_html.dart' show SourceLocation; | |
11 import 'package:observatory/src/elements/source_link.dart'; | |
12 import 'package:observatory/src/elements/helpers/tag.dart'; | |
13 import 'package:observatory/src/elements/shims/binding.dart'; | |
14 | |
15 @bindable | |
16 class SourceLinkElementWrapper extends HtmlElement { | |
17 static const binder = const Binder<SourceLinkElementWrapper>(const { | |
18 'location' : #location | |
19 }); | |
20 | |
21 static const tag = const Tag<SourceLinkElementWrapper>('source-link'); | |
22 | |
23 SourceLocation _location; | |
24 SourceLocation get location => location; | |
25 set location(SourceLocation value) { | |
26 _location = value; | |
27 render(); | |
28 } | |
29 | |
30 SourceLinkElementWrapper.created() : super.created() { | |
31 binder.registerCallback(this); | |
32 createShadowRoot(); | |
33 render(); | |
34 } | |
35 | |
36 @override | |
37 void attached() { | |
38 super.attached(); | |
39 render(); | |
40 } | |
41 | |
42 Future render() async { | |
43 shadowRoot.children = []; | |
44 if (_location == null) { | |
45 return; | |
46 } | |
47 | |
48 shadowRoot.children = [ | |
49 new StyleElement() | |
50 ..text = ''' | |
51 source-link-wrapped > a[href]:hover { | |
52 text-decoration: underline; | |
53 } | |
54 source-link-wrapped > a[href] { | |
55 color: #0489c3; | |
56 text-decoration: none; | |
57 }''', | |
58 new SourceLinkElement(_location.isolate, _location, | |
59 new ScriptRepository(), | |
60 queue: ObservatoryApplication.app.queue) | |
61 ]; | |
62 } | |
63 } | |
OLD | NEW |