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

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

Issue 2666033002: [MD Bookmarks] Add edit folder. (Closed)
Patch Set: Add menu for folder items. Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 Polymer({ 5 Polymer({
6 is: 'bookmarks-list', 6 is: 'bookmarks-list',
7 7
8 properties: { 8 properties: {
9 /** @type {BookmarkTreeNode} */ 9 /** @type {BookmarkTreeNode} */
10 menuItem_: Object, 10 menuItem_: Object,
11 11
12 /** @type {Array<BookmarkTreeNode>} */ 12 /** @type {Array<BookmarkTreeNode>} */
13 displayedList: Array, 13 displayedList: Array,
14 14
15 searchTerm: String, 15 searchTerm: String,
16
17 hideUrlInput_: Boolean,
16 }, 18 },
17 19
18 listeners: { 20 listeners: {
19 'open-item-menu': 'onOpenItemMenu_', 21 'open-item-menu': 'onOpenItemMenu_',
20 }, 22 },
21 23
22 /** 24 /**
23 * @param {Event} e 25 * @param {Event} e
24 * @private 26 * @private
25 */ 27 */
26 onOpenItemMenu_: function(e) { 28 onOpenItemMenu_: function(e) {
27 this.menuItem_ = e.detail.item; 29 this.menuItem_ = e.detail.item;
28 var menu = /** @type {!CrActionMenuElement} */ ( 30 var menu = /** @type {!CrActionMenuElement} */ (
29 this.$.dropdown); 31 this.$.dropdown);
32 this.hideUrlInput_ = !this.menuItem_.url;
30 menu.showAt(/** @type {!Element} */ (e.detail.target)); 33 menu.showAt(/** @type {!Element} */ (e.detail.target));
31 }, 34 },
32 35
33 // TODO(jiaxi): change these dummy click event handlers later.
34 /** @private */ 36 /** @private */
35 onEditTap_: function() { 37 onEditTap_: function() {
36 this.closeDropdownMenu_(); 38 this.closeDropdownMenu_();
37 if (this.menuItem_.url) 39 this.$.editBookmark.showModal();
38 this.$.editBookmark.showModal();
39 }, 40 },
40 41
41 /** @private */ 42 /** @private */
42 onCopyURLTap_: function() { 43 onCopyURLTap_: function() {
43 var idList = [this.menuItem_.id]; 44 var idList = [this.menuItem_.id];
44 chrome.bookmarkManagerPrivate.copy(idList, function() { 45 chrome.bookmarkManagerPrivate.copy(idList, function() {
45 // TODO(jiaxi): Add toast later. 46 // TODO(jiaxi): Add toast later.
46 }); 47 });
47 this.closeDropdownMenu_(); 48 this.closeDropdownMenu_();
48 }, 49 },
49 50
50 /** @private */ 51 /** @private */
51 onDeleteTap_: function() { 52 onDeleteTap_: function() {
52 if (this.menuItem_.url) { 53 if (this.menuItem_.url) {
53 chrome.bookmarks.remove(this.menuItem_.id, function() { 54 chrome.bookmarks.remove(this.menuItem_.id, function() {
54 // TODO(jiaxi): Add toast later. 55 // TODO(jiaxi): Add toast later.
55 }.bind(this)); 56 }.bind(this));
56 } else { 57 } else {
57 chrome.bookmarks.removeTree(this.menuItem_.id, function() { 58 chrome.bookmarks.removeTree(this.menuItem_.id, function() {
58 // TODO(jiaxi): Add toast later. 59 // TODO(jiaxi): Add toast later.
59 }.bind(this)); 60 }.bind(this));
60 } 61 }
61 this.closeDropdownMenu_(); 62 this.closeDropdownMenu_();
62 }, 63 },
63 64
64 /** @private */ 65 /** @private */
65 onSaveEditTap_: function() { 66 onSaveEditTap_: function() {
tsergeant 2017/02/01 23:46:48 You can do this with a single call to chrome.bookm
angelayang 2017/02/02 00:57:07 perfect thanks
66 chrome.bookmarks.update(this.menuItem_.id, { 67 if (this.menuItem_.url) {
67 'title': this.menuItem_.title, 68 chrome.bookmarks.update(this.menuItem_.id, {
68 'url': this.menuItem_.url, 69 'title': this.menuItem_.title,
69 }); 70 'url': this.menuItem_.url,
71 });
72 } else {
73 chrome.bookmarks.update(this.menuItem_.id, {
74 'title': this.menuItem_.title,
75 });
76 }
70 this.$.editBookmark.close(); 77 this.$.editBookmark.close();
71 }, 78 },
72 79
73 /** @private */ 80 /** @private */
74 onCancelEditTap_: function() { 81 onCancelEditTap_: function() {
75 this.$.editBookmark.cancel(); 82 this.$.editBookmark.cancel();
76 }, 83 },
77 84
78 /** @private */ 85 /** @private */
79 closeDropdownMenu_: function() { 86 closeDropdownMenu_: function() {
80 var menu = /** @type {!CrActionMenuElement} */ ( 87 var menu = /** @type {!CrActionMenuElement} */ (
81 this.$.dropdown); 88 this.$.dropdown);
82 menu.close(); 89 menu.close();
83 }, 90 },
84 91
85 /** @private */ 92 /** @private */
93 getMenuActionLabel_: function() {
tsergeant 2017/02/01 23:46:48 Should have 'edit' in the function name since it's
angelayang 2017/02/02 00:57:07 Done.
94 var label = this.menuItem_.url ? 'menuEdit' : 'menuRename';
95 return loadTimeData.getString(label);
96 },
97
98 /** @private */
99 getEditorTitle_: function() {
100 var title = this.menuItem_.url ? 'editBookmarkTitle' : 'renameFolderTitle';
101 return loadTimeData.getString(title);
102 },
103
104 /** @private */
86 emptyListMessage_: function() { 105 emptyListMessage_: function() {
87 var emptyListMessage = this.searchTerm ? 'noSearchResults' : 'emptyList'; 106 var emptyListMessage = this.searchTerm ? 'noSearchResults' : 'emptyList';
88 return loadTimeData.getString(emptyListMessage); 107 return loadTimeData.getString(emptyListMessage);
89 }, 108 },
90 109
91 /** @private */ 110 /** @private */
92 isEmptyList_: function() { 111 isEmptyList_: function() {
93 return this.displayedList.length == 0; 112 return this.displayedList.length == 0;
94 }, 113 },
95 }); 114 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_bookmarks/list.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