|
37 | 37 | 'previousLanguageMenuItem', 'nextLanguageMenuItem', 'handleCaptionToggle', |
38 | 38 | 'showClosedCaptions', 'hideClosedCaptions', 'toggleClosedCaptions', |
39 | 39 | 'updateCaptioningCookie', 'handleCaptioningCookie', 'handleTranscriptToggle', |
40 | | - 'listenForDragDrop', 'setTranscriptVisibility', 'updateTranscriptCookie' |
| 40 | + 'listenForDragDrop', 'setTranscriptVisibility', 'updateTranscriptCookie', |
| 41 | + 'toggleGoogleDisclaimer' |
41 | 42 | ); |
42 | 43 |
|
43 | 44 | this.state = state; |
|
492 | 493 | }; |
493 | 494 | }, |
494 | 495 |
|
| 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 | + |
495 | 521 | /** |
496 | 522 | * @desc Fetch the caption file specified by the user. Upon successful |
497 | 523 | * receipt of the file, the captions will be rendered. |
|
547 | 573 | start = results.start; |
548 | 574 | captions = results.captions; |
549 | 575 |
|
| 576 | + self.toggleGoogleDisclaimer(captions); |
| 577 | + |
550 | 578 | if (self.loaded) { |
551 | 579 | if (self.rendered) { |
552 | 580 | self.renderCaption(start, captions); |
|
1299 | 1327 | */ |
1300 | 1328 | hideCaptions: function(hideCaptions, triggerEvent) { |
1301 | 1329 | var transcriptControlEl = this.transcriptControlEl, |
| 1330 | + self = this, |
1302 | 1331 | state = this.state, |
1303 | 1332 | text; |
1304 | 1333 |
|
|
1310 | 1339 | this.state.el.trigger('transcript:hide'); |
1311 | 1340 | } |
1312 | 1341 |
|
| 1342 | + state.el.find('.google-disclaimer').hide(); |
| 1343 | + |
1313 | 1344 | transcriptControlEl |
1314 | 1345 | .removeClass('is-active') |
1315 | 1346 | .attr('title', gettext(text)) |
|
1323 | 1354 | this.state.el.trigger('transcript:show'); |
1324 | 1355 | } |
1325 | 1356 |
|
| 1357 | + if (self.shouldShowGoogleDisclaimer) { |
| 1358 | + state.el.find('.google-disclaimer').show(); |
| 1359 | + } |
| 1360 | + |
1326 | 1361 | transcriptControlEl |
1327 | 1362 | .addClass('is-active') |
1328 | 1363 | .attr('title', gettext(text)) |
|
0 commit comments