OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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('ntp', function() { | 5 cr.define('ntp', 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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 this.tileGrid_.style.WebkitMaskBoxImage = gradient; | 977 this.tileGrid_.style.WebkitMaskBoxImage = gradient; |
978 }, | 978 }, |
979 | 979 |
980 updateTopMargin_: function() { | 980 updateTopMargin_: function() { |
981 var layout = this.layoutValues_; | 981 var layout = this.layoutValues_; |
982 | 982 |
983 // The top margin is set so that the vertical midpoint of the grid will | 983 // The top margin is set so that the vertical midpoint of the grid will |
984 // be 1/3 down the page. | 984 // be 1/3 down the page. |
985 var numTiles = this.tileCount + | 985 var numTiles = this.tileCount + |
986 (this.isCurrentDragTarget && !this.withinPageDrag_ ? 1 : 0); | 986 (this.isCurrentDragTarget && !this.withinPageDrag_ ? 1 : 0); |
987 // Minimum of 1 row (this can come into play when there is an app install | |
988 // hint hiding the webstore tile, and there are no other tiles). | |
989 var numRows = Math.max(1, Math.ceil(numTiles / layout.numRowTiles)); | 987 var numRows = Math.max(1, Math.ceil(numTiles / layout.numRowTiles)); |
990 var usedHeight = layout.rowHeight * numRows; | 988 var usedHeight = layout.rowHeight * numRows; |
991 var newMargin = document.documentElement.clientHeight / 3 - | 989 var newMargin = document.documentElement.clientHeight / 3 - |
992 usedHeight / 3 - this.contentPadding; | 990 usedHeight / 3 - this.contentPadding; |
993 // The 'height' style attribute of topMargin is non-zero to work around | 991 // The 'height' style attribute of topMargin is non-zero to work around |
994 // webkit's collapsing margin behavior, so we have to factor that into | 992 // webkit's collapsing margin behavior, so we have to factor that into |
995 // our calculations here. | 993 // our calculations here. |
996 newMargin = Math.max(newMargin, 0) - this.topMargin_.offsetHeight; | 994 newMargin = Math.max(newMargin, 0) - this.topMargin_.offsetHeight; |
997 | 995 |
998 // |newMargin| is the final margin we actually want to show. However, | 996 // |newMargin| is the final margin we actually want to show. However, |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 assert(false); | 1337 assert(false); |
1340 }, | 1338 }, |
1341 }; | 1339 }; |
1342 | 1340 |
1343 return { | 1341 return { |
1344 getCurrentlyDraggingTile: getCurrentlyDraggingTile, | 1342 getCurrentlyDraggingTile: getCurrentlyDraggingTile, |
1345 setCurrentDropEffect: setCurrentDropEffect, | 1343 setCurrentDropEffect: setCurrentDropEffect, |
1346 TilePage: TilePage, | 1344 TilePage: TilePage, |
1347 }; | 1345 }; |
1348 }); | 1346 }); |
OLD | NEW |