]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/assets/player/videojs-components/peertube-link-button.ts
Fix For GitPod
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / videojs-components / peertube-link-button.ts
CommitLineData
2adfc7ea
C
1import { VideoJSComponentInterface, videojsUntyped } from '../peertube-videojs-typings'
2import { buildVideoLink } from '../utils'
c199c427
C
3// FIXME: something weird with our path definition in tsconfig and typings
4// @ts-ignore
5import { Player } from 'video.js'
c6352f2c
C
6
7const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button')
8class PeerTubeLinkButton extends Button {
9
c199c427 10 constructor (player: Player, options: any) {
960a11e8
C
11 super(player, options)
12 }
13
c6352f2c 14 createEl () {
fc73684a
C
15 return this.buildElement()
16 }
17
18 updateHref () {
2f4c784a 19 this.el().setAttribute('href', buildVideoLink({ startTime: this.player().currentTime() }))
fc73684a
C
20 }
21
22 handleClick () {
23 this.player_.pause()
24 }
25
26 private buildElement () {
27 const el = videojsUntyped.dom.createEl('a', {
960a11e8 28 href: buildVideoLink(),
c6352f2c 29 innerHTML: 'PeerTube',
e945b184 30 title: this.player_.localize('Go to the video page'),
c6352f2c
C
31 className: 'vjs-peertube-link',
32 target: '_blank'
33 })
fc73684a
C
34
35 el.addEventListener('mouseenter', () => this.updateHref())
36
37 return el
c6352f2c 38 }
c6352f2c
C
39}
40Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)