Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1172)

Unified Diff: runtime/observatory/lib/src/elements/nav/refresh_wrapper.dart

Issue 2161633005: Converted Observatory nav-refresh element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Final Merge Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/elements/nav/refresh_wrapper.dart
diff --git a/runtime/observatory/lib/src/elements/nav/refresh_wrapper.dart b/runtime/observatory/lib/src/elements/nav/refresh_wrapper.dart
new file mode 100644
index 0000000000000000000000000000000000000000..dcd169659f2ee00cfb2b0ce8fac785084260951b
--- /dev/null
+++ b/runtime/observatory/lib/src/elements/nav/refresh_wrapper.dart
@@ -0,0 +1,78 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:html';
+import 'dart:async';
+
+import 'package:observatory/app.dart';
+import 'package:observatory/src/elements/helpers/tag.dart';
+import 'package:observatory/src/elements/shims/binding.dart';
+import 'package:observatory/src/elements/nav/refresh.dart';
+
+class NavRefreshElementWrapper extends HtmlElement {
+ static final binder = new Binder<NavRefreshElementWrapper>(
+ const [const Binding('callback'), const Binding('label')]);
+
+ static const tag = const Tag<NavRefreshElementWrapper>('nav-refresh');
+
+ Function _callback;
+ String _label;
+ Function get callback => _callback;
+ String get label => _label;
+ set callback(Function value) {
+ _callback = value; render();
+ }
+ set label(String value) {
+ _label = value; render();
+ }
+
+ NavRefreshElementWrapper.created() : super.created() {
+ binder.registerCallback(this);
+ _label = getAttribute('label') ?? 'Refresh';
+ createShadowRoot();
+ render();
+ }
+
+ @override
+ void attached() {
+ super.attached();
+ render();
+ }
+
+ void render() {
+ shadowRoot.children = [];
+ if (_callback == null || _label == null) return;
+
+ shadowRoot.children = [
+ new StyleElement()
+ ..text = '''nav-refresh-wrapped > li > button {
+ color: #000;
+ margin: 3px;
+ padding: 8px;
+ border-width: 2px;
+ line-height: 13px;
+ font: 400 13px 'Montserrat', sans-serif;
+ }
+ nav-refresh-wrapped > li > button[disabled] {
+ color: #aaa;
+ cursor: wait;
+ }
+ nav-refresh-wrapped > li {
+ float: right;
+ margin: 0;
+ }''',
+ new NavRefreshElement(label: _label,
+ queue: ObservatoryApplication.app.queue)
+ ..onRefresh.listen((event) async{
+ event.element.disabled = true;
+ try {
+ var future = callback();
+ if (future is Future) await future;
+ } finally {
+ event.element.disabled = false;
+ }
+ })
+ ];
+ }
+}
« no previous file with comments | « runtime/observatory/lib/src/elements/nav/refresh.dart ('k') | runtime/observatory/lib/src/elements/nav_bar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698