1/** 2 * @file 3 * Defines Javascript behaviors for the cookies module. 4 */ 5(function (Drupal, $) { 6 'use strict'; 7 8 /** 9 * Define defaults. 10 */ 11 Drupal.behaviors.cookiesInstagram = { 12 13 id: 'instagram', 14 15 consentGiven: function () { 16 // Activate scripts in correct order to regard dependencies. 17 var i = 0; 18 var progress = true; 19 while (i < 10 && progress) { 20 var id = 'cookies_instagram_' + i; 21 var script = document.getElementById(id); 22 progress = (script !== null); 23 if (progress) { 24 // Create new script element to alter the old. 25 var src = script.getAttribute('src'); 26 var newScript = document.createElement('script'); 27 newScript.setAttribute('id', id); 28 if (src) { 29 newScript.setAttribute('src', src); 30 } 31 else { 32 newScript.innerHTML = script.innerHTML; 33 } 34 // Replace script. 35 script.parentNode.replaceChild(newScript, script); 36 } 37 i++; 38 } 39 }, 40 41 consentDenied: function (context) { 42 $('.instagram-media', context).cookiesOverlay('instagram'); 43 }, 44 45 46 attach: function (context) { 47 var self = this; 48 document.addEventListener('cookiesjsrUserConsent', function (event) { 49 var service = (typeof event.detail.services === 'object') ? event.detail.services : {}; 50 if (typeof service[self.id] !== 'undefined' && service[self.id]) { 51 self.consentGiven(context); 52 } else { 53 self.consentDenied(context); 54 } 55 }); 56 } 57 }; 58})(Drupal, jQuery);
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.