| 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..039015f28d7a08041070f7205fceabed2dfb123c
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/md_bookmarks/toast_manager.js
|
| @@ -0,0 +1,62 @@
|
| +// 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,
|
| + },
|
| +
|
| + /** @override */
|
| + attached: function() {
|
| + assert(ToastManager.instance_ == null);
|
| + ToastManager.instance_ = this;
|
| + },
|
| +
|
| + /** @override */
|
| + 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} */
|
| + ToastManager.instance_ = null;
|
| +
|
| + /** @return {!bookmarks.ToastManager} */
|
| + ToastManager.getInstance = function() {
|
| + return assert(ToastManager.instance_);
|
| + };
|
| +
|
| + return {
|
| + ToastManager: ToastManager,
|
| + };
|
| +});
|
|
|