<commit_before>// minform 0.1 - a minimalistic form enhancement plugin for jQuery
// https://github.com/jekor/minform

// Copyright 2011 <NAME>
// Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).

// Requirements:
//  * jQuery >= 1.4.3

(function ($) {
  var isEmpty = function () {
    var $input = $(this);
    return $input.val() === '' || $input.val() === $input.attr('placeholder');
  };

  $.fn.minform = function () {
    // Add placeholder text to elements with an HTML5 placeholder attribute.
    // To do so, insert the placeholder value into the input value and add a
    // class that allows for CSS styling.
    $('[placeholder]', this).live('blur.minform', function () {
      if (isEmpty.call(this)) {
        $(this).val($(this).attr('placeholder')).addClass('placeheld');
      }
    }).blur();

    $('.placeheld[placeholder]', this).live('focus.minform', function () {
      $(this).val('').removeClass('placeheld');
    });

    // Focus any inputs with attribute autofocus.
    $('[autofocus]', this).focus();

    this.submit(function () {
      // Don't submit without all required fields.
      var missing = $('[required]', $(this)).filter(isEmpty);
      if (missing.length) {
        // Rather than highlight all of the missing fields, re-focus the first one.
        missing[0].focus();
        return false;
      }

      // Clear all placeholder values from non-required fields.
      $('[placeholder]:not([required])', $(this)).filter(isEmpty).val('');
    });

    return this;
  };
})(jQuery);<commit_msg>Moving isEmpty() into the jQuery namespace as it's useful outside of the plugin.<commit_after>// minform 0.1 - a minimalistic form enhancement plugin for jQuery
// https://github.com/jekor/minform

// Copyright 2011 <NAME>
// Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).

// Requirements:
//  * jQuery >= 1.4.3

(function ($) {
  // We cannot rely on .val() since it might be the placeholder text. I could
  // attempt to override val(), but I think that a better long-term solution
  // will be to avoid putting the placeholder text into the value attribute.
  $.fn.isEmpty = function () {
    return this.val() === '' || this.val() === this.attr('placeholder');
  };

  $.fn.minform = function () {
    // Add placeholder text to elements with an HTML5 placeholder attribute.
    // To do so, insert the placeholder value into the input value and add a
    // class that allows for CSS styling.
    $('[placeholder]', this).live('blur.minform', function () {
      if ($(this).isEmpty()) {
        $(this).val($(this).attr('placeholder')).addClass('placeheld');
      }
    }).blur();

    $('.placeheld[placeholder]', this).live('focus.minform', function () {
      $(this).val('').removeClass('placeheld');
    });

    // Focus any inputs with attribute autofocus.
    $('[autofocus]', this).focus();

    this.submit(function () {
      // Don't submit without all required fields.
      var missing = $('[required]', this).filter(function () {return $(this).isEmpty();});
      if (missing.length) {
        // Rather than highlight all of the missing fields, re-focus the first one.
        missing[0].focus();
        return false;
      }

      // Clear all placeholder values from non-required fields.
      $('[placeholder]:not([required])', $(this)).filter(function () {return $(this).isEmpty();}).val('');
    });

    return this;
  };
})(jQuery);
{'fraction_non_alphanumeric': 0.17280046003450258, 'fraction_numerical': 0.0063254744105807935, 'mean_word_length': 2.9624145785876994, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '1393202', 'n_tokens_mistral': 1003, 'n_tokens_neox': 965, 'n_words': 300}