1(function ($, Drupal, once) { 2 Drupal.behaviors.gtranslateConsent = { 3 attach: function (context, settings) { 4 once('gtranslateConsent', '#consent-trigger', context).forEach(function () { 5 var $trigger = $('#consent-trigger', context); 6 var $modal = $('#consent_modal', context); 7 var $accept = $('#gt_accept', context); 8 var $decline = $('#gt_decline', context); 9 var $language = $('#language_consent', context); 10 var gaStatus = sessionStorage.getItem('ga-status'); 11 12 // Set UI state on load 13 if (gaStatus === 'accepted') { 14 $trigger.addClass('d-none'); 15 $language.removeClass('d-none'); 16 } 17 18 // Accept: store state, hide modal, update UI 19 $accept.on('click', function () { 20 sessionStorage.setItem('ga-status', 'accepted'); 21 $modal.modal('hide'); 22 $trigger.addClass('d-none'); 23 $language.removeClass('d-none'); 24 }); 25 26 // Decline: store state, hide modal 27 $decline.on('click', function () { 28 sessionStorage.setItem('ga-status', 'declined'); 29 $modal.modal('hide'); 30 }); 31 32 // Trigger click / keyboard activation 33 $trigger.on('click keydown', function (e) { 34 if (e.type === 'click' || e.key === 'Enter' || e.key === ' ') { 35 var gaStatus = sessionStorage.getItem('ga-status'); 36 if (gaStatus == null || gaStatus === 'declined') { 37 $modal.modal('show'); 38 $trigger.attr('aria-expanded', 'true'); 39 setTimeout(function () { $accept.focus(); }, 300); 40 } 41 } 42 }); 43 44 // â Safe focus restoration after modal fully hidden 45 $modal.on('hidden.bs.modal', function () { 46 $trigger.attr('aria-expanded', 'false').focus(); 47 }); 48 }); 49 }, 50 }; 51})(jQuery, Drupal, once);
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.