comparison util.js @ 19:bde4f0bbfe69

Clear a spinner’s timeout on change if it had been set previously.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 22 Dec 2018 19:53:01 +0100
parents 07543f7f5e89
children 6c620e9f7d2c
comparison
equal deleted inserted replaced
18:3c02cbced2df 19:bde4f0bbfe69
42 .up() 42 .up()
43 .up(); 43 .up();
44 } 44 }
45 45
46 function displaySpinner(spinner) { 46 function displaySpinner(spinner) {
47 if ('timeoutid' in spinner.dataset)
48 clearTimeout(spinner.dataset.timeoutid);
47 spinner.src = 'spinner.svg'; 49 spinner.src = 'spinner.svg';
48 spinner.hidden = false; 50 spinner.hidden = false;
49 } 51 }
50 52
51 function spinnerOk(spinner) { 53 function spinnerOk(spinner) {
54 if ('timeoutid' in spinner.dataset)
55 clearTimeout(spinner.dataset.timeoutid);
52 spinner.src = 'ok.svg'; 56 spinner.src = 'ok.svg';
53 spinner.hidden = false; 57 spinner.hidden = false;
54 setTimeout(function () { 58 spinner.dataset.timeoutid = setTimeout(function () {
55 spinner.hidden = true; 59 spinner.hidden = true;
56 }, 1000); 60 }, 1000);
57 } 61 }
58 62
59 function spinnerError(spinner) { 63 function spinnerError(spinner) {
64 if ('timeoutid' in spinner.dataset)
65 clearTimeout(spinner.dataset.timeoutid);
60 spinner.src = 'error.svg'; 66 spinner.src = 'error.svg';
61 spinner.hidden = false; 67 spinner.hidden = false;
62 } 68 }
63 69
64 function hideSpinner(spinner) { 70 function hideSpinner(spinner) {
71 if ('timeoutid' in spinner.dataset)
72 clearTimeout(spinner.dataset.timeoutid);
65 spinner.hidden = true; 73 spinner.hidden = true;
66 } 74 }