Left: | ||
Right: |
OLD | NEW |
---|---|
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 Loading... | |
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); | |
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
| |
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 Loading... | |
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) |
593 }, false); | 602 { |
603 case "abp-notification-close": | |
604 notificationPanel.classList.add("abp-closing"); | |
605 break; | |
606 case "abp-notification-optout": | |
607 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
| |
608 case "abp-notification-hide": | |
609 notificationPanel.hidePopup(); | |
610 break; | |
611 } | |
612 }, 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.
| |
594 | 613 |
595 // First-run actions? | 614 // First-run actions? |
596 this.firstRunActions(window); | 615 this.firstRunActions(window); |
597 | 616 |
598 // Some people actually switch off browser.frames.enabled and are surprised | 617 // Some people actually switch off browser.frames.enabled and are surprised |
599 // that things stop working... | 618 // that things stop working... |
600 window.QueryInterface(Ci.nsIInterfaceRequestor) | 619 window.QueryInterface(Ci.nsIInterfaceRequestor) |
601 .getInterface(Ci.nsIWebNavigation) | 620 .getInterface(Ci.nsIWebNavigation) |
602 .QueryInterface(Ci.nsIDocShell) | 621 .QueryInterface(Ci.nsIDocShell) |
603 .allowSubframes = true; | 622 .allowSubframes = true; |
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1556 | 1575 |
1557 setChecked(prefix + "disabled", !Prefs.enabled); | 1576 setChecked(prefix + "disabled", !Prefs.enabled); |
1558 setChecked(prefix + "frameobjects", Prefs.frameobjects); | 1577 setChecked(prefix + "frameobjects", Prefs.frameobjects); |
1559 setChecked(prefix + "savestats", Prefs.savestats); | 1578 setChecked(prefix + "savestats", Prefs.savestats); |
1560 | 1579 |
1561 let {defaultToolbarPosition, statusbarPosition} = require("appSupport"); | 1580 let {defaultToolbarPosition, statusbarPosition} = require("appSupport"); |
1562 let hasToolbar = defaultToolbarPosition; | 1581 let hasToolbar = defaultToolbarPosition; |
1563 let hasStatusBar = statusbarPosition; | 1582 let hasStatusBar = statusbarPosition; |
1564 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar- "); | 1583 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar- "); |
1565 hideElement(prefix + "showinstatusbar", !hasStatusBar); | 1584 hideElement(prefix + "showinstatusbar", !hasStatusBar); |
1585 hideElement(prefix + "shownotifications", !Prefs.notifications_showui); | |
1566 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || ! hasToolbar) && !hasStatusBar); | 1586 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || ! hasToolbar) && !hasStatusBar); |
1567 | 1587 |
1568 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible()); | 1588 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible()); |
1569 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar); | 1589 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar); |
1590 setChecked(prefix + "shownotifications", Prefs.notifications_ignoredcategori es.indexOf("*") == -1); | |
1570 | 1591 |
1571 let {Sync} = require("sync"); | 1592 let {Sync} = require("sync"); |
1572 let syncEngine = Sync.getEngine(); | 1593 let syncEngine = Sync.getEngine(); |
1573 hideElement(prefix + "sync", !syncEngine); | 1594 hideElement(prefix + "sync", !syncEngine); |
1574 setChecked(prefix + "sync", syncEngine && syncEngine.enabled); | 1595 setChecked(prefix + "sync", syncEngine && syncEngine.enabled); |
1575 | 1596 |
1576 let defAction = (!window.document.popupNode || window.document.popupNode.id == "abp-toolbarbutton" ? | 1597 let defAction = (!window.document.popupNode || window.document.popupNode.id == "abp-toolbarbutton" ? |
1577 Prefs.defaulttoolbaraction : | 1598 Prefs.defaulttoolbaraction : |
1578 Prefs.defaultstatusbaraction); | 1599 Prefs.defaultstatusbaraction); |
1579 setDefault(prefix + "openbottombar", defAction == 1); | 1600 setDefault(prefix + "openbottombar", defAction == 1); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1947 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)], | 1968 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)], |
1948 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si teWhitelist); }], | 1969 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si teWhitelist); }], |
1949 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa geWhitelist); }], | 1970 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa geWhitelist); }], |
1950 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects" )], | 1971 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects" )], |
1951 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)], | 1972 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)], |
1952 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)], | 1973 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)], |
1953 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)], | 1974 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)], |
1954 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi nstatusbar")], | 1975 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi nstatusbar")], |
1955 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")], | 1976 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")], |
1956 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1977 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
1957 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1978 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)], |
1979 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa tegory.bind(Notification, "*", null)] | |
1958 ]; | 1980 ]; |
1959 | 1981 |
1960 onShutdown.add(function() | 1982 onShutdown.add(function() |
1961 { | 1983 { |
1962 for (let window of UI.applicationWindows) | 1984 for (let window of UI.applicationWindows) |
1963 if (UI.isBottombarOpen(window)) | 1985 if (UI.isBottombarOpen(window)) |
1964 UI.toggleBottombar(window); | 1986 UI.toggleBottombar(window); |
1965 }); | 1987 }); |
OLD | NEW |