woocommerce/assets/js/frontend/woocommerce.min.js

1 line
2.5 KiB
JavaScript
Raw Normal View History

2012-12-10 13:11:05 +00:00
jQuery(document).ready(function(e){e("select.orderby").change(function(){e(this).closest("form").submit()});e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />');e("input.qty:not(.product-quantity input.qty)").each(function(){var t=parseFloat(e(this).attr("min"));t&&t>0&&parseFloat(e(this).val())<t&&e(this).val(t)});e(".plus, .minus").live("click",function(){var t=e(this).closest(".quantity").find(".qty"),n=parseFloat(t.val()),r=parseFloat(t.attr("max")),i=parseFloat(t.attr("min")),s=t.attr("step");if(!n||n==""||n=="NaN")n=0;if(r==""||r=="NaN")r="";if(i==""||i=="NaN")i=0;if(s=="any"||s==""||s==undefined||parseFloat(s)=="NaN")s=1;e(this).is(".plus")?r&&(r==n||n>r)?t.val(r):t.val(n+parseFloat(s)):i&&(i==n||n<i)?t.val(i):n>0&&t.val(n-parseFloat(s));t.trigger("change")});var t=woocommerce_params.countries.replace(/&quot;/g,'"'),n=e.parseJSON(t);e("select.country_to_state").change(function(){var t=e(this).val(),r=e(this).closest("div").find("#billing_state, #shipping_state, #calc_shipping_state"),i=r.parent(),s=r.attr("name"),o=r.attr("id"),u=r.val();if(n[t])n[t].length==0?i.fadeOut(200,function(){r.parent().find(".chzn-container").remove();r.replaceWith('<input type="hidden" class="hidden" name="'+s+'" id="'+o+'" value="" />');e("body").trigger("country_to_state_changed",[t,e(this).closest("div")])}):i.fadeOut(200,function(){var a="",f=n[t];for(var l in f)a=a+'<option value="'+l+'">'+f[l]+"</option>";if(r.is("input")){r.replaceWith('<select name="'+s+'" id="'+o+'" class="state_select"></select>');r=e(this).closest("div").find("#billing_state, #shipping_state, #calc_shipping_state")}r.html('<option value="">'+woocommerce_params.i18n_select_state_text+"</option>"+a);r.val(u);e("body").trigger("country_to_state_changed",[t,e(this).closest("div")]);i.fadeIn(500)});else if(r.is("select"))i.fadeOut(200,function(){i.find(".chzn-container").remove();r.replaceWith('<input type="text" class="input-text" name="'+s+'" id="'+o+'" />');e("body").trigger("country_to_state_changed",[t,e(this).closest("div")]);i.fadeIn(500)});else if(r.is(".hidden")){i.find(".chzn-container").remove();r.replaceWith('<input type="text" class="input-text" name="'+s+'" id="'+o+'" />');e("body").trigger("country_to_state_changed",[t,e(this).closest("div")]);i.delay(200).fadeIn(500)}e("body").delay(200).trigger("country_to_state_changing",[t,e(this).closest("div")])})});