Index: chrome/browser/resources/new_new_tab.js |
=================================================================== |
--- chrome/browser/resources/new_new_tab.js (revision 67122) |
+++ chrome/browser/resources/new_new_tab.js (working copy) |
@@ -794,7 +794,11 @@ |
var notificationTimeout; |
-function showNotification(text, actionText, opt_f, opt_delay) { |
+/* |
+ * Displays a message (either a string or a document fragment) in the |
+ * notification slot at the top of the NTP. |
+ */ |
+function showNotification(message, actionText, opt_f, opt_delay) { |
arv (Not doing code reviews)
2010/11/24 17:28:49
/**
* Displays a message in the notification slot
|
var notificationElement = $('notification'); |
var f = opt_f || function() {}; |
var delay = opt_delay || 10000; |
@@ -814,11 +818,20 @@ |
hideNotification(); |
} |
- // Remove any possible first-run trails. |
+ // Remove classList entries from previous notifications. |
notification.classList.remove('first-run'); |
+ notification.classList.remove('promo'); |
+ var notificationNode = notificationElement.firstElementChild; |
+ notificationNode.removeChild(notificationNode.firstChild); |
+ |
var actionLink = notificationElement.querySelector('.link-color'); |
- notificationElement.firstElementChild.textContent = text; |
+ |
+ if ((typeof message) == "string") |
arv (Not doing code reviews)
2010/11/24 17:28:49
Single quotes and too many parens
if (typeof mess
|
+ notificationElement.firstElementChild.textContent = message; |
+ else |
+ notificationElement.firstElementChild.appendChild(message); |
+ |
actionLink.textContent = actionText; |
actionLink.onclick = doAction; |
@@ -859,6 +872,15 @@ |
notification.classList.add('first-run'); |
} |
+function showPromoNotification() { |
+ showNotification(parseHtmlSubset(localStrings.getString('serverpromo')), |
+ localStrings.getString('closefirstrunnotification'), |
+ function () { chrome.send('closePromo'); }, |
+ 60000); |
+ var notificationElement = $('notification'); |
+ notification.classList.add('promo'); |
+} |
+ |
$('main').addEventListener('click', function(e) { |
var p = e.target; |
while (p && p.tagName != 'H2') { |
@@ -1190,6 +1212,8 @@ |
// Only show the first run notification if first run. |
if (firstRun) { |
showFirstRunNotification(); |
+ } else if (localStrings.getString('serverpromo')) { |
+ showPromoNotification(); |
} |
} |