| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 (function() | 20 (function() |
| 21 { | 21 { |
| 22 var subscriptionsMap = Object.create(null); | 22 var subscriptionsMap = Object.create(null); |
| 23 var filtersMap = Object.create(null); | 23 var filtersMap = Object.create(null); |
| 24 var collections = Object.create(null); | 24 var collections = Object.create(null); |
| 25 var acceptableAdsUrl = null; | 25 var acceptableAdsUrl = null; |
| 26 var maxItemId = 0; | |
| 27 var getMessage = ext.i18n.getMessage; | 26 var getMessage = ext.i18n.getMessage; |
| 28 var filterErrors = | 27 var filterErrors = |
| 29 { | 28 { |
| 30 "synchronize_invalid_url": "options_filterList_lastDownload_invalidURL", | 29 "synchronize_invalid_url": "options_filterList_lastDownload_invalidURL", |
| 31 "synchronize_connection_error": "options_filterList_lastDownload_connectionE rror", | 30 "synchronize_connection_error": "options_filterList_lastDownload_connectionE rror", |
| 32 "synchronize_invalid_data": "options_filterList_lastDownload_invalidData", | 31 "synchronize_invalid_data": "options_filterList_lastDownload_invalidData", |
| 33 "synchronize_checksum_mismatch": "options_filterList_lastDownload_checksumMi smatch" | 32 "synchronize_checksum_mismatch": "options_filterList_lastDownload_checksumMi smatch" |
| 34 }; | 33 }; |
| 35 | 34 |
| 36 function Collection(details) | 35 function Collection(details) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 }.bind(this)); | 93 }.bind(this)); |
| 95 | 94 |
| 96 for (var j = 0; j < this.details.length; j++) | 95 for (var j = 0; j < this.details.length; j++) |
| 97 { | 96 { |
| 98 var table = E(this.details[j].id); | 97 var table = E(this.details[j].id); |
| 99 var template = table.querySelector("template"); | 98 var template = table.querySelector("template"); |
| 100 for (var i = 0; i < arguments.length; i++) | 99 for (var i = 0; i < arguments.length; i++) |
| 101 { | 100 { |
| 102 var item = arguments[i]; | 101 var item = arguments[i]; |
| 103 var listItem = document.createElement("li"); | 102 var listItem = document.createElement("li"); |
| 104 var ItemId = "item-" + (++maxItemId); | |
|
Thomas Greiner
2016/06/16 10:42:22
Detail: Variable names should start with a lower-c
saroyanm
2016/06/16 18:22:59
Done.
| |
| 105 listItem.appendChild(document.importNode(template.content, true)); | 103 listItem.appendChild(document.importNode(template.content, true)); |
| 104 listItem.setAttribute("aria-label", this._getItemTitle(item, j)); | |
| 106 listItem.setAttribute("data-access", item.url || item.text); | 105 listItem.setAttribute("data-access", item.url || item.text); |
| 107 listItem.setAttribute("id", ItemId); | |
| 108 listItem.setAttribute("role", "section"); | 106 listItem.setAttribute("role", "section"); |
| 109 | 107 |
| 110 var label = listItem.querySelector(".display"); | 108 var label = listItem.querySelector(".display"); |
| 111 label.setAttribute("for", ItemId); | |
| 112 if (item.recommended && label.hasAttribute("data-tooltip")) | 109 if (item.recommended && label.hasAttribute("data-tooltip")) |
| 113 { | 110 { |
| 114 var tooltipId = label.getAttribute("data-tooltip"); | 111 var tooltipId = label.getAttribute("data-tooltip"); |
| 115 tooltipId = tooltipId.replace("%value%", item.recommended); | 112 tooltipId = tooltipId.replace("%value%", item.recommended); |
| 116 label.setAttribute("data-tooltip", tooltipId); | 113 label.setAttribute("data-tooltip", tooltipId); |
| 117 } | 114 } |
| 118 | 115 |
| 119 var controls = listItem.querySelectorAll(".control"); | 116 var controls = listItem.querySelectorAll(".control"); |
| 120 for (var k = 0; k < controls.length; k++) | 117 for (var k = 0; k < controls.length; k++) |
| 121 controls[k].setAttribute("aria-labelledby", ItemId); | 118 { |
| 119 if (controls[k].hasAttribute("title")) | |
| 120 { | |
| 121 var titleValue = getMessage(controls[k].getAttribute("title")); | |
| 122 controls[k].setAttribute("title", titleValue) | |
| 123 } | |
| 124 } | |
| 122 | 125 |
| 123 this._setEmpty(table, null); | 126 this._setEmpty(table, null); |
| 124 if (table.hasChildNodes()) | 127 if (table.hasChildNodes()) |
| 125 { | 128 { |
| 126 table.insertBefore(listItem, | 129 table.insertBefore(listItem, |
| 127 table.childNodes[this.items.indexOf(item)]); | 130 table.childNodes[this.items.indexOf(item)]); |
| 128 } | 131 } |
| 129 else | 132 else |
| 130 table.appendChild(listItem); | 133 table.appendChild(listItem); |
| 131 this.updateItem(item); | 134 this.updateItem(item); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 var access = (item.url || item.text).replace(/'/g, "\\'"); | 181 var access = (item.url || item.text).replace(/'/g, "\\'"); |
| 179 for (var i = 0; i < this.details.length; i++) | 182 for (var i = 0; i < this.details.length; i++) |
| 180 { | 183 { |
| 181 var table = E(this.details[i].id); | 184 var table = E(this.details[i].id); |
| 182 var element = table.querySelector("[data-access='" + access + "']"); | 185 var element = table.querySelector("[data-access='" + access + "']"); |
| 183 if (!element) | 186 if (!element) |
| 184 continue; | 187 continue; |
| 185 | 188 |
| 186 var title = this._getItemTitle(item, i); | 189 var title = this._getItemTitle(item, i); |
| 187 element.querySelector(".display").textContent = title; | 190 element.querySelector(".display").textContent = title; |
| 188 element.setAttribute("label", title); | 191 element.setAttribute("aria-label", title); |
|
Thomas Greiner
2016/06/16 10:42:22
What's the "label" attribute supposed to do?
saroyanm
2016/06/16 18:22:59
I was testing with screen reader and apparently in
Thomas Greiner
2016/06/17 14:07:50
Ok, in that case please use the standardized "aria
saroyanm
2016/06/21 13:29:56
I had another look and seems like removing this at
Thomas Greiner
2016/06/22 10:26:13
I could imagine that the duplication might be beca
saroyanm
2016/06/22 13:46:16
Genius! Done.
| |
| 189 if (title) | 192 if (this.details[i].searchable) |
| 190 element.setAttribute("data-search", title.toLowerCase()); | 193 element.setAttribute("data-search", title.toLowerCase()); |
| 191 var control = element.querySelector(".control[role='checkbox']"); | 194 var control = element.querySelector(".control[role='checkbox']"); |
| 192 if (control) | 195 if (control) |
| 193 { | 196 { |
| 194 control.setAttribute("aria-checked", item.disabled == false); | 197 control.setAttribute("aria-checked", item.disabled == false); |
| 195 if (item.url == acceptableAdsUrl && this == collections.filterLists) | 198 if (item.url == acceptableAdsUrl && this == collections.filterLists) |
| 196 control.setAttribute("disabled", true); | 199 control.setAttribute("disabled", true); |
| 197 } | 200 } |
| 198 | 201 |
| 199 var dateElement = element.querySelector(".date"); | 202 var dateElement = element.querySelector(".date"); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 }, | 290 }, |
| 288 { | 291 { |
| 289 id: "blocking-languages-dialog-table", | 292 id: "blocking-languages-dialog-table", |
| 290 emptyText: "options_dialog_language_added_empty" | 293 emptyText: "options_dialog_language_added_empty" |
| 291 } | 294 } |
| 292 ]); | 295 ]); |
| 293 collections.allLangs = new Collection( | 296 collections.allLangs = new Collection( |
| 294 [ | 297 [ |
| 295 { | 298 { |
| 296 id: "all-lang-table", | 299 id: "all-lang-table", |
| 297 emptyText: "options_dialog_language_other_empty" | 300 emptyText: "options_dialog_language_other_empty", |
| 301 searchable: true | |
| 298 } | 302 } |
| 299 ]); | 303 ]); |
| 300 collections.acceptableAds = new Collection( | 304 collections.acceptableAds = new Collection( |
| 301 [ | 305 [ |
| 302 { | 306 { |
| 303 id: "acceptableads-table" | 307 id: "acceptableads-table" |
| 304 } | 308 } |
| 305 ]); | 309 ]); |
| 306 collections.custom = new Collection( | 310 collections.custom = new Collection( |
| 307 [ | 311 [ |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 916 if (subscription.url in subscriptionsMap) | 920 if (subscription.url in subscriptionsMap) |
| 917 subscription = updateSubscription(subscription); | 921 subscription = updateSubscription(subscription); |
| 918 else | 922 else |
| 919 addSubscription(subscription); | 923 addSubscription(subscription); |
| 920 | 924 |
| 921 collections.filterLists.addItems(subscription); | 925 collections.filterLists.addItems(subscription); |
| 922 updateLanguageCollections(subscription); | 926 updateLanguageCollections(subscription); |
| 923 break; | 927 break; |
| 924 case "removed": | 928 case "removed": |
| 925 var knownSubscription = subscriptionsMap[subscription.url]; | 929 var knownSubscription = subscriptionsMap[subscription.url]; |
| 926 | |
| 927 if (subscription.url == acceptableAdsUrl || subscription.recommended) | 930 if (subscription.url == acceptableAdsUrl || subscription.recommended) |
| 928 { | 931 { |
| 929 subscription.disabled = true; | 932 subscription.disabled = true; |
| 930 onSubscriptionMessage("disabled", subscription); | 933 onSubscriptionMessage("disabled", subscription); |
| 931 } | 934 } |
| 932 else | 935 else |
| 933 { | 936 { |
| 934 collections.custom.removeItem(knownSubscription); | 937 collections.custom.removeItem(knownSubscription); |
| 935 delete subscriptionsMap[subscription.url]; | 938 delete subscriptionsMap[subscription.url]; |
| 936 } | 939 } |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1168 }); | 1171 }); |
| 1169 ext.backgroundPage.sendMessage( | 1172 ext.backgroundPage.sendMessage( |
| 1170 { | 1173 { |
| 1171 type: "subscriptions.listen", | 1174 type: "subscriptions.listen", |
| 1172 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1175 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1173 "title", "downloadStatus", "downloading"] | 1176 "title", "downloadStatus", "downloading"] |
| 1174 }); | 1177 }); |
| 1175 | 1178 |
| 1176 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1179 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1177 })(); | 1180 })(); |
| LEFT | RIGHT |