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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/ntp4/tile_page.js
diff --git a/chrome/browser/resources/ntp4/tile_page.js b/chrome/browser/resources/ntp4/tile_page.js
index 541bfbbcff183791f044bc760f16148726883bd5..5201c6028ccd205dfcc3d684b9aa57b1ea322465 100644
--- a/chrome/browser/resources/ntp4/tile_page.js
+++ b/chrome/browser/resources/ntp4/tile_page.js
@@ -503,6 +503,25 @@ cr.define('ntp4', function() {
},
/**
+ * The notification content of this tile (if any, otherwise null).
+ * @type {!HTMLElement}
+ */
+ get notification() {
+ return this.topMargin_.nextElementSibling.id == 'notification-container' ?
+ this.topMargin_.nextElementSibling : null;
+ },
+ /**
+ * The notification content of this tile (if any, otherwise null).
+ * @param {!HTMLElement}
+ */
+ set notification(node) {
+ assert(node instanceof HTMLElement, '|node| isn\'t an HTMLElement!');
+ // NOTE: Implicitly removes from DOM if |node| is inside it.
+ this.content_.insertBefore(node, this.topMargin_.nextElementSibling);
+ this.positionNotification_();
+ },
+
+ /**
* Removes the tilePage from the DOM and cleans up event handlers.
*/
remove: function() {
@@ -910,6 +929,7 @@ cr.define('ntp4', function() {
this.classList.add('animating-tile-page');
this.heightChanged_();
+ this.positionNotification_();
this.repositionTiles_();
},
@@ -984,6 +1004,17 @@ cr.define('ntp4', function() {
},
/**
+ * Position the notification if there's one showing.
+ */
+ positionNotification_: function() {
+ if (this.notification && !this.notification.hidden) {
+ this.notification.style.margin =
+ -this.notification.offsetHeight + 'px ' +
+ this.layoutValues_.leftMargin + 'px 0';
+ }
+ },
+
+ /**
* Handles final setup that can only happen after |this| is inserted into
* the page.
* @private
« 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