cart jshinted and standard coding fixes

This commit is contained in:
splashingpixels 2014-03-17 20:08:41 -07:00
parent 6d2aa8b3c3
commit ce3605ad36
2 changed files with 18 additions and 16 deletions

View File

@ -1,37 +1,39 @@
jQuery(function($) { jQuery( function( $ ) {
// wc_cart_params is required to continue, ensure the object exists // wc_cart_params is required to continue, ensure the object exists
if (typeof wc_cart_params === "undefined") if ( typeof wc_cart_params === 'undefined' ) {
return false; return false;
}
// Shipping calculator // Shipping calculator
$(document).on( 'click', '.shipping-calculator-button', function() { $( document ).on( 'click', '.shipping-calculator-button', function() {
$('.shipping-calculator-form').slideToggle('slow'); $( '.shipping-calculator-form' ).slideToggle( 'slow' );
return false; return false;
}).on( 'change', 'select.shipping_method, input[name^=shipping_method]', function() { }).on( 'change', 'select.shipping_method, input[name^=shipping_method]', function() {
var shipping_methods = []; var shipping_methods = [];
$('select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]').each( function( index, input ) { $( 'select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]' ).each( function( index, input ) {
shipping_methods[ $(this).data( 'index' ) ] = $(this).val(); shipping_methods[ $( this ).data( 'index' ) ] = $( this ).val();
} ); } );
$('div.cart_totals').block({message: null, overlayCSS: {background: '#fff url(' + wc_cart_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}}); $( 'div.cart_totals' ).block({ message: null, overlayCSS: { background: '#fff url(' + wc_cart_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } });
var data = { var data = {
action: 'woocommerce_update_shipping_method', action: 'woocommerce_update_shipping_method',
security: wc_cart_params.update_shipping_method_nonce, security: wc_cart_params.update_shipping_method_nonce,
shipping_method: shipping_methods shipping_method: shipping_methods
}; };
$.post( wc_cart_params.ajax_url, data, function(response) { $.post( wc_cart_params.ajax_url, data, function( response ) {
$('div.cart_totals').replaceWith( response ); $( 'div.cart_totals' ).replaceWith( response );
$('body').trigger('updated_shipping_method'); $( 'body' ).trigger( 'updated_shipping_method' );
}); });
}) });
$('.shipping-calculator-form').hide(); $( '.shipping-calculator-form' ).hide();
}); });

View File

@ -1 +1 @@
jQuery(function(a){return"undefined"==typeof wc_cart_params?!1:(a(document).on("click",".shipping-calculator-button",function(){return a(".shipping-calculator-form").slideToggle("slow"),!1}).on("change","select.shipping_method, input[name^=shipping_method]",function(){var b=[];a("select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]").each(function(){b[a(this).data("index")]=a(this).val()}),a("div.cart_totals").block({message:null,overlayCSS:{background:"#fff url("+wc_cart_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});var c={action:"woocommerce_update_shipping_method",security:wc_cart_params.update_shipping_method_nonce,shipping_method:b};a.post(wc_cart_params.ajax_url,c,function(b){a("div.cart_totals").replaceWith(b),a("body").trigger("updated_shipping_method")})}),void a(".shipping-calculator-form").hide())}); jQuery(function(e){if(typeof wc_cart_params==="undefined"){return false}e(document).on("click",".shipping-calculator-button",function(){e(".shipping-calculator-form").slideToggle("slow");return false}).on("change","select.shipping_method, input[name^=shipping_method]",function(){var t=[];e("select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]").each(function(n,r){t[e(this).data("index")]=e(this).val()});e("div.cart_totals").block({message:null,overlayCSS:{background:"#fff url("+wc_cart_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});var n={action:"woocommerce_update_shipping_method",security:wc_cart_params.update_shipping_method_nonce,shipping_method:t};e.post(wc_cart_params.ajax_url,n,function(t){e("div.cart_totals").replaceWith(t);e("body").trigger("updated_shipping_method")})});e(".shipping-calculator-form").hide()})