diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-30 17:10:00 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-30 17:10:00 +0200 |
commit | 960a11e89da4e4a6ad6fbad61c71625f89e267b6 (patch) | |
tree | 0cd370970c3166dd3715e46a5503a3da78f25e37 /client/src/assets/player/peertube-link-button.ts | |
parent | e10c7d5125c47830bd23ecfed2f1b2d1048e6639 (diff) | |
download | PeerTube-960a11e89da4e4a6ad6fbad61c71625f89e267b6.tar.gz PeerTube-960a11e89da4e4a6ad6fbad61c71625f89e267b6.tar.zst PeerTube-960a11e89da4e4a6ad6fbad61c71625f89e267b6.zip |
Add context menu to player
Diffstat (limited to 'client/src/assets/player/peertube-link-button.ts')
-rw-r--r-- | client/src/assets/player/peertube-link-button.ts | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/client/src/assets/player/peertube-link-button.ts b/client/src/assets/player/peertube-link-button.ts index 54d802732..a13815d61 100644 --- a/client/src/assets/player/peertube-link-button.ts +++ b/client/src/assets/player/peertube-link-button.ts | |||
@@ -1,15 +1,19 @@ | |||
1 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' | 1 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' |
2 | import { buildVideoLink } from './utils' | ||
2 | 3 | ||
3 | const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button') | 4 | const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button') |
4 | class PeerTubeLinkButton extends Button { | 5 | class PeerTubeLinkButton extends Button { |
5 | 6 | ||
7 | constructor (player: videojs.Player, options) { | ||
8 | super(player, options) | ||
9 | } | ||
10 | |||
6 | createEl () { | 11 | createEl () { |
7 | return this.buildElement() | 12 | return this.buildElement() |
8 | } | 13 | } |
9 | 14 | ||
10 | updateHref () { | 15 | updateHref () { |
11 | const currentTime = Math.floor(this.player().currentTime()) | 16 | this.el().setAttribute('href', buildVideoLink(this.player().currentTime())) |
12 | this.el().setAttribute('href', this.buildHref(currentTime)) | ||
13 | } | 17 | } |
14 | 18 | ||
15 | handleClick () { | 19 | handleClick () { |
@@ -18,7 +22,7 @@ class PeerTubeLinkButton extends Button { | |||
18 | 22 | ||
19 | private buildElement () { | 23 | private buildElement () { |
20 | const el = videojsUntyped.dom.createEl('a', { | 24 | const el = videojsUntyped.dom.createEl('a', { |
21 | href: this.buildHref(), | 25 | href: buildVideoLink(), |
22 | innerHTML: 'PeerTube', | 26 | innerHTML: 'PeerTube', |
23 | title: 'Go to the video page', | 27 | title: 'Go to the video page', |
24 | className: 'vjs-peertube-link', | 28 | className: 'vjs-peertube-link', |
@@ -29,15 +33,5 @@ class PeerTubeLinkButton extends Button { | |||
29 | 33 | ||
30 | return el | 34 | return el |
31 | } | 35 | } |
32 | |||
33 | private buildHref (time?: number) { | ||
34 | let href = window.location.href.replace('embed', 'watch') | ||
35 | if (time) { | ||
36 | if (window.location.search) href += '&start=' + time | ||
37 | else href += '?start=' + time | ||
38 | } | ||
39 | |||
40 | return href | ||
41 | } | ||
42 | } | 36 | } |
43 | Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton) | 37 | Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton) |