| 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 /** | 493 /** |
| 494 * Returns the width of the scrollbar, in pixels, if it is active, or 0 | 494 * Returns the width of the scrollbar, in pixels, if it is active, or 0 |
| 495 * otherwise. | 495 * otherwise. |
| 496 * @type {number} | 496 * @type {number} |
| 497 */ | 497 */ |
| 498 get scrollbarWidth() { | 498 get scrollbarWidth() { |
| 499 return this.scrollbar_.hidden ? 0 : 13; | 499 return this.scrollbar_.hidden ? 0 : 13; |
| 500 }, | 500 }, |
| 501 | 501 |
| 502 /** | 502 /** |
| 503 * Returns any extra padding to insert to the bottom of a tile page. By | |
| 504 * default there is none, but subclasses can override. | |
| 505 * @type {number} | |
| 506 */ | |
| 507 get extraBottomPadding() { | |
| 508 return 0; | |
| 509 }, | |
| 510 | |
| 511 /** | |
| 512 * The notification content of this tile (if any, otherwise null). | 503 * The notification content of this tile (if any, otherwise null). |
| 513 * @type {!HTMLElement} | 504 * @type {!HTMLElement} |
| 514 */ | 505 */ |
| 515 get notification() { | 506 get notification() { |
| 516 return this.topMargin_.nextElementSibling.id == 'notification-container' ? | 507 return this.topMargin_.nextElementSibling.id == 'notification-container' ? |
| 517 this.topMargin_.nextElementSibling : null; | 508 this.topMargin_.nextElementSibling : null; |
| 518 }, | 509 }, |
| 519 /** | 510 /** |
| 520 * The notification content of this tile (if any, otherwise null). | 511 * The notification content of this tile (if any, otherwise null). |
| 521 * @type {!HTMLElement} | 512 * @type {!HTMLElement} |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 /** | 1089 /** |
| 1099 * Called when the height of |this| has changed: update the size of | 1090 * Called when the height of |this| has changed: update the size of |
| 1100 * tileGrid. | 1091 * tileGrid. |
| 1101 * @private | 1092 * @private |
| 1102 */ | 1093 */ |
| 1103 heightChanged_: function() { | 1094 heightChanged_: function() { |
| 1104 // The tile grid will expand to the bottom footer, or enough to hold all | 1095 // The tile grid will expand to the bottom footer, or enough to hold all |
| 1105 // the tiles, whichever is greater. It would be nicer if tilePage were | 1096 // the tiles, whichever is greater. It would be nicer if tilePage were |
| 1106 // a flex box, and the tile grid could be box-flex: 1, but this exposes a | 1097 // a flex box, and the tile grid could be box-flex: 1, but this exposes a |
| 1107 // bug where repositioning tiles will cause the scroll position to reset. | 1098 // bug where repositioning tiles will cause the scroll position to reset. |
| 1108 this.tileGrid_.style.minHeight = (this.clientHeight - | 1099 this.tileGrid_.style.minHeight = this.clientHeight - |
| 1109 this.tileGrid_.offsetTop - this.content_.offsetTop - | 1100 this.tileGrid_.offsetTop - this.content_.offsetTop + 'px'; |
| 1110 this.extraBottomPadding - | |
| 1111 (this.footerNode_ ? this.footerNode_.clientHeight : 0)) + 'px'; | |
| 1112 }, | |
| 1113 | |
| 1114 /** | |
| 1115 * Places an element at the bottom of the content div. Used in bare-minimum | |
| 1116 * mode to hold #footer. | |
| 1117 * @param {HTMLElement} footerNode The node to append to content. | |
| 1118 */ | |
| 1119 appendFooter: function(footerNode) { | |
| 1120 this.footerNode_ = footerNode; | |
| 1121 this.content_.appendChild(footerNode); | |
| 1122 }, | 1101 }, |
| 1123 | 1102 |
| 1124 /** | 1103 /** |
| 1125 * Scrolls the page in response to an mousewheel event, although the event | 1104 * Scrolls the page in response to an mousewheel event, although the event |
| 1126 * may have been triggered on a different element. Return true if the | 1105 * may have been triggered on a different element. Return true if the |
| 1127 * event triggered scrolling, and false otherwise. | 1106 * event triggered scrolling, and false otherwise. |
| 1128 * This is called explicitly, which allows a consistent experience whether | 1107 * This is called explicitly, which allows a consistent experience whether |
| 1129 * the user scrolls on the page or on the page switcher, because this | 1108 * the user scrolls on the page or on the page switcher, because this |
| 1130 * function provides a common conversion factor between wheel delta and | 1109 * function provides a common conversion factor between wheel delta and |
| 1131 * scroll delta. | 1110 * scroll delta. |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 }; | 1378 }; |
| 1400 | 1379 |
| 1401 return { | 1380 return { |
| 1402 getCurrentlyDraggingTile: getCurrentlyDraggingTile, | 1381 getCurrentlyDraggingTile: getCurrentlyDraggingTile, |
| 1403 setCurrentDropEffect: setCurrentDropEffect, | 1382 setCurrentDropEffect: setCurrentDropEffect, |
| 1404 // Not used outside, just for usage in JSDoc inside this file. | 1383 // Not used outside, just for usage in JSDoc inside this file. |
| 1405 Tile: Tile, | 1384 Tile: Tile, |
| 1406 TilePage: TilePage, | 1385 TilePage: TilePage, |
| 1407 }; | 1386 }; |
| 1408 }); | 1387 }); |
| OLD | NEW |