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 25db675f724a43b8fd464b847a7092337a60a74d..b16f20d44a13183978ce6db14a13442c52aba96d 100644 |
--- a/chrome/browser/resources/ntp_search/tile_page.js |
+++ b/chrome/browser/resources/ntp_search/tile_page.js |
@@ -78,10 +78,10 @@ cr.define('ntp', function() { |
}, |
/** |
- * Update the appearance of this tile according to |data|. |
+ * The data for this Tile. |
* @param {Object} data A dictionary of relevant data for the page. |
*/ |
- setData: function(data) { |
+ set data(data) { |
// TODO(pedrosimonetti): Remove data.filler usage everywhere. |
if (!data || data.filler) { |
if (this.data_) |
@@ -90,7 +90,7 @@ cr.define('ntp', function() { |
} |
this.data_ = data; |
- } |
+ }, |
}; |
var TileGetters = { |
@@ -110,14 +110,6 @@ cr.define('ntp', function() { |
assert(this.tileCell); |
return this.tileCell.index; |
}, |
- |
- /** |
- * Tile data object. |
- * @type {Object} |
- */ |
- 'data': function() { |
- return this.data_; |
- } |
}; |
//---------------------------------------------------------------------------- |
@@ -166,7 +158,15 @@ cr.define('ntp', function() { |
*/ |
get index() { |
return Array.prototype.indexOf.call(this.tilePage.tiles_, |
- this.firstChild); |
+ this.tile); |
+ }, |
+ |
+ /** |
+ * The Tile associated to this TileCell. |
+ * @type {Tile} |
Dan Beam
2012/12/07 05:05:31
nit: you should assert(this.firstElementChild) and
pedro (no code reviews)
2012/12/07 21:54:55
We cannot do that because sometimes we use |if (ce
|
+ */ |
+ get tile() { |
+ return this.firstElementChild; |
}, |
/** |
@@ -182,8 +182,8 @@ cr.define('ntp', function() { |
* @type {TilePage} |
*/ |
assign: function(tile) { |
- if (this.firstChild) |
- this.replaceChild(tile, this.firstChild); |
+ if (this.tile) |
+ this.replaceChild(tile, this.tile); |
else |
this.appendChild(tile); |
}, |
@@ -193,10 +193,7 @@ cr.define('ntp', function() { |
* @param {boolean=} opt_animate Whether the animation should be animated. |
*/ |
doRemove: function(opt_animate) { |
- if (opt_animate) |
- this.firstChild.classList.add('removing-tile-contents'); |
- else |
- this.tilePage.removeTile(this, false); |
+ this.tilePage.removeTile(this.tile, false); |
}, |
}; |
@@ -481,7 +478,7 @@ cr.define('ntp', function() { |
if (i >= dataList.length) |
tile.reset(); |
else |
- tile.setData(data); |
+ tile.data = data; |
} |
}, |
@@ -639,16 +636,16 @@ cr.define('ntp', function() { |
if (tile < tileCount) { |
tileCell.classList.remove('filler'); |
tileElement = tiles[tile]; |
- if (!tileCell.firstChild) |
+ if (!tileCell.tile) |
tileCell.appendChild(tileElement); |
- else if (tileElement != tileCell.firstChild) |
- tileCell.replaceChild(tileElement, tileCell.firstChild); |
+ else if (tileElement != tileCell.tile) |
+ tileCell.replaceChild(tileElement, tileCell.tile); |
} else if (!tileCell.classList.contains('filler')) { |
tileCell.classList.add('filler'); |
tileElement = cr.doc.createElement('span'); |
tileElement.className = 'tile'; |
- if (tileCell.firstChild) |
- tileCell.replaceChild(tileElement, tileCell.firstChild); |
+ if (tileCell.tile) |
+ tileCell.replaceChild(tileElement, tileCell.tile); |
else |
tileCell.appendChild(tileElement); |
} |
@@ -857,7 +854,7 @@ cr.define('ntp', function() { |
var tileBeingRestored = createTile(this, restoredData); |
tileCells[index].appendChild(tileBeingRestored); |
- var extraTile = extraCell.firstChild; |
+ var extraTile = extraCell.tile; |
this.executeRepositioningAnimation_(tileBeingRestored, extraTile, |
repositioningStartIndex, repositioningEndIndex, false); |
@@ -1075,7 +1072,7 @@ cr.define('ntp', function() { |
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.setData(opt_data); |
+ tile.data = opt_data; |
} else { |
// Otherwise, it will be a fake filler tile. |
tile = cr.doc.createElement('span'); |