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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 { | 543 { |
544 ext.backgroundPage.sendMessage(message, (errors) => | 544 ext.backgroundPage.sendMessage(message, (errors) => |
545 { | 545 { |
546 if (errors.length > 0) | 546 if (errors.length > 0) |
547 alert(errors.join("\n")); | 547 alert(errors.join("\n")); |
548 else if (onSuccess) | 548 else if (onSuccess) |
549 onSuccess(); | 549 onSuccess(); |
550 }); | 550 }); |
551 } | 551 } |
552 | 552 |
553 function openDocLink(id) | |
saroyanm
2017/08/10 12:04:48
This is not being used anymore.
| |
554 { | |
555 getDocLink(id, (link) => | |
556 { | |
557 if (id == "share-general") | |
558 openSharePopup(link); | |
559 else | |
560 location.href = link; | |
561 }); | |
562 } | |
563 | |
564 function switchTab(id) | 553 function switchTab(id) |
565 { | 554 { |
566 location.hash = id; | 555 location.hash = id; |
567 } | 556 } |
568 | 557 |
569 function execAction(action, element) | 558 function execAction(action, element) |
570 { | 559 { |
571 switch (action) | 560 switch (action) |
572 { | 561 { |
573 case "add-domain-exception": | 562 case "add-domain-exception": |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 let listItem = findParentData(element, "access", true); | 634 let listItem = findParentData(element, "access", true); |
646 if (listItem && !listItem.classList.contains("show-context-menu")) | 635 if (listItem && !listItem.classList.contains("show-context-menu")) |
647 listItem.classList.add("show-context-menu"); | 636 listItem.classList.add("show-context-menu"); |
648 break; | 637 break; |
649 } | 638 } |
650 case "open-dialog": { | 639 case "open-dialog": { |
651 let dialog = findParentData(element, "dialog", false); | 640 let dialog = findParentData(element, "dialog", false); |
652 openDialog(dialog); | 641 openDialog(dialog); |
653 break; | 642 break; |
654 } | 643 } |
655 case "open-doclink": { | |
656 let doclink = findParentData(element, "doclink", false); | |
657 openDocLink(doclink); | |
658 break; | |
659 } | |
660 case "remove-filter": | 644 case "remove-filter": |
661 ext.backgroundPage.sendMessage({ | 645 ext.backgroundPage.sendMessage({ |
662 type: "filters.remove", | 646 type: "filters.remove", |
663 text: findParentData(element, "access", false) | 647 text: findParentData(element, "access", false) |
664 }); | 648 }); |
665 break; | 649 break; |
666 case "remove-subscription": | 650 case "remove-subscription": |
667 ext.backgroundPage.sendMessage({ | 651 ext.backgroundPage.sendMessage({ |
668 type: "subscriptions.remove", | 652 type: "subscriptions.remove", |
669 url: findParentData(element, "access", false) | 653 url: findParentData(element, "access", false) |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
860 { | 844 { |
861 populateLists(); | 845 populateLists(); |
862 | 846 |
863 // Initialize navigation sidebar | 847 // Initialize navigation sidebar |
864 ext.backgroundPage.sendMessage({ | 848 ext.backgroundPage.sendMessage({ |
865 type: "app.get", | 849 type: "app.get", |
866 what: "addonVersion" | 850 what: "addonVersion" |
867 }, | 851 }, |
868 (addonVersion) => | 852 (addonVersion) => |
869 { | 853 { |
870 E("abp-version").textContent = addonVersion; | 854 E("abp-version").textContent = getMessage("options_dialog_about_version", |
871 }); | 855 [addonVersion]); |
872 getDocLink("releases", (link) => | |
873 { | |
874 E("link-version").setAttribute("href", link); | |
875 }); | 856 }); |
876 | 857 |
877 updateShareLink(); | |
878 updateTooltips(); | 858 updateTooltips(); |
879 | 859 |
880 // Initialize interactive UI elements | 860 // Initialize interactive UI elements |
881 document.body.addEventListener("click", onClick, false); | 861 document.body.addEventListener("click", onClick, false); |
882 document.body.addEventListener("keyup", onKeyUp, false); | 862 document.body.addEventListener("keyup", onKeyUp, false); |
883 let exampleValue = getMessage("options_whitelist_placeholder_example", | 863 let exampleValue = getMessage("options_whitelist_placeholder_example", |
884 ["www.example.com"]); | 864 ["www.example.com"]); |
885 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); | 865 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); |
886 E("whitelisting-textbox").addEventListener("keyup", (e) => | 866 E("whitelisting-textbox").addEventListener("keyup", (e) => |
887 { | 867 { |
888 E("whitelisting-add-button").disabled = !e.target.value; | 868 E("whitelisting-add-button").disabled = !e.target.value; |
889 }, false); | 869 }, false); |
890 | 870 |
871 | |
872 getDocLink("contribute", (link) => | |
873 { | |
874 E("contribute").href = link; | |
875 }); | |
891 getDocLink("acceptable_ads_criteria", (link) => | 876 getDocLink("acceptable_ads_criteria", (link) => |
892 { | 877 { |
893 setLinks("enable-aa-description", link); | 878 setLinks("enable-aa-description", link); |
894 }); | 879 }); |
895 | 880 |
896 // Advanced tab | 881 // Advanced tab |
897 let customize = document.querySelectorAll("#customize li[data-pref]"); | 882 let customize = document.querySelectorAll("#customize li[data-pref]"); |
898 customize = Array.prototype.map.call(customize, (checkbox) => | 883 customize = Array.prototype.map.call(customize, (checkbox) => |
899 { | 884 { |
900 return checkbox.getAttribute("data-pref"); | 885 return checkbox.getAttribute("data-pref"); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1156 ext.backgroundPage.sendMessage(message); | 1141 ext.backgroundPage.sendMessage(message); |
1157 } | 1142 } |
1158 | 1143 |
1159 function onFilterMessage(action, filter) | 1144 function onFilterMessage(action, filter) |
1160 { | 1145 { |
1161 switch (action) | 1146 switch (action) |
1162 { | 1147 { |
1163 case "added": | 1148 case "added": |
1164 filter[timestampUI] = Date.now(); | 1149 filter[timestampUI] = Date.now(); |
1165 updateFilter(filter); | 1150 updateFilter(filter); |
1166 updateShareLink(); | |
1167 break; | 1151 break; |
1168 case "loaded": | 1152 case "loaded": |
1169 populateLists(); | 1153 populateLists(); |
1170 break; | 1154 break; |
1171 case "removed": | 1155 case "removed": |
1172 let knownFilter = filtersMap[filter.text]; | 1156 let knownFilter = filtersMap[filter.text]; |
1173 if (whitelistedDomainRegexp.test(knownFilter.text)) | 1157 if (whitelistedDomainRegexp.test(knownFilter.text)) |
1174 collections.whitelist.removeItem(knownFilter); | 1158 collections.whitelist.removeItem(knownFilter); |
1175 else | 1159 else |
1176 removeCustomFilter(filter.text); | 1160 removeCustomFilter(filter.text); |
1177 | 1161 |
1178 delete filtersMap[filter.text]; | 1162 delete filtersMap[filter.text]; |
1179 updateShareLink(); | |
1180 break; | 1163 break; |
1181 } | 1164 } |
1182 } | 1165 } |
1183 | 1166 |
1184 function onSubscriptionMessage(action, subscription) | 1167 function onSubscriptionMessage(action, subscription) |
1185 { | 1168 { |
1186 if (subscription.url in subscriptionsMap) | 1169 if (subscription.url in subscriptionsMap) |
1187 { | 1170 { |
1188 let knownSubscription = subscriptionsMap[subscription.url]; | 1171 let knownSubscription = subscriptionsMap[subscription.url]; |
1189 for (let property in subscription) | 1172 for (let property in subscription) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1237 } | 1220 } |
1238 else | 1221 else |
1239 { | 1222 { |
1240 collections.custom.removeItem(subscription); | 1223 collections.custom.removeItem(subscription); |
1241 delete subscriptionsMap[subscription.url]; | 1224 delete subscriptionsMap[subscription.url]; |
1242 } | 1225 } |
1243 collections.filterLists.removeItem(subscription); | 1226 collections.filterLists.removeItem(subscription); |
1244 break; | 1227 break; |
1245 } | 1228 } |
1246 | 1229 |
1247 updateShareLink(); | |
1248 } | 1230 } |
1249 | 1231 |
1250 function hidePref(key, value) | 1232 function hidePref(key, value) |
1251 { | 1233 { |
1252 let element = document.querySelector("[data-pref='" + key + "']"); | 1234 let element = document.querySelector("[data-pref='" + key + "']"); |
1253 if (element) | 1235 if (element) |
1254 element.setAttribute("aria-hidden", value); | 1236 element.setAttribute("aria-hidden", value); |
1255 } | 1237 } |
1256 | 1238 |
1257 function getPref(key, callback) | 1239 function getPref(key, callback) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1298 break; | 1280 break; |
1299 } | 1281 } |
1300 | 1282 |
1301 let checkbox = document.querySelector( | 1283 let checkbox = document.querySelector( |
1302 "[data-pref='" + key + "'] button[role='checkbox']" | 1284 "[data-pref='" + key + "'] button[role='checkbox']" |
1303 ); | 1285 ); |
1304 if (checkbox) | 1286 if (checkbox) |
1305 checkbox.setAttribute("aria-checked", value); | 1287 checkbox.setAttribute("aria-checked", value); |
1306 } | 1288 } |
1307 | 1289 |
1308 function updateShareLink() | |
saroyanm
2017/08/10 12:04:48
We don't have share dialog in "new" new version of
| |
1309 { | |
1310 let shareResources = [ | |
1311 "https://facebook.com/plugins/like.php?", | |
1312 "https://platform.twitter.com/widgets/", | |
1313 "https://apis.google.com/se/0/_/+1/fastbutton?" | |
1314 ]; | |
1315 let isAnyBlocked = false; | |
1316 let checksRemaining = shareResources.length; | |
1317 | |
1318 function onResult(isBlocked) | |
1319 { | |
1320 isAnyBlocked |= isBlocked; | |
1321 if (!--checksRemaining) | |
1322 { | |
1323 // Hide the share tab if a script on the share page would be blocked | |
1324 E("tab-share").hidden = isAnyBlocked; | |
1325 } | |
1326 } | |
1327 | |
1328 for (let sharedResource of shareResources) | |
1329 checkShareResource(sharedResource, onResult); | |
1330 } | |
1331 | |
1332 function getMessages(id) | 1290 function getMessages(id) |
1333 { | 1291 { |
1334 let messages = []; | 1292 let messages = []; |
1335 for (let i = 1; true; i++) | 1293 for (let i = 1; true; i++) |
1336 { | 1294 { |
1337 let message = ext.i18n.getMessage(id + "_" + i); | 1295 let message = ext.i18n.getMessage(id + "_" + i); |
1338 if (!message) | 1296 if (!message) |
1339 break; | 1297 break; |
1340 | 1298 |
1341 messages.push(message); | 1299 messages.push(message); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1448 }); | 1406 }); |
1449 ext.backgroundPage.sendMessage({ | 1407 ext.backgroundPage.sendMessage({ |
1450 type: "subscriptions.listen", | 1408 type: "subscriptions.listen", |
1451 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1409 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1452 "title", "downloadStatus", "downloading"] | 1410 "title", "downloadStatus", "downloading"] |
1453 }); | 1411 }); |
1454 | 1412 |
1455 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1413 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1456 window.addEventListener("hashchange", onHashChange, false); | 1414 window.addEventListener("hashchange", onHashChange, false); |
1457 } | 1415 } |
OLD | NEW |