-
Notifications
You must be signed in to change notification settings - Fork 4.3k
a11y imporvements to wiki/history.html #1543
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,14 +8,39 @@ | |
|
|
||
| {% addtoblock "js" %} | ||
| <script type="text/javascript" src="{{ STATIC_URL }}wiki/js/diffview.js"></script> | ||
| <script type="text/javascript" src="{{ STATIC_URL }}wiki/js/diff.js"></script> | ||
| <script type="text/javascript"> | ||
| $(document).ready( | ||
| function() { | ||
| $('.accordion input[disabled!="disabled"][type="radio"]').first().attr('checked', 'true'); | ||
| // Fix modal heights | ||
| // $('.modal-body').css('height', $(window).height()*0.70 + 'px'); | ||
| // $('.modal').css('max-height', $(window).height() + 'px'); | ||
|
|
||
| $( document ).ready(function() { | ||
| $('.accordion input[disabled!="disabled"][type="radio"]').first().attr('checked', 'true'); | ||
|
|
||
| $('a.accordion-toggle').click(function(event) { | ||
| event.preventDefault(); | ||
| var diffUrl = $(event.target).attr('href'); | ||
| var accordionBody = $(this).parentsUntil('.accordion').find('.accordion-body'); | ||
|
|
||
| jsonWrapper(diffUrl, function (data) { | ||
| if (!accordionBody.find('.diff-container tbody').length > 0) { | ||
| accordionBody.parentsUntil('.accordion').find('.progress').show(0 , function() { | ||
| tbody = pydifferviewer.as_tbody({differ_output: data.diff}); | ||
| accordionBody.find('.diff-container table').append(tbody); | ||
| if (data.other_changes) { | ||
| for (var i=0; i < data.other_changes.length; i++) { | ||
| accordionBody.find('dl').append($('<dt>'+data.other_changes[i][0]+'</dt>' + | ||
| '<dd>'+data.other_changes[i][1]+'</dd>' )); | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really qualified to truly PR this section as I'm not incredibly familiar with this accordion content code...but it seems somewhat reasonable?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See note above. I have just changed the name of the div. Otherwise the logic is the same as before. |
||
| accordionBody.parentsUntil('.accordion').find('.progress').detach(); | ||
| accordionBody.removeClass('collapse'); | ||
| accordionBody.focus(); | ||
| }); | ||
| } else { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the accordion content IS loaded, toggle collapse and focus it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup. |
||
| accordionBody.toggleClass('collapse'); | ||
| if (!accordionBody.hasClass('collapse')) { | ||
| accordionBody.focus(); | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Focus diff details after uncollapsing it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This handler was previously in diff.js in the django-wiki repo. I have copied it over to remove twitter bootstrap collapse module whose behavior was causing screen readers to start reading from the start. |
||
| } | ||
| }); | ||
| }); | ||
| }); | ||
| </script> | ||
| {% endaddtoblock %} | ||
|
|
@@ -62,7 +87,7 @@ | |
| <div class="accordion" id="accordion{{ revision.revision_number }}"> | ||
| <div class="accordion-group"> | ||
| <div class="accordion-heading"> | ||
| <a class="accordion-toggle" style="float: left;" href="#collapse{{ revision.revision_number }}" onclick="get_diff_json('{% url 'wiki:diff' revision.id %}', $('#collapse{{ revision.revision_number }}'))"> | ||
| <a class="accordion-toggle" style="float: left;" href="{% url 'wiki:diff' revision.id %}"> | ||
| <span class="icon-plus"></span> | ||
| {% include "wiki/includes/revision_info.html" with current_revision=article.current_revision %} | ||
| <div style="color: #CCC;"> | ||
|
|
@@ -95,7 +120,7 @@ | |
| </div> | ||
| <div style="clear: both"></div> | ||
| </div> | ||
| <div id="collapse{{ revision.revision_number }}" class="accordion-body collapse"> | ||
| <div id="collapse{{ revision.revision_number }}" class="accordion-body collapse" tabindex="0"> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make revision details div keyboard focusable.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, looks completely sane. |
||
| <div class="accordion-inner diff-container" style="padding: 0;"> | ||
| <dl class="dl-horizontal"> | ||
| <dt>{% trans "Auto log:" %}</dt> | ||
|
|
@@ -104,9 +129,9 @@ | |
| <table class="table table-condensed" style="margin: 0; border-collapse: collapse;"> | ||
| <thead> | ||
| <tr> | ||
| <th class="linenumber">{% if revision.previous_revision %}#{{revision.previous_revision.revision_number}}{% endif %}</th> | ||
| <th class="linenumber">#{{revision.revision_number}}</th> | ||
| <th>{% trans "Change" %}</th> | ||
| <th scope="col" class="linenumber">{% if revision.previous_revision %}#{{revision.previous_revision.revision_number}}{% endif %}</th> | ||
| <th scope="col" class="linenumber">#{{revision.revision_number}}</th> | ||
| <th scope="col">{% trans "Change" %}</th> | ||
| </tr> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Annotate table cells.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Follows W3 table a11y syntax so, this lgtm... |
||
| </thead> | ||
| </table> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This basically loads content of accordion if it's not loaded, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This function is taken from https://github.com/edx/django-wiki/blob/master/wiki/static/wiki/js/diff.js. I have just cleaned it up a bit and added a few lines to toggleClass('collapsed') and do focus() at the appropriate places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should delete wiki/js/diff.js if we're not using it too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its in the django-wiki repo. Then we will have to create a PR there, and then update the commit id in the requirements file. So best to skip it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok