<commit_before>/**
 * info window module, allow to edit the infowindow appearance
 * and the fields that will be shown
 */

cdb.admin.mod = cdb.admin.mod || {};

(function() {

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

  tagName: 'li',

  events: {
    'click .switch': 'toggle',
    'click .title': 'toggleTitle'
  },

  template: _.template(
    '<span class="ellipsis"><%- fieldName %></span>\
    <div class="switches">\
      <a href="#title" class="checkbox small light title">\
        <span class="check"></span>\
        title?\
      </a>\
      <a href="#switch" class="switch">\
        <span class="handle"></span>\
      </a>\
    </div>'),

  initialize: function() {
    this.fieldName = this.options.field;
    this.position = this.options.position;
    this.model.bind('change:fields', this.fieldChange, this);
  },

  fieldChange: function() {
    if(this.model.containsField(this.fieldName)) {
      this.$('.switch').removeClass('disabled').addClass('enabled');
    } else {
      this.$('.switch').removeClass('enabled').addClass('disabled');
    }
    // title
    var t = this.model.getFieldProperty(this.fieldName, 'title');
    if(t) {
      this.$('.title').removeClass('disabled').addClass('enabled');
    } else {
      this.$('.title').removeClass('enabled').addClass('disabled');
    }
  },

  toggle: function(e) {
    e.preventDefault();
    if(!this.model.containsField(this.fieldName)) {
      this.model.addField(this.fieldName, this.position);
    } else {
      this.model.removeField(this.fieldName);
    }

    return false;
  },

  toggleTitle: function(e) {
    e.preventDefault();
    var t = this.model.getFieldProperty(this.fieldName, 'title');
    this.model.setFieldProperty(this.fieldName, 'title', !t);
    return false;
  },

  render: function() {
    this.$el.append(this.template(this));
    this.fieldChange();
    this.$el.attr('cid', this.cid);
    this.$el.addClass('drag_field');

    return this;
  }

});

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

    buttonClass: 'infowindow_mod',
    className: 'infowindow_panel',
    type: 'tool',

    events: {
      'click .selectall': '_manageAll'
    },

    initialize: function() {
      var self = this;
      this.selectedAll = true;
      this.add_related_model(this.options.table);

      this.template = this.getTemplate('table/menu_modules/views/infowindow');
      this.model.bind('remove:fields', this.renderSelectAll, this);
      this.model.bind('add:fields', this.renderSelectAll, this);
      this.options.table.bind('change:schema', this.render, this);
      this.options.table.linkToInfowindow(this.model);
    },

    activated: function() {},

    // column names to be rendered
    getColumnNames: function() {
      var names = this.options.table.columnNames();
      return _(names).filter(function(c) {
        return !_.contains(this.model.SYSTEM_COLUMNS, c);
      });<commit_msg>fixed bad context<commit_after>/**
 * info window module, allow to edit the infowindow appearance
 * and the fields that will be shown
 */

cdb.admin.mod = cdb.admin.mod || {};

(function() {

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

  tagName: 'li',

  events: {
    'click .switch': 'toggle',
    'click .title': 'toggleTitle'
  },

  template: _.template(
    '<span class="ellipsis"><%- fieldName %></span>\
    <div class="switches">\
      <a href="#title" class="checkbox small light title">\
        <span class="check"></span>\
        title?\
      </a>\
      <a href="#switch" class="switch">\
        <span class="handle"></span>\
      </a>\
    </div>'),

  initialize: function() {
    this.fieldName = this.options.field;
    this.position = this.options.position;
    this.model.bind('change:fields', this.fieldChange, this);
  },

  fieldChange: function() {
    if(this.model.containsField(this.fieldName)) {
      this.$('.switch').removeClass('disabled').addClass('enabled');
    } else {
      this.$('.switch').removeClass('enabled').addClass('disabled');
    }
    // title
    var t = this.model.getFieldProperty(this.fieldName, 'title');
    if(t) {
      this.$('.title').removeClass('disabled').addClass('enabled');
    } else {
      this.$('.title').removeClass('enabled').addClass('disabled');
    }
  },

  toggle: function(e) {
    e.preventDefault();
    if(!this.model.containsField(this.fieldName)) {
      this.model.addField(this.fieldName, this.position);
    } else {
      this.model.removeField(this.fieldName);
    }

    return false;
  },

  toggleTitle: function(e) {
    e.preventDefault();
    var t = this.model.getFieldProperty(this.fieldName, 'title');
    this.model.setFieldProperty(this.fieldName, 'title', !t);
    return false;
  },

  render: function() {
    this.$el.append(this.template(this));
    this.fieldChange();
    this.$el.attr('cid', this.cid);
    this.$el.addClass('drag_field');

    return this;
  }

});

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

    buttonClass: 'infowindow_mod',
    className: 'infowindow_panel',
    type: 'tool',

    events: {
      'click .selectall': '_manageAll'
    },

    initialize: function() {
      var self = this;
      this.selectedAll = true;
      this.add_related_model(this.options.table);

      this.template = this.getTemplate('table/menu_modules/views/infowindow');
      this.model.bind('remove:fields', this.renderSelectAll, this);
      this.model.bind('add:fields', this.renderSelectAll, this);
      this.options.table.bind('change:schema', this.render, this);
      this.options.table.linkToInfowindow(this.model);
    },

    activated: function() {},

    // column names to be rendered
    getColumnNames: function() {
      var self = this;
      var names = this.options.table.columnNames();
      return _(names).filter(function(c) {
        return !_.contains(self.model.SYSTEM_COLUMNS, c);
      });
{'fraction_non_alphanumeric': 0.17479049085000856, 'fraction_numerical': 0.0, 'mean_word_length': 3.0526680526680527, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '5011392', 'n_tokens_mistral': 1846, 'n_tokens_neox': 1827, 'n_words': 327}