<commit_before>define([
    'require',
    '../lib/jquery',
    '../lib/jquery.form'
], function(require) {

    var init = function($el, opts) {
        var $first = $el.children(':first'),
            $rest = $el.children(':not(:first)'),
            $header = $('<div class="header" />'),
            $body = $('<div class="body" />'),
            $form = $el.find('form'),
            $closebutton = $(
                '<button type="button" class="close-panel">Close</button>');

        // separate into header and body
        if ($rest.length === 0) {
            $first.wrap($body);
            $el.prepend($header);
        } else {
            $first.wrap($header);
            $rest.wrapAll($body);
        }

        // add close-panel button to header
        $('.header', $el).append($closebutton);

        // event handler to remove element
        var remove = function(ev) {
            ev.preventDefault();
            $(ev.currentTarget).off('.remove.modal');
            $el.remove();
        };

        // remove on ESC
        $(document).on('keyup.remove.modal', function(ev) {
            if (ev.which == 27) remove(ev);
        });
        // remove on close-panel button click
        $el.find('.close-panel').on('click.remove.modal', remove);
        // remove on click of triggering element
        if (opts.$trigger_el) opts.$trigger_el.on('click.remove.modal', remove);

        // close forms that are successfully submitted or show error
        var url = $form.attr('action');
        if ($form) {
            // prepare ajax request and submit function
            var params = {
                url: url,
                type: 'POST',
                error: function(jqXHR, textStatus, errorThrown) {
                    var msg = [jqXHR.status, textStatus, url].join(' ');
                    $form.replaceWith($('<div />').html(msg));
                    console.error(jqXHR, textStatus, errorThrown);
                },
                success: function(data, textStatus, jqXHR) {
                    console.log(data, textStatus, jqXHR);
                    $el.remove();
                }
            };
            var submit = function(ev) {
                ev.preventDefault();
                $form.ajaxSubmit(params);
            };
            $form.find('[type=submit]').on('click', submit);
        }
    };

    var pattern = {
        markup_trigger: "div.modal",
        initialised_class: "modal",
        default_opts: {
            shown: false
        },
        init: init
    };

    return pattern;
});<commit_msg>modal forms: add submit=submit, method and action taken from form<commit_after>define([
    'require',
    '../lib/jquery',
    '../lib/jquery.form'
], function(require) {

    var init = function($el, opts) {
        var $first = $el.children(':first'),
            $rest = $el.children(':not(:first)'),
            $header = $('<div class="header" />'),
            $body = $('<div class="body" />'),
            $form = $el.find('form'),
            $closebutton = $(
                '<button type="button" class="close-panel">Close</button>');

        // separate into header and body
        if ($rest.length === 0) {
            $first.wrap($body);
            $el.prepend($header);
        } else {
            $first.wrap($header);
            $rest.wrapAll($body);
        }

        // add close-panel button to header
        $('.header', $el).append($closebutton);

        // event handler to remove element
        var remove = function(ev) {
            ev.preventDefault();
            $(ev.currentTarget).off('.remove.modal');
            $el.remove();
        };

        // remove on ESC
        $(document).on('keyup.remove.modal', function(ev) {
            if (ev.which == 27) remove(ev);
        });
        // remove on close-panel button click
        $el.find('.close-panel').on('click.remove.modal', remove);
        // remove on click of triggering element
        if (opts.$trigger_el) opts.$trigger_el.on('click.remove.modal', remove);

        // close forms that are successfully submitted or show error
        if ($form) {
            // prepare ajax request and submit function
            var params = {
                data: { submit: "submit" },
                error: function(jqXHR, textStatus, errorThrown) {
                    var msg = [jqXHR.status, textStatus, url].join(' ');
                    $form.replaceWith($('<div />').html(msg));
                    console.error(jqXHR, textStatus, errorThrown);
                },
                success: function(data, textStatus, jqXHR) {
                    $el.remove();
                }
            };
            var submit = function(ev) {
                ev.preventDefault();
                $form.ajaxSubmit(params);
            };
            $form.find('[type=submit]').on('click', submit);
        }
    };

    var pattern = {
        markup_trigger: "div.modal",
        initialised_class: "modal",
        default_opts: {
            shown: false
        },
        init: init
    };

    return pattern;
});
{'fraction_non_alphanumeric': 0.15553809897879026, 'fraction_numerical': 0.001178318931657502, 'mean_word_length': 1.5696266397578205, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6473045', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1359, 'n_words': 304}