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 attached: function() { | |
dpapad
2017/05/31 17:52:38
@override
calamity
2017/06/01 06:40:08
Done.
| |
19 assert(ToastManager.instance_ == null); | |
20 ToastManager.instance_ = this; | |
21 }, | |
22 | |
23 detached: function() { | |
24 ToastManager.instance_ = null; | |
25 }, | |
26 | |
27 /** | |
28 * @param {string} label The label to display inside the toast. | |
29 * @param {boolean} showUndo Whether the undo button should be shown. | |
30 */ | |
31 show: function(label, showUndo) { | |
32 this.$.toast.open = true; | |
33 // TODO(calamity): Support collapsing of long bookmark names in label. | |
34 this.$.content.textContent = label; | |
35 this.showUndo_ = showUndo; | |
36 }, | |
37 | |
38 hide: function() { | |
39 this.$.toast.open = false; | |
40 }, | |
41 | |
42 /** @private */ | |
43 onUndoTap_: function() { | |
44 // Will hide the toast. | |
45 this.fire('command-undo'); | |
46 }, | |
47 }); | |
48 | |
49 /** @private {bookmarks.ToastManager} */ | |
dpapad
2017/05/31 17:52:38
?bookmarks.ToastManager
calamity
2017/06/01 06:40:08
Done.
| |
50 ToastManager.instance_ = null; | |
51 | |
52 /** @return {!bookmarks.ToastManager} */ | |
53 ToastManager.getInstance = function() { | |
54 return assert(ToastManager.instance_); | |
55 }; | |
56 | |
57 return { | |
58 ToastManager: ToastManager, | |
59 }; | |
60 }); | |
OLD | NEW |