| 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 listeners: { | 38 listeners: { |
| 39 'click': 'onClick_', | 39 'click': 'onClick_', |
| 40 'dblclick': 'onDblClick_', | 40 'dblclick': 'onDblClick_', |
| 41 }, | 41 }, |
| 42 | 42 |
| 43 attached: function() { | 43 attached: function() { |
| 44 this.watch('item_', function(store) { | 44 this.watch('item_', function(store) { |
| 45 return store.nodes[this.itemId]; | 45 return store.nodes[this.itemId]; |
| 46 }.bind(this)); | 46 }.bind(this)); |
| 47 this.watch('isSelectedItem_', function(store) { |
| 48 return !!store.selection.items[this.itemId]; |
| 49 }.bind(this)); |
| 47 | 50 |
| 48 this.updateFromStore(); | 51 this.updateFromStore(); |
| 49 }, | 52 }, |
| 50 | 53 |
| 51 /** | 54 /** |
| 52 * @param {Event} e | 55 * @param {Event} e |
| 53 * @private | 56 * @private |
| 54 */ | 57 */ |
| 55 onMenuButtonOpenClick_: function(e) { | 58 onMenuButtonOpenClick_: function(e) { |
| 56 e.stopPropagation(); | 59 e.stopPropagation(); |
| 57 this.fire('open-item-menu', { | 60 this.fire('open-item-menu', { |
| 58 target: e.target, | 61 target: e.target, |
| 59 item: this.item_, | 62 item: this.item_, |
| 60 }); | 63 }); |
| 61 }, | 64 }, |
| 62 | 65 |
| 63 /** @private */ | 66 /** @private */ |
| 64 onItemChanged_: function() { | 67 onItemChanged_: function() { |
| 65 this.isFolder_ = !(this.item_.url); | 68 this.isFolder_ = !(this.item_.url); |
| 66 }, | 69 }, |
| 67 | 70 |
| 68 /** | 71 /** |
| 69 * @param {Event} e | 72 * @param {Event} e |
| 70 * @private | 73 * @private |
| 71 */ | 74 */ |
| 72 onClick_: function(e) { | 75 onClick_: function(e) { |
| 73 this.fire('select-item', { | 76 this.dispatch(bookmarks.actions.selectItem( |
| 74 item: this.item_, | 77 this.itemId, e.ctrlKey, e.shiftKey, this.getState())); |
| 75 range: e.shiftKey, | |
| 76 add: e.ctrlKey, | |
| 77 }); | |
| 78 }, | 78 }, |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * @param {Event} e | 81 * @param {Event} e |
| 82 * @private | 82 * @private |
| 83 */ | 83 */ |
| 84 onDblClick_: function(e) { | 84 onDblClick_: function(e) { |
| 85 if (!this.item_.url) | 85 if (!this.item_.url) |
| 86 this.dispatch(bookmarks.actions.selectFolder(this.item_.id)); | 86 this.dispatch(bookmarks.actions.selectFolder(this.item_.id)); |
| 87 else | 87 else |
| 88 chrome.tabs.create({url: this.item_.url}); | 88 chrome.tabs.create({url: this.item_.url}); |
| 89 }, | 89 }, |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * @param {string} url | 92 * @param {string} url |
| 93 * @private | 93 * @private |
| 94 */ | 94 */ |
| 95 updateFavicon_: function(url) { | 95 updateFavicon_: function(url) { |
| 96 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url); | 96 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url); |
| 97 }, | 97 }, |
| 98 }); | 98 }); |
| OLD | NEW |