X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=js%2F10-modal.js;h=acee78b7fdd6c3e4d525bfc8515bef911c050e2f;hb=db826688fdfc12865c5208a9c137142dddefd43a;hp=9bf83ce71f634aad3bfb124fcba63962edb6a782;hpb=a66a1fe02efc1cdf7adfa606de00790b02b3ee72;p=plack-app-gruntmaster.git diff --git a/js/10-modal.js b/js/10-modal.js index 9bf83ce..acee78b 100644 --- a/js/10-modal.js +++ b/js/10-modal.js @@ -1,8 +1,8 @@ -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); @@ -13,18 +13,17 @@ function hide_modal () { } $(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 => {