-let modal, backdrop, hiding;
+let modal, hiding;
function show_modal () {
modal.classList.remove('hidden');
- backdrop.classList.remove('hidden');
+ q('.backdrop').classList.remove('hidden');
setTimeout(function (){
document.body.classList.add('modal-open');
}, 20);
}
$(function() {
- if(window.innerWidth < 768)
- return;
- modal = $('.modal')[0];
- backdrop = $('.backdrop')[0];
+ modal = q('.modal');
$(modal).on('transitionend', el => {
if(!document.body.classList.contains('modal-open'))
modal.classList.add('hidden');
});
$('.backdrop,.modal').each(el => document.body.appendChild(el) );
$('#solution').on('click', e => {
- show_modal();
- e.preventDefault();
+ if(window.matchMedia("(min-width: 768px)").matches){
+ show_modal();
+ e.preventDefault();
+ }
});
$('.backdrop').on('click', hide_modal);
window.onkeyup = event => {