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-item', | 6 is: 'bookmarks-item', |
7 | 7 |
8 behaviors: [ | 8 behaviors: [ |
9 bookmarks.StoreClient, | 9 bookmarks.StoreClient, |
10 ], | 10 ], |
(...skipping 20 matching lines...) Expand all Loading... | |
31 isFolder_: Boolean, | 31 isFolder_: Boolean, |
32 }, | 32 }, |
33 | 33 |
34 observers: [ | 34 observers: [ |
35 'updateFavicon_(item_.url)', | 35 'updateFavicon_(item_.url)', |
36 ], | 36 ], |
37 | 37 |
38 listeners: { | 38 listeners: { |
39 'click': 'onClick_', | 39 'click': 'onClick_', |
40 'dblclick': 'onDblClick_', | 40 'dblclick': 'onDblClick_', |
41 'contextmenu': 'onContextMenu_', | |
41 }, | 42 }, |
42 | 43 |
43 /** @override */ | 44 /** @override */ |
44 attached: function() { | 45 attached: function() { |
45 this.watch('item_', function(store) { | 46 this.watch('item_', function(store) { |
46 return store.nodes[this.itemId]; | 47 return store.nodes[this.itemId]; |
47 }.bind(this)); | 48 }.bind(this)); |
48 this.watch('isSelectedItem_', function(store) { | 49 this.watch('isSelectedItem_', function(store) { |
49 return !!store.selection.items.has(this.itemId); | 50 return !!store.selection.items.has(this.itemId); |
50 }.bind(this)); | 51 }.bind(this)); |
51 | 52 |
52 this.updateFromStore(); | 53 this.updateFromStore(); |
53 }, | 54 }, |
54 | 55 |
55 /** @return {BookmarksItemElement} */ | 56 /** @return {BookmarksItemElement} */ |
56 getDropTarget: function() { | 57 getDropTarget: function() { |
57 return this; | 58 return this; |
58 }, | 59 }, |
59 | 60 |
60 /** | 61 /** |
61 * @param {Event} e | 62 * @param {Event} e |
62 * @private | 63 * @private |
63 */ | 64 */ |
65 onContextMenu_: function(e) { | |
66 e.preventDefault(); | |
tsergeant
2017/04/13 01:15:47
Minor suggestion: you should select the item here
calamity
2017/04/13 04:56:46
Done. This only happens if it's not selected since
| |
67 this.fire('open-item-menu', { | |
68 x: e.clientX, | |
69 y: e.clientY, | |
70 item: this.item_, | |
71 }); | |
72 }, | |
73 | |
74 /** | |
75 * @param {Event} e | |
76 * @private | |
77 */ | |
64 onMenuButtonClick_: function(e) { | 78 onMenuButtonClick_: function(e) { |
65 e.stopPropagation(); | 79 e.stopPropagation(); |
66 this.dispatch(bookmarks.actions.selectItem( | 80 this.dispatch(bookmarks.actions.selectItem( |
67 this.itemId, false, false, this.getState())); | 81 this.itemId, false, false, this.getState())); |
68 this.fire('open-item-menu', { | 82 this.fire('open-item-menu', { |
69 target: e.target, | 83 targetElement: e.target, |
70 item: this.item_, | 84 item: this.item_, |
71 }); | 85 }); |
72 }, | 86 }, |
73 | 87 |
74 /** | 88 /** |
75 * @param {Event} e | 89 * @param {Event} e |
76 * @private | 90 * @private |
77 */ | 91 */ |
78 onMenuButtonDblClick_: function(e) { | 92 onMenuButtonDblClick_: function(e) { |
79 e.stopPropagation(); | 93 e.stopPropagation(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 }, | 128 }, |
115 | 129 |
116 /** | 130 /** |
117 * @param {string} url | 131 * @param {string} url |
118 * @private | 132 * @private |
119 */ | 133 */ |
120 updateFavicon_: function(url) { | 134 updateFavicon_: function(url) { |
121 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url); | 135 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url); |
122 }, | 136 }, |
123 }); | 137 }); |
OLD | NEW |