Rev 17143 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
17143 | obado | 1 | /*** By now, foundation.util.triggers must be disabled |
2 | * to avoid a conflict with the Dynapi lib. |
||
3 | * ( it duplicates every item created by dynapi) |
||
4 | * see here for sample : localhost/wims/?module=H1%2Falgebra%2Faddfig.fr&cmd=new |
||
5 | * meanwhile, we define here at least some usefull functions |
||
6 | **/ |
||
7 | |||
8 | document.addEventListener('DOMContentLoaded', function () { |
||
9 | // Auto Close all data-closable items |
||
10 | const wims_closables = document.querySelectorAll("div[data-closable]"); |
||
11 | // Wait 4s to let user read message |
||
12 | window.setTimeout(() => { |
||
13 | wims_closables.forEach((closableItem) => { |
||
14 | alert_close(closableItem) |
||
15 | }); |
||
16 | }, 4000); |
||
17 | |||
17144 | obado | 18 | const wims_closebuttons = document.querySelectorAll("button.wims-closer"); |
17143 | obado | 19 | wims_closebuttons.forEach((closebtn) => { |
17144 | obado | 20 | closebtn.addEventListener('click', function () { |
17143 | obado | 21 | alert_close(closebtn.parentElement); |
22 | closebtn.parentElement.removeChild(closebtn); |
||
23 | }); |
||
24 | }); |
||
25 | |||
26 | }); |
||
27 | |||
28 | |||
29 | // Remove an item with smooth transition |
||
30 | function alert_close(closableItem) { |
||
17144 | obado | 31 | if (!closableItem.classList.contains("alert_closing")) { |
32 | closableItem.classList.add("alert_closing"); |
||
33 | // let transition run, then remove element |
||
34 | window.setTimeout(() => { |
||
35 | closableItem.parentElement.removeChild(closableItem); |
||
36 | }, 3000); |
||
37 | } |
||
17143 | obado | 38 | } |