<commit_before>var _ = require('underscore');
var CoreView = require('backbone/core-view');
var template = require('./analysis-option.tpl');
var Analyses = require('../../../data/analyses');

/**
 * View for an individual analysis option.
 */
module.exports = CoreView.extend({

  tagName: 'li',
  className: 'ModalBlockList-item',

  events: {
    'mouseenter': '_onMouseEnter',
    'mouseleave': '_onMouseLeave',
    'click': '_onClick'
  },

  initialize: function (opts) {
    this._simpleGeometryTypeInput = opts.simpleGeometryTypeInput; // might be undefined/null, so don't check

    this.listenTo(this.model, 'change:selected', this.render);
  },

  render: function () {
    var props = this.model.pick('title', 'type_group', 'desc', 'selected');

    props.enabled = this._acceptsInputGeometry();

    if (!props.enabled) {
      props.desc = this._disabledDesc();
    }

    var analysisType = this.model.get('type');
    var analysisItem = Analyses.getAnalysisByType(analysisType);
    var animationTemplate = analysisItem && analysisItem.animationTemplate;
    var genericType = '';

    if (animationTemplate) {
      genericType = analysisItem.genericType || analysisType;
    }

    this.$el.html(template(_.extend(props, { type: genericType })));

    if (animationTemplate) {
      this.$('.js-animation').append(animationTemplate);
    }

    this.$el.toggleClass('is-selected', this.model.get('selected'));
    this.$el.toggleClass('is-disabled', !props.enabled);

    return this;
  },

  _onMouseEnter: function () {
    if (this._acceptsInputGeometry()) {
      this.$('.js-animation').addClass('has-autoplay');
    }
  },

  _onMouseLeave: function () {
    if (this._acceptsInputGeometry()) {
      this.$('.js-animation').removeClass('has-autoplay');
    }
  },

  _onClick: function (e) {
    if (e && e.target && e.target.getAttribute('class') && e.target.getAttribute('class').match('js-more')) {
      this.trigger('onClickInfo', this);
    }

    if (this._acceptsInputGeometry()) {
      this.model.set('selected', true);
    }
  },

  _disabledDesc: function (desc) {
    return _t('components.modals.add-analysis.disabled-option-desc', {
      simpleGeometryType: this._simpleGeometryTypeInput || _t('components.modals.add-analysis.unknown-geometry-type'),
      requiredInputGeometries: this.model.getValidInputGeometries()
    });
  },

  _acceptsInputGeometry: function () {
    return this.model.acceptsGeometryTypeAsInput(this._simpleGeometryTypeInput);
  }

});<commit_msg>Using jQuery instead of getAttribute which is failing for IE11 browsers+<commit_after>var _ = require('underscore');
var $ = require('jquery');
var CoreView = require('backbone/core-view');
var template = require('./analysis-option.tpl');
var Analyses = require('../../../data/analyses');

/**
 * View for an individual analysis option.
 */
module.exports = CoreView.extend({

  tagName: 'li',
  className: 'ModalBlockList-item',

  events: {
    'mouseenter': '_onMouseEnter',
    'mouseleave': '_onMouseLeave',
    'click': '_onClick'
  },

  initialize: function (opts) {
    this._simpleGeometryTypeInput = opts.simpleGeometryTypeInput; // might be undefined/null, so don't check

    this.listenTo(this.model, 'change:selected', this.render);
  },

  render: function () {
    var props = this.model.pick('title', 'type_group', 'desc', 'selected');

    props.enabled = this._acceptsInputGeometry();

    if (!props.enabled) {
      props.desc = this._disabledDesc();
    }

    var analysisType = this.model.get('type');
    var analysisItem = Analyses.getAnalysisByType(analysisType);
    var animationTemplate = analysisItem && analysisItem.animationTemplate;
    var genericType = '';

    if (animationTemplate) {
      genericType = analysisItem.genericType || analysisType;
    }

    this.$el.html(template(_.extend(props, { type: genericType })));

    if (animationTemplate) {
      this.$('.js-animation').append(animationTemplate);
    }

    this.$el.toggleClass('is-selected', this.model.get('selected'));
    this.$el.toggleClass('is-disabled', !props.enabled);

    return this;
  },

  _onMouseEnter: function () {
    if (this._acceptsInputGeometry()) {
      this.$('.js-animation').addClass('has-autoplay');
    }
  },

  _onMouseLeave: function () {
    if (this._acceptsInputGeometry()) {
      this.$('.js-animation').removeClass('has-autoplay');
    }
  },

  _onClick: function (e) {
    if (e && e.target && $(e.target).hasClass('js-more')) {
      this.trigger('onClickInfo', this);
    }

    if (this._acceptsInputGeometry()) {
      this.model.set('selected', true);
    }
  },

  _disabledDesc: function (desc) {
    return _t('components.modals.add-analysis.disabled-option-desc', {
      simpleGeometryType: this._simpleGeometryTypeInput || _t('components.modals.add-analysis.unknown-geometry-type'),
      requiredInputGeometries: this.model.getValidInputGeometries()
    });
  },

  _acceptsInputGeometry: function () {
    return this.model.acceptsGeometryTypeAsInput(this._simpleGeometryTypeInput);
  }

});
{'fraction_non_alphanumeric': 0.16159620703279337, 'fraction_numerical': 0.0003951007506914263, 'mean_word_length': 3.7406367041198503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1570603', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1496, 'n_words': 261}