<commit_before>define([
    'backbone',
    'jquery',
    'underscore',
    'find/app/vent',
    'find/app/model/document-model',
    'find/app/model/promotions-collection',
    'find/app/page/search/sort-view',
    'find/app/page/search/results/results-number-view',
    'find/app/page/search/results/result-rendering/result-renderer',
    'find/app/page/search/results/result-rendering/result-renderer-config',
    'find/app/util/view-server-client',
    'find/app/util/events',
    'find/app/page/search/results/add-links-to-summary',
    'text!find/templates/app/page/search/results/results-view.html',
    'text!find/templates/app/page/search/results/results-container.html',
    'text!find/templates/app/page/loading-spinner.html',
    'moment',
    'i18n!find/nls/bundle',
    'i18n!find/nls/indexes'
], function(Backbone, $, _, vent, DocumentModel, PromotionsCollection, SortView, ResultsNumberView,
            ResultRenderer, resultsRendererConfig, viewClient, events, addLinksToSummary, template, resultsTemplate,
            loadingSpinnerTemplate, moment, i18n, i18n_indexes) {

    var SCROLL_INCREMENT = 30;
    var INFINITE_SCROLL_POSITION_PIXELS = 500;

    function infiniteScroll() {
        var resultsPresent = this.documentsCollection.size() > 0 && this.fetchStrategy.validateQuery(this.queryModel);

        if (resultsPresent && this.resultsFinished && !this.endOfResults) {
            this.start = this.maxResults + 1;
            this.maxResults += SCROLL_INCREMENT;

            this.loadData(true);

            events().page(this.maxResults / SCROLL_INCREMENT);
        }
    }

    return Backbone.View.extend({
        //to be overridden
        generateErrorMessage: null,

        template: _.template(template),
        loadingTemplate: _.template(loadingSpinnerTemplate)({i18n: i18n, large: true}),
        resultsTemplate: _.template(resultsTemplate),
        messageTemplate: _.template('<div class="result-message span10"><%-message%> </div>'),
        errorTemplate: _.template('<li class="error-message span10"><span><%-feature%>: </span><%-error%></li>'),

        events: {
            'click .highlighted-entity-text': function(e) {
                e.stopPropagation();

                var $target = $(e.target);
                var entity = $target.attr('data-entity-text');
                this.relatedConceptsClickHandler([entity]);
            },
            'click .preview-mode [data-cid]': function(e) {
                var $target = $(e.currentTarget);

                if ($target.hasClass('selected-document')) {
                    // disable preview mode
                    this.previewModeModel.set({document: null});
                } else {
                    //enable/choose another preview view
                    var cid = $target.data('cid');
                    var isPromotion = $target.closest('.main-results-list').hasClass('promotion');
                    var collection = isPromotion ? this.promotionsCollections : this.documentsCollection;
                    var model = collection.get(cid);<commit_msg>[FIND-97] Fix a couple of typos [for matt.gordon]<commit_after>define([
    'backbone',
    'jquery',
    'underscore',
    'find/app/vent',
    'find/app/model/document-model',
    'find/app/model/promotions-collection',
    'find/app/page/search/sort-view',
    'find/app/page/search/results/results-number-view',
    'find/app/page/search/results/result-rendering/result-renderer',
    'find/app/page/search/results/result-rendering/result-renderer-config',
    'find/app/util/view-server-client',
    'find/app/util/events',
    'find/app/page/search/results/add-links-to-summary',
    'text!find/templates/app/page/search/results/results-view.html',
    'text!find/templates/app/page/search/results/results-container.html',
    'text!find/templates/app/page/loading-spinner.html',
    'moment',
    'i18n!find/nls/bundle',
    'i18n!find/nls/indexes'
], function(Backbone, $, _, vent, DocumentModel, PromotionsCollection, SortView, ResultsNumberView,
            ResultRenderer, resultsRendererConfig, viewClient, events, addLinksToSummary, template, resultsTemplate,
            loadingSpinnerTemplate, moment, i18n, i18n_indexes) {

    var SCROLL_INCREMENT = 30;
    var INFINITE_SCROLL_POSITION_PIXELS = 500;

    function infiniteScroll() {
        var resultsPresent = this.documentsCollection.size() > 0 && this.fetchStrategy.validateQuery(this.queryModel);

        if (resultsPresent && this.resultsFinished && !this.endOfResults) {
            this.start = this.maxResults + 1;
            this.maxResults += SCROLL_INCREMENT;

            this.loadData(true);

            events().page(this.maxResults / SCROLL_INCREMENT);
        }
    }

    return Backbone.View.extend({
        //to be overridden
        generateErrorMessage: null,

        template: _.template(template),
        loadingTemplate: _.template(loadingSpinnerTemplate)({i18n: i18n, large: true}),
        resultsTemplate: _.template(resultsTemplate),
        messageTemplate: _.template('<div class="result-message span10"><%-message%> </div>'),
        errorTemplate: _.template('<li class="error-message span10"><span><%-feature%>: </span><%-error%></li>'),

        events: {
            'click .highlighted-entity-text': function(e) {
                e.stopPropagation();

                var $target = $(e.target);
                var entity = $target.attr('data-entity-text');
                this.relatedConceptsClickHandler([entity]);
            },
            'click .preview-mode [data-cid]': function(e) {
                var $target = $(e.currentTarget);

                if ($target.hasClass('selected-document')) {
                    // disable preview mode
                    this.previewModeModel.set({document: null});
                } else {
                    //enable/choose another preview view
                    var cid = $target.data('cid');
                    var isPromotion = $target.closest('.main-results-list').hasClass('promotions');
                    var collection = isPromotion ? this.promotionsCollection : this.documentsCollection;
                    var model = collection.get(cid);
{'fraction_non_alphanumeric': 0.13852114949951566, 'fraction_numerical': 0.007749434937035841, 'mean_word_length': 2.560344827586207, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, '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': '3438763', 'n_tokens_mistral': 1848, 'n_tokens_neox': 1756, 'n_words': 272}