1 2 3(function ($) { 4 'use strict'; 5 6 /** 7 * All of the code for your public-facing JavaScript source 8 * should reside in this file. 9 * 10 * Note: It has been assumed you will write jQuery code here, so the 11 * $ function reference has been prepared for usage within the scope 12 * of this function. 13 * 14 * This enables you to define handlers, for when the DOM is ready: 15 * 16 * $(function() { 17 * 18 * }); 19 * 20 * When the window is loaded: 21 * 22 * $( window ).load(function() { 23 * 24 * }); 25 * 26 * ...and/or other possibilities. 27 * 28 * Ideally, it is not considered best practise to attach more than a 29 * single DOM-ready or window-load handler for a particular page. 30 * Although scripts in the WordPress core, Plugins and Themes may be 31 * practising this, we should strive to set a better example in our own work. 32 * 33 * 34 */ 35 36 37 jQuery(document).on('click', '.wfea-search__submit, .wfea-search_cal__submit', function (e) { 38 if (e.target.matches('input.wfea-search_cal__submit')) { 39 e.preventDefault(); 40 41 // Get the closest form to the clicked submit button 42 var form = $(this).closest('form'); 43 44 // Check if the form exists in the DOM 45 if (form.length) { 46 var searchVal = form.find('.wfea-search__input').val(); 47 var section = form.parent('div').nextAll('div').find('section.wfea').first(); 48 console.log(section); 49 section.attr('data-wfea-search', searchVal); // Add data attribute to adjacent section 50 51 // Render the calendar 52 wfea_render_calendar(); 53 } 54 return; 55 } 56 e.preventDefault(); 57 const url = new URL(window.location.href); 58 const searchInput = jQuery('.wfea-search__input').val(); 59 const searchParams = { 60 wfea_s: searchInput, 61 wfea_s_target: jQuery('input[name="wfea_s_target"]').val(), 62 _wfea_nonce: jQuery('input[name="_wfea_nonce"]').val(), 63 }; 64 65 for (const [key, value] of Object.entries(searchParams)) { 66 if (searchInput && value) { 67 url.searchParams.set(key, value); 68 } else { 69 url.searchParams.delete(key); 70 } 71 } 72 73 // Redirect to the modified URL 74 window.location.href = url.toString(); 75 }); 76 77})(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.