X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-share-modal%2Fvideo-share.component.ts;h=d59f338c7a2c5c4c368fa4e52c30f31681d1819e;hb=f1c861727c1d2f9eacf98821c81f0f8cdcb57317;hp=e6e4bd147eec1acd15ac4520a95542341ee3aec2;hpb=382258676c3ab83f9cebfc4e378ab955cd8fd9ff;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-share-modal/video-share.component.ts b/client/src/app/shared/shared-share-modal/video-share.component.ts index e6e4bd147..d59f338c7 100644 --- a/client/src/app/shared/shared-share-modal/video-share.component.ts +++ b/client/src/app/shared/shared-share-modal/video-share.component.ts @@ -1,4 +1,5 @@ import { Component, ElementRef, Input, ViewChild } from '@angular/core' +import { DomSanitizer, SafeHtml } from '@angular/platform-browser' import { VideoDetails } from '@app/shared/shared-main' import { VideoPlaylist } from '@app/shared/shared-video-playlist' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' @@ -48,7 +49,13 @@ export class VideoShareComponent { isAdvancedCustomizationCollapsed = true includeVideoInPlaylist = false - constructor (private modalService: NgbModal) { } + playlistEmbedHTML: SafeHtml + videoEmbedHTML: SafeHtml + + constructor ( + private modalService: NgbModal, + private sanitizer: DomSanitizer + ) { } show (currentVideoTimestamp?: number, currentPlaylistPosition?: number) { let subtitle: string @@ -56,7 +63,7 @@ export class VideoShareComponent { subtitle = this.videoCaptions[0].language.id } - this.customizations = { + this.customizations = new Proxy({ startAtCheckbox: false, startAt: currentVideoTimestamp ? Math.floor(currentVideoTimestamp) : 0, @@ -76,10 +83,20 @@ export class VideoShareComponent { warningTitle: true, controls: true, peertubeLink: true - } + }, { + set: (target, prop, value) => { + target[prop] = value + + this.updateEmbedCode() + + return true + } + }) this.playlistPosition = currentPlaylistPosition + this.updateEmbedCode() + this.modalService.open(this.modal, { centered: true }) } @@ -114,6 +131,12 @@ export class VideoShareComponent { return decoratePlaylistLink({ url, playlistPosition: this.playlistPosition }) } + updateEmbedCode () { + if (this.playlist) this.playlistEmbedHTML = this.sanitizer.bypassSecurityTrustHtml(this.getPlaylistIframeCode()) + + if (this.video) this.videoEmbedHTML = this.sanitizer.bypassSecurityTrustHtml(this.getVideoIframeCode()) + } + notSecure () { return window.location.protocol === 'http:' }