Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Accessibility issues #428

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions boxes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def html(self, name, default, translate):
("""<option value="%s"%s>%s</option>""" %
(e, ' selected="selected"' if e == default else "",
translate("%s %s" % (e, self.names.get(e, "")))) for e in self.edges))
return """<select name="%s" size="1">\n%s</select>\n""" % (name, options)
return """<select name="%s" size="1">\n%s</select>\n""" % (name, options) #here

def inx(self, name, viewname, arg):
return (' <param name="%s" type="optiongroup" appearance="combo" gui-text="%s" gui-description=%s>\n' %
Expand All @@ -218,8 +218,8 @@ def html(self, name, default, _):
if isinstance(default, (str)):
default = self(default)
return """<input name="%s" type="hidden" value="0">
<input name="%s" type="checkbox" value="1"%s>""" % \
(name, name, ' checked="checked"' if default else "")
<input name="%s" id="%s" aria-labeledby="%s %s" type="checkbox" value="1"%s>""" % \
(name, name, name, name+"_id", name+"_description",' checked="checked"' if default else "") #fix here
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adds associated of label to the left of the input box and description to the right to the input box so screen readers will announce items it does this with an id tag and aria-labeledby tags that reference labelfor tags and id tags there is some redundancy with the aria-labeledby tag referencing the same tag as the label for tag (ie name_id) this is to provide robustness across different screen readers.


boolarg = BoolArg()

Expand Down
17 changes: 9 additions & 8 deletions scripts/boxesserver
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,25 @@ class BServer:
viewname = name[len(prefix)+1:]

default = defaults.get(name, None)

row = """<tr><td>%s</td><td>%%s</td><td>%s</td></tr>\n""" % \
(_(viewname), "" if not a.help else markdown.markdown(_(a.help)))
#fix here?
row = """<tr><td id="%s"><label for="%s">%s</label></td><td>%%s</td><td id="%s">%s</td></tr>\n""" % \
(name+"_id", name, _(viewname), name+"_description","" if not a.help else markdown.markdown(_(a.help)))
if (isinstance(a, argparse._StoreAction) and
hasattr(a.type, "html")):
input = a.type.html(name, default or a.default, _)
elif a.dest == "layout":
val = (default or a.default).split("\n")
input = """<textarea name="%s" cols="%s" rows="%s">%s</textarea>""" % \
(name, max((len(l) for l in val))+10, len(val)+1, default or a.default)
input = """<textarea name="%s" id="%s" aria-labeledby="%s %s" cols="%s" rows="%s">%s</textarea>""" % \
(name, name, name+"_id", name+"_description", max((len(l) for l in val))+10, len(val)+1, default or a.default)
elif a.choices:
options = "\n".join(
("""<option value="%s"%s>%s</option>""" %
(e, ' selected="selected"' if (e == (default or a.default)) or (str(e) == str(default or a.default)) else "",
_(e)) for e in a.choices))
input = """<select name="%s" size="1">\n%s</select>\n""" % (name, options)
input = """<select name="%s" id="%s" aria-labeledby="%s %s" size="1" >\n%s</select>\n""" % (name, name, name+"_id", name+"_description", options)
else:
input = """<input name="%s" type="text" value="%s">""" % \
(name, default or a.default)
input = """<input name="%s" id="%s" aria-labeledby="%s %s" type="text" value="%s" >""" % \
(name, name, name+"_id", name+"_description", default or a.default)

return row % input

Expand Down Expand Up @@ -250,6 +250,7 @@ class BServer:

for a in group._group_actions:
if a.dest in ("input", "output"):

continue
result.append(self.arg2html(a, prefix, defaults, _))
result.append("</table>")
Expand Down