Closed GoogleCodeExporter closed 8 years ago
You might also want to have another substring for text after the value: maybe
called "extra".
extra could store extra information about particular elements, (such as "option
1 of 6"). Although ideally, that extra information would only be provided when
a person activates a control--that way they only hear the extra information
when they are interested in that particular control.
Original comment by jbjor...@gmail.com
on 22 May 2013 at 6:51
Some code ideas
/* General checks for precedence */
var name = '';
if (obj.hasAttribute(data-ez-sayalt)) name = obj.getAttribute(data-ez-sayalt);
else if (obj.hasAttribute(aria-label)) name = obj.getAttribute(aria-label);
else if (label) name = label; //assuming you get the label earlier
var role = '';
if (obj.hasAttribute(data-ez-sayrole)) role = obj.getAttribute(data-ez-sayrole);
var ariaRole = obj.getAttribute(aria-role);
else if (obj.hasAttribute(aria-role) && (ariaRole == 'button' || ariaRole ==
'checkbox' || ariaRole == 'radio')) {
role = ariaRole;
}
var value = '';
if (obj.hasAttribute(data-ez-sayvalue)) value =
obj.getAttribute(data-ez-sayvalue);
/* Specific enhancements for particular elements */
//example
...
if(obj.tagName == 'INPUT') {
if(obj.getAttribute('readonly') || obj.getAttribute('disabled')) {
if(name == '') {
name = "Disabled field";
}
else {
phrase = 'is';
}
if(obj.value !== undefined) { //This may be safer, b/c what if value=0, which is falsy?
value = obj.value;
} else {
value = "blank.";
}
//Continue with other elements
//Be sure to check if name, role, or value already have a value before writing
a new one, for example
...
else if(obj.type == 'submit') {
if (name == '') {
if(obj.value) name = obj.value;
else name = "Submit";
}
role = " Button";
} ...
//At the end, the standard concatenation might look like this:
if (speech == '') { //i.e., it has not been "over-ridden"
speech = name + ' ' + role + ' ' + phrase + ' ' + value + ' ' + extra + '.';
}
Original comment by jbjor...@gmail.com
on 22 May 2013 at 7:18
More function-based approach
function getName( obj ) {
var ret = '';
if (obj.hasAttribute(data-ez-sayalt)) ret = obj.getAttribute(data-ez-sayalt);
else if (obj.hasAttribute(aria-labelledby) {
var labelID = obj.getAttribute(aria-labelledby);
//since aria-labelledby could be a space-delimited list of IDs,
//you will need to concatenate if there is a list
//so the code will be a little more involved than:
ret += document.getElementById(labelID).textContent;
}
else if (obj.hasAttribute(aria-label)) ret = obj.getAttribute(aria-label);
else if ( findLabel() != '') ret = findLabel();
else if (obj.hasAttribute(placeholder) ret = obj.getAttribute(placeholder);
//Could get other possible name/labels here or not
//Could get inner text content here or not
return ret;
}
//If you don't catch everything in getName(), you will need to handle for a
return of a blank name elsewhere--perhaps with code for individual elements.
Original comment by jbjor...@gmail.com
on 22 May 2013 at 7:32
I'll handle this one.
Original comment by jbjor...@gmail.com
on 28 May 2013 at 2:23
Implemented in a fashion with r137.
Note that there is no connecting phrase, which should be included in the value
string.
Original comment by jbjor...@gmail.com
on 28 May 2013 at 4:13
Original comment by jbjor...@gmail.com
on 28 May 2013 at 9:09
Original issue reported on code.google.com by
jbjor...@gmail.com
on 22 May 2013 at 5:58