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

Side by Side Diff: chrome/browser/resources/bookmark_manager/js/dnd.js

Issue 2512903002: Add bookmark bar/manager actions to track drag and drop. (Closed)
Patch Set: own BookmarkBar_DragEnd Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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('dnd', function() { 5 cr.define('dnd', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** @const */ var BookmarkList = bmm.BookmarkList; 8 /** @const */ var BookmarkList = bmm.BookmarkList;
9 /** @const */ var ListItem = cr.ui.ListItem; 9 /** @const */ var ListItem = cr.ui.ListItem;
10 /** @const */ var TreeItem = cr.ui.TreeItem; 10 /** @const */ var TreeItem = cr.ui.TreeItem;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 338
339 if (draggedNodes.length) { 339 if (draggedNodes.length) {
340 // If we are dragging a single link, we can do the *Link* effect. 340 // If we are dragging a single link, we can do the *Link* effect.
341 // Otherwise, we only allow copy and move. 341 // Otherwise, we only allow copy and move.
342 e.dataTransfer.effectAllowed = draggedNodes.length == 1 && 342 e.dataTransfer.effectAllowed = draggedNodes.length == 1 &&
343 !bmm.isFolder(draggedNodes[0]) ? 'copyMoveLink' : 'copyMove'; 343 !bmm.isFolder(draggedNodes[0]) ? 'copyMoveLink' : 'copyMove';
344 344
345 chrome.bookmarkManagerPrivate.startDrag(draggedNodes.map(function(node) { 345 chrome.bookmarkManagerPrivate.startDrag(draggedNodes.map(function(node) {
346 return node.id; 346 return node.id;
347 }), isFromTouch); 347 }), isFromTouch);
348 chrome.metricsPrivate.recordUserAction('BookmarkManager_StartDrag');
348 } 349 }
349 } 350 }
350 351
351 function handleDragEnter(e) { 352 function handleDragEnter(e) {
352 e.preventDefault(); 353 e.preventDefault();
353 } 354 }
354 355
355 /** 356 /**
356 * Calback for the dragover event. 357 * Calback for the dragover event.
357 * @param {Event} e The dragover event. 358 * @param {Event} e The dragover event.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 function handleDrop(e) { 478 function handleDrop(e) {
478 var dropInfo = calculateDropInfo(e.target, dropDestination); 479 var dropInfo = calculateDropInfo(e.target, dropDestination);
479 if (dropInfo) { 480 if (dropInfo) {
480 selectItemsAfterUserAction(dropInfo.selectTarget, 481 selectItemsAfterUserAction(dropInfo.selectTarget,
481 dropInfo.selectedTreeId); 482 dropInfo.selectedTreeId);
482 if (dropInfo.index != -1) 483 if (dropInfo.index != -1)
483 chrome.bookmarkManagerPrivate.drop(dropInfo.parentId, dropInfo.index); 484 chrome.bookmarkManagerPrivate.drop(dropInfo.parentId, dropInfo.index);
484 else 485 else
485 chrome.bookmarkManagerPrivate.drop(dropInfo.parentId); 486 chrome.bookmarkManagerPrivate.drop(dropInfo.parentId);
486 487
488 chrome.metricsPrivate.recordUserAction('BookmarkManager_Drop');
489
487 e.preventDefault(); 490 e.preventDefault();
488 } 491 }
489 dropDestination = null; 492 dropDestination = null;
490 dropIndicator.finish(); 493 dropIndicator.finish();
491 } 494 }
492 495
493 function setCurrentTouchTarget(e) { 496 function setCurrentTouchTarget(e) {
494 // Only set a new target for a single touch point. 497 // Only set a new target for a single touch point.
495 if (e.touches.length == 1) 498 if (e.touches.length == 1)
496 currentTouchTarget = getBookmarkElement(e.target); 499 currentTouchTarget = getBookmarkElement(e.target);
(...skipping 28 matching lines...) Expand all
525 document.addEventListener('touchend', clearCurrentTouchTarget); 528 document.addEventListener('touchend', clearCurrentTouchTarget);
526 document.addEventListener('touchstart', setCurrentTouchTarget); 529 document.addEventListener('touchstart', setCurrentTouchTarget);
527 530
528 chrome.bookmarkManagerPrivate.onDragEnter.addListener( 531 chrome.bookmarkManagerPrivate.onDragEnter.addListener(
529 dragInfo.handleChromeDragEnter); 532 dragInfo.handleChromeDragEnter);
530 chrome.bookmarkManagerPrivate.onDragLeave.addListener(deferredClearData); 533 chrome.bookmarkManagerPrivate.onDragLeave.addListener(deferredClearData);
531 chrome.bookmarkManagerPrivate.onDrop.addListener(deferredClearData); 534 chrome.bookmarkManagerPrivate.onDrop.addListener(deferredClearData);
532 } 535 }
533 return {init: init}; 536 return {init: init};
534 }); 537 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698