<commit_before>{% extends 'forms/base_widget.html' %}
{% from 'forms/_form.html' import form_field %}


{% block html %}
    {% for subfield in field %}
        <div class="i-radio i-linking form-subfield{% if has_error[subfield.data] %} has-error{% endif %}">
            {% set dropdown = form[subfield.data] if subfield.data in form.conditional_fields %}
            {% set disabled = dropdown is defined and dropdown.choices|length <= 1 %}
            {{ subfield(disabled=disabled) }}
            {{ subfield.label }}
            {% if dropdown %}
                {{ form_field(dropdown, "i-linking-dropdown form-subfield") }}
            {% elif subfield.data == 'event' %}
                <span class='static-text'>{{ form.event.getTitle() }}</span>
            {% endif %}
        </div>
    {% endfor %}
{% endblock %}


{% block javascript %}
    <script>
        $(function() {
            'use strict';

            function update_dropdown_state() {
                var $this = $(this);
                if ($this.prop('checked')) {
                    $this.closest('.i-radio').siblings('.i-radio').find('.i-linking-dropdown select').prop('disabled', true);
                    $this.siblings('.i-linking-dropdown').find('select').prop('disabled', false);
                }
            }

            $('.i-linking > .i-linking-dropdown > select > option[value=""]').prop('disabled', true);

            $('.i-linking.i-radio input[type="radio"]')
                .off('change').on('change', update_dropdown_state)
                .each(update_dropdown_state);
        });
    </script>
{% endblock %}
<commit_msg>Use self-executing function<commit_after>{% extends 'forms/base_widget.html' %}
{% from 'forms/_form.html' import form_field %}


{% block html %}
    {% for subfield in field %}
        <div class="i-radio i-linking form-subfield{% if has_error[subfield.data] %} has-error{% endif %}">
            {% set dropdown = form[subfield.data] if subfield.data in form.conditional_fields %}
            {% set disabled = dropdown is defined and dropdown.choices|length <= 1 %}
            {{ subfield(disabled=disabled) }}
            {{ subfield.label }}
            {% if dropdown %}
                {{ form_field(dropdown, "i-linking-dropdown form-subfield") }}
            {% elif subfield.data == 'event' %}
                <span class='static-text'>{{ form.event.getTitle() }}</span>
            {% endif %}
        </div>
    {% endfor %}
{% endblock %}


{% block javascript %}
    <script>
        (function() {
            'use strict';

            function update_dropdown_state() {
                var $this = $(this);
                if ($this.prop('checked')) {
                    $this.closest('.i-radio').siblings('.i-radio').find('.i-linking-dropdown select').prop('disabled', true);
                    $this.siblings('.i-linking-dropdown').find('select').prop('disabled', false);
                }
            }

            $('.i-linking > .i-linking-dropdown > select > option[value=""]').prop('disabled', true);

            $('.i-linking.i-radio input[type="radio"]')
                .off('change').on('change', update_dropdown_state)
                .each(update_dropdown_state);
        })();
    </script>
{% endblock %}

{'fraction_non_alphanumeric': 0.17436524931171613, 'fraction_numerical': 0.000611807892321811, 'mean_word_length': 2.033395176252319, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '5992448', 'n_tokens_mistral': 1005, 'n_tokens_neox': 884, 'n_words': 170}