Переглянути джерело

Merge pull request #115 from thomascombe/feat/hide-read-more

Change read more link
Amauri CHAMPEAUX 6 роки тому
батько
коміт
6dec199d5d
2 змінених файлів з 33 додано та 1 видалено
  1. 22 0
      README.md
  2. 11 1
      tarteaucitron.js

+ 22 - 0
README.md

@@ -50,6 +50,28 @@ tarteaucitron.init({
     "useExternalCss": false /* If false, the tarteaucitron.css file will be loaded */
 
     //"cookieDomain": ".my-multisite-domaine.fr" /* Shared cookie for subdomain website */
+                          
+    "readmoreLink": "/cookiespolicy" /* Change the default readmore link pointing to opt-out.ferank.eu */
 });
 </script>
 ```
+
+# Create custom service
+```js
+tarteaucitron.services.mycustomservice = {
+  "key": "mycustomservice",
+  "type": "social|analytic|ads|video|support",
+  "name": "MyCustomService",
+  "needConsent": true,
+  "cookies": ['cookie', 'cookie2'],
+  "readmoreLink": "/custom_read_more", // If you want to change readmore link
+  "js": function () {
+    "use strict";
+    // When user allow cookie
+  },
+  "fallback": function () {
+    "use strict";
+    // when use deny cookie
+  }
+};
+```

+ 11 - 1
tarteaucitron.js

@@ -521,8 +521,17 @@ var tarteaucitron = {
             html += '   <div class="tarteaucitronName">';
             html += '       <span class="tarteaucitronH3" role="heading" aria-level="h3">' + service.name + '</span>';
             html += '       <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
+
             if (tarteaucitron.parameters.moreInfoLink == true) {
-                html += '       <a href="https://opt-out.ferank.eu/service/' + service.key + '/" target="_blank" rel="noopener" title="'+ tarteaucitron.lang.cookieDetail + ' ' + service.name + ' ' + tarteaucitron.lang.ourSite + ' ' + tarteaucitron.lang.newWindow +'">';
+
+                var link = 'https://opt-out.ferank.eu/service/' + service.key + '/';
+                if (service.readmoreLink !== undefined && service.readmoreLink !== '') {
+                    link = service.readmoreLink;
+                }
+                if (tarteaucitron.parameters.readmoreLink !== undefined && tarteaucitron.parameters.readmoreLink !== '') {
+                    link = tarteaucitron.parameters.readmoreLink;
+                }
+                html += '       <a href="' + link + '" target="_blank" rel="noopener" title="'+ tarteaucitron.lang.cookieDetail + ' ' + service.name + ' ' + tarteaucitron.lang.ourSite + ' ' + tarteaucitron.lang.newWindow +'">';
                 html += '           ' + tarteaucitron.lang.more;
                 html += '       </a>';
                 html += '        - ';
@@ -530,6 +539,7 @@ var tarteaucitron = {
                 html += '           ' + tarteaucitron.lang.source;
                 html += '       </a>';
             }
+
             html += '   </div>';
             html += '   <div class="tarteaucitronAsk">';
             html += '       <button id="' + service.key + 'Allowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respond(this, true);">';