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

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: most visited polish 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
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..625c1a11b953a49d88eeb243e657114c3695b4af 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,34 @@ cr.define('ntp4', function() {
setCurrentlyDraggingTile(null);
- if (!this.tilePage) {
+ // 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.firstChild.classList.add('deleting');
- return;
+ } 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 {
+ // 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)';
Rick Byers 2011/08/08 15:24:15 shouldn't you really leave this presentation detai
Evan Stade 2011/08/08 18:26:58 Done.
+ }
}
- 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 +246,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 +893,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');
@@ -985,14 +980,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);
},

Powered by Google App Engine
This is Rietveld 408576698