OLD | NEW |
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 behaviors: [ | 8 behaviors: [ |
9 bookmarks.StoreClient, | 9 bookmarks.StoreClient, |
10 ], | 10 ], |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 onOpenItemMenu_: function(e) { | 48 onOpenItemMenu_: function(e) { |
49 this.menuItem_ = e.detail.item; | 49 this.menuItem_ = e.detail.item; |
50 var menu = /** @type {!CrActionMenuElement} */ ( | 50 var menu = /** @type {!CrActionMenuElement} */ ( |
51 this.$.dropdown); | 51 this.$.dropdown); |
52 menu.showAt(/** @type {!Element} */ (e.detail.target)); | 52 menu.showAt(/** @type {!Element} */ (e.detail.target)); |
53 }, | 53 }, |
54 | 54 |
55 /** @private */ | 55 /** @private */ |
56 onEditTap_: function() { | 56 onEditTap_: function() { |
57 this.closeDropdownMenu_(); | 57 this.closeDropdownMenu_(); |
58 this.$.editBookmark.showModal(); | 58 /** @type {BookmarksEditDialogElement} */ (this.$.editDialog.get()) |
| 59 .editNode(this.menuItem_); |
59 }, | 60 }, |
60 | 61 |
61 /** @private */ | 62 /** @private */ |
62 onCopyURLTap_: function() { | 63 onCopyURLTap_: function() { |
63 var idList = [this.menuItem_.id]; | 64 var idList = [this.menuItem_.id]; |
64 chrome.bookmarkManagerPrivate.copy(idList, function() { | 65 chrome.bookmarkManagerPrivate.copy(idList, function() { |
65 // TODO(jiaxi): Add toast later. | 66 // TODO(jiaxi): Add toast later. |
66 }); | 67 }); |
67 this.closeDropdownMenu_(); | 68 this.closeDropdownMenu_(); |
68 }, | 69 }, |
69 | 70 |
70 /** @private */ | 71 /** @private */ |
71 onDeleteTap_: function() { | 72 onDeleteTap_: function() { |
72 if (this.menuItem_.url) { | 73 if (this.menuItem_.url) { |
73 chrome.bookmarks.remove(this.menuItem_.id, function() { | 74 chrome.bookmarks.remove(this.menuItem_.id, function() { |
74 // TODO(jiaxi): Add toast later. | 75 // TODO(jiaxi): Add toast later. |
75 }.bind(this)); | 76 }.bind(this)); |
76 } else { | 77 } else { |
77 chrome.bookmarks.removeTree(this.menuItem_.id, function() { | 78 chrome.bookmarks.removeTree(this.menuItem_.id, function() { |
78 // TODO(jiaxi): Add toast later. | 79 // TODO(jiaxi): Add toast later. |
79 }.bind(this)); | 80 }.bind(this)); |
80 } | 81 } |
81 this.closeDropdownMenu_(); | 82 this.closeDropdownMenu_(); |
82 }, | 83 }, |
83 | 84 |
84 /** @private */ | 85 /** @private */ |
85 onSaveEditTap_: function() { | |
86 var edit = {'title': this.menuItem_.title}; | |
87 if (this.menuItem_.url) | |
88 edit['url'] = this.menuItem_.url; | |
89 | |
90 chrome.bookmarks.update(this.menuItem_.id, edit); | |
91 this.$.editBookmark.close(); | |
92 }, | |
93 | |
94 /** @private */ | |
95 onCancelEditTap_: function() { | |
96 this.$.editBookmark.cancel(); | |
97 }, | |
98 | |
99 /** @private */ | |
100 closeDropdownMenu_: function() { | 86 closeDropdownMenu_: function() { |
101 var menu = /** @type {!CrActionMenuElement} */ ( | 87 var menu = /** @type {!CrActionMenuElement} */ ( |
102 this.$.dropdown); | 88 this.$.dropdown); |
103 menu.close(); | 89 menu.close(); |
104 }, | 90 }, |
105 | 91 |
106 /** @private */ | 92 /** @private */ |
107 getEditActionLabel_: function() { | 93 getEditActionLabel_: function() { |
108 var label = this.menuItem_.url ? 'menuEdit' : 'menuRename'; | 94 var label = this.menuItem_.url ? 'menuEdit' : 'menuRename'; |
109 return loadTimeData.getString(label); | 95 return loadTimeData.getString(label); |
110 }, | 96 }, |
111 | 97 |
112 /** @private */ | 98 /** @private */ |
113 getEditorTitle_: function() { | |
114 var title = this.menuItem_.url ? 'editBookmarkTitle' : 'renameFolderTitle'; | |
115 return loadTimeData.getString(title); | |
116 }, | |
117 | |
118 /** @private */ | |
119 emptyListMessage_: function() { | 99 emptyListMessage_: function() { |
120 var emptyListMessage = this.searchTerm_ ? 'noSearchResults' : 'emptyList'; | 100 var emptyListMessage = this.searchTerm_ ? 'noSearchResults' : 'emptyList'; |
121 return loadTimeData.getString(emptyListMessage); | 101 return loadTimeData.getString(emptyListMessage); |
122 }, | 102 }, |
123 | 103 |
124 /** @private */ | 104 /** @private */ |
125 isEmptyList_: function() { | 105 isEmptyList_: function() { |
126 return this.displayedList_.length == 0; | 106 return this.displayedList_.length == 0; |
127 }, | 107 }, |
128 }); | 108 }); |
OLD | NEW |