<commit_before>var _ = require('underscore');
var View = require('cdb/core/view');
var template = require('./item_view.tpl');

/**
 * Category list item view
 */
module.exports = View.extend({

  tagName: 'li',
  className: 'Widget-listItem',

  events: {
    'click .js-button': '_onItemClick'
  },

  initialize: function(options) {
    this.filter = this.options.filter;
    this.dataModel = this.options.dataModel;
    this._initBinds();
  },

  render: function() {
    var value = this.model.get('count');
    var totalCount = this.dataModel.get('totalCount');

    this.$el.html(
      template({
        name: this.model.get('name'),
        value: Math.ceil(value),
        percentage: Math.ceil(!totalCount ? 0 : (value / this.dataModel.get('totalCount')) * 100),
        isDisabled: !this.model.get('selected') ? 'is-disabled' : ''
      })
    );

    return this;
  },

  _initBinds: function() {
    this.model.bind('change', this.render, this);
  },

  _onItemClick: function() {
    this.trigger('itemClicked', this.model, this);
  }
});<commit_msg>Progress bars in category widget normalized by max count item<commit_after>var _ = require('underscore');
var View = require('cdb/core/view');
var template = require('./item_view.tpl');

/**
 * Category list item view
 */
module.exports = View.extend({

  tagName: 'li',
  className: 'Widget-listItem',

  events: {
    'click .js-button': '_onItemClick'
  },

  initialize: function(options) {
    this.filter = this.options.filter;
    this.dataModel = this.options.dataModel;
    this._initBinds();
  },

  render: function() {
    var value = this.model.get('count');
    var totalCount = this.dataModel.get('totalCount');

    this.$el.html(
      template({
        name: this.model.get('name'),
        value: Math.ceil(value),
        percentage: Math.ceil(!totalCount ? 0 : (value / this.dataModel.get('max')) * 100),
        isDisabled: !this.model.get('selected') ? 'is-disabled' : ''
      })
    );

    return this;
  },

  _initBinds: function() {
    this.model.bind('change', this.render, this);
  },

  _onItemClick: function() {
    this.trigger('itemClicked', this.model, this);
  }
});
{'fraction_non_alphanumeric': 0.17411331183786274, 'fraction_numerical': 0.0036849378166743437, 'mean_word_length': 3.129277566539924, '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': '3940908', 'n_tokens_mistral': 719, 'n_tokens_neox': 696, 'n_words': 137}