<commit_before>var CoreView = require('backbone/core-view');
var template = require('./custom-list-search.tpl');

module.exports = CoreView.extend({

  className: 'CustomList--full',
  tagName: 'form',

  events: {
    'keyup .js-search': '_onSearchType',
    'click .js-clear': '_onClickClear',
    'submit': '_submit'
  },

  initialize: function () {
    this.template = this.options.template || template;
    this.searchPlaceholder = this.options.searchPlaceholder || _t('components.custom-list.placeholder', { typeLabel: this.options.typeLabel });
    this._initBinds();
  },

  render: function () {
    this.$el
      .empty()
      .append(
        this.template({
          query: this.model.get('query'),
          searchPlaceholder: this.searchPlaceholder
        })
      );
    return this;
  },

  _initBinds: function () {
    this.model.on('change:query', this._checkButtons, this);
  },

  _checkButtons: function () {
    var query = this.model.get('query');

    if (query.length > 0) {
      this.$('.js-clear').css('opacity', 1);
    } else {
      this.$('.js-clear').css('opacity', 0);
    }
  },

  _onSearchType: function (e) {
    this._submit();
  },

  _onClickClear: function (e) {
    e.stopPropagation();
    this.model.set('query', '');
    this.render();<commit_msg>Using ternary operator instead of if<commit_after>var CoreView = require('backbone/core-view');
var template = require('./custom-list-search.tpl');

module.exports = CoreView.extend({

  className: 'CustomList--full',
  tagName: 'form',

  events: {
    'keyup .js-search': '_onSearchType',
    'click .js-clear': '_onClickClear',
    'submit': '_submit'
  },

  initialize: function () {
    this.template = this.options.template || template;
    this.searchPlaceholder = this.options.searchPlaceholder || _t('components.custom-list.placeholder', { typeLabel: this.options.typeLabel });
    this._initBinds();
  },

  render: function () {
    this.$el
      .empty()
      .append(
        this.template({
          query: this.model.get('query'),
          searchPlaceholder: this.searchPlaceholder
        })
      );
    return this;
  },

  _initBinds: function () {
    this.model.on('change:query', this._checkButtons, this);
  },

  _checkButtons: function () {
    var query = this.model.get('query');
    this.$('.js-clear').css('opacity', query.length ? 1 : 0);
  },

  _onSearchType: function (e) {
    this._submit();
  },

  _onClickClear: function (e) {
    e.stopPropagation();
    this.model.set('query', '');
    this.render();
{'fraction_non_alphanumeric': 0.1736738703339882, 'fraction_numerical': 0.0019646365422396855, 'mean_word_length': 2.978125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '21535', 'n_tokens_mistral': 820, 'n_tokens_neox': 806, 'n_words': 144}