| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 | 56 |
| 57 Collection.prototype._createElementQuery = function(item) | 57 Collection.prototype._createElementQuery = function(item) |
| 58 { | 58 { |
| 59 var access = (item.url || item.text).replace(/'/g, "\\'"); | 59 var access = (item.url || item.text).replace(/'/g, "\\'"); |
| 60 return function(container) | 60 return function(container) |
| 61 { | 61 { |
| 62 return container.querySelector("[data-access='" + access + "']"); | 62 return container.querySelector("[data-access='" + access + "']"); |
| 63 }; | 63 }; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 Collection.prototype._isControlDisabled = function(item, i) | |
| 67 { | |
| 68 return item.url == acceptableAdsUrl && | |
| 69 this.details[i].onClick == toggleDisableSubscription; | |
| 70 }; | |
| 71 | |
| 72 Collection.prototype._getItemTitle = function(item, i) | 66 Collection.prototype._getItemTitle = function(item, i) |
| 73 { | 67 { |
| 74 var title = null; | 68 var title = null; |
| 75 if (this.details[i].useOriginalTitle) | 69 if (this.details[i].useOriginalTitle) |
| 76 title = item.originalTitle; | 70 title = item.originalTitle; |
| 77 if (!title) | 71 if (!title) |
| 78 title = item.title || item.url || item.text; | 72 title = item.title || item.url || item.text; |
| 79 return title; | 73 return title; |
| 80 }; | 74 }; |
| 81 | 75 |
| 82 Collection.prototype.addItems = function() | 76 Collection.prototype.addItems = function() |
| 83 { | 77 { |
| 84 var length = Array.prototype.push.apply(this.items, arguments); | 78 var length = Array.prototype.push.apply(this.items, arguments); |
| 85 if (length == 0) | 79 if (length == 0) |
| 86 return; | 80 return; |
| 87 | 81 |
| 88 this.items.sort(function(a, b) | 82 this.items.sort(function(a, b) |
| 89 { | 83 { |
| 90 var aDisabled = this._isControlDisabled(a, 0); | 84 // Make sure that Acceptable Ads is always last, since it cannot be |
| 91 var bDisabled = this._isControlDisabled(b, 0); | 85 // disabled, but only be removed. That way it's grouped together with |
|
Thomas Greiner
2016/04/07 17:21:15
It's a nice idea to group together all disabled ch
Sebastian Noack
2016/04/08 14:22:17
Yeah, hard-coding the index isn't great, but we ha
| |
| 92 if (aDisabled != bDisabled) | 86 // the "Own filter list" which cannot be disabled either at the bottom |
| 93 return aDisabled - bDisabled; | 87 // of the filter lists in the Advanced tab. |
| 88 if (a.url == acceptableAdsUrl) | |
| 89 return 1; | |
| 90 if (b.url == acceptableAdsUrl) | |
| 91 return -1; | |
| 94 | 92 |
| 95 var aTitle = this._getItemTitle(a, 0).toLowerCase(); | 93 var aTitle = this._getItemTitle(a, 0).toLowerCase(); |
|
Thomas Greiner
2016/04/07 17:21:15
Detail: Hardcoding the table index here might caus
Sebastian Noack
2016/04/08 14:22:17
I know. This is kinda a hack. But at least more co
| |
| 96 var bTitle = this._getItemTitle(b, 0).toLowerCase(); | 94 var bTitle = this._getItemTitle(b, 0).toLowerCase(); |
| 97 return aTitle.localeCompare(bTitle); | 95 return aTitle.localeCompare(bTitle); |
| 98 }.bind(this)); | 96 }.bind(this)); |
| 99 | 97 |
| 100 for (var j = 0; j < this.details.length; j++) | 98 for (var j = 0; j < this.details.length; j++) |
| 101 { | 99 { |
| 102 var table = E(this.details[j].id); | 100 var table = E(this.details[j].id); |
| 103 var template = table.querySelector("template"); | 101 var template = table.querySelector("template"); |
| 104 for (var i = 0; i < arguments.length; i++) | 102 for (var i = 0; i < arguments.length; i++) |
| 105 { | 103 { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 continue; | 189 continue; |
| 192 | 190 |
| 193 var title = this._getItemTitle(item, i); | 191 var title = this._getItemTitle(item, i); |
| 194 element.querySelector(".display").textContent = title; | 192 element.querySelector(".display").textContent = title; |
| 195 if (title) | 193 if (title) |
| 196 element.setAttribute("data-search", title.toLowerCase()); | 194 element.setAttribute("data-search", title.toLowerCase()); |
| 197 var control = element.querySelector(".control[role='checkbox']"); | 195 var control = element.querySelector(".control[role='checkbox']"); |
| 198 if (control) | 196 if (control) |
| 199 { | 197 { |
| 200 control.setAttribute("aria-checked", item.disabled == false); | 198 control.setAttribute("aria-checked", item.disabled == false); |
| 201 if (this._isControlDisabled(item, i)) | 199 if (item.url == acceptableAdsUrl && this.details[i].onClick == |
| 200 toggleDisableSubscription) | |
| 202 control.setAttribute("disabled", true); | 201 control.setAttribute("disabled", true); |
| 203 } | 202 } |
| 204 | 203 |
| 205 var dateElement = element.querySelector(".date"); | 204 var dateElement = element.querySelector(".date"); |
| 206 var timeElement = element.querySelector(".time"); | 205 var timeElement = element.querySelector(".time"); |
| 207 if (dateElement && timeElement) | 206 if (dateElement && timeElement) |
| 208 { | 207 { |
| 209 var message = element.querySelector(".message"); | 208 var message = element.querySelector(".message"); |
| 210 if (item.isDownloading) | 209 if (item.isDownloading) |
| 211 { | 210 { |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1154 }); | 1153 }); |
| 1155 ext.backgroundPage.sendMessage( | 1154 ext.backgroundPage.sendMessage( |
| 1156 { | 1155 { |
| 1157 type: "subscriptions.listen", | 1156 type: "subscriptions.listen", |
| 1158 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1157 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1159 "title", "downloadStatus", "downloading"] | 1158 "title", "downloadStatus", "downloading"] |
| 1160 }); | 1159 }); |
| 1161 | 1160 |
| 1162 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1161 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1163 })(); | 1162 })(); |
| LEFT | RIGHT |