<commit_before>{% load i18n %}


/*
 * Create and display a new modal dialog
 */
function createNewModal(options={}) {

    var id = options.id || 0;

    // Always increment the ID of the modal
    id += 1;

    var html = `
    <div class='modal fade modal-fixed-footer modal-primary' role='dialog' id='modal-form-${id}'>
        <div class='modal-dialog'>
            <div class='modal-content'>
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label='{% trans "Close" %}'>
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h3 id='modal-title'>
                        <!-- Form title to be injected here -->
                    </h3>
                </div>
                <div class='modal-form-content-wrapper'>
                    <div id='pre-form-content'>
                        <!-- Content can be inserted here *before* the form fields -->
                    </div>
                    <div id='non-field-errors'>
                        <!-- Form error messages go here -->
                    </div>
                    <div id='form-content' class='modal-form-content'>
                        <!-- Form content will be injected here-->
                    </div>
                    <div id='post-form-content'>
                        <!-- Content can be inserted here *after* the form fields -->
                    </div>
                </div>
                <div class='modal-footer'>
                    <div id='modal-footer-buttons'>
                        <!-- Extra buttons can be inserted here -->
                    </div>
                    <button type='button' class='btn btn-default' id='modal-form-close' data-dismiss='modal'>{% trans "Cancel" %}</button>
                    <button type='button' class='btn btn-primary' id='modal-form-submit'>{% trans "Submit" %}</button>
                </div>
            </div>
        </div>
    </div>
    `;

    $('body').append(html);

    var modal_name = `#modal-form-${id}`;

    // Automatically remove the modal when it is deleted!
    $(modal_name).on('hidden.bs.modal', function(e) {
        $(modal_name).remove();
    });

    // Set labels based on supplied options
    modalSetTitle(modal_name, options.title || '{% trans "Form Title" %}');
    modalSetSubmitText(modal_name, options.submitText || '{% trans "Submit" %}');
    modalSetCloseText(modal_name, options.cancelText || '{% trans "Cancel" %}');
<commit_msg>Capture enter key to submit form<commit_after>{% load i18n %}


/*
 * Create and display a new modal dialog
 */
function createNewModal(options={}) {

    var id = options.id || 0;

    // Always increment the ID of the modal
    id += 1;

    var html = `
    <div class='modal fade modal-fixed-footer modal-primary' role='dialog' id='modal-form-${id}'>
        <div class='modal-dialog'>
            <div class='modal-content'>
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label='{% trans "Close" %}'>
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h3 id='modal-title'>
                        <!-- Form title to be injected here -->
                    </h3>
                </div>
                <div class='modal-form-content-wrapper'>
                    <div id='pre-form-content'>
                        <!-- Content can be inserted here *before* the form fields -->
                    </div>
                    <div id='non-field-errors'>
                        <!-- Form error messages go here -->
                    </div>
                    <div id='form-content' class='modal-form-content'>
                        <!-- Form content will be injected here-->
                    </div>
                    <div id='post-form-content'>
                        <!-- Content can be inserted here *after* the form fields -->
                    </div>
                </div>
                <div class='modal-footer'>
                    <div id='modal-footer-buttons'>
                        <!-- Extra buttons can be inserted here -->
                    </div>
                    <button type='button' class='btn btn-default' id='modal-form-close' data-dismiss='modal'>{% trans "Cancel" %}</button>
                    <button type='button' class='btn btn-primary' id='modal-form-submit'>{% trans "Submit" %}</button>
                </div>
            </div>
        </div>
    </div>
    `;

    $('body').append(html);

    var modal_name = `#modal-form-${id}`;

    $(modal_name).on('shown.bs.modal', function() {
        $(modal_name + ' .modal-form-content').scrollTop(0);
    });

    // Automatically remove the modal when it is deleted!
    $(modal_name).on('hidden.bs.modal', function(e) {
        $(modal_name).remove();
    });

    // Capture "enter" key input
    $(modal_name).on('keydown', 'input', function(event) {

        
        if (event.keyCode == 13) {
            event.preventDefault();
            // Simulate a click on the 'Submit' button
            $(modal_name).find("#modal-form-submit").click();
            
            return false;
        }
    });

    $(modal_name).modal({
        backdrop: 'static',
        keyboard: false,
    });

    // Set labels based on supplied options
    modalSetTitle(modal_name, options.title || '{% trans "Form Title" %}');
    modalSetSubmitText(modal_name, options.submitText || '{% trans "Submit" %}');
    modalSetCloseText(modal_name, options.cancelText || '{% trans "Cancel" %}');

{'fraction_non_alphanumeric': 0.1535481598873041, 'fraction_numerical': 0.002641310089804543, 'mean_word_length': 1.5505163897620118, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 79, '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': '7226220', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1447, 'n_words': 377}