1/** 2 * Event Ticket script 3 * @version 1.8 4 */ 5jQuery(document).ready(function($){ 6 7// on change variable product selection 8 $('body').on('change','table.variations select',function(){ 9 CART = $(this).closest('table').siblings('.evotx_orderonline_add_cart'); 10 STOCK = CART.find('p.stock'); 11 12 // check if variable products are out of stock 13 if(STOCK.hasClass('out-of-stock')){ 14 CART.find('.variations_button').hide(); 15 }else{ 16 CART.find('.variations_button').show(); 17 } 18 }); 19 20 21// get ticket product total price 22 $('body').on('evotx_qty_changed', function(event,QTY, MAX, OBJ ){ 23 SECTION = OBJ.closest('.evotx_ticket_purchase_section'); 24 $('body').trigger('evotx_calculate_total', [SECTION]); 25 }); 26 27// calculate total price 28 $('body').on('evotx_calculate_total', function(event, SECTION ){ 29 30 QTY = SECTION.find('input[name=quantity]').val(); 31 sin_price = SECTION.find('p.price.tx_price_line span.value').data('sp'); 32 price_extra = 0; 33 34 sin_price = parseFloat(sin_price); 35 36 // include sin price additions 37 if( SECTION.find('p.price.tx_price_line input').length>0){ 38 39 SECTION.find('p.price.tx_price_line input').each(function(){ 40 if( $(this).hasClass('nyp')) return; 41 42 DATA = SECTION.find('p.price.tx_price_line input').data('prices'); 43 44 if(DATA === undefined) return; 45 46 price_muli = 0; 47 price_extra = 0; 48 if( Object.keys(DATA).length>0){ 49 $.each(DATA, function(index, val){ 50 51 if( val === undefined) return; 52 if( !('price') in val) return; 53 if( val.price === undefined) return; 54 55 p = parseFloat(val.price); 56 p = p * parseInt( val.qty); 57 58 if( 'pt' in val && val.pt == 'extra'){ 59 price_extra += p; 60 }else{ 61 price_muli += p; 62 } 63 64 }) 65 } 66 67 sin_price += price_muli; 68 }); 69 } 70 71 new_price = sin_price * QTY; 72 new_price += price_extra; 73 74 75 // formating 76 new_price = get_format_price( new_price, SECTION); 77 SECTION.find('.evotx_addtocart_total span.value').html( new_price); 78 }); 79 80// GET format the price 81 function get_format_price(price, SECTION){ 82 83 // price format data 84 PF = SECTION.find('.evotx_data').data('pf'); 85 86 totalPrice = price.toFixed(PF.numDec); // number of decimals 87 htmlPrice = totalPrice.toString().replace('.', PF.decSep); 88 89 if(PF.thoSep.length > 0) { 90 htmlPrice = _addThousandSep(htmlPrice, PF.thoSep); 91 } 92 if(PF.curPos == 'right') { 93 htmlPrice = htmlPrice + PF.currencySymbol; 94 } 95 else if(PF.curPos == 'right_space') { 96 htmlPrice = htmlPrice + ' ' + PF.currencySymbol; 97 } 98 else if(PF.curPos == 'left_space') { 99 htmlPrice = PF.currencySymbol + ' ' + htmlPrice; 100 } 101 else { 102 htmlPrice = PF.currencySymbol + htmlPrice; 103 } 104 return htmlPrice; 105 } 106 function _addThousandSep(n, thoSep){ 107 var rx= /(\d+)(\d{3})/; 108 return String(n).replace(/^\d+/, function(w){ 109 while(rx.test(w)){ 110 w= w.replace(rx, '$1'+thoSep+'$2'); 111 } 112 return w; 113 }); 114 }; 115 116// increase and reduce quantity 117 $('body').on('click','.evotx_qty_change', function(event){ 118 119 OBJ = $(this); 120 121 if(OBJ.closest('.evotx_quantity').hasClass('one')) return; 122 123 QTY = parseInt(OBJ.siblings('em').html()); 124 MAX = OBJ.siblings('input').data('max'); 125 126 // plug
127 $('body').trigger('evotx_before_qty_changed',[ MAX, OBJ]); 128 129 if(!MAX) MAX = OBJ.siblings('input').attr('max'); 130 131 132 NEWQTY = (OBJ.hasClass('plu'))? QTY+1: QTY-1; 133 134 NEWQTY =(NEWQTY <= 0)? 0: NEWQTY; 135 136 137 // can not go below 1 138 if( NEWQTY == 0 && OBJ.hasClass('min') && !OBJ.hasClass('zpos')){ 139 return; 140 } 141 142 NEWQTY = (MAX!='' && NEWQTY > MAX)? MAX: NEWQTY; 143 144 OBJ.siblings('em').html(NEWQTY); 145 OBJ.siblings('input').val(NEWQTY); 146 147 if( QTY != NEWQTY) $('body').trigger('evotx_qty_changed',[NEWQTY, MAX, OBJ]); 148 149 if(NEWQTY == MAX){ 150 151 PLU = OBJ.parent().find('b.plu'); 152 if(!PLU.hasClass('reached')) PLU.addClass('reached'); 153 154 if(QTY == MAX) $('body').trigger('evotx_qty_max_reached',[NEWQTY, MAX, OBJ]); 155 }else{ 156 OBJ.parent().find('b.plu').removeClass('reached'); 157 } 158 }); 159 160// on triggers for variations form 161 $('body').on('reset_data','form.evotx_orderonline_variable',function(event){ 162 FORM = $(this); 163 FORM.find('.evotx_variation_purchase_section').hide(); 164 }); 165 166 $('body').on('evolightbox_end',function(){ 167 $('body').trigger('show_variation'); 168 }); 169 $('body').on('show_variation','form.evotx_orderonline_variable',function(event, variation, purchasable){ 170 FORM = $(this); 171 172 // variation not in stock 173 if(!variation.is_in_stock){ 174 FORM.find('.evotx_variations_soldout').show(); 175 FORM.find('.evotx_variation_purchase_section').hide(); 176 }else{ 177 FORM.find('.evotx_variations_soldout').hide(); 178 FORM.find('.evotx_variation_purchase_section').show(); 179 } 180 181 if(variation.sold_individually){ 182 FORM.find('.evotx_quantity').hide(); 183 } 184 185 NEWQTY = parseInt(FORM.find('.evotx_quantity_adjuster em').html()); 186 NEWQTY = (variation.max_qty!= '' && NEWQTY > variation.max_qty)? variation.max_qty: NEWQTY; 187 188 FORM.find('.evotx_quantity_adjuster em').html( NEWQTY); 189 FORM.find('.evotx_quantity_adjuster input').val( NEWQTY); 190 }); 191 192// Standalone button 193 $('body').on('click','.trig_evotx_btn',function(){ 194 LIGHTBOX = $('.evotx_lightbox'); 195 LIGHTBOX.addClass('show'); 196 $('body').trigger('evolightbox_show'); 197 198 199 // get form html 200 var ajaxdataa = {}; 201 202 ajaxdataa['action'] = 'evotx_standalone_form'; 203 ajaxdataa['eid'] = parseInt($(this).data('eid')); 204 ajaxdataa['ri'] = parseInt($(this).data('ri')); 205 $.ajax({
206 beforeSend: function(){ 207 LIGHTBOX.find('.evo_lightbox_body').addClass('evoloading').html('<p class="loading_content"></p>'); 208 }, 209 url: evotx_object.ajaxurl, 210 data: ajaxdataa, dataType:'json', type: 'POST', 211 success:function(data){ 212 213 LIGHTBOX.find('.evo_lightbox_body').html( data.html ); 214 215 },complete:function(){ 216 LIGHTBOX.find('.evo_lightbox_body').removeClass('evoloading'); 217 } 218 }); 219 220 221 }); 222 223// Add to cart custom method 224// this method is used by ticket addons when adding tickets to cart and simple ticket product 225// @version 1.7 up 226 $('body').on('click', '.evotx_addtocart', function(event){ 227 228 event.preventDefault(); 229 230 var ajaxdata = {}; 231 232 // make sure the button is good to go 233 if( $(this).data('green') != 'y') return; 234 235 var BTN = $(this); 236 var SECTION = BTN.closest('.evotx_ticket_purchase_section'); 237 var EVOROW = BTN.closest('.evorow'); 238 var EVOTX_DATA = SECTION.find('.evotx_data'); 239 240 ajaxdata['qty'] = SECTION.find('input[name="quantity"]').val(); 241 ajaxdata['nyp'] = SECTION.find('input[name="nyp"]').val(); 242 ajaxdata['action'] = 'evotx_add_to_cart'; 243 ajaxdata['data'] = EVOTX_DATA.data(); 244 245 if( ajaxdata['qty'] === undefined && BTN.hasClass('si')) ajaxdata['qty'] = 1; 246 247 // gather other input fields 248 SECTION.find('input').each(function(){ 249 if( $(this).attr('name') === undefined) return; 250 if( $(this).attr('name') == 'add-to-cart') return; 251 ajaxdata[ $(this).attr('name') ] = $(this).val(); 252 }); 253 254 // check for quantity 255 if( ajaxdata.qty== undefined || ajaxdata.qty=='' || ajaxdata.qty == 0){ 256 $('body').trigger('evotx_ticket_msg',[EVOROW,'bad', 't5' ]); 257 return false; 258 } 259 260 $.ajax({
261 beforeSend: function(){ EVOROW.addClass( 'evoloading'); }, 262 url: evotx_object.ajaxurl, 263 data: ajaxdata, dataType:'json', type: 'POST', 264 success:function(data){ 265 266 if( data.status == 'good'){ 267 268 $('body').trigger('evotx_added_to_cart',[ data, SECTION]); 269 $('body').trigger('evotx_ticket_msg',[EVOROW,'good']); 270 271 // if need to be redirected to cart after adding 272 if(evotx_object.redirect_to_cart == 'cart'){ 273 window.location.href = evotx_object.cart_url; 274 }else if( evotx_object.redirect_to_cart =='checkout'){ 275 window.location.href = evotx_object.checkout_url; 276 }else{ 277 $('body').trigger('evo_update_wc_cart'); 278 } 279 }else{ 280 $('body').trigger('evotx_ticket_msg', [EVOROW,'bad', data.msg]); 281 } 282 283 },complete:function(){ 284 EVOROW.removeClass( 'evoloading'); 285 } 286 }); 287 }); 288 289// name your price 290 $(document).on('keypress',function(e){ 291 var obj = $(e.target); 292 if(e.which == 13 && obj.hasClass('nyp') ){ 293 e.preventDefault(); 294 return; 295 } 296 }); 297 $('body').on('change','input.nyp',function(){ 298 299 var EVOROW = $(this).closest('.evorow'); 300 301 var raw_new = $(this).val(); 302 303 $(this).parent().data('sp', raw_new); 304 305 var new_price = Number(raw_new.replace(/[^0-9.-]+/g,"")); 306 //var new_price = parseFloat( raw_new ); 307 308 309 var min_nyp = parseFloat($(this).data('minnyp')); 310 311 // min price higher than 0 312 if( min_nyp > 0 ){ 313 // price is less than minimum 314 if(new_price < min_nyp){ 315 evotx_DATA = $(EVOROW).find('.evotx_data').data('t'); 316 $('body').trigger('evotx_ticket_msg', [EVOROW,'bad', evotx_DATA.t6,false]); 317 EVOROW.find('.evotx_addtocart').data('green','n'); 318 // price is good 319 }else{ 320 EVOROW.find('.evotx_addtocart').data('green','y'); 321 $('body').trigger('evotx_ticket_msg_hide', [EVOROW]); 322 $('body').trigger('evotx_calculate_total', [ $(this).closest('.evotx_ticket_purchase_section') ]); 323 } 324 // minimum price less than 0 325 }else{ 326 $('body').trigger('evotx_calculate_total', [ $(this).closest('.evotx_ticket_purchase_section') ]); 327 } 328 }); 329 330// repopulate evotx_data data values 331 $('body').on('evotx_repopulate_evotx_data', function(event, EVOROW, data){ 332 evotx_DATA = $(EVOROW).find('.evotx_data'); 333 $.each(data, function(index, value){ 334 evotx_DATA.data( index, value); 335 }); 336 }); 337 338// Show add to cart notification messages 339 $('body').on('evotx_ticket_msg', function(event, EVOROW, STATUS, bad_msg, hide_hidables){ 340 MSG = $(EVOROW).find('.evotx_addtocart_msg'); 341 342 if( !MSG) return false; // if add to cart message section is not present 343 344 evotx_DATA = $(EVOROW).find('.evotx_data').data('t'); 345 346 console.log(evotx_DATA); 347 348 if(evotx_DATA === undefined) return false; 349 350 HTML = ''; 351 if( STATUS == 'good'){ 352 target = evotx_object.tBlank? 'target="_blank"':''; 353 HTML += "<p class='evotx_success_msg'><b>" + evotx_DATA.t1+"</b>"; 354 HTML +="<span><a class='evcal_btn' href='"+evotx_object.cart_url+"' "+target+">"+evotx_DATA.t2 +"</a><a class='evcal_btn' href='"+evotx_object.checkout_url+"' "+target+">"+evotx_DATA.t3+"</a></span></p>"; 355 356 }else{ 357 bad_msg = bad_msg? 358 (bad_msg in evotx_DATA? evotx_DATA[bad_msg] : bad_msg) 359 : evotx_DATA.t4; 360 HTML += "<p class='evotx_success_msg bad'><b>" +bad_msg+"</b>"; 361 } 362 363 //console.log( hide_hidables); 364 365 if( hide_hidables === undefined) hide_hidables = true; 366 367 // hiding message afterwards 368 MSG_int = $(EVOROW).find('.evotx_data').data('msg_interaction'); 369 370 //console.log(MSG_int); 371 if( MSG_int.hide_after == true ){ 372 setTimeout(function(){ 373 $('body').trigger('evotx_ticket_msg_hide', [EVOROW]); 374 }, 3000); 375 } 376 377 // redirecting 378 if(MSG_int.redirect != 'nonemore' && hide_hidables){ 379 // hide only the hidable section 380 $(EVOROW).find('.evotx_hidable_section').hide(); 381 } 382 383 MSG.html(HTML).show(); 384 });
385 $('body').on('evotx_ticket_msg_hide',function(event, EVOROW){ 386 $(EVOROW).find('.evotx_addtocart_msg').hide(); 387 }); 388 389// click add to cart for variable product 390// OLD Method 391 $('body').on('click','.evoAddToCart', function(e){ 392 393 e.preventDefault(); 394 thisButton = $(this); 395 396 // loading animation 397 thisButton.closest('.evoTX_wc').addClass('evoloading'); 398 399 // Initial 400 TICKET_ROW = thisButton.closest('.evo_metarow_tix'); 401 PURCHASESEC = TICKET_ROW.find('.evoTX_wc'); 402 403 // set cart item additional data 404 var ticket_row = thisButton.closest('.evo_metarow_tix'); 405 var event_id = ticket_row.attr('data-event_id'); 406 var ri = ticket_row.attr('data-ri'); 407 var lang = thisButton.data('l'); 408 var event_location = thisButton.closest('.evcal_eventcard').find('.evo_location_name').html(); 409 410 event_location = (event_location !== undefined && event_location != '' )? 411 encodeURIComponent(event_location):''; 412 413 // passing location values 414 location_str = event_location!= ''? '&eloc='+event_location: ''; 415 416 // pass lang 417 lang_str = ( lang !== undefined)? '&lang='+lang:''; 418 419 //console.log(event_location); 420 421 // variable item 422 if(thisButton.hasClass('variable_add_to_cart_button')){ 423 424 var variation_form = thisButton.closest('form.variations_form'), 425 variations_table = variation_form.find('table.variations'), 426 singleVariation = variation_form.find('.single_variation p.stock'); 427 428 // Stop processing is out of stock 429 if(singleVariation.hasClass('out-of-stock')){ 430 return; 431 } 432 433 var product_id = parseInt(variation_form.attr('data-product_id')); 434 var variation_id = parseInt(variation_form.find('input[name=variation_id]').val()); 435 var quantity = parseInt(variation_form.find('input[name=quantity]').val()); 436 437 quantity = (quantity=== undefined || quantity == '' || isNaN(quantity)) ? 1: quantity; 438 439 values = variation_form.serialize(); 440 441 var attributes =''; 442 variations_table.find('select').each(function(index){ 443 attributes += '&'+ $(this).attr('name') +'='+ $(this).val(); 444 }); 445 446 // get data from the add to cart form 447 dataform = thisButton.closest('.variations_form').serializeArray(); 448 var data_arg = dataform; 449 450 $.ajax({
451 type: 'POST',data: data_arg, 452 url: '?add-to-cart='+product_id+'&variation_id='+variation_id+attributes+'&quantity='+quantity +'&ri='+ri+'&eid='+event_id + location_str + lang_str, 453 beforeSend: function(){ 454 $('body').trigger('adding_to_cart'); 455 }, 456 success: function(response, textStatus, jqXHR){ 457 458 // Show success message 459 $('body').trigger('evotx_ticket_msg',[TICKET_ROW,'good']); 460 461 }, complete: function(){ 462 thisButton.closest('.evoTX_wc').removeClass('evoloading'); 463 464 // if need to be redirected to cart after adding 465 if(evotx_object.redirect_to_cart == 'cart'){ 466 window.location.href = evotx_object.cart_url; 467 }else if( evotx_object.redirect_to_cart =='checkout'){ 468 window.location.href = evotx_object.checkout_url; 469 }else{ 470 update_wc_cart(); 471 } 472 } 473 }); 474 } 475 476 // simple product add to cart method is deprecated since 1.8 477 return false; 478 }); 479 480// Update mini cart content 481 $('body').on('evo_update_wc_cart',function(){ 482 update_wc_cart(); 483 }); 484 function update_wc_cart(){ 485 var data = { 486 action: 'evoTX_ajax_09' 487 }; 488 $.ajax({
489 type:'POST',url:evotx_object.ajaxurl, 490 data:data, 491 dataType:'json', 492 success:function(data){ 493 494 if (!data) return; 495 496 var this_page = window.location.toString(); 497 this_page = this_page.replace( 'add-to-cart', 'added-to-cart' ); 498 499 var fragments = data.fragments; 500 var cart_hash = data.cart_hash; 501 502 // Block fragments class 503 fragments && $.each(fragments, function (key, value) { 504 $(key).addClass('updating'); 505 }); 506 507 // Block fragments class 508 if ( fragments ) { 509 $.each( fragments, function( key ) { 510 $( key ).addClass( 'updating' ); 511 }); 512 } 513 514 // Block widgets and fragments 515 $( '.shop_table.cart, .updating, .cart_totals' ) 516 .fadeTo( '400', '0.6' ) 517 .block({ 518 message: null, 519 overlayCSS: { 520 opacity: 0.6 521 } 522 }); 523 524 // Replace fragments 525 if ( fragments ) { 526 $.each( fragments, function( key, value ) { 527 $( key ).replaceWith( value ); 528 }); 529 530 $( document.body ).trigger( 'wc_fragments_loaded' ); 531 } 532 533 // Unblock 534 $( '.widget_shopping_cart, .updating' ).stop( true ).css( 'opacity', '1' ).unblock(); 535 536 // Cart page elements 537 $( '.shop_table.cart' ).load( this_page + ' .shop_table.cart:eq(0) > *', function() { 538 539 $( '.shop_table.cart' ).stop( true ).css( 'opacity', '1' ).unblock(); 540 541 $( document.body ).trigger( 'cart_page_refreshed' ); 542 }); 543 544 $( '.cart_totals' ).load( this_page + ' .cart_totals:eq(0) > *', function() { 545 $( '.cart_totals' ).stop( true ).css( 'opacity', '1' ).unblock(); 546 }); 547 548 // Trigger event so themes can refresh other areas 549 $( document.body ).trigger( 'added_to_cart', [ fragments, cart_hash ] ); 550 } 551 }); 552 } 553 554// inquiry submissions 555 $('body').on('click','.evotx_INQ_btn', function(){ 556 $(this).siblings('.evotxINQ_box').slideToggle(); 557 }); 558 $('body').on('click','.evotx_INQ_submit', function(event){ 559 event.preventDefault(); 560 var form = $(this).closest('.evotxINQ_form'); 561 var notif = form.find('.notif'); 562 563 //reset 564 form.find('.evotxinq_field').removeClass('error'); 565 566 //reset notification 567 notif.html( notif.attr('data-notif') ); 568 569 var data = { 570 action: 'evoTX_ajax_06', 571 event_id: form.attr('data-event_id'), 572 ri: form.attr('data-ri'), 573 }; 574 575 error = 'none'; 576 form.find('.evotxinq_field').each(function(index){ 577 if( $(this).val()==''){ 578 error='yes'; 579 $(this).addClass('error'); 580 } 581 data[$(this).attr('name')] = $(this).val(); 582 }); 583 584 // validate captcha 585 var human = validate_human( form.find('input.captcha') ); 586 if(!human){ 587 form.find('input.captcha').addClass('error'); 588 error=3; 589 } 590 591 if(error=='none'){ 592 $.ajax({
593 type:'POST',url:evotx_object.ajaxurl, 594 data:data, 595 beforeSend: function(){ 596 form.addClass('loading'); 597 },success:function(data){ 598 form.slideUp(); 599 form.siblings('.evotxINQ_msg').fadeIn(function(){ 600 form.removeClass('loading'); 601 }); 602 } 603 }); 604 }else{ 605 notif.html( form.attr('data-err') ); 606 } 607 }); 608 // validate humans 609 function validate_human(field){ 610 if(field==undefined){ 611 return true; 612 }else{ 613 var numbers = ['11', '3', '6', '3', '8']; 614 if(numbers[field.attr('data-cal')] == field.val() ){ 615 return true; 616 }else{ return false;} 617 } 618 } 619 620// add to cart button from eventtop 621 $('body').on('click','.evotx_add_to_cart em', function(){ }); 622 623 // hover over guests list icons 624 $('body').on('mouseover','.evotx_whos_coming span', function(){ 625 name = $(this).attr('data-name'); 626 html = $(this).html(); 627 $(this).html(name).attr('data-intials', html).addClass('hover'); 628 }); 629 $('body').on('mouseout','.evotx_whos_coming span', function(){ 630 $(this).html( $(this).attr('data-intials')).removeClass('hover'); 631 }); 632 633// ActionUser event manager 634 // show ticket stats for events 635 $('#evoau_event_manager').on('click','a.load_tix_stats',function(event){ 636 event.preventDefault(); 637 MANAGER = $(this).closest('.evoau_manager'); 638 var data_arg = { 639 action: 'evotx_ajax_get_auem_stats', 640 eid: $(this).data('eid') 641 }; 642 $.ajax({
643 beforeSend: function(){ 644 MANAGER.find('.eventon_actionuser_eventslist').addClass('evoloading'); 645 }, 646 type: 'POST', 647 url:evotx_object.ajaxurl, 648 data: data_arg, 649 dataType:'json', 650 success:function(data){ 651 $('body').trigger('evoau_show_eventdata',[MANAGER, data.html, true]); 652 },complete:function(){ 653 MANAGER.find('.eventon_actionuser_eventslist').removeClass('evoloading'); 654 } 655 }); 656 }); 657 658 // check in attendees 659 $('body').on('click','.evotx_status', function(){ 660 var obj = $(this); 661 if(obj.hasClass('refunded')) return false; 662 if( obj.data('gc')== false) return false; 663 664 var data_arg = { 665 action: 'the_ajax_evotx_a5', 666 tid: obj.data('tid'), 667 tiid: obj.data('tiid'), 668 status: obj.data('status'), 669 }; 670 $.ajax({
671 beforeSend: function(){ obj.html( obj.html()+'...' ); }, 672 type: 'POST', 673 url:evotx_object.ajaxurl, 674 data: data_arg, 675 dataType:'json', 676 success:function(data){ 677 obj.data('status', data.new_status) 678 obj.html(data.new_status_lang).removeAttr('class').addClass('evotx_status '+ data.new_status); 679 680 } 681 }); 682 }); 683 // open incompleted orders 684 $('.evoau_manager_event_content').on('click','span.evotx_incomplete_orders',function(){ 685 $(this).closest('table').find('td.hidden').toggleClass('bad'); 686 }); 687});
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.