Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: notification.js

Issue 11161031: Show notifications on startup (Chrome) (Closed)
Patch Set: Address issue from the Firefox review Created July 20, 2013, 10:51 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« metadata.opera ('K') | « notification.html ('k') | popup.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: notification.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/notification.js
@@ -0,0 +1,35 @@
+window.addEventListener("load", function()
+{
+ var backgroundPage = chrome.extension.getBackgroundPage();
+ var notification = backgroundPage.activeNotification;
+ if (!notification)
+ return;
+
+ if (notification.onClicked)
+ notification.onClicked();
+
+ var texts = backgroundPage.getLocalizedTexts(notification);
Wladimir Palant 2013/07/21 11:15:30 Call Notification and Utils directly here (via req
Felix Dahlke 2013/07/22 12:30:15 Done. Not sure why I didn't do it in fact.
+ var titleElement = document.getElementById("title");
+ titleElement.innerHTML = texts.title;
Wladimir Palant 2013/07/21 11:15:30 textContent please, not innerHTML.
Felix Dahlke 2013/07/22 12:30:15 Done.
+ var messageElement = document.getElementById("message");
+ messageElement.innerHTML = texts.message;
Wladimir Palant 2013/07/21 11:15:30 Please use the same code as in Firefox here, not i
Felix Dahlke 2013/07/21 12:19:53 Hehe, I thought I'd try :D This should be safe in
Felix Dahlke 2013/07/22 12:30:15 Done. I think it's less than great that this code
+
+ var docLinks = backgroundPage.getDocLinks(notification);
+ var linkElements = messageElement.getElementsByTagName("a");
+ for (var i = 0; i < linkElements.length; i++)
+ {
+ var linkElement = linkElements[i];
+ if (docLinks && docLinks.length)
+ linkElement.href = docLinks.shift();
+ linkElement.addEventListener("click", function(event)
+ {
+ event.preventDefault();
+ event.stopPropagation();
+ chrome.tabs.create({url: linkElement.href});
+ });
+ }
+
+ var notificationElement = document.getElementById("notification");
+ notificationElement.className = notification.severity;
+ notificationElement.style.display = "block";
+});
« metadata.opera ('K') | « notification.html ('k') | popup.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld