File Editor
Directories:
.. (Back)
admin
app
commerce
v2
Files:
accordion.js
accordion.min.js
move-tickets-dialog.js
move-tickets-dialog.min.js
rsvp-block.js
rsvp-block.min.js
rsvp.js
rsvp.min.js
ticket-details.js
ticket-details.min.js
tickets-attendees.js
tickets-attendees.min.js
tickets-block.js
tickets-block.min.js
tickets-provider.js
tickets-provider.min.js
tickets-registration-page.js
tickets-registration-page.min.js
tickets.js
tickets.min.js
tpp-admin.js
tpp-admin.min.js
Create New File
Create
Edit File: tickets-block.min.js
/** * This JS file was auto-generated via Terser. * * Contributors should avoid editing this file, but instead edit the associated * non minified file file. For more information, check out our engineering docs * on how we handle JS minification in our engineering docs. * * @see: https://evnt.is/dev-docs-minification */ void 0===window.tribe&&(window.tribe={}),window.tribe.tickets=window.tribe.tickets||{},window.tribe.dialogs=window.tribe.dialogs||{},window.tribe.dialogs.events=window.tribe.dialogs.events||{},window.tribe.tickets.block={num_attendees:0,event:{}},function($,obj,tde){obj.selector={blockFooter:".tribe-tickets__footer",blockFooterAmount:".tribe-amount",blockFooterQuantity:".tribe-tickets__footer__quantity__number",blockSubmit:"#tribe-tickets__submit",classicSubmit:"#tribe-tickets__buy",container:"#tribe-tickets",hidden:"tribe-common-a11y-hidden",item:".tribe-tickets__item",itemExtraAvailable:".tribe-tickets__item__extra__available",itemExtraAvailableQuantity:".tribe-tickets__item__extra__available__quantity",itemOptOut:".tribe-tickets-attendees-list-optout--wrapper",itemOptOutInput:"#tribe-tickets-attendees-list-optout-",itemPrice:".tribe-tickets__sale_price .tribe-amount",itemQuantity:".tribe-tickets__item__quantity",itemQuantityInput:".tribe-tickets-quantity",loader:".tribe-common-c-loader",submit:".tribe-tickets__buy",ticketLoader:".tribe-tickets-loader__tickets-block",validationNotice:".tribe-tickets__notice--error",ticketInCartNotice:"#tribe-tickets__notice__tickets-in-cart",horizontal_datepicker:{container:".tribe_horizontal_datepicker__container",select:".tribe_horizontal_datepicker__container select",day:".tribe_horizontal_datepicker__day",month:".tribe_horizontal_datepicker__month",year:".tribe_horizontal_datepicker__year",value:".tribe_horizontal_datepicker__value"}};const $tribeTicket=$(obj.selector.container);0!==$tribeTicket.length&&(obj.document=$(document),obj.modalSelector={cartForm:".tribe-modal__wrapper--ar #tribe-modal__cart",container:".tribe-modal__wrapper--ar",form:"#tribe-tickets__modal-form",itemRemove:".tribe-tickets__item__remove",itemTotal:".tribe-tickets__item__total .tribe-amount",loader:".tribe-tickets-loader__modal",metaField:".ticket-meta",metaForm:".tribe-modal__wrapper--ar #tribe-modal__attendee_registration",metaItem:".tribe-ticket",submit:".tribe-block__tickets__item__attendee__fields__footer_submit"},obj.commerceSelector={edd:"Tribe__Tickets_Plus__Commerce__EDD__Main",rsvp:"Tribe__Tickets__RSVP",tpp:"Tribe__Tickets__Commerce__PayPal__Main",Tribe__Tickets__Commerce__PayPal__Main:"tribe-commerce",Tribe__Tickets__RSVP:"rsvp",Tribe__Tickets_Plus__Commerce__EDD__Main:"edd",Tribe__Tickets_Plus__Commerce__WooCommerce__Main:"woo",tribe_eddticket:"Tribe__Tickets_Plus__Commerce__EDD__Main",tribe_tpp_attendees:"Tribe__Tickets__Commerce__PayPal__Main",tribe_wooticket:"Tribe__Tickets_Plus__Commerce__WooCommerce__Main",woo:"Tribe__Tickets_Plus__Commerce__WooCommerce__Main"},obj.tribe_ticket_provider=$tribeTicket.data("provider"),obj.postId=TribeTicketOptions.post_id,obj.init=function(){0<TribeTicketOptions.availability_check_interval&&obj.checkAvailability(),TribeTicketOptions.ajax_preload_ticket_form&&(obj.loaderShow(),obj.initPrefill()),obj.disable($(obj.selector.submit),!0)},obj.updateAvailability=function(tickets){Object.keys(tickets).forEach((function(ticketId){const available=tickets[ticketId].available,maxPurchase=tickets[ticketId].max_purchase,$ticketEl=$(obj.selector.item+'[data-ticket-id="'+ticketId+'"]');if(0===available){const unavailableHtml=tickets[ticketId].unavailable_html;$ticketEl.attr("available",!1),$ticketEl.removeClass("instock"),$ticketEl.removeClass("purchasable"),$ticketEl.find(obj.selector.itemQuantity).html(unavailableHtml),$ticketEl.find(obj.selector.itemExtraAvailable).html("")}1<available&&($ticketEl.find(obj.selector.itemQuantityInput).attr({max:maxPurchase}),$ticketEl.find(obj.selector.itemExtraAvailableQuantity).html(available))}))},obj.updateFooter=function($form){obj.updateFooterCount($form),obj.updateFooterAmount($form),$form.find(".tribe-tickets__footer").addClass("tribe-tickets__footer--active")},obj.updateFooterCount=function($form){const $field=$form.find(obj.selector.blockFooter+" "+obj.selector.blockFooterQuantity);let footerCount=0;$form.find(obj.selector.item+" "+obj.selector.itemQuantityInput).each((function(){let newQuantity=parseInt($(this).val(),10);newQuantity=isNaN(newQuantity)?0:newQuantity,footerCount+=newQuantity}));const disabled=0>=footerCount;obj.disable($(obj.selector.submit),disabled),0>footerCount||$field.text(footerCount)},obj.updateFooterAmount=function($form){const $field=$form.find(obj.selector.blockFooter+" "+obj.selector.blockFooterAmount);let footerAmount=0;$form.find(obj.selector.item+" "+obj.selector.itemQuantityInput).each((function(){const $price=$(this).closest(obj.selector.item).find(obj.selector.itemPrice).first();let quantity=parseInt($(this).val(),10);quantity=isNaN(quantity)?0:quantity;let text=$price.text();text=obj.cleanNumber(text);footerAmount+=text*quantity})),0>footerAmount||$field.text(obj.numberFormat(footerAmount))},obj.updateFormTotals=function($cart){obj.updateFooter($cart),obj.appendARFields($cart)},obj.updateItem=function(id,$modalCartItem,$blockCartItem){const item={};if(item.id=id,$blockCartItem){item.qty=obj.getQty($blockCartItem),item.price=obj.getPrice($modalCartItem),$modalCartItem.find(obj.selector.itemQuantityInput).val(item.qty).trigger("change");const optoutSelector=obj.selector.itemOptOutInput+$blockCartItem.data("ticket-id");item.$optOut=$(optoutSelector);const $optoutInput=$(optoutSelector+"-modal");item.$optOut.length&&item.$optOut.is(":checked")?$optoutInput.val("1"):$optoutInput.val("0")}else item.qty=obj.getQty($modalCartItem),item.price=obj.getPrice($modalCartItem);return obj.updateTotal(item.qty,item.price,$modalCartItem),item},obj.updateTotal=function(qty,price,$cartItem){const totalForItem=(qty*price).toFixed(obj.getCurrencyFormatting().number_of_decimals);return $cartItem.find(obj.modalSelector.itemTotal).text(obj.numberFormat(totalForItem)),totalForItem},obj.maybeShowNonMetaNotice=function($form){let nonMetaCount=0,metaCount=0;const $cartItems=$form.find(obj.selector.item).filter((function(){return $(this).find(obj.selector.itemQuantityInput).val()>0}));if(!$cartItems.length)return;$cartItems.each((function(){const $cartItem=$(this),ticketID=$cartItem.closest(obj.selector.item).data("ticket-id");$(obj.modalSelector.metaForm).find('.tribe-tickets__item__attendee__fields__container[data-ticket-id="'+ticketID+'"]').length?metaCount+=obj.getQty($cartItem):nonMetaCount+=obj.getQty($cartItem)}));const $notice=$(".tribe-tickets__notice--non-ar"),$title=$(".tribe-tickets__item__attendee__fields__title");0<nonMetaCount&&0<metaCount?($("#tribe-tickets__non-ar-count").text(nonMetaCount),$notice.removeClass("tribe-common-a11y-hidden"),$title.show()):($notice.addClass("tribe-common-a11y-hidden"),$title.hide())},obj.getRestEndpoint=function(){return TribeCartEndpoint.url},obj.getTickets=function(){return $(obj.selector.item).map((function(){return $(this).data("ticket-id")})).get()},obj.maybeShowOptOut=function($ticket,newQuantity){if($ticket.has(obj.selector.itemOptOut).length){const $item=$ticket.closest(obj.selector.item);0<newQuantity?$item.addClass("show-optout"):$item.removeClass("show-optout")}},obj.appendARFields=function($form){$form.find(obj.selector.item).each((function(){const $cartItem=$(this);if($cartItem.is(":visible")){const ticketID=$cartItem.closest(obj.selector.item).data("ticket-id"),$ticketContainer=$(obj.modalSelector.metaForm).find('.tribe-tickets__item__attendee__fields__container[data-ticket-id="'+ticketID+'"]');if(!$ticketContainer.length)return;const $existing=$ticketContainer.find(obj.modalSelector.metaItem),qty=obj.getQty($cartItem);if(0>=qty)return $ticketContainer.removeClass("tribe-tickets--has-tickets"),void $ticketContainer.find(obj.modalSelector.metaItem).remove();if($existing.length>qty){const removeCount=$existing.length-qty;$ticketContainer.find(".tribe-ticket:nth-last-child( -n+"+removeCount+" )").remove()}else if($existing.length<qty){const ticketTemplate=window.wp.template("tribe-registration--"+ticketID),counter=0<$existing.length?$existing.length+1:1;$ticketContainer.addClass("tribe-tickets--has-tickets");for(let i=counter;i<=qty;i++){const data={attendee_id:i};$ticketContainer.append(ticketTemplate(data)),obj.maybeHydrateAttendeeBlockFromLocal($existing.length)}}}})),obj.maybeShowNonMetaNotice($form),obj.loaderHide(),obj.document.trigger("tribe-ar-fields-appended")},obj.stepUp=function($input,originalValue){const max=$input.attr("max")?Number($input.attr("max")):-1,step=$input.attr("step")?Number($input.attr("step")):1;let newValue=-1===max||max>=originalValue+step?originalValue+step:max;const $parent=$input.closest(obj.selector.item);if("true"===$parent.attr("data-has-shared-cap")){const $form=$parent.closest("form");newValue=obj.checkSharedCapacity($form,newValue)}if(0!==newValue)if(0>newValue)$input[0].value=originalValue+newValue;else if("function"==typeof $input[0].stepUp)try{if(max<originalValue+step)return;$input[0].stepUp()}catch(ex){$input.val(newValue)}else $input.val(newValue)},obj.stepDown=function($input,originalValue){const min=$input.attr("min")?Number($input.attr("min")):0,step=$input.attr("step")?Number($input.attr("step")):1,decrease=min<=originalValue-step&&0<originalValue-step?originalValue-step:min;if("function"==typeof $input[0].stepDown)try{$input[0].stepDown()}catch(ex){$input[0].value=decrease}else $input[0].value=decrease},obj.checkAvailability=function(){const params={action:"ticket_availability_check",tickets:obj.getTickets()};$.post(TribeTicketOptions.ajaxurl,params,(function(response){if(!response.success)return;const tickets=response.data.tickets;obj.updateAvailability(tickets)})),0<TribeTicketOptions.availability_check_interval&&setTimeout(obj.checkAvailability,TribeTicketOptions.availability_check_interval)},obj.checkSharedCapacity=function($form,qty){let sharedCap=[],currentLoad=[];const $sharedTickets=$form.find(obj.selector.item).filter('[data-has-shared-cap="true"]'),$sharedCapTickets=$sharedTickets.find(obj.selector.itemQuantityInput);if(!$sharedTickets.length)return qty;$sharedTickets.each((function(){sharedCap.push(parseInt($(this).attr("data-shared-cap"),10))})),$sharedCapTickets.each((function(){currentLoad.push(parseInt($(this).val(),10))})),sharedCap=Math.max.apply(this,sharedCap),currentLoad=currentLoad.reduce((function(a,b){return a+b}),0);const currentAvailable=sharedCap-currentLoad;return Math.min(currentAvailable,qty)},obj.getQty=function($cartItem){const qty=parseInt($cartItem.find(obj.selector.itemQuantityInput).val(),10);return isNaN(qty)?0:qty},obj.getPrice=function($cartItem){const price=obj.cleanNumber($cartItem.find(obj.selector.itemPrice).first().text());return isNaN(price)?0:price},obj.getCurrencyFormatting=function(){return JSON.parse(TribeCurrency.formatting)[obj.tribe_ticket_provider]},obj.cleanNumber=function(passedNumber){let number=passedNumber;const format=obj.getCurrencyFormatting();if(0===parseInt(format.number_of_decimals)&&""===format.thousands_sep)return number;if(format.thousands_sep===format.decimal_point){const decPlace=number.length-(format.number_of_decimals+1);number=number.substr(0,decPlace)+"_"+number.substr(decPlace+1),""!==format.thousands_sep&&(number=number.split(format.thousands_sep).join("")),number=number.split("_").join(".")}else""!==format.thousands_sep&&(number=number.split(format.thousands_sep).join("")),""!==format.decimal_point&&(number=number.split(format.decimal_point).join("."));return number},obj.numberFormat=function(number){const format=obj.getCurrencyFormatting();if(!format)return!1;const decimals=format.number_of_decimals,decPoint=format.decimal_point,thousandsSep=format.thousands_sep,n=isFinite(+number)?+number:0,prec=isFinite(+decimals)?Math.abs(decimals):0,sep=void 0===thousandsSep?",":thousandsSep,dec=void 0===decPoint?".":decPoint,toFixedFix=function(num,precision){const k=Math.pow(10,precision);return Math.round(num*k)/k};let s=(prec?toFixedFix(n,prec):Math.round(n)).toString().split(dec);return"."===format.thousands_sep&&(s=(prec?toFixedFix(n,prec):Math.round(n)).toString().split(".")),s[0].length>3&&(s[0]=s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,sep)),(s[1]||"").length<prec&&(s[1]=s[1]||"",s[1]+=new Array(prec-s[1].length+1).join("0")),s.join(dec)},obj.focusTicketBlock=function(input){$(input).closest(obj.modalSelector.metaItem).addClass("tribe-ticket-item__has-focus")},obj.unfocusTicketBlock=function(input){$(input).closest(obj.modalSelector.metaItem).removeClass("tribe-ticket-item__has-focus")},obj.loaderShow=function(loaderClass){const loadClass=loaderClass||obj.selector.ticketLoader;$(obj.selector.loader).filter(loadClass).removeClass(obj.selector.hidden)},obj.loaderHide=function(loaderClass){const loadClass=loaderClass||obj.selector.ticketLoader;$(obj.selector.loader).filter(loadClass).addClass(obj.selector.hidden)},obj.disable=function($element,isDisabled){isDisabled?$element.prop("disabled",!0).attr({disabled:"true","aria-disabled":"true"}):$element.prop("disabled",!1).removeProp("disabled").removeAttr("disabled aria-disabled")},obj.initPrefill=function(){obj.prefillTicketsBlock()},obj.initModalFormPrefills=function(){obj.loaderShow(obj.modalSelector.loader),$.when(obj.getData()).then((function(data){obj.prefillModalCartForm($(obj.modalSelector.cartForm)),data.meta&&$.each(data.meta,(function(ticket){$tribeTicket.find('[data-ticket-id="'+ticket.ticket_id+'"]').length&&obj.prefillModalMetaForm(data.meta)}));const local=obj.getLocal();local.meta&&obj.prefillModalMetaForm(local.meta),window.setTimeout(obj.loaderHide,500,obj.modalSelector.loader)}))},obj.prefillModalMetaForm=function(meta){if(void 0===meta||0>=meta.length)return;const $containers=$(obj.modalSelector.metaForm).find(".tribe-tickets__item__attendee__fields__container");$.each(meta,(function(idx,ticket){let current=0;const $currentContainers=$containers.find(obj.modalSelector.metaItem).filter('[data-ticket-id="'+ticket.ticket_id+'"]');$currentContainers.length&&$.each(ticket.items,(function(indx,data){"object"==typeof data&&($.each(data,(function(index,value){const $field=$currentContainers.eq(current).find('[name*="'+index+'"]');$field.is(":radio")||$field.is(":checkbox")?$field.each((function(){const $item=$(this);value===$item.val()&&$item.prop("checked",!0)})):$field.val(value)})),current++)}))})),obj.loaderHide(obj.modalSelector.loader)},obj.prefillModalCartForm=function($form){$form.find(obj.selector.item).hide();const $items=$tribeTicket.find(obj.selector.item);$.each($items,(function(index,item){const $blockItem=$(item),$item=$form.find('[data-ticket-id="'+$blockItem.attr("data-ticket-id")+'"]');if($item){0<$blockItem.find(".tribe-tickets-quantity").val()&&$item.fadeIn()}})),obj.appendARFields($form),obj.loaderHide(obj.modalSelector.loader)},obj.prefillTicketsBlock=function(){$.when(obj.getData(!0)).then((function(data){const tickets=data.tickets;if(tickets.length){let $eventCount=0;tickets.forEach((function(ticket){const $ticketRow=$('.tribe-tickets__item[data-ticket-id="'+ticket.ticket_id+'"]');if("true"===$ticketRow.attr("data-available")){const $field=$ticketRow.find(obj.selector.itemQuantityInput),$optout=$ticketRow.find(obj.selector.itemOptOutInput+ticket.ticket_id);$field.length&&($field.val(ticket.quantity),$field.trigger("change"),$eventCount+=ticket.quantity,1===parseInt(ticket.optout,10)&&$optout.prop("checked","true"))}})),0<$eventCount&&$(obj.selector.ticketInCartNotice).fadeIn()}obj.loaderHide()}),(function(){const $errorNotice=$(obj.selector.ticketInCartNotice);$errorNotice.removeClass("tribe-tickets__notice--barred tribe-tickets__notice--barred-left").addClass("tribe-tickets__notice--error"),$errorNotice.find(".tribe-tickets-notice__title").text(TribeMessages.api_error_title),$errorNotice.find(".tribe-tickets-notice__content").text(TribeMessages.connection_error),$errorNotice.fadeIn(),obj.loaderHide()}))},obj.storeLocal=function(){const meta=obj.getMetaForSave();sessionStorage.setItem("tribe_tickets_attendees-"+obj.postId,window.JSON.stringify(meta));const tickets=obj.getTicketsForCart();sessionStorage.setItem("tribe_tickets_cart-"+obj.postId,window.JSON.stringify(tickets))},obj.getLocal=function(eventId){const postId=eventId||obj.postId,meta=window.JSON.parse(sessionStorage.getItem("tribe_tickets_attendees-"+postId)),tickets=window.JSON.parse(sessionStorage.getItem("tribe_tickets_cart-"+postId)),ret={};return ret.meta=meta,ret.tickets=tickets,ret},obj.clearLocal=function(eventId){const postId=eventId||obj.postId;sessionStorage.removeItem("tribe_tickets_attendees-"+postId),sessionStorage.removeItem("tribe_tickets_cart-"+postId)},obj.maybeHydrateAttendeeBlockFromLocal=function(length){$.when(obj.getData()).then((function(data){if(!data.meta)return;const cartSkip=data.meta.length;if(length<cartSkip)return void obj.prefillModalMetaForm(data.meta);const $newBlocks=$(obj.modalSelector.metaForm).find(obj.modalSelector.metaItem).slice(length-1);$newBlocks&&$newBlocks.find(obj.modalSelector.metaField).each((function(){const $this=$(this),name=$this.attr("name"),storedVal=data[name];storedVal&&$this.val(storedVal)}))}))},obj.getTicketsForCart=function(){const tickets=[];let $cartForm=$(obj.modalSelector.cartForm);$cartForm.length||($cartForm=$(obj.selector.container));return $cartForm.find(obj.selector.item).each((function(){const $row=$(this),ticketId=$row.data("ticketId"),qty=$row.find(obj.selector.itemQuantityInput).val(),$optoutInput=$row.find('[name="attendee[optout]"]');let optout=$optoutInput.val();$optoutInput.is(":checkbox")&&(optout=$optoutInput.prop("checked")?1:0);const data={};data.ticket_id=ticketId,data.quantity=qty,data.optout=optout,tickets.push(data)})),tickets},obj.getMetaForSave=function(){const $ticketRows=$(obj.modalSelector.metaForm).find(obj.modalSelector.metaItem),meta=[],tempMeta=[];return $ticketRows.each((function(){const data={},$row=$(this),ticketId=$row.data("ticketId"),$fields=$row.find(obj.modalSelector.metaField);$fields.length&&(tempMeta[ticketId]||(tempMeta[ticketId]={},tempMeta[ticketId].ticket_id=ticketId,tempMeta[ticketId].items=[]),$fields.each((function(){const $field=$(this);let value=$field.val();const isRadio=$field.is(":radio");let name=$field.attr("name");if(name=name.split("["),name=name.pop().replace("]",""),(isRadio||$field.is(":checkbox"))&&!$field.prop("checked")){if(isRadio&&""!==data[name])return;value=""}data[name]=value})),tempMeta[ticketId].items.push(data))})),Object.keys(tempMeta).forEach((function(index){const newArr={ticket_id:index,items:tempMeta[index].items};meta.push(newArr)})),meta},obj.getData=function(pageLoad){let ret={meta:{},tickets:{}};const deferred=$.Deferred(),meta=window.JSON.parse(sessionStorage.getItem("tribe_tickets_attendees-"+obj.postId));if(null!==meta&&(ret.meta=meta),!pageLoad){const tickets=window.JSON.parse(sessionStorage.getItem("tribe_tickets_cart-"+obj.postId));null!==tickets&&tickets.length&&(ret.tickets=tickets),deferred.resolve(ret)}return ret.tickets&&ret.meta||$.ajax({type:"GET",data:{provider:$tribeTicket.data("providerId"),post_id:obj.postId},dataType:"json",url:obj.getRestEndpoint(),success:function(data){null===meta&&sessionStorage.setItem("tribe_tickets_attendees-"+obj.postId,window.JSON.stringify(data.meta)),sessionStorage.setItem("tribe_tickets_cart-"+obj.postId,window.JSON.stringify(data.tickets)),ret={meta:data.meta,tickets:data.tickets},deferred.resolve(ret)},error:function(){deferred.reject(!1)}}),deferred.promise()},obj.validateForm=function($form){const $containers=$form.find(obj.modalSelector.metaItem);let formValid=!0,invalidTickets=0;return $containers.each((function(){const $container=$(this);obj.validateBlock($container)||(invalidTickets++,formValid=!1)})),[formValid,invalidTickets]},obj.validateBlock=function($container){const $fields=$container.find(obj.modalSelector.metaField);let validBlock=!0;return $fields.each((function(){const $field=$(this);obj.validateField($field[0])||(validBlock=!1)})),validBlock?$container.removeClass("tribe-ticket-item__has-error"):$container.addClass("tribe-ticket-item__has-error"),validBlock},obj.validateCheckboxRadioGroup=function($group){const checked=$group.find("input:checked").length,required=$group.find("input:required").length;return!!(!required||required&&checked)},obj.validateHorizontalDatePickerValue=function($input){if(""===$input.val()||"null-null-null"===$input.val())return!0;const wrapper=$input.closest(obj.selector.horizontal_datepicker.container),day=wrapper.find(obj.selector.horizontal_datepicker.day),month=wrapper.find(obj.selector.horizontal_datepicker.month),year=wrapper.find(obj.selector.horizontal_datepicker.year);let isValidDatePicker=!0;return[day,month,year].forEach((function(el){isNaN(parseInt(el.val()))||parseInt(el.val())<=0?(el.addClass("ticket-meta__has-error"),isValidDatePicker=!1):el.removeClass("ticket-meta__has-error")}),isValidDatePicker),isValidDatePicker},obj.validateField=function(input){let $input=$(input),isValidField=input.checkValidity();if(!isValidField)if($input=$(input),$input.is(":checkbox")||$input.is(":radio")){const $group=$input.closest(".tribe-common-form-control-checkbox-radio-group");$group.length&&(isValidField=obj.validateCheckboxRadioGroup($group))}else isValidField=!1;return $input.is(obj.selector.horizontal_datepicker.value)&&(isValidField=obj.validateHorizontalDatePickerValue($input)),isValidField?$input.removeClass("ticket-meta__has-error"):$input.addClass("ticket-meta__has-error"),isValidField},obj.document.on("click",".tribe-tickets__item__quantity__remove, .tribe-tickets__item__quantity__add",(function(e){e.preventDefault();const $input=$(this).parent().find('input[type="number"]');if($input.is(":disabled"))return!1;const originalValue=Number($input[0].value),$modalForm=$input.closest(obj.modalSelector.cartForm);if($(this).hasClass("tribe-tickets__item__quantity__add")?obj.stepUp($input,originalValue):obj.stepDown($input,originalValue),obj.updateFooter($input.closest("form")),originalValue!==$input[0].value&&$input.trigger("change"),$modalForm.length){const $item=$input.closest(obj.selector.item);obj.updateTotal(obj.getQty($item),obj.getPrice($item),$item)}})),obj.document.on("click",obj.modalSelector.itemRemove,(function(e){e.preventDefault();const ticket={},$cart=$(this).closest("form"),$cartItem=$(this).closest(obj.selector.item);$cartItem.find(obj.selector.itemQuantity).val(0),$cartItem.fadeOut(),ticket.id=$cartItem.data("ticketId"),ticket.qty=0,$cartItem.find(obj.selector.itemQuantityInput).val(ticket.qty),ticket.price=obj.getPrice($cartItem),obj.updateTotal(ticket.qty,ticket.price,$cartItem),obj.updateFormTotals($cart),$('.tribe-tickets__item__attendee__fields__container[data-ticket-id="'+ticket.id+'"]').removeClass("tribe-tickets--has-tickets").find(obj.modalSelector.metaItem).remove(),window.setTimeout(obj.maybeShowNonMetaNotice,500,$cart),window.setTimeout((function(){if(0>=$cart.find(obj.selector.item).filter(":visible").length){const id=$(obj.selector.blockSubmit).attr("data-content"),result="dialog_obj_"+id.substring(id.lastIndexOf("-")+1);window[result].hide(),obj.disable($(obj.selector.submit),!1)}}),500)})),obj.document.on("focus",".tribe-ticket .ticket-meta",(function(e){const input=e.target;obj.focusTicketBlock(input)})),obj.document.on("blur",".tribe-ticket .ticket-meta",(function(e){const input=e.target;obj.unfocusTicketBlock(input)})),obj.document.on("change keyup",obj.selector.itemQuantityInput,(function(e){const $this=$(e.target),$ticket=$this.closest(obj.selector.item),$form=$this.closest("form"),max=$this.attr("max");let maxQty=0,newQuantity=parseInt($this.val(),10);newQuantity=isNaN(newQuantity)?0:newQuantity,max<newQuantity&&(newQuantity=max,$this.val(max)),"true"===$ticket.attr("data-has-shared-cap")&&(maxQty=obj.checkSharedCapacity($form,newQuantity)),0>maxQty&&(newQuantity+=maxQty,$this.val(newQuantity)),e.preventDefault(),obj.maybeShowOptOut($ticket,newQuantity),obj.updateFooter($form),obj.updateFormTotals($form)})),obj.document.on("beforeunload",(function(){window.tribe.tickets.modal_redirect?obj.clearLocal():obj.storeLocal()})),obj.document.on("keypress",obj.modalSelector.form,(function(e){if(13===e.keyCode){const $form=$(e.target).closest(obj.modalSelector.form);if("undefined"===$form)return;e.preventDefault(),e.stopPropagation(),$form.find('[name="cart-button"]').click()}})),obj.document.on("click",obj.modalSelector.submit,(function(e){e.preventDefault();const $button=$(this),$form=$(obj.modalSelector.form),$metaForm=$(obj.modalSelector.metaForm),isValidForm=obj.validateForm($metaForm),$errorNotice=$(obj.selector.validationNotice),buttonText=$button.attr("name"),provider=$form.data("provider");if(obj.loaderShow(obj.modalSelector.loader),!isValidForm[0])return $errorNotice.find(".tribe-tickets-notice__title").text(TribeMessages.validation_error_title),$errorNotice.find("p").html(TribeMessages.validation_error),$(obj.selector.validationNotice+"__count").text(isValidForm[1]),$errorNotice.show(),obj.loaderHide(obj.modalSelector.loader),document.getElementById("tribe-tickets__notice__attendee-modal").scrollIntoView({behavior:"smooth",block:"start"}),!1;$errorNotice.hide(),obj.loaderShow(obj.modalSelector.loader);let action=TribeTicketsURLs.checkout[provider];-1!==buttonText.indexOf("cart")&&(action=TribeTicketsURLs.cart[provider]),$(obj.modalSelector.form).attr("action",action);const params={tribe_tickets_provider:obj.commerceSelector[obj.tribe_ticket_provider],tribe_tickets_tickets:obj.getTicketsForCart(),tribe_tickets_meta:obj.getMetaForSave(),tribe_tickets_post_id:obj.postId};$("#tribe_tickets_ar_data").val(JSON.stringify(params)),window.tribe.tickets.modal_redirect=!0,obj.clearLocal(),$form.submit()})),obj.document.on("click",obj.selector.classicSubmit,(function(e){e.preventDefault();const $form=$(obj.selector.container);obj.loaderShow(obj.selector.loader);const params={tribe_tickets_provider:obj.commerceSelector[obj.tribe_ticket_provider],tribe_tickets_tickets:obj.getTicketsForCart(),tribe_tickets_meta:{},tribe_tickets_post_id:obj.postId};$form.find("#tribe_tickets_block_ar_data").val(JSON.stringify(params)),$form.submit()})),obj.document.on("keypress",obj.selector.itemQuantityInput,(function(e){if(13===e.keyCode)return e.preventDefault(),void e.stopPropagation()})),$(tde).on("tribe_dialog_show_ar_modal",(function(){obj.loaderShow(),obj.loaderShow(obj.modalSelector.loader);const $modalCart=$(obj.modalSelector.cartForm);$tribeTicket.find(obj.selector.item).each((function(){const $blockCartItem=$(this),id=$blockCartItem.data("ticketId"),$modalCartItem=$modalCart.find('[data-ticket-id="'+id+'"]');$modalCartItem&&obj.updateItem(id,$modalCartItem,$blockCartItem)})),obj.initModalFormPrefills(),obj.updateFormTotals($modalCart),obj.loaderHide(),obj.loaderHide(obj.modalSelector.loader)})),$(tde).on("tribe_dialog_close_ar_modal",(function(){obj.storeLocal()})),obj.init(),window.addEventListener("pageshow",(function(event){(event.persisted||void 0!==window.performance&&2===window.performance.navigation.type)&&obj.init()})))}(jQuery,window.tribe.tickets.block,window.tribe.dialogs.events);
Save Changes
Rename File
Rename