<commit_before>/**
 * Show and edit tags.
 * Tabbing issue on Firefox: https://github.com/selectize/selectize.js/issues/396; fix has languished
 * as PR since 2015-02-20.
 **/
var $ = require("jquery"),
    _ = require("underscore"),
    Backbone = require("backbone"),
    Handlebars = require("handlebars"),
    Selectize = require("selectize"),
    TagInputTemplate = require("./templates/taginput.html");

var TagInputView = Backbone.View.extend({
    _logHeader: "[TagInputView]",
    tagName: "div",

    initialize: function(options) {
        this.template = Handlebars.compile(TagInputTemplate);
        this.configuration = options.configuration || {};
        this.tagCollection = options.tagCollection || null;
    },

    render: function() {
        this.$el.html(this.template());
        this.$("#simpleshelf-tag-input").selectize({
            options: this.tagCollection.map(function(tag) {
                return {"value": tag.id, "text": tag.id};
            }),
            items: _.isObject(this.model) ? this.model.get("tags") : [],
            delimiter: ",",
            hideSelected: true,
            create: true,
            onFocus: function() {
                console.info("selectize", "onFocus()");
            },
            onChange: _.bind(this.onTagChange, this),
        });
        console.info(this._logHeader, "selectize ready?");
    },

    /* EVENTS */
    onTagChange: function(value) {
        console.info("selectize", "onChange()", value, value.split(","));
        this.model.set("tags", value.split(","));
    }
});

module.exports = TagInputView;<commit_msg>Clean up logging<commit_after>/**
 * Show and edit tags.
 * Tabbing issue on Firefox: https://github.com/selectize/selectize.js/issues/396; fix has languished
 * as PR since 2015-02-20.
 **/
var $ = require("jquery"),
    _ = require("underscore"),
    Backbone = require("backbone"),
    Handlebars = require("handlebars"),
    Selectize = require("selectize"),
    TagInputTemplate = require("./templates/taginput.html");

var TagInputView = Backbone.View.extend({
    _logHeader: "[TagInputView]",
    tagName: "div",

    initialize: function(options) {
        this.template = Handlebars.compile(TagInputTemplate);
        this.configuration = options.configuration || {};
        this.tagCollection = options.tagCollection || null;
    },

    render: function() {
        this.$el.html(this.template());
        this.$("#simpleshelf-tag-input").selectize({
            options: this.tagCollection.map(function(tag) {
                return {"value": tag.id, "text": tag.id};
            }),
            items: _.isObject(this.model) ? this.model.get("tags") : [],
            delimiter: ",",
            hideSelected: true,
            create: true,
            onChange: _.bind(this.onTagChange, this),
        });
    },

    /* EVENTS */
    onTagChange: function(value) {
        console.info(this._logHeader, "selectize.onChange()", value.split(","));
        this.model.set("tags", value.split(","));
    }
});

module.exports = TagInputView;
{'fraction_non_alphanumeric': 0.16546997389033943, 'fraction_numerical': 0.007180156657963447, 'mean_word_length': 2.61438679245283, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3284633', 'n_tokens_mistral': 903, 'n_tokens_neox': 876, 'n_words': 161}