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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 $("#tabs").tabs(); | 140 $("#tabs").tabs(); |
141 $("button").button(); | 141 $("button").button(); |
142 $(".refreshButton").button("option", "icons", {primary: "ui-icon-refresh"}); | 142 $(".refreshButton").button("option", "icons", {primary: "ui-icon-refresh"}); |
143 $(".addButton").button("option", "icons", {primary: "ui-icon-plus"}); | 143 $(".addButton").button("option", "icons", {primary: "ui-icon-plus"}); |
144 $(".removeButton").button("option", "icons", {primary: "ui-icon-minus"}); | 144 $(".removeButton").button("option", "icons", {primary: "ui-icon-minus"}); |
145 | 145 |
146 // Popuplate option checkboxes | 146 // Popuplate option checkboxes |
147 initCheckbox("shouldShowBlockElementMenu"); | 147 initCheckbox("shouldShowBlockElementMenu"); |
148 initCheckbox("show_devtools_panel"); | 148 initCheckbox("show_devtools_panel"); |
149 initCheckbox("shouldShowNotifications", "notifications_ignoredcategories"); | 149 initCheckbox("shouldShowNotifications", "notifications_ignoredcategories"); |
150 initCheckbox("safariContentBlocker"); | |
151 | 150 |
152 getInfo("features", function(features) | 151 getInfo("features", function(features) |
153 { | 152 { |
154 if (!features.devToolsPanel) | 153 if (!features.devToolsPanel) |
155 document.getElementById("showDevtoolsPanelContainer").hidden = true; | 154 document.getElementById("showDevtoolsPanelContainer").hidden = true; |
156 | |
157 // Only show the option for Safari content blocking API if the user is | |
158 // running Safari and both the legacy and content blocking APIs are | |
159 // available. | |
160 document.getElementById("safariContentBlockerContainer").hidden = !( | |
161 features.safariContentBlocker && | |
162 typeof safari != "undefined" && | |
163 "canLoad" in safari.self.tab && | |
164 "onbeforeload" in Element.prototype | |
165 ); | |
166 }); | 155 }); |
167 getPref("notifications_showui", function(notifications_showui) | 156 getPref("notifications_showui", function(notifications_showui) |
168 { | 157 { |
169 if (!notifications_showui) | 158 if (!notifications_showui) |
170 document.getElementById("shouldShowNotificationsContainer").hidden = true; | 159 document.getElementById("shouldShowNotificationsContainer").hidden = true; |
171 }); | 160 }); |
172 | 161 |
173 // Register listeners in the background message responder | 162 // Register listeners in the background message responder |
174 ext.backgroundPage.sendMessage({ | 163 ext.backgroundPage.sendMessage({ |
175 type: "app.listen", | 164 type: "app.listen", |
176 filter: ["addSubscription", "focusSection"] | 165 filter: ["addSubscription", "focusSection"] |
177 }); | 166 }); |
178 ext.backgroundPage.sendMessage( | 167 ext.backgroundPage.sendMessage( |
179 { | 168 { |
180 type: "filters.listen", | 169 type: "filters.listen", |
181 filter: ["added", "loaded", "removed"] | 170 filter: ["added", "loaded", "removed"] |
182 }); | 171 }); |
183 ext.backgroundPage.sendMessage( | 172 ext.backgroundPage.sendMessage( |
184 { | 173 { |
185 type: "prefs.listen", | 174 type: "prefs.listen", |
186 filter: ["notifications_ignoredcategories", "notifications_showui", | 175 filter: ["notifications_ignoredcategories", "notifications_showui", |
187 "safariContentBlocker", "show_devtools_panel", | 176 "show_devtools_panel", "shouldShowBlockElementMenu"] |
188 "shouldShowBlockElementMenu"] | |
189 }); | 177 }); |
190 ext.backgroundPage.sendMessage( | 178 ext.backgroundPage.sendMessage( |
191 { | 179 { |
192 type: "subscriptions.listen", | 180 type: "subscriptions.listen", |
193 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 181 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
194 "title", "downloadStatus", "downloading"] | 182 "title", "downloadStatus", "downloading"] |
195 }); | 183 }); |
196 | 184 |
197 // Load recommended subscriptions | 185 // Load recommended subscriptions |
198 loadRecommendations(); | 186 loadRecommendations(); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 { | 488 { |
501 switch (key) | 489 switch (key) |
502 { | 490 { |
503 case "notifications_showui": | 491 case "notifications_showui": |
504 document.getElementById("shouldShowNotificationsContainer").hidden = !valu
e; | 492 document.getElementById("shouldShowNotificationsContainer").hidden = !valu
e; |
505 return; | 493 return; |
506 case "notifications_ignoredcategories": | 494 case "notifications_ignoredcategories": |
507 key = "shouldShowNotifications"; | 495 key = "shouldShowNotifications"; |
508 value = value.indexOf("*") == -1; | 496 value = value.indexOf("*") == -1; |
509 break; | 497 break; |
510 case "safariContentBlocker": | |
511 var restartMessage = document.getElementById("restart-safari"); | |
512 restartMessage.hidden = true; | |
513 // When the user has chosen to use the legacy APIs but Safari has disabled | |
514 // them we need to show a "Please restart Safari" message. | |
515 if (!value) | |
516 { | |
517 ext.backgroundPage.sendMessage({type: "safari.contentBlockingActive"}, | |
518 function(contentBlockingActive) | |
519 { | |
520 if (contentBlockingActive) | |
521 restartMessage.hidden = false; | |
522 }); | |
523 } | |
524 } | 498 } |
525 var checkbox = document.getElementById(key); | 499 var checkbox = document.getElementById(key); |
526 if (checkbox) | 500 if (checkbox) |
527 checkbox.checked = value; | 501 checkbox.checked = value; |
528 } | 502 } |
529 | 503 |
530 function onFilterMessage(action, filter) | 504 function onFilterMessage(action, filter) |
531 { | 505 { |
532 switch (action) | 506 switch (action) |
533 { | 507 { |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 onFilterMessage(message.action, message.args[0]); | 741 onFilterMessage(message.action, message.args[0]); |
768 break; | 742 break; |
769 case "prefs.respond": | 743 case "prefs.respond": |
770 onPrefMessage(message.action, message.args[0]); | 744 onPrefMessage(message.action, message.args[0]); |
771 break; | 745 break; |
772 case "subscriptions.respond": | 746 case "subscriptions.respond": |
773 onSubscriptionMessage(message.action, message.args[0]); | 747 onSubscriptionMessage(message.action, message.args[0]); |
774 break; | 748 break; |
775 } | 749 } |
776 }); | 750 }); |
OLD | NEW |