Prevent stealing focus when page loads

HFJ-2040
pull/5/head
Frode Petterson 2016-07-04 11:54:28 +02:00
parent 5391fec861
commit 71f92ff664
1 changed files with 17 additions and 15 deletions

View File

@ -204,7 +204,7 @@ H5P.QuestionSet = function (options, contentId) {
} }
}; };
var _showQuestion = function (questionNumber) { var _showQuestion = function (questionNumber, preventAnnouncement) {
// Sanitize input. // Sanitize input.
if (questionNumber < 0) { if (questionNumber < 0) {
questionNumber = 0; questionNumber = 0;
@ -242,21 +242,23 @@ H5P.QuestionSet = function (options, contentId) {
toggleCurrentDot(questionNumber, true); toggleCurrentDot(questionNumber, true);
} }
// Announce question number of total, must use timeout because of buttons logic if (!preventAnnouncement) {
setTimeout(function () { // Announce question number of total, must use timeout because of buttons logic
var humanizedProgress = params.texts.readSpeakerProgress setTimeout(function () {
.replace('@current', (currentQuestion + 1).toString()) var humanizedProgress = params.texts.readSpeakerProgress
.replace('@total', questionInstances.length.toString()); .replace('@current', (currentQuestion + 1).toString())
.replace('@total', questionInstances.length.toString());
$('.qs-progress-announcer', $myDom) $('.qs-progress-announcer', $myDom)
.show() .show()
.html(humanizedProgress) .html(humanizedProgress)
.focus(); .focus();
if (instance && instance.readFeedback) { if (instance && instance.readFeedback) {
instance.readFeedback(); instance.readFeedback();
} }
}, 0); }, 0);
}
// Remember where we are // Remember where we are
_updateButtons(); _updateButtons();
@ -661,7 +663,7 @@ H5P.QuestionSet = function (options, contentId) {
// Hide all but initial Question. // Hide all but initial Question.
_showQuestion(params.initialQuestion); _showQuestion(params.initialQuestion, true);
if (renderSolutions) { if (renderSolutions) {
showSolutions(); showSolutions();