<commit_before>/**
 * Spines by first letter of title view.
 */
var _ = require("underscore"),
    Backbone = require("backbone"),
    Handlebars = require("handlebars"),
    template = require("./templates/spinesbylettercollapsible.html"),
    spineTemplate = require("./templates/spinelistitem.html");

var SpinesByLetterView = Backbone.View.extend({

    initialize: function(options) {
        this.template = Handlebars.compile(template);
        this.spineTemplate = Handlebars.compile(spineTemplate);
        this.spineCollection = _.has(options, "spineCollection") ? options.spineCollection : null;
        if (!_.isNull(this.spineCollection)) {
            this.listenTo(this.spineCollection, "sync", "onSpineSync");
        }
        return this;
    },

    render: function() {
        this.$el = $(this.template(this.model.toJSON()));
        return this;
    },

    postRender: function() {
        // Add the spines to the list.
        this._renderList();
        return this;
    },

    _renderList: function() {
        var spines = this.spineCollection.where({firstLetter: this.model.id}),
            $listParent = this.$(".list-group");

        // REFACTOR: create sub-view for spine.
        _.each(spines, function(spine) {
            $listParent.append(this.spineTemplate(spine.toJSON()));
        }, this);
    },

    // EVENTS //
    onSpineSync: function() {
        console.info("[SpinesByLetterView]", "spineCollection synced", this.spineCollection.size());
    }
});

module.exports = SpinesByLetterView;
<commit_msg>Fix .listenTo syntax<commit_after>/**
 * Spines by first letter of title view.
 */
var _ = require("underscore"),
    Backbone = require("backbone"),
    Handlebars = require("handlebars"),
    template = require("./templates/spinesbylettercollapsible.html"),
    spineTemplate = require("./templates/spinelistitem.html");

var SpinesByLetterView = Backbone.View.extend({

    initialize: function(options) {
        this.template = Handlebars.compile(template);
        this.spineTemplate = Handlebars.compile(spineTemplate);
        this.spineCollection = _.has(options, "spineCollection") ? options.spineCollection : null;
        if (!_.isNull(this.spineCollection)) {
            this.listenTo(this.spineCollection, "sync", this.onSpineSync);
        }
        return this;
    },

    render: function() {
        this.$el = $(this.template(this.model.toJSON()));
        return this;
    },

    postRender: function() {
        // Add the spines to the list.
        this._renderList();
        return this;
    },

    _renderList: function() {
        var spines = this.spineCollection.where({firstLetter: this.model.id}),
            $listParent = this.$(".list-group");

        // REFACTOR: create sub-view for spine.
        _.each(spines, function(spine) {
            $listParent.append(this.spineTemplate(spine.toJSON()));
        }, this);
    },

    // EVENTS //
    onSpineSync: function() {
        console.info("[SpinesByLetterView]", "spineCollection synced", this.spineCollection.size());
    }
});

module.exports = SpinesByLetterView;

{'fraction_non_alphanumeric': 0.1438664097623635, 'fraction_numerical': 0.0, 'mean_word_length': 2.7941534713763705, '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': '2253629', 'n_tokens_mistral': 920, 'n_tokens_neox': 895, 'n_words': 166}