OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('ntp4', function() { | 5 cr.define('ntp4', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 // We can't pass the currently dragging tile via dataTransfer because of | 8 // We can't pass the currently dragging tile via dataTransfer because of |
9 // http://crbug.com/31037 | 9 // http://crbug.com/31037 |
10 var currentlyDraggingTile = null; | 10 var currentlyDraggingTile = null; |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 this.classList.add('animating-tile-page'); | 493 this.classList.add('animating-tile-page'); |
494 var index = Array.prototype.indexOf.call(this.tileElements_, tile); | 494 var index = Array.prototype.indexOf.call(this.tileElements_, tile); |
495 tile.parentNode.removeChild(tile); | 495 tile.parentNode.removeChild(tile); |
496 this.calculateLayoutValues_(); | 496 this.calculateLayoutValues_(); |
497 for (var i = index; i < this.tileElements_.length; i++) { | 497 for (var i = index; i < this.tileElements_.length; i++) { |
498 this.positionTile_(i); | 498 this.positionTile_(i); |
499 } | 499 } |
500 }, | 500 }, |
501 | 501 |
502 /** | 502 /** |
503 * Removes all tiles from the page. | |
504 */ | |
505 removeAllTiles: function() { | |
506 while (this.tileElements_.length) { | |
arv (Not doing code reviews)
2011/08/13 01:02:07
why not use?
this.tileGrid_.innerHTML = '';
csilv
2011/08/13 01:48:17
I've changed this since this is going to be more e
| |
507 this.tileGrid_.removeChild(this.tileElements_[0]); | |
508 } | |
509 }, | |
510 | |
511 /** | |
503 * Makes some calculations for tile layout. These change depending on | 512 * Makes some calculations for tile layout. These change depending on |
504 * height, width, and the number of tiles. | 513 * height, width, and the number of tiles. |
505 * TODO(estade): optimize calls to this function. Do nothing if the page is | 514 * TODO(estade): optimize calls to this function. Do nothing if the page is |
506 * hidden, but call before being shown. | 515 * hidden, but call before being shown. |
507 * @private | 516 * @private |
508 */ | 517 */ |
509 calculateLayoutValues_: function() { | 518 calculateLayoutValues_: function() { |
510 var grid = this.gridValues_; | 519 var grid = this.gridValues_; |
511 var availableSpace = this.tileGrid_.clientWidth - 2 * MIN_WIDE_MARGIN; | 520 var availableSpace = this.tileGrid_.clientWidth - 2 * MIN_WIDE_MARGIN; |
512 var wide = availableSpace >= grid.minWideWidth; | 521 var wide = availableSpace >= grid.minWideWidth; |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
995 */ | 1004 */ |
996 tileMoved: function(draggedTile) { | 1005 tileMoved: function(draggedTile) { |
997 }, | 1006 }, |
998 }; | 1007 }; |
999 | 1008 |
1000 return { | 1009 return { |
1001 getCurrentlyDraggingTile: getCurrentlyDraggingTile, | 1010 getCurrentlyDraggingTile: getCurrentlyDraggingTile, |
1002 TilePage: TilePage, | 1011 TilePage: TilePage, |
1003 }; | 1012 }; |
1004 }); | 1013 }); |
OLD | NEW |