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

Side by Side Diff: lib/ui.js

Issue 6526453483044864: Issue 2193 - Added notification opt-out (Firefox) (Closed)
Patch Set: Created June 26, 2015, 3:29 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/skin/overlay.css ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 return; 118 return;
119 } 119 }
120 120
121 setChecked("adblockplus-savestats", Prefs.savestats); 121 setChecked("adblockplus-savestats", Prefs.savestats);
122 addCommandHandler("adblockplus-savestats", function() 122 addCommandHandler("adblockplus-savestats", function()
123 { 123 {
124 UI.toggleSaveStats(doc.defaultView); 124 UI.toggleSaveStats(doc.defaultView);
125 this.value = Prefs.savestats; 125 this.value = Prefs.savestats;
126 }); 126 });
127 127
128 hideElement("adblockplus-shownotifications", !Prefs.notifications_showui);
129 setChecked("adblockplus-shownotifications", Prefs.notifications_ignoredcat egories.indexOf("*") == -1);
130 addCommandHandler("adblockplus-shownotifications", function()
131 {
132 Notification.toggleIgnoreCategory("*");
133 this.value = (Prefs.notifications_ignoredcategories.indexOf("*") == -1);
134 });
135
128 let hasAcceptableAds = FilterStorage.subscriptions.some((subscription) => subscription instanceof DownloadableSubscription && 136 let hasAcceptableAds = FilterStorage.subscriptions.some((subscription) => subscription instanceof DownloadableSubscription &&
129 subscription.url == Prefs.subscriptions_exceptionsurl); 137 subscription.url == Prefs.subscriptions_exceptionsurl);
130 setChecked("adblockplus-acceptableAds", hasAcceptableAds); 138 setChecked("adblockplus-acceptableAds", hasAcceptableAds);
131 addCommandHandler("adblockplus-acceptableAds", function() 139 addCommandHandler("adblockplus-acceptableAds", function()
132 { 140 {
133 this.value = UI.toggleAcceptableAds(); 141 this.value = UI.toggleAcceptableAds();
134 }); 142 });
135 143
136 setChecked("adblockplus-sync", syncEngine && syncEngine.enabled); 144 setChecked("adblockplus-sync", syncEngine && syncEngine.enabled);
137 addCommandHandler("adblockplus-sync", function() 145 addCommandHandler("adblockplus-sync", function()
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 window.addEventListener("popupshowing", this.onPopupShowing, false); 588 window.addEventListener("popupshowing", this.onPopupShowing, false);
581 window.addEventListener("keypress", this.onKeyPress, false); 589 window.addEventListener("keypress", this.onKeyPress, false);
582 590
583 addBrowserLocationListener(window, function() 591 addBrowserLocationListener(window, function()
584 { 592 {
585 this.updateIconState(window, window.document.getElementById("abp-status")) ; 593 this.updateIconState(window, window.document.getElementById("abp-status")) ;
586 this.updateIconState(window, window.document.getElementById("abp-toolbarbu tton")); 594 this.updateIconState(window, window.document.getElementById("abp-toolbarbu tton"));
587 }.bind(this)); 595 }.bind(this));
588 addBrowserClickListener(window, this.onBrowserClick.bind(this, window)); 596 addBrowserClickListener(window, this.onBrowserClick.bind(this, window));
589 597
590 window.document.getElementById("abp-notification-close").addEventListener("c ommand", function(event) 598 let notificationPanel = window.document.getElementById("abp-notification");
599 notificationPanel.addEventListener("command", function(event)
591 { 600 {
592 window.document.getElementById("abp-notification").hidePopup(); 601 switch (event.target.id)
602 {
603 case "abp-notification-close":
604 notificationPanel.classList.add("abp-closing");
605 break;
606 case "abp-notification-optout":
607 Notification.toggleIgnoreCategory("*", true);
608 /* FALL THROUGH */
609 case "abp-notification-hide":
610 notificationPanel.hidePopup();
611 break;
612 }
593 }, false); 613 }, false);
594 614
595 // First-run actions? 615 // First-run actions?
596 this.firstRunActions(window); 616 this.firstRunActions(window);
597 617
598 // Some people actually switch off browser.frames.enabled and are surprised 618 // Some people actually switch off browser.frames.enabled and are surprised
599 // that things stop working... 619 // that things stop working...
600 window.QueryInterface(Ci.nsIInterfaceRequestor) 620 window.QueryInterface(Ci.nsIInterfaceRequestor)
601 .getInterface(Ci.nsIWebNavigation) 621 .getInterface(Ci.nsIWebNavigation)
602 .QueryInterface(Ci.nsIDocShell) 622 .QueryInterface(Ci.nsIDocShell)
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 1576
1557 setChecked(prefix + "disabled", !Prefs.enabled); 1577 setChecked(prefix + "disabled", !Prefs.enabled);
1558 setChecked(prefix + "frameobjects", Prefs.frameobjects); 1578 setChecked(prefix + "frameobjects", Prefs.frameobjects);
1559 setChecked(prefix + "savestats", Prefs.savestats); 1579 setChecked(prefix + "savestats", Prefs.savestats);
1560 1580
1561 let {defaultToolbarPosition, statusbarPosition} = require("appSupport"); 1581 let {defaultToolbarPosition, statusbarPosition} = require("appSupport");
1562 let hasToolbar = defaultToolbarPosition; 1582 let hasToolbar = defaultToolbarPosition;
1563 let hasStatusBar = statusbarPosition; 1583 let hasStatusBar = statusbarPosition;
1564 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar- "); 1584 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar- ");
1565 hideElement(prefix + "showinstatusbar", !hasStatusBar); 1585 hideElement(prefix + "showinstatusbar", !hasStatusBar);
1586 hideElement(prefix + "shownotifications", !Prefs.notifications_showui);
1566 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || ! hasToolbar) && !hasStatusBar); 1587 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || ! hasToolbar) && !hasStatusBar);
1567 1588
1568 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible()); 1589 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible());
1569 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar); 1590 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar);
1591 setChecked(prefix + "shownotifications", Prefs.notifications_ignoredcategori es.indexOf("*") == -1);
1570 1592
1571 let {Sync} = require("sync"); 1593 let {Sync} = require("sync");
1572 let syncEngine = Sync.getEngine(); 1594 let syncEngine = Sync.getEngine();
1573 hideElement(prefix + "sync", !syncEngine); 1595 hideElement(prefix + "sync", !syncEngine);
1574 setChecked(prefix + "sync", syncEngine && syncEngine.enabled); 1596 setChecked(prefix + "sync", syncEngine && syncEngine.enabled);
1575 1597
1576 let defAction = (!window.document.popupNode || window.document.popupNode.id == "abp-toolbarbutton" ? 1598 let defAction = (!window.document.popupNode || window.document.popupNode.id == "abp-toolbarbutton" ?
1577 Prefs.defaulttoolbaraction : 1599 Prefs.defaulttoolbaraction :
1578 Prefs.defaultstatusbaraction); 1600 Prefs.defaultstatusbaraction);
1579 setDefault(prefix + "openbottombar", defAction == 1); 1601 setDefault(prefix + "openbottombar", defAction == 1);
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)], 1969 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)],
1948 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si teWhitelist); }], 1970 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si teWhitelist); }],
1949 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa geWhitelist); }], 1971 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa geWhitelist); }],
1950 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects" )], 1972 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects" )],
1951 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)], 1973 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)],
1952 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)], 1974 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)],
1953 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)], 1975 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)],
1954 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi nstatusbar")], 1976 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi nstatusbar")],
1955 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")], 1977 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")],
1956 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], 1978 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)],
1957 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] 1979 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)],
1980 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa tegory.bind(Notification, "*", null)]
1958 ]; 1981 ];
1959 1982
1960 onShutdown.add(function() 1983 onShutdown.add(function()
1961 { 1984 {
1962 for (let window of UI.applicationWindows) 1985 for (let window of UI.applicationWindows)
1963 if (UI.isBottombarOpen(window)) 1986 if (UI.isBottombarOpen(window))
1964 UI.toggleBottombar(window); 1987 UI.toggleBottombar(window);
1965 }); 1988 });
OLDNEW
« 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