1/* <fs_premium_only> */ 2function wfeaCalendarModalHandler() { 3 (function ($) { 4 $("body").on('click', ".wfea-share-button", function () { 5 $("#" + $(this).attr('data-target')).show(); 6 }); 7 $("body").on('click', ".wfea-modal .close", function () { 8 $('.wfea-modal').hide(); 9 }); 10 var calendar_modal = document.getElementById("wfea-calendar-modal"); 11 var social_modal = document.getElementById("wfea-social-modal"); 12 window.onclick = function (event) { 13 if (event.target == calendar_modal) { 14 calendar_modal.style.display = "none"; 15 } 16 if (event.target == social_modal) { 17 social_modal.style.display = "none"; 18 } 19 } 20 })(jQuery); 21} 22 23/* </fs_premium_only> */ 24 25(function ($) { 26 'use strict'; 27 28 /** 29 * All of the code for your public-facing JavaScript source 30 * should reside in this file. 31 * 32 * Note: It has been assumed you will write jQuery code here, so the 33 * $ function reference has been prepared for usage within the scope 34 * of this function. 35 * 36 * This enables you to define handlers, for when the DOM is ready: 37 * 38 * $(function() { 39 * 40 * }); 41 * 42 * When the window is loaded: 43 * 44 * $( window ).load(function() { 45 * 46 * }); 47 * 48 * ...and/or other possibilities. 49 * 50 * Ideally, it is not considered best practise to attach more than a 51 * single DOM-ready or window-load handler for a particular page. 52 * Although scripts in the WordPress core, Plugins and Themes may be 53 * practising this, we should strive to set a better example in our own work. 54 * 55 * 56 */ 57 /* <fs_premium_only> */ 58 $(function () { 59 60 // Guard against duplicate script execution (e.g. LiteSpeed optimization 61 // loading both original and optimized copies of this file). 62 if (window.wfeaFrontendLoaded) { 63 return; 64 } 65 window.wfeaFrontendLoaded = true; 66 67 /* -- modal -- */ 68 69 wfeaCalendarModalHandler(); 70 $('body').on('click', '.wfea-modal-view-details', function () { 71 var $button = $(this); 72 var $modalContainer = $('.wfea-modal-container'); 73 $modalContainer.addClass('active'); 74 75 // Move .wfea-modal-container immediately after <body> 76 $modalContainer.prependTo('body'); 77 78 $modalContainer.find('.scrollable-modal').addClass('loading').html('<div class="scrollable-modal-loader"></div>'); 79 // Collect all data attributes 80 var data = { 81 action: 'wfea_full_modal', 82 nonce: wfea_frontend.nonce, 83 eventbrite_id: $button.data('eventbrite_id') 84 }; 85 // Get all data attributes that start with 'wfea' 86 $.each($button[0].attributes, function(_, attr) { 87 if (attr.name.startsWith('data-wfea')) { 88 let key = attr.name; 89 data[key] = attr.value; 90 } 91 }); 92 console.log(data); 93 $.ajax({ 94 url: wfea_frontend.ajaxurl, 95 method: 'POST', 96 data: data, 97 success: function (res) { 98 // Guard against garbled responses (e.g. full HTML error page 99 // returned by server cache or error handler) 100 if (typeof res === 'string' && (res.indexOf('<!DOCTYPE') !== -1 || res.indexOf('<html') !== -1)) { 101 $modalContainer.find('.scrollable-modal').removeClass('loading').html( 102 '<div class="wfea-modal-error" style="padding: 2em; text-align: center;"><p>An issue occurred, please refresh and try again.</p></div>' 103 ); 104 return; 105 } 106 $modalContainer.find('.scrollable-modal').removeClass('loading').html(res); 107 try { 108 $("[data-eb-id]").wfeaBindLinksToEB(); 109 } catch (e) {
110 // that is OK just no popup 111 } 112 } 113 }); 114 }); 115 116 $('body').on('click', '.wfea-backdrop, .wfea-modal-close-button, .wfea-modal-checkout-button', function () { 117 $('.wfea-modal-container').removeClass('active'); 118 }); 119 120 /* -- accordion -- */ 121 $('body').on('click', '.wfea-accordion .tab', function () { 122 var accordionContent = $(this).next('.tab__content'); 123 124 if (accordionContent.hasClass('open')) { 125 accordionContent.slideUp(400, function () { 126 accordionContent.removeClass('open').addClass('closed'); 127 }); 128 $(this).removeClass('open').addClass('closed'); 129 } else { 130 $('.tab__content.open').slideUp(400).removeClass('open').addClass('closed'); 131 $('.tab.open').removeClass('open').addClass('closed'); 132 133 accordionContent.slideDown(400, function () { 134 accordionContent.removeClass('closed').addClass('open'); 135 }); 136 $(this).removeClass('closed').addClass('open'); 137 } 138 }); 139 140 }); 141 /* </fs_premium_only> */ 142 143 jQuery(document).on('click', '.wfea-search__submit, .wfea-search_cal__submit', function (e) { 144 if (e.target.matches('input.wfea-search_cal__submit')) { 145 e.preventDefault(); 146 147 // Get the closest form to the clicked submit button 148 var form = $(this).closest('form'); 149 150 // Check if the form exists in the DOM 151 if (form.length) { 152 var searchVal = form.find('.wfea-search__input').val(); 153 var section = form.parent('div').nextAll('div').find('section.wfea').first(); 154 console.log(section); 155 section.attr('data-wfea-search', searchVal); // Add data attribute to adjacent section 156 157 // Render the calendar 158 wfea_render_calendar(); 159 } 160 return; 161 } 162 e.preventDefault(); 163 const url = new URL(window.location.href); 164 const searchInput = jQuery('.wfea-search__input').val(); 165 const searchParams = { 166 wfea_s: searchInput, 167 wfea_s_target: jQuery('input[name="wfea_s_target"]').val(), 168 _wfea_nonce: jQuery('input[name="_wfea_nonce"]').val(), 169 }; 170 171 for (const [key, value] of Object.entries(searchParams)) { 172 if (searchInput && value) { 173 url.searchParams.set(key, value); 174 } else { 175 url.searchParams.delete(key); 176 } 177 } 178 179 // Redirect to the modified URL 180 window.location.href = url.toString(); 181 }); 182 183})(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.