]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/assets/player/videojs-components/peertube-link-button.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / videojs-components / peertube-link-button.ts
CommitLineData
2adfc7ea 1import { buildVideoLink } from '../utils'
f5fcd9f7 2import videojs, { VideoJsPlayer } from 'video.js'
c6352f2c 3
f5fcd9f7 4const Button = videojs.getComponent('Button')
c6352f2c
C
5class PeerTubeLinkButton extends Button {
6
f5fcd9f7 7 constructor (player: VideoJsPlayer, options?: videojs.ComponentOptions) {
960a11e8
C
8 super(player, options)
9 }
10
c6352f2c 11 createEl () {
fc73684a
C
12 return this.buildElement()
13 }
14
15 updateHref () {
2f4c784a 16 this.el().setAttribute('href', buildVideoLink({ startTime: this.player().currentTime() }))
fc73684a
C
17 }
18
19 handleClick () {
f5fcd9f7 20 this.player().pause()
fc73684a
C
21 }
22
23 private buildElement () {
f5fcd9f7 24 const el = videojs.dom.createEl('a', {
960a11e8 25 href: buildVideoLink(),
c6352f2c 26 innerHTML: 'PeerTube',
f5fcd9f7 27 title: this.player().localize('Go to the video page'),
c6352f2c
C
28 className: 'vjs-peertube-link',
29 target: '_blank'
30 })
fc73684a
C
31
32 el.addEventListener('mouseenter', () => this.updateHref())
33
f5fcd9f7 34 return el as HTMLButtonElement
c6352f2c 35 }
c6352f2c 36}
f5fcd9f7
C
37
38videojs.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)