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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 }, | 47 }, |
48 | 48 |
49 /** | 49 /** |
50 * @param {Event} e | 50 * @param {Event} e |
51 * @private | 51 * @private |
52 */ | 52 */ |
53 onOpenItemMenu_: function(e) { | 53 onOpenItemMenu_: function(e) { |
54 this.menuItem_ = e.detail.item; | 54 this.menuItem_ = e.detail.item; |
55 var menu = /** @type {!CrActionMenuElement} */ ( | 55 var menu = /** @type {!CrActionMenuElement} */ ( |
56 this.$.dropdown); | 56 this.$.dropdown); |
57 menu.showAt(/** @type {!Element} */ (e.detail.target)); | 57 if (e.detail.targetElement) { |
58 menu.showAt(/** @type {!Element} */ (e.detail.targetElement)); | |
59 } else { | |
60 menu.showAtPosition({ | |
61 top: e.detail.y, | |
62 left: e.detail.x, | |
63 }); | |
64 } | |
58 }, | 65 }, |
59 | 66 |
60 /** @private */ | 67 /** @private */ |
61 onEditTap_: function() { | 68 onEditTap_: function() { |
62 this.closeDropdownMenu_(); | 69 this.closeDropdownMenu_(); |
63 /** @type {BookmarksEditDialogElement} */ (this.$.editDialog.get()) | 70 /** @type {BookmarksEditDialogElement} */ (this.$.editDialog.get()) |
64 .showEditDialog(this.menuItem_); | 71 .showEditDialog(this.menuItem_); |
65 }, | 72 }, |
66 | 73 |
67 /** @private */ | 74 /** @private */ |
(...skipping 12 matching lines...) Expand all Loading... | |
80 // TODO(jiaxi): Add toast later. | 87 // TODO(jiaxi): Add toast later. |
81 }.bind(this)); | 88 }.bind(this)); |
82 } else { | 89 } else { |
83 chrome.bookmarks.removeTree(this.menuItem_.id, function() { | 90 chrome.bookmarks.removeTree(this.menuItem_.id, function() { |
84 // TODO(jiaxi): Add toast later. | 91 // TODO(jiaxi): Add toast later. |
85 }.bind(this)); | 92 }.bind(this)); |
86 } | 93 } |
87 this.closeDropdownMenu_(); | 94 this.closeDropdownMenu_(); |
88 }, | 95 }, |
89 | 96 |
97 /** | |
98 * Close the menu on mousedown so clicks can propagate to the underlying UI. | |
99 * This allows the user to right click the list while a context menu is | |
100 * showing and get another context menu. | |
101 * @param {Event} e | |
102 * @private | |
103 */ | |
104 onMenuMousedown_: function(e) { | |
105 if (e.path[0] != this.$.dropdown) | |
106 return; | |
107 | |
108 this.$.dropdown.close(); | |
tsergeant
2017/04/13 05:48:25
nit: call this.closeDropdownMenu_()
calamity
2017/04/19 05:36:34
Done.
| |
109 }, | |
110 | |
90 /** @private */ | 111 /** @private */ |
91 closeDropdownMenu_: function() { | 112 closeDropdownMenu_: function() { |
92 var menu = /** @type {!CrActionMenuElement} */ ( | 113 var menu = /** @type {!CrActionMenuElement} */ ( |
93 this.$.dropdown); | 114 this.$.dropdown); |
94 menu.close(); | 115 menu.close(); |
95 }, | 116 }, |
96 | 117 |
97 /** @private */ | 118 /** @private */ |
98 getEditActionLabel_: function() { | 119 getEditActionLabel_: function() { |
99 var label = this.menuItem_.url ? 'menuEdit' : 'menuRename'; | 120 var label = this.menuItem_.url ? 'menuEdit' : 'menuRename'; |
100 return loadTimeData.getString(label); | 121 return loadTimeData.getString(label); |
101 }, | 122 }, |
102 | 123 |
103 /** @private */ | 124 /** @private */ |
104 emptyListMessage_: function() { | 125 emptyListMessage_: function() { |
105 var emptyListMessage = this.searchTerm_ ? 'noSearchResults' : 'emptyList'; | 126 var emptyListMessage = this.searchTerm_ ? 'noSearchResults' : 'emptyList'; |
106 return loadTimeData.getString(emptyListMessage); | 127 return loadTimeData.getString(emptyListMessage); |
107 }, | 128 }, |
108 | 129 |
109 /** @private */ | 130 /** @private */ |
110 isEmptyList_: function() { | 131 isEmptyList_: function() { |
111 return this.displayedList_.length == 0; | 132 return this.displayedList_.length == 0; |
112 }, | 133 }, |
113 | 134 |
114 /** @private */ | 135 /** @private */ |
115 deselectItems_: function() { | 136 deselectItems_: function() { |
116 this.dispatch(bookmarks.actions.deselectItems()); | 137 this.dispatch(bookmarks.actions.deselectItems()); |
117 }, | 138 }, |
118 }); | 139 }); |
OLD | NEW |