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

Delta Between Two Patch Sets: options.js

Issue 29339192: Issue 3880 - Improve behavior of Safari content blocker option (Closed)
Left Patch Set: Made CSS comply with coding styles Created March 31, 2016, 2:45 p.m.
Right Patch Set: Don't persists whether Safari needs to be restarted Created March 31, 2016, 3:15 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « options.html ('k') | skin/options.css » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 // Advanced tab 700 // Advanced tab
701 var tweaks = document.querySelectorAll("#tweaks li[data-pref]"); 701 var tweaks = document.querySelectorAll("#tweaks li[data-pref]");
702 tweaks = Array.prototype.map.call(tweaks, function(checkbox) 702 tweaks = Array.prototype.map.call(tweaks, function(checkbox)
703 { 703 {
704 return checkbox.getAttribute("data-pref"); 704 return checkbox.getAttribute("data-pref");
705 }); 705 });
706 tweaks.forEach(function(key) 706 tweaks.forEach(function(key)
707 { 707 {
708 getPref(key, function(value) 708 getPref(key, function(value)
709 { 709 {
710 onPrefMessage(key, value); 710 onPrefMessage(key, value, true);
711 }); 711 });
712 }); 712 });
713 ext.backgroundPage.sendMessage( 713 ext.backgroundPage.sendMessage(
714 { 714 {
715 type: "app.get", 715 type: "app.get",
716 what: "features" 716 what: "features"
717 }, 717 },
718 function(features) 718 function(features)
719 { 719 {
720 hidePref("show_devtools_panel", !features.devToolsPanel); 720 hidePref("show_devtools_panel", !features.devToolsPanel);
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 }; 1021 };
1022 1022
1023 getPref.checks = 1023 getPref.checks =
1024 { 1024 {
1025 notifications_ignoredcategories: function(callback) 1025 notifications_ignoredcategories: function(callback)
1026 { 1026 {
1027 getPref("notifications_showui", callback); 1027 getPref("notifications_showui", callback);
1028 } 1028 }
1029 }; 1029 };
1030 1030
1031 function onPrefMessage(key, value) 1031 function onPrefMessage(key, value, initial)
1032 { 1032 {
1033 switch (key)
1034 {
1035 case "notifications_ignoredcategories":
1036 value = value.indexOf("*") == -1;
1037 break;
1038
1039 case "notifications_showui":
1040 hidePref("notifications_ignoredcategories", !value);
1041 break;
1042
1043 case "safari_contentblocker":
1044 E("restart-safari").setAttribute("aria-hidden", value || initial);
1045 break;
1046 }
1047
1033 var checkbox = document.querySelector("[data-pref='" + key + "'] button[role ='checkbox']"); 1048 var checkbox = document.querySelector("[data-pref='" + key + "'] button[role ='checkbox']");
1034 if (checkbox) 1049 if (checkbox)
1035 {
1036 if (key == "notifications_ignoredcategories")
1037 value = (value.indexOf("*") == -1);
1038 checkbox.setAttribute("aria-checked", value); 1050 checkbox.setAttribute("aria-checked", value);
1039 }
1040 else if (key == "notifications_showui")
1041 hidePref("notifications_ignoredcategories", !value);
1042 } 1051 }
1043 1052
1044 function onShareLinkClick(e) 1053 function onShareLinkClick(e)
1045 { 1054 {
1046 e.preventDefault(); 1055 e.preventDefault();
1047 1056
1048 getDocLink("share-general", function(link) 1057 getDocLink("share-general", function(link)
1049 { 1058 {
1050 openSharePopup(link); 1059 openSharePopup(link);
1051 }); 1060 });
(...skipping 28 matching lines...) Expand all
1080 1089
1081 for (var i = 0; i < shareResources.length; i++) 1090 for (var i = 0; i < shareResources.length; i++)
1082 checkShareResource(shareResources[i], onResult); 1091 checkShareResource(shareResources[i], onResult);
1083 } 1092 }
1084 1093
1085 ext.onMessage.addListener(function(message) 1094 ext.onMessage.addListener(function(message)
1086 { 1095 {
1087 switch (message.type) 1096 switch (message.type)
1088 { 1097 {
1089 case "app.respond": 1098 case "app.respond":
1090 switch (message.action) 1099 if (message.action == "addSubscription")
1091 { 1100 {
1092 case "addSubscription": 1101 var subscription = message.args[0];
1093 var subscription = message.args[0]; 1102 var dialog = E("dialog-content-predefined");
1094 var dialog = E("dialog-content-predefined"); 1103 dialog.querySelector("h3").textContent = subscription.title || "";
1095 dialog.querySelector("h3").textContent = subscription.title || ""; 1104 dialog.querySelector(".url").textContent = subscription.url;
1096 dialog.querySelector(".url").textContent = subscription.url; 1105 openDialog("predefined");
1097 openDialog("predefined");
1098 break;
1099 case "safariRestartRequired":
1100 E("restart-safari").setAttribute("aria-hidden", !message.args[0]);
1101 break;
1102 } 1106 }
1103 break; 1107 break;
1104 case "filters.respond": 1108 case "filters.respond":
1105 onFilterMessage(message.action, message.args[0]); 1109 onFilterMessage(message.action, message.args[0]);
1106 break; 1110 break;
1107 case "prefs.respond": 1111 case "prefs.respond":
1108 onPrefMessage(message.action, message.args[0]); 1112 onPrefMessage(message.action, message.args[0], false);
1109 break; 1113 break;
1110 case "subscriptions.respond": 1114 case "subscriptions.respond":
1111 onSubscriptionMessage(message.action, message.args[0]); 1115 onSubscriptionMessage(message.action, message.args[0]);
1112 break; 1116 break;
1113 } 1117 }
1114 }); 1118 });
1115 1119
1116 ext.backgroundPage.sendMessage( 1120 ext.backgroundPage.sendMessage(
1117 { 1121 {
1118 type: "app.listen", 1122 type: "app.listen",
1119 filter: ["addSubscription", "safariRestartRequired"] 1123 filter: ["addSubscription"]
1120 }); 1124 });
1121 ext.backgroundPage.sendMessage( 1125 ext.backgroundPage.sendMessage(
1122 { 1126 {
1123 type: "filters.listen", 1127 type: "filters.listen",
1124 filter: ["added", "loaded", "removed"] 1128 filter: ["added", "loaded", "removed"]
1125 }); 1129 });
1126 ext.backgroundPage.sendMessage( 1130 ext.backgroundPage.sendMessage(
1127 { 1131 {
1128 type: "prefs.listen", 1132 type: "prefs.listen",
1129 filter: ["notifications_ignoredcategories", "notifications_showui", 1133 filter: ["notifications_ignoredcategories", "notifications_showui",
1130 "safari_contentblocker", "show_devtools_panel", 1134 "safari_contentblocker", "show_devtools_panel",
1131 "shouldShowBlockElementMenu"] 1135 "shouldShowBlockElementMenu"]
1132 }); 1136 });
1133 ext.backgroundPage.sendMessage( 1137 ext.backgroundPage.sendMessage(
1134 { 1138 {
1135 type: "subscriptions.listen", 1139 type: "subscriptions.listen",
1136 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1140 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1137 "title"] 1141 "title"]
1138 }); 1142 });
1139 1143
1140 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1144 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1141 })(); 1145 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld