PageSourceSearch

https://largusladaclub.ru/includes/jquery/autogrow/jquery.autogrow.js

js largusladaclub.ru collected 2026-09-25 21:52:42 UTC 3,774 bytes, 133 lines download raw bytes

1/* �
2 * Auto Expanding Text Area (1.2.2)�
3 * by Chrys Bader (www.chrysbader.com)�
4 * [email protected]�
5 *�
6 * Special thanks to:�
7 * Jake Chapa - [email protected]�
8 * John Resig - [email protected]�
9 *�
10 * Copyright (c) 2008 Chrys Bader (www.chrysbader.com)�
11 * Dual licensed under the MIT (MIT-LICENSE.txt)�
12 * and GPL (GPL-LICENSE.txt) licenses.�
13 *�
14 *�
15 * NOTE: This script requires jQuery to work.  Download jQuery at www.jquery.com�
16 *�
17 */�
18 �
19(function(jQuery) {�
20		  �
21	var self = null;�
22 �
23	jQuery.fn.autogrow = function(o)�
24	{	�
25		return this.each(function() {�
26			new jQuery.autogrow(this, o);�
27		});�
28	};�
29	�
30�
31    /**�
32     * The autogrow object.�
33     *�
34     * @constructor�
35     * @name jQuery.autogrow�
36     * @param Object e The textarea to create the autogrow for.�
37     * @param Hash o A set of key/value pairs to set as configuration properties.�
38     * @cat Plugins/autogrow�
39     */�
40	�
41	jQuery.autogrow = function (e, o)�
42	{�
43		this.options		  	= o || {};�
44		this.dummy			  	= null;�
45		this.interval	 	  	= null;�
46		this.line_height	  	= this.options.lineHeight || parseInt(jQuery(e).css('line-height'));�
47		this.min_height		  	= this.options.minHeight || parseInt(jQuery(e).css('min-height'));�
48		this.max_height		  	= this.options.maxHeight || parseInt(jQuery(e).css('max-height'));;�
49		this.textarea		  	= jQuery(e);�
50		�
51		if(this.line_height == NaN)�
52		  this.line_height = 0;�
53		�
54		// Only one textarea activated at a time, the one being used�
55		this.init();�
56	};�
57	�
58	jQuery.autogrow.fn = jQuery.autogrow.prototype = {�
59    autogrow: '1.2.2'�
60  };�
61	�
62 	jQuery.autogrow.fn.extend = jQuery.autogrow.extend = jQuery.extend;�
63	�
64	jQuery.autogrow.fn.extend({�
65						 �
66		init: function() {			�
67			var self = this;			�
68			this.textarea.css({overflow: 'hidden', display: 'block'});�
69			this.textarea.bind('focus', function() { self.startExpand() } ).bind('blur', function() { self.stopExpand() });�
70			this.checkExpand();	�
71		},�
72						 �
73		startExpand: function() {				�
74		  var self = this;�
75			this.interval = window.setInterval(function() {self.checkExpand()}, 400);�
76		},�
77		�
78		stopExpand: function() {�
79			clearInterval(this.interval);	�
80		},�
81		�
82		checkExpand: function() {�
83			�
84			if (this.dummy == null)�
85			{�
86				this.dummy = jQuery('<div></div>');�
87				this.dummy.css({�
88												'font-size'  : this.textarea.css('font-size'),�
89												'font-family': this.textarea.css('font-family'),�
90												'width'      : this.textarea.css('width'),�
91												'padding'    : this.textarea.css('padding'),�
92												'line-height': this.line_height + 'px',�
93												'overflow-x' : 'hidden',�
94												'position'   : 'absolute',�
95												'top'        : 0,�
96												'left'		 : -9999�
97												}).appendTo('body');�
98			}�
99			�
100			// Strip HTML tags�
101			var html = this.textarea.val().replace(/(<|>)/g, '');�
102			�
103			// IE is different, as per usual�
104			if ($.browser.msie)�
105			{�
106				html = html.replace(/\n/g, '<BR>new');�
107			}�
108			else�
109			{�
110				html = html.replace(/\n/g, '<br>new');�
111			}�
112			�
113			if (this.dummy.html() != html)�
114			{�
115				this.dummy.html(html);	�
116				�
117				if (this.max_height > 0 && (this.dummy.height() + this.line_height > this.max_height))�
118				{�
119					this.textarea.css('overflow-y', 'auto');	�
120				}�
121				else�
122				{�
123					this.textarea.css('overflow-y', 'hidden');�
124					if (this.textarea.height() < this.dummy.height() + this.line_height || (this.dummy.height() < this.textarea.height()))�
125					{	�
126						this.textarea.animate({height: (this.dummy.height() + this.line_height) + 'px'}, 100);	�
127					}�
128				}�
129			}�
130		}�
131						 �
132	 });�
133})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.