1jQuery(document).ready(function ($) { 2 // collection of ALL datetime selectors for ALL Events on the page 3 const $datetime_options = $('.datetime-selector-option'); 4 const $ticket_selector_submit_btn = $('.ticket-selector-submit-btn'); 5 // reset by unchecking everything 6 $.each( $datetime_options, function() { 7 $( this ).prop( 'checked', false ); 8 } ); 9 // add error notices to the DOM 10 $ticket_selector_submit_btn.before( 11 '<span class="ticket-selector-disabled-submit-btn-msg important-notice">'+ eei18n.please_select_date_filter_notice+'</span>' 12 ); 13 // update ticket selector if datetime is chosen 14 $('.checkbox-dropdown-selector').on( 15 'click', 16 '.datetime-selector-option', 17 function () { 18 const $datetime_selector_option = $(this); 19 const event_id = $datetime_selector_option.data('tkt_slctr_evt'); 20 const $submit_button = $('#ticket-selector-submit-' + event_id + '-btn'); 21 // track how many ticket selector rows are active ? ie: being displayed 22 let active_rows = 0; 23 const datetimes = []; 24 const $ticket_selector = $('#tkt-slctr-tbl-' + event_id); 25 if (object_exists($ticket_selector, '$ticket_selector', false)) { 26 // first let's put together an array of ALL checked datetime options for this event 27 const $ticket_datetime_options = $datetime_selector_option.parents('ul').find('.datetime-selector-option'); 28 if (object_exists($ticket_datetime_options, '$datetime_options', false)) { 29 // add each datetime options to our array of datetimes 30 $.each($ticket_datetime_options, function () { 31 // if checked, then display row and increment active_rows count 32 if ($(this).prop('checked')) { 33 datetimes.push('ee-ticket-datetimes-' + $(this).val()); 34 } 35 }); 36 } 37 // find all ticket rows for this event 38 const $ticket_selector_rows = $ticket_selector.find('.tckt-slctr-tbl-tr'); 39 $.each($ticket_selector_rows, function () { 40 const $ticket_selector_row = $(this); 41 const $ticket_details_row = $ticket_selector_row.next('.tckt-slctr-tkt-details-tr'); 42 // get all the specific datetime related classes assigned to this ticket row 43 const ticket_row_datetime_classes = $ticket_selector_row.attr('class').split(' ').filter( 44 function(element) { 45 return element.indexOf('ee-ticket-datetimes-') !== -1; 46 } 47 ); 48 // because a ticket can have multiple datetimes, 49 // we need to compare ALL the ticket's datetimes to see if it will be displayed 50 let display = false; 51 $.each(ticket_row_datetime_classes, function (index, element) { 52 if ($.inArray(element, datetimes) !== -1) { 53 display = true; 54 } 55 }); 56 if (display) { 57 $ticket_selector_row.removeClass('ee-hidden-ticket-tr'); 58 $ticket_details_row.removeClass('ee-hidden-ticket-tr'); 59 active_rows++; 60 } else { 61 $ticket_selector_row.addClass( 'ee-hidden-ticket-tr' ); 62 $ticket_details_row.addClass( 'ee-hidden-ticket-tr' ); 63 const $qty_input = $ticket_selector_row.find('.ticket-selector-tbl-qty-slct'); 64 // set qty to zero for non-radio inputs 65 if ( 66 $qty_input.attr( 'type' ) !== 'checkbox' 67 && $qty_input.attr( 'type' ) !== 'radio' 68 ) { 69 $qty_input.val( 0 ); 70 } 71 } 72 }); 73 } 74 // enable or disable submit button based on active_rows count 75 if (object_exists($submit_button, '$submit_button', false)) { 76 if (active_rows > 0) { 77 $submit_button.removeClass('ee-disabled-btn'); 78 } else { 79 $submit_button.addClass('ee-disabled-btn'); 80 } 81 } 82 83 $('.ticket-selector-disabled-submit-btn-msg').stop().hide(); 84 } 85 ); 86 87 $ticket_selector_submit_btn.on('click', function (e) { 88 if( $( this ).hasClass( 'ee-disabled-btn' ) ) { 89 e.preventDefault(); 90 e.stopPropagation(); 91 $(this).prev('.ticket-selector-disabled-submit-btn-msg').stop().fadeIn(100).delay(6000).fadeOut(); 92 } 93 }); 94 95 const maxChecked = typeof eeDTS !== 'undefined' && eeDTS.maxChecked ? eeDTS.maxChecked : 10; 96 let counter = 0; 97 let prevCounter = 0; 98 let dtsEvent = 0; 99 let thisEvent = 0; 100 let prevEvent = 0; 101 let noticeID = ''; 102 let $notice; 103 $.each( $datetime_options, function() { 104 // need to track previous state 105 prevEvent = thisEvent; 106 prevCounter = counter; 107 thisEvent = $( this ).data( 'tkt_slctr_evt' ); 108 // reset counter when input changes, which is tracked by Event ID 109 counter = thisEvent !== dtsEvent ? 1 : counter + 1; 110 // new DTS for next Event? 111 if ( thisEvent !== dtsEvent ) { 112 // if the previous Event counter was less than the max checked 113 if ( prevCounter > 1 && prevCounter <= maxChecked ) { 114 // then hide the notice re: extra dates cuz there are none 115 noticeID = '#datetime-selector-' + prevEvent; 116 noticeID += '-date-time-filter-notice-pg'; 117 $notice = $( noticeID ); 118 if ( $notice.length ) { 119 $notice.hide(); 120 } 121 } 122 dtsEvent = thisEvent; 123 } 124 if ( maxChecked > 0 && counter > maxChecked ) { 125 return; 126 } 127 $( this ).click(); 128 } ); 129 130 131 $('.display-tckt-slctr-tkt-details').on( 132 'click', 133 function (e) { 134 // get target element from "this" (the control element's) "rel" attribute 135 const target = $(this).attr("rel"); 136 if (target.length) { 137 const $ticket_details_row = $('#' + target + '-dv').closest('.tckt-slctr-tkt-details-tr'); 138 $ticket_details_row.removeClass('ee-hidden-ticket-tr'); 139 if ($ticket_details_row.length) { 140 $ticket_details_row.removeClass('ee-hidden-ticket-tr'); 141 } 142 } 143 e.preventDefault(); 144 e.stopPropagation(); 145 return false;
146 } 147 ); 148 149 $('.hide-tckt-slctr-tkt-details').on( 150 'click', 151 function (e) { 152 // get target element from "this" (the control element's) "rel" attribute 153 const target = $(this).attr("rel"); 154 if (target.length) { 155 const $ticket_details_row = $('#' + target + '-dv').closest('.tckt-slctr-tkt-details-tr'); 156 if ($ticket_details_row.length){ 157 $ticket_details_row.addClass('ee-hidden-ticket-tr'); 158 } 159 } 160 e.preventDefault(); 161 e.stopPropagation(); 162 return false; 163 } 164 ); 165 166 167 168 169 function jiggleRequiredTicketMessage($element) { 170 // try to find the ticket-required paragraph within the same ticket row 171 let $row = $element.closest('.tckt-slctr-tbl-tr'); 172 if (!$row.length) { 173 $row = $element.closest('tr'); 174 } 175 if (!$row.length) { 176 return; 177 } 178 const $msg = $row.find('.ticket-required-pg').first(); 179 if (!$msg.length) { 180 return; 181 } 182 183 if (window.espressoAnnounceToScreenReader) { 184 window.espressoAnnounceToScreenReader($msg.text()); 185 } 186 // add class and ensure repeated triggers restart the timer. 187 $msg.addClass('look-at-meeeeee'); 188 // Remove any existing timeout marker we may have stored and set a new one. 189 // Use data on the element to avoid leaking timers. 190 const existingTimer = $msg.data('lookTimer'); 191 if (existingTimer) { 192 clearTimeout(existingTimer); 193 } 194 const timer = setTimeout(function () { 195 $msg.removeClass('look-at-meeeeee'); 196 $msg.removeData('lookTimer'); 197 }, 2000); 198 199 $msg.data('lookTimer', timer); 200 } 201 202 // Prevent users from unchecking required checkbox qty inputs. 203 // This covers mouse clicks, keyboard activation (spacebar), and a final 204 // safeguard in `change` to re-check if something toggles the input programmatically. 205 // helper to create/show the inline required-message next to the checkbox 206 $(document).on('click', '.ticket-selector-tbl-qty-slct[type="checkbox"][required]', function (e) { 207 // if currently checked, and user tries to uncheck it 208 if ($(this).prop("checked")) { 209 e.preventDefault(); 210 e.stopPropagation(); 211 // ensure it stays checked 212 $(this).prop("checked", true); 213 jiggleRequiredTicketMessage($checkbox); 214 return false; 215 } 216 }); 217 218 // Keyboard support: prevent spacebar toggling off a required checkbox. 219 $(document).on('keydown', '.ticket-selector-tbl-qty-slct[type="checkbox"][required]', function (e) { 220 // spacebar (32) or ' ' in modern browsers 221 if (e.which === 32 || e.key === ' ') { 222 if ($(this).prop("checked")) { 223 e.preventDefault(); 224 e.stopPropagation(); 225 $(this).prop("checked", true); 226 jiggleRequiredTicketMessage($(this)); 227 } 228 } 229 }); 230 231 // Final safeguard: if the input was toggled programmatically, restore the checked state. 232 $(document).on('change', '.ticket-selector-tbl-qty-slct[type="checkbox"][required]', function () { 233 if (!$(this).prop("checked")) { 234 $(this).prop("checked", true); 235 jiggleRequiredTicketMessage($(this)); 236 } 237 }); 238 239});
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.