<commit_before>var Backbone = require('backbone');
var $ = require('jquery');
var _ = require('underscore');
var EditorHelpers = require('../editor-helpers-extend');

/**
 * A single item in the list
 *
 * @param {editors.List} options.list The List editor instance this item belongs to
 * @param {Function} options.Editor   Editor constructor function
 * @param {String} options.key        Model key
 * @param {Mixed} options.value       Value
 * @param {Object} options.schema     Field schema
 */
Backbone.Form.editors.List.Item = Backbone.Form.editors.Base.extend({

  events: {
    'click [data-action="remove"]': function (event) {
      event.preventDefault();
      this.list.removeItem(this);
    },
    'keydown input[type=text]': function (event) {
      if (event.keyCode !== 13) return;
      event.preventDefault();
      this.list.addItem();
      this.list.$list.find('> li:last input').focus();
    }
  },

  initialize: function (options) {
    EditorHelpers.setOptions(this, options);
    this.list = options.list;
    this.schema = options.schema || this.list.schema;
    this.Editor = options.Editor || Backbone.Form.editors.Text;
    this.template = options.template || this.schema.itemTemplate || this.constructor.template;
    this.errorClassName = options.errorClassName || this.constructor.errorClassName;
  },

  render: function () {
    // Create editor
    this.editor = new this.Editor({
      key: this.options.key,
      schema: this.schema,
      value: this.options.value,
      list: this.options.list,
      item: this,
      form: this.options.form,
      trackingClass: this.options.trackingClass
    }, {
      userModel: this.options.userModel,
      configModel: this.options.configModel,
      modals: this.options.modals
    }).render();<commit_msg>Focus last legend item created with Enter<commit_after>var Backbone = require('backbone');
var $ = require('jquery');
var _ = require('underscore');
var EditorHelpers = require('../editor-helpers-extend');

/**
 * A single item in the list
 *
 * @param {editors.List} options.list The List editor instance this item belongs to
 * @param {Function} options.Editor   Editor constructor function
 * @param {String} options.key        Model key
 * @param {Mixed} options.value       Value
 * @param {Object} options.schema     Field schema
 */
Backbone.Form.editors.List.Item = Backbone.Form.editors.Base.extend({

  events: {
    'click [data-action="remove"]': function (event) {
      event.preventDefault();
      this.list.removeItem(this);
    },
    'keydown input[type=text]': function (event) {
      if (event.keyCode !== 13) return;
      event.preventDefault();
      this.list.addItem();
      this.list.$list.find('input:last').focus();
    }
  },

  initialize: function (options) {
    EditorHelpers.setOptions(this, options);
    this.list = options.list;
    this.schema = options.schema || this.list.schema;
    this.Editor = options.Editor || Backbone.Form.editors.Text;
    this.template = options.template || this.schema.itemTemplate || this.constructor.template;
    this.errorClassName = options.errorClassName || this.constructor.errorClassName;
  },

  render: function () {
    // Create editor
    this.editor = new this.Editor({
      key: this.options.key,
      schema: this.schema,
      value: this.options.value,
      list: this.options.list,
      item: this,
      form: this.options.form,
      trackingClass: this.options.trackingClass
    }, {
      userModel: this.options.userModel,
      configModel: this.options.configModel,
      modals: this.options.modals
    }).render();
{'fraction_non_alphanumeric': 0.13881961762261014, 'fraction_numerical': 0.0011083402604599613, 'mean_word_length': 3.2025611175785795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '684210', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1048, 'n_words': 237}