aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/videojs-components/peertube-link-button.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/videojs-components/peertube-link-button.ts')
-rw-r--r--client/src/assets/player/videojs-components/peertube-link-button.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/client/src/assets/player/videojs-components/peertube-link-button.ts b/client/src/assets/player/videojs-components/peertube-link-button.ts
new file mode 100644
index 000000000..fed8ea33e
--- /dev/null
+++ b/client/src/assets/player/videojs-components/peertube-link-button.ts
@@ -0,0 +1,40 @@
1import { VideoJSComponentInterface, videojsUntyped } from '../peertube-videojs-typings'
2import { buildVideoLink } from '../utils'
3// FIXME: something weird with our path definition in tsconfig and typings
4// @ts-ignore
5import { Player } from 'video.js'
6
7const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button')
8class PeerTubeLinkButton extends Button {
9
10 constructor (player: Player, options: any) {
11 super(player, options)
12 }
13
14 createEl () {
15 return this.buildElement()
16 }
17
18 updateHref () {
19 this.el().setAttribute('href', buildVideoLink(this.player().currentTime()))
20 }
21
22 handleClick () {
23 this.player_.pause()
24 }
25
26 private buildElement () {
27 const el = videojsUntyped.dom.createEl('a', {
28 href: buildVideoLink(),
29 innerHTML: 'PeerTube',
30 title: this.player_.localize('Go to the video page'),
31 className: 'vjs-peertube-link',
32 target: '_blank'
33 })
34
35 el.addEventListener('mouseenter', () => this.updateHref())
36
37 return el
38 }
39}
40Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)