OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import 'dart:html'; | |
6 | |
7 import 'package:observatory/app.dart'; | |
8 import 'package:observatory/service_html.dart' show Code; | |
9 import 'package:observatory/src/elements/code_ref.dart'; | |
10 import 'package:observatory/src/elements/helpers/tag.dart'; | |
11 import 'package:observatory/src/elements/shims/binding.dart'; | |
12 | |
13 @bindable | |
14 class CodeRefElementWrapper extends HtmlElement { | |
15 | |
16 static const binder = const Binder<CodeRefElementWrapper>(const { | |
17 'ref': #ref | |
18 }); | |
19 | |
20 static const tag = const Tag<CodeRefElementWrapper>('code-ref'); | |
21 | |
22 Code _code; | |
23 | |
24 Code get ref => _code; | |
25 | |
26 void set ref(Code value) { | |
27 _code = value; | |
28 render(); | |
29 } | |
30 | |
31 CodeRefElementWrapper.created() : super.created() { | |
32 binder.registerCallback(this); | |
33 createShadowRoot(); | |
34 render(); | |
35 } | |
36 | |
37 @override | |
38 void attached() { | |
39 super.attached(); | |
40 render(); | |
41 } | |
42 | |
43 void render() { | |
44 shadowRoot.children = []; | |
45 if (ref == null) { | |
46 return; | |
47 } | |
48 | |
49 shadowRoot.children = [ | |
50 new StyleElement() | |
51 ..text = ''' | |
52 code-ref-wrapped > a[href]:hover { | |
53 text-decoration: underline; | |
54 } | |
55 code-ref-wrapped > a[href] { | |
56 color: #0489c3; | |
57 text-decoration: none; | |
58 }''', | |
59 new CodeRefElement(_code.isolate, _code, | |
60 queue: ObservatoryApplication.app.queue) | |
61 ]; | |
62 } | |
63 } | |
OLD | NEW |