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

Unified Diff: chrome/browser/resources/md_bookmarks/toast_manager.js

Issue 2898303004: [MD Bookmarks] Add toasts. (Closed)
Patch Set: roll our own toast Created 3 years, 7 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: chrome/browser/resources/md_bookmarks/toast_manager.js
diff --git a/chrome/browser/resources/md_bookmarks/toast_manager.js b/chrome/browser/resources/md_bookmarks/toast_manager.js
new file mode 100644
index 0000000000000000000000000000000000000000..1fdaa68d9e7a45891b70e5dbd72905f5693e8f0b
--- /dev/null
+++ b/chrome/browser/resources/md_bookmarks/toast_manager.js
@@ -0,0 +1,60 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview Element which shows toasts.
+ */
+cr.define('bookmarks', function() {
+
+ var ToastManager = Polymer({
+ is: 'bookmarks-toast-manager',
+
+ properties: {
+ /** @private */
+ showUndo_: Boolean,
+ },
+
+ attached: function() {
dpapad 2017/05/31 17:52:38 @override
calamity 2017/06/01 06:40:08 Done.
+ assert(ToastManager.instance_ == null);
+ ToastManager.instance_ = this;
+ },
+
+ detached: function() {
+ ToastManager.instance_ = null;
+ },
+
+ /**
+ * @param {string} label The label to display inside the toast.
+ * @param {boolean} showUndo Whether the undo button should be shown.
+ */
+ show: function(label, showUndo) {
+ this.$.toast.open = true;
+ // TODO(calamity): Support collapsing of long bookmark names in label.
+ this.$.content.textContent = label;
+ this.showUndo_ = showUndo;
+ },
+
+ hide: function() {
+ this.$.toast.open = false;
+ },
+
+ /** @private */
+ onUndoTap_: function() {
+ // Will hide the toast.
+ this.fire('command-undo');
+ },
+ });
+
+ /** @private {bookmarks.ToastManager} */
dpapad 2017/05/31 17:52:38 ?bookmarks.ToastManager
calamity 2017/06/01 06:40:08 Done.
+ ToastManager.instance_ = null;
+
+ /** @return {!bookmarks.ToastManager} */
+ ToastManager.getInstance = function() {
+ return assert(ToastManager.instance_);
+ };
+
+ return {
+ ToastManager: ToastManager,
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698