X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=js%2F10-modal.js;h=d930f44ef0b6b3f956f0076b8055295c8f73de1e;hb=dee46c5bb42f8fdaa70e70d6bdd4da5072a99ecd;hp=980bab79a987ae6001413765e665d6fb7390d69c;hpb=7093e9ba00cf7727a52a49d34d4df12e4f865dd4;p=plack-app-gruntmaster.git diff --git a/js/10-modal.js b/js/10-modal.js index 980bab7..d930f44 100644 --- a/js/10-modal.js +++ b/js/10-modal.js @@ -1,7 +1,8 @@ -var modal, hiding; +let modal, backdrop, hiding; function show_modal () { modal.classList.remove('hidden'); + backdrop.classList.remove('hidden'); setTimeout(function (){ document.body.classList.add('modal-open'); }, 20); @@ -12,20 +13,21 @@ function hide_modal () { } $(function() { - modal = $('.modal')[0]; - $(modal).on('transitionend', function (){ + modal = q('.modal'); + backdrop = q('.backdrop'); + $(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(); }