OLD | NEW |
| (Empty) |
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 | |
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'; | |
9 import 'package:observatory/service_common.dart'; | |
10 import 'package:observatory/src/elements/helpers/tag.dart'; | |
11 import 'package:observatory/src/elements/shims/binding.dart'; | |
12 import 'package:observatory/src/elements/nav/vm_menu.dart'; | |
13 | |
14 @bindable | |
15 class NavVMMenuElementWrapper extends HtmlElement { | |
16 static const binder = const Binder<NavVMMenuElementWrapper>(const { | |
17 'last': #last, 'vm': #vm | |
18 }); | |
19 | |
20 static const tag = const Tag<NavVMMenuElementWrapper>('vm-nav-menu'); | |
21 | |
22 bool _last = false; | |
23 VM _vm; | |
24 | |
25 bool get last => _last; | |
26 VM get vm => _vm; | |
27 | |
28 set last(bool value) { | |
29 _last = value; | |
30 render(); } | |
31 set vm(VM value) { | |
32 _vm = value; | |
33 render(); | |
34 } | |
35 | |
36 NavVMMenuElementWrapper.created() : super.created() { | |
37 binder.registerCallback(this); | |
38 _last = _getBoolAttribute('last'); | |
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 (_vm == null || _last == null) { | |
52 return; | |
53 } | |
54 | |
55 shadowRoot.children = [ | |
56 new NavVMMenuElement(vm, app.events, last: last, | |
57 queue: app.queue) | |
58 ..children = [new ContentElement()] | |
59 ]; | |
60 } | |
61 | |
62 ObservatoryApplication get app => ObservatoryApplication.app; | |
63 | |
64 bool _getBoolAttribute(String name) { | |
65 final String value = getAttribute(name); | |
66 return !(value == null || value == 'false'); | |
67 } | |
68 } | |
OLD | NEW |