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('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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 /** | 496 /** |
497 * Returns any extra padding to insert to the bottom of a tile page. By | 497 * Returns any extra padding to insert to the bottom of a tile page. By |
498 * default there is none, but subclasses can override. | 498 * default there is none, but subclasses can override. |
499 * @type {number} | 499 * @type {number} |
500 */ | 500 */ |
501 get extraBottomPadding() { | 501 get extraBottomPadding() { |
502 return 0; | 502 return 0; |
503 }, | 503 }, |
504 | 504 |
505 /** | 505 /** |
506 * The notification content of this tile (if any, otherwise null). | |
507 * @type {!HTMLElement} | |
508 */ | |
509 get notification() { | |
510 return this.topMargin_.nextElementSibling.id == 'notification-container' ? | |
511 this.topMargin_.nextElementSibling : null; | |
512 }, | |
513 /** | |
514 * The notification content of this tile (if any, otherwise null). | |
515 * @param {!HTMLElement} | |
516 */ | |
517 set notification(node) { | |
518 assert(node instanceof HTMLElement, '|node| isn\'t an HTMLElement!'); | |
519 // NOTE: Implicitly removes from DOM if |node| is inside it. | |
520 this.content_.insertBefore(node, this.topMargin_.nextElementSibling); | |
521 this.positionNotification_(); | |
522 }, | |
523 | |
524 /** | |
506 * Removes the tilePage from the DOM and cleans up event handlers. | 525 * Removes the tilePage from the DOM and cleans up event handlers. |
507 */ | 526 */ |
508 remove: function() { | 527 remove: function() { |
509 // This checks arguments.length as most remove functions have a boolean | 528 // This checks arguments.length as most remove functions have a boolean |
510 // |opt_animate| argument, but that's not necesarilly applicable to | 529 // |opt_animate| argument, but that's not necesarilly applicable to |
511 // removing a tilePage. Selecting a different card in an animated way and | 530 // removing a tilePage. Selecting a different card in an animated way and |
512 // deleting the card afterward is probably a better choice. | 531 // deleting the card afterward is probably a better choice. |
513 assert(typeof arguments[0] != 'boolean', | 532 assert(typeof arguments[0] != 'boolean', |
514 'This function takes no |opt_animate| argument.'); | 533 'This function takes no |opt_animate| argument.'); |
515 this.tearDown_(); | 534 this.tearDown_(); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
903 return; | 922 return; |
904 } | 923 } |
905 | 924 |
906 this.calculateLayoutValues_(); | 925 this.calculateLayoutValues_(); |
907 | 926 |
908 this.lastWidth_ = this.clientWidth; | 927 this.lastWidth_ = this.clientWidth; |
909 this.lastHeight_ = this.clientHeight; | 928 this.lastHeight_ = this.clientHeight; |
910 this.classList.add('animating-tile-page'); | 929 this.classList.add('animating-tile-page'); |
911 this.heightChanged_(); | 930 this.heightChanged_(); |
912 | 931 |
932 this.positionNotification_(); | |
933 | |
Evan Stade
2012/02/07 01:07:21
nit: remove newline
Dan Beam
2012/02/07 01:42:27
Done.
| |
913 this.repositionTiles_(); | 934 this.repositionTiles_(); |
914 }, | 935 }, |
915 | 936 |
916 /** | 937 /** |
917 * The tile grid has an image mask which fades at the edges. We only show | 938 * The tile grid has an image mask which fades at the edges. We only show |
918 * the mask when there is an active drag; it obscures doppleganger tiles | 939 * the mask when there is an active drag; it obscures doppleganger tiles |
919 * as they enter or exit the grid. | 940 * as they enter or exit the grid. |
920 * @private | 941 * @private |
921 */ | 942 */ |
922 updateMask_: function() { | 943 updateMask_: function() { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
977 this.animatedTopMarginPx_ + 'px'; | 998 this.animatedTopMarginPx_ + 'px'; |
978 } | 999 } |
979 | 1000 |
980 this.topMarginIsForWide_ = layout.wide; | 1001 this.topMarginIsForWide_ = layout.wide; |
981 this.topMarginPx_ = newMargin; | 1002 this.topMarginPx_ = newMargin; |
982 this.topMargin_.style.marginTop = | 1003 this.topMargin_.style.marginTop = |
983 (this.topMarginPx_ - this.animatedTopMarginPx_) + 'px'; | 1004 (this.topMarginPx_ - this.animatedTopMarginPx_) + 'px'; |
984 }, | 1005 }, |
985 | 1006 |
986 /** | 1007 /** |
1008 * Position the notification if there's one showing. | |
1009 */ | |
1010 positionNotification_: function() { | |
1011 if (this.notification && !this.notification.hidden) { | |
1012 this.notification.style.margin = | |
1013 -this.notification.offsetHeight + 'px ' + | |
1014 this.layoutValues_.leftMargin + 'px 0'; | |
1015 } | |
1016 }, | |
1017 | |
1018 /** | |
987 * Handles final setup that can only happen after |this| is inserted into | 1019 * Handles final setup that can only happen after |this| is inserted into |
988 * the page. | 1020 * the page. |
989 * @private | 1021 * @private |
990 */ | 1022 */ |
991 onNodeInsertedIntoDocument_: function(e) { | 1023 onNodeInsertedIntoDocument_: function(e) { |
992 this.calculateLayoutValues_(); | 1024 this.calculateLayoutValues_(); |
993 this.heightChanged_(); | 1025 this.heightChanged_(); |
994 }, | 1026 }, |
995 | 1027 |
996 /** | 1028 /** |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1289 assert(false); | 1321 assert(false); |
1290 }, | 1322 }, |
1291 }; | 1323 }; |
1292 | 1324 |
1293 return { | 1325 return { |
1294 getCurrentlyDraggingTile: getCurrentlyDraggingTile, | 1326 getCurrentlyDraggingTile: getCurrentlyDraggingTile, |
1295 setCurrentDropEffect: setCurrentDropEffect, | 1327 setCurrentDropEffect: setCurrentDropEffect, |
1296 TilePage: TilePage, | 1328 TilePage: TilePage, |
1297 }; | 1329 }; |
1298 }); | 1330 }); |
OLD | NEW |