X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fassets%2Fplayer%2Fvideojs-components%2Fpeertube-link-button.ts;h=c49cee5662ae2bb6562b8caa99268487ca8585cb;hb=23ca2f7bc942f06ed5653b41f119b84c54f1948d;hp=fed8ea33e4b0ea8748d189774b42f5104bf270b0;hpb=2adfc7ea9a1f858db874df9fe322e7ae833db77c;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 fed8ea33e..c49cee566 100644 --- a/client/src/assets/player/videojs-components/peertube-link-button.ts +++ b/client/src/assets/player/videojs-components/peertube-link-button.ts @@ -1,14 +1,12 @@ -import { VideoJSComponentInterface, videojsUntyped } from '../peertube-videojs-typings' -import { buildVideoLink } from '../utils' -// FIXME: something weird with our path definition in tsconfig and typings -// @ts-ignore -import { Player } from 'video.js' +import videojs from 'video.js' +import { buildVideoLink, decorateVideoLink } from '@shared/core-utils' +import { PeerTubeLinkButtonOptions } from '../peertube-videojs-typings' -const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button') +const Button = videojs.getComponent('Button') class PeerTubeLinkButton extends Button { - constructor (player: Player, options: any) { - super(player, options) + constructor (player: videojs.Player, options?: PeerTubeLinkButtonOptions) { + super(player, options as any) } createEl () { @@ -16,25 +14,32 @@ class PeerTubeLinkButton extends Button { } updateHref () { - this.el().setAttribute('href', buildVideoLink(this.player().currentTime())) + this.el().setAttribute('href', this.buildLink()) } handleClick () { - this.player_.pause() + this.player().pause() } private buildElement () { - const el = videojsUntyped.dom.createEl('a', { - href: buildVideoLink(), + const el = videojs.dom.createEl('a', { + 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' }) el.addEventListener('mouseenter', () => this.updateHref()) - return el + return el as HTMLButtonElement + } + + private buildLink () { + const url = buildVideoLink({ shortUUID: (this.options_ as PeerTubeLinkButtonOptions).shortUUID }) + + return decorateVideoLink({ url, startTime: this.player().currentTime() }) } } -Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton) + +videojs.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)