1 line
No EOL
5.5 KiB
JavaScript
1 line
No EOL
5.5 KiB
JavaScript
timely.define(["jquery_timely","ai1ec_config"],function(e,t){e('input[name="ai1ec_payment_method"]').on("click change",function(){e(".ai1ec-payment-details").removeClass("ai1ec-active"),e(this).closest("li").find(".ai1ec-payment-details").addClass("ai1ec-active")}),e(".ai1ec-tickets-manage ul.ai1ec-nav-tabs li").on("click",function(){return e(".ai1ec-tickets-manage ul.ai1ec-nav-tabs li.ai1ec-active").removeClass("ai1ec-active"),e(".ai1ec-tickets-manage .ai1ec-tab-pane").removeClass("ai1ec-active"),e(this).addClass("ai1ec-active"),$tab=e(e(this).find("a").attr("href")),$tab.addClass("ai1ec-active"),!1}),e(document).on("click","a.ai1ec-has-tickets",function(){var r=e(this),i=r.closest("tr"),s=r.attr("data-post-id"),o=i.find("td, th").not(".hidden").length,u=e('<tr class="ai1ec-tickets-details ai1ec-tickets-details-'+s+'"><td colspan="'+o+'" class="ai1ec-ticket-details-row-empty"></td></tr>'),a=e('<tr class="ai1ec-tickets-details ai1ec-tickets-details-'+s+'""><td colspan="'+o+'" class="ai1ec-ticket-details-row"><div></div></td></tr>');return r.hasClass("ai1ec-tickets-shown")?(e(".ai1ec-tickets-details-"+s).remove(),r.text(t.ticketing.details).removeClass("ai1ec-tickets-shown"),!1):(r.text(t.ticketing.hide_details).addClass("ai1ec-tickets-shown"),i.after(a).after(u),a.find(".ai1ec-ticket-details-row > div").append(t.ticketing.loading_details),e.ajax({url:t.ajax_url,type:"POST",data:{action:"ai1ec_show_ticket_details",ai1ec_event_id:s},success:function(r){r=e.parseJSON(r);if(r&&r.data&&r.data.length){a.find(".ai1ec-ticket-details-row > div").html("");var i=e("<table></table>"),o=e("<thead></thead>"),u=e("<tbody></tbody>");o=e("<th>"+t.ticketing.type_and_price+"</th>"+'<th class="ai1ec-hidden-sm">'+t.ticketing.info+"</th>"+"<th>"+t.ticketing.report+"</th>"+'<th class="ai1ec-hidden-sm">'+t.ticketing.sale_dates+"</th>"+'<th class="ai1ec-hidden-sm">'+t.ticketing.limits+"</th>"+'<th class="ai1ec-ticket-details-actions">'+t.ticketing.actions+"</th>"),o.appendTo(i);for(var f=0;f<r.data.length;f++){var l=e("<tr></tr>"),c='<span class="ai1ec-tickets-status ai1ec-tickets-status-'+n(r.data[f].ticket_status)+'">'+n(r.data[f].ticket_status_label)+"</span>",h="";typeof r.data[f]["symbol"]!="undefined"?h=n(r.data[f].symbol):h="$",l.append(e("<td></td>").html('"'+n(r.data[f].name)+'"'+"<br /><b>"+h+n(r.data[f].price)+" "+n(r.data[f].currency)+"</b>"+'<div class="ai1ec-visible-sm">'+c+"</div>"),e('<td class="ai1ec-hidden-sm"></td>').html(c),e("<td></td>").html(t.ticketing.sold+" "+n(r.data[f].sold)+"<br>"+t.ticketing.left+" "+(null==r.data[f]["available"]?t.ticketing.unlimited:n(r.data[f].available))),e('<td class="ai1ec-hidden-sm"></td>').html(t.ticketing.start+" "+n(r.data[f].sale_start_date)+"<br />"+t.ticketing.end+" "+n(r.data[f].sale_end_date)),e('<td class="ai1ec-hidden-sm"></td>').html(t.ticketing.min+" "+n(r.data[f].buy_min_qty)+"<br />"+t.ticketing.max+""+n(r.data[f].buy_max_qty)),e("<td></td>").html('<a href="#" class="ai1ec-show-attendees" data-ticket-type="'+n(r.data[f].id)+'" data-post-id="'+s+'">'+t.ticketing.attendees+"</a>")),i.append(l)}a.find(".ai1ec-ticket-details-row > div").append(i)}else r&&r.error&&(a.find(".ai1ec-ticket-details-row > div").html(""),a.find(".ai1ec-ticket-details-row > div").append(r.error))}}),!1)}),e(document).on("click",".ai1ec-show-attendees",function(){var r=e(this),i=r.closest("tr"),s=e(this).attr("data-ticket-type"),o=r.attr("data-post-id");return attendees=0,r.hasClass("ai1ec-attendees-shown")?(r.removeClass("ai1ec-attendees-shown").text(t.ticketing.attendees),i.next(".ai1ec-ticket-attendees-row").remove(),!1):(r.text(t.ticketing.hide_attendees).addClass("ai1ec-attendees-shown"),e.ajax({url:t.ajax_url,type:"POST",data:{action:"ai1ec_show_attendees",ai1ec_event_id:o},success:function(r){r=e.parseJSON(r);var o=e('<tr class="ai1ec-ticket-attendees-row"><td colspan="6" class="ai1ec-ticket-attendees"><h3>'+t.ticketing.attendees_list+"</h3>"+'<table class="ai1ec-attendees-list"><thead>'+'<th class="ai1ec-hidden-sm">#</th>'+"<th>"+t.ticketing.guest_name+"</th>"+'<th class="ai1ec-hidden-sm">'+t.ticketing.status+"</th>"+"<th>"+t.ticketing.code+"</th>"+'<th class="ai1ec-hidden-sm">'+t.ticketing.email+"</th>"+"</thead><tbody></tbody></table></td></tr>");if(r&&r.data&&r.data.length){for(var u=0;u<r.data.length;u++)s==r.data[u]["ticket_type_id"]&&($att_row=e("<tr></tr>"),$att_row.append(e('<td class="ai1ec-hidden-sm"></td>').text(u+1),e("<td></td>").text(r.data[u].holder_first_name+" "+r.data[u].holder_last_name),e('<td class="ai1ec-hidden-sm"></td>').text(r.data[u].status),e("<td></td>").text(r.data[u].ticket_code),e('<td class="ai1ec-hidden-sm"></td>').html('<a href="'+n(r.data[u].holder_email)+'">'+n(r.data[u].holder_email)+"</a>")),o.find("tbody").append($att_row),attendees++);attendees||o.find("table").replaceWith("<h4>"+t.ticketing.no_attendees+"</h4>"),i.after(o)}else r&&r.error&&(o.find("table").replaceWith("<h4>"+r.error+"</h4>"),i.after(o))}}),!1)}),e('[name="ai1ec_tickets_submit"]').on("click",function(){return e(".ai1ec-ticket-field-error").hide(),e(".ai1ec-required:visible").each(function(){var t=e(this);t.removeClass("ai1ec-error");if(!e.trim(t.val())||"checkbox"===t.attr("type")&&!this.checked)t.addClass("ai1ec-error"),t.closest("td").find(".ai1ec-ticket-field-error").show(),t.prev(".ai1ec-ticket-field-error").show()}),e(".ai1ec-ticket-field-error:visible").length||(e(".ai1ec-noauto").remove(),e(this).closest("form").submit()),!1});var n=function(e){return"string"==typeof e&&(e=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")),e}}); |