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

Unified Diff: options.js

Issue 29321084: Issue 2195 - Added notification opt-out (Platform) (Closed)
Patch Set: Created June 25, 2015, 4:44 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 | « options.html ('k') | popup.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: options.js
===================================================================
--- a/options.js
+++ b/options.js
@@ -39,6 +39,7 @@
var Prefs = require("prefs").Prefs;
var Synchronizer = require("synchronizer").Synchronizer;
var Utils = require("utils").Utils;
+var NotificationStorage = require("notification").Notification;
// Loads options from localStorage and sets UI elements accordingly
function loadOptions()
@@ -76,6 +77,22 @@
// Popuplate option checkboxes
initCheckbox("shouldShowBlockElementMenu");
+ if (Prefs.notifications_showui)
+ {
+ initCheckbox("shouldShowNotifications", {
+ get: function()
+ {
+ return Prefs.notifications_ignoredcategories.indexOf("*") == -1;
+ },
+ toggle: function()
+ {
+ NotificationStorage.toggleIgnoreCategory("*");
+ return this.get();
+ }
+ });
+ }
+ else
+ document.getElementById("shouldShowNotificationsContainer").hidden = true;
ext.onMessage.addListener(onMessage);
@@ -131,12 +148,19 @@
FilterNotifier.removeListener(onFilterChange);
}
-function initCheckbox(id)
+function initCheckbox(id, descriptor)
{
var checkbox = document.getElementById(id);
- checkbox.checked = Prefs[id];
+ if (descriptor && descriptor.get)
+ checkbox.checked = descriptor.get();
+ else
+ checkbox.checked = Prefs[id];
+
checkbox.addEventListener("click", function()
{
+ if (descriptor && descriptor.toggle)
+ checkbox.checked = descriptor.toggle();
+
Prefs[id] = checkbox.checked;
}, false);
}
« no previous file with comments | « options.html ('k') | popup.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld