Use document.documentElement.clientWidth instead of window.innerWidth
[plack-app-gruntmaster.git] / js / 10-modal.js
CommitLineData
03720101 1let modal, backdrop, hiding;
0f578ab0 2
7093e9ba
MG
3function show_modal () {
4 modal.classList.remove('hidden');
03720101 5 backdrop.classList.remove('hidden');
7093e9ba
MG
6 setTimeout(function (){
7 document.body.classList.add('modal-open');
8 }, 20);
9}
0f578ab0 10
7093e9ba
MG
11function hide_modal () {
12 document.body.classList.remove('modal-open');
13}
0f578ab0 14
7093e9ba 15$(function() {
4aff66ac 16 if(document.documentElement.clientWidth)
a66a1fe0 17 return;
7093e9ba 18 modal = $('.modal')[0];
03720101 19 backdrop = $('.backdrop')[0];
8345760a 20 $(modal).on('transitionend', el => {
7093e9ba
MG
21 if(!document.body.classList.contains('modal-open'))
22 modal.classList.add('hidden');
23 });
8345760a
MG
24 $('.backdrop,.modal').each(el => document.body.appendChild(el) );
25 $('#solution').on('click', e => {
7093e9ba
MG
26 show_modal();
27 e.preventDefault();
28 });
29 $('.backdrop').on('click', hide_modal);
8345760a 30 window.onkeyup = event => {
7093e9ba
MG
31 if (event.keyCode === 27)
32 hide_modal();
33 }
34});
This page took 0.012701 seconds and 4 git commands to generate.