<commit_before>var Macgyver = function(macgyver, $) {
  macgyver.slider = {
    'defaults': {'range': 'min'},
    '_createFormatSpan': function(format, value, className) {
      var inner = format.replace('%s', '<span>' + (value || '&nbsp;') + '</span>');
      if(className) {
        return '<span class="' + className + '">' + inner + '</span>';
      } else {
        return '<span>' + inner + '</span>';
      }
    },
    'init': function($instigator, options){
      options = $.extend({}, this.defaults, options);

      var $ui;
      if(options['target']) {
        $ui = $(options['target']);
      } else {
        var id = $instigator.attr('id');
        var extras = '';
        if(id) {
          extras = ' id="' + id + '-macgyver-slider"';
        }
        $ui = $('<div' + extras + '></div>').insertAfter($instigator);
      }

      options['value'] = $instigator.val();
      options['slide'] = function(event, slider) {
        /* Force trigger of .change() to propagate the value elsewhere. */
        $instigator.val(slider.value).change();
      };

      if ($instigator.is('select')) {
        var $options = $instigator.find('option');
        options['min'] = parseInt($options.first().val());
        options['max'] = parseInt($options.last().val());
        options['step'] = (options['max'] - options['min']) / ($options.length - 1);
      } else {
        options['min'] = parseInt($instigator.attr('min') || $instigator.data('min'));
        options['max'] = parseInt($instigator.attr('max') || $instigator.data('max'));
        options['step'] = parseInt($instigator.attr('step') || $instigator.data('step'));
      }

      $instigator.change(function(){
        var val = parseInt($instigator.val());
        if (val > options['max']) { val = options['max']; }
        if (val < options['min']) { val = options['min']; }
        if (isNaN(val)) { val = options['value']; }
        $instigator.val(val);
        $ui.slider('value', val);
      });

      if(options['minLabel']) {
        $ui.append(this._createFormatSpan('min-label', options['minLabel'], options['min']));
      }
      if(options['maxLabel']) {
        $ui.append(this._createFormatSpan('max-label', options['maxLabel'], options['max']));
      }

      $ui.slider(options);

      /* Need to append the element to a DOM loaded slider so this occurs after the slider instantiation. */
      if(options['valueLabel']) {
        /* If value does not exist, force a non-empty element draw.  Starting with empty
         * element prevents correct drawing when it has been replace with real contents.
         */
        var $valueLabel = $(this._createFormatSpan('value-label', options['valueLabel'], options['value'])).appendTo($ui.find('.ui-slider-handle'));
        var $value = $valueLabel.find('span');
        $instigator.change(function() {
          $value.html($instigator.val());
        });
      }
    }
  };

  return macgyver;
}(Macgyver || {}, jQuery);
<commit_msg>Fixed slider labels<commit_after>var Macgyver = function(macgyver, $) {
  macgyver.slider = {
    'defaults': {'range': 'min'},
    '_createFormatSpan': function(format, value, className) {
      var inner = format.replace('%s', '<span>' + (value || '&nbsp;') + '</span>');
      if(className) {
        return '<span class="' + className + '">' + inner + '</span>';
      } else {
        return '<span>' + inner + '</span>';
      }
    },
    'init': function($instigator, options){
      options = $.extend({}, this.defaults, options);

      var $ui;
      if(options['target']) {
        $ui = $(options['target']);
      } else {
        var id = $instigator.attr('id');
        var extras = '';
        if(id) {
          extras = ' id="' + id + '-macgyver-slider"';
        }
        $ui = $('<div' + extras + '></div>').insertAfter($instigator);
      }

      options['value'] = $instigator.val();
      options['slide'] = function(event, slider) {
        /* Force trigger of .change() to propagate the value elsewhere. */
        $instigator.val(slider.value).change();
      };

      if ($instigator.is('select')) {
        var $options = $instigator.find('option');
        options['min'] = parseInt($options.first().val());
        options['max'] = parseInt($options.last().val());
        options['step'] = (options['max'] - options['min']) / ($options.length - 1);
      } else {
        options['min'] = parseInt($instigator.attr('min') || $instigator.data('min'));
        options['max'] = parseInt($instigator.attr('max') || $instigator.data('max'));
        options['step'] = parseInt($instigator.attr('step') || $instigator.data('step'));
      }

      $instigator.change(function(){
        var val = parseInt($instigator.val());
        if (val > options['max']) { val = options['max']; }
        if (val < options['min']) { val = options['min']; }
        if (isNaN(val)) { val = options['value']; }
        $instigator.val(val);
        $ui.slider('value', val);
      });

      if(options['minLabel']) {
        $ui.append(this._createFormatSpan(options['minLabel'], options['min'], 'min-label'));
      }
      if(options['maxLabel']) {
        $ui.append(this._createFormatSpan(options['maxLabel'], options['max'], 'max-label'));
      }

      $ui.slider(options);

      /* Need to append the element to a DOM loaded slider so this occurs after the slider instantiation. */
      if(options['valueLabel']) {
        /* If value does not exist, force a non-empty element draw.  Starting with empty
         * element prevents correct drawing when it has been replace with real contents.
         */
        var $valueLabel = $(this._createFormatSpan(options['valueLabel'], options['value'], 'valueLabel')).appendTo($ui.find('.ui-slider-handle'));
        var $value = $valueLabel.find('span');
        $instigator.change(function() {
          $value.html($instigator.val());
        });
      }
    }
  };

  return macgyver;
}(Macgyver || {}, jQuery);

{'fraction_non_alphanumeric': 0.20013398090772064, 'fraction_numerical': 0.0003349522693016245, 'mean_word_length': 2.6955445544554455, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '1355980', 'n_tokens_mistral': 1753, 'n_tokens_neox': 1734, 'n_words': 368}