From 1cafbf09f44280af6d4b0c7c509ce9fd4e827380 Mon Sep 17 00:00:00 2001 From: thomasmars Date: Tue, 4 Oct 2016 11:43:12 +0200 Subject: [PATCH] Added aria-disabled attribute to dots when they are disabled HFP-8 --- js/questionset.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/js/questionset.js b/js/questionset.js index 3602de9..10cc730 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -45,8 +45,9 @@ H5P.QuestionSet = function (options, contentId, contentData) { '
  • " tabindex="-1">
  • ' + + ' + ", " + texts.unansweredText %>" tabindex="-1" ' + + ' <% if (disableBackwardsNavigation) { %> aria-disabled="true" <% } %>' + + ' >' + ' <% } %>' + ' ' + ' <% } else if (progressType == "textual") { %>' + @@ -296,6 +297,7 @@ H5P.QuestionSet = function (options, contentId, contentData) { for (var i = 0; i < questionInstances.length; i++) { // Enable back and forth navigation in solution mode + toggleDotsNavigation(true); if (i < questionInstances.length - 1) { 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. * Used for contracts with integrated content. @@ -329,6 +341,8 @@ H5P.QuestionSet = function (options, contentId, contentData) { // Hide back and forth navigation in normal mode if (params.disableBackwardsNavigation) { + toggleDotsNavigation(false); + // Check if first question is answered by default if (i === 0 && questionInstances[i].getAnswerGiven()) { questionInstances[i].showButton('next');