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

Unified Diff: lib/ui.js

Issue 11165026: Show notifications on startup (Closed)
Patch Set: Created July 19, 2013, 1:41 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
« lib/notification.js ('K') | « lib/notification.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/ui.js
===================================================================
--- a/lib/ui.js
+++ b/lib/ui.js
@@ -29,6 +29,7 @@
let {Subscription, SpecialSubscription, DownloadableSubscription} = require("subscriptionClasses");
let {Synchronizer} = require("synchronizer");
let {KeySelector} = require("keySelector");
+let {Notification} = require("notification");
/**
* Filter corresponding with "disable on site" menu item (set in fillIconMent()).
@@ -420,6 +421,14 @@
if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(action) || action == "load")
this.updateState();
}.bind(this));
+
+ let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
Wladimir Palant 2013/07/19 15:17:52 Sure, we do: onShutdown.add(function() timer.ca
Felix Dahlke 2013/07/19 17:07:01 Done.
+ timer.initWithCallback(function()
+ {
+ let notificationToShow = Notification.getNextToShow();
+ if (notificationToShow)
+ this._showNotification(notificationToShow);
+ }.bind(this), 3 * 60 * 1000, Ci.nsITimer.TYPE_ONE_SHOT);
},
/**
@@ -1914,6 +1923,44 @@
if (button)
button.hidden = true;
}
+ },
+
+ _showNotification: function(notification)
+ {
+ let window = null;
+ for (window in this.applicationWindows)
+ break;
+
+ if (!window)
+ return;
Wladimir Palant 2013/07/19 15:17:52 We already marked the notification as shown at thi
Felix Dahlke 2013/07/19 17:07:01 Done.
+
+ let button = window.document.getElementById("abp-toolbarbutton")
+ || window.document.getElementById("abp-status");
+ if (!button)
+ return;
+
+ let texts = Notification.getLocalizedTexts(notification);
+ let titleElement = window.document.getElementById("abp-notification-title");
+ titleElement.setAttribute("value", texts.title);
+ let messageElement = window.document.getElementById("abp-notification-message");
+ let message = texts.message.replace(/<(\/?)a(.*?)>/g, "<$1html:a$2>");
+ messageElement.innerHTML = message;
+
+ let links = window.document.querySelectorAll("#abp-notification-message a");
+ for each (let link in links)
+ {
+ let url = link.href;
+ let ui = this;
+ link.onclick = function(event)
+ {
+ event.preventDefault();
+ event.stopPropagation();
+ ui.loadInBrowser(url, window);
+ };
+ }
+
+ let panel = window.document.getElementById("abp-notification");
+ panel.openPopup(button, "bottomcenter topcenter", 0, 0, false, false, null);
}
};
UI.onPopupShowing = UI.onPopupShowing.bind(UI);
« lib/notification.js ('K') | « lib/notification.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld