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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 }, | 43 }, |
44 | 44 |
45 /** | 45 /** |
46 * @param {Event} e | 46 * @param {Event} e |
47 * @private | 47 * @private |
48 */ | 48 */ |
49 onOpenItemMenu_: function(e) { | 49 onOpenItemMenu_: function(e) { |
50 this.menuItem_ = e.detail.item; | 50 this.menuItem_ = e.detail.item; |
51 var menu = /** @type {!CrActionMenuElement} */ ( | 51 var menu = /** @type {!CrActionMenuElement} */ ( |
52 this.$.dropdown); | 52 this.$.dropdown); |
53 menu.showAt(/** @type {!Element} */ (e.detail.target)); | 53 if (e.detail.targetElement) { |
54 menu.showAt(/** @type {!Element} */ (e.detail.targetElement)); | |
55 } else { | |
56 menu.showAtPosition({ | |
57 top: e.detail.y, | |
58 left: e.detail.x, | |
59 }); | |
60 } | |
54 }, | 61 }, |
55 | 62 |
56 /** @private */ | 63 /** @private */ |
57 onEditTap_: function() { | 64 onEditTap_: function() { |
58 this.closeDropdownMenu_(); | 65 this.closeDropdownMenu_(); |
59 /** @type {BookmarksEditDialogElement} */ (this.$.editDialog.get()) | 66 /** @type {BookmarksEditDialogElement} */ (this.$.editDialog.get()) |
60 .showEditDialog(this.menuItem_); | 67 .showEditDialog(this.menuItem_); |
61 }, | 68 }, |
62 | 69 |
63 /** @private */ | 70 /** @private */ |
(...skipping 12 matching lines...) Expand all Loading... | |
76 // TODO(jiaxi): Add toast later. | 83 // TODO(jiaxi): Add toast later. |
77 }.bind(this)); | 84 }.bind(this)); |
78 } else { | 85 } else { |
79 chrome.bookmarks.removeTree(this.menuItem_.id, function() { | 86 chrome.bookmarks.removeTree(this.menuItem_.id, function() { |
80 // TODO(jiaxi): Add toast later. | 87 // TODO(jiaxi): Add toast later. |
81 }.bind(this)); | 88 }.bind(this)); |
82 } | 89 } |
83 this.closeDropdownMenu_(); | 90 this.closeDropdownMenu_(); |
84 }, | 91 }, |
85 | 92 |
93 /** | |
94 * @param {Event} e | |
tsergeant
2017/04/13 01:15:47
I think you should add a small comment here to sho
calamity
2017/04/13 04:56:46
Done.
| |
95 * @private | |
96 */ | |
97 onMenuMousedown_: function(e) { | |
98 if (e.path[0] != this.$.dropdown) | |
99 return; | |
100 | |
101 this.$.dropdown.close(); | |
102 }, | |
103 | |
86 /** @private */ | 104 /** @private */ |
87 closeDropdownMenu_: function() { | 105 closeDropdownMenu_: function() { |
88 var menu = /** @type {!CrActionMenuElement} */ ( | 106 var menu = /** @type {!CrActionMenuElement} */ ( |
89 this.$.dropdown); | 107 this.$.dropdown); |
90 menu.close(); | 108 menu.close(); |
91 }, | 109 }, |
92 | 110 |
93 /** @private */ | 111 /** @private */ |
94 getEditActionLabel_: function() { | 112 getEditActionLabel_: function() { |
95 var label = this.menuItem_.url ? 'menuEdit' : 'menuRename'; | 113 var label = this.menuItem_.url ? 'menuEdit' : 'menuRename'; |
96 return loadTimeData.getString(label); | 114 return loadTimeData.getString(label); |
97 }, | 115 }, |
98 | 116 |
99 /** @private */ | 117 /** @private */ |
100 emptyListMessage_: function() { | 118 emptyListMessage_: function() { |
101 var emptyListMessage = this.searchTerm_ ? 'noSearchResults' : 'emptyList'; | 119 var emptyListMessage = this.searchTerm_ ? 'noSearchResults' : 'emptyList'; |
102 return loadTimeData.getString(emptyListMessage); | 120 return loadTimeData.getString(emptyListMessage); |
103 }, | 121 }, |
104 | 122 |
105 /** @private */ | 123 /** @private */ |
106 isEmptyList_: function() { | 124 isEmptyList_: function() { |
107 return this.displayedList_.length == 0; | 125 return this.displayedList_.length == 0; |
108 }, | 126 }, |
109 | 127 |
110 /** @private */ | 128 /** @private */ |
111 deselectItems_: function() { | 129 deselectItems_: function() { |
112 this.dispatch(bookmarks.actions.deselectItems()); | 130 this.dispatch(bookmarks.actions.deselectItems()); |
113 }, | 131 }, |
114 }); | 132 }); |
OLD | NEW |