Skip to content

Commit e276b65

Browse files
committed
HFP-3780 Cleanup code #2
1 parent d95b40d commit e276b65

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

js/flashcards.js

+14-20
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ H5P.Flashcards = (function ($, XapiGenerator) {
3636
results: "Results",
3737
ofCorrect: "@score of @total correct",
3838
showResults: "Show results",
39-
retry : "Retry",
39+
retry: "Retry",
4040
cardAnnouncement: 'Incorrect answer. Correct answer was @answer',
4141
pageAnnouncement: 'Page @current of @total',
4242
correctAnswerAnnouncement: '@answer is correct!'
@@ -208,7 +208,6 @@ H5P.Flashcards = (function ($, XapiGenerator) {
208208
var $inner = this.$container.html(
209209
'<div class="h5p-description" id="flashcards-description' + '-' + descId + '" title="' + this.options.description + '">' + this.options.description + '</div>' +
210210
'<div class="h5p-progress"></div>' +
211-
// '<div class="h5p-inner" role="region" aria-labelledby="flashcards-description' + '-' + descId + '" aria-roledescription="carousel"></div>' +
212211
'<div class="h5p-inner" role="region" ' + '-' + descId + '></div>' +
213212
'<div class="h5p-navigation">' +
214213
'<button type="button" class="h5p-button h5p-previous h5p-hidden" tabindex="0" title="' + this.options.previous + '" aria-label="' + this.options.previous + '"></button>' +
@@ -329,7 +328,6 @@ H5P.Flashcards = (function ($, XapiGenerator) {
329328

330329
// Generate a new flashcards html and add it to h5p-inner
331330
var $card = $(
332-
// '<div role="group" aria-roledescription="slide" aria-labelledby="h5p-flashcard-card-' + cardId + '" class="h5p-card h5p-animate' + (index === 0 ? ' h5p-current' : '') + '"> ' +
333331
'<div role="group" id="cardgroup"' + '" class="h5p-card h5p-animate' + (index === 0 ? ' h5p-current' : '') + '"> ' +
334332
'<div class="h5p-cardholder">' +
335333
'<div class="h5p-imageholder">' +
@@ -569,10 +567,7 @@ H5P.Flashcards = (function ($, XapiGenerator) {
569567
* @param {H5P.jQuery} $card
570568
* Class to add to existing current card.
571569
*/
572-
C.prototype.setCurrent = function ($card) {
573-
574-
this.$prev = this.$current;
575-
570+
C.prototype.setCurrent = function ($card) {
576571
// Remove from existing card.
577572
if (this.$current) {
578573
this.$current.find('.h5p-textinput').attr('tabindex', '-1');
@@ -581,23 +576,22 @@ H5P.Flashcards = (function ($, XapiGenerator) {
581576
this.$current.find('.h5p-icon-button').attr('tabindex', '-1');
582577
}
583578

584-
// Set new card
579+
// Set new card
585580
this.$current = $card;
586581

587582
/* We can't set focus on anything until the transition is finished.
588583
If we do, iPad will try to center the focused element while the transition
589584
is running, and the card will be misplaced */
590585

591-
// Handle focus shift and screen reader announcement
592-
$card.one('transitionend', function () {
593-
if ($card.hasClass('h5p-current') && !$card.find('.h5p-textinput')[0].disabled) {
594-
$card.find('.h5p-textinput').focus();
595-
}
596-
setTimeout(function () {
597-
this.announceCurrentPage();
598-
}.bind(this), 50); // Adjust the delay as necessary
599-
600-
}.bind(this));
586+
// Handle focus shift and screen reader announcement
587+
$card.one('transitionend', function () {
588+
if ($card.hasClass('h5p-current') && !$card.find('.h5p-textinput')[0].disabled) {
589+
$card.find('.h5p-textinput').focus();
590+
}
591+
setTimeout(function () {
592+
this.announceCurrentPage();
593+
}.bind(this), 50); // Adjust the delay as necessary
594+
}.bind(this));
601595

602596
// Update card classes
603597
$card.removeClass('h5p-previous h5p-next');
@@ -620,7 +614,7 @@ H5P.Flashcards = (function ($, XapiGenerator) {
620614
$card.find('.h5p-check-button').attr('tabindex', '0');
621615
$card.find('.h5p-icon-button').attr('tabindex', '0');
622616
$card.find('.joubel-tip-container').attr('tabindex', '0');
623-
};
617+
};
624618

625619
/**
626620
* Announces current page to assistive technologies
@@ -629,7 +623,7 @@ H5P.Flashcards = (function ($, XapiGenerator) {
629623
const pageText = this.options.pageAnnouncement
630624
.replace('@current', this.$current.index() + 1)
631625
.replace('@total', this.options.cards.length.toString());
632-
this.$pageAnnouncer.text(pageText);
626+
this.$pageAnnouncer.text(pageText);
633627
};
634628

635629
/**

0 commit comments

Comments
 (0)