<commit_before>
if(typeof define !== 'function') {
  var define = require('amdefine')(module);
}

define(function(require) {
  var View = inServer ? require('../../lib/View') : require('View')
    , template = inServer ? content_appTmpls : require('contentTmpls')
    , _ = require('underscore');

  return View.extend({

    /**
     * Initializer
     *
     * @return {void}
     * @api public
     */

    initialize : function(model) {
      this._model = model;
      this.setElement(document.querySelector('.condition[data-row="' + this._model.get('row') + '"]'));
      this._setElements()
        ._bind();
    },

    /**
     * Set elements
     *
     * @return {this}
     * @api private
     */

    _setElements : function() {
      this.$operators = this.$('.condition-operators');
      this.$operator = this.$('.condition-operators-value');

      return this;
    },

    /**
     * Bind view
     *
     * @return {this}
     * @api private
     */

    _bind : function() {
      this._bindMethods()
        ._addDesktopListeners()
        ._bindModel();

      return this;
    },

    /**
     * Bind model
     *
     * @return {this}
     * @api private
     */

    _bindModel : function() {
      this._model.on('change:operator', this._onOperatorChange);
      return this;
    },

    /**
     * On operator change
     *
     * @delegate
     */

    _onOperatorChange : function() {
      this.$operator.html(this._model.get('operator'));
    },

    /**
     * Bind methods
     *
     * @return {this}
     * @api private
     */

    _bindMethods : function() {
      _.bindAll(this,
        '_showOperatorsDropDown',
        '_hideOperatorsDropDown',
        '_setOperator',
        '_onOperatorChange'
      );

      return this;
    },

    /**
     * Add desktop listeners
     *
     * @return {this}
     * @api private
     */

    _addDesktopListeners : function() {
      this.$el.on('click', '.condition-operators', this._showOperatorsDropDown);
      this.$el.on('click', '.condition-operator', this._setOperator);

      return this;
    },

    /**
     * Show operators dropdown
     *
     * @delegate
     */

    _showOperatorsDropDown : function() {
      var _this = this;

      this.$operators[0].classList.add('active');
      _.defer(function() {
        _this.$el.off('click', '.condition-operators');
        app.$document.on('mousedown', _this._hideOperatorsDropDown);
      });
    },

    /**
     * Hide operators dropdown
     *
     * @delegate
     */

    _hideOperatorsDropDown : function(event) {
      if(typeof event !== 'undefined'
      && $(event.target).parents('.condition-operators').length > 0) {
        return;
      }

      var _this = this;

      this.$operators[0].classList.remove('active');
      _.defer(function() {
        _this.$el.on('click', '.condition-operators', _this._showOperatorsDropDown);
        app.$document.off('mousedown', _this._hideOperatorsDropDown);
      });
    },

    /**
     * Set operator
     *
     * @delegate
     */

    _setOperator : function(event) {
      this._model.set('operator', event.currentTarget.dataset['value']);
      this._hideOperatorsDropDown();
    }
  });
});
<commit_msg>Added active mode for then input<commit_after>
if(typeof define !== 'function') {
  var define = require('amdefine')(module);
}

define(function(require) {
  var View = inServer ? require('../../lib/View') : require('View')
    , template = inServer ? content_appTmpls : require('contentTmpls')
    , _ = require('underscore');

  return View.extend({

    /**
     * Initializer
     *
     * @return {void}
     * @api public
     */

    initialize : function(model) {
      this._model = model;
      this.setElement(document.querySelector('.condition[data-row="' + this._model.get('row') + '"]'));
      this._setElements()
      this._bind();
    },

    /**
     * Set elements
     *
     * @return {this}
     * @api private
     */

    _setElements : function() {
      this.$operators = this.$('.condition-operators');
      this.$operator = this.$('.condition-operators-value');
      this.$then = this.$('.condition-then');
    },

    /**
     * Bind view
     *
     * @return {this}
     * @api private
     */

    _bind : function() {
      this._bindMethods()
      this._addDesktopListeners()
      this._bindModel();
    },

    /**
     * Bind model
     *
     * @return {this}
     * @api private
     */

    _bindModel : function() {
      this._model.on('change:operator', this._onOperatorChange);
      return this;
    },

    /**
     * On operator change
     *
     * @delegate
     */

    _onOperatorChange : function() {
      this.$operator.html(this._model.get('operator'));
    },

    /**
     * Bind methods
     *
     * @return {void}
     * @api private
     */

    _bindMethods : function() {
      _.bindAll(this,
        '_showOperatorsDropDown',
        '_hideOperatorsDropDown',
        '_showThenDropDown',
        '_hideThenDropDown',
        '_setOperator',
        '_onOperatorChange'
      );
    },

    /**
     * Add desktop listeners
     *
     * @return {void}
     * @api private
     */

    _addDesktopListeners : function() {
      this.$el.on('click', '.condition-operators', this._showOperatorsDropDown);
      this.$el.on('click', '.condition-operator', this._setOperator);
      this.$el.on('click', '.condition-then', this._showThenDropDown);
    },

    /**
     * Show operators dropdown
     *
     * @delegate
     */

    _showOperatorsDropDown : function() {
      var _this = this;

      this.$operators[0].classList.add('active');
      _.defer(function() {
        _this.$el.off('click', '.condition-operators');
        app.$document.on('mousedown', _this._hideOperatorsDropDown);
      });
    },

    /**
     * Hide operators dropdown
     *
     * @delegate
     */

    _hideOperatorsDropDown : function(event) {
      if(typeof event !== 'undefined'
      && $(event.target).parents('.condition-operators').length > 0) {
        return;
      }

      var _this = this;

      this.$operators[0].classList.remove('active');
      _.defer(function() {
        _this.$el.on('click', '.condition-operators', _this._showOperatorsDropDown);
        app.$document.off('mousedown', _this._hideOperatorsDropDown);
      });
    },

    /**
     * Set operator
     *
     * @delegate
     */

    _setOperator : function(event) {
      this._model.set('operator', event.currentTarget.dataset['value']);
      this._hideOperatorsDropDown();
    },

    /**
     * Show then dropdown
     *
     * @delegate
     */

    _showThenDropDown : function() {
      var _this = this;

      this.$then[0].classList.add('active');
      _.defer(function() {
        _this.$el.off('click', '.condition-then');
        app.$document.on('mousedown', _this._hideThenDropDown);
      });
    },

    /**
     * Hide operators dropdown
     *
     * @delegate
     */

    _hideThenDropDown : function(event) {
      if(typeof event !== 'undefined'
      && $(event.target).parents('.condition-then').length > 0) {
        return;
      }

      var _this = this;

      this.$then[0].classList.remove('active');
      _.defer(function() {
        _this.$el.on('click', '.condition-then', _this._showThenDropDown);
        app.$document.off('mousedown', _this._hideThenDropDown);
      });
    }
  });
});

{'fraction_non_alphanumeric': 0.16330399458361544, 'fraction_numerical': 0.0012186865267433988, 'mean_word_length': 2.1059714045416316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '3818074', 'n_tokens_mistral': 2292, 'n_tokens_neox': 2211, 'n_words': 353}