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

Side by Side Diff: chrome/browser/resources/md_bookmarks/toast_manager.js

Issue 2917003003: [MD Bookmarks] Support elision of bookmark names in the bookmark toast. (Closed)
Patch Set: fix multiline Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Element which shows toasts. 6 * @fileoverview Element which shows toasts.
7 */ 7 */
8 cr.define('bookmarks', function() { 8 cr.define('bookmarks', function() {
9 9
10 var ToastManager = Polymer({ 10 var ToastManager = Polymer({
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 /** @override */ 44 /** @override */
45 detached: function() { 45 detached: function() {
46 ToastManager.instance_ = null; 46 ToastManager.instance_ = null;
47 }, 47 },
48 48
49 /** 49 /**
50 * @param {string} label The label to display inside the toast. 50 * @param {string} label The label to display inside the toast.
51 * @param {boolean} showUndo Whether the undo button should be shown. 51 * @param {boolean} showUndo Whether the undo button should be shown.
52 */ 52 */
53 show: function(label, showUndo) { 53 show: function(label, showUndo) {
54 this.$.content.textContent = label;
55 this.showInternal_(showUndo);
56 },
57
58 /**
59 * Shows the toast, making certain text fragments collapsible.
60 * @param {!Array<!{value: string, collapsible: boolean}>} pieces
61 * @param {boolean} showUndo Whether the undo button should be shown.
62 */
63 showForStringPieces: function(pieces, showUndo) {
64 var content = this.$.content;
65 content.textContent = '';
66 pieces.forEach(function(p) {
67 if (p.value.length == 0)
68 return;
69
70 var span = document.createElement('span');
71 span.textContent = p.value;
72 if (p.collapsible)
73 span.classList.add('collapsible');
74
75 content.appendChild(span);
76 });
77
78 this.showInternal_(showUndo);
79 },
80
81 /**
82 * @param {boolean} showUndo Whether the undo button should be shown.
83 * @private
84 */
85 showInternal_: function(showUndo) {
54 this.open_ = true; 86 this.open_ = true;
55 // TODO(calamity): Support collapsing of long bookmark names in label.
56 this.$.content.textContent = label;
57 this.showUndo_ = showUndo; 87 this.showUndo_ = showUndo;
58 88
59 if (!this.duration) 89 if (!this.duration)
60 return; 90 return;
61 91
62 if (this.hideTimeout_ != null) { 92 if (this.hideTimeout_ != null) {
63 this.clearTimeout_(this.hideTimeout_); 93 this.clearTimeout_(this.hideTimeout_);
64 this.hideTimeout_ = null; 94 this.hideTimeout_ = null;
65 } 95 }
66 96
(...skipping 19 matching lines...) Expand all
86 116
87 /** @return {!bookmarks.ToastManager} */ 117 /** @return {!bookmarks.ToastManager} */
88 ToastManager.getInstance = function() { 118 ToastManager.getInstance = function() {
89 return assert(ToastManager.instance_); 119 return assert(ToastManager.instance_);
90 }; 120 };
91 121
92 return { 122 return {
93 ToastManager: ToastManager, 123 ToastManager: ToastManager,
94 }; 124 };
95 }); 125 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_bookmarks/toast_manager.html ('k') | chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698