From 11b8762f9c815930982599f4ff90c0db60eaf0ca Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 27 Aug 2018 15:59:00 +0200 Subject: Add start at checkbox in share modal --- .../+video-watch/modal/video-share.component.html | 17 ++++++++---- .../+video-watch/modal/video-share.component.scss | 6 +++++ .../+video-watch/modal/video-share.component.ts | 31 ++++++++++++++++++---- 3 files changed, 44 insertions(+), 10 deletions(-) (limited to 'client/src/app/videos/+video-watch/modal') diff --git a/client/src/app/videos/+video-watch/modal/video-share.component.html b/client/src/app/videos/+video-watch/modal/video-share.component.html index 02f5f0f44..a20c320a4 100644 --- a/client/src/app/videos/+video-watch/modal/video-share.component.html +++ b/client/src/app/videos/+video-watch/modal/video-share.component.html @@ -17,6 +17,11 @@ +
+ + +
+
@@ -32,15 +37,17 @@
The url is not secured (no HTTPS), so the embed video won't work on HTTPS websites (web browsers block non secured HTTP requests on HTTPS websites).
+
-
- - -
+
+
diff --git a/client/src/app/videos/+video-watch/modal/video-share.component.scss b/client/src/app/videos/+video-watch/modal/video-share.component.scss index a9e9b8498..4c07bce89 100644 --- a/client/src/app/videos/+video-watch/modal/video-share.component.scss +++ b/client/src/app/videos/+video-watch/modal/video-share.component.scss @@ -12,3 +12,9 @@ .qr-code-group { text-align: center; } + +.start-at { + display: flex; + justify-content: center; + margin-top: 10px; +} diff --git a/client/src/app/videos/+video-watch/modal/video-share.component.ts b/client/src/app/videos/+video-watch/modal/video-share.component.ts index 14f557f9a..71d6f5633 100644 --- a/client/src/app/videos/+video-watch/modal/video-share.component.ts +++ b/client/src/app/videos/+video-watch/modal/video-share.component.ts @@ -1,9 +1,10 @@ import { Component, ElementRef, Input, ViewChild } from '@angular/core' import { NotificationsService } from 'angular2-notifications' import { VideoDetails } from '../../../shared/video/video-details.model' -import { buildVideoEmbed } from '../../../../assets/player/utils' +import { buildVideoEmbed, buildVideoLink } from '../../../../assets/player/utils' import { I18n } from '@ngx-translate/i18n-polyfill' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' +import { durationToString } from '@app/shared/misc/utils' @Component({ selector: 'my-video-share', @@ -11,9 +12,14 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap' styleUrls: [ './video-share.component.scss' ] }) export class VideoShareComponent { + @ViewChild('modal') modal: ElementRef + @Input() video: VideoDetails = null - @ViewChild('modal') modal: ElementRef + startAtCheckbox = false + currentVideoTimestampString: string + + private currentVideoTimestamp: number constructor ( private modalService: NgbModal, @@ -23,16 +29,21 @@ export class VideoShareComponent { // empty } - show () { + show (currentVideoTimestamp?: number) { + this.currentVideoTimestamp = Math.floor(currentVideoTimestamp) + this.currentVideoTimestampString = durationToString(this.currentVideoTimestamp) + this.modalService.open(this.modal) } getVideoIframeCode () { - return buildVideoEmbed(this.video.embedUrl) + const embedUrl = buildVideoLink(this.getVideoTimestampIfEnabled(), this.video.embedUrl) + + return buildVideoEmbed(embedUrl) } getVideoUrl () { - return window.location.href + return buildVideoLink(this.getVideoTimestampIfEnabled()) } notSecure () { @@ -42,4 +53,14 @@ export class VideoShareComponent { activateCopiedMessage () { this.notificationsService.success(this.i18n('Success'), this.i18n('Copied')) } + + getStartCheckboxLabel () { + return this.i18n('Start at {{timestamp}}', { timestamp: this.currentVideoTimestampString }) + } + + private getVideoTimestampIfEnabled () { + if (this.startAtCheckbox === true) return this.currentVideoTimestamp + + return undefined + } } -- cgit v1.2.3