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