Current File : /home/digitaw/www/wp-content/plugins/event-tickets/build/js/move-tickets-dialog.js
(()=>{var t=t||{};!function(t,e){let i,o,a,c,n,s,r,d,_,p,l,k;function f(t){c=t,n=c.attr("id"),s.hide(),c.show(),i.trigger("pre-activate-stage.tribe"),i.trigger("activate-"+n+".tribe")}function m(t){(t=parseInt(t,10))>0&&l!==t&&(l=t,i.trigger("destination-post-selected.tribe"))}function u(t,e){e===n&&(t.removeProp("disabled").show().removeClass("disabled"),"next"===t.attr("id")&&b()&&t.addClass("button-primary"))}function v(t,e){e===n&&t.prop("disabled",!0).addClass("disabled").removeClass("button-primary")}function h(t,e){e===n&&t.hide()}function b(){return!c.next(".stage").length}e.get_main_element=function(){return i},e.hide_btn=h,e.disable_btn=v,e.enable_btn=u,e.activate_stage=f,t((function(){i=t("#main"),a=t(".error"),o=t("#processing"),r=t("#back"),d=t("#next"),i.trigger("move-tickets-dialog-pre-init.tribe"),r.add(d).hide(),o.hide(),a.length||(d.show(),function(){let e,o=t("#choose-event").find(".select-single-container"),a=t("#post-type"),n=t("#search-terms"),r="choose-event",l=!1;function k(){if(l)return;l=!0,o.css("opacity",.6),v(d,r);const e={action:"move_tickets_get_post_choices",check:tribe_move_tickets_data.check,post_type:a.val(),search_terms:n.val(),ignore:tribe_move_tickets_data.src_post_id};t.post(ajaxurl,e,(function(t){if(void 0===t.data||"object"!=typeof t.data.posts)return;o.html("");let e=0;for(const i in t.data.posts){const a=parseInt(t.data.posts[i]),c=i;e++,o.append(`<label> <input type="radio" value="${a}" name="post-choice">${c}</label>`)}e||o.append(`<label>${tribe_move_tickets_data.no_posts_found}</label>`),l=!1,o.css("opacity",1)}))}function h(){const t=o.find("input:checked");o.find(".selected").removeClass("selected"),t.length&&(m(t.val()),t.parent("label").addClass("selected"),u(d,r))}i.on("activate-choose-event.tribe",(function(){v(d,r),p&&"next"===_?f(c.next()):p&&f(s.first()),h()})),function(){a.html('<option value="">'+tribe_move_tickets_data.loading_msg+"</option>");const e={action:"move_tickets_get_post_types",check:tribe_move_tickets_data.check};t.post(ajaxurl,e,(function(t){if(void 0!==t.data&&"object"==typeof t.data.posts){a.html("");for(const e in t.data.posts)a.append('<option value="'+e+'">'+t.data.posts[e]+"</option>")}}))}(),k(),n.keyup((function(){clearTimeout(e),e=setTimeout(k,200)})),a.change(k),o.click((function(){l||h()}))}(),"move_tickets"===tribe_move_tickets_data.mode?(function(){const e="move-where",o=t('input[name="move-where"]');function a(){const t=o.filter(":checked");t.length?("this-post"===t.val()?(m(tribe_move_tickets_data.src_post_id),p=!0):(l=!1,p=!1),u(d,e)):v(d,e)}i.on("activate-move-where.tribe",(function(){h(r,e),a()})),o.change(a)}(),function(){const e="choose-ticket-type",o=t("#choose-ticket-type").find(".select-single-container");i.on("activate-choose-ticket-type.tribe",(function(){v(d,e),l||f(s.first())})),i.on("destination-post-selected.tribe",(function(){o.css("opacity",.6),v(d,e);const i={action:"move_tickets_get_ticket_types",check:tribe_move_tickets_data.check,post_id:l,provider:tribe_move_tickets_data.provider,ticket_ids:tribe_move_tickets_data.ticket_ids};t.post(ajaxurl,i,(function(t){if("object"!=typeof t.data.posts)return;o.html("");let e=0;for(const i in t.data.posts){const a=parseInt(i,10),c=t.data.posts[i];e++,o.append('<label> <input type="radio" value="'+a+'" name="post-choice">'+c+"</label>")}e||o.append("<label>"+tribe_move_tickets_data.no_ticket_types_found+"</label>"),o.css("opacity",1)}))})),o.click((function(){const t=o.find("input:checked");o.find(".selected").removeClass("selected"),t.length&&(k=parseInt(t.val()),t.parent("label").addClass("selected"),u(d,e))}))}()):(t("#move-where").remove(),t("#choose-ticket-type").remove()),s=t(".stage"),function(){const e=d.html();let o=d.data("final-text");function a(t){_=t;const e=c[t](".stage");e.length?f(e):b()&&i.trigger("move-tickets-final-stage.tribe")}o=o||e,i.on("pre-activate-stage.tribe",(function(){d.html(b()?o:e)})),r.add(d).click((function(){switch(t(this).attr("id")){case"back":a("prev");break;case"next":a("next")}}))}(),function(){function e(e){if(void 0!==e.data&&"string"==typeof e.data.message){if(o.html(e.data.message),"string"==typeof e.data.redirect_top){const t="number"==typeof e.data.redirect_top_delay?e.data.redirect_top_delay:2e3;setTimeout((function(){top.location=e.data.redirect_top}),t)}"number"==typeof e.data.remove_ticket_type&&top.jQuery("table.ticket_list").find('tr[data-ticket-type-id="'+e.data.remove_ticket_type+'"]').remove(),top.jQuery("#ticket_form_cancel").trigger("click"),t.isArray(e.data.remove_tickets)&&top.tribe_event_tickets_attendees.remove_tickets(e.data.remove_tickets)}else a()}function a(){o.html(tribe_move_tickets_data.unexpected_failure)}i.on("move-tickets-final-stage.tribe",(function(){switch(tribe_move_tickets_data.mode){case"move_tickets":!function(){if(!l||!k)return;const i={action:"move_tickets",src_post_id:tribe_move_tickets_data.src_post_id,target_post_id:l,check:tribe_move_tickets_data.check,ticket_ids:tribe_move_tickets_data.ticket_ids,target_type_id:k};s.hide(),r.hide(),d.hide(),o.show(),t.post(ajaxurl,i,(function(t){e(t)})).fail(a)}();break;case"ticket_type_only":!function(){if(!l)return;const i={action:"move_ticket_type",src_post_id:tribe_move_tickets_data.src_post_id,ticket_type_id:tribe_move_tickets_data.ticket_type_id,target_post_id:l,check:tribe_move_tickets_data.check};s.hide(),r.hide(),d.hide(),o.show(),t.post(ajaxurl,i,(function(t){e(t)})).fail(a)}()}}))}(),f(s.first())),i.trigger("move-tickets-dialog-post-init.tribe")}))}(jQuery,t),window.tec=window.tec||{},window.tec.tickets=window.tec.tickets||{},window.tec.tickets.moveTicketsDialog={}})();