Commit 97f15274 authored by Sebastian Noack's avatar Sebastian Noack

Issue 3880 - Improve behavior of Safari content blocker option

parent ba1f1aa1
......@@ -155,6 +155,10 @@
"description": "Switch between classic and Safari's Content Blocking",
"message": "Use Safari's native Content Blocking (experimental)"
},
"options_tweaks_restartSafari": {
"description": "Shown next to the option for Safai Content Blockers if disabled in order to indicate that a restart is required",
"message": "Please restart Safari"
},
"options_filterList_title": {
"description": "Section title in Advanced tab",
"message": "Filter lists"
......
......@@ -233,6 +233,7 @@
<li data-pref="safari_contentblocker">
<button role="checkbox" data-action="toggle-pref"></button>
<span class="i18n_options_tweaks_safariContentBlocker"></span>
<span id="restart-safari" class="i18n_options_tweaks_restartSafari"></span>
</li>
</ul>
</div>
......
......@@ -707,7 +707,7 @@
{
getPref(key, function(value)
{
onPrefMessage(key, value);
onPrefMessage(key, value, true);
});
});
ext.backgroundPage.sendMessage(
......@@ -718,7 +718,14 @@
function(features)
{
hidePref("show_devtools_panel", !features.devToolsPanel);
hidePref("safari_contentblocker", !features.safariContentBlocker);
// Only show option to switch between Safari Content Blockers
// and event based blocking if both are available.
hidePref("safari_contentblocker", !(
features.safariContentBlocker &&
"canLoad" in safari.self.tab &&
"onbeforeload" in Element.prototype
));
});
var filterTextbox = document.querySelector("#custom-filters-add input");
......@@ -1021,17 +1028,26 @@
}
};
function onPrefMessage(key, value)
function onPrefMessage(key, value, initial)
{
switch (key)
{
case "notifications_ignoredcategories":
value = value.indexOf("*") == -1;
break;
case "notifications_showui":
hidePref("notifications_ignoredcategories", !value);
break;
case "safari_contentblocker":
E("restart-safari").setAttribute("aria-hidden", value || initial);
break;
}
var checkbox = document.querySelector("[data-pref='" + key + "'] button[role='checkbox']");
if (checkbox)
{
if (key == "notifications_ignoredcategories")
value = (value.indexOf("*") == -1);
checkbox.setAttribute("aria-checked", value);
}
else if (key == "notifications_showui")
hidePref("notifications_ignoredcategories", !value);
}
function onShareLinkClick(e)
......@@ -1093,7 +1109,7 @@
onFilterMessage(message.action, message.args[0]);
break;
case "prefs.respond":
onPrefMessage(message.action, message.args[0]);
onPrefMessage(message.action, message.args[0], false);
break;
case "subscriptions.respond":
onSubscriptionMessage(message.action, message.args[0]);
......
......@@ -617,6 +617,14 @@ button[role="checkbox"],
padding-bottom: 0px;
}
#restart-safari
{
-moz-margin-start: 20px;
-webkit-margin-start: 20px;
color: red;
font-weight: 600;
}
#filter-lists > div
{
display: none;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment