1 line
1.6 KiB
JavaScript
1 line
1.6 KiB
JavaScript
jQuery(function(a){var b=wc_address_i18n_params.locale.replace(/"/g,'"'),c=a.parseJSON(b),d=' <abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>';a("body").bind("country_to_state_changing",function(b,e,f){var g=f;if("undefined"!=typeof c[e])var h=c[e];else var h=c["default"];var i=a.parseJSON(wc_address_i18n_params.locale_fields);a.each(i,function(a,b){var e=g.find(b);h[a]?(h[a].label&&e.find("label").html(h[a].label),h[a].placeholder&&e.find("input").attr("placeholder",h[a].placeholder),e.find("label abbr").remove(),"undefined"==typeof h[a].required&&1==c["default"][a].required?e.find("label").append(d):1==h[a].required&&e.find("label").append(d),"state"!==a&&(1==h[a].hidden?e.hide().find("input").val(""):e.show())):c["default"][a]&&(1==c["default"][a].required&&0==e.find("label abbr").size()&&e.find("label").append(d),"state"!==a&&("undefined"==typeof c["default"][a].hidden||0==c["default"][a].hidden?e.show():1==c["default"][a].hidden&&e.hide().find("input").val("")))});var j=g.find("#billing_postcode_field, #shipping_postcode_field"),k=g.find("#billing_city_field, #shipping_city_field"),l=g.find("#billing_state_field, #shipping_state_field");j.attr("data-o_class")||(j.attr("data-o_class",j.attr("class")),k.attr("data-o_class",k.attr("class")),l.attr("data-o_class",l.attr("class"))),h.postcode_before_city?(j.add(k).add(l).removeClass("form-row-first form-row-last").addClass("form-row-wide"),j.insertBefore(k)):(j.attr("class",j.attr("data-o_class")),k.attr("class",k.attr("data-o_class")),l.attr("class",l.attr("data-o_class")),j.insertAfter(l))})}); |