<commit_before>$(document).ready(function() {
    var report = $('.review-reason').parent().html();
    $('.flag-review').addPopup(report)
        .bind('newPopup', function(e, popup) {
            // If there's a click on one of the flag links, submit it.
            // If they pick other, show the extra text field.
            $(popup).click(function(e) {
                var parent = $(this).parent(),
                    url = parent.find('.flag-review').attr('href');
                if ($(e.target).filter('a').length) {
                    e.preventDefault();
                    var flag = $(e.target).attr('href').slice(1)
                    if (flag == 'other') {
                        // Show the Other form and bind the submit.
                        parent.addClass('other');
                        $(this).find('form').submit(function(e){
                            e.preventDefault();
                            var note = parent.find('#id_note').val();
                            if (!note) {
                                alert(gettext('Your input is required'));
                                return false;
                            }
                            addFlag(parent, url, 'other', note);
                        });
                    } else {
                        addFlag(parent, url, flag, '');
                    }
                }
            });
        });

    var addFlag = function(el, url, flag, note) {
        $.ajax({type: 'POST',
                url: url,
                data: {flag: flag, note: note},
                success: function(){
                    el.find('.flag-review')
                        .replaceWith(gettext('Flagged for review'));
                },
                error: function(){ },
                dataType: 'json'
        });
    };

    $('.delete-review').click(function(e) {
        e.preventDefault();
        var target = $(e.target);
        $.post(target.attr('href'), function() {
            target.replaceWith(gettext('Marked for deletion'));
        });
        target.closest('.review').addClass('deleted');
    });
});<commit_msg>click on the review to close the report popup (bug 577379)<commit_after>$(document).ready(function() {
    var report = $('.review-reason').parent().html();
    $('.flag-review').addPopup(report)
        .bind('newPopup', function(e, popup) {
            // If there's a click on one of the flag links, submit it.
            // If they pick other, show the extra text field.
            $(popup).click(function(e) {
                var parent = $(this).parent(),
                    url = parent.find('.flag-review').attr('href');
                if ($(e.target).filter('a').length) {
                    e.preventDefault();
                    var flag = $(e.target).attr('href').slice(1)
                    if (flag == 'other') {
                        // Show the Other form and bind the submit.
                        parent.addClass('other');
                        $(this).find('form').submit(function(e){
                            e.preventDefault();
                            var note = parent.find('#id_note').val();
                            if (!note) {
                                alert(gettext('Your input is required'));
                                return false;
                            }
                            addFlag(parent, url, 'other', note);
                        });
                    } else {
                        addFlag(parent, url, flag, '');
                    }
                }
            });
        });

    var addFlag = function(el, url, flag, note) {
        $.ajax({type: 'POST',
                url: url,
                data: {flag: flag, note: note},
                success: function() {
                    el.find('.flag-review')
                        .replaceWith(gettext('Flagged for review'));
                },
                error: function(){ },
                complete: function() { el.click() },
                dataType: 'json'
        });
    };

    $('.delete-review').click(function(e) {
        e.preventDefault();
        var target = $(e.target);
        $.post(target.attr('href'), function() {
            target.replaceWith(gettext('Marked for deletion'));
        });
        target.closest('.review').addClass('deleted');
    });
});
{'fraction_non_alphanumeric': 0.1496458761708933, 'fraction_numerical': 0.0018277358921635824, 'mean_word_length': 1.1781094527363185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4863505', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1027, 'n_words': 233}