PluginProbe
MakeCommerce for WooCommerce / 4.1.0
MakeCommerce for WooCommerce v4.1.0
4.1.0 4.0.8 trunk 1.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.2 All 96 releases
makecommerce / shipping / js / parcelmachine.js

parcelmachine.js in MakeCommerce for WooCommerce 4.1.0, at shipping/js/parcelmachine.js

49 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(function(){
2
3 jQuery(document).on('updated_checkout', function() {
4
5 jQuery(".parcel_machine_checkout").css('display', 'none');
6
7 jQuery('.shipping_method:checked, .shipping_method[type=hidden]').each(function() {
8 var method = jQuery(this).val(), display;
9 if (method.indexOf(':') > -1) {
10 var tmp = method.split(':');
11 method = tmp[0];
12 }
13 jQuery(".parcel_machine_checkout_"+method).not(':first').remove();
14 jQuery(".parcel_machine_checkout_"+method).css('display', 'table-row');
15 });
16
17 adjust_select_box_width();
18 });
19
20 jQuery(window).resize(function() {
21 adjust_select_box_width();
22 });
23
24 function adjust_select_box_width() {
25 // Get widths of the content, parcel_machine_checkout row
26 var select_box_width;
27 var content_width = jQuery('.woocommerce-checkout-review-order').width();
28 var checkout_width = jQuery('.woocommerce-checkout').width();
29 var parcel_row = jQuery('.parcel_machine_checkout');
30 // Get the parent table class
31 var default_layout = jQuery(parcel_row).closest('table').hasClass('shop_table') &&
32 jQuery(parcel_row).closest('table').hasClass('woocommerce-checkout-review-order-table');
33 // Get the width of the correct select box
34 parcel_row.find('.parcel-machine-select-box').each(function() {
35 select_box_width = jQuery(this).width() > 1 ? jQuery(this).width() : select_box_width;
36 });
37
38 // If it is not the default table class, the theme is customized and no changes will be made
39 if (default_layout && content_width !== 'undefined' && checkout_width !== 'undefined') {
40 // Keep the searchable selectbox within size limits
41 if (content_width > checkout_width / 2){
42 jQuery('.parcel_machine_checkout > td').css('max-width', (content_width / 2 - 20) +'px');
43 } else {
44 jQuery('.parcel_machine_checkout > td').css('max-width', (content_width - 20) +'px');
45 }
46 }
47 }
48 });
49