]>
Commit | Line | Data |
---|---|---|
03720101 | 1 | let modal, backdrop, hiding; |
0f578ab0 | 2 | |
7093e9ba MG |
3 | function 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 |
11 | function hide_modal () { |
12 | document.body.classList.remove('modal-open'); | |
13 | } | |
0f578ab0 | 14 | |
7093e9ba MG |
15 | $(function() { |
16 | modal = $('.modal')[0]; | |
03720101 | 17 | backdrop = $('.backdrop')[0]; |
8345760a | 18 | $(modal).on('transitionend', el => { |
7093e9ba MG |
19 | if(!document.body.classList.contains('modal-open')) |
20 | modal.classList.add('hidden'); | |
21 | }); | |
8345760a MG |
22 | $('.backdrop,.modal').each(el => document.body.appendChild(el) ); |
23 | $('#solution').on('click', e => { | |
7093e9ba MG |
24 | show_modal(); |
25 | e.preventDefault(); | |
26 | }); | |
27 | $('.backdrop').on('click', hide_modal); | |
8345760a | 28 | window.onkeyup = event => { |
7093e9ba MG |
29 | if (event.keyCode === 27) |
30 | hide_modal(); | |
31 | } | |
32 | }); |