| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 /** @private */ | 116 /** @private */ |
| 117 isEmptyList_: function() { | 117 isEmptyList_: function() { |
| 118 return this.displayedList_.length == 0; | 118 return this.displayedList_.length == 0; |
| 119 }, | 119 }, |
| 120 | 120 |
| 121 /** @private */ | 121 /** @private */ |
| 122 deselectItems_: function() { | 122 deselectItems_: function() { |
| 123 this.dispatch(bookmarks.actions.deselectItems()); | 123 this.dispatch(bookmarks.actions.deselectItems()); |
| 124 }, | 124 }, |
| 125 | 125 |
| 126 /** @private */ | |
| 127 selectAllItems_: function() { | |
| 128 this.dispatch( | |
| 129 bookmarks.actions.selectAll(this.displayedIds_, this.getState())); | |
| 130 }, | |
| 131 | |
| 132 /** | 126 /** |
| 133 * @param{HTMLElement} el | 127 * @param{HTMLElement} el |
| 134 * @private | 128 * @private |
| 135 */ | 129 */ |
| 136 getIndexForItemElement_: function(el) { | 130 getIndexForItemElement_: function(el) { |
| 137 return this.$.bookmarksCard.modelForElement(el).index; | 131 return this.$.bookmarksCard.modelForElement(el).index; |
| 138 }, | 132 }, |
| 139 | 133 |
| 140 /** | 134 /** |
| 141 * @param {KeyboardEvent} e | 135 * @param {KeyboardEvent} e |
| (...skipping 19 matching lines...) Expand all Loading... |
| 161 } else if (e.key == 'End') { | 155 } else if (e.key == 'End') { |
| 162 focusedIndex = list.items.length - 1; | 156 focusedIndex = list.items.length - 1; |
| 163 focusMoved = true; | 157 focusMoved = true; |
| 164 } else if (e.key == ' ' && e.ctrlKey) { | 158 } else if (e.key == ' ' && e.ctrlKey) { |
| 165 this.dispatch(bookmarks.actions.selectItem( | 159 this.dispatch(bookmarks.actions.selectItem( |
| 166 this.displayedIds_[focusedIndex], this.getState(), { | 160 this.displayedIds_[focusedIndex], this.getState(), { |
| 167 clear: false, | 161 clear: false, |
| 168 range: false, | 162 range: false, |
| 169 toggle: true, | 163 toggle: true, |
| 170 })); | 164 })); |
| 171 } else if (e.key == 'a' && e.ctrlKey) { | |
| 172 this.selectAllItems_(); | |
| 173 } else if (e.key == 'Escape') { | |
| 174 this.deselectItems_(); | |
| 175 } else { | 165 } else { |
| 176 handled = false; | 166 handled = false; |
| 177 } | 167 } |
| 178 | 168 |
| 179 if (focusMoved) { | 169 if (focusMoved) { |
| 180 focusedIndex = Math.min(list.items.length - 1, Math.max(0, focusedIndex)); | 170 focusedIndex = Math.min(list.items.length - 1, Math.max(0, focusedIndex)); |
| 181 list.focusItem(focusedIndex); | 171 list.focusItem(focusedIndex); |
| 182 | 172 |
| 183 if (e.ctrlKey && !e.shiftKey) { | 173 if (e.ctrlKey && !e.shiftKey) { |
| 184 this.dispatch( | 174 this.dispatch( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 209 | 199 |
| 210 if (!handled) { | 200 if (!handled) { |
| 211 handled = bookmarks.CommandManager.getInstance().handleKeyEvent( | 201 handled = bookmarks.CommandManager.getInstance().handleKeyEvent( |
| 212 e, this.getState().selection.items); | 202 e, this.getState().selection.items); |
| 213 } | 203 } |
| 214 | 204 |
| 215 if (handled) | 205 if (handled) |
| 216 e.stopPropagation(); | 206 e.stopPropagation(); |
| 217 }, | 207 }, |
| 218 }); | 208 }); |
| OLD | NEW |