Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2444)

Unified Diff: chrome/browser/resources/md_bookmarks/actions.js

Issue 2741393002: MD Bookmarks: Implement item selection in new data flow system (Closed)
Patch Set: Review comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/item.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7ed4cfc4f6a9545fdd8dc7d60b01a46726d7d5b8..e70bcee0a21f1ed0409d1cfebd495db93a5574c5 100644
--- a/chrome/browser/resources/md_bookmarks/actions.js
+++ b/chrome/browser/resources/md_bookmarks/actions.js
@@ -80,6 +80,44 @@ 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 = [];
+
+ // TODO(tsergeant): Make it possible to deselect items by ctrl-clicking them
+ // again.
+ if (range && anchor) {
+ var displayedList = bookmarks.util.getDisplayedList(state);
+ var selectedIndex = displayedList.indexOf(id);
+ assert(selectedIndex != -1);
+ var anchorIndex = displayedList.indexOf(anchor);
+ if (anchorIndex == -1)
+ anchorIndex = selectedIndex;
+
+ 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}
*/
@@ -111,6 +149,7 @@ cr.define('bookmarks.actions', function() {
refreshNodes: refreshNodes,
removeBookmark: removeBookmark,
selectFolder: selectFolder,
+ selectItem: selectItem,
setSearchResults: setSearchResults,
setSearchTerm: setSearchTerm,
};
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/item.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698