Chromium Code Reviews| Index: chrome/browser/resources/ntp_search/tile_page.js |
| diff --git a/chrome/browser/resources/ntp_search/tile_page.js b/chrome/browser/resources/ntp_search/tile_page.js |
| index 52c347d76143a44138ab22c9cf3b4d7ab71a56b5..ab56e0621e44c7fd75ce4d75716240371de5d25d 100644 |
| --- a/chrome/browser/resources/ntp_search/tile_page.js |
| +++ b/chrome/browser/resources/ntp_search/tile_page.js |
| @@ -126,12 +126,11 @@ cr.define('ntp', function() { |
| * @constructor |
| * @extends {HTMLDivElement} |
| * @param {HTMLElement} tile Tile element that will be associated to the cell. |
| - * @param {Object} config TilePage configuration object. |
| */ |
| - function TileCell(tile, config) { |
| + function TileCell(tile) { |
| var tileCell = cr.doc.createElement('div'); |
| tileCell.__proto__ = TileCell.prototype; |
| - tileCell.initialize(tile, config); |
| + tileCell.initialize(tile); |
| return tileCell; |
| } |
| @@ -142,9 +141,8 @@ cr.define('ntp', function() { |
| /** |
| * Initializes a TileCell. |
| * @param {Tile} tile The Tile that will be assigned to this TileCell. |
| - * @param {Object} config TilePage configuration object. |
| */ |
| - initialize: function(tile, config) { |
| + initialize: function(tile) { |
| this.className = 'tile-cell'; |
| this.assign(tile); |
| }, |
| @@ -451,7 +449,7 @@ cr.define('ntp', function() { |
| * @protected |
| */ |
| createTile_: function() { |
| - return new this.TileClass(this.config); |
| + return new this.TileClass(); |
| }, |
| /** |
| @@ -636,7 +634,7 @@ cr.define('ntp', function() { |
| tileCell = tileRowTiles[col]; |
| } else { |
| var span = cr.doc.createElement('span'); |
| - tileCell = new TileCell(span, this.config); |
| + tileCell = new TileCell(span); |
| } |
| // Render Tiles. |
| @@ -851,13 +849,25 @@ cr.define('ntp', function() { |
| var extraCell = tileCells[extraTileIndex]; |
| var extraTileData = newDataList[extraTileIndex + 1]; |
| + var restoredData = newDataList[index]; |
| + var tileBeingRestored = createTile(this, restoredData); |
| + |
| + // If the tile being restored/added is on the last position, and the |
| + // tile before that is on the last column of a particular row, then we |
| + // need to handle it separately once there will be no cell to put the |
| + // restored tile temporarily and there will be no rearrangement of tiles. |
|
Dan Beam
2012/12/14 18:28:13
I appreciate this comment but I'm still not quite
pedro (no code reviews)
2012/12/14 18:54:10
I've rewritten this comment, let me know if it is
|
| + if (!tileCells[index]) { |
| + this.appendTile(tileBeingRestored); |
| + tileBeingRestored.classList.add('target-tile'); |
| + fadeTile(tileBeingRestored, true); |
| + return; |
| + } |
| + |
| var repositioningStartIndex = index; |
| var repositioningEndIndex = tileCount - (extraTileData ? 1 : 0); |
| this.initializeRepositioningAnimation_(index, repositioningEndIndex); |
| - var restoredData = newDataList[index]; |
| - var tileBeingRestored = createTile(this, restoredData); |
| tileCells[index].appendChild(tileBeingRestored); |
| if (this.config.scrollable) |
| @@ -1084,8 +1094,7 @@ cr.define('ntp', function() { |
| var tile; |
| if (opt_data) { |
| // If there's data, the new tile will be a real one (not a filler). |
| - tile = new tilePage.TileClass(tilePage.config); |
| - tile.data = opt_data; |
| + tile = new tilePage.TileClass(opt_data); |
| } else { |
| // Otherwise, it will be a fake filler tile. |
| tile = cr.doc.createElement('span'); |