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

Unified Diff: chrome/browser/resources/ntp4/tile_page.js

Issue 7592001: ntp4: most visited dragging onto apps page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments and a fix for dropping mv on nav dots Created 9 years, 4 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 | « chrome/browser/resources/ntp4/tile_page.css ('k') | chrome/browser/resources/ntp4/trash.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp4/tile_page.js
diff --git a/chrome/browser/resources/ntp4/tile_page.js b/chrome/browser/resources/ntp4/tile_page.js
index ace7aa46ea1a6182e4775da70e0b08f3c2fbb2e6..caf0f5224993be54251d981922f3e3a8d9b4b305 100644
--- a/chrome/browser/resources/ntp4/tile_page.js
+++ b/chrome/browser/resources/ntp4/tile_page.js
@@ -90,14 +90,6 @@ cr.define('ntp4', function() {
* @private
*/
onDragStart_: function(e) {
- // TODO(estade): most visited dragging is disabled for now, remove this
- // when it does something useful.
- if (this.querySelector('.most-visited')) {
- e.preventDefault();
- e.stopPropagation();
- return;
- }
-
// The user may start dragging again during a previous drag's finishing
// animation.
if (this.classList.contains('dragging'))
@@ -161,30 +153,32 @@ cr.define('ntp4', function() {
setCurrentlyDraggingTile(null);
- if (!this.tilePage) {
- this.dragClone.firstChild.classList.add('deleting');
- return;
+ // tilePage will be null if we've already been removed.
+ if (this.tilePage)
+ this.tilePage.positionTile_(this.index);
+
+ // Take an appropriate action with the drag clone.
+ if (this.landedOnTrash) {
+ this.dragClone.classList.add('deleting');
+ } else if (this.tilePage) {
+ if (this.tilePage.selected) {
+ // The tile's contents may have moved following the respositioning;
+ // adjust for that.
+ var contentDiffX = this.dragClone.firstChild.offsetLeft -
+ this.firstChild.offsetLeft;
+ var contentDiffY = this.dragClone.firstChild.offsetTop -
+ this.firstChild.offsetTop;
+ this.dragClone.style.left = (this.gridX + this.parentNode.offsetLeft -
+ contentDiffX) + 'px';
+ this.dragClone.style.top =
+ (this.gridY + this.parentNode.getBoundingClientRect().top -
+ contentDiffY) + 'px';
+ } else {
+ this.dragClone.classList.add('dropped-on-other-page');
+ }
}
- this.tilePage.positionTile_(this.index);
-
- if (this.tilePage.selected) {
- // The tile's contents may have moved following the respositioning;
- // adjust for that.
- var contentDiffX = this.dragClone.firstChild.offsetLeft -
- this.firstChild.offsetLeft;
- var contentDiffY = this.dragClone.firstChild.offsetTop -
- this.firstChild.offsetTop;
- this.dragClone.style.left = (this.gridX + this.parentNode.offsetLeft -
- contentDiffX) + 'px';
- this.dragClone.style.top =
- (this.gridY + this.parentNode.getBoundingClientRect().top -
- contentDiffY) + 'px';
- } else {
- // When we're showing another page and a drag fails or gets cancelled,
- // the tile shrinks to a dot.
- this.dragClone.firstChild.style.webkitTransform = 'scale(0)';
- }
+ this.landedOnTrash = false;
},
/**
@@ -250,6 +244,8 @@ cr.define('ntp4', function() {
clone.parentNode.removeChild(clone);
this.eventTracker.remove(clone, 'webkitTransitionEnd');
this.classList.remove('dragging');
+ if (this.firstChild.finalizeDrag)
+ this.firstChild.finalizeDrag();
},
/**
@@ -895,23 +891,20 @@ cr.define('ntp4', function() {
if (!((index == this.dragItemIndex_) && this.withinPageDrag_)) {
var adjustedIndex = this.currentDropIndex_ +
(index > this.dragItemIndex_ ? 1 : 0);
- if (currentlyDraggingTile) {
- var originalPage = currentlyDraggingTile.tilePage;
+ if (this.withinPageDrag_) {
this.tileGrid_.insertBefore(
currentlyDraggingTile,
this.tileElements_[adjustedIndex]);
-
- if (originalPage != this)
- originalPage.cleanupDrag();
this.tileMoved(currentlyDraggingTile);
-
- // Dropping the icon may cause topMargin to change, but changing it
- // now would cause everything to move (annoying), so we leave it
- // alone. The top margin will be re-calculated next time the window is
- // resized or the page is selected.
} else {
- this.addOutsideData(e.dataTransfer, adjustedIndex);
+ this.addDragData(e.dataTransfer, adjustedIndex);
+ currentlyDraggingTile.tilePage.cleanupDrag();
}
+
+ // Dropping the icon may cause topMargin to change, but changing it
+ // now would cause everything to move (annoying), so we leave it
+ // alone. The top margin will be re-calculated next time the window is
+ // resized or the page is selected.
}
this.classList.remove('animating-tile-page');
@@ -927,9 +920,8 @@ cr.define('ntp4', function() {
if (originalPage == this)
return;
- this.tileGrid_.appendChild(currentlyDraggingTile);
+ this.addDragData(null, this.tileElements_.length - 1);
Rick Byers 2011/08/08 18:37:03 Seems a little ugly that you have to pass null as
Evan Stade 2011/08/08 20:42:55 Done.
originalPage.cleanupDrag();
- this.tileMoved(currentlyDraggingTile);
},
/**
@@ -985,14 +977,12 @@ cr.define('ntp4', function() {
},
/**
- * Called to accept a drag drop.
+ * Called to accept a drag drop. Will not be called for in-page drops.
* @param {Object} dataTransfer The data transfer object that holds the drop
* data.
* @param {number} index The tile index at which the drop occurred.
*/
- addOutsideData: function(dataTransfer, index) {
- // This should not get called unless there is a non-default
- // implementation.
+ addDragData: function(dataTransfer, index) {
assert(false);
},
« no previous file with comments | « chrome/browser/resources/ntp4/tile_page.css ('k') | chrome/browser/resources/ntp4/trash.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698