<commit_before>"use strict";

var Backbone = require('../backbone')
  , $ = require('../jquery')
  , Autocompleter = require('../utils/autocomplete_widget')
  , RelatedTopicItemView

RelatedTopicItemView = Backbone.View.extend({
  events: {
    'click a.destroy': 'destroy'
  },
  className: 'related-topic',
  render: function () {
    this.$el.html('<a href="#" class="destroy"><i class="icon-minus-sign"></i></a>' + this.model.get('name'));
  },
  destroy: function (e) { 
    var that = this;
    e.preventDefault();
    this.model.collection.remove(this.model);
    this.$el.fadeOut(function () {
      that.remove()
    });
  }
});

module.exports = Backbone.View.extend({
  events: {
    'autocompleteselect': 'selectItem'
  },
  className: 'related-topics-widget',
  initialize: function (options) {
    var autocompleter;
    this.$topicList = $('<div class="related-topics-list">').appendTo(this.$el);

    this.listenTo(this.collection, 'add', this.addTopic);
    this.collection.forEach(this.addTopic, this);

    this.$search = $('<input type="text">').prependTo(this.$el);
    autocompleter = new Autocompleter(this.$search, this.collection.project.get('slug'), 'topics');

  },
  addTopic: function (topic) {
    var view = new RelatedTopicItemView({ model: topic });
    view.render();
    this.$topicList.append( view.$el );
  },
  addAllTopics: function (collection) {
    collection.forEach(this.addTopic, this);
  },
  selectItem: function (event, ui) {
    if (!ui.item) return;
    event.preventDefault();
    event.target.value = '';
    var topic = this.collection.add({
      url: ui.item.uri,
      name: ui.item.value
    });
  }
});<commit_msg>Fix typo in related_topics view<commit_after>"use strict";

var Backbone = require('../backbone')
  , $ = require('../jquery')
  , Autocompleter = require('../utils/autocomplete_widget')
  , RelatedTopicItemView

RelatedTopicItemView = Backbone.View.extend({
  events: {
    'click a.destroy': 'destroy'
  },
  className: 'related-topic',
  render: function () {
    this.$el.html('<a href="#" class="destroy"><i class="icon-minus-sign"></i></a>' + this.model.get('preferred_name'));
  },
  destroy: function (e) { 
    var that = this;
    e.preventDefault();
    this.model.collection.remove(this.model);
    this.$el.fadeOut(function () {
      that.remove()
    });
  }
});

module.exports = Backbone.View.extend({
  events: {
    'autocompleteselect': 'selectItem'
  },
  className: 'related-topics-widget',
  initialize: function (options) {
    var autocompleter;
    this.$topicList = $('<div class="related-topics-list">').appendTo(this.$el);

    this.listenTo(this.collection, 'add', this.addTopic);
    this.collection.forEach(this.addTopic, this);

    this.$search = $('<input type="text">').prependTo(this.$el);
    autocompleter = new Autocompleter(this.$search, this.collection.project.get('slug'), 'topics');

  },
  addTopic: function (topic) {
    var view = new RelatedTopicItemView({ model: topic });
    view.render();
    this.$topicList.append( view.$el );
  },
  addAllTopics: function (collection) {
    collection.forEach(this.addTopic, this);
  },
  selectItem: function (event, ui) {
    if (!ui.item) return;
    event.preventDefault();
    event.target.value = '';
    var topic = this.collection.add({
      url: ui.item.uri,
      preferred_name: ui.item.value
    });
  }
});
{'fraction_non_alphanumeric': 0.18332347723240686, 'fraction_numerical': 0.0, 'mean_word_length': 3.602721088435374, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4907769', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1100, 'n_words': 194}