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

Unified Diff: chrome/browser/resources/ntp4/new_tab.js

Issue 7124002: ntp4: notification area (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: notification area Created 9 years, 6 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/new_tab.js
diff --git a/chrome/browser/resources/ntp4/new_tab.js b/chrome/browser/resources/ntp4/new_tab.js
index 22e0a5eb70a3e0c7a57d2895f584e8fdc678252e..2f9922da4fc5de677e92cb4adb47ba4746a25a5b 100644
--- a/chrome/browser/resources/ntp4/new_tab.js
+++ b/chrome/browser/resources/ntp4/new_tab.js
@@ -84,6 +84,10 @@ cr.define('ntp4', function() {
trash = getRequiredElement('trash');
trash.hidden = true;
+ document.querySelector('#notification button').onclick = function(e) {
+ hideNotification();
+ };
+
// Request data on the apps so we can fill them in.
// Note that this is kicked off asynchronously. 'getAppsCallback' will be
// invoked at some point after this function returns.
@@ -371,7 +375,51 @@ cr.define('ntp4', function() {
} else {
attribution.hidden = true;
}
+ }
+
+ /**
+ * Timeout ID.
+ * @type {number}
+ */
+ var notificationTimeout_ = 0;
+
+ /**
+ * Shows the notification bubble.
+ * @param {string} text The notification message.
+ * @param {array} links An array of objects describing the links in the
Rick Byers 2011/06/08 20:41:10 You could precisely describe the type using closur
Evan Stade 2011/06/08 23:54:52 yes, I think that's it except with one fewer pair
+ * notification. Each object should have a 'text' attribute (a string)
+ * and an 'action' attribute (a function to run when the link is
+ * activated).
+ */
+ function showNotification(text, links) {
+ window.clearTimeout(notificationTimeout_);
+ document.querySelector('#notification > span').textContent = text;
+
+ var linksBin = $('notificationLinks');
+ linksBin.textContent = '';
+ for (var i = 0; i < links.length; i++) {
+ var link = linksBin.ownerDocument.createElement('div');
+ link.textContent = links[i].text;
+ var action = links[i].action;
+ link.onclick = function(e) {
+ action();
+ hideNotification();
+ }
+ link.setAttribute('role', 'button');
+ link.setAttribute('tabindex', 0);
+ link.className = "linkButton";
+ linksBin.appendChild(link);
+ }
+ $('notification').classList.remove('inactive');
+ notificationTimeout_ = window.setTimeout(hideNotification, 10000);
+ }
+
+ /**
+ * Hide the notification bubble.
+ */
+ function hideNotification() {
+ $('notification').classList.add('inactive');
}
function setRecentlyClosedTabs(dataItems) {
@@ -395,6 +443,7 @@ cr.define('ntp4', function() {
themeChanged: themeChanged,
setRecentlyClosedTabs: setRecentlyClosedTabs,
setMostVisitedPages: setMostVisitedPages,
+ showNotification: showNotification,
};
});

Powered by Google App Engine
This is Rietveld 408576698