| 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.MouseFocusBehavior, |
| 9 bookmarks.StoreClient, | 10 bookmarks.StoreClient, |
| 10 ], | 11 ], |
| 11 | 12 |
| 12 properties: { | 13 properties: { |
| 13 itemId: { | 14 itemId: { |
| 14 type: String, | 15 type: String, |
| 15 observer: 'onItemIdChanged_', | 16 observer: 'onItemIdChanged_', |
| 16 }, | 17 }, |
| 17 | 18 |
| 18 ironListTabIndex: String, | 19 ironListTabIndex: String, |
| 19 | 20 |
| 20 /** @private {BookmarkNode} */ | 21 /** @private {BookmarkNode} */ |
| 21 item_: { | 22 item_: { |
| 22 type: Object, | 23 type: Object, |
| 23 observer: 'onItemChanged_', | 24 observer: 'onItemChanged_', |
| 24 }, | 25 }, |
| 25 | 26 |
| 26 /** @private */ | 27 /** @private */ |
| 27 isSelectedItem_: { | 28 isSelectedItem_: { |
| 28 type: Boolean, | 29 type: Boolean, |
| 29 reflectToAttribute: true, | 30 reflectToAttribute: true, |
| 30 }, | 31 }, |
| 31 | 32 |
| 32 /** @private */ | 33 /** @private */ |
| 33 mouseFocus_: { | |
| 34 type: Boolean, | |
| 35 reflectToAttribute: true, | |
| 36 }, | |
| 37 | |
| 38 /** @private */ | |
| 39 isFolder_: Boolean, | 34 isFolder_: Boolean, |
| 40 }, | 35 }, |
| 41 | 36 |
| 42 observers: [ | 37 observers: [ |
| 43 'updateFavicon_(item_.url)', | 38 'updateFavicon_(item_.url)', |
| 44 ], | 39 ], |
| 45 | 40 |
| 46 listeners: { | 41 listeners: { |
| 47 'mousedown': 'onMousedown_', | |
| 48 'blur': 'onItemBlur_', | |
| 49 'click': 'onClick_', | 42 'click': 'onClick_', |
| 50 'dblclick': 'onDblClick_', | 43 'dblclick': 'onDblClick_', |
| 51 'contextmenu': 'onContextMenu_', | 44 'contextmenu': 'onContextMenu_', |
| 52 }, | 45 }, |
| 53 | 46 |
| 54 /** @override */ | 47 /** @override */ |
| 55 attached: function() { | 48 attached: function() { |
| 56 this.watch('item_', function(store) { | 49 this.watch('item_', function(store) { |
| 57 return store.nodes[this.itemId]; | 50 return store.nodes[this.itemId]; |
| 58 }.bind(this)); | 51 }.bind(this)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 assert(this.getState().nodes[this.itemId]); | 113 assert(this.getState().nodes[this.itemId]); |
| 121 this.updateFromStore(); | 114 this.updateFromStore(); |
| 122 }, | 115 }, |
| 123 | 116 |
| 124 /** @private */ | 117 /** @private */ |
| 125 onItemChanged_: function() { | 118 onItemChanged_: function() { |
| 126 this.isFolder_ = !this.item_.url; | 119 this.isFolder_ = !this.item_.url; |
| 127 }, | 120 }, |
| 128 | 121 |
| 129 /** | 122 /** |
| 130 * @private | |
| 131 */ | |
| 132 onMousedown_: function() { | |
| 133 this.mouseFocus_ = true; | |
| 134 }, | |
| 135 | |
| 136 /** | |
| 137 * @private | |
| 138 */ | |
| 139 onItemBlur_: function() { | |
| 140 this.mouseFocus_ = false; | |
| 141 }, | |
| 142 | |
| 143 /** | |
| 144 * @param {MouseEvent} e | 123 * @param {MouseEvent} e |
| 145 * @private | 124 * @private |
| 146 */ | 125 */ |
| 147 onClick_: function(e) { | 126 onClick_: function(e) { |
| 148 // Ignore double clicks so that Ctrl double-clicking an item won't deselect | 127 // Ignore double clicks so that Ctrl double-clicking an item won't deselect |
| 149 // the item before opening. | 128 // the item before opening. |
| 150 if (e.detail != 2) { | 129 if (e.detail != 2) { |
| 151 this.dispatch(bookmarks.actions.selectItem(this.itemId, this.getState(), { | 130 this.dispatch(bookmarks.actions.selectItem(this.itemId, this.getState(), { |
| 152 clear: !e.ctrlKey, | 131 clear: !e.ctrlKey, |
| 153 range: e.shiftKey, | 132 range: e.shiftKey, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 170 }, | 149 }, |
| 171 | 150 |
| 172 /** | 151 /** |
| 173 * @param {string} url | 152 * @param {string} url |
| 174 * @private | 153 * @private |
| 175 */ | 154 */ |
| 176 updateFavicon_: function(url) { | 155 updateFavicon_: function(url) { |
| 177 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url); | 156 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url); |
| 178 }, | 157 }, |
| 179 }); | 158 }); |
| OLD | NEW |