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.dart' show ServiceFunction; | |
9 import 'package:observatory/src/elements/function_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 FunctionRefElementWrapper extends HtmlElement { | |
15 | |
16 static const binder = const Binder<FunctionRefElementWrapper>(const { | |
17 'ref': #ref, 'qualified': #qualified | |
18 }); | |
19 | |
20 static const tag = const Tag<FunctionRefElementWrapper>('function-ref'); | |
21 | |
22 bool _qualified = true; | |
23 ServiceFunction _function; | |
24 | |
25 bool get qualified => _qualified; | |
26 ServiceFunction get ref => _function; | |
27 | |
28 void set qualified(bool value) { | |
29 _qualified = value; | |
30 render(); | |
31 } | |
32 void set ref(ServiceFunction value) { | |
33 _function = value; | |
34 render(); | |
35 } | |
36 | |
37 FunctionRefElementWrapper.created() : super.created() { | |
38 binder.registerCallback(this); | |
39 createShadowRoot(); | |
40 render(); | |
41 } | |
42 | |
43 @override | |
44 void attached() { | |
45 super.attached(); | |
46 render(); | |
47 } | |
48 | |
49 void render() { | |
50 shadowRoot.children = []; | |
51 if (ref == null) { | |
52 return; | |
53 } | |
54 | |
55 shadowRoot.children = [ | |
56 new StyleElement() | |
57 ..text = ''' | |
58 class-ref-wrapped > a[href]:hover, | |
59 function-ref-wrapped > a[href]:hover { | |
60 text-decoration: underline; | |
61 } | |
62 class-ref-wrapped > a[href], | |
63 function-ref-wrapped > a[href] { | |
64 color: #0489c3; | |
65 text-decoration: none; | |
66 }''', | |
67 new FunctionRefElement(_function.isolate, _function, qualified: qualified, | |
68 queue: ObservatoryApplication.app.queue) | |
69 ]; | |
70 } | |
71 } | |
OLD | NEW |