frontend.js
52 lines
| 1 | +(function($) { |
| 2 | var WPB_Woo_Product_size_Chart = { |
| 3 | |
| 4 | initialize: function() { |
| 5 | $('.wpb-psc-table-fire').on('click', this.FireSizeChart); |
| 6 | }, |
| 7 | |
| 8 | FireSizeChart: function(e) { |
| 9 | e.preventDefault(); |
| 10 | |
| 11 | var button = $(this), |
| 12 | id = button.attr('data-id'), |
| 13 | post_id = button.attr('data-post_id'), |
| 14 | popup_style = button.attr('data-popup_style') ? !0 : !1, |
| 15 | width = button.attr('data-width'); |
| 16 | |
| 17 | wp.ajax.send( { |
| 18 | data: { |
| 19 | action: 'fire_wpb_product_size_chart', |
| 20 | size_id: id, |
| 21 | wpb_post_id: post_id, |
| 22 | _wpnonce: WPB_PSC_Vars.nonce |
| 23 | }, |
| 24 | beforeSend : function ( xhr ) { |
| 25 | button.addClass('wpb-psc-btn-loading'); |
| 26 | }, |
| 27 | success: function( res ) { |
| 28 | button.removeClass('wpb-psc-btn-loading'); |
| 29 | Swal.fire({ |
| 30 | html: res, |
| 31 | showConfirmButton: false, |
| 32 | customClass: { |
| 33 | container: 'wpb-psc-size-chart-popup wpb-psc-table-style-' + popup_style, |
| 34 | }, |
| 35 | padding: '30px', |
| 36 | width: width, |
| 37 | showCloseButton: true, |
| 38 | }); |
| 39 | }, |
| 40 | error: function(error) { |
| 41 | alert( error ); |
| 42 | } |
| 43 | }); |
| 44 | }, |
| 45 | |
| 46 | |
| 47 | }; |
| 48 | |
| 49 | $(function() { |
| 50 | WPB_Woo_Product_size_Chart.initialize(); |
| 51 | }); |
| 52 | })(jQuery); |