Chromium Code Reviews| Index: chrome/browser/resources/md_bookmarks/actions.js |
| diff --git a/chrome/browser/resources/md_bookmarks/actions.js b/chrome/browser/resources/md_bookmarks/actions.js |
| index c1a2ad2248f2da2d8b74dfc62b8f04796890d7d1..aec05052fe87dbdeae203258ebb84befab38c71f 100644 |
| --- a/chrome/browser/resources/md_bookmarks/actions.js |
| +++ b/chrome/browser/resources/md_bookmarks/actions.js |
| @@ -72,6 +72,41 @@ cr.define('bookmarks.actions', function() { |
| } |
| /** |
| + * @param {string} id |
| + * @param {boolean} add |
| + * @param {boolean} range |
| + * @param {BookmarksPageState} state |
| + * @return {!Action} |
| + */ |
| + function selectItem(id, add, range, state) { |
| + var anchor = state.selection.anchor; |
| + var toSelect = []; |
| + |
|
calamity
2017/03/14 03:01:45
Add a TODO to deselect already selected items when
tsergeant
2017/03/14 05:42:02
TODO-ed since we'll want to be careful about how t
|
| + if (range && anchor) { |
| + var displayedList = bookmarks.util.getDisplayedList(state); |
| + var selectedIndex = displayedList.indexOf(id); |
| + assert(selectedIndex != -1); |
| + var anchorIndex = displayedList.indexOf(anchor); |
| + assert(anchorIndex != -1); |
| + |
| + var startIndex = Math.min(anchorIndex, selectedIndex); |
| + var endIndex = Math.max(anchorIndex, selectedIndex); |
| + |
| + for (var i = startIndex; i <= endIndex; i++) |
| + toSelect.push(displayedList[i]); |
| + } else { |
| + toSelect.push(id); |
| + } |
| + |
| + return { |
| + name: 'select-items', |
| + add: add, |
| + anchor: id, |
| + items: toSelect, |
| + }; |
| + } |
| + |
| + /** |
| * @param {string} term |
| * @return {!Action} |
| */ |
| @@ -102,6 +137,7 @@ cr.define('bookmarks.actions', function() { |
| refreshNodes: refreshNodes, |
| removeBookmark: removeBookmark, |
| selectFolder: selectFolder, |
| + selectItem: selectItem, |
| setSearchResults: setSearchResults, |
| setSearchTerm: setSearchTerm, |
| }; |