aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/videojs-components
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-26 14:12:39 +0200
committerChocobozzz <me@florianbigard.com>2021-07-26 14:12:50 +0200
commit9162fdd36300d2478f13d6ad346ec2c323f40faa (patch)
treedea0ca43f3ea2fb72a73ca77338f5b7c990acdd7 /client/src/assets/player/videojs-components
parent764b1a14fc494f2cfd7ea590d2f07b01df65c7ad (diff)
downloadPeerTube-9162fdd36300d2478f13d6ad346ec2c323f40faa.tar.gz
PeerTube-9162fdd36300d2478f13d6ad346ec2c323f40faa.tar.zst
PeerTube-9162fdd36300d2478f13d6ad346ec2c323f40faa.zip
Refactor video links building
Diffstat (limited to 'client/src/assets/player/videojs-components')
-rw-r--r--client/src/assets/player/videojs-components/peertube-link-button.ts18
1 files changed, 13 insertions, 5 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
index e73c95900..f47c165d9 100644
--- a/client/src/assets/player/videojs-components/peertube-link-button.ts
+++ b/client/src/assets/player/videojs-components/peertube-link-button.ts
@@ -1,11 +1,13 @@
1import { buildVideoLink } from '../utils'
2import videojs from 'video.js' 1import videojs from 'video.js'
2import { PeerTubeLinkButtonOptions } from '../peertube-videojs-typings'
3import { buildVideoLink, decorateVideoLink } from '../utils'
3 4
4const Button = videojs.getComponent('Button') 5const Button = videojs.getComponent('Button')
5class PeerTubeLinkButton extends Button { 6class PeerTubeLinkButton extends Button {
7 private shortUUID: string
6 8
7 constructor (player: videojs.Player, options?: videojs.ComponentOptions) { 9 constructor (player: videojs.Player, options?: PeerTubeLinkButtonOptions) {
8 super(player, options) 10 super(player, options as any)
9 } 11 }
10 12
11 createEl () { 13 createEl () {
@@ -13,7 +15,7 @@ class PeerTubeLinkButton extends Button {
13 } 15 }
14 16
15 updateHref () { 17 updateHref () {
16 this.el().setAttribute('href', buildVideoLink({ startTime: this.player().currentTime() })) 18 this.el().setAttribute('href', this.buildLink())
17 } 19 }
18 20
19 handleClick () { 21 handleClick () {
@@ -22,7 +24,7 @@ class PeerTubeLinkButton extends Button {
22 24
23 private buildElement () { 25 private buildElement () {
24 const el = videojs.dom.createEl('a', { 26 const el = videojs.dom.createEl('a', {
25 href: buildVideoLink(), 27 href: this.buildLink(),
26 innerHTML: 'PeerTube', 28 innerHTML: 'PeerTube',
27 title: this.player().localize('Video page (new window)'), 29 title: this.player().localize('Video page (new window)'),
28 className: 'vjs-peertube-link', 30 className: 'vjs-peertube-link',
@@ -33,6 +35,12 @@ class PeerTubeLinkButton extends Button {
33 35
34 return el as HTMLButtonElement 36 return el as HTMLButtonElement
35 } 37 }
38
39 private buildLink () {
40 const url = buildVideoLink({ shortUUID: this.shortUUID })
41
42 return decorateVideoLink({ url, startTime: this.player().currentTime() })
43 }
36} 44}
37 45
38videojs.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton) 46videojs.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)