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

Side by Side Diff: chrome/browser/resources/md_bookmarks/dnd_manager.js

Issue 2774233006: [MD Bookmarks] Change selection items from Map to Set. (Closed)
Patch Set: rebase Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 cr.define('bookmarks', function() { 5 cr.define('bookmarks', function() {
6 /** 6 /**
7 * @param {BookmarkElement} element 7 * @param {BookmarkElement} element
8 * @return {boolean} 8 * @return {boolean}
9 */ 9 */
10 function isBookmarkItem(element) { 10 function isBookmarkItem(element) {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 * @private 321 * @private
322 * @param {Event} e 322 * @param {Event} e
323 */ 323 */
324 onDragStart_: function(e) { 324 onDragStart_: function(e) {
325 var dragElement = getBookmarkElement(e.path); 325 var dragElement = getBookmarkElement(e.path);
326 if (!dragElement) 326 if (!dragElement)
327 return; 327 return;
328 328
329 // Determine the selected bookmarks. 329 // Determine the selected bookmarks.
330 var state = bookmarks.Store.getInstance().data; 330 var state = bookmarks.Store.getInstance().data;
331 var draggedNodes = Object.keys(state.selection.items); 331 var draggedNodes = Array.from(state.selection.items);
332 332
333 if (isBookmarkFolderNode(dragElement) || 333 if (isBookmarkFolderNode(dragElement) ||
334 draggedNodes.indexOf(dragElement.itemId) == -1) { 334 draggedNodes.indexOf(dragElement.itemId) == -1) {
335 // TODO(calamity): clear current selection. 335 // TODO(calamity): clear current selection.
336 draggedNodes = [dragElement.itemId]; 336 draggedNodes = [dragElement.itemId];
337 } 337 }
338 338
339 e.preventDefault(); 339 e.preventDefault();
340 340
341 // If we are dragging a single link, we can do the *Link* effect. 341 // If we are dragging a single link, we can do the *Link* effect.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 489
490 var validDropPositions = DropPosition.NONE; 490 var validDropPositions = DropPosition.NONE;
491 491
492 // Cannot drop above if the item above is already in the drag source. 492 // Cannot drop above if the item above is already in the drag source.
493 var previousElem = overElement.previousElementSibling; 493 var previousElem = overElement.previousElementSibling;
494 if (!previousElem || !dragInfo.isDraggingBookmark(previousElem.itemId)) 494 if (!previousElem || !dragInfo.isDraggingBookmark(previousElem.itemId))
495 validDropPositions |= DropPosition.ABOVE; 495 validDropPositions |= DropPosition.ABOVE;
496 496
497 // Don't allow dropping below an expanded sidebar folder item since it is 497 // Don't allow dropping below an expanded sidebar folder item since it is
498 // confusing to the user anyway. 498 // confusing to the user anyway.
499 if (isOverFolderNode && !state.closedFolders[overElement.itemId] && 499 if (isOverFolderNode && !state.closedFolders.has(overElement.itemId) &&
500 bookmarks.util.hasChildFolders(overElement.itemId, state.nodes)) { 500 bookmarks.util.hasChildFolders(overElement.itemId, state.nodes)) {
501 return validDropPositions; 501 return validDropPositions;
502 } 502 }
503 503
504 var nextElement = overElement.nextElementSibling; 504 var nextElement = overElement.nextElementSibling;
505 505
506 // The template element sits past the end of the last bookmark element. 506 // The template element sits past the end of the last bookmark element.
507 if (!isBookmarkItem(nextElement) && !isBookmarkFolderNode(nextElement)) 507 if (!isBookmarkItem(nextElement) && !isBookmarkFolderNode(nextElement))
508 nextElement = null; 508 nextElement = null;
509 509
(...skipping 20 matching lines...) Expand all
530 return !this.dragInfo_.isDraggingChildBookmark(overElement.itemId) 530 return !this.dragInfo_.isDraggingChildBookmark(overElement.itemId)
531 }, 531 },
532 }; 532 };
533 533
534 return { 534 return {
535 DNDManager: DNDManager, 535 DNDManager: DNDManager,
536 DragInfo: DragInfo, 536 DragInfo: DragInfo,
537 DropIndicator: DropIndicator, 537 DropIndicator: DropIndicator,
538 }; 538 };
539 }); 539 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_bookmarks/app.js ('k') | chrome/browser/resources/md_bookmarks/folder_node.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698