PageSourceSearch

https://wj-goeppingen.de/admin/include/jquery/jquery-stickytable.js?rev=1731585203

js wj-goeppingen.de collected 2026-10-05 17:44:53 UTC 8,787 bytes, 286 lines download raw bytes

1(function (factory) {
2	typeof define === 'function' && define.amd ? define(factory) :
3	factory();
4}(function () { 'use strict';
5
6	/**
7	 * jQuery throttle / debounce - v1.1 - 3/7/2010
8	 * http://benalman.com/projects/jquery-throttle-debounce-plugin/
9	 *
10	 * Copyright (c) 2010 "Cowboy" Ben Alman
11	 * Dual licensed under the MIT and GPL licenses.
12	 * http://benalman.com/about/license/
13	 * @preserve
14	 */
15	(function (b, c) { var $ = b.jQuery || b.Cowboy || (b.Cowboy = {}), a; $.throttle = a = function (e, f, j, i) { var h, d = 0; if (typeof f !== "boolean") { i = j; j = f; f = c; } function g() { var o = this, m = +new Date() - d, n = arguments; function l() { d = +new Date(); j.apply(o, n); } function k() { h = c; } if (i && !h) { l(); } h && clearTimeout(h); if (i === c && m > e) { l(); } else { if (f !== true) { h = setTimeout(i ? k : l, i === c ? e - m : e); } } } if ($.guid) { g.guid = j.guid = j.guid || $.guid++; } return g }; $.debounce = function (d, e, f) { return f === c ? a(d, e, false) : a(d, f, e !== false) }; })(window);
16
17	/**
18	 * jQuery Stick Table Headers - v3.0.0
19	 * https://github.com/jpchip/stickytable
20	 *
21	 * Wrapped version of sticky table headers code here:
22	 * http://tympanus.net/codrops/2014/01/09/sticky-table-headers-columns/
23	 * http://tympanus.net/Tutorials/StickyTableHeaders/
24	 *
25	 * CSS located in jquery-stickytable.css
26	 *
27	 * Depends:
28	 * jQuery
29	 * jQuery throttle / debounce - v1.1 - 3/7/2010
30	 * http://benalman.com/projects/jquery-throttle-debounce-plugin/
31	 * @preserve
32	 */
33
34	(function ($, window, document, undefined$1) {
35
36		var pluginName = 'stickyTable',
37		defaults = {
38			copyTableClass: true, //copies table classes to sticky tables
39			copyEvents: false, //copy events on headers and cols to sticky tables
40			overflowy: false, //if true limits height of table to height of parent element
41              fixedOffset: 0
42		};
43
44		function StickyTable(element, options) {
45			this.element = element;
46			this._defaults = defaults;
47			this._name = pluginName;
48			this.options = $.extend({}, defaults, options);
49			this._init();
50		}
51
52		StickyTable.prototype._init = function () {
53			var $w = $(window),
54				$t = $(this.element),
55				classList = [],
56				$thead,
57				$col,
58				$stickyHead,
59				$stickyCol,
60				$stickyInsct,
61				$stickyWrap,
62				setWidths,
63				repositionStickyHead,
64				repositionStickyCol,
65				calcAllowance,
66                   $fixedOffset;
67
68			if (!$(this.element).is("table")) {
69				$.error('Target element must be a table');
70			}
71
72              $fixedOffset=this.options.fixedOffset;
73
74			//don't run this function again on same element!
75			if ($(this.element).hasClass("sticky-enabled")) {
76				return;
77			}
78
79			if ($t.find('thead:visible').length > 0 && $t.find('th:visible').length > 0) {
80				// Clone <thead>
81				$thead = $t.find('thead').clone(this.options.copyEvents);
82				$col = $t.find('thead, tbody').clone(this.options.copyEvents);
83
84				// Add class, remove margins, reset width and wrap table
85				$t.css({
86					margin: 0,
87					width: '100%'
88				}).wrap('<div class="sticky-wrap" />');
89
90				if (this.options.overflowy) {
91					$t.parent().addClass('overflow-y');
92				}
93
94				if ($t.attr('class')) {
95					classList = $t.attr('class').split(/\s+/);
96				}
97
98				$t.addClass('sticky-enabled');
99
100				// Create new sticky table head (basic)
101				$t.after('<table class="sticky-thead" />');
102
103				// If <tbody> contains <th>, then we create sticky column and intersect (advanced)
104				if ($t.find('tbody th').length > 0) {
105					$t.after('<table class="sticky-col" /><table class="sticky-intersect" />');
106				}
107
108				// Create shorthand for things
109				$stickyHead = $t.siblings('.sticky-thead');
110				$stickyCol = $t.siblings('.sticky-col');
111				$stickyInsct = $t.siblings('.sticky-intersect');
112				$stickyWrap = $t.parent('.sticky-wrap');
113
114				if (this.options.copyTableClass) {
115					$.each(classList, function (index, item) {
116						$stickyHead.addClass(item);
117						$stickyCol.addClass(item);
118						$stickyInsct.addClass(item);
119					});
120				}
121
122				$stickyHead.append($thead);
123
124				$stickyCol.append($col)
125					.find('thead th:gt(0)').remove()
126					.end()
127					.find('tbody td').remove();
128
129				$stickyInsct.html('<thead><tr><th>
129' + $t.find('thead th:first-child').html() + '</th></tr></thead>');
130				$stickyInsct.find('th').height($t.find('thead th:first-child').height());
131
132				setWidths = function () {
133					$t.find('thead th').each(function (i) {
134						$stickyHead.find('th').eq(i).width($(this).width());
135					})
136						.end()
137						.find('tr').each(function (i) {
138							$stickyCol.find('tr').eq(i).height($(this).height());
139						});
140
141					// Set width of sticky table head
142					$stickyHead.width($t.width());
143
144					// Set width of sticky table col
145					$stickyCol.find('th').add($stickyInsct.find('th')).width($t.find('thead th').width());
146				};
147
148				repositionStickyHead = function () {
149					// Return value of calculated allowance
150					var allowance = calcAllowance();
151
152					// Check if wrapper parent is overflowing along the y-axis
153					if ($t.height() > $stickyWrap.height()) {
154						// If it is overflowing (advanced layout)
155						// Position sticky header based on wrapper scrollTop()
156						if ($stickyWrap.scrollTop() > 0) {
157							// When top of wrapping parent is out of view
158							$stickyHead.add($stickyInsct).css({
159								opacity: 1,
160								top: $stickyWrap.scrollTop()
161							});
162						} else {
163							// When top of wrapping parent is in view
164							$stickyHead.add($stickyInsct).css({
165								opacity: 0,
166								top: 0
167							});
168						}
169					} else {
170						// If it is not overflowing (basic layout)
171						// Position sticky header based on viewport scrollTop
172						if ($w.scrollTop() > $t.offset().top && $w.scrollTop() < $t.offset().top + $t.outerHeight() - allowance) {
173							// When top of viewport is in the table itself
174							$stickyHead.add($stickyInsct).css({
175								opacity: 1,
176								top: $fixedOffset + $w.scrollTop() - $t.offset().top
177							});
178						} else {
179							// When top of viewport is above or below table
180							$stickyHead.add($stickyInsct).css({
181								opacity: 0,
182								top: 0
183							});
184						}
185					}
186				};
187
188				repositionStickyCol = function () {
189					if ($stickyWrap.scrollLeft() > 0) {
190						// When left of wrapping parent is out of view
191						$stickyCol.add($stickyInsct).css({
192							opacity: 1,
193							left: $stickyWrap.scrollLeft()
194						});
195					} else {
196						// When left of wrapping parent is in view
197						$stickyCol.css({
198							opacity: 0
199						})
200							.add($stickyInsct).css({
201								left: 0
202							});
203					}
204				};
205
206				calcAllowance = function () {
207					var a = 0;
208					// Calculate allowance
209					$t.find('tbody tr:lt(3)').each(function () {
210						a += $t.height();
211					});
212
213					// Set fail safe limit (last three row might be too tall)
214					// Set arbitrary limit at 0.25 of viewport height, or you can use an arbitrary pixel value
215					if (a > $w.height() * 0.25) {
216						a = $w.height() * 0.25;
217					}
218
219					// Add the height of sticky header
220					a += $stickyHead.height();
221					return a;
222				};
223
224				setWidths();
225
226				$t.parent('.sticky-wrap').scroll(function () {
227					repositionStickyHead();
228					repositionStickyCol();
229				});
230
231				$w.on('load', setWidths)
232					.resize($.debounce(500, function () {
233						setWidths();
234						repositionStickyHead();
235						repositionStickyCol();
236					}))
237					.scroll(repositionStickyHead);
238			}
239		};
240
241		StickyTable.prototype.destroy = function () {
242			var $t = $(this.element),
243				$stickyHead = $t.siblings('.sticky-thead'),
244				$stickyCol = $t.siblings('.sticky-col'),
245				$stickyInsct = $t.siblings('.sticky-intersect');
246
247			this.options = $.extend({}, defaults);
248
249			if ($t.hasClass('sticky-enabled')) {
250				$stickyHead.remove();
251				$stickyCol.remove();
252				$stickyInsct.remove();
253
254				$t.unwrap();
255				$t.removeClass('sticky-enabled');
256				//todo: clear events...
257			}
258			$.removeData(this.element, 'plugin_' + this._name);
259		};
260
261		$.fn[pluginName] = function (options) {
262			return this.each(function () {
263				var instance = $.data(this, 'plugin_' + pluginName);
264				if (instance) {
265					if (typeof options === 'string' || options instanceof String) {
266						if (instance[options] !== undefined$1 && $.isFunction(instance[options])) {
267							if (options.indexOf('_') !== -1) {
268								$.error('Method ' + options + ' is private!');
269							} else {
270								instance[options](Array.prototype.slice.call(arguments, 1));
271							}
272						} else {
273							$.error('Method ' + options + ' does not exist.');
274						}
275					}
276				} else if (typeof options === 'object' || !options) {
277					$.data(this, 'plugin_' + pluginName, new StickyTable(this, options));
278				} else {
279					$.error('Plugin must be initialised before using method: ' + options);
280				}
281			});
282		};
283
284	}(jQuery, window, document));
285
286}));

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.