| 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(); |
| 67 if (!this.isSelectedItem_) { |
| 68 this.dispatch(bookmarks.actions.selectItem( |
| 69 this.itemId, false, false, this.getState())); |
| 70 } |
| 71 this.fire('open-item-menu', { |
| 72 x: e.clientX, |
| 73 y: e.clientY, |
| 74 item: this.item_, |
| 75 }); |
| 76 }, |
| 77 |
| 78 /** |
| 79 * @param {Event} e |
| 80 * @private |
| 81 */ |
| 64 onMenuButtonClick_: function(e) { | 82 onMenuButtonClick_: function(e) { |
| 65 e.stopPropagation(); | 83 e.stopPropagation(); |
| 66 this.dispatch(bookmarks.actions.selectItem( | 84 this.dispatch(bookmarks.actions.selectItem( |
| 67 this.itemId, false, false, this.getState())); | 85 this.itemId, false, false, this.getState())); |
| 68 this.fire('open-item-menu', { | 86 this.fire('open-item-menu', { |
| 69 target: e.target, | 87 targetElement: e.target, |
| 70 item: this.item_, | 88 item: this.item_, |
| 71 }); | 89 }); |
| 72 }, | 90 }, |
| 73 | 91 |
| 74 /** | 92 /** |
| 75 * @param {Event} e | 93 * @param {Event} e |
| 76 * @private | 94 * @private |
| 77 */ | 95 */ |
| 78 onMenuButtonDblClick_: function(e) { | 96 onMenuButtonDblClick_: function(e) { |
| 79 e.stopPropagation(); | 97 e.stopPropagation(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 }, | 132 }, |
| 115 | 133 |
| 116 /** | 134 /** |
| 117 * @param {string} url | 135 * @param {string} url |
| 118 * @private | 136 * @private |
| 119 */ | 137 */ |
| 120 updateFavicon_: function(url) { | 138 updateFavicon_: function(url) { |
| 121 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url); | 139 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url); |
| 122 }, | 140 }, |
| 123 }); | 141 }); |
| OLD | NEW |