Created
October 27, 2023 15:30
-
-
Save bublick/7842131c0b3405f6427768ebcb4c4ad0 to your computer and use it in GitHub Desktop.
modal popup with embedded youtube video
This file contains hidden or 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
@keyframes pulse { | |
0% { | |
-webkit-box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.1), 0 0 0 10px rgba(255, 255, 255, 0.1), 0 0 0 20px rgba(255, 255, 255, 0.1); | |
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.1), 0 0 0 10px rgba(255, 255, 255, 0.1), 0 0 0 20px rgba(255, 255, 255, 0.1); } | |
100% { | |
-webkit-box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.1), 0 0 0 20px rgba(255, 255, 255, 0.1), 0 0 0 100px rgba(255, 255, 255, 0); | |
box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.1), 0 0 0 20px rgba(255, 255, 255, 0.1), 0 0 0 100px rgba(255, 255, 255, 0); } | |
} | |
@keyframes appearModalClose { | |
0% { | |
top: -10%; | |
transform: scale(0.5); | |
} | |
100% { | |
top: 10%; | |
transform: scale(1); | |
} | |
} | |
/* .vedio-btn i { | |
color: #000cca; | |
} */ | |
.close-btn { | |
position: absolute; | |
top: 14%; | |
right: 20%; | |
padding: 10px; | |
background: transparent; | |
border: 0; | |
font-size: 20px; | |
color: #bebbbb; | |
cursor: pointer; | |
} | |
.modal-container { | |
background-color: rgba(0, 0, 0, 0.7); | |
display: none; | |
position: fixed; | |
top: 0; | |
left: 0; | |
right: 0; | |
bottom: 0; | |
} | |
.modal-container.show-modal { | |
display: block; | |
z-index: 999; | |
} | |
.modal { | |
background-color: transparent; | |
border-radius: 5px; | |
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); | |
position: absolute; | |
overflow: hidden; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
max-width: 100%; | |
animation-name: modalopen; | |
animation-duration: 1s; | |
z-index: 9999; | |
} | |
button#close{ | |
position: absolute; | |
display: fixed; | |
width: 40px; | |
height: 40px; | |
top: 10%; | |
border-radius: 50%; | |
right: 20%; | |
cursor: pointer; | |
transition: all 0.3s ease-in-out; | |
animation: appearModalClose 0.5s ease-in-out; | |
&:hover { | |
top: 9.5%; | |
transition: all 0.3s ease-in-out; | |
} | |
span { | |
display: block; | |
position: relative; | |
height: 3px; | |
width: 100%; | |
background-color: #000; | |
transition: transform .3s; | |
} | |
span:nth-child(1) { | |
transform: rotate(45deg); | |
top: 2px; | |
} | |
span:nth-child(2) { | |
transform: rotate(-45deg); | |
bottom: 1px; | |
} | |
} | |
@media screen and (max-width: 440px) { | |
#modal iframe{ | |
width: 350px; | |
} | |
} | |
@media screen and (max-width: 840px) { | |
#modal iframe{ | |
width: 440px; | |
} | |
} |
This file contains hidden or 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
function pageReady(fn) { | |
if (document.readyState != 'loading') { | |
fn() | |
} else { | |
document.addEventListener('DOMContentLoaded', fn) | |
} | |
} | |
function initWebinarsPopups() { | |
const webinarBtn = document.querySelector('.webinar-button') | |
if (!webinarBtn) return | |
const allWebinarBtns = document.querySelectorAll('.webinar-button') | |
const modal = document.getElementById('modal') | |
const close = modal.querySelector('#close') | |
allWebinarBtns.forEach((btn) => { | |
btn.addEventListener('click', function (e) { | |
e.preventDefault() | |
const videoUrl = btn.dataset.videoUrl | |
modal.querySelector('iframe').src = videoUrl | |
modal.classList.add('show-modal') | |
}) | |
}) | |
// Hide modal | |
close.addEventListener('click', () => { | |
modal.classList.remove('show-modal') | |
modal.querySelector('iframe').src = '' | |
}) | |
// Hide modal on outside click | |
window.addEventListener('click', (e) => { | |
if (e.target == modal) { | |
modal.classList.remove('show-modal') | |
modal.querySelector('iframe').src = '' | |
} else { | |
return false | |
} | |
}) | |
} | |
pageReady(function () { | |
initWebinarsPopups() | |
}) |
This file contains hidden or 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
{{with $featuredwebinars}} | |
<div class="blog-features"> | |
{{range .}} | |
{{ $lastMod := .Lastmod }} | |
{{ $date := .Date }} | |
<a href="{{.RelPermalink}}" class="blog-card blog-feature-card"> | |
<div class="blog-card-image"> | |
{{with .Params.thumbnail}} | |
<img src="{{. | relURL}}" alt="" /> | |
{{end}} | |
</div> | |
<div class="blog-card-content"> | |
<h3 class="blog-card-title">{{.Title}}</h3> | |
<div class="flex fl-jc-between fl-ai-center blog-card-footer"> | |
<div class="bold blog-card-date"> | |
<span class="title-red-grad"> | |
{{$lastMod.Format "Jan 2, 2006"}} | |
</span> | |
</div> | |
{{with .Params.Tags}} | |
<span class="bold blog-card-tag">{{index . 0}}</span> | |
{{end}} | |
</div> | |
</div> | |
</a> | |
{{end}} | |
</div> | |
{{end}} | |
<section> | |
<div class="blog-wrap"> | |
{{with $webinars}} | |
<!-- <h2 class="blog-part-title"><span class="title-blue-grad">More articles:</span></h2> --> | |
<div class="blog-cards"> | |
{{range sort .Pages ".Lastmod" "desc"}} | |
<a href="#" class="blog-card webinar-button" data-video-url="{{.Params.video_url}}"> | |
<div class="blog-card-image"> | |
{{with .Params.thumbnail}} | |
<img src="{{. | relURL}}" alt="" /> | |
{{end}} | |
</div> | |
<div class="blog-card-content"> | |
<h3 class="blog-card-title">{{.Title}}</h3> | |
<div class="flex fl-jc-between fl-ai-center blog-card-footer"> | |
{{with .Lastmod}} | |
<div class="bold blog-card-date"><span class="title-red-grad">{{.Format "Jan 2, 2006"}}</span></div> | |
{{end}} | |
{{with .Params.Tags}} | |
<span class="bold blog-card-tag">{{index . 0}}</span> | |
{{end}} | |
</div> | |
</div> | |
</a> | |
{{end}} | |
<div class="modal-container" id="modal"> | |
<button class="" id="close"> | |
<span></span> | |
<span></span> | |
</button> | |
<div class="modal"> | |
<iframe width="800" height="400" frameborder="0" allowfullscreen="" src="//"> | |
</iframe> | |
</div> | |
</div> | |
</div> | |
{{end}} | |
</div> | |
</section> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment