Selaa lähdekoodia

Add a timer on the closeelement

Amauri CHAMPEAUX 4 vuotta sitten
vanhempi
commit
b091e07cc5
1 muutettua tiedostoa jossa 9 lisäystä ja 5 poistoa
  1. 9 5
      tarteaucitron.js

+ 9 - 5
tarteaucitron.js

@@ -595,11 +595,15 @@ var tarteaucitron = {
                     }, 1500);
                 }
                 if(tarteaucitron.parameters.closePopup === true){
-                    var closeElement = document.getElementById('tarteaucitronAlertBig'),
-                        closeSpan = document.createElement('span');
-                    closeSpan.textContent = 'X';
-                    closeSpan.setAttribute('id', "tarteaucitronCloseCross");
-                    closeElement.insertBefore(closeSpan, closeElement.firstElementChild);
+                    setTimeout(function() {
+                        var closeElement = document.getElementById('tarteaucitronAlertBig'),
+                            closeSpan = document.createElement('span');
+                        if (closeElement) {
+                            closeSpan.textContent = 'X';
+                            closeSpan.setAttribute('id', "tarteaucitronCloseCross");
+                            closeElement.insertBefore(closeSpan, closeElement.firstElementChild);
+                        }
+                    }, 100);
                 }