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