<commit_before>/**
 * InputElementView
 * Controls the view of a single input element.
 */
var InputElementView = Backbone.View.extend({
  events: {
    'click     .reset':     'resetValue',
    'mousedown .decrease':  'beginStepDown',
    'mousedown .increase':  'beginStepUp',
    'click     .show-info': 'toggleInfoBox'
  },

  initialize: function (options) {
    Backbone.View.prototype.initialize.call(this, options);

    _.bindAll(this, 'updateFromModel', 'resetValue', 'toggleInfoBox',
                    'beginStepDown', 'beginStepUp', 'quinnOnChange',
                    'quinnOnComplete', 'checkMunicipalityNotice',
                    'inputElementInfoBoxShown');

    this.model       = this.options.model;
    this.el          = this.options.el;
    this.formatValue = this.__getFormatter();

    // Keeps track of intervals used to repeat stepDown and stepUp
    // operations when the user holds down the mouse button.
    this.incrementInterval = null;

    this.model.bind('change', this.updateFromModel);

    // make the toggle red if it's semi unadaptable and in a municipality.
    if (App.municipalityController.isMunicipality() &&
                this.model.get("semi_unadaptable")) {

      // TODO Needs a custom Quinn sprite to do this on the new slider.
      // this.sliderView.slider.toggleButton.element.addClass('municipality-toggle');
    }

    this.render();

    if (this.model.get('share_group')) {
      InputElement.Balancer.
        get(this.model.get('share_group'), { max: 100 }).
        add(this);
    }

    // Disable buttons?
    if (this.model.get('disabled')) {
      this.disableButton('reset');
      this.disableButton('decrease');
      this.disableButton('increase');
    }
  },

  /**
   * Creates the HTML elements used to display the slider.
   */
  render: function () {
    var quinnElement   = $('<div class="quinn"></div>'),
        wrapperElement = $('<div class="slider-controls"></div>'),

        // Need to keep hold of this to add the text to the new info box...
        description = this.el.find('.info-box .text').text(),

        quinnOnChange, quinnOnComplete;

    // TEMPLATING.

    // Start by removing the contents of the existing element, so that we
    // may add our own.
    this.el.empty();
    this.el.addClass('new-input-slider');

    // The label.
    wrapperElement.append(
      $('<label><label>').text(this.model.get('translated_name')));

    // Reset and decrease-value buttons.
    this.resetElement = $('<div class="reset"></div>');
    wrapperElement.append(this.resetElement);

    this.decreaseElement = $('<div class="decrease"></div>');
    wrapperElement.append(this.decreaseElement);

    // Holds the Quinn slider widget.
    wrapperElement.append(quinnElement);

    // Increase-value button.
    this.increaseElement = $('<div class="increase"></div>');
    wrapperElement.append(this.increaseElement);

    // Displays the current value to the user.
    this.valueElement = $('<output></output>');
    wrapperElement.append(this.valueElement);

    // The help / info button.
    wrapperElement.append('<div class="show-info"></div>');

    // Finally, the help / info box itself.
    this.el.append(wrapperElement);
    this.el.append($('<div class="info"></div>').text(description));

    // INITIALIZATION.

    // new $.Quinn is an alternative to $(...).quinn(), and allows us to
    // easily keep hold of the Quinn instance.
    this.quinn = new $.Quinn(quinnElement, {
      range:    [ this.model.get('min_value'),
                  this.model.get('max_value') ],

      value:      this.model.get('user_value'),
      step:       this.model.get('step_value'),
      disable:    this.model.get('disabled'),

      // Callbacks.
      onChange: this.quinnOnChange,<commit_msg>Disable animation on balanced sliders.<commit_after>/**
 * InputElementView
 * Controls the view of a single input element.
 */
var InputElementView = Backbone.View.extend({
  events: {
    'click     .reset':     'resetValue',
    'mousedown .decrease':  'beginStepDown',
    'mousedown .increase':  'beginStepUp',
    'click     .show-info': 'toggleInfoBox'
  },

  initialize: function (options) {
    Backbone.View.prototype.initialize.call(this, options);

    _.bindAll(this, 'updateFromModel', 'resetValue', 'toggleInfoBox',
                    'beginStepDown', 'beginStepUp', 'quinnOnChange',
                    'quinnOnComplete', 'checkMunicipalityNotice',
                    'inputElementInfoBoxShown');

    this.model       = this.options.model;
    this.el          = this.options.el;
    this.formatValue = this.__getFormatter();

    // Keeps track of intervals used to repeat stepDown and stepUp
    // operations when the user holds down the mouse button.
    this.incrementInterval = null;

    this.model.bind('change', this.updateFromModel);

    // make the toggle red if it's semi unadaptable and in a municipality.
    if (App.municipalityController.isMunicipality() &&
                this.model.get("semi_unadaptable")) {

      // TODO Needs a custom Quinn sprite to do this on the new slider.
      // this.sliderView.slider.toggleButton.element.addClass('municipality-toggle');
    }

    this.render();

    if (this.model.get('share_group')) {
      InputElement.Balancer.
        get(this.model.get('share_group'), { max: 100 }).
        add(this);
    }

    // Disable buttons?
    if (this.model.get('disabled')) {
      this.disableButton('reset');
      this.disableButton('decrease');
      this.disableButton('increase');
    }
  },

  /**
   * Creates the HTML elements used to display the slider.
   */
  render: function () {
    var quinnElement   = $('<div class="quinn"></div>'),
        wrapperElement = $('<div class="slider-controls"></div>'),

        // Need to keep hold of this to add the text to the new info box...
        description = this.el.find('.info-box .text').text(),

        quinnOnChange, quinnOnComplete;

    // TEMPLATING.

    // Start by removing the contents of the existing element, so that we
    // may add our own.
    this.el.empty();
    this.el.addClass('new-input-slider');

    // The label.
    wrapperElement.append(
      $('<label><label>').text(this.model.get('translated_name')));

    // Reset and decrease-value buttons.
    this.resetElement = $('<div class="reset"></div>');
    wrapperElement.append(this.resetElement);

    this.decreaseElement = $('<div class="decrease"></div>');
    wrapperElement.append(this.decreaseElement);

    // Holds the Quinn slider widget.
    wrapperElement.append(quinnElement);

    // Increase-value button.
    this.increaseElement = $('<div class="increase"></div>');
    wrapperElement.append(this.increaseElement);

    // Displays the current value to the user.
    this.valueElement = $('<output></output>');
    wrapperElement.append(this.valueElement);

    // The help / info button.
    wrapperElement.append('<div class="show-info"></div>');

    // Finally, the help / info box itself.
    this.el.append(wrapperElement);
    this.el.append($('<div class="info"></div>').text(description));

    // INITIALIZATION.

    // new $.Quinn is an alternative to $(...).quinn(), and allows us to
    // easily keep hold of the Quinn instance.
    this.quinn = new $.Quinn(quinnElement, {
      range:    [ this.model.get('min_value'),
                  this.model.get('max_value') ],

      value:      this.model.get('user_value'),
      step:       this.model.get('step_value'),
      disable:    this.model.get('disabled'),

      // Disable effects on sliders which are part of a group, since the
      // animation can look a little jarring.
      effects:  ! this.model.get('share_group'),

      // Callbacks.
      onChange: this.quinnOnChange,
{'fraction_non_alphanumeric': 0.14583333333333334, 'fraction_numerical': 0.0007716049382716049, 'mean_word_length': 2.7068636796949477, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, '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': '1207863', 'n_tokens_mistral': 2348, 'n_tokens_neox': 2220, 'n_words': 539}