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 21 matching lines...) Expand all Loading... | |
32 with(require("filterValidation")) | 32 with(require("filterValidation")) |
33 { | 33 { |
34 this.parseFilter = parseFilter; | 34 this.parseFilter = parseFilter; |
35 this.parseFilters = parseFilters; | 35 this.parseFilters = parseFilters; |
36 } | 36 } |
37 var FilterStorage = require("filterStorage").FilterStorage; | 37 var FilterStorage = require("filterStorage").FilterStorage; |
38 var FilterNotifier = require("filterNotifier").FilterNotifier; | 38 var FilterNotifier = require("filterNotifier").FilterNotifier; |
39 var Prefs = require("prefs").Prefs; | 39 var Prefs = require("prefs").Prefs; |
40 var Synchronizer = require("synchronizer").Synchronizer; | 40 var Synchronizer = require("synchronizer").Synchronizer; |
41 var Utils = require("utils").Utils; | 41 var Utils = require("utils").Utils; |
42 var NotificationStorage = require("notification").Notification; | |
42 | 43 |
43 // Loads options from localStorage and sets UI elements accordingly | 44 // Loads options from localStorage and sets UI elements accordingly |
44 function loadOptions() | 45 function loadOptions() |
45 { | 46 { |
46 // Set page title to i18n version of "Adblock Plus Options" | 47 // Set page title to i18n version of "Adblock Plus Options" |
47 document.title = i18n.getMessage("options"); | 48 document.title = i18n.getMessage("options"); |
48 | 49 |
49 // Set links | 50 // Set links |
50 $("#acceptableAdsLink").attr("href", Prefs.subscriptions_exceptionsurl); | 51 $("#acceptableAdsLink").attr("href", Prefs.subscriptions_exceptionsurl); |
51 $("#acceptableAdsDocs").attr("href", Utils.getDocLink("acceptable_ads")); | 52 $("#acceptableAdsDocs").attr("href", Utils.getDocLink("acceptable_ads")); |
(...skipping 17 matching lines...) Expand all Loading... | |
69 | 70 |
70 // Display jQuery UI elements | 71 // Display jQuery UI elements |
71 $("#tabs").tabs(); | 72 $("#tabs").tabs(); |
72 $("button").button(); | 73 $("button").button(); |
73 $(".refreshButton").button("option", "icons", {primary: "ui-icon-refresh"}); | 74 $(".refreshButton").button("option", "icons", {primary: "ui-icon-refresh"}); |
74 $(".addButton").button("option", "icons", {primary: "ui-icon-plus"}); | 75 $(".addButton").button("option", "icons", {primary: "ui-icon-plus"}); |
75 $(".removeButton").button("option", "icons", {primary: "ui-icon-minus"}); | 76 $(".removeButton").button("option", "icons", {primary: "ui-icon-minus"}); |
76 | 77 |
77 // Popuplate option checkboxes | 78 // Popuplate option checkboxes |
78 initCheckbox("shouldShowBlockElementMenu"); | 79 initCheckbox("shouldShowBlockElementMenu"); |
80 if (Prefs.notifications_showui) | |
81 { | |
82 initCheckbox("shouldShowNotifications", { | |
83 get: function() | |
84 { | |
85 return Prefs.notifications_ignoredcategories.indexOf("*") == -1; | |
86 }, | |
87 toggle: function() | |
88 { | |
89 NotificationStorage.toggleIgnoreCategory("*"); | |
90 return Prefs.notifications_ignoredcategories.indexOf("*") == -1; | |
Sebastian Noack
2015/06/25 13:55:04
How about |this.get()| to avoid code duplication?
Thomas Greiner
2015/06/25 16:48:44
Done.
| |
91 } | |
92 }); | |
93 } | |
94 else | |
95 document.getElementById("shouldShowNotificationsContainer").hidden = true; | |
79 | 96 |
80 ext.onMessage.addListener(onMessage); | 97 ext.onMessage.addListener(onMessage); |
81 | 98 |
82 // Load recommended subscriptions | 99 // Load recommended subscriptions |
83 loadRecommendations(); | 100 loadRecommendations(); |
84 | 101 |
85 // Show user's filters | 102 // Show user's filters |
86 reloadFilters(); | 103 reloadFilters(); |
87 } | 104 } |
88 $(loadOptions); | 105 $(loadOptions); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 populateList("userFiltersBox", userFilters.filters); | 141 populateList("userFiltersBox", userFilters.filters); |
125 populateList("excludedDomainsBox", userFilters.exceptions); | 142 populateList("excludedDomainsBox", userFilters.exceptions); |
126 } | 143 } |
127 | 144 |
128 // Cleans up when the options window is closed | 145 // Cleans up when the options window is closed |
129 function unloadOptions() | 146 function unloadOptions() |
130 { | 147 { |
131 FilterNotifier.removeListener(onFilterChange); | 148 FilterNotifier.removeListener(onFilterChange); |
132 } | 149 } |
133 | 150 |
134 function initCheckbox(id) | 151 function initCheckbox(id, descriptor) |
135 { | 152 { |
136 var checkbox = document.getElementById(id); | 153 var checkbox = document.getElementById(id); |
137 checkbox.checked = Prefs[id]; | 154 if (descriptor && descriptor.get) |
155 checkbox.checked = descriptor.get(); | |
156 else | |
157 checkbox.checked = Prefs[id]; | |
158 | |
138 checkbox.addEventListener("click", function() | 159 checkbox.addEventListener("click", function() |
139 { | 160 { |
161 if (descriptor && descriptor.toggle) | |
162 checkbox.checked = descriptor.toggle(); | |
163 | |
140 Prefs[id] = checkbox.checked; | 164 Prefs[id] = checkbox.checked; |
141 }, false); | 165 }, false); |
142 } | 166 } |
143 | 167 |
144 var delayedSubscriptionSelection = null; | 168 var delayedSubscriptionSelection = null; |
145 | 169 |
146 function loadRecommendations() | 170 function loadRecommendations() |
147 { | 171 { |
148 var request = new XMLHttpRequest(); | 172 var request = new XMLHttpRequest(); |
149 request.open("GET", "subscriptions.xml"); | 173 request.open("GET", "subscriptions.xml"); |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 links[i].href = arguments[i + 1]; | 664 links[i].href = arguments[i + 1]; |
641 links[i].setAttribute("target", "_blank"); | 665 links[i].setAttribute("target", "_blank"); |
642 } | 666 } |
643 else if (typeof arguments[i + 1] == "function") | 667 else if (typeof arguments[i + 1] == "function") |
644 { | 668 { |
645 links[i].href = "javascript:void(0);"; | 669 links[i].href = "javascript:void(0);"; |
646 links[i].addEventListener("click", arguments[i + 1], false); | 670 links[i].addEventListener("click", arguments[i + 1], false); |
647 } | 671 } |
648 } | 672 } |
649 } | 673 } |
OLD | NEW |