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