X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fassets%2Fplayer%2Fvideojs-components%2Fpeertube-link-button.ts;h=98434898cfd9f082dd48690161662f71124b89b7;hb=171efc48e67498406feb6d7873b3482b41505515;hp=4151758d4e76820c1c5a6a430f6c2f46fad923ed;hpb=7e37e111116e41530749b88327bc601cb39ade03;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/assets/player/videojs-components/peertube-link-button.ts b/client/src/assets/player/videojs-components/peertube-link-button.ts index 4151758d4..98434898c 100644 --- a/client/src/assets/player/videojs-components/peertube-link-button.ts +++ b/client/src/assets/player/videojs-components/peertube-link-button.ts @@ -1,11 +1,15 @@ -import { buildVideoLink } from '../utils' -import videojs from 'video.js/dist/alt/video.core.js' +import videojs from 'video.js' +import { buildVideoLink, decorateVideoLink } from '@shared/core-utils' +import { PeerTubeLinkButtonOptions } from '../peertube-videojs-typings' const Button = videojs.getComponent('Button') class PeerTubeLinkButton extends Button { + private shortUUID: string - constructor (player: videojs.Player, options?: videojs.ComponentOptions) { - super(player, options) + constructor (player: videojs.Player, options?: PeerTubeLinkButtonOptions) { + super(player, options as any) + + this.shortUUID = options.shortUUID } createEl () { @@ -13,7 +17,7 @@ class PeerTubeLinkButton extends Button { } updateHref () { - this.el().setAttribute('href', buildVideoLink({ startTime: this.player().currentTime() })) + this.el().setAttribute('href', this.buildLink()) } handleClick () { @@ -22,9 +26,9 @@ class PeerTubeLinkButton extends Button { private buildElement () { const el = videojs.dom.createEl('a', { - href: buildVideoLink(), + href: this.buildLink(), innerHTML: 'PeerTube', - title: this.player().localize('Go to the video page'), + title: this.player().localize('Video page (new window)'), className: 'vjs-peertube-link', target: '_blank' }) @@ -33,6 +37,12 @@ class PeerTubeLinkButton extends Button { return el as HTMLButtonElement } + + private buildLink () { + const url = buildVideoLink({ shortUUID: this.shortUUID }) + + return decorateVideoLink({ url, startTime: this.player().currentTime() }) + } } videojs.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)