Use document.documentElement.clientWidth instead of window.innerWidth
[plack-app-gruntmaster.git] / js / 10-modal.js
index 980bab79a987ae6001413765e665d6fb7390d69c..eea85d7ac43e7a080aff36bd9164ea840071752b 100644 (file)
@@ -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() {
+       if(document.documentElement.clientWidth)
+               return;
        modal = $('.modal')[0];
-       $(modal).on('transitionend', function (){
+       backdrop = $('.backdrop')[0];
+       $(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){
+       $('.backdrop,.modal').each(el => document.body.appendChild(el) );
+       $('#solution').on('click', e => {
                show_modal();
                e.preventDefault();
        });
        $('.backdrop').on('click', hide_modal);
-       window.onkeyup = function (event) {
+       window.onkeyup = event => {
                if (event.keyCode === 27)
                        hide_modal();
        }
This page took 0.01048 seconds and 4 git commands to generate.