1/** 2 * @file alerts.js 3 * 4 * JS File for alert component. 5 */ 6(function (Drupal, once, Cookies) { 7 8 /** 9 * @Behavior 10 */ 11 Drupal.behaviors.exploreAlertCookies = { 12 onceName: 'explore-alert-cookies', 13 alertSelector: '.alert[data-node-id]', 14 attach(context) { 15 const cookiePrefix = 'Drupal.visitor.hideAlert'; 16 // Toggle other accordion items. 17 once(this.onceName, context.querySelectorAll(this.alertSelector), context).forEach(function (alert) { 18 // Remove or display alert. 19 const cookieName = cookiePrefix + '.' + alert.getAttribute('data-node-id'); 20 if (Cookies.get(cookieName)) { 21 alert.remove(); 22 return; 23 } 24 25 // Show the alert content. 26 alert.classList.remove('visually-hidden'); 27 28 // Close and set cookie. 29 const btn = alert.querySelector('button'); 30 if (!btn) { 31 return; 32 } 33 34 ['click', 'touch'].forEach(function (e) { 35 btn.addEventListener(e, function (event) { 36 Cookies.set(cookieName, "1", { path: '/' }); 37 }); 38 }); 39 }); 40 }, 41 detach: function detach(context, settings, trigger) { 42 if (trigger === "unload") { 43 once.remove(this.onceName, context.querySelectorAll(this.alertSelector)); 44 } 45 }, 46 }; 47})(Drupal, once, window.Cookies);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.