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); |