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

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

Issue 2888863002: [MD Bookmarks] Refine mouse selection (Closed)
Patch Set: address comments Created 3 years, 7 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/dnd_manager.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 be264052e0dc394c77c2833081f4fe2faff89633..6fb4ae621fdca9a634911c0ff222fd9caa9c8225 100644
--- a/chrome/browser/resources/md_bookmarks/actions.js
+++ b/chrome/browser/resources/md_bookmarks/actions.js
@@ -141,19 +141,26 @@ cr.define('bookmarks.actions', function() {
/**
* @param {string} id
- * @param {boolean} add
- * @param {boolean} range
* @param {BookmarksPageState} state
+ * @param {{
+ * clear: boolean,
+ * range: boolean,
+ * toggle: boolean}} config Options for how the selection should change:
+ * - clear: If true, clears the previous selection before adding this one
+ * - range: If true, selects all items from the anchor to this item
+ * - toggle: If true, toggles the selection state of the item. Cannot be
+ * used with clear or range.
* @return {!Action}
*/
- function selectItem(id, add, range, state) {
+ function selectItem(id, state, config) {
+ assert(!config.toggle || !config.range);
+ assert(!config.toggle || !config.clear);
+
var anchor = state.selection.anchor;
var toSelect = [];
var newAnchor = id;
- // TODO(tsergeant): Make it possible to deselect items by ctrl-clicking them
- // again.
- if (range && anchor) {
+ if (config.range && anchor) {
var displayedList = bookmarks.util.getDisplayedList(state);
var selectedIndex = displayedList.indexOf(id);
assert(selectedIndex != -1);
@@ -176,7 +183,8 @@ cr.define('bookmarks.actions', function() {
return {
name: 'select-items',
- add: add,
+ clear: config.clear,
+ toggle: config.toggle,
anchor: newAnchor,
items: toSelect,
};
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/dnd_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698