<commit_before>/*
 * This file is part of the Sylius package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

(function ( $ ) {
    'use strict';

    $(document).ready(function() {
        $('select[name$="[country]"]').on('change', function(event) {
            var $select = $(event.currentTarget);
            var $provinceContainer = $select.closest('div.form-group').next('div.province-container');
            var provinceName = $select.attr('name').replace('country', 'province');

            if (null === $select.val()) {
                return;
            }

            $.get($provinceContainer.attr('data-url'), {countryId: $(this).val()}, function (response) {
                if (!response.content) {
                    $provinceContainer.fadeOut('slow', function () {
                        $provinceContainer.html('');
                    });
                } else {
                    $provinceContainer.fadeOut('slow', function () {
                        $provinceContainer.html(response.content.replace(
                            'name="sylius_address_province"',
                            'name="' + provinceName + '"'
                        ));

                        $provinceContainer.fadeIn();<commit_msg>Don't make ajax request for provinces if contry value is empty<commit_after>/*
 * This file is part of the Sylius package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

(function ( $ ) {
    'use strict';

    $(document).ready(function() {
        $('select[name$="[country]"]').on('change', function(event) {
            var $select = $(event.currentTarget);
            var $provinceContainer = $select.closest('div.form-group').next('div.province-container');
            var provinceName = $select.attr('name').replace('country', 'province');

            if ('' === $select.val()) {
                $provinceContainer.fadeOut('slow', function () {
                    $provinceContainer.html('');
                });
                return;
            }

            $.get($provinceContainer.attr('data-url'), {countryId: $(this).val()}, function (response) {
                if (!response.content) {
                    $provinceContainer.fadeOut('slow', function () {
                        $provinceContainer.html('');
                    });
                } else {
                    $provinceContainer.fadeOut('slow', function () {
                        $provinceContainer.html(response.content.replace(
                            'name="sylius_address_province"',
                            'name="' + provinceName + '"'
                        ));

                        $provinceContainer.fadeIn();
{'fraction_non_alphanumeric': 0.14529023288147375, 'fraction_numerical': 0.0, 'mean_word_length': 1.754066985645933, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1373393', 'n_tokens_mistral': 753, 'n_tokens_neox': 704, 'n_words': 147}