| 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-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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 | 55 |
| 56 Collection.prototype._createElementQuery = function(item) | 56 Collection.prototype._createElementQuery = function(item) |
| 57 { | 57 { |
| 58 var access = (item.url || item.text).replace(/'/g, "\\'"); | 58 var access = (item.url || item.text).replace(/'/g, "\\'"); |
| 59 return function(container) | 59 return function(container) |
| 60 { | 60 { |
| 61 return container.querySelector("[data-access='" + access + "']"); | 61 return container.querySelector("[data-access='" + access + "']"); |
| 62 }; | 62 }; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 Collection.prototype._isControlDisabled = function(item, i) | |
| 66 { | |
| 67 return item.disableable == false && | |
| 68 this.details[i].onClick == toggleDisableSubscription; | |
| 69 }; | |
| 70 | |
| 71 Collection.prototype._getItemTitle = function(item, i) | |
| 72 { | |
| 73 var title = null; | |
| 74 if (this.details[i].useOriginalTitle) | |
| 75 title = item.originalTitle; | |
| 76 if (!title) | |
| 77 title = item.title || item.url || item.text; | |
| 78 return title; | |
| 79 }; | |
| 80 | |
| 65 Collection.prototype.addItems = function() | 81 Collection.prototype.addItems = function() |
| 66 { | 82 { |
| 67 var length = Array.prototype.push.apply(this.items, arguments); | 83 var length = Array.prototype.push.apply(this.items, arguments); |
| 68 if (length == 0) | 84 if (length == 0) |
| 69 return; | 85 return; |
| 70 | 86 |
| 71 this.items.sort(function(a, b) | 87 this.items.sort(function(a, b) |
| 72 { | 88 { |
| 73 var aValue = (a.title || a.text || a.url).toLowerCase(); | 89 var aDisabled = this._isControlDisabled(a, 0); |
|
Sebastian Noack
2016/04/01 18:26:43
This makes sure that items with disabled checkboxe
| |
| 74 var bValue = (b.title || b.text || b.url).toLowerCase(); | 90 var bDisabled = this._isControlDisabled(b, 0); |
| 75 return aValue.localeCompare(bValue); | 91 if (aDisabled != bDisabled) |
| 76 }); | 92 return aDisabled - bDisabled; |
| 93 | |
| 94 var aTitle = this._getItemTitle(a, 0).toLowerCase(); | |
|
Sebastian Noack
2016/04/01 18:26:43
This was missed on the previous review, where we s
| |
| 95 var bTitle = this._getItemTitle(b, 0).toLowerCase(); | |
| 96 return aTitle.localeCompare(bTitle); | |
| 97 }.bind(this)); | |
| 77 | 98 |
| 78 for (var j = 0; j < this.details.length; j++) | 99 for (var j = 0; j < this.details.length; j++) |
| 79 { | 100 { |
| 80 var table = E(this.details[j].id); | 101 var table = E(this.details[j].id); |
| 81 var template = table.querySelector("template"); | 102 var template = table.querySelector("template"); |
| 82 for (var i = 0; i < arguments.length; i++) | 103 for (var i = 0; i < arguments.length; i++) |
| 83 { | 104 { |
| 84 var item = arguments[i]; | 105 var item = arguments[i]; |
| 85 var listItem = document.createElement("li"); | 106 var listItem = document.createElement("li"); |
| 86 listItem.appendChild(document.importNode(template.content, true)); | 107 listItem.appendChild(document.importNode(template.content, true)); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 Collection.prototype.updateItem = function(item) | 182 Collection.prototype.updateItem = function(item) |
| 162 { | 183 { |
| 163 var access = (item.url || item.text).replace(/'/g, "\\'"); | 184 var access = (item.url || item.text).replace(/'/g, "\\'"); |
| 164 for (var i = 0; i < this.details.length; i++) | 185 for (var i = 0; i < this.details.length; i++) |
| 165 { | 186 { |
| 166 var table = E(this.details[i].id); | 187 var table = E(this.details[i].id); |
| 167 var element = table.querySelector("[data-access='" + access + "']"); | 188 var element = table.querySelector("[data-access='" + access + "']"); |
| 168 if (!element) | 189 if (!element) |
| 169 continue; | 190 continue; |
| 170 | 191 |
| 171 var title = null; | 192 var title = this._getItemTitle(item, i); |
| 172 if (this.details[i].useOriginalTitle) | |
| 173 title = item.originalTitle; | |
| 174 if (!title) | |
| 175 title = item.title || item.url || item.text; | |
| 176 element.querySelector(".display").textContent = title; | 193 element.querySelector(".display").textContent = title; |
| 177 if (title) | 194 if (title) |
| 178 element.setAttribute("data-search", title.toLowerCase()); | 195 element.setAttribute("data-search", title.toLowerCase()); |
| 179 var control = element.querySelector(".control[role='checkbox']"); | 196 var control = element.querySelector(".control[role='checkbox']"); |
| 180 if (control) | 197 if (control) |
| 198 { | |
| 181 control.setAttribute("aria-checked", item.disabled == false); | 199 control.setAttribute("aria-checked", item.disabled == false); |
| 200 if (this._isControlDisabled(item, i)) | |
| 201 control.setAttribute("disabled", true); | |
| 202 } | |
| 182 | 203 |
| 183 var downloadStatus = item.downloadStatus; | 204 var downloadStatus = item.downloadStatus; |
| 184 var dateElement = element.querySelector(".date"); | 205 var dateElement = element.querySelector(".date"); |
| 185 var timeElement = element.querySelector(".time"); | 206 var timeElement = element.querySelector(".time"); |
| 186 if(dateElement && timeElement) | 207 if(dateElement && timeElement) |
| 187 { | 208 { |
| 188 var message = element.querySelector(".message"); | 209 var message = element.querySelector(".message"); |
| 189 ext.backgroundPage.sendMessage( | 210 ext.backgroundPage.sendMessage( |
| 190 { | 211 { |
| 191 type: "subscriptions.isDownloading", | 212 type: "subscriptions.isDownloading", |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 { | 467 { |
| 447 var recommendation = recommendationsMap[subscriptionUrl]; | 468 var recommendation = recommendationsMap[subscriptionUrl]; |
| 448 if (recommendation.type != "ads") | 469 if (recommendation.type != "ads") |
| 449 collection = collections.popular; | 470 collection = collections.popular; |
| 450 else if (subscription.disabled == false) | 471 else if (subscription.disabled == false) |
| 451 collection = collections.langs; | 472 collection = collections.langs; |
| 452 else | 473 else |
| 453 collection = collections.allLangs; | 474 collection = collections.allLangs; |
| 454 } | 475 } |
| 455 else if (subscriptionUrl == acceptableAdsUrl) | 476 else if (subscriptionUrl == acceptableAdsUrl) |
| 477 { | |
| 456 collection = collections.acceptableAds; | 478 collection = collections.acceptableAds; |
| 479 subscription.disableable = false; | |
| 480 } | |
| 457 else | 481 else |
| 458 collection = collections.custom; | 482 collection = collections.custom; |
| 459 | 483 |
| 460 collection.addItems(subscription); | 484 collection.addItems(subscription); |
| 461 subscriptionsMap[subscriptionUrl] = subscription; | 485 subscriptionsMap[subscriptionUrl] = subscription; |
| 462 }); | 486 }); |
| 463 } | 487 } |
| 464 } | 488 } |
| 465 | 489 |
| 466 function updateFilter(filter) | 490 function updateFilter(filter) |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 { | 914 { |
| 891 var customFilterItems = collections.customFilters.items; | 915 var customFilterItems = collections.customFilters.items; |
| 892 var filterTexts = []; | 916 var filterTexts = []; |
| 893 for (var i = 0; i < customFilterItems.length; i++) | 917 for (var i = 0; i < customFilterItems.length; i++) |
| 894 filterTexts.push(customFilterItems[i].text); | 918 filterTexts.push(customFilterItems[i].text); |
| 895 E("custom-filters-raw").value = filterTexts.join("\n"); | 919 E("custom-filters-raw").value = filterTexts.join("\n"); |
| 896 } | 920 } |
| 897 | 921 |
| 898 function getAcceptableAdsURL(callback) | 922 function getAcceptableAdsURL(callback) |
| 899 { | 923 { |
| 900 getPref("subscriptions_exceptionsurl", function(value) | 924 getPref("subscriptions_exceptionsurl", callback); |
| 901 { | |
| 902 getAcceptableAdsURL = function(callback) | |
| 903 { | |
| 904 callback(value); | |
| 905 }; | |
| 906 getAcceptableAdsURL(callback); | |
| 907 }); | |
| 908 } | 925 } |
| 909 | 926 |
| 910 function addEnableSubscription(url, title, homepage) | 927 function addEnableSubscription(url, title, homepage) |
| 911 { | 928 { |
| 912 var messageType = null; | 929 var messageType = null; |
| 913 var knownSubscription = subscriptionsMap[url]; | 930 var knownSubscription = subscriptionsMap[url]; |
| 914 if (knownSubscription && knownSubscription.disabled == true) | 931 if (knownSubscription && knownSubscription.disabled == true) |
| 915 messageType = "subscriptions.toggle" | 932 messageType = "subscriptions.toggle" |
| 916 else | 933 else |
| 917 messageType = "subscriptions.add" | 934 messageType = "subscriptions.add" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1149 }); | 1166 }); |
| 1150 ext.backgroundPage.sendMessage( | 1167 ext.backgroundPage.sendMessage( |
| 1151 { | 1168 { |
| 1152 type: "subscriptions.listen", | 1169 type: "subscriptions.listen", |
| 1153 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1170 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1154 "title"] | 1171 "title"] |
| 1155 }); | 1172 }); |
| 1156 | 1173 |
| 1157 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1174 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1158 })(); | 1175 })(); |
| OLD | NEW |