<commit_before>/**
 * Follow button
 */
define(['jquery', 'api', 'auth', 'i18n', 'notify'],
function($, API, Auth, i18n, Notify) {
    'use strict';

    function hideNewForm(el, form) {
        form.addClass('fadeOutDown');
        setTimeout(function() {
            form.addClass('hidden');
        }, 1000);
    }

    function submitNewComment(el, form, data) {
        API.post(form.data('api-url'), data, function(data) {
            var msg = i18n._('Your comment has been sent to the server');
            Notify.success(msg);
        }).error(function(e) {
            var msg = i18n._('An error occured while submitting your comment');
            Notify.error(msg);
            console.error(e.responseJSON);
        });
    }

    function displayNewDiscussionForm(el) {
        $('.list-group-form-discussion').removeClass('hidden').addClass('fadeInDown');
    }

    function hideNewDiscussionButton(el) {
        el.addClass('hidden');
    }

    $('.new-discussion').click(function(e) {
        e.preventDefault();
        var $this = $(this);

        if (!Auth.need_user(i18n._('You need to be logged in to discuss.'))) {
            return false;
        }

        displayNewDiscussionForm($this);
        hideNewDiscussionButton($this);
    });

    $('.new-comment').click(function(e) {
        e.preventDefault();
        var $this = $(this);

        if (!Auth.need_user(i18n._('You need to be logged in to comment.'))) {
            return false;
        }

        function displayNewCommentForm(el) {
            var discussionId = el.data('discussion-id');
            $('.list-group-form-' + discussionId).removeClass('hidden').addClass('fadeInDown');
        }

        function hideNewCommentButton(el) {
            el.addClass('hidden');
        }

        displayNewCommentForm($this);
        hideNewCommentButton($this);
    });

    $('.open-discussion-thread').click(function(e) {
        e.preventDefault();
        var $this = $(this);

        function openDiscussionThread(el) {
            var discussionId = el.parent().data('discussion-id');
            $('.list-group-thread-' + discussionId).removeClass('hidden').addClass('fadeInDown');
            $('.list-group-form-' + discussionId).addClass('hidden');
        }

        openDiscussionThread($this);
    });

    $('.submit-new-discussion').click(function(e) {
        e.preventDefault();
        var $this = $(this);
        var $form = $this.parent();
        var $newMessage = $('.list-group-new-message');

        if (!Auth.need_user(i18n._('You need to be logged in to add a discussion.')) || !$form.valid()) {
            return false;
        }

        var data = {
            title: $form.find('#title-new-discussion').val(),
            comment: $form.find('#comment-new-discussion').val(),
            subject: $form.data('subject')
        };

        function displayNewDiscussion(el, form, data, newMessage) {
            form.siblings('.list-group-item-heading').text(data.title);
            form.siblings('.list-group-item-text').text(i18n._('Discussion started today with your message.'));
            form.parent().css('height', '54px');
            newMessage.addClass('fadeInDown').removeClass('hidden');
            newMessage.children('.list-group-item-heading').text(data.comment);
        }

        hideNewForm($this, $form);
        displayNewDiscussion($this, $form, data, $newMessage);
        submitNewComment($this, $form, data);
    });

    $('.submit-new-message').click(function(e) {
        e.preventDefault();
        var $this = $(this);
        var $form = $this.parent();
        var discussionId = $form.parent().data('discussion-id');

        if (!Auth.need_user(i18n._('You need to be logged in to add a comment.')) || !$form.valid()) {
            return false;
        }

        var data = {
            comment: $form.find('#comment-new-message').val()
        };

        function displayNewComment(el, form, data) {
            form.siblings('.list-group-item-heading').text(data.comment);
            form.siblings('.list-group-item-text').remove();
            form.parent().css('min-height', '54px');
            $('.list-group-message-number-' + discussionId).append(i18n._('and your comment!'));
        }

        hideNewForm($this, $form);
        displayNewComment($this, $form, data);
        submitNewComment($this, $form, data);
    });

    $('.suggest-tag').click(function(e) {
        e.preventDefault();
        var $newDiscussion = $('.new-discussion');
        var $form = $newDiscussion.parent();

        // Otherwise the scrollTop is not effective if the form is already
        // displayed (hence the new discussion button is hidden)
        $newDiscussion.removeClass('hidden');

        // Scroll to the new discussion thread form
        $('html, body').animate({
            scrollTop : $newDiscussion.offset().top
        }, 400);

        if (!Auth.need_user(i18n._('You need to be logged in to propose a tag.'))) {
            return false;
        }

        displayNewDiscussionForm($newDiscussion);
        hideNewDiscussionButton($newDiscussion);

        // Prefill the new discussion thread form
        $form.find('#title-new-discussion').val(
            i18n._('New tag suggestion to improve metadata'));
        $form.find('#comment-new-discussion').val(
            i18n._('Hello,\n\nI propose this new tag: '));
    });

});
<commit_msg>Splitting a translation to avoid newlines<commit_after>/**
 * Follow button
 */
define(['jquery', 'api', 'auth', 'i18n', 'notify'],
function($, API, Auth, i18n, Notify) {
    'use strict';

    function hideNewForm(el, form) {
        form.addClass('fadeOutDown');
        setTimeout(function() {
            form.addClass('hidden');
        }, 1000);
    }

    function submitNewComment(el, form, data) {
        API.post(form.data('api-url'), data, function(data) {
            var msg = i18n._('Your comment has been sent to the server');
            Notify.success(msg);
        }).error(function(e) {
            var msg = i18n._('An error occured while submitting your comment');
            Notify.error(msg);
            console.error(e.responseJSON);
        });
    }

    function displayNewDiscussionForm(el) {
        $('.list-group-form-discussion').removeClass('hidden').addClass('fadeInDown');
    }

    function hideNewDiscussionButton(el) {
        el.addClass('hidden');
    }

    $('.new-discussion').click(function(e) {
        e.preventDefault();
        var $this = $(this);

        if (!Auth.need_user(i18n._('You need to be logged in to discuss.'))) {
            return false;
        }

        displayNewDiscussionForm($this);
        hideNewDiscussionButton($this);
    });

    $('.new-comment').click(function(e) {
        e.preventDefault();
        var $this = $(this);

        if (!Auth.need_user(i18n._('You need to be logged in to comment.'))) {
            return false;
        }

        function displayNewCommentForm(el) {
            var discussionId = el.data('discussion-id');
            $('.list-group-form-' + discussionId).removeClass('hidden').addClass('fadeInDown');
        }

        function hideNewCommentButton(el) {
            el.addClass('hidden');
        }

        displayNewCommentForm($this);
        hideNewCommentButton($this);
    });

    $('.open-discussion-thread').click(function(e) {
        e.preventDefault();
        var $this = $(this);

        function openDiscussionThread(el) {
            var discussionId = el.parent().data('discussion-id');
            $('.list-group-thread-' + discussionId).removeClass('hidden').addClass('fadeInDown');
            $('.list-group-form-' + discussionId).addClass('hidden');
        }

        openDiscussionThread($this);
    });

    $('.submit-new-discussion').click(function(e) {
        e.preventDefault();
        var $this = $(this);
        var $form = $this.parent();
        var $newMessage = $('.list-group-new-message');

        if (!Auth.need_user(i18n._('You need to be logged in to add a discussion.')) || !$form.valid()) {
            return false;
        }

        var data = {
            title: $form.find('#title-new-discussion').val(),
            comment: $form.find('#comment-new-discussion').val(),
            subject: $form.data('subject')
        };

        function displayNewDiscussion(el, form, data, newMessage) {
            form.siblings('.list-group-item-heading').text(data.title);
            form.siblings('.list-group-item-text').text(i18n._('Discussion started today with your message.'));
            form.parent().css('height', '54px');
            newMessage.addClass('fadeInDown').removeClass('hidden');
            newMessage.children('.list-group-item-heading').text(data.comment);
        }

        hideNewForm($this, $form);
        displayNewDiscussion($this, $form, data, $newMessage);
        submitNewComment($this, $form, data);
    });

    $('.submit-new-message').click(function(e) {
        e.preventDefault();
        var $this = $(this);
        var $form = $this.parent();
        var discussionId = $form.parent().data('discussion-id');

        if (!Auth.need_user(i18n._('You need to be logged in to add a comment.')) || !$form.valid()) {
            return false;
        }

        var data = {
            comment: $form.find('#comment-new-message').val()
        };

        function displayNewComment(el, form, data) {
            form.siblings('.list-group-item-heading').text(data.comment);
            form.siblings('.list-group-item-text').remove();
            form.parent().css('min-height', '54px');
            $('.list-group-message-number-' + discussionId).append(i18n._('and your comment!'));
        }

        hideNewForm($this, $form);
        displayNewComment($this, $form, data);
        submitNewComment($this, $form, data);
    });

    $('.suggest-tag').click(function(e) {
        e.preventDefault();
        var $newDiscussion = $('.new-discussion');
        var $form = $newDiscussion.parent();

        // Otherwise the scrollTop is not effective if the form is already
        // displayed (hence the new discussion button is hidden)
        $newDiscussion.removeClass('hidden');

        // Scroll to the new discussion thread form
        $('html, body').animate({
            scrollTop : $newDiscussion.offset().top
        }, 400);

        if (!Auth.need_user(i18n._('You need to be logged in to propose a tag.'))) {
            return false;
        }

        displayNewDiscussionForm($newDiscussion);
        hideNewDiscussionButton($newDiscussion);

        // Prefill the new discussion thread form
        $form.find('#title-new-discussion').val(
            i18n._('New tag suggestion to improve metadata'));
        $form.find('#comment-new-discussion').val(
            i18n._('Hello,') + '\n\n' + i18n._('I propose this new tag: '));
    });

});

{'fraction_non_alphanumeric': 0.16355140186915887, 'fraction_numerical': 0.006963533076782115, 'mean_word_length': 2.294597041955931, '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': '6513488', 'n_tokens_mistral': 3188, 'n_tokens_neox': 3007, 'n_words': 607}