<commit_before>/**
 * Created by babich on 12/19/14.
 */
define(['jquery', 'fury.notify'], function ($, notify) {
    $(function () {
        $("[rel='tooltip']").tooltip();
    });
    $('body')
        .on('click', '.submit-ajax-button', function () {
            $(this).closest('.modal').find('form.form-ajax').trigger('submit.ajax');
        })
        .on('submit.ajax', '.form-ajax', function (e) {
            e.preventDefault();
            var $this = $(this);
            var formData = $this.serializeArray();
            $.ajax({
                url: $this.attr('action'),
                type: 'POST',
                beforeSend: function () {
                    $('.modal').find('a, .btn').addClass('disabled');
                    $('.error-form-field').each(function (i, element) {
                        $(element).removeClass('error-form-field');
                    });
                    $('.error-form-message').each(function (i, element) {
                        $(element).html('');
                    });
                },
                success: function (jsonData) {
                    $('.modal').find('a, .btn').removeClass('disabled');
                    if (!$.isEmptyObject(jsonData.errors)) {
                        for (var key in jsonData.errors) {
                            var field = $this.find('.form-group .form-control[name="' + key + '"]');
                            field.addClass('form-control error-form-field');
                            field.attr("rel", "tooltip");
                            field.tooltip({
                                html: true,
                                title: jsonData.errors[key],
                                //title: jsonData.errors[key][0],
                                trigger: 'manual',
                                // change position for long messages, and for hidden fields
                                placement: (field.width() < 220) || field.is('label') ? 'right' : 'top',
                                animation: true
                            });
                            field.tooltip('show');
                            field.click(function () {
                                $(this).removeClass('error-form-field');
                                $(this).tooltip('destroy');
                            });
                            //field.next().html(jsonData.errors[key][0]);
                        }
                    } else {
                        $this.trigger('success.form.fury', []);
                        $('.close-form-button').trigger('click');
                        jsonData.success.forEach(function (entry) {
                            notify.addSuccess(entry);
                        });
                    }<commit_msg>Added tooltip for form error handling<commit_after>/**
 * Created by babich on 12/19/14.
 */
define(['jquery', 'fury.notify'], function ($, notify) {
    $(function () {
        $("[rel='tooltip']").tooltip();
    });
    $('body')
        .on('click', '.submit-ajax-button', function () {
            $(this).closest('.modal').find('form.form-ajax').trigger('submit.ajax');
        })
        .on('submit.ajax', '.form-ajax', function (e) {
            e.preventDefault();
            var $this = $(this);
            var formData = $this.serializeArray();
            $.ajax({
                url: $this.attr('action'),
                type: 'POST',
                beforeSend: function () {
                    $('.modal').find('a, .btn').addClass('disabled');
                    $('.error-form-field').each(function (i, element) {
                        $(element).removeClass('error-form-field');
                    });
                    $('.error-form-message').each(function (i, element) {
                        $(element).html('');
                    });
                },
                success: function (jsonData) {
                    $('.modal').find('a, .btn').removeClass('disabled');
                    if (!$.isEmptyObject(jsonData.errors)) {
                        for (var key in jsonData.errors) {
                            var field = $this.find('.form-group .form-control[name="' + key + '"]');
                            field.addClass('form-control error-form-field');
                            field.attr("rel", "tooltip");
                            field.tooltip({
                                html: true,
                                title: jsonData.errors[key].join('<br/>'),
                                trigger: 'manual',
                                // change position for long messages, and for hidden fields
                                placement: (field.width() < 220) || field.is('label') ? 'right' : 'top',
                                animation: true
                            });
                            field.tooltip('show');
                            field.click(function () {
                                $(this).removeClass('error-form-field');
                                $(this).tooltip('destroy');
                            });
                        }
                    } else {
                        $this.trigger('success.form.fury', []);
                        $('.close-form-button').trigger('click');
                        jsonData.success.forEach(function (entry) {
                            notify.addSuccess(entry);
                        });
                    }
{'fraction_non_alphanumeric': 0.1563643013899049, 'fraction_numerical': 0.0036576444769568397, 'mean_word_length': 1.0583364697026723, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5287851', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1220, 'n_words': 208}