aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-link-button.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/peertube-link-button.ts')
-rw-r--r--client/src/assets/player/peertube-link-button.ts28
1 files changed, 24 insertions, 4 deletions
diff --git a/client/src/assets/player/peertube-link-button.ts b/client/src/assets/player/peertube-link-button.ts
index 6ead78c00..a47adc2db 100644
--- a/client/src/assets/player/peertube-link-button.ts
+++ b/client/src/assets/player/peertube-link-button.ts
@@ -4,17 +4,37 @@ const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button')
4class PeerTubeLinkButton extends Button { 4class PeerTubeLinkButton extends Button {
5 5
6 createEl () { 6 createEl () {
7 return videojsUntyped.dom.createEl('a', { 7 return this.buildElement()
8 href: window.location.href.replace('embed', 'watch'), 8 }
9
10 updateHref () {
11 const currentTime = Math.floor(this.player().currentTime())
12 this.el().setAttribute('href', this.buildHref(currentTime))
13 }
14
15 handleClick () {
16 this.player_.pause()
17 }
18
19 private buildElement () {
20 const el = videojsUntyped.dom.createEl('a', {
21 href: this.buildHref(),
9 innerHTML: 'PeerTube', 22 innerHTML: 'PeerTube',
10 title: 'Go to the video page', 23 title: 'Go to the video page',
11 className: 'vjs-peertube-link', 24 className: 'vjs-peertube-link',
12 target: '_blank' 25 target: '_blank'
13 }) 26 })
27
28 el.addEventListener('mouseenter', () => this.updateHref())
29
30 return el
14 } 31 }
15 32
16 handleClick () { 33 private buildHref (time?: number) {
17 this.player_.pause() 34 let href = window.location.href.replace('embed', 'watch')
35 if (time) href += '?start=' + time
36
37 return href
18 } 38 }
19} 39}
20Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton) 40Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)