Adding code back in I was able to get this far with no errors:
no videos appearing though.
https://jsfiddle.net/ux8jm6eq/5/
Here is the code with videos appearing:
https://jsfiddle.net/ux8jm6eq/2/
Here is the full working code: has buttons: https://jsfiddle.net/u2pn17we/
Update: Here I have the videos appearing: https://jsfiddle.net/aps6gjc1/
I think I am a bit closer of it working.
Next, trying to get remove player working.
Working on this code: https://jsfiddle.net/aps6gjc1/
<div id="myModal" class="modal open">
<div class="modal-content">
<div class="blog-pager close">
<a title="Exit" aria-label="Close"></a>
</div><div class="container">
<div class="ratio-keeper wrap">
<div class="video " data-id="1Q1aDAnBsU8"></div>
</div> </div>
<div class="playa"></div>
</div>
</div>
const manageUI = (function makeManageUI() {
function exitClickHandler() {
}
function addClickToExit(exitButtons) {
exitButtons.forEach(function addExitButtonHandler(exitButtons) {
exitButtons.addEventListener("click", exitClickHandler);
});
}
function addExitHandlers(callback) {
const resetVideo = document.querySelectorAll(".close");
resetVideo.forEach(function resetVideoHandler(video) {
video.addEventListener("click", callback);
});
}
function init() {
const exitButtons = document.querySelectorAll(".close");
addClickToExit(exitButtons);
}
return {
addExitHandlers,
init
};
}());
function removePlayer(wrapper) {
wrapper.player.destroy();
delete wrapper.player;
console.log("removePlayer");
}
function removePlayerHandler(evt) {
const el = evt.target;
//const container = el.closest(".container");
const wrapper = document.querySelector(".wrap");
if (wrapper.player) {
return removePlayer(wrapper);
}
}
function init() {
manageCover.init({
container: ".container"
});
manageUI.init({});
manageUI.addExitHandlers(managePlayer.removePlayerHandler);
}
return {
add: addPlayer,
init
};
}());
function show(el) {
el.classList.remove("hide");
}
function hide(el) {
el.classList.add("hide");
}
function exitClickHandler() {
const thewrap = document.querySelector(".blog-pager");
show(thewrap);
const cover = document.querySelector(".close");
hide(cover);
}