PageSourceSearch

https://bulgaria-dobrich.eu/wp-content/themes/pen/assets/js/plugins/autosize.js?ver=4.0

js bulgaria-dobrich.eu collected 2026-10-08 13:58:13 UTC 7,770 bytes, 292 lines download raw bytes

vendor: 7,770 bytes, lines 1-292
1/*!
2	Autosize 4.0.0
3	license: MIT
4	http://www.jacklmoore.com/autosize
5*/
6(function (global, factory) {
7	if (typeof define === 'function' && define.amd) {
8		define(['exports', 'module'], factory);
9	} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
10		factory(exports, module);
11	} else {
12		var mod = {
13			exports: {}
14		};
15		factory(mod.exports, mod);
16		global.autosize = mod.exports;
17	}
18})(this, function (exports, module) {
19	'use strict';
20
21	var map = typeof Map === "function" ? new Map() : (function () {
22		var keys = [];
23		var values = [];
24
25		return {
26			has: function has(key) {
27				return keys.indexOf(key) > -1;
28			},
29			get: function get(key) {
30				return values[keys.indexOf(key)];
31			},
32			set: function set(key, value) {
33				if (keys.indexOf(key) === -1) {
34					keys.push(key);
35					values.push(value);
36				}
37			},
38			'delete': function _delete(key) {
39				var index = keys.indexOf(key);
40				if (index > -1) {
41					keys.splice(index, 1);
42					values.splice(index, 1);
43				}
44			}
45		};
46	})();
47
48	var createEvent = function createEvent(name) {
49		return new Event(name, { bubbles: true });
50	};
51	try {
52		new Event('test');
53	} catch (e) {
54		// IE does not support `new Event()`
55		createEvent = function (name) {
56			var evt = document.createEvent('Event');
57			evt.initEvent(name, true, false);
58			return evt;
59		};
60	}
61
62	function assign(ta) {
63		if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return;
64
65		var heightOffset = null;
66		var clientWidth = ta.clientWidth;
67		var cachedHeight = null;
68
69		function init() {
70			var style = window.getComputedStyle(ta, null);
71
72			if (style.resize === 'vertical') {
73				ta.style.resize = 'none';
74			} else if (style.resize === 'both') {
75				ta.style.resize = 'horizontal';
76			}
77
78			if (style.boxSizing === 'content-box') {
79				heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
80			} else {
81				heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
82			}
83			// Fix when a textarea is not on document body and heightOffset is Not a Number
84			if (isNaN(heightOffset)) {
85				heightOffset = 0;
86			}
87
88			update();
89		}
90
91		function changeOverflow(value) {
92			{
93				// Chrome/Safari-specific fix:
94				// When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space
95				// made available by removing the scrollbar. The following forces the necessary text reflow.
96				var width = ta.style.width;
97				ta.style.width = '0px';
98				// Force reflow:
99				/* jshint ignore:start */
100				ta.offsetWidth;
101				/* jshint ignore:end */
102				ta.style.width = width;
103			}
104
105			ta.style.overflowY = value;
106		}
107
108		function getParentOverflows(el) {
109			var arr = [];
110
111			while (el && el.parentNode && el.parentNode instanceof Element) {
112				if (el.parentNode.scrollTop) {
113					arr.push({
114						node: el.parentNode,
115						scrollTop: el.parentNode.scrollTop
116					});
117				}
118				el = el.parentNode;
119			}
120
121			return arr;
122		}
123
124		function resize() {
125			var originalHeight = ta.style.height;
126			var overflows = getParentOverflows(ta);
127			var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)
128
129			ta.style.height = '';
130
131			var endHeight = ta.scrollHeight + heightOffset;
132
133			if (ta.scrollHeight === 0) {
134				// If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
135				ta.style.height = originalHeight;
136				return;
137			}
138
139			ta.style.height = endHeight + 'px';
140
141			// used to check if an update is actually necessary on window.resize
142			clientWidth = ta.clientWidth;
143
144			// prevents scroll-position jumping
145			overflows.forEach(function (el) {
146				el.node.scrollTop = el.scrollTop;
147			});
148
149			if (docTop) {
150				document.documentElement.scrollTop = docTop;
151			}
152		}
153
154		function update() {
155			resize();
156
157			var styleHeight = Math.round(parseFloat(ta.style.height));
158			var computed = window.getComputedStyle(ta, null);
159
160			// Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box
161			var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;
162
163			// The actual height not matching the style height (set via the resize method) indicates that
164			// the max-height has been exceeded, in which case the overflow should be allowed.
165			if (actualHeight !== styleHeight) {
166				if (computed.overflowY === 'hidden') {
167					changeOverflow('scroll');
168					resize();
169					actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
170				}
171			} else {
172				// Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
173				if (computed.overflowY !== 'hidden') {
174					changeOverflow('hidden');
175					resize();
176					actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
177				}
178			}
179
180			if (cachedHeight !== actualHeight) {
181				cachedHeight = actualHeight;
182				var evt = createEvent('autosize:resized');
183				try {
184					ta.dispatchEvent(evt);
185				} catch (err) {
186					// Firefox will throw an error on dispatchEvent for a detached element
187					// https://bugzilla.mozilla.org/show_bug.cgi?id=889376
188				}
189			}
190		}
191
192		var pageResize = function pageResize() {
193			if (ta.clientWidth !== clientWidth) {
194				update();
195			}
196		};
197
198		var destroy = (function (style) {
199			window.removeEventListener('resize', pageResize, false);
200			ta.removeEventListener('input', update, false);
201			ta.removeEventListener('keyup', update, false);
202			ta.removeEventListener('autosize:destroy', destroy, false);
203			ta.removeEventListener('autosize:update', update, false);
204
205			Object.keys(style).forEach(function (key) {
206				ta.style[key] = style[key];
207			});
208
209			map['delete'](ta);
210		}).bind(ta, {
211			height: ta.style.height,
212			resize: ta.style.resize,
213			overflowY: ta.style.overflowY,
214			overflowX: ta.style.overflowX,
215			wordWrap: ta.style.wordWrap
216		});
217
218		ta.addEventListener('autosize:destroy', destroy, false);
219
220		// IE9 does not fire onpropertychange or oninput for deletions,
221		// so binding to onkeyup to catch most of those events.
222		// There is no way that I know of to detect something like 'cut' in IE9.
223		if ('onpropertychange' in ta && 'oninput' in ta) {
224			ta.addEventListener('keyup', update, false);
225		}
226
227		window.addEventListener('resize', pageResize, false);
228		ta.addEventListener('input', update, false);
229		ta.addEventListener('autosize:update', update, false);
230		ta.style.overflowX = 'hidden';
231		ta.style.wordWrap = 'break-word';
232
233		map.set(ta, {
234			destroy: destroy,
235			update: update
236		});
237
238		init();
239	}
240
241	function destroy(ta) {
242		var methods = map.get(ta);
243		if (methods) {
244			methods.destroy();
245		}
246	}
247
248	function update(ta) {
249		var methods = map.get(ta);
250		if (methods) {
251			methods.update();
252		}
253	}
254
255	var autosize = null;
256
257	// Do nothing in Node.js environment and IE8 (or lower)
258	if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
259		autosize = function (el) {
260			return el;
261		};
262		autosize.destroy = function (el) {
263			return el;
264		};
265		autosize.update = function (el) {
266			return el;
267		};
268	} else {
269		autosize = function (el, options) {
270			if (el) {
271				Array.prototype.forEach.call(el.length ? el : [el], function (x) {
272					return assign(x, options);
273				});
274			}
275			return el;
276		};
277		autosize.destroy = function (el) {
278			if (el) {
279				Array.prototype.forEach.call(el.length ? el : [el], destroy);
280			}
281			return el;
282		};
283		autosize.update = function (el) {
284			if (el) {
285				Array.prototype.forEach.call(el.length ? el : [el], update);
286			}
287			return el;
288		};
289	}
290
291	module.exports = autosize;
292});

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.