-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3158cf
commit 7204f47
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.vjs-endcapCTA { | ||
background: #000; | ||
background: rgba(0, 0, 0, .7); | ||
display: none; | ||
height: 100%; | ||
left: 0; | ||
overflow: hidden; | ||
position: absolute; | ||
right: 0; | ||
top: 0; | ||
width: 100%; | ||
} | ||
|
||
.vjs-endcapCTA.is-active { | ||
display: block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Video.js Endcap CTA | ||
* Created by Wulf Sölter | ||
* License information: https://github.com/wulfsolter/videojs-endcapCTA/blob/master/LICENSE | ||
* Plugin details: https://github.com/wulfsolter/videojs-endcapCTA | ||
*/ | ||
|
||
(function(videojs) { | ||
'use strict'; | ||
|
||
videojs.plugin('endcapCTA', function(opts) { | ||
opts = opts || { | ||
html: '<h1>Header</h1><p>Some content here...</p>', | ||
}; | ||
var player = this; | ||
var _content; | ||
|
||
/** | ||
* Generate the DOM elements for the suggested video endcap content | ||
* @type {function} | ||
*/ | ||
function constructContent() { | ||
var _frag = document.createDocumentFragment(); | ||
var _aside = document.createElement('aside'); | ||
|
||
_aside.className = 'vjs-endcapCTA'; | ||
_aside.innerHTML = opts.html; | ||
|
||
_content = _aside; | ||
_frag.appendChild(_aside); | ||
player.el().appendChild(_frag); | ||
} | ||
|
||
// attach VideoJS event handlers | ||
player.on('ended', function() { | ||
_content.classList.add('is-active'); | ||
}); | ||
player.on('play', function() { | ||
if (_content) { | ||
_content.classList.remove('is-active'); | ||
} | ||
}); | ||
player.ready(function() { | ||
constructContent(); | ||
}); | ||
|
||
}); | ||
}(window.videojs)); |