Repository navigation
Improve accessibility for dashboard course settings dropdown #11393
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 1 commit
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 |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| var edx = edx || {}; | ||
|
|
||
| (function ($) { | ||
| 'use strict'; | ||
|
|
||
| edx.dashboard = edx.dashboard || {}; | ||
| edx.dashboard.dropdown = {}; | ||
|
|
||
| // Generate the properties object to be passed along with business intelligence events. | ||
| edx.dashboard.dropdown.toggleCourseActionsDropdownMenu = function (event) { | ||
| // define variables for code legibility | ||
| var dashboardIndex = $(event.currentTarget).data().dashboardIndex, | ||
| dropdown = $('#actions-dropdown-' + dashboardIndex), | ||
| dropdownButton = $('#actions-dropdown-link-' + dashboardIndex), | ||
| ariaExpandedState = (dropdownButton.attr('aria-expanded') === 'true'), | ||
| menuItems = dropdown.find('a'); | ||
|
|
||
| var catchKeyPress = function(object, event) { | ||
| // get currently focused item | ||
| var focusedItem = $(':focus'); | ||
|
|
||
| // get the index of the currently focused item | ||
| var focusedItemIndex = menuItems.index(focusedItem); | ||
|
|
||
| // var to store next focused item index | ||
| var itemToFocusIndex; | ||
|
|
||
| // if space or escape key pressed | ||
| if ( event.which === 32 || event.which === 27) { | ||
| dropdownButton.click(); | ||
| event.preventDefault(); | ||
| } | ||
|
|
||
| // if up arrow key pressed or shift+tab | ||
| else if (event.which === 38 || (event.which === 9 && event.shiftKey)) { | ||
| // if first item go to last | ||
| if (focusedItemIndex === 0 || focusedItemIndex === -1) { | ||
| menuItems.last().focus(); | ||
| } else { | ||
| itemToFocusIndex = focusedItemIndex - 1; | ||
| menuItems.get(itemToFocusIndex).focus(); | ||
| } | ||
| event.preventDefault(); | ||
| } | ||
|
|
||
| // if down arrow key pressed or tab key | ||
| else if (event.which === 40 || event.which === 9) { | ||
| // if last item go to first | ||
| if (focusedItemIndex === menuItems.length - 1 || focusedItemIndex === -1) { | ||
| menuItems.first().focus(); | ||
| } else { | ||
| itemToFocusIndex = focusedItemIndex + 1; | ||
| menuItems.get(itemToFocusIndex).focus(); | ||
| } | ||
| event.preventDefault(); | ||
| } | ||
| }; | ||
|
|
||
| // Toggle the visibility control for the selected element and set the focus | ||
| dropdown.toggleClass('is-visible'); | ||
| if (dropdown.hasClass('is-visible')) { | ||
| dropdown.attr('tabindex', -1); | ||
| dropdown.focus(); | ||
| } else { | ||
| dropdown.removeAttr('tabindex'); | ||
| dropdownButton.focus(); | ||
| } | ||
|
|
||
| // Inform the ARIA framework that the dropdown has been expanded | ||
| dropdownButton.attr('aria-expanded', !ariaExpandedState); | ||
|
|
||
| //catch keypresses when inside dropdownMenu (we want to catch spacebar; | ||
| // escape; up arrow or shift+tab; and down arrow or tab) | ||
| dropdown.on('keydown', function(event){ | ||
| catchKeyPress($(this), event); | ||
| }); | ||
| }; | ||
|
|
||
| edx.dashboard.dropdown.bindToggleButtons = function() { | ||
| $('.action-more').bind( | ||
| 'click', | ||
| edx.dashboard.dropdown.toggleCourseActionsDropdownMenu | ||
| ); | ||
| }; | ||
|
|
||
| $(document).ready(function() { | ||
| edx.dashboard.dropdown.bindToggleButtons(); | ||
| }); | ||
|
|
||
| })(jQuery); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| <style> | ||
| .actions-dropdown { display: none; } | ||
| .actions-dropdown.is-visible { display: block; } | ||
| </style> | ||
| <a class="cover" data-course-key="edX/DemoX/Demo_Course" href="courses/edX/DemoX/Demo_Course/info"> | ||
| <img alt="DemoX" class="course-image" src="/path/to/image.jpg"> | ||
| </a> | ||
|
|
@@ -21,12 +25,13 @@ <h3 class="course-title"> | |
|
|
||
| <a href="#" class="verified-info" data-course-key="edX/DemoX/Demo_Course"></a> | ||
|
|
||
|
|
||
| <div class="course-container"> | ||
| <div class="label-xseries-association"> | ||
| <i class="xseries-icon"></i> | ||
| <p class="message-copy">XSeries Program Course</p> | ||
| </div> | ||
| <article class="course honor"> | ||
| <article class="course honor"> | ||
| <section class="details"> | ||
| <div class="wrapper-course-image" aria-hidden="true"> | ||
| <a class="cover"> | ||
|
|
@@ -48,10 +53,102 @@ <h3 class="course-title"><span>Introduction to Drinking Water Treatment</span></ | |
| <div class="wrapper-course-actions"> | ||
| <div class="course-actions"> | ||
| <div class="wrapper-action-more" data-course-key="course-v1:DelftX+CTB3365DWx+1T2016"> | ||
| <a href="#actions-dropdown-2" class="action action-more" id="actions-dropdown-link-2" aria-haspopup="true" aria-expanded="false" data-course-number="CTB3365DWx" data-course-name="Introduction to Drinking Water Treatment" data-dashboard-index="2"> | ||
| <span class="sr">Course options dropdown</span> | ||
| <button type='button'class="action action-more" id="actions-dropdown-link-1" aria-haspopup="true" aria-expanded="false" data-course-number="CTB3365DWx" data-course-name="Introduction to Drinking Water Treatment" data-dashboard-index="1"> | ||
| <span class="sr"> | ||
| Course options for Introduction to Drinking Water Treatment | ||
|
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. excellent SR text. |
||
| </span> | ||
| <i class="fa fa-cog" aria-hidden="true"></i> | ||
| </button> | ||
| <div class="actions-dropdown" id="actions-dropdown-1" aria-label="Additional Actions Menu"> | ||
|
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. the aria-label here is forcing VO to treat this as a role=group. since the aria-label on the |
||
| <ul class="actions-dropdown-list" id="actions-dropdown-list-1" aria-label="Available Actions" role="menu"> | ||
| <li class="actions-item" id="actions-item-unenroll-1"> | ||
| <a href="#unenroll-modal" class="action action-unenroll" rel="leanModal" data-course-id="course-v1:DelftX+CTB3365DWx+1T2016" data-course-number="CTB3365DWx" data-course-name="Introduction to Drinking Water Treatment" data-dashboard-index="1" data-track-info="Are you sure you want to unenroll from %(course_name)s (%(course_number)s)?" id="unenroll-1">Unenroll</a> | ||
| </li> | ||
| <li class="actions-item" id="actions-item-email-settings-1"> | ||
| <a href="#email-settings-modal" class="action action-email-settings" rel="leanModal" data-course-id="course-v1:DelftX+CTB3365DWx+1T2016" data-course-number="CTB3365DWx" data-dashboard-index="1" data-optout="False" id="email-settings-1">Email Settings</a> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| <footer class="wrapper-messages-primary"> | ||
| <ul class="messages-list"> | ||
| <div class="message message-upsell has-actions is-shown"> | ||
| <div class="wrapper-extended"> | ||
| <p class="message-copy" align="justify"> | ||
| <b class="message-copy-bold">Pursue a Certificate of Achievement to highlight the knowledge and skills you gain in this course.</b> | ||
| <br> | ||
| It's official. It's easily shareable. It's a proven motivator to complete the course. | ||
| <br> | ||
| <a href="https://www.edx.org/verified-certificate" class="verified-info" data-course-key="course-v1:DelftX+CTB3365DWx+1T2016">Learn more about the verified Certificate of Achievement</a>. | ||
| </p> | ||
| <div class="action-upgrade-container"> | ||
| <a class="action action-upgrade" href="/verify_student/upgrade/course-v1:DelftX+CTB3365DWx+1T2016/" data-course-id="course-v1:DelftX+CTB3365DWx+1T2016" data-user="Anon"> | ||
| <i class="action-upgrade-icon"></i> | ||
| <span class="wrapper-copy"> | ||
| <span class="copy" id="upgrade-to-verified">Upgrade to Verified</span> | ||
| </span> | ||
| </a> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="message message-status is-shown credit-message"> | ||
| <div class="xseries-action"> | ||
| <div class="message-copy xseries-msg"> | ||
| <p><b class="message-copy-bold">XSeries Program: Interested in more courses in this subject?</b></p> | ||
| <p></p> | ||
| <p class="message-copy"> | ||
| This course is 1 of 3 courses in the <a href="https://www.edx.org/xseries/water-management">Water Management</a> XSeries. | ||
| </p> | ||
| </div> | ||
|
|
||
| <a class="btn xseries-border-btn" href="https://www.edx.org/xseries/water-management" target="_blank" | ||
| data-program-id="xseries007"> | ||
| <i class="action-xseries-icon"></i> | ||
| <span>View XSeries Details</span> | ||
| </a> | ||
| </div> | ||
| </div> | ||
| </ul> | ||
| </footer> | ||
| </article> | ||
| </div> | ||
| <div class="course-container"> | ||
| <div class="label-xseries-association"> | ||
| <i class="xseries-icon"></i> | ||
| <p class="message-copy">XSeries Program Course</p> | ||
| </div> | ||
| <article class="course honor"> | ||
| <section class="details"> | ||
| <div class="wrapper-course-image" aria-hidden="true"> | ||
| <a class="cover"> | ||
| <img src="/asset-v1:DelftX+CTB3365DWx+1T2016+type@asset+block@Delftx_water_course_image2.jpg" class="course-image" alt="CTB3365DWx Introduction to Drinking Water Treatment Cover Image"> | ||
| </a> | ||
| <span class="sts-enrollment" title="You're enrolled as an honor code student"> | ||
| <span class="label">Enrolled as: </span> | ||
| <div class="sts-enrollment-value">Honor Code</div> | ||
| </span> | ||
| </div> | ||
|
|
||
| <div class="wrapper-course-details"> | ||
| <h3 class="course-title"><span>Introduction to Drinking Water Treatment</span></h3> | ||
| <div class="course-info"> | ||
| <span class="info-university">DelftX - </span> | ||
| <span class="info-course-id">CTB3365DWx</span> | ||
| <span class="info-date-block" data-tooltip="Hi">Starts - Tuesday at 12pm UTC</span> | ||
| </div> | ||
| <div class="wrapper-course-actions"> | ||
| <div class="course-actions"> | ||
| <div class="wrapper-action-more" data-course-key="course-v1:DelftX+CTB3365DWx+1T2016"> | ||
| <button type='button'class="action action-more" id="actions-dropdown-link-2" aria-haspopup="true" aria-expanded="false" data-course-number="CTB3365DWx" data-course-name="Introduction to Drinking Water Treatment" data-dashboard-index="2"> | ||
| <span class="sr"> | ||
| Course options for Introduction to Drinking Water Treatment | ||
| </span> | ||
| <i class="fa fa-cog" aria-hidden="true"></i> | ||
| </button> | ||
| <div class="actions-dropdown" id="actions-dropdown-2" aria-label="Additional Actions Menu"> | ||
| <ul class="actions-dropdown-list" id="actions-dropdown-list-2" aria-label="Available Actions" role="menu"> | ||
| <li class="actions-item" id="actions-item-unenroll-2"> | ||
|
|
@@ -87,7 +184,7 @@ <h3 class="course-title"><span>Introduction to Drinking Water Treatment</span></ | |
| </a> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="message message-status is-shown credit-message"> | ||
| <div class="xseries-action"> | ||
| <div class="message-copy xseries-msg"> | ||
|
|
@@ -96,7 +193,7 @@ <h3 class="course-title"><span>Introduction to Drinking Water Treatment</span></ | |
| This course is 1 of 3 courses in the <a href="https://www.edx.org/xseries/water-management">Water Management</a> XSeries. | ||
| </p> | ||
| </div> | ||
|
|
||
| <a class="btn xseries-border-btn" href="https://www.edx.org/xseries/water-management" target="_blank" | ||
| data-program-id="xseries007"> | ||
| <i class="action-xseries-icon"></i> | ||
|
|
||
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.
we should add
aria-controlsattribute here that references the actions-dropdown-# div?