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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 /** | 132 /** |
133 * @param{HTMLElement} el | 133 * @param{HTMLElement} el |
134 * @private | 134 * @private |
135 */ | 135 */ |
136 getIndexForItemElement_: function(el) { | 136 getIndexForItemElement_: function(el) { |
137 return this.$.bookmarksCard.modelForElement(el).index; | 137 return this.$.bookmarksCard.modelForElement(el).index; |
138 }, | 138 }, |
139 | 139 |
140 /** | 140 /** |
| 141 * @param {Event} e |
| 142 * @private |
| 143 */ |
| 144 onOpenItemMenu_: function(e) { |
| 145 var index = e.target.index; |
| 146 var list = this.$.bookmarksCard; |
| 147 // If the item is not visible, scroll to it before rendering the menu. |
| 148 if (index < list.firstVisibleIndex || index > list.lastVisibleIndex) |
| 149 list.scrollToIndex(index); |
| 150 }, |
| 151 |
| 152 /** |
141 * @param {KeyboardEvent} e | 153 * @param {KeyboardEvent} e |
142 * @private | 154 * @private |
143 */ | 155 */ |
144 onItemKeydown_: function(e) { | 156 onItemKeydown_: function(e) { |
145 var handled = true; | 157 var handled = true; |
146 var list = this.$.bookmarksCard; | 158 var list = this.$.bookmarksCard; |
147 var focusMoved = false; | 159 var focusMoved = false; |
148 var focusedIndex = | 160 var focusedIndex = |
149 this.getIndexForItemElement_(/** @type {HTMLElement} */ (e.target)); | 161 this.getIndexForItemElement_(/** @type {HTMLElement} */ (e.target)); |
150 var oldFocusedIndex = focusedIndex; | 162 var oldFocusedIndex = focusedIndex; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 221 |
210 if (!handled) { | 222 if (!handled) { |
211 handled = bookmarks.CommandManager.getInstance().handleKeyEvent( | 223 handled = bookmarks.CommandManager.getInstance().handleKeyEvent( |
212 e, this.getState().selection.items); | 224 e, this.getState().selection.items); |
213 } | 225 } |
214 | 226 |
215 if (handled) | 227 if (handled) |
216 e.stopPropagation(); | 228 e.stopPropagation(); |
217 }, | 229 }, |
218 }); | 230 }); |
OLD | NEW |