<commit_before>$(document).ready(function() {

    // Support for AJAX loaded modal window.
    // Focuses on first input textbox after it loads the window.
    // To use it  : <a href="/url/to/load/modal_window.htm" data-toggle="modal">link</a>
    $(document).on('click', '[data-toggle="ajax-modal"]', function(e) {
        e.preventDefault();
        $('.modal').modal('hide').on('hidden.bs.modal', function(){$(this).remove()});
        var url = $(this).attr('href');
        var customClass = $(this).attr('data-modal-class') ? $(this).attr('data-modal-class') : '';
        if (url.indexOf('#') == 0) {
            $(url).modal('show');
        } else {
            $('#canvasloader-container').fadeIn();
            $.get(url, function(data) {
                var modalContent = '<div id="ajax-modal" class="modal fade' + customClass + '">' + data + '</div>';
                $('body').append(modalContent);
                $('#ajax-modal').modal('show');
            }).success(function() { 
                $('input:text:visible:first').focus(); 
                $('#canvasloader-container').fadeOut();
            });
        }
    });

});
<commit_msg>improve remove modal markup from dom when closing it<commit_after>$(document).ready(function() {

    // Support for AJAX loaded modal window.
    // Focuses on first input textbox after it loads the window.
    // To use it  : <a href="/url/to/load/modal_window.htm" data-toggle="modal">link</a>
    $(document).on('click', '[data-toggle="ajax-modal"]', function(e) {
        e.preventDefault();
        $('.modal').modal('hide').on('hidden.bs.modal', function(){$(this).remove()});
        var url = $(this).attr('href');
        var customClass = $(this).attr('data-modal-class') ? $(this).attr('data-modal-class') : '';
        if (url.indexOf('#') == 0) {
            $(url).modal('show');
        } else {
            $('#canvasloader-container').fadeIn();
            $.get(url, function(data) {
                var modalContent = '<div id="ajax-modal" class="modal fade' + customClass + '">' + data + '</div>';
                $('body').append(modalContent);
                $('#ajax-modal').modal('show');
            }).success(function() { 
                $('input:text:visible:first').focus(); 
                $('#canvasloader-container').fadeOut();
            });
        }
    });
});

$(document).on('hidden.bs.modal', function() {
    $('#ajax-modal').remove();
});
{'fraction_non_alphanumeric': 0.21854575163398693, 'fraction_numerical': 0.0008169934640522876, 'mean_word_length': 2.364010989010989, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4419103', 'n_tokens_mistral': 715, 'n_tokens_neox': 694, 'n_words': 127}