Skip to content
Merged
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
2 changes: 1 addition & 1 deletion common/test/acceptance/tests/lms/test_account_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def test_account_settings_a11y(self):
self.visit_account_settings_page()
self.account_settings_page.a11y_audit.config.set_rules({
'ignore': [
'link-href', # TODO: AC-233, AC-238
'link-href', # TODO: AC-233
],
})
self.account_settings_page.a11y_audit.check_for_accessibility_errors()
7 changes: 0 additions & 7 deletions common/test/acceptance/tests/lms/test_lms_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,4 @@ def test_dashboard_course_listings_a11y(self):
"""
course_listings = self.dashboard_page.get_course_listings()
self.assertEqual(len(course_listings), 1)

self.dashboard_page.a11y_audit.config.set_rules({
"ignore": [
'link-href', # TODO: AC-238
],
})

self.dashboard_page.a11y_audit.check_for_accessibility_errors()
90 changes: 90 additions & 0 deletions lms/static/js/dashboard/dropdown.js
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);
34 changes: 2 additions & 32 deletions lms/static/js/dashboard/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
notifications.focus();
}

$('.action-more').bind('click', toggleCourseActionsDropdown);

// Track clicks of the upgrade button. The `trackLink` method is a helper that makes
// a `track` call whenever a bound link is clicked. Usually the page would change before
// `track` had time to execute; `trackLink` inserts a small timeout to give the `track`
Expand Down Expand Up @@ -79,33 +77,6 @@
return properties;
}

function toggleCourseActionsDropdownInternal(element) {
var dashboard_index = element.data('dashboard-index');

// Toggle the visibility control for the selected element and set the focus
var dropdown_selector = 'div#actions-dropdown-' + dashboard_index;
var dropdown = $(dropdown_selector);
dropdown.toggleClass('is-visible');
if (dropdown.hasClass('is-visible')) {
dropdown.attr('tabindex', -1);
} else {
dropdown.removeAttr('tabindex');
}

// Inform the ARIA framework that the dropdown has been expanded
var anchor_selector = 'a#actions-dropdown-link-' + dashboard_index;
var anchor = $(anchor_selector);
var aria_expanded_state = (anchor.attr('aria-expanded') === 'true');
anchor.attr('aria-expanded', !aria_expanded_state);
}

function toggleCourseActionsDropdown(event) {
toggleCourseActionsDropdownInternal($(this));

// Suppress the actual click event from the browser
event.preventDefault();
}

$("#failed-verification-button-dismiss").click(function() {
$.ajax({
url: urls.verifyToggleBannerFailedOff,
Expand All @@ -128,7 +99,7 @@
if($(event.target).data("optout") === "False") {
$("#receive_emails").prop('checked', true);
}
toggleCourseActionsDropdownInternal(element);
edx.dashboard.dropdown.toggleCourseActionsDropdownMenu(event);
});

$(".action-unenroll").click(function(event) {
Expand All @@ -144,7 +115,7 @@
}, true));
$('#refund-info').html( element.data("refund-info") );
$("#unenroll_course_id").val( element.data("course-id") );
toggleCourseActionsDropdownInternal(element);
edx.dashboard.dropdown.toggleCourseActionsDropdownMenu(event);
});

$('#unenroll_form').on('ajax:complete', function(event, xhr) {
Expand Down Expand Up @@ -179,7 +150,6 @@
return false;
});


$(".action-email-settings").each(function(index){
$(this).attr("id", "email-settings-" + index);
// a bit of a hack, but gets the unique selector for the modal trigger
Expand Down
107 changes: 102 additions & 5 deletions lms/static/js/fixtures/dashboard/dashboard.html
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>
Expand All @@ -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">
Expand All @@ -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">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should add aria-controls attribute here that references the actions-dropdown-# div?

<span class="sr">
Course options for Introduction to Drinking Water Treatment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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> below is also doing this, it requires a VO user to do a CMD+OPTION+SHIFT+DownArrow twice to actually get to the menu. This is a odd implementation by VO, so its not really our fault here, but to minimize the difficulty, we should get rid of the aria-label here. JAWS and NVDA do not do this, and they only read the aria-label on the <ul> below, so lets keep that one.

<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">
Expand Down Expand Up @@ -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">
Expand All @@ -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>
Expand Down
Loading