| 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 ], |
| 11 | 11 |
| 12 properties: { | 12 properties: { |
| 13 itemId: { | 13 itemId: { |
| 14 type: String, | 14 type: String, |
| 15 observer: 'onItemIdChanged_', | 15 observer: 'onItemIdChanged_', |
| 16 }, | 16 }, |
| 17 | 17 |
| 18 ironListTabIndex: String, |
| 19 |
| 18 /** @private {BookmarkNode} */ | 20 /** @private {BookmarkNode} */ |
| 19 item_: { | 21 item_: { |
| 20 type: Object, | 22 type: Object, |
| 21 observer: 'onItemChanged_', | 23 observer: 'onItemChanged_', |
| 22 }, | 24 }, |
| 23 | 25 |
| 24 /** @private */ | 26 /** @private */ |
| 25 isSelectedItem_: { | 27 isSelectedItem_: { |
| 26 type: Boolean, | 28 type: Boolean, |
| 27 reflectToAttribute: true, | 29 reflectToAttribute: true, |
| 28 }, | 30 }, |
| 29 | 31 |
| 30 /** @private */ | 32 /** @private */ |
| 33 mouseFocus_: { |
| 34 type: Boolean, |
| 35 reflectToAttribute: true, |
| 36 }, |
| 37 |
| 38 /** @private */ |
| 31 isFolder_: Boolean, | 39 isFolder_: Boolean, |
| 32 }, | 40 }, |
| 33 | 41 |
| 34 observers: [ | 42 observers: [ |
| 35 'updateFavicon_(item_.url)', | 43 'updateFavicon_(item_.url)', |
| 36 ], | 44 ], |
| 37 | 45 |
| 38 listeners: { | 46 listeners: { |
| 47 'mousedown': 'onMousedown_', |
| 48 'blur': 'onItemBlur_', |
| 39 'click': 'onClick_', | 49 'click': 'onClick_', |
| 40 'dblclick': 'onDblClick_', | 50 'dblclick': 'onDblClick_', |
| 41 'contextmenu': 'onContextMenu_', | 51 'contextmenu': 'onContextMenu_', |
| 42 }, | 52 }, |
| 43 | 53 |
| 44 /** @override */ | 54 /** @override */ |
| 45 attached: function() { | 55 attached: function() { |
| 46 this.watch('item_', function(store) { | 56 this.watch('item_', function(store) { |
| 47 return store.nodes[this.itemId]; | 57 return store.nodes[this.itemId]; |
| 48 }.bind(this)); | 58 }.bind(this)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 assert(this.getState().nodes[this.itemId]); | 112 assert(this.getState().nodes[this.itemId]); |
| 103 this.updateFromStore(); | 113 this.updateFromStore(); |
| 104 }, | 114 }, |
| 105 | 115 |
| 106 /** @private */ | 116 /** @private */ |
| 107 onItemChanged_: function() { | 117 onItemChanged_: function() { |
| 108 this.isFolder_ = !this.item_.url; | 118 this.isFolder_ = !this.item_.url; |
| 109 }, | 119 }, |
| 110 | 120 |
| 111 /** | 121 /** |
| 122 * @private |
| 123 */ |
| 124 onMousedown_: function() { |
| 125 this.mouseFocus_ = true; |
| 126 }, |
| 127 |
| 128 /** |
| 129 * @private |
| 130 */ |
| 131 onItemBlur_: function() { |
| 132 this.mouseFocus_ = false; |
| 133 }, |
| 134 |
| 135 /** |
| 112 * @param {Event} e | 136 * @param {Event} e |
| 113 * @private | 137 * @private |
| 114 */ | 138 */ |
| 115 onClick_: function(e) { | 139 onClick_: function(e) { |
| 116 this.dispatch(bookmarks.actions.selectItem( | 140 this.dispatch(bookmarks.actions.selectItem( |
| 117 this.itemId, e.ctrlKey, e.shiftKey, this.getState())); | 141 this.itemId, e.ctrlKey, e.shiftKey, this.getState())); |
| 118 e.stopPropagation(); | 142 e.stopPropagation(); |
| 119 }, | 143 }, |
| 120 | 144 |
| 121 /** | 145 /** |
| (...skipping 10 matching lines...) Expand all Loading... |
| 132 }, | 156 }, |
| 133 | 157 |
| 134 /** | 158 /** |
| 135 * @param {string} url | 159 * @param {string} url |
| 136 * @private | 160 * @private |
| 137 */ | 161 */ |
| 138 updateFavicon_: function(url) { | 162 updateFavicon_: function(url) { |
| 139 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url); | 163 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url); |
| 140 }, | 164 }, |
| 141 }); | 165 }); |
| OLD | NEW |