Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: chrome/browser/resources/ntp4/tile_page.js

Issue 9318017: [NTP4] Redesign of notification promo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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_();
913 this.repositionTiles_(); 933 this.repositionTiles_();
914 }, 934 },
915 935
916 /** 936 /**
917 * The tile grid has an image mask which fades at the edges. We only show 937 * 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 938 * the mask when there is an active drag; it obscures doppleganger tiles
919 * as they enter or exit the grid. 939 * as they enter or exit the grid.
920 * @private 940 * @private
921 */ 941 */
922 updateMask_: function() { 942 updateMask_: function() {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 this.animatedTopMarginPx_ + 'px'; 997 this.animatedTopMarginPx_ + 'px';
978 } 998 }
979 999
980 this.topMarginIsForWide_ = layout.wide; 1000 this.topMarginIsForWide_ = layout.wide;
981 this.topMarginPx_ = newMargin; 1001 this.topMarginPx_ = newMargin;
982 this.topMargin_.style.marginTop = 1002 this.topMargin_.style.marginTop =
983 (this.topMarginPx_ - this.animatedTopMarginPx_) + 'px'; 1003 (this.topMarginPx_ - this.animatedTopMarginPx_) + 'px';
984 }, 1004 },
985 1005
986 /** 1006 /**
1007 * Position the notification if there's one showing.
1008 */
1009 positionNotification_: function() {
1010 if (this.notification && !this.notification.hidden) {
1011 this.notification.style.margin =
1012 -this.notification.offsetHeight + 'px ' +
1013 this.layoutValues_.leftMargin + 'px 0';
1014 }
1015 },
1016
1017 /**
987 * Handles final setup that can only happen after |this| is inserted into 1018 * Handles final setup that can only happen after |this| is inserted into
988 * the page. 1019 * the page.
989 * @private 1020 * @private
990 */ 1021 */
991 onNodeInsertedIntoDocument_: function(e) { 1022 onNodeInsertedIntoDocument_: function(e) {
992 this.calculateLayoutValues_(); 1023 this.calculateLayoutValues_();
993 this.heightChanged_(); 1024 this.heightChanged_();
994 }, 1025 },
995 1026
996 /** 1027 /**
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 assert(false); 1320 assert(false);
1290 }, 1321 },
1291 }; 1322 };
1292 1323
1293 return { 1324 return {
1294 getCurrentlyDraggingTile: getCurrentlyDraggingTile, 1325 getCurrentlyDraggingTile: getCurrentlyDraggingTile,
1295 setCurrentDropEffect: setCurrentDropEffect, 1326 setCurrentDropEffect: setCurrentDropEffect,
1296 TilePage: TilePage, 1327 TilePage: TilePage,
1297 }; 1328 };
1298 }); 1329 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/tile_page.css ('k') | chrome/browser/resources/shared/js/cr/ui/card_slider.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698