1 2(function($, Drupal, drupalSettings, once){ 3 "use strict"; 4 5 Drupal.behaviors.HologicHoneypot = { 6 attach: function (context, settings) { 7 $(document).ready(function() { 8 9 10 jQuery("form").each(function() { 11 let form = jQuery(this); 12 13 // Only add honeypot once per form 14 if (form.find("input[name='hologic_dataset']").length === 0) { 15 jQuery('<input>', { 16 type: 'text', 17 class: 'form-control', 18 name: 'hologic_dataset', 19 value: '', 20 tabindex: -1, 21 'aria-hidden': true 22 }).css({display:'none'}).prependTo(form); 23 } 24 }); 25 26 27 28 jQuery("input[name='hologic_dataset']").change(function(){ 29 var hologic_datasetdata = jQuery(this).val(); 30 // Honeypot field change event to disable submit 31 let submissionBtn = jQuery( this ).closest( "form" ).find('input[type="submit"]'); 32 33 var $submits = jQuery(this) 34 .closest("form") 35 .find('button[type="submit"]'); 36 37 $submits.each(function () { 38 const $btn = jQuery(this); 39 $btn.not('[value="Go back"]').prop('disabled', true); 40 41 42 }) 43 44 jQuery( this ).closest( "form" ).find('input[type="submit"]').attr('disabled','disabled'); 45 jQuery( this ).closest( "form" ).find('input[type="button"]').attr('disabled','disabled'); 46 jQuery( this ).closest( "form" ).find('button[type="button"]').prop("disabled", true); 47 jQuery('form input[type="submit"]:disabled, button[type=submit]:disabled, form button:disabled, button[type=button]:disabled').css({ 48 'opacity': 1, 49 }); 50 51 var hologic_datasetdata = jQuery(this).val(); 52 var hologic_datasetlength = hologic_datasetdata.length; 53 if( hologic_datasetlength == 0 ){ 54 jQuery( this ).closest( "form" ).find('button[type="submit"]').prop("disabled", false); 55 jQuery( this ).closest( "form" ).find('button[type="button"]').prop("disabled", false); 56 jQuery( this ).closest( "form" ).find('input[type="submit"]').removeAttr('disabled'); 57 jQuery( this ).closest( "form" ).find('input[type="button"]').removeAttr('disabled'); 58 jQuery( this ).closest( "form" ).find('button').removeAttr('disabled'); 59 jQuery('form input[type="submit"], button[type=submit], form button, button[type=button]').css({'opacity' : '' }); 60 } 61 62 }); 63 64 jQuery("input[name='hologic_dataset']").css({ 65 'visibility': 'hidden', 66 'height': 0, 67 'width': 0, 68 'display': 'none' 69 }); 70 71 72 // captured submit event to the 73 jQuery("form").submit(function(event) { 74 var data = jQuery(this).find("input[name='hologic_dataset']").val(); 75 var length = data.length; 76 // condition to prevent the submission 77 if(length > 0) { 78 return false; 79 event.preventDefault(); 80 } 81 82 }); 83 84 }) 85 } 86 }; 87 88})(jQuery, Drupal, drupalSettings, 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.