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

Unified Diff: chrome/browser/resources/bookmark_manager/js/dnd.js

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 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
Index: chrome/browser/resources/bookmark_manager/js/dnd.js
diff --git a/chrome/browser/resources/bookmark_manager/js/dnd.js b/chrome/browser/resources/bookmark_manager/js/dnd.js
index 65f382b745038210694b9c28d420942046ced232..c8f2a09a0bde98d134309541204d3c138e47caa7 100644
--- a/chrome/browser/resources/bookmark_manager/js/dnd.js
+++ b/chrome/browser/resources/bookmark_manager/js/dnd.js
@@ -15,12 +15,7 @@ cr.define('dnd', function() {
* @enum {number}
* @const
*/
- var DropPosition = {
- NONE: 0,
- ABOVE: 1,
- ON: 2,
- BELOW: 4
- };
+ var DropPosition = {NONE: 0, ABOVE: 1, ON: 2, BELOW: 4};
/**
* @type {Object} Drop information calculated in |handleDragOver|.
@@ -28,27 +23,27 @@ cr.define('dnd', function() {
var dropDestination = null;
/**
- * @type {number} Timer id used to help minimize flicker.
- */
+ * @type {number} Timer id used to help minimize flicker.
+ */
var removeDropIndicatorTimer;
/**
- * The element currently targeted by a touch.
- * @type {Element}
- */
+ * The element currently targeted by a touch.
+ * @type {Element}
+ */
var currentTouchTarget;
/**
- * The element that had a style applied it to indicate the drop location.
- * This is used to easily remove the style when necessary.
- * @type {Element}
- */
+ * The element that had a style applied it to indicate the drop location.
+ * This is used to easily remove the style when necessary.
+ * @type {Element}
+ */
var lastIndicatorElement;
/**
- * The style that was applied to indicate the drop location.
- * @type {?string}
- */
+ * The style that was applied to indicate the drop location.
+ * @type {?string}
+ */
var lastIndicatorClassName;
var dropIndicator = {
@@ -57,9 +52,9 @@ cr.define('dnd', function() {
* information to easily remove the style in the future.
*/
addDropIndicatorStyle: function(indicatorElement, position) {
- var indicatorStyleName = position == DropPosition.ABOVE ? 'drag-above' :
- position == DropPosition.BELOW ? 'drag-below' :
- 'drag-on';
+ var indicatorStyleName = position == DropPosition.ABOVE ?
+ 'drag-above' :
+ position == DropPosition.BELOW ? 'drag-below' : 'drag-on';
lastIndicatorElement = indicatorElement;
lastIndicatorClassName = indicatorStyleName;
@@ -80,9 +75,9 @@ cr.define('dnd', function() {
},
/**
- * Displays the drop indicator on the current drop target to give the
- * user feedback on where the drop will occur.
- */
+ * Displays the drop indicator on the current drop target to give the
+ * user feedback on where the drop will occur.
+ */
update: function(dropDest) {
window.clearTimeout(removeDropIndicatorTimer);
@@ -112,26 +107,26 @@ cr.define('dnd', function() {
};
/**
- * Delay for expanding folder when pointer hovers on folder in tree view in
- * milliseconds.
- * @type {number}
- * @const
- */
+ * Delay for expanding folder when pointer hovers on folder in tree view in
+ * milliseconds.
+ * @type {number}
+ * @const
+ */
// TODO(yosin): EXPAND_FOLDER_DELAY should follow system settings. 400ms is
// taken from Windows default settings.
var EXPAND_FOLDER_DELAY = 400;
/**
- * The timestamp when the mouse was over a folder during a drag operation.
- * Used to open the hovered folder after a certain time.
- * @type {number}
- */
+ * The timestamp when the mouse was over a folder during a drag operation.
+ * Used to open the hovered folder after a certain time.
+ * @type {number}
+ */
var lastHoverOnFolderTimeStamp = 0;
/**
- * Expand a folder if the user has hovered for longer than the specified
- * time during a drag action.
- */
+ * Expand a folder if the user has hovered for longer than the specified
+ * time during a drag action.
+ */
function updateAutoExpander(eventTimeStamp, overElement) {
// Expands a folder in tree view when pointer hovers on it longer than
// EXPAND_FOLDER_DELAY.
@@ -142,18 +137,18 @@ cr.define('dnd', function() {
overElement.expanded = true;
else
lastHoverOnFolderTimeStamp = hoverOnFolderTimeStamp;
- } else if (overElement instanceof TreeItem &&
- bmm.isFolder(overElement.bookmarkNode) &&
- overElement.hasChildren &&
- !overElement.expanded) {
+ } else if (
+ overElement instanceof TreeItem &&
+ bmm.isFolder(overElement.bookmarkNode) && overElement.hasChildren &&
+ !overElement.expanded) {
lastHoverOnFolderTimeStamp = eventTimeStamp;
}
}
/**
- * Stores the information about the bookmark and folders being dragged.
- * @type {Object}
- */
+ * Stores the information about the bookmark and folders being dragged.
+ * @type {Object}
+ */
var dragData = null;
var dragInfo = {
handleChromeDragEnter: function(newDragData) {
@@ -339,12 +334,16 @@ cr.define('dnd', function() {
if (draggedNodes.length) {
// If we are dragging a single link, we can do the *Link* effect.
// Otherwise, we only allow copy and move.
- e.dataTransfer.effectAllowed = draggedNodes.length == 1 &&
- !bmm.isFolder(draggedNodes[0]) ? 'copyMoveLink' : 'copyMove';
-
- chrome.bookmarkManagerPrivate.startDrag(draggedNodes.map(function(node) {
- return node.id;
- }), isFromTouch);
+ e.dataTransfer.effectAllowed =
+ draggedNodes.length == 1 && !bmm.isFolder(draggedNodes[0]) ?
+ 'copyMoveLink' :
+ 'copyMove';
+
+ chrome.bookmarkManagerPrivate.startDrag(
+ draggedNodes.map(function(node) {
+ return node.id;
+ }),
+ isFromTouch);
var dragTarget = getBookmarkElement(e.target);
if (dragTarget instanceof ListItem ||
dragTarget instanceof BookmarkList) {
@@ -383,7 +382,7 @@ cr.define('dnd', function() {
return;
var overElement = getBookmarkElement(e.target) ||
- (e.target == bmm.list ? bmm.list : null);
+ (e.target == bmm.list ? bmm.list : null);
if (!overElement)
return;
@@ -448,13 +447,13 @@ cr.define('dnd', function() {
var dropPos = dropDestination.position;
var relatedNode = dropDestination.element.bookmarkNode;
var dropInfoResult = {
- selectTarget: null,
- selectedTreeId: -1,
- parentId: dropPos == DropPosition.ON ? relatedNode.id :
- relatedNode.parentId,
- index: -1,
- relatedIndex: -1
- };
+ selectTarget: null,
+ selectedTreeId: -1,
+ parentId: dropPos == DropPosition.ON ? relatedNode.id :
+ relatedNode.parentId,
+ index: -1,
+ relatedIndex: -1
+ };
// Try to find the index in the dataModel so we don't have to always keep
// the index for the list items up to date.
@@ -489,8 +488,8 @@ cr.define('dnd', function() {
function handleDrop(e) {
var dropInfo = calculateDropInfo(e.target, dropDestination);
if (dropInfo) {
- selectItemsAfterUserAction(dropInfo.selectTarget,
- dropInfo.selectedTreeId);
+ selectItemsAfterUserAction(
+ dropInfo.selectTarget, dropInfo.selectedTreeId);
if (dropInfo.index != -1)
chrome.bookmarkManagerPrivate.drop(dropInfo.parentId, dropInfo.index);
else

Powered by Google App Engine
This is Rietveld 408576698