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: Rebased to 5434ef6e1545 Created June 24, 2015, 4:19 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);
Wladimir Palant 2015/06/26 13:13:09 Nit: toggleIgnoreCategory() should really return t
Thomas Greiner 2015/06/26 15:32:48 Totally makes sense. I created #2727 for that now
+ });
+
let hasAcceptableAds = FilterStorage.subscriptions.some((subscription) => subscription instanceof DownloadableSubscription &&
subscription.url == Prefs.subscriptions_exceptionsurl);
setChecked("adblockplus-acceptableAds", hasAcceptableAds);
@@ -587,10 +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();
- }, false);
+ switch (event.target.id)
+ {
+ case "abp-notification-close":
+ notificationPanel.classList.add("abp-closing");
+ break;
+ case "abp-notification-optout":
+ Notification.toggleIgnoreCategory("*", true);
Wladimir Palant 2015/06/26 13:13:09 I'm not a huge fan of fallthrough in switch statem
Thomas Greiner 2015/06/26 15:32:48 Done. I guess it would make sense to add this to h
+ case "abp-notification-hide":
+ notificationPanel.hidePopup();
+ break;
+ }
+ }, true);
Wladimir Palant 2015/06/26 13:13:09 Why true? We don't usually add capturing event lis
Thomas Greiner 2015/06/26 15:32:48 Done.
// First-run actions?
this.firstRunActions(window);
@@ -1563,10 +1582,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 +1975,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