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/src/elements/helpers/tag.dart'; | |
9 import 'package:observatory/src/elements/shims/binding.dart'; | |
10 import 'package:observatory/src/elements/nav/top_menu.dart'; | |
11 | |
12 @bindable | |
13 class NavTopMenuElementWrapper extends HtmlElement { | |
14 static const binder = const Binder<NavTopMenuElementWrapper>(const { | |
15 'last': #last | |
16 }); | |
17 | |
18 static const tag = const Tag<NavTopMenuElementWrapper>('top-nav-menu'); | |
19 | |
20 bool _last = false; | |
21 | |
22 bool get last => _last; | |
23 | |
24 set last(bool value) { | |
25 _last = value; | |
26 render(); | |
27 } | |
28 | |
29 NavTopMenuElementWrapper.created() : super.created() { | |
30 binder.registerCallback(this); | |
31 _last = _getBoolAttribute('last'); | |
32 createShadowRoot(); | |
33 render(); | |
34 } | |
35 | |
36 @override | |
37 void attached() { | |
38 super.attached(); | |
39 render(); | |
40 } | |
41 | |
42 void render() { | |
43 shadowRoot.children = []; | |
44 if (_last == null) { | |
45 return; | |
46 } | |
47 | |
48 shadowRoot.children = [ | |
49 new NavTopMenuElement(last: last, queue: ObservatoryApplication.app.queue) | |
50 ..children = [new ContentElement()] | |
51 ]; | |
52 } | |
53 | |
54 bool _getBoolAttribute(String name) { | |
55 final String value = getAttribute(name); | |
56 return !(value == null || value == 'false'); | |
57 } | |
58 } | |
OLD | NEW |