Index: notification.js |
=================================================================== |
--- a/notification.js |
+++ b/notification.js |
@@ -1,6 +1,6 @@ |
/* |
* This file is part of Adblock Plus <http://adblockplus.org/>, |
- * Copyright (C) 2006-2013 Eyeo GmbH |
+ * Copyright (C) 2006-2014 Eyeo GmbH |
* |
* Adblock Plus is free software: you can redistribute it and/or modify |
* it under the terms of the GNU General Public License version 3 as |
@@ -15,6 +15,12 @@ |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
+//This case is true only for chrome when loading from notification.html |
+if (typeof ext === "undefined") |
+{ |
+ var ext = chrome.extension.getBackgroundPage().ext; |
+} |
+ |
var backgroundPage = ext.backgroundPage.getWindow(); |
var require = backgroundPage.require; |
@@ -65,9 +71,6 @@ |
if (!notification) |
return; |
- if (notification.onClicked) |
- notification.onClicked(); |
- |
var texts = Notification.getLocalizedTexts(notification); |
var titleElement = document.getElementById("notification-title"); |
titleElement.textContent = texts.title; |
@@ -85,10 +88,38 @@ |
return; |
event.preventDefault(); |
event.stopPropagation(); |
- ext.windows.getLastFocused(function(win) { win.openTab(link.href); }); |
+ ext.pages.open(link.href); |
}); |
+ if (notification.type == "question") |
+ { |
+ document.getElementById("notification-question").addEventListener("click", function(event) |
+ { |
+ event.preventDefault(); |
+ event.stopPropagation(); |
+ |
+ var approved = false; |
+ switch (event.target.id) |
+ { |
+ case "notification-yes": |
+ approved = true; |
+ case "notification-no": |
+ Notification.triggerQuestionListeners(notification.id, approved); |
+ Notification.markAsShown(notification.id); |
+ notification.onClicked(); |
+ break; |
+ } |
+ window.close(); |
+ }, true); |
+ } |
+ |
var notificationElement = document.getElementById("notification"); |
- notificationElement.className = notification.severity; |
+ notificationElement.className = notification.type; |
notificationElement.style.display = "block"; |
-}); |
+ |
+ document.getElementById("close-notification").addEventListener("click", function() |
+ { |
+ notificationElement.style.display = "none"; |
+ notification.onClicked(); |
+ }, false); |
+}, false); |