]>
Commit | Line | Data |
---|---|---|
c6352f2c | 1 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' |
960a11e8 | 2 | import { buildVideoLink } from './utils' |
c199c427 C |
3 | // FIXME: something weird with our path definition in tsconfig and typings |
4 | // @ts-ignore | |
5 | import { Player } from 'video.js' | |
c6352f2c C |
6 | |
7 | const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button') | |
8 | class 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 () { | |
960a11e8 | 19 | this.el().setAttribute('href', buildVideoLink(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 | } |
40 | Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton) |