| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:html'; | 5 import 'dart:html'; |
| 6 | 6 |
| 7 import 'package:observatory/app.dart'; | 7 import 'package:observatory/app.dart'; |
| 8 import 'package:observatory/repositories.dart'; | 8 import 'package:observatory/repositories.dart'; |
| 9 import 'package:observatory/src/elements/helpers/tag.dart'; | 9 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 10 import 'package:observatory/src/elements/shims/binding.dart'; | 10 import 'package:observatory/src/elements/shims/binding.dart'; |
| 11 import 'package:observatory/src/elements/nav/notify.dart'; | 11 import 'package:observatory/src/elements/nav/notify.dart'; |
| 12 | 12 |
| 13 @bindable | 13 @bindable |
| 14 class NavNotifyElementWrapper extends HtmlElement { | 14 class NavNotifyElementWrapper extends HtmlElement { |
| 15 static const binder = const Binder<NavNotifyElementWrapper>(const { | 15 static const binder = const Binder<NavNotifyElementWrapper>(const { |
| 16 'notifications': #notifications, 'notifyOnPause': #notifyOnPause | 16 'notifications': #notifications, 'notifyOnPause': #notifyOnPause |
| 17 }); | 17 }); |
| 18 | 18 |
| 19 static const tag = const Tag<NavNotifyElementWrapper>('nav-notify'); | 19 static const tag = const Tag<NavNotifyElementWrapper>('nav-notify'); |
| 20 | 20 |
| 21 NotificationRepository _notifications; | 21 NotificationRepository _notifications; |
| 22 bool _notifyOnPause = true; | 22 bool _notifyOnPause = true; |
| 23 |
| 23 NotificationRepository get notifications => _notifications; | 24 NotificationRepository get notifications => _notifications; |
| 24 bool get notifyOnPause => _notifyOnPause; | 25 bool get notifyOnPause => _notifyOnPause; |
| 26 |
| 25 set notifications(NotificationRepository value) { | 27 set notifications(NotificationRepository value) { |
| 26 _notifications = value; render(); | 28 _notifications = value; |
| 29 render(); |
| 27 } | 30 } |
| 28 set notifyOnPause(bool value) { | 31 set notifyOnPause(bool value) { |
| 29 _notifyOnPause = value; render(); | 32 _notifyOnPause = value; |
| 33 render(); |
| 30 } | 34 } |
| 31 | 35 |
| 32 NavNotifyElementWrapper.created() : super.created() { | 36 NavNotifyElementWrapper.created() : super.created() { |
| 33 binder.registerCallback(this); | 37 binder.registerCallback(this); |
| 34 createShadowRoot(); | 38 createShadowRoot(); |
| 35 render(); | 39 render(); |
| 36 } | 40 } |
| 37 | 41 |
| 38 @override | 42 @override |
| 39 void attached() { | 43 void attached() { |
| 40 super.attached(); | 44 super.attached(); |
| 41 render(); | 45 render(); |
| 42 } | 46 } |
| 43 | 47 |
| 44 void render() { | 48 void render() { |
| 45 shadowRoot.children = []; | 49 shadowRoot.children = []; |
| 46 if (_notifications == null) return; | 50 if (_notifications == null) { |
| 51 return; |
| 52 } |
| 47 | 53 |
| 48 shadowRoot.children = [ | 54 shadowRoot.children = [ |
| 49 new StyleElement() | 55 new StyleElement() |
| 50 ..text = '''nav-notify-wrapped > div { | 56 ..text = '''nav-notify-wrapped > div { |
| 51 float: right; | 57 float: right; |
| 52 } | 58 } |
| 53 nav-notify-wrapped > div > div { | 59 nav-notify-wrapped > div > div { |
| 54 display: block; | 60 display: block; |
| 55 position: absolute; | 61 position: absolute; |
| 56 top: 98%; | 62 top: 98%; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 122 } |
| 117 | 123 |
| 118 nav-exception > div > button:hover, nav-event > div > button:hover { | 124 nav-exception > div > button:hover, nav-event > div > button:hover { |
| 119 background: rgba(255,255,255,0.5); | 125 background: rgba(255,255,255,0.5); |
| 120 }''', | 126 }''', |
| 121 new NavNotifyElement(_notifications, notifyOnPause: notifyOnPause, | 127 new NavNotifyElement(_notifications, notifyOnPause: notifyOnPause, |
| 122 queue: ObservatoryApplication.app.queue) | 128 queue: ObservatoryApplication.app.queue) |
| 123 ]; | 129 ]; |
| 124 } | 130 } |
| 125 } | 131 } |
| OLD | NEW |