Skip to content

Commit

Permalink
It does what it says on the box
Browse files Browse the repository at this point in the history
  • Loading branch information
wulfsolter committed Dec 31, 2015
1 parent a3158cf commit 7204f47
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
16 changes: 16 additions & 0 deletions videojs.endcapCTA.css
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;
}
48 changes: 48 additions & 0 deletions videojs.endcapCTA.js
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));

0 comments on commit 7204f47

Please sign in to comment.