| 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-list', | 6 is: 'bookmarks-list', |
| 7 | 7 |
| 8 behaviors: [ | 8 behaviors: [ |
| 9 bookmarks.StoreClient, | 9 bookmarks.StoreClient, |
| 10 ], | 10 ], |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 /** @private */ | 40 /** @private */ |
| 41 selectedFolder_: { | 41 selectedFolder_: { |
| 42 type: String, | 42 type: String, |
| 43 observer: 'onDisplayedListSourceChange_', | 43 observer: 'onDisplayedListSourceChange_', |
| 44 }, | 44 }, |
| 45 }, | 45 }, |
| 46 | 46 |
| 47 listeners: { | 47 listeners: { |
| 48 'click': 'deselectItems_', | 48 'click': 'deselectItems_', |
| 49 'open-item-menu': 'onOpenItemMenu_', |
| 49 }, | 50 }, |
| 50 | 51 |
| 51 attached: function() { | 52 attached: function() { |
| 52 var list = /** @type {IronListElement} */ (this.$.bookmarksCard); | 53 var list = /** @type {IronListElement} */ (this.$.bookmarksCard); |
| 53 list.scrollTarget = this; | 54 list.scrollTarget = this; |
| 54 | 55 |
| 55 this.watch('displayedIds_', function(state) { | 56 this.watch('displayedIds_', function(state) { |
| 56 return bookmarks.util.getDisplayedList(state); | 57 return bookmarks.util.getDisplayedList(state); |
| 57 }); | 58 }); |
| 58 this.watch('searchTerm_', function(state) { | 59 this.watch('searchTerm_', function(state) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 126 |
| 126 /** | 127 /** |
| 127 * @param{HTMLElement} el | 128 * @param{HTMLElement} el |
| 128 * @private | 129 * @private |
| 129 */ | 130 */ |
| 130 getIndexForItemElement_: function(el) { | 131 getIndexForItemElement_: function(el) { |
| 131 return this.$.bookmarksCard.modelForElement(el).index; | 132 return this.$.bookmarksCard.modelForElement(el).index; |
| 132 }, | 133 }, |
| 133 | 134 |
| 134 /** | 135 /** |
| 136 * @param {Event} e |
| 137 * @private |
| 138 */ |
| 139 onOpenItemMenu_: function(e) { |
| 140 var index = this.displayedIds_.indexOf( |
| 141 /** @type {BookmarksItemElement} */ (e.path[0]).itemId); |
| 142 var list = this.$.bookmarksCard; |
| 143 // If the item is not visible, scroll to it before rendering the menu. |
| 144 if (index < list.firstVisibleIndex || index > list.lastVisibleIndex) |
| 145 list.scrollToIndex(index); |
| 146 }, |
| 147 |
| 148 /** |
| 135 * @param {KeyboardEvent} e | 149 * @param {KeyboardEvent} e |
| 136 * @private | 150 * @private |
| 137 */ | 151 */ |
| 138 onItemKeydown_: function(e) { | 152 onItemKeydown_: function(e) { |
| 139 var handled = true; | 153 var handled = true; |
| 140 var list = this.$.bookmarksCard; | 154 var list = this.$.bookmarksCard; |
| 141 var focusMoved = false; | 155 var focusMoved = false; |
| 142 var focusedIndex = | 156 var focusedIndex = |
| 143 this.getIndexForItemElement_(/** @type {HTMLElement} */ (e.target)); | 157 this.getIndexForItemElement_(/** @type {HTMLElement} */ (e.target)); |
| 144 var oldFocusedIndex = focusedIndex; | 158 var oldFocusedIndex = focusedIndex; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 213 |
| 200 if (!handled) { | 214 if (!handled) { |
| 201 handled = bookmarks.CommandManager.getInstance().handleKeyEvent( | 215 handled = bookmarks.CommandManager.getInstance().handleKeyEvent( |
| 202 e, this.getState().selection.items); | 216 e, this.getState().selection.items); |
| 203 } | 217 } |
| 204 | 218 |
| 205 if (handled) | 219 if (handled) |
| 206 e.stopPropagation(); | 220 e.stopPropagation(); |
| 207 }, | 221 }, |
| 208 }); | 222 }); |
| OLD | NEW |