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/repositories.dart'; |
| 9 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 10 import 'package:observatory/src/elements/shims/binding.dart'; |
| 11 import 'package:observatory/src/elements/nav/notify.dart'; |
| 12 |
| 13 class NavNotifyElementWrapper extends HtmlElement { |
| 14 static final binder = new Binder<NavNotifyElementWrapper>( |
| 15 const [const Binding('notifications'), const Binding('notifyOnPause')]); |
| 16 |
| 17 static const tag = const Tag<NavNotifyElementWrapper>('nav-notify'); |
| 18 |
| 19 NotificationRepository _notifications; |
| 20 bool _notifyOnPause = true; |
| 21 NotificationRepository get notifications => _notifications; |
| 22 bool get notifyOnPause => _notifyOnPause; |
| 23 set notifications(NotificationRepository notifications) { |
| 24 _notifications = notifications; render(); |
| 25 } |
| 26 set notifyOnPause(bool notifyOnPause) { |
| 27 _notifyOnPause = notifyOnPause; render(); |
| 28 } |
| 29 |
| 30 NavNotifyElementWrapper.created() : super.created() { |
| 31 binder.registerCallback(this); |
| 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 (_notifications == null) return; |
| 45 |
| 46 shadowRoot.children = [ |
| 47 new StyleElement() |
| 48 ..text = '@import "packages/observatory/src/elements/css/shared.css";', |
| 49 new NavNotifyElement(_notifications, notifyOnPause: notifyOnPause, |
| 50 queue: ObservatoryApplication.app.queue) |
| 51 ]; |
| 52 } |
| 53 } |
OLD | NEW |