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