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

Unified Diff: chrome/browser/resources/new_new_tab.js

Issue 4804001: Add new promotional line for NTP.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « chrome/browser/resources/new_new_tab.css ('k') | chrome/browser/web_resource/web_resource_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
}
« no previous file with comments | « chrome/browser/resources/new_new_tab.css ('k') | chrome/browser/web_resource/web_resource_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698