<commit_before>/**
 * TextAreaExpander plugin for jQuery
 * v1.0
 * Expands or contracts a textarea height depending on the
 * quatity of content entered by the user in the box.
 *
 * By <NAME>, Optimalworks.net
 *
 * As featured on SitePoint.com:
 * http://www.sitepoint.com/blogs/2009/07/29/build-auto-expanding-textarea-1/
 *
 * Please use as you wish at your own risk.
 */

/**
 * This is a slight variation of Buckler's original code. The
 * formatting was changed and the class name magic removed. Also, I
 * prefer to call the new function from my main Javascript file.
 *
 * <NAME>, ANUSF, 2010-06-24
 */

/**
 * Usage:
 *
 * From JavaScript, use:
 *     $(<node>).TextAreaExpander(<minHeight>, <maxHeight>);
 *     where:
 *       <node> is the DOM node selector, e.g. "textarea"
 *       <minHeight> is the minimum textarea height in pixels (optional)
 *       <maxHeight> is the maximum textarea height in pixels (optional)
 */

(function($) {
  $.fn.TextAreaExpander = function(minHeight, maxHeight) {
    var hCheck = !($.browser.msie || $.browser.opera);

    function ResizeTextarea(e) {
      // event or initialize element?
      e = e.target || e;

      // find content length and box width
      var vlen = e.value.length, ewidth = e.offsetWidth;

      if (vlen != e.valLength || ewidth != e.boxWidth) {
	if (hCheck && (vlen < e.valLength || ewidth != e.boxWidth))
	  e.style.height = "0px";
	var h = Math.max(e.expandMin, Math.min(e.scrollHeight, e.expandMax));

	e.style.overflow = (e.scrollHeight > h ? "auto" : "hidden");
	e.style.height = h + "px";

	e.valLength = vlen;
	e.boxWidth = ewidth;
      }

      return true;
    };

    // initialize
    this.each(function() {
      // is a textarea?
      if (this.nodeName.toLowerCase() != "textarea") return;

      // set height restrictions
      this.expandMin = minHeight;
      this.expandMax = maxHeight;

      // initial resize
      ResizeTextarea(this);

      // zero vertical padding and add events
      if (!this.Initialized) {
	this.Initialized = true;
	$(this).css("padding-top", 0).css("padding-bottom", 0);
	$(this).bind("keyup", ResizeTextarea).bind("focus", ResizeTextarea);
      }
    });

    return this;
  };
})(jQuery);<commit_msg>Leave the padding intact in auto-expanding textareas.<commit_after>/**
 * TextAreaExpander plugin for jQuery
 * v1.0
 * Expands or contracts a textarea height depending on the
 * quatity of content entered by the user in the box.
 *
 * By <NAME>, Optimalworks.net
 *
 * As featured on SitePoint.com:
 * http://www.sitepoint.com/blogs/2009/07/29/build-auto-expanding-textarea-1/
 *
 * Please use as you wish at your own risk.
 */

/**
 * This is a slight variation of Buckler's original code:
 *
 * - the formatting was changed
 * - no class name magic for setting height bounds individually
 * - the TextAreaExpander() method is not called automatically
 * - commented the code that sets the padding to 0 (=> problems on Safari?)
 *
 * <NAME>, ANUSF, 2010-06-24
 */

/**
 * Usage:
 *
 * From JavaScript, use:
 *     $(<node>).TextAreaExpander(<minHeight>, <maxHeight>);
 *     where:
 *       <node> is the DOM node selector, e.g. "textarea"
 *       <minHeight> is the minimum textarea height in pixels (optional)
 *       <maxHeight> is the maximum textarea height in pixels (optional)
 */

(function($) {
  $.fn.TextAreaExpander = function(minHeight, maxHeight) {
    var hCheck = !($.browser.msie || $.browser.opera);

    function ResizeTextarea(e) {
      // event or initialize element?
      e = e.target || e;

      // find content length and box width
      var vlen = e.value.length, ewidth = e.offsetWidth;

      if (vlen != e.valLength || ewidth != e.boxWidth) {
	if (hCheck && (vlen < e.valLength || ewidth != e.boxWidth))
	  e.style.height = "0px";
	var h = Math.max(e.expandMin, Math.min(e.scrollHeight, e.expandMax));

	e.style.overflow = (e.scrollHeight > h ? "auto" : "hidden");
	e.style.height = h + "px";

	e.valLength = vlen;
	e.boxWidth = ewidth;
      }

      return true;
    };

    // initialize
    this.each(function() {
      // is a textarea?
      if (this.nodeName.toLowerCase() != "textarea") return;

      // set height restrictions
      this.expandMin = minHeight;
      this.expandMax = maxHeight;

      // initial resize
      ResizeTextarea(this);

      // zero vertical padding and add events
      if (!this.Initialized) {
	this.Initialized = true;
	//$(this).css("padding-top", 0).css("padding-bottom", 0);
	$(this).bind("keyup", ResizeTextarea).bind("focus", ResizeTextarea);
      }
    });

    return this;
  };
})(jQuery);
{'fraction_non_alphanumeric': 0.14211325667172922, 'fraction_numerical': 0.009763506183553917, 'mean_word_length': 2.8480801335559267, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, 'https://': 0, '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': '5208656', 'n_tokens_mistral': 1530, 'n_tokens_neox': 1463, 'n_words': 430}