Make JS a bit simpler
[plack-app-gruntmaster.git] / js / 10-modal.js
index 9bf83ce71f634aad3bfb124fcba63962edb6a782..d930f44ef0b6b3f956f0076b8055295c8f73de1e 100644 (file)
@@ -13,18 +13,18 @@ function hide_modal () {
 }
 
 $(function() {
-       if(window.innerWidth < 768)
-               return;
-       modal = $('.modal')[0];
-       backdrop = $('.backdrop')[0];
+       modal = q('.modal');
+       backdrop = q('.backdrop');
        $(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 => {
This page took 0.009564 seconds and 4 git commands to generate.