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 bool get qualified => _qualified; |
| 25 ServiceFunction get ref => _function; |
| 26 void set qualified(bool qualified) { _qualified = qualified; render(); } |
| 27 void set ref(ServiceFunction ref) { _function = ref; render(); } |
| 28 |
| 29 FunctionRefElementWrapper.created() : super.created() { |
| 30 binder.registerCallback(this); |
| 31 createShadowRoot(); |
| 32 render(); |
| 33 } |
| 34 |
| 35 @override |
| 36 void attached() { |
| 37 super.attached(); |
| 38 render(); |
| 39 } |
| 40 |
| 41 void render() { |
| 42 shadowRoot.children = []; |
| 43 if (ref == null) return; |
| 44 |
| 45 shadowRoot.children = [ |
| 46 new StyleElement() |
| 47 ..text = ''' |
| 48 function-ref-wrapped > a[href]:hover { |
| 49 text-decoration: underline; |
| 50 } |
| 51 function-ref-wrapped > a[href] { |
| 52 color: #0489c3; |
| 53 text-decoration: none; |
| 54 }''', |
| 55 new FunctionRefElement(_function.isolate, _function, qualified: qualified, |
| 56 queue: ObservatoryApplication.app.queue) |
| 57 ]; |
| 58 } |
| 59 } |
OLD | NEW |