OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview Element which shows toasts. |
| 7 */ |
| 8 cr.define('bookmarks', function() { |
| 9 |
| 10 var ToastManager = Polymer({ |
| 11 is: 'bookmarks-toast-manager', |
| 12 |
| 13 properties: { |
| 14 /** @private */ |
| 15 showUndo_: Boolean, |
| 16 }, |
| 17 |
| 18 /** @override */ |
| 19 attached: function() { |
| 20 assert(ToastManager.instance_ == null); |
| 21 ToastManager.instance_ = this; |
| 22 }, |
| 23 |
| 24 /** @override */ |
| 25 detached: function() { |
| 26 ToastManager.instance_ = null; |
| 27 }, |
| 28 |
| 29 /** |
| 30 * @param {string} label The label to display inside the toast. |
| 31 * @param {boolean} showUndo Whether the undo button should be shown. |
| 32 */ |
| 33 show: function(label, showUndo) { |
| 34 this.$.toast.open = true; |
| 35 // TODO(calamity): Support collapsing of long bookmark names in label. |
| 36 this.$.content.textContent = label; |
| 37 this.showUndo_ = showUndo; |
| 38 }, |
| 39 |
| 40 hide: function() { |
| 41 this.$.toast.open = false; |
| 42 }, |
| 43 |
| 44 /** @private */ |
| 45 onUndoTap_: function() { |
| 46 // Will hide the toast. |
| 47 this.fire('command-undo'); |
| 48 }, |
| 49 }); |
| 50 |
| 51 /** @private {?bookmarks.ToastManager} */ |
| 52 ToastManager.instance_ = null; |
| 53 |
| 54 /** @return {!bookmarks.ToastManager} */ |
| 55 ToastManager.getInstance = function() { |
| 56 return assert(ToastManager.instance_); |
| 57 }; |
| 58 |
| 59 return { |
| 60 ToastManager: ToastManager, |
| 61 }; |
| 62 }); |
OLD | NEW |