Skip to content

Commit

Permalink
Bug #57928: Revert accidental JS commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiaanGrutters committed Oct 16, 2023
1 parent 1838ed8 commit fa696a0
Showing 1 changed file with 6 additions and 32 deletions.
38 changes: 6 additions & 32 deletions assets/js/postcode-eu-autofill.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

// Wrap in timeout to execute after Woocommerce field logic:
window.setTimeout(function () {
toggleAddressFields(getAddressFields(container), !isSupportedCountry(selectedCountry), true, isSupportedCountry(selectedCountry));
toggleAddressFields(getAddressFields(container), !isSupportedCountry(selectedCountry), true);
});
}).trigger('change.postcode-eu.address-fields');
})
Expand Down Expand Up @@ -96,7 +96,7 @@
}
}

const toggleAddressFields = function (addressFields, state, force, isSupportedCountry)
const toggleAddressFields = function (addressFields, state, force)
{
if (!force)
{
Expand All @@ -120,33 +120,7 @@

if (field.length > 0 && field.prop('type') !== 'hidden')
{
let formRow = field.closest('.form-row');
formRow.toggle(state);
let input = formRow.find('input[type="text"]');
if (input.length === 0)
{
continue;
}
if (state && !isSupportedCountry)
{
let previousValue = input.attr('previous-autocomplete');
if (previousValue)
{
input.attr('autocomplete', previousValue);
}
else
{
input.attr('autocomplete', null);
}
}
else
{
if (!input.attr('previous-autocomplete'))
{
input.attr('previous-autocomplete', input.attr('autocomplete'));
}
input.attr('autocomplete', 'off');
}
field.closest('.form-row').toggle(state);
}
}
}
Expand Down Expand Up @@ -573,7 +547,7 @@

const callback = (result) => {
fillAddressFieldsIntl(result);
toggleAddressFields(addressFields, true, false, true);
toggleAddressFields(addressFields, true);
intlField
.removeClass('postcodenl-address-autocomplete-loading')
.trigger('address-result', result);
Expand Down Expand Up @@ -633,7 +607,7 @@

document.addEventListener('autocomplete-xhrerror', function (e) {
console.error('Autocomplete XHR error', e);
toggleAddressFields(addressFields, true, false, true);
toggleAddressFields(addressFields, true);
intlField.removeClass('postcodenl-address-autocomplete-loading')
setFieldValidity(
intlField,
Expand Down Expand Up @@ -754,7 +728,7 @@
link = $('<a>', {'class': 'postcode-eu-autofill-intl-bypass-link', text: settings.autofillIntlBypassLinkText});

link.on('click', function () {
toggleAddressFields(getAddressFields(container), true, true, true);
toggleAddressFields(getAddressFields(container), true, true);
formRow.hide();
return false;
});
Expand Down

0 comments on commit fa696a0

Please sign in to comment.