custom link component
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Roy Olav Purser 2022-03-13 12:04:16 +01:00
parent 341932fd0e
commit 230f542b54
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -27,7 +27,18 @@
const canPlayType = (canPlayTypeRaw === "maybe") || (canPlayTypeRaw === "probably");
if(canPlayType) {
const Button = videojs.getComponent("Button");
const Component = videojs.getComponent("Component");
const DownloadButton = videojs.extend(videojs.getComponent("Component"), {
createEl: () => {
const elem = document.createElement("a");
elem.href = info.download;
elem.classList.add("vjs-control");
elem.classList.add("vjs-button");
elem.classList.add("fas");
elem.classList.add("fa-download");
elem.classList.add("vjs-big-download");
return elem;
}
})
const cbutton = {};
cbutton.clickHandler = (ev) => {
@ -35,8 +46,7 @@
}
const bigCastButtonWrapper = new Button(player, cbutton);
const bigDownloadButtonWrapper = new Component(player);
bigDownloadButtonWrapper.el_ = document.createElement("a");
const bigDownloadButtonWrapper = new DownloadButton(player);
const bigCastButton = bigCastButtonWrapper.el();
const bigDownloadButton = bigDownloadButtonWrapper.el();
@ -49,12 +59,6 @@
player.addChild(bigCastButtonWrapper);
if(info.download) {
bigDownloadButton.href = info.download;
bigDownloadButton.classList.add("vjs-control");
bigDownloadButton.classList.add("vjs-button");
bigDownloadButton.classList.add("fas");
bigDownloadButton.classList.add("fa-download");
bigDownloadButton.classList.add("vjs-big-download");
player.addChild(bigDownloadButtonWrapper);
}