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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 let access = (item.url || item.text).replace(/'/g, "\\'"); | 83 let access = (item.url || item.text).replace(/'/g, "\\'"); |
84 return function(container) | 84 return function(container) |
85 { | 85 { |
86 return container.querySelector("[data-access='" + access + "']"); | 86 return container.querySelector("[data-access='" + access + "']"); |
87 }; | 87 }; |
88 }; | 88 }; |
89 | 89 |
90 Collection.prototype._getItemTitle = function(item, i) | 90 Collection.prototype._getItemTitle = function(item, i) |
91 { | 91 { |
92 if (this.details[i].useSpecialization && item.specialization) | 92 if (this.details[i].useSpecialization && item.specialization) |
93 return item.specialization; | 93 { |
ire
2018/01/04 08:32:52
NIT: I think this was cleaner without the nested `
saroyanm
2018/01/04 21:28:52
Yes, previously logic was bit different:
Previousl
ire
2018/01/05 09:23:45
Ack. Yes it is more clear, thanks!
| |
94 if (this.details[i].useOriginalTitle && item.originalTitle) | 94 let title = item.specialization; |
95 return item.originalTitle; | 95 if (item.originalTitle && item.originalTitle.indexOf("+EasyList") >= 0) |
ire
2018/01/04 08:32:52
NIT: I don't know if it actually makes a differenc
saroyanm
2018/01/04 21:28:52
Done.
| |
96 title += " + " + getMessage("options_english"); | |
97 return title; | |
98 } | |
96 return item.title || item.url || item.text; | 99 return item.title || item.url || item.text; |
97 }; | 100 }; |
98 | 101 |
99 Collection.prototype._sortItems = function() | 102 Collection.prototype._sortItems = function() |
100 { | 103 { |
101 this.items.sort((a, b) => | 104 this.items.sort((a, b) => |
102 { | 105 { |
103 // Make sure that Acceptable Ads is always last, since it cannot be | 106 // Make sure that Acceptable Ads is always last, since it cannot be |
104 // disabled, but only be removed. That way it's grouped together with | 107 // disabled, but only be removed. That way it's grouped together with |
105 // the "Own filter list" which cannot be disabled either at the bottom | 108 // the "Own filter list" which cannot be disabled either at the bottom |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 this._sortItems(); | 219 this._sortItems(); |
217 let access = (item.url || item.text).replace(/'/g, "\\'"); | 220 let access = (item.url || item.text).replace(/'/g, "\\'"); |
218 for (let i = 0; i < this.details.length; i++) | 221 for (let i = 0; i < this.details.length; i++) |
219 { | 222 { |
220 let table = E(this.details[i].id); | 223 let table = E(this.details[i].id); |
221 let element = table.querySelector("[data-access='" + access + "']"); | 224 let element = table.querySelector("[data-access='" + access + "']"); |
222 if (!element) | 225 if (!element) |
223 continue; | 226 continue; |
224 | 227 |
225 let title = this._getItemTitle(item, i); | 228 let title = this._getItemTitle(item, i); |
226 let displays = element.querySelectorAll(".display"); | 229 let displays = element.querySelectorAll("[data-display]"); |
227 for (let j = 0; j < displays.length; j++) | 230 for (let j = 0; j < displays.length; j++) |
228 displays[j].textContent = title; | 231 { |
232 if (item[displays[j].dataset.display]) | |
233 displays[j].textContent = item[displays[j].dataset.display]; | |
234 else | |
235 displays[j].textContent = title; | |
236 } | |
229 | 237 |
230 element.setAttribute("aria-label", title); | 238 element.setAttribute("aria-label", title); |
231 if (this.details[i].searchable) | 239 if (this.details[i].searchable) |
232 element.setAttribute("data-search", title.toLowerCase()); | 240 element.setAttribute("data-search", title.toLowerCase()); |
233 let controls = element.querySelectorAll(".control[role='checkbox']"); | 241 let controls = element.querySelectorAll(".control[role='checkbox']"); |
234 for (let control of controls) | 242 for (let control of controls) |
235 { | 243 { |
236 control.setAttribute("aria-checked", item.disabled == false); | 244 control.setAttribute("aria-checked", item.disabled == false); |
237 if (isAcceptableAds(item.url) && this == collections.filterLists) | 245 if (isAcceptableAds(item.url) && this == collections.filterLists) |
238 control.disabled = true; | 246 control.disabled = true; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 ]); | 378 ]); |
371 collections.whitelist = new Collection([ | 379 collections.whitelist = new Collection([ |
372 { | 380 { |
373 id: "whitelisting-table", | 381 id: "whitelisting-table", |
374 emptyTexts: ["options_whitelist_empty_1", "options_whitelist_empty_2"] | 382 emptyTexts: ["options_whitelist_empty_1", "options_whitelist_empty_2"] |
375 } | 383 } |
376 ]); | 384 ]); |
377 collections.filterLists = new Collection([ | 385 collections.filterLists = new Collection([ |
378 { | 386 { |
379 id: "all-filter-lists-table", | 387 id: "all-filter-lists-table", |
380 emptyTexts: ["options_filterList_empty"], | 388 emptyTexts: ["options_filterList_empty"] |
381 useOriginalTitle: true | |
382 } | 389 } |
383 ]); | 390 ]); |
384 | 391 |
385 function addSubscription(subscription) | 392 function addSubscription(subscription) |
386 { | 393 { |
387 let {disabled} = subscription; | 394 let {disabled} = subscription; |
388 let collection = null; | 395 let collection = null; |
389 if (subscription.recommended) | 396 if (subscription.recommended) |
390 { | 397 { |
391 if (subscription.recommended == "ads") | 398 if (subscription.recommended == "ads") |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1459 }); | 1466 }); |
1460 browser.runtime.sendMessage({ | 1467 browser.runtime.sendMessage({ |
1461 type: "subscriptions.listen", | 1468 type: "subscriptions.listen", |
1462 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1469 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1463 "title", "downloadStatus", "downloading"] | 1470 "title", "downloadStatus", "downloading"] |
1464 }); | 1471 }); |
1465 | 1472 |
1466 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1473 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1467 window.addEventListener("hashchange", onHashChange, false); | 1474 window.addEventListener("hashchange", onHashChange, false); |
1468 } | 1475 } |
OLD | NEW |