浏览代码

Put CSS on the .css file and set onclick as an event #572

Amauri CHAMPEAUX 4 年之前
父节点
当前提交
ececa37bf3
共有 2 个文件被更改,包括 15 次插入7 次删除
  1. 9 0
      css/tarteaucitron.css
  2. 6 7
      tarteaucitron.js

+ 9 - 0
css/tarteaucitron.css

@@ -869,6 +869,15 @@ span.tarteaucitronTitle.tarteaucitronH3 {
     margin-top: 12px!important;
 }
 
+#tarteaucitronCloseCross {
+    position:absolute;
+    color: #FFFF;
+    font-size:1.8rem;
+    cursor: pointer;
+    top: 10px;
+    right: 26px
+}
+
 .spacer-20 {
     height: 20px;
     display: block;

+ 6 - 7
tarteaucitron.js

@@ -582,12 +582,8 @@ var tarteaucitron = {
                     let element = document.getElementById('tarteaucitronAlertBig');
                     let span = document.createElement('span')
                     span.textContent = 'X';
-                    span.style.cssText = 'position:absolute; color: #FFFF; font-size:2rem; cursor: pointer; top: 10px; right: 26px';
-                    span.setAttribute('id', "clossCross")
+                    span.setAttribute('id', "tarteaucitronCloseCross")
                     element.insertBefore(span, element.firstElementChild)
-                    document.getElementById("clossCross").onclick = () =>{
-                        tarteaucitron.userInterface.closeAlert();
-                    }
                 }
 
 
@@ -596,6 +592,9 @@ var tarteaucitron = {
                 setTimeout(function () {
                     
                     // Setup events
+                    tarteaucitron.addClickEventToId("tarteaucitronCloseCross", function () {
+                        tarteaucitron.userInterface.closeAlert();
+                    });
                     tarteaucitron.addClickEventToId("tarteaucitronPersonalize", function () {
                         tarteaucitron.userInterface.openPanel();
                     });
@@ -872,11 +871,11 @@ var tarteaucitron = {
                 index = 0;
 
             for (index = 0; index < tarteaucitron.job.length; index += 1) {
-                
+
                 if (typeof type !== 'undefined' && s[tarteaucitron.job[index]].type !== type) {
                     continue;
                 }
-                
+
                 service = s[tarteaucitron.job[index]];
                 key = service.key;
                 if (tarteaucitron.state[key] !== status) {