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

Side by Side Diff: options.js

Issue 29339287: Issue 3885 - Disable the checkbox to toggle the Acceptable Ads list on the options page (Closed)
Patch Set: Created April 1, 2016, 3:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 var title = null; 171 var title = null;
172 if (this.details[i].useOriginalTitle) 172 if (this.details[i].useOriginalTitle)
173 title = item.originalTitle; 173 title = item.originalTitle;
174 if (!title) 174 if (!title)
175 title = item.title || item.url || item.text; 175 title = item.title || item.url || item.text;
176 element.querySelector(".display").textContent = title; 176 element.querySelector(".display").textContent = title;
177 if (title) 177 if (title)
178 element.setAttribute("data-search", title.toLowerCase()); 178 element.setAttribute("data-search", title.toLowerCase());
179 var control = element.querySelector(".control[role='checkbox']"); 179 var control = element.querySelector(".control[role='checkbox']");
180 if (control) 180 if (control)
181 {
181 control.setAttribute("aria-checked", item.disabled == false); 182 control.setAttribute("aria-checked", item.disabled == false);
183 if (item.disableable == false &&
184 this.details[i].onClick == toggleDisableSubscription)
185 control.setAttribute("disabled", true);
186 }
182 187
183 var downloadStatus = item.downloadStatus; 188 var downloadStatus = item.downloadStatus;
184 var dateElement = element.querySelector(".date"); 189 var dateElement = element.querySelector(".date");
185 var timeElement = element.querySelector(".time"); 190 var timeElement = element.querySelector(".time");
186 if(dateElement && timeElement) 191 if(dateElement && timeElement)
187 { 192 {
188 var message = element.querySelector(".message"); 193 var message = element.querySelector(".message");
189 ext.backgroundPage.sendMessage( 194 ext.backgroundPage.sendMessage(
190 { 195 {
191 type: "subscriptions.isDownloading", 196 type: "subscriptions.isDownloading",
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 { 451 {
447 var recommendation = recommendationsMap[subscriptionUrl]; 452 var recommendation = recommendationsMap[subscriptionUrl];
448 if (recommendation.type != "ads") 453 if (recommendation.type != "ads")
449 collection = collections.popular; 454 collection = collections.popular;
450 else if (subscription.disabled == false) 455 else if (subscription.disabled == false)
451 collection = collections.langs; 456 collection = collections.langs;
452 else 457 else
453 collection = collections.allLangs; 458 collection = collections.allLangs;
454 } 459 }
455 else if (subscriptionUrl == acceptableAdsUrl) 460 else if (subscriptionUrl == acceptableAdsUrl)
461 {
456 collection = collections.acceptableAds; 462 collection = collections.acceptableAds;
463 subscription.disableable = false;
464 }
457 else 465 else
458 collection = collections.custom; 466 collection = collections.custom;
459 467
460 collection.addItems(subscription); 468 collection.addItems(subscription);
461 subscriptionsMap[subscriptionUrl] = subscription; 469 subscriptionsMap[subscriptionUrl] = subscription;
462 }); 470 });
463 } 471 }
464 } 472 }
465 473
466 function updateFilter(filter) 474 function updateFilter(filter)
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 { 898 {
891 var customFilterItems = collections.customFilters.items; 899 var customFilterItems = collections.customFilters.items;
892 var filterTexts = []; 900 var filterTexts = [];
893 for (var i = 0; i < customFilterItems.length; i++) 901 for (var i = 0; i < customFilterItems.length; i++)
894 filterTexts.push(customFilterItems[i].text); 902 filterTexts.push(customFilterItems[i].text);
895 E("custom-filters-raw").value = filterTexts.join("\n"); 903 E("custom-filters-raw").value = filterTexts.join("\n");
896 } 904 }
897 905
898 function getAcceptableAdsURL(callback) 906 function getAcceptableAdsURL(callback)
899 { 907 {
900 getPref("subscriptions_exceptionsurl", function(value) 908 getPref("subscriptions_exceptionsurl", callback);
Sebastian Noack 2016/04/01 15:41:56 Unrelated, but I couldn't resits. WTF?
Sebastian Noack 2016/04/06 17:15:41 Ahh, now I understand. The old code impelemted som
Thomas Greiner 2016/04/07 17:21:15 Yeah, the idea here was to avoid messaging the bac
Sebastian Noack 2016/04/08 14:22:16 Well, a promise still requires a callback. Caching
901 {
902 getAcceptableAdsURL = function(callback)
903 {
904 callback(value);
905 };
906 getAcceptableAdsURL(callback);
907 });
908 } 909 }
909 910
910 function addEnableSubscription(url, title, homepage) 911 function addEnableSubscription(url, title, homepage)
911 { 912 {
912 var messageType = null; 913 var messageType = null;
913 var knownSubscription = subscriptionsMap[url]; 914 var knownSubscription = subscriptionsMap[url];
914 if (knownSubscription && knownSubscription.disabled == true) 915 if (knownSubscription && knownSubscription.disabled == true)
915 messageType = "subscriptions.toggle" 916 messageType = "subscriptions.toggle"
916 else 917 else
917 messageType = "subscriptions.add" 918 messageType = "subscriptions.add"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 }); 1150 });
1150 ext.backgroundPage.sendMessage( 1151 ext.backgroundPage.sendMessage(
1151 { 1152 {
1152 type: "subscriptions.listen", 1153 type: "subscriptions.listen",
1153 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1154 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1154 "title"] 1155 "title"]
1155 }); 1156 });
1156 1157
1157 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1158 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1158 })(); 1159 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld