From 032bf044c6d2cae0988acf465a59a9be9608fee3 Mon Sep 17 00:00:00 2001 From: Rodrigo Martin Date: Fri, 28 Jun 2024 13:15:31 -0300 Subject: [PATCH] feat(AU-2042): Show Google disclaimer on VideoBlock bottom section (#35040) * feat(AU-2042): Show Google disclaimer on VideoBlock bottom section * feat(AU-2042): Remove unnecessary classname prop --- lms/templates/video.html | 12 ++++++++ xmodule/assets/video/_display.scss | 8 +++++ xmodule/js/src/video/09_video_caption.js | 37 +++++++++++++++++++++++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/lms/templates/video.html b/lms/templates/video.html index 6401f17238a6..1d1a374f6379 100644 --- a/lms/templates/video.html +++ b/lms/templates/video.html @@ -170,6 +170,18 @@

${_('How is the transcript quality ?')}

% endif +
+ Powered by + + + + +
diff --git a/xmodule/assets/video/_display.scss b/xmodule/assets/video/_display.scss index 1a28e9150df7..fd5cd73b2105 100644 --- a/xmodule/assets/video/_display.scss +++ b/xmodule/assets/video/_display.scss @@ -91,6 +91,7 @@ $cool-dark: rgb(79, 89, 93); // UXPL cool dark .wrapper-video-bottom-section { display: flex; + justify-content: space-between; .wrapper-download-video, .wrapper-download-transcripts, @@ -177,6 +178,13 @@ $cool-dark: rgb(79, 89, 93); // UXPL cool dark } } + .google-disclaimer { + display: none; + margin-top: $baseline; + @include padding-right($baseline); + vertical-align: top; + } + .video-wrapper { @include float(left); @include margin-right(flex-gutter(9)); diff --git a/xmodule/js/src/video/09_video_caption.js b/xmodule/js/src/video/09_video_caption.js index 5584a9503beb..37e3923067d5 100644 --- a/xmodule/js/src/video/09_video_caption.js +++ b/xmodule/js/src/video/09_video_caption.js @@ -37,7 +37,8 @@ 'previousLanguageMenuItem', 'nextLanguageMenuItem', 'handleCaptionToggle', 'showClosedCaptions', 'hideClosedCaptions', 'toggleClosedCaptions', 'updateCaptioningCookie', 'handleCaptioningCookie', 'handleTranscriptToggle', - 'listenForDragDrop', 'setTranscriptVisibility', 'updateTranscriptCookie' + 'listenForDragDrop', 'setTranscriptVisibility', 'updateTranscriptCookie', + 'toggleGoogleDisclaimer' ); this.state = state; @@ -492,6 +493,31 @@ }; }, + /** + * @desc Shows/Hides Google disclaimer based on captions being AI generated and + * if ClosedCaptions are being shown. + * + * @param {array} captions List of captions for the video. + * + * @returns {boolean} + */ + toggleGoogleDisclaimer: function(captions) { + var self = this, + state = this.state, + aIGeneratedSpan = '', + captionsAIGenerated = captions.some(caption => caption.includes(aIGeneratedSpan)); + + if (!self.hideCaptionsOnLoad && !state.captionsHidden) { + if (captionsAIGenerated) { + state.el.find('.google-disclaimer').show(); + self.shouldShowGoogleDisclaimer = true; + } else { + state.el.find('.google-disclaimer').hide(); + self.shouldShowGoogleDisclaimer = false; + } + } + }, + /** * @desc Fetch the caption file specified by the user. Upon successful * receipt of the file, the captions will be rendered. @@ -547,6 +573,8 @@ start = results.start; captions = results.captions; + self.toggleGoogleDisclaimer(captions); + if (self.loaded) { if (self.rendered) { self.renderCaption(start, captions); @@ -1299,6 +1327,7 @@ */ hideCaptions: function(hideCaptions, triggerEvent) { var transcriptControlEl = this.transcriptControlEl, + self = this, state = this.state, text; @@ -1310,6 +1339,8 @@ this.state.el.trigger('transcript:hide'); } + state.el.find('.google-disclaimer').hide(); + transcriptControlEl .removeClass('is-active') .attr('title', gettext(text)) @@ -1323,6 +1354,10 @@ this.state.el.trigger('transcript:show'); } + if (self.shouldShowGoogleDisclaimer) { + state.el.find('.google-disclaimer').show(); + } + transcriptControlEl .addClass('is-active') .attr('title', gettext(text))