<commit_before>(function() {

  var SelectorView = cdb.core.View.extend({

    tagName: 'li',

    events: {
      'click': 'toggle'
    },

    initialize: function() {
      this.model.bind('change', this.render, this);
      this.template_base = _.template("<%= bucket %>  <div class='value'><%= value %></div>");
    },

    render: function() {

      this.$el.html(this.template_base(_.extend(this.model.toJSON(), this.options)));

      // this.model.get('bucket') this.model.get('value')

      if(this.model.get('selected')) {
        this.$el.addClass('selected');
      } else {
        this.$el.removeClass('selected');
      }

      return this;

    },

    toggle: function() {

      var m = this.model.get('selected')
      this.model.set('selected', !m);
    }

  });

  cdb.admin.mod.SelectorFilter = cdb.core.View.extend({

    tagName: 'li',
    className: 'filter selection',

    events: {
      'click a.remove': '_remove'
    },

    initialize: function() {
      this.model.items.bind('reset', this.render, this);
      this.add_related_model(this.model.items);
    },

    render: function() {

      var self = this;

      this.clearSubViews();

      this.$el.html(this.getTemplate('table/menu_modules/filters/templates/selection')({
        legend: this.model.escape('column'),
        count: 0
      }));

      var items = this.$('ul.items');

      this.model.items.each(function(m) {

        var v = new SelectorView({
          model: m
        });

        items.append(v.render().el);

        self.addView(v);

      });

      $('.scroll').jScrollPane({ showArrows: true });

      return this;

    },

    _remove: function() {
      this.model.destroy();
    }

  });

<commit_msg>Updates counter<commit_after>(function() {

  var SelectorView = cdb.core.View.extend({

    tagName: 'li',

    events: {
      'click': 'toggle'
    },

    initialize: function() {
      this.model.bind('change', this.render, this);
      this.template_base = _.template("<%= bucket %>  <div class='value'><%= value %></div>");
    },

    render: function() {

      this.$el.html(this.template_base(_.extend(this.model.toJSON(), this.options)));

      if(this.model.get('selected')) {
        this.$el.addClass('selected');
      } else {
        this.$el.removeClass('selected');
      }

      return this;

    },

    toggle: function() {

      var m = this.model.get('selected');
      this.model.set('selected', !m);
      this.trigger("updateCounter");

    }

  });

  cdb.admin.mod.SelectorFilter = cdb.core.View.extend({

    tagName: 'li',
    className: 'filter selection',

    events: {
      'click a.remove': '_remove'
    },

    initialize: function() {

      _.bindAll(this, "_updateCounter");

      this.model.items.bind('reset',  this.render, this);
      this.add_related_model(this.model.items);
    },

    _updateCounter: function() {

      var count = _.countBy(this.model.items.models, function(m) { return m.get("selected") ? "selected" : "unselected"; });
      var c = count.selected == undefined ? 0 : count.selected;
      this.$el.find(".count").html(" - " + c + " selected");

    },

    render: function() {

      var self = this;

      this.clearSubViews();

      this.$el.html(this.getTemplate('table/menu_modules/filters/templates/selection')({
        legend: this.model.escape('column'),
        count: 0
      }));

      var items = this.$('ul.items');

      this.model.items.each(function(m) {

        var v = new SelectorView({
          model: m
        });

        v.bind("updateCounter", self._updateCounter, self);

        items.append(v.render().el);

        self.addView(v);

      });

      self._updateCounter();

      $('.scroll').jScrollPane({ showArrows: true });

      return this;

    },

    _remove: function() {
      this.model.destroy();
    }

  });


{'fraction_non_alphanumeric': 0.18090062111801242, 'fraction_numerical': 0.0007763975155279503, 'mean_word_length': 2.3147512864493995, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3141528', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1187, 'n_words': 201}