blob: fe17ce2cef29e234c9764a824a488ba146757cc8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import videojs from 'video.js'
import { NextPreviousVideoButtonOptions } from '../peertube-videojs-typings'
const Button = videojs.getComponent('Button')
class NextPreviousVideoButton extends Button {
private readonly nextPreviousVideoButtonOptions: NextPreviousVideoButtonOptions
constructor (player: videojs.Player, options?: NextPreviousVideoButtonOptions) {
super(player, options as any)
this.nextPreviousVideoButtonOptions = options
this.update()
}
createEl () {
const type = (this.options_ as NextPreviousVideoButtonOptions).type
const button = videojs.dom.createEl('button', {
className: 'vjs-' + type + '-video'
}) as HTMLButtonElement
const nextIcon = videojs.dom.createEl('span', {
className: 'icon icon-' + type
})
button.appendChild(nextIcon)
if (type === 'next') {
button.title = this.player_.localize('Next video')
} else {
button.title = this.player_.localize('Previous video')
}
return button
}
handleClick () {
this.nextPreviousVideoButtonOptions.handler()
}
update () {
const disabled = this.nextPreviousVideoButtonOptions.isDisabled()
if (disabled) this.addClass('vjs-disabled')
else this.removeClass('vjs-disabled')
}
}
videojs.registerComponent('NextVideoButton', NextPreviousVideoButton)
videojs.registerComponent('PreviousVideoButton', NextPreviousVideoButton)
|