Added aria-disabled attribute to dots when they are disabled

HFP-8
pull/7/head
thomasmars 2016-10-04 11:43:12 +02:00
parent 84c8751238
commit 1cafbf09f4
1 changed files with 16 additions and 2 deletions

View File

@ -45,8 +45,9 @@ H5P.QuestionSet = function (options, contentId, contentData) {
' <li class="progress-item"><a href="#" class="progress-dot unanswered" ' + ' <li class="progress-item"><a href="#" class="progress-dot unanswered" ' +
' aria-label="<%=' + ' aria-label="<%=' +
' texts.jumpToQuestion.replace("%d", i + 1).replace("%total", questions.length)' + ' texts.jumpToQuestion.replace("%d", i + 1).replace("%total", questions.length)' +
' + ", " + texts.unansweredText' + ' + ", " + texts.unansweredText %>" tabindex="-1" ' +
' %>" tabindex="-1"></a></li>' + ' <% if (disableBackwardsNavigation) { %> aria-disabled="true" <% } %>' +
' ></a></li>' +
' <% } %>' + ' <% } %>' +
' </div>' + ' </div>' +
' <% } else if (progressType == "textual") { %>' + ' <% } else if (progressType == "textual") { %>' +
@ -296,6 +297,7 @@ H5P.QuestionSet = function (options, contentId, contentData) {
for (var i = 0; i < questionInstances.length; i++) { for (var i = 0; i < questionInstances.length; i++) {
// Enable back and forth navigation in solution mode // Enable back and forth navigation in solution mode
toggleDotsNavigation(true);
if (i < questionInstances.length - 1) { if (i < questionInstances.length - 1) {
questionInstances[i].showButton('next'); questionInstances[i].showButton('next');
} }
@ -316,6 +318,16 @@ H5P.QuestionSet = function (options, contentId, contentData) {
} }
}; };
/**
* Toggles whether dots are enabled for navigation
*/
var toggleDotsNavigation = function (enable) {
console.log("toggle dots", enable);
$('.progress-dot', $myDom).each(function () {
$(this).attr('aria-disabled', enable ? 'false' : 'true');
});
};
/** /**
* Resets the task and every subcontent task. * Resets the task and every subcontent task.
* Used for contracts with integrated content. * Used for contracts with integrated content.
@ -329,6 +341,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
// Hide back and forth navigation in normal mode // Hide back and forth navigation in normal mode
if (params.disableBackwardsNavigation) { if (params.disableBackwardsNavigation) {
toggleDotsNavigation(false);
// Check if first question is answered by default // Check if first question is answered by default
if (i === 0 && questionInstances[i].getAnswerGiven()) { if (i === 0 && questionInstances[i].getAnswerGiven()) {
questionInstances[i].showButton('next'); questionInstances[i].showButton('next');