Skip to content

Commit 032bf04

Browse files
authored
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
1 parent 98dfb12 commit 032bf04

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

lms/templates/video.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ <h4 class="hd hd-5">${_('How is the transcript quality ?')}</h4>
170170
</div>
171171
</div>
172172
% endif
173+
<div class="google-disclaimer">
174+
<span className="text-dark-300 x-small">Powered by
175+
<a href="https://translate.google.com/" target="_blank">
176+
<img
177+
width="100"
178+
id="google-translate-logo"
179+
src="https://learning.edx.org/d4ab1b25143ecad62d69d855b00e7313.png"
180+
alt="Translated by Google logo"
181+
>
182+
</a>
183+
</span>
184+
</div>
173185
</div>
174186
</div>
175187

xmodule/assets/video/_display.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ $cool-dark: rgb(79, 89, 93); // UXPL cool dark
9191

9292
.wrapper-video-bottom-section {
9393
display: flex;
94+
justify-content: space-between;
9495

9596
.wrapper-download-video,
9697
.wrapper-download-transcripts,
@@ -177,6 +178,13 @@ $cool-dark: rgb(79, 89, 93); // UXPL cool dark
177178
}
178179
}
179180

181+
.google-disclaimer {
182+
display: none;
183+
margin-top: $baseline;
184+
@include padding-right($baseline);
185+
vertical-align: top;
186+
}
187+
180188
.video-wrapper {
181189
@include float(left);
182190
@include margin-right(flex-gutter(9));

xmodule/js/src/video/09_video_caption.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
'previousLanguageMenuItem', 'nextLanguageMenuItem', 'handleCaptionToggle',
3838
'showClosedCaptions', 'hideClosedCaptions', 'toggleClosedCaptions',
3939
'updateCaptioningCookie', 'handleCaptioningCookie', 'handleTranscriptToggle',
40-
'listenForDragDrop', 'setTranscriptVisibility', 'updateTranscriptCookie'
40+
'listenForDragDrop', 'setTranscriptVisibility', 'updateTranscriptCookie',
41+
'toggleGoogleDisclaimer'
4142
);
4243

4344
this.state = state;
@@ -492,6 +493,31 @@
492493
};
493494
},
494495

496+
/**
497+
* @desc Shows/Hides Google disclaimer based on captions being AI generated and
498+
* if ClosedCaptions are being shown.
499+
*
500+
* @param {array} captions List of captions for the video.
501+
*
502+
* @returns {boolean}
503+
*/
504+
toggleGoogleDisclaimer: function(captions) {
505+
var self = this,
506+
state = this.state,
507+
aIGeneratedSpan = '<span id="captions-ai-generated"></span>',
508+
captionsAIGenerated = captions.some(caption => caption.includes(aIGeneratedSpan));
509+
510+
if (!self.hideCaptionsOnLoad && !state.captionsHidden) {
511+
if (captionsAIGenerated) {
512+
state.el.find('.google-disclaimer').show();
513+
self.shouldShowGoogleDisclaimer = true;
514+
} else {
515+
state.el.find('.google-disclaimer').hide();
516+
self.shouldShowGoogleDisclaimer = false;
517+
}
518+
}
519+
},
520+
495521
/**
496522
* @desc Fetch the caption file specified by the user. Upon successful
497523
* receipt of the file, the captions will be rendered.
@@ -547,6 +573,8 @@
547573
start = results.start;
548574
captions = results.captions;
549575

576+
self.toggleGoogleDisclaimer(captions);
577+
550578
if (self.loaded) {
551579
if (self.rendered) {
552580
self.renderCaption(start, captions);
@@ -1299,6 +1327,7 @@
12991327
*/
13001328
hideCaptions: function(hideCaptions, triggerEvent) {
13011329
var transcriptControlEl = this.transcriptControlEl,
1330+
self = this,
13021331
state = this.state,
13031332
text;
13041333

@@ -1310,6 +1339,8 @@
13101339
this.state.el.trigger('transcript:hide');
13111340
}
13121341

1342+
state.el.find('.google-disclaimer').hide();
1343+
13131344
transcriptControlEl
13141345
.removeClass('is-active')
13151346
.attr('title', gettext(text))
@@ -1323,6 +1354,10 @@
13231354
this.state.el.trigger('transcript:show');
13241355
}
13251356

1357+
if (self.shouldShowGoogleDisclaimer) {
1358+
state.el.find('.google-disclaimer').show();
1359+
}
1360+
13261361
transcriptControlEl
13271362
.addClass('is-active')
13281363
.attr('title', gettext(text))

0 commit comments

Comments
 (0)