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

Delta Between Two Patch Sets: options.js

Issue 29332808: Issue 2408 - Improved accessibility of checkboxes in options page (Closed)
Left Patch Set: Rebased to 59920e6112a6 Created Dec. 17, 2015, 6:36 p.m.
Right Patch Set: Reverted styles for Advanced tab Created Jan. 25, 2016, 6:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « options.html ('k') | skin/options.css » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 var table = E(this.details[j].id); 63 var table = E(this.details[j].id);
64 var template = table.querySelector("template"); 64 var template = table.querySelector("template");
65 for (var i = 0; i < arguments.length; i++) 65 for (var i = 0; i < arguments.length; i++)
66 { 66 {
67 var item = arguments[i]; 67 var item = arguments[i];
68 var listItem = document.createElement("li"); 68 var listItem = document.createElement("li");
69 listItem.appendChild(document.importNode(template.content, true)); 69 listItem.appendChild(document.importNode(template.content, true));
70 listItem.setAttribute("data-access", item.url || item.text); 70 listItem.setAttribute("data-access", item.url || item.text);
71 71
72 var labelId = "label-" + (++maxLabelId); 72 var labelId = "label-" + (++maxLabelId);
73 var label = listItem.querySelector(".display"); 73 listItem.querySelector(".display").setAttribute("id", labelId);
saroyanm 2016/01/19 11:19:50 Nit: we can have two lines merged: listItem.query
Thomas Greiner 2016/01/19 15:15:04 Done.
74 label.setAttribute("id", labelId);
75 var control = listItem.querySelector(".control"); 74 var control = listItem.querySelector(".control");
76 if (control) 75 if (control)
77 { 76 {
78 // We use aria-labelledby to avoid triggering the control when 77 // We use aria-labelledby to avoid triggering the control when
79 // interacting with the label 78 // interacting with the label
80 control.setAttribute("aria-labelledby", labelId); 79 control.setAttribute("aria-labelledby", labelId);
81 control.addEventListener("click", this.details[j].onClick, false); 80 control.addEventListener("click", this.details[j].onClick, false);
82 } 81 }
83 82
84 this._setEmpty(table, null); 83 this._setEmpty(table, null);
(...skipping 18 matching lines...) Expand all
103 { 102 {
104 var table = E(this.details[i].id); 103 var table = E(this.details[i].id);
105 var element = table.childNodes[index]; 104 var element = table.childNodes[index];
106 105
107 // Element gets removed so make sure to handle focus appropriately 106 // Element gets removed so make sure to handle focus appropriately
108 var control = element.querySelector(".control"); 107 var control = element.querySelector(".control");
109 if (control && control == document.activeElement) 108 if (control && control == document.activeElement)
110 { 109 {
111 if (!focusNextElement(element.parentElement, control)) 110 if (!focusNextElement(element.parentElement, control))
112 { 111 {
113 // Fall back to next focusable element within same tab 112 // Fall back to next focusable element within same tab or dialog
114 var tab = element.parentElement; 113 var focusableElement = element.parentElement;
115 while (true) 114 while (focusableElement)
saroyanm 2016/01/19 11:19:49 What about ? while (tab.tagName == "BODY") ? In t
Thomas Greiner 2016/01/19 15:15:04 Done. Checking for the element type should be the
saroyanm 2016/01/25 14:45:43 you can also check for the element itself "documen
116 { 115 {
117 if (tab.classList.contains("tab-content")) 116 if (focusableElement.classList.contains("tab-content")
117 || focusableElement.classList.contains("dialog-content"))
118 break; 118 break;
119 119
120 tab = tab.parentElement; 120 focusableElement = focusableElement.parentElement;
121 if (!tab)
122 {
123 tab = document;
124 break;
125 }
126 } 121 }
127 focusNextElement(tab, control); 122 focusNextElement(focusableElement || document, control);
128 } 123 }
129 } 124 }
130 125
131 element.parentElement.removeChild(element); 126 element.parentElement.removeChild(element);
132 if (this.items.length == 0) 127 if (this.items.length == 0)
133 this._setEmpty(table, this.details[i].emptyText); 128 this._setEmpty(table, this.details[i].emptyText);
134 } 129 }
135 }; 130 };
136 131
137 Collection.prototype.updateItem = function(item) 132 Collection.prototype.updateItem = function(item)
saroyanm 2016/01/19 11:19:50 I think it make sense to have second optional argu
Thomas Greiner 2016/01/19 15:15:04 But an item can be associated with multiple list e
138 { 133 {
139 var access = (item.url || item.text).replace(/'/g, "\\'"); 134 var access = (item.url || item.text).replace(/'/g, "\\'");
140 for (var i = 0; i < this.details.length; i++) 135 for (var i = 0; i < this.details.length; i++)
141 { 136 {
142 var table = E(this.details[i].id); 137 var table = E(this.details[i].id);
143 var element = table.querySelector("[data-access='" + access + "']"); 138 var element = table.querySelector("[data-access='" + access + "']");
144 if (!element) 139 if (!element)
145 continue; 140 continue;
146 141
147 var text = item.title || item.url || item.text; 142 var text = item.title || item.url || item.text;
(...skipping 14 matching lines...) Expand all
162 var table = E(this.details[i].id); 157 var table = E(this.details[i].id);
163 var template = table.querySelector("template"); 158 var template = table.querySelector("template");
164 table.innerHTML = ""; 159 table.innerHTML = "";
165 table.appendChild(template); 160 table.appendChild(template);
166 this._setEmpty(table, this.details[i].emptyText); 161 this._setEmpty(table, this.details[i].emptyText);
167 } 162 }
168 }; 163 };
169 164
170 function focusNextElement(container, currentElement) 165 function focusNextElement(container, currentElement)
171 { 166 {
172 var focusables = container.querySelectorAll("a, button, .control"); 167 var focusables = container.querySelectorAll("a, button, input, .control");
saroyanm 2016/01/19 11:19:50 What about have a focus for input elements as well
Thomas Greiner 2016/01/19 15:15:04 Done.
173 focusables = Array.prototype.slice.call(focusables); 168 focusables = Array.prototype.slice.call(focusables);
174 var index = focusables.indexOf(currentElement); 169 var index = focusables.indexOf(currentElement);
175 if (index + 1 < focusables.length) 170 index += (index == focusables.length - 1) ? -1 : 1;
saroyanm 2016/01/19 11:19:49 I think we can write this one line, something like
Thomas Greiner 2016/01/19 15:15:04 Done.
176 index += 1;
177 else if (index < focusables.length)
178 index -= 1;
179 171
180 var nextElement = focusables[index]; 172 var nextElement = focusables[index];
181 if (!nextElement) 173 if (!nextElement)
182 return false; 174 return false;
183 175
184 nextElement.focus(); 176 nextElement.focus();
185 return true; 177 return true;
186 } 178 }
187 179
188 function onToggleSubscriptionClick(e) 180 function onToggleSubscriptionClick(e)
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 filter: ["added", "loaded", "removed"] 867 filter: ["added", "loaded", "removed"]
876 }); 868 });
877 ext.backgroundPage.sendMessage( 869 ext.backgroundPage.sendMessage(
878 { 870 {
879 type: "subscriptions.listen", 871 type: "subscriptions.listen",
880 filter: ["added", "disabled", "homepage", "removed", "title"] 872 filter: ["added", "disabled", "homepage", "removed", "title"]
881 }); 873 });
882 874
883 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 875 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
884 })(); 876 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld