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