Get rid of backdrop variable since it confuses Wappalyzer
[plack-app-gruntmaster.git] / js / 10-modal.js
CommitLineData
db826688 1let modal, hiding;
0f578ab0 2
7093e9ba
MG
3function show_modal () {
4 modal.classList.remove('hidden');
db826688 5 q('.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() {
dee46c5b 16 modal = q('.modal');
8345760a 17 $(modal).on('transitionend', el => {
7093e9ba
MG
18 if(!document.body.classList.contains('modal-open'))
19 modal.classList.add('hidden');
20 });
8345760a
MG
21 $('.backdrop,.modal').each(el => document.body.appendChild(el) );
22 $('#solution').on('click', e => {
74b0b0ab
MG
23 if(window.matchMedia("(min-width: 768px)").matches){
24 show_modal();
25 e.preventDefault();
26 }
7093e9ba
MG
27 });
28 $('.backdrop').on('click', hide_modal);
8345760a 29 window.onkeyup = event => {
7093e9ba
MG
30 if (event.keyCode === 27)
31 hide_modal();
32 }
33});
This page took 0.01132 seconds and 4 git commands to generate.