1 line
2.3 KiB
JavaScript
1 line
2.3 KiB
JavaScript
jQuery(function(s){if("undefined"==typeof wc_address_i18n_params)return!1;var e=wc_address_i18n_params.locale.replace(/"/g,'"'),p=s.parseJSON(e);function f(e,a){a?(e.find("label .optional").remove(),e.addClass("validate-required"),0===e.find("label .required").length&&e.find("label").append(' <abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>')):(e.find("label .required").remove(),e.removeClass("validate-required"),0===e.find("label .optional").length&&e.find("label").append(' <span class="optional">('+wc_address_i18n_params.i18n_optional_text+")</span>"))}s(document.body).bind("country_to_state_changing",function(e,a,i){var t,l=i;t="undefined"!=typeof p[a]?p[a]:p["default"];var d=l.find("#billing_postcode_field, #shipping_postcode_field"),r=l.find("#billing_city_field, #shipping_city_field"),n=l.find("#billing_state_field, #shipping_state_field");d.attr("data-o_class")||(d.attr("data-o_class",d.attr("class")),r.attr("data-o_class",r.attr("class")),n.attr("data-o_class",n.attr("class")));var o=s.parseJSON(wc_address_i18n_params.locale_fields);s.each(o,function(e,a){var i=l.find(a),d=s.extend(!0,{},p["default"][e],t[e]);"undefined"!=typeof d.label&&i.find("label").html(d.label),"undefined"!=typeof d.placeholder&&(i.find("input").attr("placeholder",d.placeholder),i.find(".select2-selection__placeholder").text(d.placeholder)),"undefined"!=typeof d.placeholder||"undefined"==typeof d.label||i.find("label").length||(i.find("input").attr("placeholder",d.label),i.find(".select2-selection__placeholder").text(d.label)),"undefined"!=typeof d.required?f(i,d.required):f(i,!1),"undefined"!=typeof d.priority&&i.data("priority",d.priority),"state"!==e&&("undefined"!=typeof d.hidden&&!0===d.hidden?i.hide().find("input").val(""):i.show())}),s(".woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields").each(function(e,a){var i=s(a).find(".form-row"),d=i.first().parent(),t=0;i.each(function(){s(this).data("priority")||s(this).data("priority",t+1),t=s(this).data("priority")}),i.sort(function(e,a){var i=s(e).data("priority"),d=s(a).data("priority");return d<i?1:i<d?-1:0}),i.detach().appendTo(d)})})}); |