1( function( $ ) { 2 3 /** 4 * Hook to $( window ).load() to correctly capture the rendered attribute values. 5 * @since 3.5.1.2 6 */ 7 $( window ).ready( function() { 8 9 /** 10 * Payment Method selection. 11 * Expand the first Payment Method in Payment Page. 12 */ 13 setTimeout( function() { 14 let selected_method = $( 'input.tc_choose_gateway:checked' ).val(), 15 max_height = $( 'div#' + selected_method + ' > .inner-wrapper' ).outerHeight(); 16 $( 'div#' + selected_method ).css( { 'max-height': max_height + 'px' } ); 17 }, 500 ); 18 }); 19 20 $( document ).ready( function() { 21 22 const tc_cart = { 23 24 quantity: function() { 25 26 var quantity = 0; 27 $( 'input[name="ticket_quantity[]"]' ).each( function() { 28 quantity = quantity + parseInt( $( this ).val() ); 29 } ); 30 31 return quantity; 32 }, 33 34 /** 35 * Initialize Listeners 36 */ 37 init: function() { 38 tc_cart.tc_empty_cart(); 39 tc_cart.tc_cart_listeners(); 40 }, 41 42 /** 43 * Listeners for add item to cart 44 * 45 * @returns {undefined} 46 */ 47 tc_cart_listeners: function() { 48 49 $( 'body' ).on( 'click', 'input.tc_button_addcart', function() { 50 51 var input = $( this ), 52 formElm = $( input ).parents( 'form.tc_buy_form' ), 53 tempHtml = formElm.html(), 54 serializedForm = formElm.serialize(); 55 56 formElm.html( '<img src="' + tc_ajax.imgUrl + '" alt="' + tc_ajax.addingMsg + '" />' ); 57 58 $.post( tc_ajax.ajaxUrl, serializedForm, function( data ) { 59 60 var result = data.split( '||', 2 ); 61 62 if ( 'error' == result[ 0 ] ) { 63 64 alert( result[ 1 ] ); 65 formElm.html( tempHtml ); 66 tc_cart.tc_cart_listeners(); 67 68 } else { 69 70 formElm.html( '<span class="tc_adding_to_cart">' + tc_ajax.successMsg + '</span>' ); 71 $( 'div.tc_cart_widget_content' ).html( result[ 1 ] ); 72 73 if ( result[ 0 ] > 0 ) { 74 75 formElm.fadeOut( 2000, function() { 76 formElm.html( tempHtml ).fadeIn( 'fast' ); 77 tc_cart.tc_cart_listeners(); 78 } ); 79 80 } else { 81 formElm.fadeOut( 2000, function() { 82 formElm.html( '<span class="tc_no_stock">' + tc_ajax.outMsg + '</span>' ).fadeIn( 'fast' ); 83 tc_cart.tc_cart_listeners(); 84 } ); 85 } 86 87 tc_cart.tc_empty_cart(); // Re-init empty script as the widget was reloaded 88 } 89 } ); 90 return false; 91 } ); 92 }, 93 94 /** 95 * Empty Cart 96 * 97 * @returns {undefined} 98 */ 99 tc_empty_cart: function() { 100 101 if ( $( 'a.tc_empty_cart' ).attr( 'onClick' ) != undefined ) { 102 return; 103 } 104 105 $( 'body' ).on( 'click', 'a.tc_empty_cart', function() { 106 107 var answer = confirm( tc_ajax.empty_cart_message ); 108 109 if ( answer ) { 110 111 $( this ).html( '<img src="' + tc_ajax.imgUrl + '" />' ); 112 113 $.post( tc_ajax.ajaxUrl, { action: 'mp-update-cart', empty_cart: 1 }, function( data ) { 114 $( 'div.tc_cart_widget_content' ).html( data ); 115 } ); 116 } 117 118 return false; 119 } ); 120 } 121 }; 122 123 /** 124 * Check age restriction. 125 * Woocommerce + Bridge for Woocommerce 126 */ 127 $( 'form.checkout' ).on( 'checkout_place_order', function( event ) { 128 if ( $( '#tc_age_check' ).length !== 0 ) { 129 if ( false == $( '#tc_age_check' ).is( ':checked' ) ) { 130 $( '.tc-age-check-error' ).remove(); 131 $( '.tc-age-check-label' ).append( '<span class="tc-age-check-error">' + tc_ajax.tc_error_message + '</span>' ); 132 $( 'html, body' ).stop().animate( { 'scrollTop': ( $( '#tc_age_check' ).offset().top ) - 100 }, 350, 'swing', function() { window.location.hash = target; }); 133 return false; 134 } 135 } 136 } ); 137 138 139 if ( $( '.tc_cart_widget' ).length > 0 ) { 140 141 function tc_update_cart_ajax() { 142 143 $( '.tc_cart_ul' ).css( 'opacity', '0.5' ); 144 145 // Since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php 146 $.post( tc_ajax.ajaxUrl, { 147 action: 'tc_update_widget_cart', 148 nonce: tc_ajax.ajaxNonce 149 }, function( response ) { 150 $( '.tc_cart_ul' ).css( 'opacity', '1' ); 151 $( '.tc_cart_ul' ).html( '' ); 152 $( '.tc_cart_ul' ).html( response ); 153 } ); 154 } 155 156 // Listen DOM changes 157 $( '.event_tickets, .cart_form' ).bind( 'DOMSubtreeModified', tc_update_cart_ajax ); 158 } 159 160 $( document ).on( 'submit', '#tc_payment_form', function() { 161 $( '#tc_payment_confirm' ).attr( 'disabled', 'disabled' ); 162 } ); 163 164 /** 165 * Increase the quantity 166 */ 167 $( 'body' ).on( 'click', 'input.tickera_button.plus', function() { 168 let parentContainer = $( this ).closest( 'td' ), 169 quantity = parentContainer.find( '.quantity' ).val(); 170 parentContainer.find( '.quantity' ).val( parseInt( quantity ) + 1 ); 171 } ); 172 173 /** 174 * Decrease the quantity 175 */ 176 $( 'body' ).on( 'click', 'input.tickera_button.minus', function() { 177 let parentContainer = $( this ).closest( 'td' ), 178 quantity = parentContainer.find( '.quantity' ).val(); 179 if ( quantity >= 1 ) { 180 parentContainer.find( '.quantity' ).val( parseInt( quantity ) - 1 ); 181 } 182 } ); 183 184 /** 185 * When user clicks on the empty cart button 186 */ 187 $( 'body' ).on( 'click', '#empty_cart', function( event ) { 188 189 let proceed = confirm( tc_ajax.empty_cart_confirmation ); 190 191 if ( proceed ) { 192 $( 'input[name="cart_action"]' ).val( 'empty_cart' ); 193 194 } else { 195 event.preventDefault(); 196 } 197 } ); 198 199 /** 200 * When user clicks on the update button 201 */ 202 $( 'body' ).on( 'click', '#update_cart', function() { 203 $( 'input[name="cart_action"]' ).val( 'update_cart' ); 204 } ); 205 206 /** 207 * Toggle Customer Age Checkbox 208 */ 209 $( document ).on( 'change', '#tc_age_check', function() { 210 211 if ( $( this ).is( ':checked' ) ) { 212 $( this ).removeClass( 'has-error' ); 213 $( '.tc-age-check-error' ).remove(); 214 215 } else { 216 $( this ).addClass( 'has-error' ); 217 $( '.tc-age-check-error' ).remove(); 218 $( this ).parent().append( '<span class="tc-age-check-error">' + tc_ajax.tc_error_message + '</span>' ); 219 } 220 } ); 221 222 /** 223 * Tickera Standalone 224 * When user click on the proceed to checkout button, 225 */ 226 var current_quantity = tc_cart.quantity();
227 $( document ).on( 'click', '#proceed_to_checkout', function( event ) { 228 229 // Make sure to update the cart if there's some changes before moving to checkout page. 230 let input_quantity = tc_cart.quantity(); 231 if ( typeof tc_cart.quantity() === 'undefined' || 0 == tc_cart.quantity() || current_quantity != input_quantity ) { 232 event.preventDefault(); 233 234 let target = $( '.tc_cart_errors' ); 235 if ( target.find( 'ul' ).length ) { 236 target.find( 'ul' ).append( '<li>' + tc_ajax.update_cart_message + '</li>' ); 237 238 } else { 239 target.html( '<ul><li>' + tc_ajax.update_cart_message + '</li></ul>' ); 240 } 241 242 $( 'html, body' ).stop().animate( { 'scrollTop': ( target.offset().top ) - 40 }, 350, 'swing', function() { 243 window.location.hash = target; 244 } ); 245 } 246 247 // Make sure confirm age before proceeding to checkout 248 if ( $( '#tc_age_check' ).length ) { 249 let age_confirmation_field = $( '#tc_age_check' ); 250 if ( age_confirmation_field.is( ':checked' ) ) { 251 age_confirmation_field.removeClass( 'has-error' ); 252 $( '.tc-age-check-error' ).remove(); 253 254 } else { 255 event.preventDefault(); 256 $( '.tc-age-check-error' ).remove(); 257 age_confirmation_field.addClass( 'has-error' ); 258 age_confirmation_field.closest( 'label' ).append( '<span class="tc-age-check-error">' + tc_ajax.tc_error_message + '</span>' ); 259 } 260 } 261 } ); 262 263 /** 264 * When user click on the proceed to checkout button 265 */ 266 $( 'body' ).on( 'click', '#apply_coupon', function() { 267 $( 'input[name="cart_action"]' ).val( 'apply_coupon' ); 268 } ); 269 270 /** 271 * Add to cart button 272 */ 273 $( 'body' ).on( 'click', 'a.add_to_cart', function( event ) { 274 275 event.preventDefault(); 276 277 $( this ).fadeOut( 'fast' ).fadeIn( 'fast' ); 278 279 var button_type = $( this ).attr( 'data-button-type' ), 280 open_method = $( this ).attr( 'data-open-method' ), 281 current_form = $( this ).parents( 'form.cart_form' ), 282 ticket_id = current_form.find( '.ticket_id' ).val(), 283 qty = $( this ).closest( 'tr' ).find( '.tc_quantity_selector' ).val(); 284 285 qty = ( typeof qty === 'undefined' ) ? $( this ).closest( '.cart_form' ).find( '.tc_quantity_selector' ).val() : qty; 286 287 $.post( tc_ajax.ajaxUrl, { action: 'add_to_cart', ticket_id: ticket_id, tc_qty: qty, nonce: tc_ajax.ajaxNonce }, function( data ) { 288 289 if ( 'error' != data ) { 290 291 current_form.html( data ); 292 293 if ( $( '.tc_cart_contents' ).length > 0 ) { 294 $.post( tc_ajax.ajaxUrl, { action: 'update_cart_widget', nonce: tc_ajax.ajaxNonce }, function( widget_data ) { 295 $( '.tc_cart_contents' ).html( widget_data ); 296 } ); 297 } 298 299 if ( 'new' == open_method && 'buynow' == button_type ) { 300 window.open( tc_ajax.cart_url, '_blank' ); 301 } 302 303 if ( 'buynow' == button_type && 'new' !== open_method ) { 304 window.location = tc_ajax.cart_url; 305 } 306 307 } else { 308 current_form.html( data ); 309 } 310 } ); 311 } ); 312 313 /** 314 * Cart Widget 315 */ 316 $( 'body' ).on( 'click', '.tc_widget_cart_button', function() { 317 window.location.href = $( this ).data( 'url' ); 318 } ); 319 320 /** 321 * Proceed to checkout button 322 */ 323 $( 'body' ).on( 'click', '#proceed_to_checkout', function() { 324 $( 'input[name="cart_action"]' ).val( 'proceed_to_checkout' ); 325 } ); 326 327 /** 328 * Check email-verification for owner field with Woocommerce 329 */ 330 $( 'form.checkout' ).on( 'click', 'button[type="submit"][name="woocommerce_checkout_place_order"]', function() { 331 332 // Disable "Place Order" button 333 var owner_email = $( '.tc_owner_email' ).val(),
334 owner_confirm_email = $( '.tc_owner_confirm_email' ).val(); 335 336 if ( ( owner_email && owner_confirm_email ) ) { 337 338 if ( ( owner_email !== owner_confirm_email ) || owner_email === "" || owner_confirm_email === "" ) { 339 $( '.tc_owner_email,.tc_owner_confirm_email' ).css( 'border-left', '2px solid #ff0000' ); 340 341 } else { 342 $( '.tc_owner_email,.tc_owner_confirm_email' ).css( 'border-left', '2px solid #09a10f' ); 343 } 344 } 345 } ); 346 347 /** 348 * Payment Method selection. 349 * Accordion effect in Payment Page. 350 */ 351 $( document ).on( 'change', '.tickera-payment-gateways input.tc_choose_gateway', function() { 352 353 let selected_method = $( 'input.tc_choose_gateway:checked' ).val(), 354 parent_container = $( this ).closest( '.tickera-payment-gateways' ), 355 max_height = parent_container.find( 'div#' + selected_method + ' > .inner-wrapper' ).outerHeight(); 356 357 parent_container.siblings().find( '.tc_gateway_form' ).removeAttr( 'style' ); 358 $( 'div#' + selected_method ).css( { 'max-height': max_height + 'px' } ); 359 }); 360 361 /** 362 * Tickera Cart: Preventing Default button to trigger on Enter Key 363 */ 364 $( document ).on( 'keypress', '#tickera_cart input', function( e ) { 365 if ( 13 === e.keyCode ) { 366 e.preventDefault(); 367 $( '#proceed_to_checkout' ).trigger( 'click' ); 368 } 369 } ); 370 371 /** 372 * Payment Gateway Page - Frontend 373 */ 374 $( document ).on( 'keypress', '.tc-numbers-only', function( e ) { 375 if ( e.which != 8 && e.which != 0 && ( e.which < 48 || e.which > 57 ) ) { 376 return false; 377 } 378 } ); 379 380 /** 381 * Update add to cart link value/ticket type id 382 * Event Tickets - Shortcode 383 * Display Type: Dropdown 384 */ 385 $( document ).on( 'change', '.tc-event-dropdown-wrap select.ticket-type-id', function() { 386 387 let wrapper = $( this ).closest( '.tc-event-dropdown-wrap' ), 388 ticketId = $( this ).val(), 389 actionsContainer = wrapper.find( '.actions' ), 390 addToCartContainer = actionsContainer.find( '[id="ticket-type-' + ticketId + '"]' ); 391 392 addToCartContainer.prependTo( actionsContainer ); 393 }); 394 } ); 395 396 /** 397 * Tickera Standalone, Woocommerce + Bridge for Woocommerce 398 * Check custom form error notification 399 */ 400 $( document ).ready( function() { 401 402 /** 403 * Cart/Checkout Form validation 404 */ 405 if ( $( 'form#tickera_cart' ).length || $( 'form.checkout' ).length ) { 406 407 $.validator.addMethod( 'alphanumericOnly', function( value, element ) { 408 if ( ! value ) return true; // Valid if empty value 409 let regex = new RegExp( "^[^<?=^>]+$" ); 410 return ( !regex.test( value ) ) ? false : true; 411 }, tc_ajax.alphanumeric_characters_only ); 412 413 $( 'form#tickera_cart, form.checkout' ).validate( { 414 debug: false, 415 errorClass: 'has-error', 416 validClass: 'valid', 417 highlight: function( element, errorClass, validClass ) { 418 $( element ).addClass( errorClass ).removeClass( validClass ); 419 }, 420 unhighlight: function( element, errorClass, validClass ) { 421 $( element ).removeClass( errorClass ).addClass( validClass ); 422 } 423 } ); 424 425 $( '.tickera-input-field' ).each( function() { 426 427 let field = $( this ), 428 field_type = field.attr( 'type' ), 429 field_name = field.attr( 'name' ); 430 431 if ( ( ( 'text' == field_type && ! field.hasClass( 'checkbox_values' ) ) // Include Text but not checkbox_values 432 || field.is( 'textarea' ) ) // Include Textarea 433 && 'coupon_code' != field_name ) { // Don't include discount field 434 $( this ).rules( 'add', { 435 alphanumericOnly: true 436 } ); 437 } 438 } ); 439 440 $( 'input[name="tc_cart_required[]"]' ).each( function() { 441 let field = $( this ).closest( 'div' ).find( '.tickera-input-field:not( input[type="checkbox"] )' ); 442 field.rules( 'add', { 443 required: { 444 depends: function() { 445 446 let trimmedValue = $( this ).val().trim(); 447 448 if ( ! trimmedValue ) { 449 $( this ).val( $.trim( $( this ).val() ) ); 450 return true; 451 452 } else { 453 return false; 454 } 455 } 456 } 457 } ); 458 } ); 459 460 $( '.tc_validate_field_type_email' ).each( function() { 461 $( this ).rules( 'add', { 462 email: true 463 } ); 464 } ); 465 466 $( '.tc_validate_field_type_confirm_email' ).each( function() { 467 $( this ).rules( 'add', { 468 email: true, 469 equalTo: '.tc_validate_field_type_email', 470 } ); 471 } ); 472 473 $( '.tc_owner_email' ).each( function() { 474 $( this ).rules( 'add', { 475 email: true 476 } ); 477 } ); 478 479 $( '.tc_owner_confirm_email' ).each( function() { 480 481 let owner_email_name = $( this ).attr( 'name' ); 482 owner_email_name = owner_email_name.replace( '_confirm', '' ); 483 484 $( this ).rules( 'add', { 485 email: true, 486 equalTo: 'input[name="' + owner_email_name + '"]', 487 } ); 488 } ); 489 490 /** 491 * Update checkbox values on field change. 492 */ 493 $( document ).on( 'change', '.buyer-field-checkbox, .owner-field-checkbox', function( e ) { 494 495 var checkbox_values_field = $( this ).closest( 'div' ).find( '.checkbox_values' ), 496 values = checkbox_values_field.val().split( ',' ); 497 498 if ( $( this ).is( ':checked' ) ) { 499 values[ values.length ] = $( this ).val(); 500 checkbox_values_field.removeClass( 'has-error' ).addClass( 'valid' ); 501 502 } else { 503 var toRemove = $( this ).val(); 504 values = $.grep( values, function( value ) { 505 return value != toRemove; 506 } ) 507 } 508 509 checkbox_values_field.val( values.filter( e => e ).join() ).focus().blur(); 510 } ); 511 } 512 } ); 513} )( 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.