From 8041b88bdbed5910911d19c5de31be219ecacf2f Mon Sep 17 00:00:00 2001 From: Skills Up Date: Thu, 15 Aug 2024 12:18:23 +0530 Subject: [PATCH 1/4] Add subContentId as attribute to interaction div Allows uniquely accessing the interaction via JS and CSS --- src/scripts/interaction.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scripts/interaction.js b/src/scripts/interaction.js index 83e15b95..43dafe91 100644 --- a/src/scripts/interaction.js +++ b/src/scripts/interaction.js @@ -816,6 +816,7 @@ function Interaction(parameters, player, previousState) { $interaction = $('
', { 'aria-label': player.l10n.interaction, 'tabindex': '-1', + 'sub-content-id': getSubcontentId(), 'class': 'h5p-interaction h5p-poster ' + classes + (isGotoClickable && parameters.goto.visualize ? ' goto-clickable-visualize' : ''), css: { left: parameters.x + '%', From 65d8e55548ded3e538ea5a54f3e22b6662dbcbfd Mon Sep 17 00:00:00 2001 From: Skills Up Date: Thu, 15 Aug 2024 12:32:39 +0530 Subject: [PATCH 2/4] Correct reference scope in previous code change --- src/scripts/interaction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/interaction.js b/src/scripts/interaction.js index 43dafe91..839a4f3c 100644 --- a/src/scripts/interaction.js +++ b/src/scripts/interaction.js @@ -816,7 +816,7 @@ function Interaction(parameters, player, previousState) { $interaction = $('
', { 'aria-label': player.l10n.interaction, 'tabindex': '-1', - 'sub-content-id': getSubcontentId(), + 'sub-content-id': self.getSubcontentId(), 'class': 'h5p-interaction h5p-poster ' + classes + (isGotoClickable && parameters.goto.visualize ? ' goto-clickable-visualize' : ''), css: { left: parameters.x + '%', From 8002c82db86ceccba33cf1a6408d30b59310e8db Mon Sep 17 00:00:00 2001 From: Skills Up Date: Thu, 15 Aug 2024 13:28:53 +0530 Subject: [PATCH 3/4] Add subContentId to dialog as well --- src/scripts/interaction.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scripts/interaction.js b/src/scripts/interaction.js index 839a4f3c..5cf950ca 100644 --- a/src/scripts/interaction.js +++ b/src/scripts/interaction.js @@ -463,6 +463,7 @@ function Interaction(parameters, player, previousState) { var openDialog = function (checkScore) { const $dialogWrapper = player.$container.find('.h5p-dialog-wrapper'); const $titleBar = $dialogWrapper.find('.h5p-dialog-titlebar'); + $dialogWrapper.find('.h5p-dialog').attr('sub-content-id', self.getSubcontentId()); if (typeof instance.setActivityStarted === 'function' && typeof instance.getScore === 'function') { instance.setActivityStarted(); From eb118046405b4fcbdbf9a8530445bb8efadaa02a Mon Sep 17 00:00:00 2001 From: Skills Up Date: Thu, 15 Aug 2024 19:41:54 +0530 Subject: [PATCH 4/4] Add `data-` prefix to custom attribute --- src/scripts/interaction.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripts/interaction.js b/src/scripts/interaction.js index 5cf950ca..90ef0872 100644 --- a/src/scripts/interaction.js +++ b/src/scripts/interaction.js @@ -463,7 +463,7 @@ function Interaction(parameters, player, previousState) { var openDialog = function (checkScore) { const $dialogWrapper = player.$container.find('.h5p-dialog-wrapper'); const $titleBar = $dialogWrapper.find('.h5p-dialog-titlebar'); - $dialogWrapper.find('.h5p-dialog').attr('sub-content-id', self.getSubcontentId()); + $dialogWrapper.find('.h5p-dialog').attr('data-sub-content-id', self.getSubcontentId()); if (typeof instance.setActivityStarted === 'function' && typeof instance.getScore === 'function') { instance.setActivityStarted(); @@ -817,7 +817,7 @@ function Interaction(parameters, player, previousState) { $interaction = $('
', { 'aria-label': player.l10n.interaction, 'tabindex': '-1', - 'sub-content-id': self.getSubcontentId(), + 'data-sub-content-id': self.getSubcontentId(), 'class': 'h5p-interaction h5p-poster ' + classes + (isGotoClickable && parameters.goto.visualize ? ' goto-clickable-visualize' : ''), css: { left: parameters.x + '%',