1/** 2 * @file 3 * JavaScript behaviors for Ajax. 4 */ 5 6(function ($) { 7 8 'use strict'; 9 10 /** 11 * Command to render all Turnstile captchas in the page if they are empty. 12 */ 13 Drupal.AjaxCommands.prototype.turnstileRender = function () { 14 window.onloadTurnstileCallback(); 15 } 16 17 window.onloadTurnstileCallback = function () { 18 $('.cf-turnstile').each(function () { 19 20 // Render Turnstile widget again for empty containers. 21 if ($(this).is(':empty')) { 22 const widget = this; 23 const appearance = $(widget).data('appearance') || ''; 24 const setA11yVisibility = function (visible) { 25 26 // 'inert' removes the element and its shadow DOM contents from the 27 // tab order and prevents all descendant focus or interaction. 28 // 'aria-hidden' ensures assistive technologies also ignore the widget 29 // in browsers that do not yet fully support 'inert'. 30 if (visible) { 31 $(widget).removeAttr('inert'); 32 $(widget).removeAttr('aria-hidden'); 33 } 34 else { 35 $(widget).attr('inert', 'true'); 36 $(widget).attr('aria-hidden', 'true'); 37 } 38 }; 39 40 turnstile.render(widget, { 41 'before-interactive-callback': function () { 42 if (appearance === 'interaction-only') { 43 44 // Make the widget accessible when it becomes interactive. 45 setA11yVisibility(true); 46 } 47 }, 48 }); 49 50 if (appearance === 'interaction-only') { 51 52 // Stop the widget from being accessible until it becomes interactive. 53 setA11yVisibility(false); 54 } 55 } 56 }); 57 }; 58})(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.