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

Unified Diff: lib/ui.js

Issue 6526453483044864: Issue 2193 - Added notification opt-out (Firefox) (Closed)
Patch Set: Created June 26, 2015, 3:29 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
« no previous file with comments | « chrome/skin/overlay.css ('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
@@ -125,6 +125,14 @@
this.value = Prefs.savestats;
});
+ hideElement("adblockplus-shownotifications", !Prefs.notifications_showui);
+ setChecked("adblockplus-shownotifications", Prefs.notifications_ignoredcategories.indexOf("*") == -1);
+ addCommandHandler("adblockplus-shownotifications", function()
+ {
+ Notification.toggleIgnoreCategory("*");
+ this.value = (Prefs.notifications_ignoredcategories.indexOf("*") == -1);
+ });
+
let hasAcceptableAds = FilterStorage.subscriptions.some((subscription) => subscription instanceof DownloadableSubscription &&
subscription.url == Prefs.subscriptions_exceptionsurl);
setChecked("adblockplus-acceptableAds", hasAcceptableAds);
@@ -587,9 +595,21 @@
}.bind(this));
addBrowserClickListener(window, this.onBrowserClick.bind(this, window));
- window.document.getElementById("abp-notification-close").addEventListener("command", function(event)
+ let notificationPanel = window.document.getElementById("abp-notification");
+ notificationPanel.addEventListener("command", function(event)
{
- window.document.getElementById("abp-notification").hidePopup();
+ switch (event.target.id)
+ {
+ case "abp-notification-close":
+ notificationPanel.classList.add("abp-closing");
+ break;
+ case "abp-notification-optout":
+ Notification.toggleIgnoreCategory("*", true);
+ /* FALL THROUGH */
+ case "abp-notification-hide":
+ notificationPanel.hidePopup();
+ break;
+ }
}, false);
// First-run actions?
@@ -1563,10 +1583,12 @@
let hasStatusBar = statusbarPosition;
hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar-");
hideElement(prefix + "showinstatusbar", !hasStatusBar);
+ hideElement(prefix + "shownotifications", !Prefs.notifications_showui);
hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || !hasToolbar) && !hasStatusBar);
setChecked(prefix + "showintoolbar", this.isToolbarIconVisible());
setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar);
+ setChecked(prefix + "shownotifications", Prefs.notifications_ignoredcategories.indexOf("*") == -1);
let {Sync} = require("sync");
let syncEngine = Sync.getEngine();
@@ -1954,7 +1976,8 @@
["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showinstatusbar")],
["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")],
["abp-command-contribute", "command", UI.openContributePage.bind(UI)],
- ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)]
+ ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)],
+ ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCategory.bind(Notification, "*", null)]
];
onShutdown.add(function()
« no previous file with comments | « chrome/skin/overlay.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld