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

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

Issue 2666033002: [MD Bookmarks] Add edit folder. (Closed)
Patch Set: Test with mockinteractions in list test. 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,
(...skipping 12 matching lines...) Expand all
23 * @param {Event} e 23 * @param {Event} e
24 * @private 24 * @private
25 */ 25 */
26 onOpenItemMenu_: function(e) { 26 onOpenItemMenu_: function(e) {
27 this.menuItem_ = e.detail.item; 27 this.menuItem_ = e.detail.item;
28 var menu = /** @type {!CrActionMenuElement} */ ( 28 var menu = /** @type {!CrActionMenuElement} */ (
29 this.$.dropdown); 29 this.$.dropdown);
30 menu.showAt(/** @type {!Element} */ (e.detail.target)); 30 menu.showAt(/** @type {!Element} */ (e.detail.target));
31 }, 31 },
32 32
33 // TODO(jiaxi): change these dummy click event handlers later.
34 /** @private */ 33 /** @private */
35 onEditTap_: function() { 34 onEditTap_: function() {
36 this.closeDropdownMenu_(); 35 this.closeDropdownMenu_();
37 if (this.menuItem_.url) 36 this.$.editBookmark.showModal();
38 this.$.editBookmark.showModal();
39 }, 37 },
40 38
41 /** @private */ 39 /** @private */
42 onCopyURLTap_: function() { 40 onCopyURLTap_: function() {
43 var idList = [this.menuItem_.id]; 41 var idList = [this.menuItem_.id];
44 chrome.bookmarkManagerPrivate.copy(idList, function() { 42 chrome.bookmarkManagerPrivate.copy(idList, function() {
45 // TODO(jiaxi): Add toast later. 43 // TODO(jiaxi): Add toast later.
46 }); 44 });
47 this.closeDropdownMenu_(); 45 this.closeDropdownMenu_();
48 }, 46 },
49 47
50 /** @private */ 48 /** @private */
51 onDeleteTap_: function() { 49 onDeleteTap_: function() {
52 if (this.menuItem_.url) { 50 if (this.menuItem_.url) {
53 chrome.bookmarks.remove(this.menuItem_.id, function() { 51 chrome.bookmarks.remove(this.menuItem_.id, function() {
54 // TODO(jiaxi): Add toast later. 52 // TODO(jiaxi): Add toast later.
55 }.bind(this)); 53 }.bind(this));
56 } else { 54 } else {
57 chrome.bookmarks.removeTree(this.menuItem_.id, function() { 55 chrome.bookmarks.removeTree(this.menuItem_.id, function() {
58 // TODO(jiaxi): Add toast later. 56 // TODO(jiaxi): Add toast later.
59 }.bind(this)); 57 }.bind(this));
60 } 58 }
61 this.closeDropdownMenu_(); 59 this.closeDropdownMenu_();
62 }, 60 },
63 61
64 /** @private */ 62 /** @private */
65 onSaveEditTap_: function() { 63 onSaveEditTap_: function() {
66 chrome.bookmarks.update(this.menuItem_.id, { 64 var edit = {'title': this.menuItem_.title};
67 'title': this.menuItem_.title, 65 if (this.menuItem_.url)
68 'url': this.menuItem_.url, 66 edit['url'] = this.menuItem_.url;
69 }); 67
68 chrome.bookmarks.update(this.menuItem_.id, edit);
70 this.$.editBookmark.close(); 69 this.$.editBookmark.close();
71 }, 70 },
72 71
73 /** @private */ 72 /** @private */
74 onCancelEditTap_: function() { 73 onCancelEditTap_: function() {
75 this.$.editBookmark.cancel(); 74 this.$.editBookmark.cancel();
76 }, 75 },
77 76
78 /** @private */ 77 /** @private */
79 closeDropdownMenu_: function() { 78 closeDropdownMenu_: function() {
80 var menu = /** @type {!CrActionMenuElement} */ ( 79 var menu = /** @type {!CrActionMenuElement} */ (
81 this.$.dropdown); 80 this.$.dropdown);
82 menu.close(); 81 menu.close();
83 }, 82 },
84 83
85 /** @private */ 84 /** @private */
85 getEditActionLabel_: function() {
86 var label = this.menuItem_.url ? 'menuEdit' : 'menuRename';
87 return loadTimeData.getString(label);
88 },
89
90 /** @private */
91 getEditorTitle_: function() {
92 var title = this.menuItem_.url ? 'editBookmarkTitle' : 'renameFolderTitle';
93 return loadTimeData.getString(title);
94 },
95
96 /** @private */
86 emptyListMessage_: function() { 97 emptyListMessage_: function() {
87 var emptyListMessage = this.searchTerm ? 'noSearchResults' : 'emptyList'; 98 var emptyListMessage = this.searchTerm ? 'noSearchResults' : 'emptyList';
88 return loadTimeData.getString(emptyListMessage); 99 return loadTimeData.getString(emptyListMessage);
89 }, 100 },
90 101
91 /** @private */ 102 /** @private */
92 isEmptyList_: function() { 103 isEmptyList_: function() {
93 return this.displayedList.length == 0; 104 return this.displayedList.length == 0;
94 }, 105 },
95 }); 106 });
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