File Editor
Directories:
.. (Back)
__tests__
Files:
rsvp-ari.js
rsvp-ari.min.js
rsvp-block.js
rsvp-block.min.js
rsvp-manager.js
rsvp-manager.min.js
rsvp-tooltip.js
rsvp-tooltip.min.js
tickets-block.js
tickets-block.min.js
tickets-commerce.js
tickets-commerce.min.js
tickets-loader.js
tickets-loader.min.js
tickets-page.js
tickets-page.min.js
tickets-utils.js
tickets-utils.min.js
Create New File
Create
Edit File: rsvp-ari.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 */ tribe.tickets=tribe.tickets||{},tribe.tickets.rsvp=tribe.tickets.rsvp||{},tribe.tickets.rsvp.ari={},function($,obj){const $document=$(document);obj.selectors={container:".tribe-tickets__rsvp-wrapper",rsvpForm:'form[name~="tribe-tickets-rsvp-form-ari"]',rsvpFormNameInput:".tribe-tickets__rsvp-form-field-name",rsvpFormEmailInput:".tribe-tickets__rsvp-form-field-email",hiddenElement:".tribe-common-a11y-hidden",addGuestButton:".tribe-tickets__rsvp-ar-quantity-input-number--plus",removeGuestButton:".tribe-tickets__rsvp-ar-quantity-input-number--minus",guestList:".tribe-tickets__rsvp-ar-guest-list",guestListItem:".tribe-tickets__rsvp-ar-guest-list-item",guestListItemTemplate:".tribe-tickets__rsvp-ar-guest-list-item-template",guestListItemButton:".tribe-tickets__rsvp-ar-guest-list-item-button",guestListItemButtonInactive:".tribe-tickets__rsvp-ar-guest-list-item-button--inactive",guestListItemButtonIcon:".tribe-tickets__rsvp-ar-guest-icon",guestFormWrapper:".tribe-tickets__rsvp-ar-form",guestFormFields:".tribe-tickets__rsvp-ar-form-guest",guestFormFieldsError:".tribe-tickets__form-message--error",guestFormFieldsTitle:".tribe-tickets__rsvp-ar-form-title",guestFormFieldsTemplate:".tribe-tickets__rsvp-ar-form-guest-template",nextGuestButton:".tribe-tickets__rsvp-form-button--next",submitButton:".tribe-tickets__rsvp-form-button--submit"},obj.goToGuest=function($container,guestNumber){const $targetGuestForm=$container.find(obj.selectors.guestFormWrapper).find(obj.selectors.guestFormFields+'[data-guest-number="'+guestNumber+'"]'),$guestListButtons=$container.find(obj.selectors.guestListItemButton);$container.find(obj.selectors.guestFormFields).addClass(obj.selectors.hiddenElement.className()),$container.find(obj.selectors.guestFormFields).prop("hidden",!0),obj.showElement($targetGuestForm),$targetGuestForm.removeAttr("hidden"),$guestListButtons.addClass(obj.selectors.guestListItemButtonInactive.className()),$guestListButtons.attr("aria-selected","false");const $targetGuestButton=$container.find(obj.selectors.guestListItemButton+'[data-guest-number="'+guestNumber+'"]');$targetGuestButton.removeClass(obj.selectors.guestListItemButtonInactive.className()),$targetGuestButton.attr("aria-selected","true")},obj.hasAriRequiredFields=function($container){const $form=$container.find(obj.selectors.rsvpForm),$required=$form.find(tribe.tickets.meta.selectors.formFieldRequired),$name=$form.find(obj.selectors.rsvpFormNameInput),$email=$form.find(obj.selectors.rsvpFormEmailInput);return!!(0<$required.length-($name.length+$email.length))},obj.showElement=function($element){$element.removeClass(obj.selectors.hiddenElement.className())},obj.hideElement=function($element){$element.addClass(obj.selectors.hiddenElement.className())},obj.isGuestValid=function($guestForm){const $fields=$guestForm.find(tribe.tickets.meta.selectors.formFieldInput);let isValid=!0;$fields.each((function(){const $field=$(this);tribe.tickets.meta.validateField($field[0])||(isValid=!1)}));const $guestFormError=$guestForm.find(obj.selectors.guestFormFieldsError);return isValid?obj.hideElement($guestFormError):obj.showElement($guestFormError),isValid},obj.canGoToGuest=function($container,guestNumber){const currentGuest=obj.getCurrentGuest($container),hasAriRequiredFields=obj.hasAriRequiredFields($container);if(guestNumber<currentGuest)return!0;if(hasAriRequiredFields&&1<guestNumber-currentGuest)return!1;const $currentGuestForm=$container.find(obj.selectors.guestFormFields+'[data-guest-number="'+currentGuest+'"]');return obj.isGuestValid($currentGuestForm)},obj.setNextAndSubmit=function($container){const $guestForm=$container.find(obj.selectors.guestFormFields),totalGuests=$guestForm.length;obj.bindNextButton($container),$guestForm.each((function(index,wrapper){const $nextGuestButton=$(wrapper).find(obj.selectors.nextGuestButton),$submitButton=$(wrapper).find(obj.selectors.submitButton);index+1===totalGuests?(obj.showElement($submitButton),obj.hideElement($nextGuestButton)):(obj.showElement($nextGuestButton),obj.hideElement($submitButton))}))},obj.bindGoToGuest=function($container,$button,guestNumberVal){let guestNumber=guestNumberVal||1;$button.on("click",(function(){const guestNumberDataAttribute=$(this).data("guest-number");void 0!==guestNumberDataAttribute&&(guestNumber=guestNumberDataAttribute),obj.canGoToGuest($container,guestNumber)&&obj.goToGuest($container,guestNumber)}))},obj.addGuest=function($container){const $guestList=$container.find(obj.selectors.guestList),$guestFormWrapper=$container.find(obj.selectors.guestFormWrapper),totalGuests=obj.getTotalGuests($container),rsvpId=$container.data("rsvp-id"),rsvpFieldsTemplate=window.wp.template(obj.selectors.guestFormFieldsTemplate.className()+"-"+rsvpId),guestListItemTemplate=window.wp.template(obj.selectors.guestListItemTemplate.className()+"-"+rsvpId),data={attendee_id:totalGuests};$guestList.append(guestListItemTemplate(data)),$guestFormWrapper.append(rsvpFieldsTemplate(data));const $newGuestButton=$guestList.children(obj.selectors.guestListItem).last().find(obj.selectors.guestListItemButton);obj.setNextAndSubmit($container),obj.bindGoToGuest($container,$newGuestButton),$container.find(tribe.tickets.rsvp.block.selectors.cancelButton).off(),tribe.tickets.rsvp.block.bindCancel($container)},obj.handleQuantityChangeValue=function(e){e.preventDefault();const $this=$(e.target),$container=e.data.container,max=$this.attr("max"),min=$this.attr("min");let newQuantity=parseInt($this.val(),10);newQuantity=isNaN(newQuantity)?0:newQuantity,max<newQuantity&&(newQuantity=max),newQuantity<min&&(newQuantity=min),$this.val(newQuantity);const difference=newQuantity-obj.getTotalGuests($container),isAdding=difference>0;for(let i=0;i<Math.abs(difference);i++)isAdding?obj.addGuest($container):obj.removeGuest($container)},obj.handleSubmission=function(e){e.preventDefault();const $form=$(this),$container=$form.closest(obj.selectors.container),rsvpId=$form.data("rsvp-id"),params=$form.serializeArray(),data={action:"tribe_tickets_rsvp_handle",ticket_id:rsvpId,step:"success"};$(params).each((function(index,object){data[object.name]=object.value})),tribe.tickets.rsvp.manager.request(data,$container)},obj.bindForm=function($container){$container.find(obj.selectors.rsvpForm).each((function(index,form){$(form).on("submit",obj.handleSubmission)}))},obj.removeGuest=function($container){const totalGuests=obj.getTotalGuests($container),currentGuest=obj.getCurrentGuest($container);if(1===totalGuests)return;totalGuests===currentGuest&&obj.goToGuest($container,currentGuest-1);const $guestFormFields=$container.find(obj.selectors.guestFormFields);$container.find(obj.selectors.guestListItem).last().remove(),$guestFormFields.last().remove();const $newLastGuest=$container.find(obj.selectors.guestFormFields).last(),$nextGuestButton=$newLastGuest.find(obj.selectors.nextGuestButton),$submitButton=$newLastGuest.find(obj.selectors.submitButton);obj.showElement($submitButton),obj.hideElement($nextGuestButton)},obj.getTotalGuests=function($container){return $container.find(obj.selectors.guestFormFields).length},obj.getCurrentGuest=function($container){return $container.find(obj.selectors.guestFormFields+":not("+obj.selectors.hiddenElement+")").data("guest-number")},obj.handleQuantityChange=function(e){e.preventDefault();const $input=$(this).parent().find('input[type="number"]'),increase=$(this).hasClass(obj.selectors.addGuestButton.className()),step=$input.attr("step")?Number($input.attr("step")):1,originalValue=Number($input.val());if(increase){const max=$input.attr("max")?Number($input.attr("max")):-1;if("function"==typeof $input[0].stepUp)try{if(max<originalValue+step)return;$input[0].stepUp()}catch(ex){$input[0].value=-1===max||max>=originalValue+step?originalValue+step:max}else $input[0].value=-1===max||max>=originalValue+step?originalValue+step:max}else{const min=$input.attr("min")?Number($input.attr("min")):0;if("function"==typeof $input[0].stepDown)try{$input[0].stepDown()}catch(ex){$input[0].value=min<=originalValue-step?originalValue-step:min}else $input[0].value=min<=originalValue-step?originalValue-step:min}originalValue!==$input[0].value&&$input.trigger("input")},obj.bindGuestAddRemove=function($container){const $addGuestButton=$container.find(obj.selectors.addGuestButton),$removeGuestButton=$container.find(obj.selectors.removeGuestButton),$guestListItemButton=$container.find(obj.selectors.guestListItemButton),$qtyInput=$container.find('.tribe-tickets__rsvp-ar-quantity-input input[type="number"]');obj.bindGoToGuest($container,$guestListItemButton),$addGuestButton.on("click",obj.handleQuantityChange),$removeGuestButton.on("click",obj.handleQuantityChange),$qtyInput.on("input",{container:$container},obj.handleQuantityChangeValue)},obj.bindNextButton=function($container){const $lastForm=$container.find(obj.selectors.guestFormFields).last(),$lastFormNextButton=$lastForm.find(obj.selectors.nextGuestButton),lastFormGuestNumber=$lastForm.data("guest-number");obj.bindGoToGuest($container,$lastFormNextButton,lastFormGuestNumber+1)},obj.unbindEvents=function(event,jqXHR,settings){const $container=event.data.container,$addGuestButton=$container.find(obj.selectors.addGuestButton),$removeGuestButton=$container.find(obj.selectors.removeGuestButton),$guestListItemButton=$container.find(obj.selectors.guestListItemButton);$addGuestButton.off(),$removeGuestButton.off(),$guestListItemButton.off()},obj.bindEvents=function($container){obj.bindGuestAddRemove($container),obj.bindForm($container),obj.bindNextButton($container),$container.on("beforeAjaxSuccess.tribeTicketsRsvp",{container:$container},obj.unbindEvents)},obj.init=function(event,index,$container){obj.bindEvents($container)},obj.ready=function(){$document.on("afterSetup.tribeTicketsRsvp",tribe.tickets.rsvp.manager.selectors.container,obj.init)},$(obj.ready)}(jQuery,tribe.tickets.rsvp.ari);
Save Changes
Rename File
Rename