Subversion Repositories munaweb

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/*** This file is dynamically generated ***
2
█████▄ ▄████▄   █████▄ ▄████▄ ██████   ███████▄ ▄████▄ █████▄ ██ ██████ ██  ██
3
██  ██ ██  ██   ██  ██ ██  ██   ██     ██ ██ ██ ██  ██ ██  ██ ██ ██▄▄   ██▄▄██
4
██  ██ ██  ██   ██  ██ ██  ██   ██     ██ ██ ██ ██  ██ ██  ██ ██ ██▀▀    ▀▀▀██
5
█████▀ ▀████▀   ██  ██ ▀████▀   ██     ██ ██ ██ ▀████▀ █████▀ ██ ██     █████▀
6
*/
7
/*! tablesorter (FORK) - updated 2018-11-20 (v2.31.1)*/
8
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
9
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery) {
10
/*! Widget: storage - updated 2018-03-18 (v2.30.0) */
11
/*global JSON:false */
12
;(function ($, window, document) {
13
	'use strict';
14
 
15
	var ts = $.tablesorter || {};
16
 
17
	// update defaults for validator; these values must be falsy!
18
	$.extend(true, ts.defaults, {
19
		fixedUrl: '',
20
		widgetOptions: {
21
			storage_fixedUrl: '',
22
			storage_group: '',
23
			storage_page: '',
24
			storage_storageType: '',
25
			storage_tableId: '',
26
			storage_useSessionStorage: ''
27
		}
28
	});
29
 
30
	// *** Store data in local storage, with a cookie fallback ***
31
	/* IE7 needs JSON library for JSON.stringify - (http://caniuse.com/#search=json)
32
	   if you need it, then include https://github.com/douglascrockford/JSON-js
33
 
34
	   $.parseJSON is not available is jQuery versions older than 1.4.1, using older
35
	   versions will only allow storing information for one page at a time
36
 
37
	   // *** Save data (JSON format only) ***
38
	   // val must be valid JSON... use http://jsonlint.com/ to ensure it is valid
39
	   var val = { "mywidget" : "data1" }; // valid JSON uses double quotes
40
	   // $.tablesorter.storage(table, key, val);
41
	   $.tablesorter.storage(table, 'tablesorter-mywidget', val);
42
 
43
	   // *** Get data: $.tablesorter.storage(table, key); ***
44
	   v = $.tablesorter.storage(table, 'tablesorter-mywidget');
45
	   // val may be empty, so also check for your data
46
	   val = (v && v.hasOwnProperty('mywidget')) ? v.mywidget : '';
47
	   alert(val); // 'data1' if saved, or '' if not
48
	*/
49
	ts.storage = function(table, key, value, options) {
50
		table = $(table)[0];
51
		var cookieIndex, cookies, date,
52
			hasStorage = false,
53
			values = {},
54
			c = table.config,
55
			wo = c && c.widgetOptions,
56
			debug = ts.debug(c, 'storage'),
57
			storageType = (
58
				( options && options.storageType ) || ( wo && wo.storage_storageType )
59
			).toString().charAt(0).toLowerCase(),
60
			// deprecating "useSessionStorage"; any storageType setting overrides it
61
			session = storageType ? '' :
62
				( options && options.useSessionStorage ) || ( wo && wo.storage_useSessionStorage ),
63
			$table = $(table),
64
			// id from (1) options ID, (2) table 'data-table-group' attribute, (3) widgetOptions.storage_tableId,
65
			// (4) table ID, then (5) table index
66
			id = options && options.id ||
67
				$table.attr( options && options.group || wo && wo.storage_group || 'data-table-group') ||
68
				wo && wo.storage_tableId || table.id || $('.tablesorter').index( $table ),
69
			// url from (1) options url, (2) table 'data-table-page' attribute, (3) widgetOptions.storage_fixedUrl,
70
			// (4) table.config.fixedUrl (deprecated), then (5) window location path
71
			url = options && options.url ||
72
				$table.attr(options && options.page || wo && wo.storage_page || 'data-table-page') ||
73
				wo && wo.storage_fixedUrl || c && c.fixedUrl || window.location.pathname;
74
 
75
		// skip if using cookies
76
		if (storageType !== 'c') {
77
			storageType = (storageType === 's' || session) ? 'sessionStorage' : 'localStorage';
78
			// https://gist.github.com/paulirish/5558557
79
			if (storageType in window) {
80
				try {
81
					window[storageType].setItem('_tmptest', 'temp');
82
					hasStorage = true;
83
					window[storageType].removeItem('_tmptest');
84
				} catch (error) {
85
					console.warn( storageType + ' is not supported in this browser' );
86
				}
87
			}
88
		}
89
		if (debug) {
90
			console.log('Storage >> Using', hasStorage ? storageType : 'cookies');
91
		}
92
		// *** get value ***
93
		if ($.parseJSON) {
94
			if (hasStorage) {
95
				values = $.parseJSON( window[storageType][key] || 'null' ) || {};
96
			} else {
97
				// old browser, using cookies
98
				cookies = document.cookie.split(/[;\s|=]/);
99
				// add one to get from the key to the value
100
				cookieIndex = $.inArray(key, cookies) + 1;
101
				values = (cookieIndex !== 0) ? $.parseJSON(cookies[cookieIndex] || 'null') || {} : {};
102
			}
103
		}
104
		// allow value to be an empty string too
105
		if (typeof value !== 'undefined' && window.JSON && JSON.hasOwnProperty('stringify')) {
106
			// add unique identifiers = url pathname > table ID/index on page > data
107
			if (!values[url]) {
108
				values[url] = {};
109
			}
110
			values[url][id] = value;
111
			// *** set value ***
112
			if (hasStorage) {
113
				window[storageType][key] = JSON.stringify(values);
114
			} else {
115
				date = new Date();
116
				date.setTime(date.getTime() + (31536e+6)); // 365 days
117
				document.cookie = key + '=' + (JSON.stringify(values)).replace(/\"/g, '\"') + '; expires=' + date.toGMTString() + '; path=/';
118
			}
119
		} else {
120
			return values && values[url] ? values[url][id] : '';
121
		}
122
	};
123
 
124
})(jQuery, window, document);
125
 
126
/*! Widget: uitheme - updated 2018-03-18 (v2.30.0) */
127
;(function ($) {
128
	'use strict';
129
	var ts = $.tablesorter || {};
130
 
131
	ts.themes = {
132
		'bootstrap' : {
133
			table        : 'table table-bordered table-striped',
134
			caption      : 'caption',
135
			// header class names
136
			header       : 'bootstrap-header', // give the header a gradient background (theme.bootstrap_2.css)
137
			sortNone     : '',
138
			sortAsc      : '',
139
			sortDesc     : '',
140
			active       : '', // applied when column is sorted
141
			hover        : '', // custom css required - a defined bootstrap style may not override other classes
142
			// icon class names
143
			icons        : '', // add 'bootstrap-icon-white' to make them white; this icon class is added to the <i> in the header
144
			iconSortNone : 'bootstrap-icon-unsorted', // class name added to icon when column is not sorted
145
			iconSortAsc  : 'glyphicon glyphicon-chevron-up', // class name added to icon when column has ascending sort
146
			iconSortDesc : 'glyphicon glyphicon-chevron-down', // class name added to icon when column has descending sort
147
			filterRow    : '', // filter row class
148
			footerRow    : '',
149
			footerCells  : '',
150
			even         : '', // even row zebra striping
151
			odd          : ''  // odd row zebra striping
152
		},
153
		'jui' : {
154
			table        : 'ui-widget ui-widget-content ui-corner-all', // table classes
155
			caption      : 'ui-widget-content',
156
			// header class names
157
			header       : 'ui-widget-header ui-corner-all ui-state-default', // header classes
158
			sortNone     : '',
159
			sortAsc      : '',
160
			sortDesc     : '',
161
			active       : 'ui-state-active', // applied when column is sorted
162
			hover        : 'ui-state-hover',  // hover class
163
			// icon class names
164
			icons        : 'ui-icon', // icon class added to the <i> in the header
165
			iconSortNone : 'ui-icon-carat-2-n-s ui-icon-caret-2-n-s', // class name added to icon when column is not sorted
166
			iconSortAsc  : 'ui-icon-carat-1-n ui-icon-caret-1-n', // class name added to icon when column has ascending sort
167
			iconSortDesc : 'ui-icon-carat-1-s ui-icon-caret-1-s', // class name added to icon when column has descending sort
168
			filterRow    : '',
169
			footerRow    : '',
170
			footerCells  : '',
171
			even         : 'ui-widget-content', // even row zebra striping
172
			odd          : 'ui-state-default'   // odd row zebra striping
173
		}
174
	};
175
 
176
	$.extend(ts.css, {
177
		wrapper : 'tablesorter-wrapper' // ui theme & resizable
178
	});
179
 
180
	ts.addWidget({
181
		id: 'uitheme',
182
		priority: 10,
183
		format: function(table, c, wo) {
184
			var i, tmp, hdr, icon, time, $header, $icon, $tfoot, $h, oldtheme, oldremove, oldIconRmv, hasOldTheme,
185
				themesAll = ts.themes,
186
				$table = c.$table.add( $( c.namespace + '_extra_table' ) ),
187
				$headers = c.$headers.add( $( c.namespace + '_extra_headers' ) ),
188
				theme = c.theme || 'jui',
189
				themes = themesAll[theme] || {},
190
				remove = $.trim( [ themes.sortNone, themes.sortDesc, themes.sortAsc, themes.active ].join( ' ' ) ),
191
				iconRmv = $.trim( [ themes.iconSortNone, themes.iconSortDesc, themes.iconSortAsc ].join( ' ' ) ),
192
				debug = ts.debug(c, 'uitheme');
193
			if (debug) { time = new Date(); }
194
			// initialization code - run once
195
			if (!$table.hasClass('tablesorter-' + theme) || c.theme !== c.appliedTheme || !wo.uitheme_applied) {
196
				wo.uitheme_applied = true;
197
				oldtheme = themesAll[c.appliedTheme] || {};
198
				hasOldTheme = !$.isEmptyObject(oldtheme);
199
				oldremove =  hasOldTheme ? [ oldtheme.sortNone, oldtheme.sortDesc, oldtheme.sortAsc, oldtheme.active ].join( ' ' ) : '';
200
				oldIconRmv = hasOldTheme ? [ oldtheme.iconSortNone, oldtheme.iconSortDesc, oldtheme.iconSortAsc ].join( ' ' ) : '';
201
				if (hasOldTheme) {
202
					wo.zebra[0] = $.trim( ' ' + wo.zebra[0].replace(' ' + oldtheme.even, '') );
203
					wo.zebra[1] = $.trim( ' ' + wo.zebra[1].replace(' ' + oldtheme.odd, '') );
204
					c.$tbodies.children().removeClass( [ oldtheme.even, oldtheme.odd ].join(' ') );
205
				}
206
				// update zebra stripes
207
				if (themes.even) { wo.zebra[0] += ' ' + themes.even; }
208
				if (themes.odd) { wo.zebra[1] += ' ' + themes.odd; }
209
				// add caption style
210
				$table.children('caption')
211
					.removeClass(oldtheme.caption || '')
212
					.addClass(themes.caption);
213
				// add table/footer class names
214
				$tfoot = $table
215
					// remove other selected themes
216
					.removeClass( (c.appliedTheme ? 'tablesorter-' + (c.appliedTheme || '') : '') + ' ' + (oldtheme.table || '') )
217
					.addClass('tablesorter-' + theme + ' ' + (themes.table || '')) // add theme widget class name
218
					.children('tfoot');
219
				c.appliedTheme = c.theme;
220
 
221
				if ($tfoot.length) {
222
					$tfoot
223
						// if oldtheme.footerRow or oldtheme.footerCells are undefined, all class names are removed
224
						.children('tr').removeClass(oldtheme.footerRow || '').addClass(themes.footerRow)
225
						.children('th, td').removeClass(oldtheme.footerCells || '').addClass(themes.footerCells);
226
				}
227
				// update header classes
228
				$headers
229
					.removeClass( (hasOldTheme ? [ oldtheme.header, oldtheme.hover, oldremove ].join(' ') : '') || '' )
230
					.addClass(themes.header)
231
					.not('.sorter-false')
232
					.unbind('mouseenter.tsuitheme mouseleave.tsuitheme')
233
					.bind('mouseenter.tsuitheme mouseleave.tsuitheme', function(event) {
234
						// toggleClass with switch added in jQuery 1.3
235
						$(this)[ event.type === 'mouseenter' ? 'addClass' : 'removeClass' ](themes.hover || '');
236
					});
237
 
238
				$headers.each(function() {
239
					var $this = $(this);
240
					if (!$this.find('.' + ts.css.wrapper).length) {
241
						// Firefox needs this inner div to position the icon & resizer correctly
242
						$this.wrapInner('<div class="' + ts.css.wrapper + '" style="position:relative;height:100%;width:100%"></div>');
243
					}
244
				});
245
				if (c.cssIcon) {
246
					// if c.cssIcon is '', then no <i> is added to the header
247
					$headers
248
						.find('.' + ts.css.icon)
249
						.removeClass(hasOldTheme ? [ oldtheme.icons, oldIconRmv ].join(' ') : '')
250
						.addClass(themes.icons || '');
251
				}
252
				// filter widget initializes after uitheme
253
				if (ts.hasWidget( c.table, 'filter' )) {
254
					tmp = function() {
255
						$table.children('thead').children('.' + ts.css.filterRow)
256
							.removeClass(hasOldTheme ? oldtheme.filterRow || '' : '')
257
							.addClass(themes.filterRow || '');
258
					};
259
					if (wo.filter_initialized) {
260
						tmp();
261
					} else {
262
						$table.one('filterInit', function() {
263
							tmp();
264
						});
265
					}
266
				}
267
			}
268
			for (i = 0; i < c.columns; i++) {
269
				$header = c.$headers
270
					.add($(c.namespace + '_extra_headers'))
271
					.not('.sorter-false')
272
					.filter('[data-column="' + i + '"]');
273
				$icon = (ts.css.icon) ? $header.find('.' + ts.css.icon) : $();
274
				$h = $headers.not('.sorter-false').filter('[data-column="' + i + '"]:last');
275
				if ($h.length) {
276
					$header.removeClass(remove);
277
					$icon.removeClass(iconRmv);
278
					if ($h[0].sortDisabled) {
279
						// no sort arrows for disabled columns!
280
						$icon.removeClass(themes.icons || '');
281
					} else {
282
						hdr = themes.sortNone;
283
						icon = themes.iconSortNone;
284
						if ($h.hasClass(ts.css.sortAsc)) {
285
							hdr = [ themes.sortAsc, themes.active ].join(' ');
286
							icon = themes.iconSortAsc;
287
						} else if ($h.hasClass(ts.css.sortDesc)) {
288
							hdr = [ themes.sortDesc, themes.active ].join(' ');
289
							icon = themes.iconSortDesc;
290
						}
291
						$header.addClass(hdr);
292
						$icon.addClass(icon || '');
293
					}
294
				}
295
			}
296
			if (debug) {
297
				console.log('uitheme >> Applied ' + theme + ' theme' + ts.benchmark(time));
298
			}
299
		},
300
		remove: function(table, c, wo, refreshing) {
301
			if (!wo.uitheme_applied) { return; }
302
			var $table = c.$table,
303
				theme = c.appliedTheme || 'jui',
304
				themes = ts.themes[ theme ] || ts.themes.jui,
305
				$headers = $table.children('thead').children(),
306
				remove = themes.sortNone + ' ' + themes.sortDesc + ' ' + themes.sortAsc,
307
				iconRmv = themes.iconSortNone + ' ' + themes.iconSortDesc + ' ' + themes.iconSortAsc;
308
			$table.removeClass('tablesorter-' + theme + ' ' + themes.table);
309
			wo.uitheme_applied = false;
310
			if (refreshing) { return; }
311
			$table.find(ts.css.header).removeClass(themes.header);
312
			$headers
313
				.unbind('mouseenter.tsuitheme mouseleave.tsuitheme') // remove hover
314
				.removeClass(themes.hover + ' ' + remove + ' ' + themes.active)
315
				.filter('.' + ts.css.filterRow)
316
				.removeClass(themes.filterRow);
317
			$headers.find('.' + ts.css.icon).removeClass(themes.icons + ' ' + iconRmv);
318
		}
319
	});
320
 
321
})(jQuery);
322
 
323
/*! Widget: columns - updated 5/24/2017 (v2.28.11) */
324
;(function ($) {
325
	'use strict';
326
	var ts = $.tablesorter || {};
327
 
328
	ts.addWidget({
329
		id: 'columns',
330
		priority: 65,
331
		options : {
332
			columns : [ 'primary', 'secondary', 'tertiary' ]
333
		},
334
		format: function(table, c, wo) {
335
			var $tbody, tbodyIndex, $rows, rows, $row, $cells, remove, indx,
336
			$table = c.$table,
337
			$tbodies = c.$tbodies,
338
			sortList = c.sortList,
339
			len = sortList.length,
340
			// removed c.widgetColumns support
341
			css = wo && wo.columns || [ 'primary', 'secondary', 'tertiary' ],
342
			last = css.length - 1;
343
			remove = css.join(' ');
344
			// check if there is a sort (on initialization there may not be one)
345
			for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
346
				$tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // detach tbody
347
				$rows = $tbody.children('tr');
348
				// loop through the visible rows
349
				$rows.each(function() {
350
					$row = $(this);
351
					if (this.style.display !== 'none') {
352
						// remove all columns class names
353
						$cells = $row.children().removeClass(remove);
354
						// add appropriate column class names
355
						if (sortList && sortList[0]) {
356
							// primary sort column class
357
							$cells.eq(sortList[0][0]).addClass(css[0]);
358
							if (len > 1) {
359
								for (indx = 1; indx < len; indx++) {
360
									// secondary, tertiary, etc sort column classes
361
									$cells.eq(sortList[indx][0]).addClass( css[indx] || css[last] );
362
								}
363
							}
364
						}
365
					}
366
				});
367
				ts.processTbody(table, $tbody, false);
368
			}
369
			// add classes to thead and tfoot
370
			rows = wo.columns_thead !== false ? [ 'thead tr' ] : [];
371
			if (wo.columns_tfoot !== false) {
372
				rows.push('tfoot tr');
373
			}
374
			if (rows.length) {
375
				$rows = $table.find( rows.join(',') ).children().removeClass(remove);
376
				if (len) {
377
					for (indx = 0; indx < len; indx++) {
378
						// add primary. secondary, tertiary, etc sort column classes
379
						$rows.filter('[data-column="' + sortList[indx][0] + '"]').addClass(css[indx] || css[last]);
380
					}
381
				}
382
			}
383
		},
384
		remove: function(table, c, wo) {
385
			var tbodyIndex, $tbody,
386
				$tbodies = c.$tbodies,
387
				remove = (wo.columns || [ 'primary', 'secondary', 'tertiary' ]).join(' ');
388
			c.$headers.removeClass(remove);
389
			c.$table.children('tfoot').children('tr').children('th, td').removeClass(remove);
390
			for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
391
				$tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody
392
				$tbody.children('tr').each(function() {
393
					$(this).children().removeClass(remove);
394
				});
395
				ts.processTbody(table, $tbody, false); // restore tbody
396
			}
397
		}
398
	});
399
 
400
})(jQuery);
401
 
402
/*! Widget: filter - updated 2018-03-18 (v2.30.0) *//*
403
 * Requires tablesorter v2.8+ and jQuery 1.7+
404
 * by Rob Garrison
405
 */
406
;( function ( $ ) {
407
	'use strict';
408
	var tsf, tsfRegex,
409
		ts = $.tablesorter || {},
410
		tscss = ts.css,
411
		tskeyCodes = ts.keyCodes;
412
 
413
	$.extend( tscss, {
414
		filterRow      : 'tablesorter-filter-row',
415
		filter         : 'tablesorter-filter',
416
		filterDisabled : 'disabled',
417
		filterRowHide  : 'hideme'
418
	});
419
 
420
	$.extend( tskeyCodes, {
421
		backSpace : 8,
422
		escape : 27,
423
		space : 32,
424
		left : 37,
425
		down : 40
426
	});
427
 
428
	ts.addWidget({
429
		id: 'filter',
430
		priority: 50,
431
		options : {
432
			filter_cellFilter    : '',    // css class name added to the filter cell ( string or array )
433
			filter_childRows     : false, // if true, filter includes child row content in the search
434
			filter_childByColumn : false, // ( filter_childRows must be true ) if true = search child rows by column; false = search all child row text grouped
435
			filter_childWithSibs : true,  // if true, include matching child row siblings
436
			filter_columnAnyMatch: true,  // if true, allows using '#:{query}' in AnyMatch searches ( column:query )
437
			filter_columnFilters : true,  // if true, a filter will be added to the top of each table column
438
			filter_cssFilter     : '',    // css class name added to the filter row & each input in the row ( tablesorter-filter is ALWAYS added )
439
			filter_defaultAttrib : 'data-value', // data attribute in the header cell that contains the default filter value
440
			filter_defaultFilter : {},    // add a default column filter type '~{query}' to make fuzzy searches default; '{q1} AND {q2}' to make all searches use a logical AND.
441
			filter_excludeFilter : {},    // filters to exclude, per column
442
			filter_external      : '',    // jQuery selector string ( or jQuery object ) of external filters
443
			filter_filteredRow   : 'filtered', // class added to filtered rows; define in css with "display:none" to hide the filtered-out rows
444
			filter_filterLabel   : 'Filter "{{label}}" column by...', // Aria-label added to filter input/select; see #1495
445
			filter_formatter     : null,  // add custom filter elements to the filter row
446
			filter_functions     : null,  // add custom filter functions using this option
447
			filter_hideEmpty     : true,  // hide filter row when table is empty
448
			filter_hideFilters   : false, // collapse filter row when mouse leaves the area
449
			filter_ignoreCase    : true,  // if true, make all searches case-insensitive
450
			filter_liveSearch    : true,  // if true, search column content while the user types ( with a delay )
451
			filter_matchType     : { 'input': 'exact', 'select': 'exact' }, // global query settings ('exact' or 'match'); overridden by "filter-match" or "filter-exact" class
452
			filter_onlyAvail     : 'filter-onlyAvail', // a header with a select dropdown & this class name will only show available ( visible ) options within the drop down
453
			filter_placeholder   : { search : '', select : '' }, // default placeholder text ( overridden by any header 'data-placeholder' setting )
454
			filter_reset         : null,  // jQuery selector string of an element used to reset the filters
455
			filter_resetOnEsc    : true,  // Reset filter input when the user presses escape - normalized across browsers
456
			filter_saveFilters   : false, // Use the $.tablesorter.storage utility to save the most recent filters
457
			filter_searchDelay   : 300,   // typing delay in milliseconds before starting a search
458
			filter_searchFiltered: true,  // allow searching through already filtered rows in special circumstances; will speed up searching in large tables if true
459
			filter_selectSource  : null,  // include a function to return an array of values to be added to the column filter select
460
			filter_selectSourceSeparator : '|', // filter_selectSource array text left of the separator is added to the option value, right into the option text
461
			filter_serversideFiltering : false, // if true, must perform server-side filtering b/c client-side filtering is disabled, but the ui and events will still be used.
462
			filter_startsWith    : false, // if true, filter start from the beginning of the cell contents
463
			filter_useParsedData : false  // filter all data using parsed content
464
		},
465
		format: function( table, c, wo ) {
466
			if ( !c.$table.hasClass( 'hasFilters' ) ) {
467
				tsf.init( table, c, wo );
468
			}
469
		},
470
		remove: function( table, c, wo, refreshing ) {
471
			var tbodyIndex, $tbody,
472
				$table = c.$table,
473
				$tbodies = c.$tbodies,
474
				events = (
475
					'addRows updateCell update updateRows updateComplete appendCache filterReset ' +
476
					'filterAndSortReset filterFomatterUpdate filterEnd search stickyHeadersInit '
477
				).split( ' ' ).join( c.namespace + 'filter ' );
478
			$table
479
				.removeClass( 'hasFilters' )
480
				// add filter namespace to all BUT search
481
				.unbind( events.replace( ts.regex.spaces, ' ' ) )
482
				// remove the filter row even if refreshing, because the column might have been moved
483
				.find( '.' + tscss.filterRow ).remove();
484
			wo.filter_initialized = false;
485
			if ( refreshing ) { return; }
486
			for ( tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
487
				$tbody = ts.processTbody( table, $tbodies.eq( tbodyIndex ), true ); // remove tbody
488
				$tbody.children().removeClass( wo.filter_filteredRow ).show();
489
				ts.processTbody( table, $tbody, false ); // restore tbody
490
			}
491
			if ( wo.filter_reset ) {
492
				$( document ).undelegate( wo.filter_reset, 'click' + c.namespace + 'filter' );
493
			}
494
		}
495
	});
496
 
497
	tsf = ts.filter = {
498
 
499
		// regex used in filter 'check' functions - not for general use and not documented
500
		regex: {
501
			regex     : /^\/((?:\\\/|[^\/])+)\/([migyu]{0,5})?$/, // regex to test for regex
502
			child     : /tablesorter-childRow/, // child row class name; this gets updated in the script
503
			filtered  : /filtered/, // filtered (hidden) row class name; updated in the script
504
			type      : /undefined|number/, // check type
505
			exact     : /(^[\"\'=]+)|([\"\'=]+$)/g, // exact match (allow '==')
506
			operators : /[<>=]/g, // replace operators
507
			query     : '(q|query)', // replace filter queries
508
			wild01    : /\?/g, // wild card match 0 or 1
509
			wild0More : /\*/g, // wild care match 0 or more
510
			quote     : /\"/g,
511
			isNeg1    : /(>=?\s*-\d)/,
512
			isNeg2    : /(<=?\s*\d)/
513
		},
514
		// function( c, data ) { }
515
		// c = table.config
516
		// data.$row = jQuery object of the row currently being processed
517
		// data.$cells = jQuery object of all cells within the current row
518
		// data.filters = array of filters for all columns ( some may be undefined )
519
		// data.filter = filter for the current column
520
		// data.iFilter = same as data.filter, except lowercase ( if wo.filter_ignoreCase is true )
521
		// data.exact = table cell text ( or parsed data if column parser enabled; may be a number & not a string )
522
		// data.iExact = same as data.exact, except lowercase ( if wo.filter_ignoreCase is true; may be a number & not a string )
523
		// data.cache = table cell text from cache, so it has been parsed ( & in all lower case if c.ignoreCase is true )
524
		// data.cacheArray = An array of parsed content from each table cell in the row being processed
525
		// data.index = column index; table = table element ( DOM )
526
		// data.parsed = array ( by column ) of boolean values ( from filter_useParsedData or 'filter-parsed' class )
527
		types: {
528
			or : function( c, data, vars ) {
529
				// look for "|", but not if it is inside of a regular expression
530
				if ( ( tsfRegex.orTest.test( data.iFilter ) || tsfRegex.orSplit.test( data.filter ) ) &&
531
					// this test for regex has potential to slow down the overall search
532
					!tsfRegex.regex.test( data.filter ) ) {
533
					var indx, filterMatched, query, regex,
534
						// duplicate data but split filter
535
						data2 = $.extend( {}, data ),
536
						filter = data.filter.split( tsfRegex.orSplit ),
537
						iFilter = data.iFilter.split( tsfRegex.orSplit ),
538
						len = filter.length;
539
					for ( indx = 0; indx < len; indx++ ) {
540
						data2.nestedFilters = true;
541
						data2.filter = '' + ( tsf.parseFilter( c, filter[ indx ], data ) || '' );
542
						data2.iFilter = '' + ( tsf.parseFilter( c, iFilter[ indx ], data ) || '' );
543
						query = '(' + ( tsf.parseFilter( c, data2.filter, data ) || '' ) + ')';
544
						try {
545
							// use try/catch, because query may not be a valid regex if "|" is contained within a partial regex search,
546
							// e.g "/(Alex|Aar" -> Uncaught SyntaxError: Invalid regular expression: /(/(Alex)/: Unterminated group
547
							regex = new RegExp( data.isMatch ? query : '^' + query + '$', c.widgetOptions.filter_ignoreCase ? 'i' : '' );
548
							// filterMatched = data2.filter === '' && indx > 0 ? true
549
							// look for an exact match with the 'or' unless the 'filter-match' class is found
550
							filterMatched = regex.test( data2.exact ) || tsf.processTypes( c, data2, vars );
551
							if ( filterMatched ) {
552
								return filterMatched;
553
							}
554
						} catch ( error ) {
555
							return null;
556
						}
557
					}
558
					// may be null from processing types
559
					return filterMatched || false;
560
				}
561
				return null;
562
			},
563
			// Look for an AND or && operator ( logical and )
564
			and : function( c, data, vars ) {
565
				if ( tsfRegex.andTest.test( data.filter ) ) {
566
					var indx, filterMatched, result, query, regex,
567
						// duplicate data but split filter
568
						data2 = $.extend( {}, data ),
569
						filter = data.filter.split( tsfRegex.andSplit ),
570
						iFilter = data.iFilter.split( tsfRegex.andSplit ),
571
						len = filter.length;
572
					for ( indx = 0; indx < len; indx++ ) {
573
						data2.nestedFilters = true;
574
						data2.filter = '' + ( tsf.parseFilter( c, filter[ indx ], data ) || '' );
575
						data2.iFilter = '' + ( tsf.parseFilter( c, iFilter[ indx ], data ) || '' );
576
						query = ( '(' + ( tsf.parseFilter( c, data2.filter, data ) || '' ) + ')' )
577
							// replace wild cards since /(a*)/i will match anything
578
							.replace( tsfRegex.wild01, '\\S{1}' ).replace( tsfRegex.wild0More, '\\S*' );
579
						try {
580
							// use try/catch just in case RegExp is invalid
581
							regex = new RegExp( data.isMatch ? query : '^' + query + '$', c.widgetOptions.filter_ignoreCase ? 'i' : '' );
582
							// look for an exact match with the 'and' unless the 'filter-match' class is found
583
							result = ( regex.test( data2.exact ) || tsf.processTypes( c, data2, vars ) );
584
							if ( indx === 0 ) {
585
								filterMatched = result;
586
							} else {
587
								filterMatched = filterMatched && result;
588
							}
589
						} catch ( error ) {
590
							return null;
591
						}
592
					}
593
					// may be null from processing types
594
					return filterMatched || false;
595
				}
596
				return null;
597
			},
598
			// Look for regex
599
			regex: function( c, data ) {
600
				if ( tsfRegex.regex.test( data.filter ) ) {
601
					var matches,
602
						// cache regex per column for optimal speed
603
						regex = data.filter_regexCache[ data.index ] || tsfRegex.regex.exec( data.filter ),
604
						isRegex = regex instanceof RegExp;
605
					try {
606
						if ( !isRegex ) {
607
							// force case insensitive search if ignoreCase option set?
608
							// if ( c.ignoreCase && !regex[2] ) { regex[2] = 'i'; }
609
							data.filter_regexCache[ data.index ] = regex = new RegExp( regex[1], regex[2] );
610
						}
611
						matches = regex.test( data.exact );
612
					} catch ( error ) {
613
						matches = false;
614
					}
615
					return matches;
616
				}
617
				return null;
618
			},
619
			// Look for operators >, >=, < or <=
620
			operators: function( c, data ) {
621
				// ignore empty strings... because '' < 10 is true
622
				if ( tsfRegex.operTest.test( data.iFilter ) && data.iExact !== '' ) {
623
					var cachedValue, result, txt,
624
						table = c.table,
625
						parsed = data.parsed[ data.index ],
626
						query = ts.formatFloat( data.iFilter.replace( tsfRegex.operators, '' ), table ),
627
						parser = c.parsers[ data.index ] || {},
628
						savedSearch = query;
629
					// parse filter value in case we're comparing numbers ( dates )
630
					if ( parsed || parser.type === 'numeric' ) {
631
						txt = $.trim( '' + data.iFilter.replace( tsfRegex.operators, '' ) );
632
						result = tsf.parseFilter( c, txt, data, true );
633
						query = ( typeof result === 'number' && result !== '' && !isNaN( result ) ) ? result : query;
634
					}
635
					// iExact may be numeric - see issue #149;
636
					// check if cached is defined, because sometimes j goes out of range? ( numeric columns )
637
					if ( ( parsed || parser.type === 'numeric' ) && !isNaN( query ) &&
638
						typeof data.cache !== 'undefined' ) {
639
						cachedValue = data.cache;
640
					} else {
641
						txt = isNaN( data.iExact ) ? data.iExact.replace( ts.regex.nondigit, '' ) : data.iExact;
642
						cachedValue = ts.formatFloat( txt, table );
643
					}
644
					if ( tsfRegex.gtTest.test( data.iFilter ) ) {
645
						result = tsfRegex.gteTest.test( data.iFilter ) ? cachedValue >= query : cachedValue > query;
646
					} else if ( tsfRegex.ltTest.test( data.iFilter ) ) {
647
						result = tsfRegex.lteTest.test( data.iFilter ) ? cachedValue <= query : cachedValue < query;
648
					}
649
					// keep showing all rows if nothing follows the operator
650
					if ( !result && savedSearch === '' ) {
651
						result = true;
652
					}
653
					return result;
654
				}
655
				return null;
656
			},
657
			// Look for a not match
658
			notMatch: function( c, data ) {
659
				if ( tsfRegex.notTest.test( data.iFilter ) ) {
660
					var indx,
661
						txt = data.iFilter.replace( '!', '' ),
662
						filter = tsf.parseFilter( c, txt, data ) || '';
663
					if ( tsfRegex.exact.test( filter ) ) {
664
						// look for exact not matches - see #628
665
						filter = filter.replace( tsfRegex.exact, '' );
666
						return filter === '' ? true : $.trim( filter ) !== data.iExact;
667
					} else {
668
						indx = data.iExact.search( $.trim( filter ) );
669
						return filter === '' ? true :
670
							// return true if not found
671
							data.anyMatch ? indx < 0 :
672
							// return false if found
673
							!( c.widgetOptions.filter_startsWith ? indx === 0 : indx >= 0 );
674
					}
675
				}
676
				return null;
677
			},
678
			// Look for quotes or equals to get an exact match; ignore type since iExact could be numeric
679
			exact: function( c, data ) {
680
				/*jshint eqeqeq:false */
681
				if ( tsfRegex.exact.test( data.iFilter ) ) {
682
					var txt = data.iFilter.replace( tsfRegex.exact, '' ),
683
						filter = tsf.parseFilter( c, txt, data ) || '';
684
					// eslint-disable-next-line eqeqeq
685
					return data.anyMatch ? $.inArray( filter, data.rowArray ) >= 0 : filter == data.iExact;
686
				}
687
				return null;
688
			},
689
			// Look for a range ( using ' to ' or ' - ' ) - see issue #166; thanks matzhu!
690
			range : function( c, data ) {
691
				if ( tsfRegex.toTest.test( data.iFilter ) ) {
692
					var result, tmp, range1, range2,
693
						table = c.table,
694
						index = data.index,
695
						parsed = data.parsed[index],
696
						// make sure the dash is for a range and not indicating a negative number
697
						query = data.iFilter.split( tsfRegex.toSplit );
698
 
699
					tmp = query[0].replace( ts.regex.nondigit, '' ) || '';
700
					range1 = ts.formatFloat( tsf.parseFilter( c, tmp, data ), table );
701
					tmp = query[1].replace( ts.regex.nondigit, '' ) || '';
702
					range2 = ts.formatFloat( tsf.parseFilter( c, tmp, data ), table );
703
					// parse filter value in case we're comparing numbers ( dates )
704
					if ( parsed || c.parsers[ index ].type === 'numeric' ) {
705
						result = c.parsers[ index ].format( '' + query[0], table, c.$headers.eq( index ), index );
706
						range1 = ( result !== '' && !isNaN( result ) ) ? result : range1;
707
						result = c.parsers[ index ].format( '' + query[1], table, c.$headers.eq( index ), index );
708
						range2 = ( result !== '' && !isNaN( result ) ) ? result : range2;
709
					}
710
					if ( ( parsed || c.parsers[ index ].type === 'numeric' ) && !isNaN( range1 ) && !isNaN( range2 ) ) {
711
						result = data.cache;
712
					} else {
713
						tmp = isNaN( data.iExact ) ? data.iExact.replace( ts.regex.nondigit, '' ) : data.iExact;
714
						result = ts.formatFloat( tmp, table );
715
					}
716
					if ( range1 > range2 ) {
717
						tmp = range1; range1 = range2; range2 = tmp; // swap
718
					}
719
					return ( result >= range1 && result <= range2 ) || ( range1 === '' || range2 === '' );
720
				}
721
				return null;
722
			},
723
			// Look for wild card: ? = single, * = multiple, or | = logical OR
724
			wild : function( c, data ) {
725
				if ( tsfRegex.wildOrTest.test( data.iFilter ) ) {
726
					var query = '' + ( tsf.parseFilter( c, data.iFilter, data ) || '' );
727
					// look for an exact match with the 'or' unless the 'filter-match' class is found
728
					if ( !tsfRegex.wildTest.test( query ) && data.nestedFilters ) {
729
						query = data.isMatch ? query : '^(' + query + ')$';
730
					}
731
					// parsing the filter may not work properly when using wildcards =/
732
					try {
733
						return new RegExp(
734
							query.replace( tsfRegex.wild01, '\\S{1}' ).replace( tsfRegex.wild0More, '\\S*' ),
735
							c.widgetOptions.filter_ignoreCase ? 'i' : ''
736
						)
737
						.test( data.exact );
738
					} catch ( error ) {
739
						return null;
740
					}
741
				}
742
				return null;
743
			},
744
			// fuzzy text search; modified from https://github.com/mattyork/fuzzy ( MIT license )
745
			fuzzy: function( c, data ) {
746
				if ( tsfRegex.fuzzyTest.test( data.iFilter ) ) {
747
					var indx,
748
						patternIndx = 0,
749
						len = data.iExact.length,
750
						txt = data.iFilter.slice( 1 ),
751
						pattern = tsf.parseFilter( c, txt, data ) || '';
752
					for ( indx = 0; indx < len; indx++ ) {
753
						if ( data.iExact[ indx ] === pattern[ patternIndx ] ) {
754
							patternIndx += 1;
755
						}
756
					}
757
					return patternIndx === pattern.length;
758
				}
759
				return null;
760
			}
761
		},
762
		init: function( table ) {
763
			// filter language options
764
			ts.language = $.extend( true, {}, {
765
				to  : 'to',
766
				or  : 'or',
767
				and : 'and'
768
			}, ts.language );
769
 
770
			var options, string, txt, $header, column, val, fxn, noSelect,
771
				c = table.config,
772
				wo = c.widgetOptions,
773
				processStr = function(prefix, str, suffix) {
774
					str = str.trim();
775
					// don't include prefix/suffix if str is empty
776
					return str === '' ? '' : (prefix || '') + str + (suffix || '');
777
				};
778
			c.$table.addClass( 'hasFilters' );
779
			c.lastSearch = [];
780
 
781
			// define timers so using clearTimeout won't cause an undefined error
782
			wo.filter_searchTimer = null;
783
			wo.filter_initTimer = null;
784
			wo.filter_formatterCount = 0;
785
			wo.filter_formatterInit = [];
786
			wo.filter_anyColumnSelector = '[data-column="all"],[data-column="any"]';
787
			wo.filter_multipleColumnSelector = '[data-column*="-"],[data-column*=","]';
788
 
789
			val = '\\{' + tsfRegex.query + '\\}';
790
			$.extend( tsfRegex, {
791
				child : new RegExp( c.cssChildRow ),
792
				filtered : new RegExp( wo.filter_filteredRow ),
793
				alreadyFiltered : new RegExp( '(\\s+(-' + processStr('|', ts.language.or) + processStr('|', ts.language.to) + ')\\s+)', 'i' ),
794
				toTest : new RegExp( '\\s+(-' + processStr('|', ts.language.to) + ')\\s+', 'i' ),
795
				toSplit : new RegExp( '(?:\\s+(?:-' + processStr('|', ts.language.to) + ')\\s+)', 'gi' ),
796
				andTest : new RegExp( '\\s+(' + processStr('', ts.language.and, '|') + '&&)\\s+', 'i' ),
797
				andSplit : new RegExp( '(?:\\s+(?:' + processStr('', ts.language.and, '|') + '&&)\\s+)', 'gi' ),
798
				orTest : new RegExp( '(\\|' + processStr('|\\s+', ts.language.or, '\\s+') + ')', 'i' ),
799
				orSplit : new RegExp( '(?:\\|' + processStr('|\\s+(?:', ts.language.or, ')\\s+') + ')', 'gi' ),
800
				iQuery : new RegExp( val, 'i' ),
801
				igQuery : new RegExp( val, 'ig' ),
802
				operTest : /^[<>]=?/,
803
				gtTest  : />/,
804
				gteTest : />=/,
805
				ltTest  : /</,
806
				lteTest : /<=/,
807
				notTest : /^\!/,
808
				wildOrTest : /[\?\*\|]/,
809
				wildTest : /\?\*/,
810
				fuzzyTest : /^~/,
811
				exactTest : /[=\"\|!]/
812
			});
813
 
814
			// don't build filter row if columnFilters is false or all columns are set to 'filter-false'
815
			// see issue #156
816
			val = c.$headers.filter( '.filter-false, .parser-false' ).length;
817
			if ( wo.filter_columnFilters !== false && val !== c.$headers.length ) {
818
				// build filter row
819
				tsf.buildRow( table, c, wo );
820
			}
821
 
822
			txt = 'addRows updateCell update updateRows updateComplete appendCache filterReset ' +
823
				'filterAndSortReset filterResetSaved filterEnd search '.split( ' ' ).join( c.namespace + 'filter ' );
824
			c.$table.bind( txt, function( event, filter ) {
825
				val = wo.filter_hideEmpty &&
826
					$.isEmptyObject( c.cache ) &&
827
					!( c.delayInit && event.type === 'appendCache' );
828
				// hide filter row using the 'filtered' class name
829
				c.$table.find( '.' + tscss.filterRow ).toggleClass( wo.filter_filteredRow, val ); // fixes #450
830
				if ( !/(search|filter)/.test( event.type ) ) {
831
					event.stopPropagation();
832
					tsf.buildDefault( table, true );
833
				}
834
				// Add filterAndSortReset - see #1361
835
				if ( event.type === 'filterReset' || event.type === 'filterAndSortReset' ) {
836
					c.$table.find( '.' + tscss.filter ).add( wo.filter_$externalFilters ).val( '' );
837
					if ( event.type === 'filterAndSortReset' ) {
838
						ts.sortReset( this.config, function() {
839
							tsf.searching( table, [] );
840
						});
841
					} else {
842
						tsf.searching( table, [] );
843
					}
844
				} else if ( event.type === 'filterResetSaved' ) {
845
					ts.storage( table, 'tablesorter-filters', '' );
846
				} else if ( event.type === 'filterEnd' ) {
847
					tsf.buildDefault( table, true );
848
				} else {
849
					// send false argument to force a new search; otherwise if the filter hasn't changed,
850
					// it will return
851
					filter = event.type === 'search' ? filter :
852
						event.type === 'updateComplete' ? c.$table.data( 'lastSearch' ) : '';
853
					if ( /(update|add)/.test( event.type ) && event.type !== 'updateComplete' ) {
854
						// force a new search since content has changed
855
						c.lastCombinedFilter = null;
856
						c.lastSearch = [];
857
						// update filterFormatters after update (& small delay) - Fixes #1237
858
						setTimeout(function() {
859
							c.$table.triggerHandler( 'filterFomatterUpdate' );
860
						}, 100);
861
					}
862
					// pass true ( skipFirst ) to prevent the tablesorter.setFilters function from skipping the first
863
					// input ensures all inputs are updated when a search is triggered on the table
864
					// $( 'table' ).trigger( 'search', [...] );
865
					tsf.searching( table, filter, true );
866
				}
867
				return false;
868
			});
869
 
870
			// reset button/link
871
			if ( wo.filter_reset ) {
872
				if ( wo.filter_reset instanceof $ ) {
873
					// reset contains a jQuery object, bind to it
874
					wo.filter_reset.click( function() {
875
						c.$table.triggerHandler( 'filterReset' );
876
					});
877
				} else if ( $( wo.filter_reset ).length ) {
878
					// reset is a jQuery selector, use event delegation
879
					$( document )
880
						.undelegate( wo.filter_reset, 'click' + c.namespace + 'filter' )
881
						.delegate( wo.filter_reset, 'click' + c.namespace + 'filter', function() {
882
							// trigger a reset event, so other functions ( filter_formatter ) know when to reset
883
							c.$table.triggerHandler( 'filterReset' );
884
						});
885
				}
886
			}
887
			if ( wo.filter_functions ) {
888
				for ( column = 0; column < c.columns; column++ ) {
889
					fxn = ts.getColumnData( table, wo.filter_functions, column );
890
					if ( fxn ) {
891
						// remove 'filter-select' from header otherwise the options added here are replaced with
892
						// all options
893
						$header = c.$headerIndexed[ column ].removeClass( 'filter-select' );
894
						// don't build select if 'filter-false' or 'parser-false' set
895
						noSelect = !( $header.hasClass( 'filter-false' ) || $header.hasClass( 'parser-false' ) );
896
						options = '';
897
						if ( fxn === true && noSelect ) {
898
							tsf.buildSelect( table, column );
899
						} else if ( typeof fxn === 'object' && noSelect ) {
900
							// add custom drop down list
901
							for ( string in fxn ) {
902
								if ( typeof string === 'string' ) {
903
									options += options === '' ?
904
										'<option value="">' +
905
											( $header.data( 'placeholder' ) ||
906
												$header.attr( 'data-placeholder' ) ||
907
												wo.filter_placeholder.select ||
908
												''
909
											) +
910
										'</option>' : '';
911
									val = string;
912
									txt = string;
913
									if ( string.indexOf( wo.filter_selectSourceSeparator ) >= 0 ) {
914
										val = string.split( wo.filter_selectSourceSeparator );
915
										txt = val[1];
916
										val = val[0];
917
									}
918
									options += '<option ' +
919
										( txt === val ? '' : 'data-function-name="' + string + '" ' ) +
920
										'value="' + val + '">' + txt + '</option>';
921
								}
922
							}
923
							c.$table
924
								.find( 'thead' )
925
								.find( 'select.' + tscss.filter + '[data-column="' + column + '"]' )
926
								.append( options );
927
							txt = wo.filter_selectSource;
928
							fxn = typeof txt === 'function' ? true : ts.getColumnData( table, txt, column );
929
							if ( fxn ) {
930
								// updating so the extra options are appended
931
								tsf.buildSelect( c.table, column, '', true, $header.hasClass( wo.filter_onlyAvail ) );
932
							}
933
						}
934
					}
935
				}
936
			}
937
			// not really updating, but if the column has both the 'filter-select' class &
938
			// filter_functions set to true, it would append the same options twice.
939
			tsf.buildDefault( table, true );
940
 
941
			tsf.bindSearch( table, c.$table.find( '.' + tscss.filter ), true );
942
			if ( wo.filter_external ) {
943
				tsf.bindSearch( table, wo.filter_external );
944
			}
945
 
946
			if ( wo.filter_hideFilters ) {
947
				tsf.hideFilters( c );
948
			}
949
 
950
			// show processing icon
951
			if ( c.showProcessing ) {
952
				txt = 'filterStart filterEnd '.split( ' ' ).join( c.namespace + 'filter-sp ' );
953
				c.$table
954
					.unbind( txt.replace( ts.regex.spaces, ' ' ) )
955
					.bind( txt, function( event, columns ) {
956
					// only add processing to certain columns to all columns
957
					$header = ( columns ) ?
958
						c.$table
959
							.find( '.' + tscss.header )
960
							.filter( '[data-column]' )
961
							.filter( function() {
962
								return columns[ $( this ).data( 'column' ) ] !== '';
963
							}) : '';
964
					ts.isProcessing( table, event.type === 'filterStart', columns ? $header : '' );
965
				});
966
			}
967
 
968
			// set filtered rows count ( intially unfiltered )
969
			c.filteredRows = c.totalRows;
970
 
971
			// add default values
972
			txt = 'tablesorter-initialized pagerBeforeInitialized '.split( ' ' ).join( c.namespace + 'filter ' );
973
			c.$table
974
			.unbind( txt.replace( ts.regex.spaces, ' ' ) )
975
			.bind( txt, function() {
976
				tsf.completeInit( this );
977
			});
978
			// if filter widget is added after pager has initialized; then set filter init flag
979
			if ( c.pager && c.pager.initialized && !wo.filter_initialized ) {
980
				c.$table.triggerHandler( 'filterFomatterUpdate' );
981
				setTimeout( function() {
982
					tsf.filterInitComplete( c );
983
				}, 100 );
984
			} else if ( !wo.filter_initialized ) {
985
				tsf.completeInit( table );
986
			}
987
		},
988
		completeInit: function( table ) {
989
			// redefine 'c' & 'wo' so they update properly inside this callback
990
			var c = table.config,
991
				wo = c.widgetOptions,
992
				filters = tsf.setDefaults( table, c, wo ) || [];
993
			if ( filters.length ) {
994
				// prevent delayInit from triggering a cache build if filters are empty
995
				if ( !( c.delayInit && filters.join( '' ) === '' ) ) {
996
					ts.setFilters( table, filters, true );
997
				}
998
			}
999
			c.$table.triggerHandler( 'filterFomatterUpdate' );
1000
			// trigger init after setTimeout to prevent multiple filterStart/End/Init triggers
1001
			setTimeout( function() {
1002
				if ( !wo.filter_initialized ) {
1003
					tsf.filterInitComplete( c );
1004
				}
1005
			}, 100 );
1006
		},
1007
 
1008
		// $cell parameter, but not the config, is passed to the filter_formatters,
1009
		// so we have to work with it instead
1010
		formatterUpdated: function( $cell, column ) {
1011
			// prevent error if $cell is undefined - see #1056
1012
			var $table = $cell && $cell.closest( 'table' );
1013
			var config = $table.length && $table[0].config,
1014
				wo = config && config.widgetOptions;
1015
			if ( wo && !wo.filter_initialized ) {
1016
				// add updates by column since this function
1017
				// may be called numerous times before initialization
1018
				wo.filter_formatterInit[ column ] = 1;
1019
			}
1020
		},
1021
		filterInitComplete: function( c ) {
1022
			var indx, len,
1023
				wo = c.widgetOptions,
1024
				count = 0,
1025
				completed = function() {
1026
					wo.filter_initialized = true;
1027
					// update lastSearch - it gets cleared often
1028
					c.lastSearch = c.$table.data( 'lastSearch' );
1029
					c.$table.triggerHandler( 'filterInit', c );
1030
					tsf.findRows( c.table, c.lastSearch || [] );
1031
					if (ts.debug(c, 'filter')) {
1032
						console.log('Filter >> Widget initialized');
1033
					}
1034
				};
1035
			if ( $.isEmptyObject( wo.filter_formatter ) ) {
1036
				completed();
1037
			} else {
1038
				len = wo.filter_formatterInit.length;
1039
				for ( indx = 0; indx < len; indx++ ) {
1040
					if ( wo.filter_formatterInit[ indx ] === 1 ) {
1041
						count++;
1042
					}
1043
				}
1044
				clearTimeout( wo.filter_initTimer );
1045
				if ( !wo.filter_initialized && count === wo.filter_formatterCount ) {
1046
					// filter widget initialized
1047
					completed();
1048
				} else if ( !wo.filter_initialized ) {
1049
					// fall back in case a filter_formatter doesn't call
1050
					// $.tablesorter.filter.formatterUpdated( $cell, column ), and the count is off
1051
					wo.filter_initTimer = setTimeout( function() {
1052
						completed();
1053
					}, 500 );
1054
				}
1055
			}
1056
		},
1057
		// encode or decode filters for storage; see #1026
1058
		processFilters: function( filters, encode ) {
1059
			var indx,
1060
				// fixes #1237; previously returning an encoded "filters" value
1061
				result = [],
1062
				mode = encode ? encodeURIComponent : decodeURIComponent,
1063
				len = filters.length;
1064
			for ( indx = 0; indx < len; indx++ ) {
1065
				if ( filters[ indx ] ) {
1066
					result[ indx ] = mode( filters[ indx ] );
1067
				}
1068
			}
1069
			return result;
1070
		},
1071
		setDefaults: function( table, c, wo ) {
1072
			var isArray, saved, indx, col, $filters,
1073
				// get current ( default ) filters
1074
				filters = ts.getFilters( table ) || [];
1075
			if ( wo.filter_saveFilters && ts.storage ) {
1076
				saved = ts.storage( table, 'tablesorter-filters' ) || [];
1077
				isArray = $.isArray( saved );
1078
				// make sure we're not just getting an empty array
1079
				if ( !( isArray && saved.join( '' ) === '' || !isArray ) ) {
1080
					filters = tsf.processFilters( saved );
1081
				}
1082
			}
1083
			// if no filters saved, then check default settings
1084
			if ( filters.join( '' ) === '' ) {
1085
				// allow adding default setting to external filters
1086
				$filters = c.$headers.add( wo.filter_$externalFilters )
1087
					.filter( '[' + wo.filter_defaultAttrib + ']' );
1088
				for ( indx = 0; indx <= c.columns; indx++ ) {
1089
					// include data-column='all' external filters
1090
					col = indx === c.columns ? 'all' : indx;
1091
					filters[ indx ] = $filters
1092
						.filter( '[data-column="' + col + '"]' )
1093
						.attr( wo.filter_defaultAttrib ) || filters[indx] || '';
1094
				}
1095
			}
1096
			c.$table.data( 'lastSearch', filters );
1097
			return filters;
1098
		},
1099
		parseFilter: function( c, filter, data, parsed ) {
1100
			return parsed || data.parsed[ data.index ] ?
1101
				c.parsers[ data.index ].format( filter, c.table, [], data.index ) :
1102
				filter;
1103
		},
1104
		buildRow: function( table, c, wo ) {
1105
			var $filter, col, column, $header, makeSelect, disabled, name, ffxn, tmp,
1106
				// c.columns defined in computeThIndexes()
1107
				cellFilter = wo.filter_cellFilter,
1108
				columns = c.columns,
1109
				arry = $.isArray( cellFilter ),
1110
				buildFilter = '<tr role="search" class="' + tscss.filterRow + ' ' + c.cssIgnoreRow + '">';
1111
			for ( column = 0; column < columns; column++ ) {
1112
				if ( c.$headerIndexed[ column ].length ) {
1113
					// account for entire column set with colspan. See #1047
1114
					tmp = c.$headerIndexed[ column ] && c.$headerIndexed[ column ][0].colSpan || 0;
1115
					if ( tmp > 1 ) {
1116
						buildFilter += '<td data-column="' + column + '-' + ( column + tmp - 1 ) + '" colspan="' + tmp + '"';
1117
					} else {
1118
						buildFilter += '<td data-column="' + column + '"';
1119
					}
1120
					if ( arry ) {
1121
						buildFilter += ( cellFilter[ column ] ? ' class="' + cellFilter[ column ] + '"' : '' );
1122
					} else {
1123
						buildFilter += ( cellFilter !== '' ? ' class="' + cellFilter + '"' : '' );
1124
					}
1125
					buildFilter += '></td>';
1126
				}
1127
			}
1128
			c.$filters = $( buildFilter += '</tr>' )
1129
				.appendTo( c.$table.children( 'thead' ).eq( 0 ) )
1130
				.children( 'td' );
1131
			// build each filter input
1132
			for ( column = 0; column < columns; column++ ) {
1133
				disabled = false;
1134
				// assuming last cell of a column is the main column
1135
				$header = c.$headerIndexed[ column ];
1136
				if ( $header && $header.length ) {
1137
					// $filter = c.$filters.filter( '[data-column="' + column + '"]' );
1138
					$filter = tsf.getColumnElm( c, c.$filters, column );
1139
					ffxn = ts.getColumnData( table, wo.filter_functions, column );
1140
					makeSelect = ( wo.filter_functions && ffxn && typeof ffxn !== 'function' ) ||
1141
						$header.hasClass( 'filter-select' );
1142
					// get data from jQuery data, metadata, headers option or header class name
1143
					col = ts.getColumnData( table, c.headers, column );
1144
					disabled = ts.getData( $header[0], col, 'filter' ) === 'false' ||
1145
						ts.getData( $header[0], col, 'parser' ) === 'false';
1146
 
1147
					if ( makeSelect ) {
1148
						buildFilter = $( '<select>' ).appendTo( $filter );
1149
					} else {
1150
						ffxn = ts.getColumnData( table, wo.filter_formatter, column );
1151
						if ( ffxn ) {
1152
							wo.filter_formatterCount++;
1153
							buildFilter = ffxn( $filter, column );
1154
							// no element returned, so lets go find it
1155
							if ( buildFilter && buildFilter.length === 0 ) {
1156
								buildFilter = $filter.children( 'input' );
1157
							}
1158
							// element not in DOM, so lets attach it
1159
							if ( buildFilter && ( buildFilter.parent().length === 0 ||
1160
								( buildFilter.parent().length && buildFilter.parent()[0] !== $filter[0] ) ) ) {
1161
								$filter.append( buildFilter );
1162
							}
1163
						} else {
1164
							buildFilter = $( '<input type="search">' ).appendTo( $filter );
1165
						}
1166
						if ( buildFilter ) {
1167
							tmp = $header.data( 'placeholder' ) ||
1168
								$header.attr( 'data-placeholder' ) ||
1169
								wo.filter_placeholder.search || '';
1170
							buildFilter.attr( 'placeholder', tmp );
1171
						}
1172
					}
1173
					if ( buildFilter ) {
1174
						// add filter class name
1175
						name = ( $.isArray( wo.filter_cssFilter ) ?
1176
							( typeof wo.filter_cssFilter[column] !== 'undefined' ? wo.filter_cssFilter[column] || '' : '' ) :
1177
							wo.filter_cssFilter ) || '';
1178
						// copy data-column from table cell (it will include colspan)
1179
						buildFilter.addClass( tscss.filter + ' ' + name );
1180
						name = wo.filter_filterLabel;
1181
						tmp = name.match(/{{([^}]+?)}}/g);
1182
						if (!tmp) {
1183
							tmp = [ '{{label}}' ];
1184
						}
1185
						$.each(tmp, function(indx, attr) {
1186
							var regex = new RegExp(attr, 'g'),
1187
								data = $header.attr('data-' + attr.replace(/{{|}}/g, '')),
1188
								text = typeof data === 'undefined' ? $header.text() : data;
1189
							name = name.replace( regex, $.trim( text ) );
1190
						});
1191
						buildFilter.attr({
1192
							'data-column': $filter.attr( 'data-column' ),
1193
							'aria-label': name
1194
						});
1195
						if ( disabled ) {
1196
							buildFilter.attr( 'placeholder', '' ).addClass( tscss.filterDisabled )[0].disabled = true;
1197
						}
1198
					}
1199
				}
1200
			}
1201
		},
1202
		bindSearch: function( table, $el, internal ) {
1203
			table = $( table )[0];
1204
			$el = $( $el ); // allow passing a selector string
1205
			if ( !$el.length ) { return; }
1206
			var tmp,
1207
				c = table.config,
1208
				wo = c.widgetOptions,
1209
				namespace = c.namespace + 'filter',
1210
				$ext = wo.filter_$externalFilters;
1211
			if ( internal !== true ) {
1212
				// save anyMatch element
1213
				tmp = wo.filter_anyColumnSelector + ',' + wo.filter_multipleColumnSelector;
1214
				wo.filter_$anyMatch = $el.filter( tmp );
1215
				if ( $ext && $ext.length ) {
1216
					wo.filter_$externalFilters = wo.filter_$externalFilters.add( $el );
1217
				} else {
1218
					wo.filter_$externalFilters = $el;
1219
				}
1220
				// update values ( external filters added after table initialization )
1221
				ts.setFilters( table, c.$table.data( 'lastSearch' ) || [], internal === false );
1222
			}
1223
			// unbind events
1224
			tmp = ( 'keypress keyup keydown search change input '.split( ' ' ).join( namespace + ' ' ) );
1225
			$el
1226
			// use data attribute instead of jQuery data since the head is cloned without including
1227
			// the data/binding
1228
			.attr( 'data-lastSearchTime', new Date().getTime() )
1229
			.unbind( tmp.replace( ts.regex.spaces, ' ' ) )
1230
			.bind( 'keydown' + namespace, function( event ) {
1231
				if ( event.which === tskeyCodes.escape && !table.config.widgetOptions.filter_resetOnEsc ) {
1232
					// prevent keypress event
1233
					return false;
1234
				}
1235
			})
1236
			.bind( 'keyup' + namespace, function( event ) {
1237
				wo = table.config.widgetOptions; // make sure "wo" isn't cached
1238
				var column = parseInt( $( this ).attr( 'data-column' ), 10 ),
1239
					liveSearch = typeof wo.filter_liveSearch === 'boolean' ? wo.filter_liveSearch :
1240
						ts.getColumnData( table, wo.filter_liveSearch, column );
1241
				if ( typeof liveSearch === 'undefined' ) {
1242
					liveSearch = wo.filter_liveSearch.fallback || false;
1243
				}
1244
				$( this ).attr( 'data-lastSearchTime', new Date().getTime() );
1245
				// emulate what webkit does.... escape clears the filter
1246
				if ( event.which === tskeyCodes.escape ) {
1247
					// make sure to restore the last value on escape
1248
					this.value = wo.filter_resetOnEsc ? '' : c.lastSearch[column];
1249
					// don't return if the search value is empty ( all rows need to be revealed )
1250
				} else if ( this.value !== '' && (
1251
					// liveSearch can contain a min value length; ignore arrow and meta keys, but allow backspace
1252
					( typeof liveSearch === 'number' && this.value.length < liveSearch ) ||
1253
					// let return & backspace continue on, but ignore arrows & non-valid characters
1254
					( event.which !== tskeyCodes.enter && event.which !== tskeyCodes.backSpace &&
1255
						( event.which < tskeyCodes.space || ( event.which >= tskeyCodes.left && event.which <= tskeyCodes.down ) ) ) ) ) {
1256
					return;
1257
					// live search
1258
				} else if ( liveSearch === false ) {
1259
					if ( this.value !== '' && event.which !== tskeyCodes.enter ) {
1260
						return;
1261
					}
1262
				}
1263
				// change event = no delay; last true flag tells getFilters to skip newest timed input
1264
				tsf.searching( table, true, true, column );
1265
			})
1266
			// include change for select - fixes #473
1267
			.bind( 'search change keypress input blur '.split( ' ' ).join( namespace + ' ' ), function( event ) {
1268
				// don't get cached data, in case data-column changes dynamically
1269
				var column = parseInt( $( this ).attr( 'data-column' ), 10 ),
1270
					eventType = event.type,
1271
					liveSearch = typeof wo.filter_liveSearch === 'boolean' ?
1272
						wo.filter_liveSearch :
1273
						ts.getColumnData( table, wo.filter_liveSearch, column );
1274
				if ( table.config.widgetOptions.filter_initialized &&
1275
					// immediate search if user presses enter
1276
					( event.which === tskeyCodes.enter ||
1277
						// immediate search if a "search" or "blur" is triggered on the input
1278
						( eventType === 'search' || eventType === 'blur' ) ||
1279
						// change & input events must be ignored if liveSearch !== true
1280
						( eventType === 'change' || eventType === 'input' ) &&
1281
						// prevent search if liveSearch is a number
1282
						( liveSearch === true || liveSearch !== true && event.target.nodeName !== 'INPUT' ) &&
1283
						// don't allow 'change' or 'input' event to process if the input value
1284
						// is the same - fixes #685
1285
						this.value !== c.lastSearch[column]
1286
					)
1287
				) {
1288
					event.preventDefault();
1289
					// init search with no delay
1290
					$( this ).attr( 'data-lastSearchTime', new Date().getTime() );
1291
					tsf.searching( table, eventType !== 'keypress', true, column );
1292
				}
1293
			});
1294
		},
1295
		searching: function( table, filter, skipFirst, column ) {
1296
			var liveSearch,
1297
				wo = table.config.widgetOptions;
1298
			if (typeof column === 'undefined') {
1299
				// no delay
1300
				liveSearch = false;
1301
			} else {
1302
				liveSearch = typeof wo.filter_liveSearch === 'boolean' ?
1303
					wo.filter_liveSearch :
1304
					// get column setting, or set to fallback value, or default to false
1305
					ts.getColumnData( table, wo.filter_liveSearch, column );
1306
				if ( typeof liveSearch === 'undefined' ) {
1307
					liveSearch = wo.filter_liveSearch.fallback || false;
1308
				}
1309
			}
1310
			clearTimeout( wo.filter_searchTimer );
1311
			if ( typeof filter === 'undefined' || filter === true ) {
1312
				// delay filtering
1313
				wo.filter_searchTimer = setTimeout( function() {
1314
					tsf.checkFilters( table, filter, skipFirst );
1315
				}, liveSearch ? wo.filter_searchDelay : 10 );
1316
			} else {
1317
				// skip delay
1318
				tsf.checkFilters( table, filter, skipFirst );
1319
			}
1320
		},
1321
		equalFilters: function (c, filter1, filter2) {
1322
			var indx,
1323
				f1 = [],
1324
				f2 = [],
1325
				len = c.columns + 1; // add one to include anyMatch filter
1326
			filter1 = $.isArray(filter1) ? filter1 : [];
1327
			filter2 = $.isArray(filter2) ? filter2 : [];
1328
			for (indx = 0; indx < len; indx++) {
1329
				f1[indx] = filter1[indx] || '';
1330
				f2[indx] = filter2[indx] || '';
1331
			}
1332
			return f1.join(',') === f2.join(',');
1333
		},
1334
		checkFilters: function( table, filter, skipFirst ) {
1335
			var c = table.config,
1336
				wo = c.widgetOptions,
1337
				filterArray = $.isArray( filter ),
1338
				filters = ( filterArray ) ? filter : ts.getFilters( table, true ),
1339
				currentFilters = filters || []; // current filter values
1340
			// prevent errors if delay init is set
1341
			if ( $.isEmptyObject( c.cache ) ) {
1342
				// update cache if delayInit set & pager has initialized ( after user initiates a search )
1343
				if ( c.delayInit && ( !c.pager || c.pager && c.pager.initialized ) ) {
1344
					ts.updateCache( c, function() {
1345
						tsf.checkFilters( table, false, skipFirst );
1346
					});
1347
				}
1348
				return;
1349
			}
1350
			// add filter array back into inputs
1351
			if ( filterArray ) {
1352
				ts.setFilters( table, filters, false, skipFirst !== true );
1353
				if ( !wo.filter_initialized ) {
1354
					c.lastSearch = [];
1355
					c.lastCombinedFilter = '';
1356
				}
1357
			}
1358
			if ( wo.filter_hideFilters ) {
1359
				// show/hide filter row as needed
1360
				c.$table
1361
					.find( '.' + tscss.filterRow )
1362
					.triggerHandler( tsf.hideFiltersCheck( c ) ? 'mouseleave' : 'mouseenter' );
1363
			}
1364
			// return if the last search is the same; but filter === false when updating the search
1365
			// see example-widget-filter.html filter toggle buttons
1366
			if ( tsf.equalFilters(c, c.lastSearch, currentFilters) && filter !== false ) {
1367
				return;
1368
			} else if ( filter === false ) {
1369
				// force filter refresh
1370
				c.lastCombinedFilter = '';
1371
				c.lastSearch = [];
1372
			}
1373
			// define filter inside it is false
1374
			filters = filters || [];
1375
			// convert filters to strings - see #1070
1376
			filters = Array.prototype.map ?
1377
				filters.map( String ) :
1378
				// for IE8 & older browsers - maybe not the best method
1379
				filters.join( '\ufffd' ).split( '\ufffd' );
1380
 
1381
			if ( wo.filter_initialized ) {
1382
				c.$table.triggerHandler( 'filterStart', [ filters ] );
1383
			}
1384
			if ( c.showProcessing ) {
1385
				// give it time for the processing icon to kick in
1386
				setTimeout( function() {
1387
					tsf.findRows( table, filters, currentFilters );
1388
					return false;
1389
				}, 30 );
1390
			} else {
1391
				tsf.findRows( table, filters, currentFilters );
1392
				return false;
1393
			}
1394
		},
1395
		hideFiltersCheck: function( c ) {
1396
			if (typeof c.widgetOptions.filter_hideFilters === 'function') {
1397
				var val = c.widgetOptions.filter_hideFilters( c );
1398
				if (typeof val === 'boolean') {
1399
					return val;
1400
				}
1401
			}
1402
			return ts.getFilters( c.$table ).join( '' ) === '';
1403
		},
1404
		hideFilters: function( c, $table ) {
1405
			var timer;
1406
			( $table || c.$table )
1407
				.find( '.' + tscss.filterRow )
1408
				.addClass( tscss.filterRowHide )
1409
				.bind( 'mouseenter mouseleave', function( e ) {
1410
					// save event object - http://bugs.jquery.com/ticket/12140
1411
					var event = e,
1412
						$row = $( this );
1413
					clearTimeout( timer );
1414
					timer = setTimeout( function() {
1415
						if ( /enter|over/.test( event.type ) ) {
1416
							$row.removeClass( tscss.filterRowHide );
1417
						} else {
1418
							// don't hide if input has focus
1419
							// $( ':focus' ) needs jQuery 1.6+
1420
							if ( $( document.activeElement ).closest( 'tr' )[0] !== $row[0] ) {
1421
								// don't hide row if any filter has a value
1422
								$row.toggleClass( tscss.filterRowHide, tsf.hideFiltersCheck( c ) );
1423
							}
1424
						}
1425
					}, 200 );
1426
				})
1427
				.find( 'input, select' ).bind( 'focus blur', function( e ) {
1428
					var event = e,
1429
						$row = $( this ).closest( 'tr' );
1430
					clearTimeout( timer );
1431
					timer = setTimeout( function() {
1432
						clearTimeout( timer );
1433
						// don't hide row if any filter has a value
1434
						$row.toggleClass( tscss.filterRowHide, tsf.hideFiltersCheck( c ) && event.type !== 'focus' );
1435
					}, 200 );
1436
				});
1437
		},
1438
		defaultFilter: function( filter, mask ) {
1439
			if ( filter === '' ) { return filter; }
1440
			var regex = tsfRegex.iQuery,
1441
				maskLen = mask.match( tsfRegex.igQuery ).length,
1442
				query = maskLen > 1 ? $.trim( filter ).split( /\s/ ) : [ $.trim( filter ) ],
1443
				len = query.length - 1,
1444
				indx = 0,
1445
				val = mask;
1446
			if ( len < 1 && maskLen > 1 ) {
1447
				// only one 'word' in query but mask has >1 slots
1448
				query[1] = query[0];
1449
			}
1450
			// replace all {query} with query words...
1451
			// if query = 'Bob', then convert mask from '!{query}' to '!Bob'
1452
			// if query = 'Bob Joe Frank', then convert mask '{q} OR {q}' to 'Bob OR Joe OR Frank'
1453
			while ( regex.test( val ) ) {
1454
				val = val.replace( regex, query[indx++] || '' );
1455
				if ( regex.test( val ) && indx < len && ( query[indx] || '' ) !== '' ) {
1456
					val = mask.replace( regex, val );
1457
				}
1458
			}
1459
			return val;
1460
		},
1461
		getLatestSearch: function( $input ) {
1462
			if ( $input ) {
1463
				return $input.sort( function( a, b ) {
1464
					return $( b ).attr( 'data-lastSearchTime' ) - $( a ).attr( 'data-lastSearchTime' );
1465
				});
1466
			}
1467
			return $input || $();
1468
		},
1469
		findRange: function( c, val, ignoreRanges ) {
1470
			// look for multiple columns '1-3,4-6,8' in data-column
1471
			var temp, ranges, range, start, end, singles, i, indx, len,
1472
				columns = [];
1473
			if ( /^[0-9]+$/.test( val ) ) {
1474
				// always return an array
1475
				return [ parseInt( val, 10 ) ];
1476
			}
1477
			// process column range
1478
			if ( !ignoreRanges && /-/.test( val ) ) {
1479
				ranges = val.match( /(\d+)\s*-\s*(\d+)/g );
1480
				len = ranges ? ranges.length : 0;
1481
				for ( indx = 0; indx < len; indx++ ) {
1482
					range = ranges[indx].split( /\s*-\s*/ );
1483
					start = parseInt( range[0], 10 ) || 0;
1484
					end = parseInt( range[1], 10 ) || ( c.columns - 1 );
1485
					if ( start > end ) {
1486
						temp = start; start = end; end = temp; // swap
1487
					}
1488
					if ( end >= c.columns ) {
1489
						end = c.columns - 1;
1490
					}
1491
					for ( ; start <= end; start++ ) {
1492
						columns[ columns.length ] = start;
1493
					}
1494
					// remove processed range from val
1495
					val = val.replace( ranges[ indx ], '' );
1496
				}
1497
			}
1498
			// process single columns
1499
			if ( !ignoreRanges && /,/.test( val ) ) {
1500
				singles = val.split( /\s*,\s*/ );
1501
				len = singles.length;
1502
				for ( i = 0; i < len; i++ ) {
1503
					if ( singles[ i ] !== '' ) {
1504
						indx = parseInt( singles[ i ], 10 );
1505
						if ( indx < c.columns ) {
1506
							columns[ columns.length ] = indx;
1507
						}
1508
					}
1509
				}
1510
			}
1511
			// return all columns
1512
			if ( !columns.length ) {
1513
				for ( indx = 0; indx < c.columns; indx++ ) {
1514
					columns[ columns.length ] = indx;
1515
				}
1516
			}
1517
			return columns;
1518
		},
1519
		getColumnElm: function( c, $elements, column ) {
1520
			// data-column may contain multiple columns '1-3,5-6,8'
1521
			// replaces: c.$filters.filter( '[data-column="' + column + '"]' );
1522
			return $elements.filter( function() {
1523
				var cols = tsf.findRange( c, $( this ).attr( 'data-column' ) );
1524
				return $.inArray( column, cols ) > -1;
1525
			});
1526
		},
1527
		multipleColumns: function( c, $input ) {
1528
			// look for multiple columns '1-3,4-6,8' in data-column
1529
			var wo = c.widgetOptions,
1530
				// only target 'all' column inputs on initialization
1531
				// & don't target 'all' column inputs if they don't exist
1532
				targets = wo.filter_initialized || !$input.filter( wo.filter_anyColumnSelector ).length,
1533
				val = $.trim( tsf.getLatestSearch( $input ).attr( 'data-column' ) || '' );
1534
			return tsf.findRange( c, val, !targets );
1535
		},
1536
		processTypes: function( c, data, vars ) {
1537
			var ffxn,
1538
				filterMatched = null,
1539
				matches = null;
1540
			for ( ffxn in tsf.types ) {
1541
				if ( $.inArray( ffxn, vars.excludeMatch ) < 0 && matches === null ) {
1542
					matches = tsf.types[ffxn]( c, data, vars );
1543
					if ( matches !== null ) {
1544
						data.matchedOn = ffxn;
1545
						filterMatched = matches;
1546
					}
1547
				}
1548
			}
1549
			return filterMatched;
1550
		},
1551
		matchType: function( c, columnIndex ) {
1552
			var isMatch,
1553
				wo = c.widgetOptions,
1554
				$el = c.$headerIndexed[ columnIndex ];
1555
			// filter-exact > filter-match > filter_matchType for type
1556
			if ( $el.hasClass( 'filter-exact' ) ) {
1557
				isMatch = false;
1558
			} else if ( $el.hasClass( 'filter-match' ) ) {
1559
				isMatch = true;
1560
			} else {
1561
				// filter-select is not applied when filter_functions are used, so look for a select
1562
				if ( wo.filter_columnFilters ) {
1563
					$el = c.$filters
1564
						.find( '.' + tscss.filter )
1565
						.add( wo.filter_$externalFilters )
1566
						.filter( '[data-column="' + columnIndex + '"]' );
1567
				} else if ( wo.filter_$externalFilters ) {
1568
					$el = wo.filter_$externalFilters.filter( '[data-column="' + columnIndex + '"]' );
1569
				}
1570
				isMatch = $el.length ?
1571
					c.widgetOptions.filter_matchType[ ( $el[ 0 ].nodeName || '' ).toLowerCase() ] === 'match' :
1572
					// default to exact, if no inputs found
1573
					false;
1574
			}
1575
			return isMatch;
1576
		},
1577
		processRow: function( c, data, vars ) {
1578
			var result, filterMatched,
1579
				fxn, ffxn, txt,
1580
				wo = c.widgetOptions,
1581
				showRow = true,
1582
				hasAnyMatchInput = wo.filter_$anyMatch && wo.filter_$anyMatch.length,
1583
 
1584
				// if wo.filter_$anyMatch data-column attribute is changed dynamically
1585
				// we don't want to do an "anyMatch" search on one column using data
1586
				// for the entire row - see #998
1587
				columnIndex = wo.filter_$anyMatch && wo.filter_$anyMatch.length ?
1588
					// look for multiple columns '1-3,4-6,8'
1589
					tsf.multipleColumns( c, wo.filter_$anyMatch ) :
1590
					[];
1591
			data.$cells = data.$row.children();
1592
			data.matchedOn = null;
1593
			if ( data.anyMatchFlag && columnIndex.length > 1 || ( data.anyMatchFilter && !hasAnyMatchInput ) ) {
1594
				data.anyMatch = true;
1595
				data.isMatch = true;
1596
				data.rowArray = data.$cells.map( function( i ) {
1597
					if ( $.inArray( i, columnIndex ) > -1 || ( data.anyMatchFilter && !hasAnyMatchInput ) ) {
1598
						if ( data.parsed[ i ] ) {
1599
							txt = data.cacheArray[ i ];
1600
						} else {
1601
							txt = data.rawArray[ i ];
1602
							txt = $.trim( wo.filter_ignoreCase ? txt.toLowerCase() : txt );
1603
							if ( c.sortLocaleCompare ) {
1604
								txt = ts.replaceAccents( txt );
1605
							}
1606
						}
1607
						return txt;
1608
					}
1609
				}).get();
1610
				data.filter = data.anyMatchFilter;
1611
				data.iFilter = data.iAnyMatchFilter;
1612
				data.exact = data.rowArray.join( ' ' );
1613
				data.iExact = wo.filter_ignoreCase ? data.exact.toLowerCase() : data.exact;
1614
				data.cache = data.cacheArray.slice( 0, -1 ).join( ' ' );
1615
				vars.excludeMatch = vars.noAnyMatch;
1616
				filterMatched = tsf.processTypes( c, data, vars );
1617
				if ( filterMatched !== null ) {
1618
					showRow = filterMatched;
1619
				} else {
1620
					if ( wo.filter_startsWith ) {
1621
						showRow = false;
1622
						// data.rowArray may not contain all columns
1623
						columnIndex = Math.min( c.columns, data.rowArray.length );
1624
						while ( !showRow && columnIndex > 0 ) {
1625
							columnIndex--;
1626
							showRow = showRow || data.rowArray[ columnIndex ].indexOf( data.iFilter ) === 0;
1627
						}
1628
					} else {
1629
						showRow = ( data.iExact + data.childRowText ).indexOf( data.iFilter ) >= 0;
1630
					}
1631
				}
1632
				data.anyMatch = false;
1633
				// no other filters to process
1634
				if ( data.filters.join( '' ) === data.filter ) {
1635
					return showRow;
1636
				}
1637
			}
1638
 
1639
			for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
1640
				data.filter = data.filters[ columnIndex ];
1641
				data.index = columnIndex;
1642
 
1643
				// filter types to exclude, per column
1644
				vars.excludeMatch = vars.excludeFilter[ columnIndex ];
1645
 
1646
				// ignore if filter is empty or disabled
1647
				if ( data.filter ) {
1648
					data.cache = data.cacheArray[ columnIndex ];
1649
					result = data.parsed[ columnIndex ] ? data.cache : data.rawArray[ columnIndex ] || '';
1650
					data.exact = c.sortLocaleCompare ? ts.replaceAccents( result ) : result; // issue #405
1651
					data.iExact = !tsfRegex.type.test( typeof data.exact ) && wo.filter_ignoreCase ?
1652
						data.exact.toLowerCase() : data.exact;
1653
					data.isMatch = tsf.matchType( c, columnIndex );
1654
 
1655
					result = showRow; // if showRow is true, show that row
1656
 
1657
					// in case select filter option has a different value vs text 'a - z|A through Z'
1658
					ffxn = wo.filter_columnFilters ?
1659
						c.$filters.add( wo.filter_$externalFilters )
1660
							.filter( '[data-column="' + columnIndex + '"]' )
1661
							.find( 'select option:selected' )
1662
							.attr( 'data-function-name' ) || '' : '';
1663
					// replace accents - see #357
1664
					if ( c.sortLocaleCompare ) {
1665
						data.filter = ts.replaceAccents( data.filter );
1666
					}
1667
 
1668
					// replace column specific default filters - see #1088
1669
					if ( wo.filter_defaultFilter && tsfRegex.iQuery.test( vars.defaultColFilter[ columnIndex ] ) ) {
1670
						data.filter = tsf.defaultFilter( data.filter, vars.defaultColFilter[ columnIndex ] );
1671
					}
1672
 
1673
					// data.iFilter = case insensitive ( if wo.filter_ignoreCase is true ),
1674
					// data.filter = case sensitive
1675
					data.iFilter = wo.filter_ignoreCase ? ( data.filter || '' ).toLowerCase() : data.filter;
1676
					fxn = vars.functions[ columnIndex ];
1677
					filterMatched = null;
1678
					if ( fxn ) {
1679
						if ( typeof fxn === 'function' ) {
1680
							// filter callback( exact cell content, parser normalized content,
1681
							// filter input value, column index, jQuery row object )
1682
							filterMatched = fxn( data.exact, data.cache, data.filter, columnIndex, data.$row, c, data );
1683
						} else if ( typeof fxn[ ffxn || data.filter ] === 'function' ) {
1684
							// selector option function
1685
							txt = ffxn || data.filter;
1686
							filterMatched =
1687
								fxn[ txt ]( data.exact, data.cache, data.filter, columnIndex, data.$row, c, data );
1688
						}
1689
					}
1690
					if ( filterMatched === null ) {
1691
						// cycle through the different filters
1692
						// filters return a boolean or null if nothing matches
1693
						filterMatched = tsf.processTypes( c, data, vars );
1694
						// select with exact match; ignore "and" or "or" within the text; fixes #1486
1695
						txt = fxn === true && (data.matchedOn === 'and' || data.matchedOn === 'or');
1696
						if ( filterMatched !== null && !txt) {
1697
							result = filterMatched;
1698
						// Look for match, and add child row data for matching
1699
						} else {
1700
							// check fxn (filter-select in header) after filter types are checked
1701
							// without this, the filter + jQuery UI selectmenu demo was breaking
1702
							if ( fxn === true ) {
1703
								// default selector uses exact match unless 'filter-match' class is found
1704
								result = data.isMatch ?
1705
									// data.iExact may be a number
1706
									( '' + data.iExact ).search( data.iFilter ) >= 0 :
1707
									data.filter === data.exact;
1708
							} else {
1709
								txt = ( data.iExact + data.childRowText ).indexOf( tsf.parseFilter( c, data.iFilter, data ) );
1710
								result = ( ( !wo.filter_startsWith && txt >= 0 ) || ( wo.filter_startsWith && txt === 0 ) );
1711
							}
1712
						}
1713
					} else {
1714
						result = filterMatched;
1715
					}
1716
					showRow = ( result ) ? showRow : false;
1717
				}
1718
			}
1719
			return showRow;
1720
		},
1721
		findRows: function( table, filters, currentFilters ) {
1722
			if (
1723
				tsf.equalFilters(table.config, table.config.lastSearch, currentFilters) ||
1724
				!table.config.widgetOptions.filter_initialized
1725
			) {
1726
				return;
1727
			}
1728
			var len, norm_rows, rowData, $rows, $row, rowIndex, tbodyIndex, $tbody, columnIndex,
1729
				isChild, childRow, lastSearch, showRow, showParent, time, val, indx,
1730
				notFiltered, searchFiltered, query, injected, res, id, txt,
1731
				storedFilters = $.extend( [], filters ),
1732
				c = table.config,
1733
				wo = c.widgetOptions,
1734
				debug = ts.debug(c, 'filter'),
1735
				// data object passed to filters; anyMatch is a flag for the filters
1736
				data = {
1737
					anyMatch: false,
1738
					filters: filters,
1739
					// regex filter type cache
1740
					filter_regexCache : []
1741
				},
1742
				vars = {
1743
					// anyMatch really screws up with these types of filters
1744
					noAnyMatch: [ 'range',  'operators' ],
1745
					// cache filter variables that use ts.getColumnData in the main loop
1746
					functions : [],
1747
					excludeFilter : [],
1748
					defaultColFilter : [],
1749
					defaultAnyFilter : ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || ''
1750
				};
1751
			// parse columns after formatter, in case the class is added at that point
1752
			data.parsed = [];
1753
			for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
1754
				data.parsed[ columnIndex ] = wo.filter_useParsedData ||
1755
					// parser has a "parsed" parameter
1756
					( c.parsers && c.parsers[ columnIndex ] && c.parsers[ columnIndex ].parsed ||
1757
					// getData may not return 'parsed' if other 'filter-' class names exist
1758
					// ( e.g. <th class="filter-select filter-parsed"> )
1759
					ts.getData && ts.getData( c.$headerIndexed[ columnIndex ],
1760
						ts.getColumnData( table, c.headers, columnIndex ), 'filter' ) === 'parsed' ||
1761
					c.$headerIndexed[ columnIndex ].hasClass( 'filter-parsed' ) );
1762
 
1763
				vars.functions[ columnIndex ] =
1764
					ts.getColumnData( table, wo.filter_functions, columnIndex ) ||
1765
					c.$headerIndexed[ columnIndex ].hasClass( 'filter-select' );
1766
				vars.defaultColFilter[ columnIndex ] =
1767
					ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '';
1768
				vars.excludeFilter[ columnIndex ] =
1769
					( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split( /\s+/ );
1770
			}
1771
 
1772
			if ( debug ) {
1773
				console.log( 'Filter >> Starting filter widget search', filters );
1774
				time = new Date();
1775
			}
1776
			// filtered rows count
1777
			c.filteredRows = 0;
1778
			c.totalRows = 0;
1779
			currentFilters = ( storedFilters || [] );
1780
 
1781
			for ( tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++ ) {
1782
				$tbody = ts.processTbody( table, c.$tbodies.eq( tbodyIndex ), true );
1783
				// skip child rows & widget added ( removable ) rows - fixes #448 thanks to @hempel!
1784
				// $rows = $tbody.children( 'tr' ).not( c.selectorRemove );
1785
				columnIndex = c.columns;
1786
				// convert stored rows into a jQuery object
1787
				norm_rows = c.cache[ tbodyIndex ].normalized;
1788
				$rows = $( $.map( norm_rows, function( el ) {
1789
					return el[ columnIndex ].$row.get();
1790
				}) );
1791
 
1792
				if ( currentFilters.join('') === '' || wo.filter_serversideFiltering ) {
1793
					$rows
1794
						.removeClass( wo.filter_filteredRow )
1795
						.not( '.' + c.cssChildRow )
1796
						.css( 'display', '' );
1797
				} else {
1798
					// filter out child rows
1799
					$rows = $rows.not( '.' + c.cssChildRow );
1800
					len = $rows.length;
1801
 
1802
					if ( ( wo.filter_$anyMatch && wo.filter_$anyMatch.length ) ||
1803
						typeof filters[c.columns] !== 'undefined' ) {
1804
						data.anyMatchFlag = true;
1805
						data.anyMatchFilter = '' + (
1806
							filters[ c.columns ] ||
1807
							wo.filter_$anyMatch && tsf.getLatestSearch( wo.filter_$anyMatch ).val() ||
1808
							''
1809
						);
1810
						if ( wo.filter_columnAnyMatch ) {
1811
							// specific columns search
1812
							query = data.anyMatchFilter.split( tsfRegex.andSplit );
1813
							injected = false;
1814
							for ( indx = 0; indx < query.length; indx++ ) {
1815
								res = query[ indx ].split( ':' );
1816
								if ( res.length > 1 ) {
1817
									// make the column a one-based index ( non-developers start counting from one :P )
1818
									if ( isNaN( res[0] ) ) {
1819
										$.each( c.headerContent, function( i, txt ) {
1820
											// multiple matches are possible
1821
											if ( txt.toLowerCase().indexOf( res[0] ) > -1 ) {
1822
												id = i;
1823
												filters[ id ] = res[1];
1824
											}
1825
										});
1826
									} else {
1827
										id = parseInt( res[0], 10 ) - 1;
1828
									}
1829
									if ( id >= 0 && id < c.columns ) { // if id is an integer
1830
										filters[ id ] = res[1];
1831
										query.splice( indx, 1 );
1832
										indx--;
1833
										injected = true;
1834
									}
1835
								}
1836
							}
1837
							if ( injected ) {
1838
								data.anyMatchFilter = query.join( ' && ' );
1839
							}
1840
						}
1841
					}
1842
 
1843
					// optimize searching only through already filtered rows - see #313
1844
					searchFiltered = wo.filter_searchFiltered;
1845
					lastSearch = c.lastSearch || c.$table.data( 'lastSearch' ) || [];
1846
					if ( searchFiltered ) {
1847
						// cycle through all filters; include last ( columnIndex + 1 = match any column ). Fixes #669
1848
						for ( indx = 0; indx < columnIndex + 1; indx++ ) {
1849
							val = filters[indx] || '';
1850
							// break out of loop if we've already determined not to search filtered rows
1851
							if ( !searchFiltered ) { indx = columnIndex; }
1852
							// search already filtered rows if...
1853
							searchFiltered = searchFiltered && lastSearch.length &&
1854
								// there are no changes from beginning of filter
1855
								val.indexOf( lastSearch[indx] || '' ) === 0 &&
1856
								// if there is NOT a logical 'or', or range ( 'to' or '-' ) in the string
1857
								!tsfRegex.alreadyFiltered.test( val ) &&
1858
								// if we are not doing exact matches, using '|' ( logical or ) or not '!'
1859
								!tsfRegex.exactTest.test( val ) &&
1860
								// don't search only filtered if the value is negative
1861
								// ( '> -10' => '> -100' will ignore hidden rows )
1862
								!( tsfRegex.isNeg1.test( val ) || tsfRegex.isNeg2.test( val ) ) &&
1863
								// if filtering using a select without a 'filter-match' class ( exact match ) - fixes #593
1864
								!( val !== '' && c.$filters && c.$filters.filter( '[data-column="' + indx + '"]' ).find( 'select' ).length &&
1865
									!tsf.matchType( c, indx ) );
1866
						}
1867
					}
1868
					notFiltered = $rows.not( '.' + wo.filter_filteredRow ).length;
1869
					// can't search when all rows are hidden - this happens when looking for exact matches
1870
					if ( searchFiltered && notFiltered === 0 ) { searchFiltered = false; }
1871
					if ( debug ) {
1872
						console.log( 'Filter >> Searching through ' +
1873
							( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
1874
					}
1875
					if ( data.anyMatchFlag ) {
1876
						if ( c.sortLocaleCompare ) {
1877
							// replace accents
1878
							data.anyMatchFilter = ts.replaceAccents( data.anyMatchFilter );
1879
						}
1880
						if ( wo.filter_defaultFilter && tsfRegex.iQuery.test( vars.defaultAnyFilter ) ) {
1881
							data.anyMatchFilter = tsf.defaultFilter( data.anyMatchFilter, vars.defaultAnyFilter );
1882
							// clear search filtered flag because default filters are not saved to the last search
1883
							searchFiltered = false;
1884
						}
1885
						// make iAnyMatchFilter lowercase unless both filter widget & core ignoreCase options are true
1886
						// when c.ignoreCase is true, the cache contains all lower case data
1887
						data.iAnyMatchFilter = !( wo.filter_ignoreCase && c.ignoreCase ) ?
1888
							data.anyMatchFilter :
1889
							data.anyMatchFilter.toLowerCase();
1890
					}
1891
 
1892
					// loop through the rows
1893
					for ( rowIndex = 0; rowIndex < len; rowIndex++ ) {
1894
 
1895
						txt = $rows[ rowIndex ].className;
1896
						// the first row can never be a child row
1897
						isChild = rowIndex && tsfRegex.child.test( txt );
1898
						// skip child rows & already filtered rows
1899
						if ( isChild || ( searchFiltered && tsfRegex.filtered.test( txt ) ) ) {
1900
							continue;
1901
						}
1902
 
1903
						data.$row = $rows.eq( rowIndex );
1904
						data.rowIndex = rowIndex;
1905
						data.cacheArray = norm_rows[ rowIndex ];
1906
						rowData = data.cacheArray[ c.columns ];
1907
						data.rawArray = rowData.raw;
1908
						data.childRowText = '';
1909
 
1910
						if ( !wo.filter_childByColumn ) {
1911
							txt = '';
1912
							// child row cached text
1913
							childRow = rowData.child;
1914
							// so, if 'table.config.widgetOptions.filter_childRows' is true and there is
1915
							// a match anywhere in the child row, then it will make the row visible
1916
							// checked here so the option can be changed dynamically
1917
							for ( indx = 0; indx < childRow.length; indx++ ) {
1918
								txt += ' ' + childRow[indx].join( ' ' ) || '';
1919
							}
1920
							data.childRowText = wo.filter_childRows ?
1921
								( wo.filter_ignoreCase ? txt.toLowerCase() : txt ) :
1922
								'';
1923
						}
1924
 
1925
						showRow = false;
1926
						showParent = tsf.processRow( c, data, vars );
1927
						$row = rowData.$row;
1928
 
1929
						// don't pass reference to val
1930
						val = showParent ? true : false;
1931
						childRow = rowData.$row.filter( ':gt(0)' );
1932
						if ( wo.filter_childRows && childRow.length ) {
1933
							if ( wo.filter_childByColumn ) {
1934
								if ( !wo.filter_childWithSibs ) {
1935
									// hide all child rows
1936
									childRow.addClass( wo.filter_filteredRow );
1937
									// if only showing resulting child row, only include parent
1938
									$row = $row.eq( 0 );
1939
								}
1940
								// cycle through each child row
1941
								for ( indx = 0; indx < childRow.length; indx++ ) {
1942
									data.$row = childRow.eq( indx );
1943
									data.cacheArray = rowData.child[ indx ];
1944
									data.rawArray = data.cacheArray;
1945
									val = tsf.processRow( c, data, vars );
1946
									// use OR comparison on child rows
1947
									showRow = showRow || val;
1948
									if ( !wo.filter_childWithSibs && val ) {
1949
										childRow.eq( indx ).removeClass( wo.filter_filteredRow );
1950
									}
1951
								}
1952
							}
1953
							// keep parent row match even if no child matches... see #1020
1954
							showRow = showRow || showParent;
1955
						} else {
1956
							showRow = val;
1957
						}
1958
						$row
1959
							.toggleClass( wo.filter_filteredRow, !showRow )[0]
1960
							.display = showRow ? '' : 'none';
1961
					}
1962
				}
1963
				c.filteredRows += $rows.not( '.' + wo.filter_filteredRow ).length;
1964
				c.totalRows += $rows.length;
1965
				ts.processTbody( table, $tbody, false );
1966
			}
1967
			// lastCombinedFilter is no longer used internally
1968
			c.lastCombinedFilter = storedFilters.join(''); // save last search
1969
			// don't save 'filters' directly since it may have altered ( AnyMatch column searches )
1970
			c.lastSearch = storedFilters;
1971
			c.$table.data( 'lastSearch', storedFilters );
1972
			if ( wo.filter_saveFilters && ts.storage ) {
1973
				ts.storage( table, 'tablesorter-filters', tsf.processFilters( storedFilters, true ) );
1974
			}
1975
			if ( debug ) {
1976
				console.log( 'Filter >> Completed search' + ts.benchmark(time) );
1977
			}
1978
			if ( wo.filter_initialized ) {
1979
				c.$table.triggerHandler( 'filterBeforeEnd', c );
1980
				c.$table.triggerHandler( 'filterEnd', c );
1981
			}
1982
			setTimeout( function() {
1983
				ts.applyWidget( c.table ); // make sure zebra widget is applied
1984
			}, 0 );
1985
		},
1986
		getOptionSource: function( table, column, onlyAvail ) {
1987
			table = $( table )[0];
1988
			var c = table.config,
1989
				wo = c.widgetOptions,
1990
				arry = false,
1991
				source = wo.filter_selectSource,
1992
				last = c.$table.data( 'lastSearch' ) || [],
1993
				fxn = typeof source === 'function' ? true : ts.getColumnData( table, source, column );
1994
 
1995
			if ( onlyAvail && last[column] !== '' ) {
1996
				onlyAvail = false;
1997
			}
1998
 
1999
			// filter select source option
2000
			if ( fxn === true ) {
2001
				// OVERALL source
2002
				arry = source( table, column, onlyAvail );
2003
			} else if ( fxn instanceof $ || ( $.type( fxn ) === 'string' && fxn.indexOf( '</option>' ) >= 0 ) ) {
2004
				// selectSource is a jQuery object or string of options
2005
				return fxn;
2006
			} else if ( $.isArray( fxn ) ) {
2007
				arry = fxn;
2008
			} else if ( $.type( source ) === 'object' && fxn ) {
2009
				// custom select source function for a SPECIFIC COLUMN
2010
				arry = fxn( table, column, onlyAvail );
2011
				// abort - updating the selects from an external method
2012
				if (arry === null) {
2013
					return null;
2014
				}
2015
			}
2016
			if ( arry === false ) {
2017
				// fall back to original method
2018
				arry = tsf.getOptions( table, column, onlyAvail );
2019
			}
2020
 
2021
			return tsf.processOptions( table, column, arry );
2022
 
2023
		},
2024
		processOptions: function( table, column, arry ) {
2025
			if ( !$.isArray( arry ) ) {
2026
				return false;
2027
			}
2028
			table = $( table )[0];
2029
			var cts, txt, indx, len, parsedTxt, str,
2030
				c = table.config,
2031
				validColumn = typeof column !== 'undefined' && column !== null && column >= 0 && column < c.columns,
2032
				direction = validColumn ? c.$headerIndexed[ column ].hasClass( 'filter-select-sort-desc' ) : false,
2033
				parsed = [];
2034
			// get unique elements and sort the list
2035
			// if $.tablesorter.sortText exists ( not in the original tablesorter ),
2036
			// then natural sort the list otherwise use a basic sort
2037
			arry = $.grep( arry, function( value, indx ) {
2038
				if ( value.text ) {
2039
					return true;
2040
				}
2041
				return $.inArray( value, arry ) === indx;
2042
			});
2043
			if ( validColumn && c.$headerIndexed[ column ].hasClass( 'filter-select-nosort' ) ) {
2044
				// unsorted select options
2045
				return arry;
2046
			} else {
2047
				len = arry.length;
2048
				// parse select option values
2049
				for ( indx = 0; indx < len; indx++ ) {
2050
					txt = arry[ indx ];
2051
					// check for object
2052
					str = txt.text ? txt.text : txt;
2053
					// sortNatural breaks if you don't pass it strings
2054
					parsedTxt = ( validColumn && c.parsers && c.parsers.length &&
2055
						c.parsers[ column ].format( str, table, [], column ) || str ).toString();
2056
					parsedTxt = c.widgetOptions.filter_ignoreCase ? parsedTxt.toLowerCase() : parsedTxt;
2057
					// parse array data using set column parser; this DOES NOT pass the original
2058
					// table cell to the parser format function
2059
					if ( txt.text ) {
2060
						txt.parsed = parsedTxt;
2061
						parsed[ parsed.length ] = txt;
2062
					} else {
2063
						parsed[ parsed.length ] = {
2064
							text : txt,
2065
							// check parser length - fixes #934
2066
							parsed : parsedTxt
2067
						};
2068
					}
2069
				}
2070
				// sort parsed select options
2071
				cts = c.textSorter || '';
2072
				parsed.sort( function( a, b ) {
2073
					var x = direction ? b.parsed : a.parsed,
2074
						y = direction ? a.parsed : b.parsed;
2075
					if ( validColumn && typeof cts === 'function' ) {
2076
						// custom OVERALL text sorter
2077
						return cts( x, y, true, column, table );
2078
					} else if ( validColumn && typeof cts === 'object' && cts.hasOwnProperty( column ) ) {
2079
						// custom text sorter for a SPECIFIC COLUMN
2080
						return cts[column]( x, y, true, column, table );
2081
					} else if ( ts.sortNatural ) {
2082
						// fall back to natural sort
2083
						return ts.sortNatural( x, y );
2084
					}
2085
					// using an older version! do a basic sort
2086
					return true;
2087
				});
2088
				// rebuild arry from sorted parsed data
2089
				arry = [];
2090
				len = parsed.length;
2091
				for ( indx = 0; indx < len; indx++ ) {
2092
					arry[ arry.length ] = parsed[indx];
2093
				}
2094
				return arry;
2095
			}
2096
		},
2097
		getOptions: function( table, column, onlyAvail ) {
2098
			table = $( table )[0];
2099
			var rowIndex, tbodyIndex, len, row, cache, indx, child, childLen,
2100
				c = table.config,
2101
				wo = c.widgetOptions,
2102
				arry = [];
2103
			for ( tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++ ) {
2104
				cache = c.cache[tbodyIndex];
2105
				len = c.cache[tbodyIndex].normalized.length;
2106
				// loop through the rows
2107
				for ( rowIndex = 0; rowIndex < len; rowIndex++ ) {
2108
					// get cached row from cache.row ( old ) or row data object
2109
					// ( new; last item in normalized array )
2110
					row = cache.row ?
2111
						cache.row[ rowIndex ] :
2112
						cache.normalized[ rowIndex ][ c.columns ].$row[0];
2113
					// check if has class filtered
2114
					if ( onlyAvail && row.className.match( wo.filter_filteredRow ) ) {
2115
						continue;
2116
					}
2117
					// get non-normalized cell content
2118
					if ( wo.filter_useParsedData ||
2119
						c.parsers[column].parsed ||
2120
						c.$headerIndexed[column].hasClass( 'filter-parsed' ) ) {
2121
						arry[ arry.length ] = '' + cache.normalized[ rowIndex ][ column ];
2122
						// child row parsed data
2123
						if ( wo.filter_childRows && wo.filter_childByColumn ) {
2124
							childLen = cache.normalized[ rowIndex ][ c.columns ].$row.length - 1;
2125
							for ( indx = 0; indx < childLen; indx++ ) {
2126
								arry[ arry.length ] = '' + cache.normalized[ rowIndex ][ c.columns ].child[ indx ][ column ];
2127
							}
2128
						}
2129
					} else {
2130
						// get raw cached data instead of content directly from the cells
2131
						arry[ arry.length ] = cache.normalized[ rowIndex ][ c.columns ].raw[ column ];
2132
						// child row unparsed data
2133
						if ( wo.filter_childRows && wo.filter_childByColumn ) {
2134
							childLen = cache.normalized[ rowIndex ][ c.columns ].$row.length;
2135
							for ( indx = 1; indx < childLen; indx++ ) {
2136
								child =  cache.normalized[ rowIndex ][ c.columns ].$row.eq( indx ).children().eq( column );
2137
								arry[ arry.length ] = '' + ts.getElementText( c, child, column );
2138
							}
2139
						}
2140
					}
2141
				}
2142
			}
2143
			return arry;
2144
		},
2145
		buildSelect: function( table, column, arry, updating, onlyAvail ) {
2146
			table = $( table )[0];
2147
			column = parseInt( column, 10 );
2148
			if ( !table.config.cache || $.isEmptyObject( table.config.cache ) ) {
2149
				return;
2150
			}
2151
 
2152
			var indx, val, txt, t, $filters, $filter, option,
2153
				c = table.config,
2154
				wo = c.widgetOptions,
2155
				node = c.$headerIndexed[ column ],
2156
				// t.data( 'placeholder' ) won't work in jQuery older than 1.4.3
2157
				options = '<option value="">' +
2158
					( node.data( 'placeholder' ) ||
2159
						node.attr( 'data-placeholder' ) ||
2160
						wo.filter_placeholder.select || ''
2161
					) + '</option>',
2162
				// Get curent filter value
2163
				currentValue = c.$table
2164
					.find( 'thead' )
2165
					.find( 'select.' + tscss.filter + '[data-column="' + column + '"]' )
2166
					.val();
2167
 
2168
			// nothing included in arry ( external source ), so get the options from
2169
			// filter_selectSource or column data
2170
			if ( typeof arry === 'undefined' || arry === '' ) {
2171
				arry = tsf.getOptionSource( table, column, onlyAvail );
2172
				// abort, selects are updated by an external method
2173
				if (arry === null) {
2174
					return;
2175
				}
2176
			}
2177
 
2178
			if ( $.isArray( arry ) ) {
2179
				// build option list
2180
				for ( indx = 0; indx < arry.length; indx++ ) {
2181
					option = arry[ indx ];
2182
					if ( option.text ) {
2183
						// OBJECT!! add data-function-name in case the value is set in filter_functions
2184
						option['data-function-name'] = typeof option.value === 'undefined' ? option.text : option.value;
2185
 
2186
						// support jQuery < v1.8, otherwise the below code could be shortened to
2187
						// options += $( '<option>', option )[ 0 ].outerHTML;
2188
						options += '<option';
2189
						for ( val in option ) {
2190
							if ( option.hasOwnProperty( val ) && val !== 'text' ) {
2191
								options += ' ' + val + '="' + option[ val ].replace( tsfRegex.quote, '&quot;' ) + '"';
2192
							}
2193
						}
2194
						if ( !option.value ) {
2195
							options += ' value="' + option.text.replace( tsfRegex.quote, '&quot;' ) + '"';
2196
						}
2197
						options += '>' + option.text.replace( tsfRegex.quote, '&quot;' ) + '</option>';
2198
						// above code is needed in jQuery < v1.8
2199
 
2200
						// make sure we don't turn an object into a string (objects without a "text" property)
2201
					} else if ( '' + option !== '[object Object]' ) {
2202
						txt = option = ( '' + option ).replace( tsfRegex.quote, '&quot;' );
2203
						val = txt;
2204
						// allow including a symbol in the selectSource array
2205
						// 'a-z|A through Z' so that 'a-z' becomes the option value
2206
						// and 'A through Z' becomes the option text
2207
						if ( txt.indexOf( wo.filter_selectSourceSeparator ) >= 0 ) {
2208
							t = txt.split( wo.filter_selectSourceSeparator );
2209
							val = t[0];
2210
							txt = t[1];
2211
						}
2212
						// replace quotes - fixes #242 & ignore empty strings
2213
						// see http://stackoverflow.com/q/14990971/145346
2214
						options += option !== '' ?
2215
							'<option ' +
2216
								( val === txt ? '' : 'data-function-name="' + option + '" ' ) +
2217
								'value="' + val + '">' + txt +
2218
							'</option>' : '';
2219
					}
2220
				}
2221
				// clear arry so it doesn't get appended twice
2222
				arry = [];
2223
			}
2224
 
2225
			// update all selects in the same column ( clone thead in sticky headers &
2226
			// any external selects ) - fixes 473
2227
			$filters = ( c.$filters ? c.$filters : c.$table.children( 'thead' ) )
2228
				.find( '.' + tscss.filter );
2229
			if ( wo.filter_$externalFilters ) {
2230
				$filters = $filters && $filters.length ?
2231
					$filters.add( wo.filter_$externalFilters ) :
2232
					wo.filter_$externalFilters;
2233
			}
2234
			$filter = $filters.filter( 'select[data-column="' + column + '"]' );
2235
 
2236
			// make sure there is a select there!
2237
			if ( $filter.length ) {
2238
				$filter[ updating ? 'html' : 'append' ]( options );
2239
				if ( !$.isArray( arry ) ) {
2240
					// append options if arry is provided externally as a string or jQuery object
2241
					// options ( default value ) was already added
2242
					$filter.append( arry ).val( currentValue );
2243
				}
2244
				$filter.val( currentValue );
2245
			}
2246
		},
2247
		buildDefault: function( table, updating ) {
2248
			var columnIndex, $header, noSelect,
2249
				c = table.config,
2250
				wo = c.widgetOptions,
2251
				columns = c.columns;
2252
			// build default select dropdown
2253
			for ( columnIndex = 0; columnIndex < columns; columnIndex++ ) {
2254
				$header = c.$headerIndexed[columnIndex];
2255
				noSelect = !( $header.hasClass( 'filter-false' ) || $header.hasClass( 'parser-false' ) );
2256
				// look for the filter-select class; build/update it if found
2257
				if ( ( $header.hasClass( 'filter-select' ) ||
2258
					ts.getColumnData( table, wo.filter_functions, columnIndex ) === true ) && noSelect ) {
2259
					tsf.buildSelect( table, columnIndex, '', updating, $header.hasClass( wo.filter_onlyAvail ) );
2260
				}
2261
			}
2262
		}
2263
	};
2264
 
2265
	// filter regex variable
2266
	tsfRegex = tsf.regex;
2267
 
2268
	ts.getFilters = function( table, getRaw, setFilters, skipFirst ) {
2269
		var i, $filters, $column, cols,
2270
			filters = [],
2271
			c = table ? $( table )[0].config : '',
2272
			wo = c ? c.widgetOptions : '';
2273
		if ( ( getRaw !== true && wo && !wo.filter_columnFilters ) ||
2274
			// setFilters called, but last search is exactly the same as the current
2275
			// fixes issue #733 & #903 where calling update causes the input values to reset
2276
			( $.isArray(setFilters) && tsf.equalFilters(c, setFilters, c.lastSearch) )
2277
		) {
2278
			return $( table ).data( 'lastSearch' ) || [];
2279
		}
2280
		if ( c ) {
2281
			if ( c.$filters ) {
2282
				$filters = c.$filters.find( '.' + tscss.filter );
2283
			}
2284
			if ( wo.filter_$externalFilters ) {
2285
				$filters = $filters && $filters.length ?
2286
					$filters.add( wo.filter_$externalFilters ) :
2287
					wo.filter_$externalFilters;
2288
			}
2289
			if ( $filters && $filters.length ) {
2290
				filters = setFilters || [];
2291
				for ( i = 0; i < c.columns + 1; i++ ) {
2292
					cols = ( i === c.columns ?
2293
						// 'all' columns can now include a range or set of columms ( data-column='0-2,4,6-7' )
2294
						wo.filter_anyColumnSelector + ',' + wo.filter_multipleColumnSelector :
2295
						'[data-column="' + i + '"]' );
2296
					$column = $filters.filter( cols );
2297
					if ( $column.length ) {
2298
						// move the latest search to the first slot in the array
2299
						$column = tsf.getLatestSearch( $column );
2300
						if ( $.isArray( setFilters ) ) {
2301
							// skip first ( latest input ) to maintain cursor position while typing
2302
							if ( skipFirst && $column.length > 1 ) {
2303
								$column = $column.slice( 1 );
2304
							}
2305
							if ( i === c.columns ) {
2306
								// prevent data-column='all' from filling data-column='0,1' ( etc )
2307
								cols = $column.filter( wo.filter_anyColumnSelector );
2308
								$column = cols.length ? cols : $column;
2309
							}
2310
							$column
2311
								.val( setFilters[ i ] )
2312
								// must include a namespace here; but not c.namespace + 'filter'?
2313
								.trigger( 'change' + c.namespace );
2314
						} else {
2315
							filters[i] = $column.val() || '';
2316
							// don't change the first... it will move the cursor
2317
							if ( i === c.columns ) {
2318
								// don't update range columns from 'all' setting
2319
								$column
2320
									.slice( 1 )
2321
									.filter( '[data-column*="' + $column.attr( 'data-column' ) + '"]' )
2322
									.val( filters[ i ] );
2323
							} else {
2324
								$column
2325
									.slice( 1 )
2326
									.val( filters[ i ] );
2327
							}
2328
						}
2329
						// save any match input dynamically
2330
						if ( i === c.columns && $column.length ) {
2331
							wo.filter_$anyMatch = $column;
2332
						}
2333
					}
2334
				}
2335
			}
2336
		}
2337
		return filters;
2338
	};
2339
 
2340
	ts.setFilters = function( table, filter, apply, skipFirst ) {
2341
		var c = table ? $( table )[0].config : '',
2342
			valid = ts.getFilters( table, true, filter, skipFirst );
2343
		// default apply to "true"
2344
		if ( typeof apply === 'undefined' ) {
2345
			apply = true;
2346
		}
2347
		if ( c && apply ) {
2348
			// ensure new set filters are applied, even if the search is the same
2349
			c.lastCombinedFilter = null;
2350
			c.lastSearch = [];
2351
			tsf.searching( c.table, filter, skipFirst );
2352
			c.$table.triggerHandler( 'filterFomatterUpdate' );
2353
		}
2354
		return valid.length !== 0;
2355
	};
2356
 
2357
})( jQuery );
2358
 
2359
/*! Widget: stickyHeaders - updated 9/27/2017 (v2.29.0) *//*
2360
 * Requires tablesorter v2.8+ and jQuery 1.4.3+
2361
 * by Rob Garrison
2362
 */
2363
;(function ($, window) {
2364
	'use strict';
2365
	var ts = $.tablesorter || {};
2366
 
2367
	$.extend(ts.css, {
2368
		sticky    : 'tablesorter-stickyHeader', // stickyHeader
2369
		stickyVis : 'tablesorter-sticky-visible',
2370
		stickyHide: 'tablesorter-sticky-hidden',
2371
		stickyWrap: 'tablesorter-sticky-wrapper'
2372
	});
2373
 
2374
	// Add a resize event to table headers
2375
	ts.addHeaderResizeEvent = function(table, disable, settings) {
2376
		table = $(table)[0]; // make sure we're using a dom element
2377
		if ( !table.config ) { return; }
2378
		var defaults = {
2379
				timer : 250
2380
			},
2381
			options = $.extend({}, defaults, settings),
2382
			c = table.config,
2383
			wo = c.widgetOptions,
2384
			checkSizes = function( triggerEvent ) {
2385
				var index, headers, $header, sizes, width, height,
2386
					len = c.$headers.length;
2387
				wo.resize_flag = true;
2388
				headers = [];
2389
				for ( index = 0; index < len; index++ ) {
2390
					$header = c.$headers.eq( index );
2391
					sizes = $header.data( 'savedSizes' ) || [ 0, 0 ]; // fixes #394
2392
					width = $header[0].offsetWidth;
2393
					height = $header[0].offsetHeight;
2394
					if ( width !== sizes[0] || height !== sizes[1] ) {
2395
						$header.data( 'savedSizes', [ width, height ] );
2396
						headers.push( $header[0] );
2397
					}
2398
				}
2399
				if ( headers.length && triggerEvent !== false ) {
2400
					c.$table.triggerHandler( 'resize', [ headers ] );
2401
				}
2402
				wo.resize_flag = false;
2403
			};
2404
		clearInterval(wo.resize_timer);
2405
		if (disable) {
2406
			wo.resize_flag = false;
2407
			return false;
2408
		}
2409
		checkSizes( false );
2410
		wo.resize_timer = setInterval(function() {
2411
			if (wo.resize_flag) { return; }
2412
			checkSizes();
2413
		}, options.timer);
2414
	};
2415
 
2416
	function getStickyOffset(c, wo) {
2417
		var $el = isNaN(wo.stickyHeaders_offset) ? $(wo.stickyHeaders_offset) : [];
2418
		return $el.length ?
2419
			$el.height() || 0 :
2420
			parseInt(wo.stickyHeaders_offset, 10) || 0;
2421
	}
2422
 
2423
	// Sticky headers based on this awesome article:
2424
	// http://css-tricks.com/13465-persistent-headers/
2425
	// and https://github.com/jmosbech/StickyTableHeaders by Jonas Mosbech
2426
	// **************************
2427
	ts.addWidget({
2428
		id: 'stickyHeaders',
2429
		priority: 54, // sticky widget must be initialized after the filter & before pager widget!
2430
		options: {
2431
			stickyHeaders : '',       // extra class name added to the sticky header row
2432
			stickyHeaders_appendTo : null, // jQuery selector or object to phycially attach the sticky headers
2433
			stickyHeaders_attachTo : null, // jQuery selector or object to attach scroll listener to (overridden by xScroll & yScroll settings)
2434
			stickyHeaders_xScroll : null, // jQuery selector or object to monitor horizontal scroll position (defaults: xScroll > attachTo > window)
2435
			stickyHeaders_yScroll : null, // jQuery selector or object to monitor vertical scroll position (defaults: yScroll > attachTo > window)
2436
			stickyHeaders_offset : 0, // number or jquery selector targeting the position:fixed element
2437
			stickyHeaders_filteredToTop: true, // scroll table top into view after filtering
2438
			stickyHeaders_cloneId : '-sticky', // added to table ID, if it exists
2439
			stickyHeaders_addResizeEvent : true, // trigger 'resize' event on headers
2440
			stickyHeaders_includeCaption : true, // if false and a caption exist, it won't be included in the sticky header
2441
			stickyHeaders_zIndex : 2 // The zIndex of the stickyHeaders, allows the user to adjust this to their needs
2442
		},
2443
		format: function(table, c, wo) {
2444
			// filter widget doesn't initialize on an empty table. Fixes #449
2445
			if ( c.$table.hasClass('hasStickyHeaders') || ($.inArray('filter', c.widgets) >= 0 && !c.$table.hasClass('hasFilters')) ) {
2446
				return;
2447
			}
2448
			var index, len, $t,
2449
				$table = c.$table,
2450
				// add position: relative to attach element, hopefully it won't cause trouble.
2451
				$attach = $(wo.stickyHeaders_attachTo || wo.stickyHeaders_appendTo),
2452
				namespace = c.namespace + 'stickyheaders ',
2453
				// element to watch for the scroll event
2454
				$yScroll = $(wo.stickyHeaders_yScroll || wo.stickyHeaders_attachTo || window),
2455
				$xScroll = $(wo.stickyHeaders_xScroll || wo.stickyHeaders_attachTo || window),
2456
				$thead = $table.children('thead:first'),
2457
				$header = $thead.children('tr').not('.sticky-false').children(),
2458
				$tfoot = $table.children('tfoot'),
2459
				stickyOffset = getStickyOffset(c, wo),
2460
				// is this table nested? If so, find parent sticky header wrapper (div, not table)
2461
				$nestedSticky = $table.parent().closest('.' + ts.css.table).hasClass('hasStickyHeaders') ?
2462
					$table.parent().closest('table.tablesorter')[0].config.widgetOptions.$sticky.parent() : [],
2463
				nestedStickyTop = $nestedSticky.length ? $nestedSticky.height() : 0,
2464
				// clone table, then wrap to make sticky header
2465
				$stickyTable = wo.$sticky = $table.clone()
2466
					.addClass('containsStickyHeaders ' + ts.css.sticky + ' ' + wo.stickyHeaders + ' ' + c.namespace.slice(1) + '_extra_table' )
2467
					.wrap('<div class="' + ts.css.stickyWrap + '">'),
2468
				$stickyWrap = $stickyTable.parent()
2469
					.addClass(ts.css.stickyHide)
2470
					.css({
2471
						position   : $attach.length ? 'absolute' : 'fixed',
2472
						padding    : parseInt( $stickyTable.parent().parent().css('padding-left'), 10 ),
2473
						top        : stickyOffset + nestedStickyTop,
2474
						left       : 0,
2475
						visibility : 'hidden',
2476
						zIndex     : wo.stickyHeaders_zIndex || 2
2477
					}),
2478
				$stickyThead = $stickyTable.children('thead:first'),
2479
				$stickyCells,
2480
				laststate = '',
2481
				setWidth = function($orig, $clone) {
2482
					var index, width, border, $cell, $this,
2483
						$cells = $orig.filter(':visible'),
2484
						len = $cells.length;
2485
					for ( index = 0; index < len; index++ ) {
2486
						$cell = $clone.filter(':visible').eq(index);
2487
						$this = $cells.eq(index);
2488
						// code from https://github.com/jmosbech/StickyTableHeaders
2489
						if ($this.css('box-sizing') === 'border-box') {
2490
							width = $this.outerWidth();
2491
						} else {
2492
							if ($cell.css('border-collapse') === 'collapse') {
2493
								if (window.getComputedStyle) {
2494
									width = parseFloat( window.getComputedStyle($this[0], null).width );
2495
								} else {
2496
									// ie8 only
2497
									border = parseFloat( $this.css('border-width') );
2498
									width = $this.outerWidth() - parseFloat( $this.css('padding-left') ) - parseFloat( $this.css('padding-right') ) - border;
2499
								}
2500
							} else {
2501
								width = $this.width();
2502
							}
2503
						}
2504
						$cell.css({
2505
							'width': width,
2506
							'min-width': width,
2507
							'max-width': width
2508
						});
2509
					}
2510
				},
2511
				getLeftPosition = function(yWindow) {
2512
					if (yWindow === false && $nestedSticky.length) {
2513
						return $table.position().left;
2514
					}
2515
					return $attach.length ?
2516
						parseInt($attach.css('padding-left'), 10) || 0 :
2517
						$table.offset().left - parseInt($table.css('margin-left'), 10) - $(window).scrollLeft();
2518
				},
2519
				resizeHeader = function() {
2520
					$stickyWrap.css({
2521
						left : getLeftPosition(),
2522
						width: $table.outerWidth()
2523
					});
2524
					setWidth( $table, $stickyTable );
2525
					setWidth( $header, $stickyCells );
2526
				},
2527
				scrollSticky = function( resizing ) {
2528
					if (!$table.is(':visible')) { return; } // fixes #278
2529
					// Detect nested tables - fixes #724
2530
					nestedStickyTop = $nestedSticky.length ? $nestedSticky.offset().top - $yScroll.scrollTop() + $nestedSticky.height() : 0;
2531
					var tmp,
2532
						offset = $table.offset(),
2533
						stickyOffset = getStickyOffset(c, wo),
2534
						yWindow = $.isWindow( $yScroll[0] ), // $.isWindow needs jQuery 1.4.3
2535
						yScroll = yWindow ?
2536
							$yScroll.scrollTop() :
2537
							// use parent sticky position if nested AND inside of a scrollable element - see #1512
2538
							$nestedSticky.length ? parseInt($nestedSticky[0].style.top, 10) : $yScroll.offset().top,
2539
						attachTop = $attach.length ? yScroll : $yScroll.scrollTop(),
2540
						captionHeight = wo.stickyHeaders_includeCaption ? 0 : $table.children( 'caption' ).height() || 0,
2541
						scrollTop = attachTop + stickyOffset + nestedStickyTop - captionHeight,
2542
						tableHeight = $table.height() - ($stickyWrap.height() + ($tfoot.height() || 0)) - captionHeight,
2543
						isVisible = ( scrollTop > offset.top ) && ( scrollTop < offset.top + tableHeight ) ? 'visible' : 'hidden',
2544
						state = isVisible === 'visible' ? ts.css.stickyVis : ts.css.stickyHide,
2545
						needsUpdating = !$stickyWrap.hasClass( state ),
2546
						cssSettings = { visibility : isVisible };
2547
					if ($attach.length) {
2548
						// attached sticky headers always need updating
2549
						needsUpdating = true;
2550
						cssSettings.top = yWindow ? scrollTop - $attach.offset().top : $attach.scrollTop();
2551
					}
2552
					// adjust when scrolling horizontally - fixes issue #143
2553
					tmp = getLeftPosition(yWindow);
2554
					if (tmp !== parseInt($stickyWrap.css('left'), 10)) {
2555
						needsUpdating = true;
2556
						cssSettings.left = tmp;
2557
					}
2558
					cssSettings.top = ( cssSettings.top || 0 ) +
2559
						// If nested AND inside of a scrollable element, only add parent sticky height
2560
						(!yWindow && $nestedSticky.length ? $nestedSticky.height() : stickyOffset + nestedStickyTop);
2561
					if (needsUpdating) {
2562
						$stickyWrap
2563
							.removeClass( ts.css.stickyVis + ' ' + ts.css.stickyHide )
2564
							.addClass( state )
2565
							.css(cssSettings);
2566
					}
2567
					if (isVisible !== laststate || resizing) {
2568
						// make sure the column widths match
2569
						resizeHeader();
2570
						laststate = isVisible;
2571
					}
2572
				};
2573
			// only add a position relative if a position isn't already defined
2574
			if ($attach.length && !$attach.css('position')) {
2575
				$attach.css('position', 'relative');
2576
			}
2577
			// fix clone ID, if it exists - fixes #271
2578
			if ($stickyTable.attr('id')) { $stickyTable[0].id += wo.stickyHeaders_cloneId; }
2579
			// clear out cloned table, except for sticky header
2580
			// include caption & filter row (fixes #126 & #249) - don't remove cells to get correct cell indexing
2581
			$stickyTable.find('> thead:gt(0), tr.sticky-false').hide();
2582
			$stickyTable.find('> tbody, > tfoot').remove();
2583
			$stickyTable.find('caption').toggle(wo.stickyHeaders_includeCaption);
2584
			// issue #172 - find td/th in sticky header
2585
			$stickyCells = $stickyThead.children().children();
2586
			$stickyTable.css({ height:0, width:0, margin: 0 });
2587
			// remove resizable block
2588
			$stickyCells.find('.' + ts.css.resizer).remove();
2589
			// update sticky header class names to match real header after sorting
2590
			$table
2591
				.addClass('hasStickyHeaders')
2592
				.bind('pagerComplete' + namespace, function() {
2593
					resizeHeader();
2594
				});
2595
 
2596
			ts.bindEvents(table, $stickyThead.children().children('.' + ts.css.header));
2597
 
2598
			if (wo.stickyHeaders_appendTo) {
2599
				$(wo.stickyHeaders_appendTo).append( $stickyWrap );
2600
			} else {
2601
				// add stickyheaders AFTER the table. If the table is selected by ID, the original one (first) will be returned.
2602
				$table.after( $stickyWrap );
2603
			}
2604
 
2605
			// onRenderHeader is defined, we need to do something about it (fixes #641)
2606
			if (c.onRenderHeader) {
2607
				$t = $stickyThead.children('tr').children();
2608
				len = $t.length;
2609
				for ( index = 0; index < len; index++ ) {
2610
					// send second parameter
2611
					c.onRenderHeader.apply( $t.eq( index ), [ index, c, $stickyTable ] );
2612
				}
2613
			}
2614
			// make it sticky!
2615
			$xScroll.add($yScroll)
2616
				.unbind( ('scroll resize '.split(' ').join( namespace )).replace(/\s+/g, ' ') )
2617
				.bind('scroll resize '.split(' ').join( namespace ), function( event ) {
2618
					scrollSticky( event.type === 'resize' );
2619
				});
2620
			c.$table
2621
				.unbind('stickyHeadersUpdate' + namespace)
2622
				.bind('stickyHeadersUpdate' + namespace, function() {
2623
					scrollSticky( true );
2624
				});
2625
 
2626
			if (wo.stickyHeaders_addResizeEvent) {
2627
				ts.addHeaderResizeEvent(table);
2628
			}
2629
 
2630
			// look for filter widget
2631
			if ($table.hasClass('hasFilters') && wo.filter_columnFilters) {
2632
				// scroll table into view after filtering, if sticky header is active - #482
2633
				$table.bind('filterEnd' + namespace, function() {
2634
					// $(':focus') needs jQuery 1.6+
2635
					var $td = $(document.activeElement).closest('td'),
2636
						column = $td.parent().children().index($td);
2637
					// only scroll if sticky header is active
2638
					if ($stickyWrap.hasClass(ts.css.stickyVis) && wo.stickyHeaders_filteredToTop) {
2639
						// scroll to original table (not sticky clone)
2640
						window.scrollTo(0, $table.position().top);
2641
						// give same input/select focus; check if c.$filters exists; fixes #594
2642
						if (column >= 0 && c.$filters) {
2643
							c.$filters.eq(column).find('a, select, input').filter(':visible').focus();
2644
						}
2645
					}
2646
				});
2647
				ts.filter.bindSearch( $table, $stickyCells.find('.' + ts.css.filter) );
2648
				// support hideFilters
2649
				if (wo.filter_hideFilters) {
2650
					ts.filter.hideFilters(c, $stickyTable);
2651
				}
2652
			}
2653
 
2654
			// resize table (Firefox)
2655
			if (wo.stickyHeaders_addResizeEvent) {
2656
				$table.bind('resize' + c.namespace + 'stickyheaders', function() {
2657
					resizeHeader();
2658
				});
2659
			}
2660
 
2661
			// make sure sticky is visible if page is partially scrolled
2662
			scrollSticky( true );
2663
			$table.triggerHandler('stickyHeadersInit');
2664
 
2665
		},
2666
		remove: function(table, c, wo) {
2667
			var namespace = c.namespace + 'stickyheaders ';
2668
			c.$table
2669
				.removeClass('hasStickyHeaders')
2670
				.unbind( ('pagerComplete resize filterEnd stickyHeadersUpdate '.split(' ').join(namespace)).replace(/\s+/g, ' ') )
2671
				.next('.' + ts.css.stickyWrap).remove();
2672
			if (wo.$sticky && wo.$sticky.length) { wo.$sticky.remove(); } // remove cloned table
2673
			$(window)
2674
				.add(wo.stickyHeaders_xScroll)
2675
				.add(wo.stickyHeaders_yScroll)
2676
				.add(wo.stickyHeaders_attachTo)
2677
				.unbind( ('scroll resize '.split(' ').join(namespace)).replace(/\s+/g, ' ') );
2678
			ts.addHeaderResizeEvent(table, true);
2679
		}
2680
	});
2681
 
2682
})(jQuery, window);
2683
 
2684
/*! Widget: resizable - updated 2018-03-26 (v2.30.2) */
2685
/*jshint browser:true, jquery:true, unused:false */
2686
;(function ($, window) {
2687
	'use strict';
2688
	var ts = $.tablesorter || {};
2689
 
2690
	$.extend(ts.css, {
2691
		resizableContainer : 'tablesorter-resizable-container',
2692
		resizableHandle    : 'tablesorter-resizable-handle',
2693
		resizableNoSelect  : 'tablesorter-disableSelection',
2694
		resizableStorage   : 'tablesorter-resizable'
2695
	});
2696
 
2697
	// Add extra scroller css
2698
	$(function() {
2699
		var s = '<style>' +
2700
			'body.' + ts.css.resizableNoSelect + ' { -ms-user-select: none; -moz-user-select: -moz-none;' +
2701
				'-khtml-user-select: none; -webkit-user-select: none; user-select: none; }' +
2702
			'.' + ts.css.resizableContainer + ' { position: relative; height: 1px; }' +
2703
			// make handle z-index > than stickyHeader z-index, so the handle stays above sticky header
2704
			'.' + ts.css.resizableHandle + ' { position: absolute; display: inline-block; width: 8px;' +
2705
				'top: 1px; cursor: ew-resize; z-index: 3; user-select: none; -moz-user-select: none; }' +
2706
			'</style>';
2707
		$('head').append(s);
2708
	});
2709
 
2710
	ts.resizable = {
2711
		init : function( c, wo ) {
2712
			if ( c.$table.hasClass( 'hasResizable' ) ) { return; }
2713
			c.$table.addClass( 'hasResizable' );
2714
 
2715
			var noResize, $header, column, storedSizes, tmp,
2716
				$table = c.$table,
2717
				$parent = $table.parent(),
2718
				marginTop = parseInt( $table.css( 'margin-top' ), 10 ),
2719
 
2720
			// internal variables
2721
			vars = wo.resizable_vars = {
2722
				useStorage : ts.storage && wo.resizable !== false,
2723
				$wrap : $parent,
2724
				mouseXPosition : 0,
2725
				$target : null,
2726
				$next : null,
2727
				overflow : $parent.css('overflow') === 'auto' ||
2728
					$parent.css('overflow') === 'scroll' ||
2729
					$parent.css('overflow-x') === 'auto' ||
2730
					$parent.css('overflow-x') === 'scroll',
2731
				storedSizes : []
2732
			};
2733
 
2734
			// set default widths
2735
			ts.resizableReset( c.table, true );
2736
 
2737
			// now get measurements!
2738
			vars.tableWidth = $table.width();
2739
			// attempt to autodetect
2740
			vars.fullWidth = Math.abs( $parent.width() - vars.tableWidth ) < 20;
2741
 
2742
			/*
2743
			// Hacky method to determine if table width is set to 'auto'
2744
			// http://stackoverflow.com/a/20892048/145346
2745
			if ( !vars.fullWidth ) {
2746
				tmp = $table.width();
2747
				$header = $table.wrap('<span>').parent(); // temp variable
2748
				storedSizes = parseInt( $table.css( 'margin-left' ), 10 ) || 0;
2749
				$table.css( 'margin-left', storedSizes + 50 );
2750
				vars.tableWidth = $header.width() > tmp ? 'auto' : tmp;
2751
				$table.css( 'margin-left', storedSizes ? storedSizes : '' );
2752
				$header = null;
2753
				$table.unwrap('<span>');
2754
			}
2755
			*/
2756
 
2757
			if ( vars.useStorage && vars.overflow ) {
2758
				// save table width
2759
				ts.storage( c.table, 'tablesorter-table-original-css-width', vars.tableWidth );
2760
				tmp = ts.storage( c.table, 'tablesorter-table-resized-width' ) || 'auto';
2761
				ts.resizable.setWidth( $table, tmp, true );
2762
			}
2763
			wo.resizable_vars.storedSizes = storedSizes = ( vars.useStorage ?
2764
				ts.storage( c.table, ts.css.resizableStorage ) :
2765
				[] ) || [];
2766
			ts.resizable.setWidths( c, wo, storedSizes );
2767
			ts.resizable.updateStoredSizes( c, wo );
2768
 
2769
			wo.$resizable_container = $( '<div class="' + ts.css.resizableContainer + '">' )
2770
				.css({ top : marginTop })
2771
				.insertBefore( $table );
2772
			// add container
2773
			for ( column = 0; column < c.columns; column++ ) {
2774
				$header = c.$headerIndexed[ column ];
2775
				tmp = ts.getColumnData( c.table, c.headers, column );
2776
				noResize = ts.getData( $header, tmp, 'resizable' ) === 'false';
2777
				if ( !noResize ) {
2778
					$( '<div class="' + ts.css.resizableHandle + '">' )
2779
						.appendTo( wo.$resizable_container )
2780
						.attr({
2781
							'data-column' : column,
2782
							'unselectable' : 'on'
2783
						})
2784
						.data( 'header', $header )
2785
						.bind( 'selectstart', false );
2786
				}
2787
			}
2788
			ts.resizable.bindings( c, wo );
2789
		},
2790
 
2791
		updateStoredSizes : function( c, wo ) {
2792
			var column, $header,
2793
				len = c.columns,
2794
				vars = wo.resizable_vars;
2795
			vars.storedSizes = [];
2796
			for ( column = 0; column < len; column++ ) {
2797
				$header = c.$headerIndexed[ column ];
2798
				vars.storedSizes[ column ] = $header.is(':visible') ? $header.width() : 0;
2799
			}
2800
		},
2801
 
2802
		setWidth : function( $el, width, overflow ) {
2803
			// overflow tables need min & max width set as well
2804
			$el.css({
2805
				'width' : width,
2806
				'min-width' : overflow ? width : '',
2807
				'max-width' : overflow ? width : ''
2808
			});
2809
		},
2810
 
2811
		setWidths : function( c, wo, storedSizes ) {
2812
			var column, $temp,
2813
				vars = wo.resizable_vars,
2814
				$extra = $( c.namespace + '_extra_headers' ),
2815
				$col = c.$table.children( 'colgroup' ).children( 'col' );
2816
			storedSizes = storedSizes || vars.storedSizes || [];
2817
			// process only if table ID or url match
2818
			if ( storedSizes.length ) {
2819
				for ( column = 0; column < c.columns; column++ ) {
2820
					// set saved resizable widths
2821
					ts.resizable.setWidth( c.$headerIndexed[ column ], storedSizes[ column ], vars.overflow );
2822
					if ( $extra.length ) {
2823
						// stickyHeaders needs to modify min & max width as well
2824
						$temp = $extra.eq( column ).add( $col.eq( column ) );
2825
						ts.resizable.setWidth( $temp, storedSizes[ column ], vars.overflow );
2826
					}
2827
				}
2828
				$temp = $( c.namespace + '_extra_table' );
2829
				if ( $temp.length && !ts.hasWidget( c.table, 'scroller' ) ) {
2830
					ts.resizable.setWidth( $temp, c.$table.outerWidth(), vars.overflow );
2831
				}
2832
			}
2833
		},
2834
 
2835
		setHandlePosition : function( c, wo ) {
2836
			var startPosition,
2837
				tableHeight = c.$table.height(),
2838
				$handles = wo.$resizable_container.children(),
2839
				handleCenter = Math.floor( $handles.width() / 2 );
2840
 
2841
			if ( ts.hasWidget( c.table, 'scroller' ) ) {
2842
				tableHeight = 0;
2843
				c.$table.closest( '.' + ts.css.scrollerWrap ).children().each(function() {
2844
					var $this = $(this);
2845
					// center table has a max-height set
2846
					tableHeight += $this.filter('[style*="height"]').length ? $this.height() : $this.children('table').height();
2847
				});
2848
			}
2849
 
2850
			if ( !wo.resizable_includeFooter && c.$table.children('tfoot').length ) {
2851
				tableHeight -= c.$table.children('tfoot').height();
2852
			}
2853
			// subtract out table left position from resizable handles. Fixes #864
2854
			// jQuery v3.3.0+ appears to include the start position with the $header.position().left; see #1544
2855
			startPosition = parseFloat($.fn.jquery) >= 3.3 ? 0 : c.$table.position().left;
2856
			$handles.each( function() {
2857
				var $this = $(this),
2858
					column = parseInt( $this.attr( 'data-column' ), 10 ),
2859
					columns = c.columns - 1,
2860
					$header = $this.data( 'header' );
2861
				if ( !$header ) { return; } // see #859
2862
				if (
2863
					!$header.is(':visible') ||
2864
					( !wo.resizable_addLastColumn && ts.resizable.checkVisibleColumns(c, column) )
2865
				) {
2866
					$this.hide();
2867
				} else if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
2868
					$this.css({
2869
						display: 'inline-block',
2870
						height : tableHeight,
2871
						left : $header.position().left - startPosition + $header.outerWidth() - handleCenter
2872
					});
2873
				}
2874
			});
2875
		},
2876
 
2877
		// Fixes #1485
2878
		checkVisibleColumns: function( c, column ) {
2879
			var i,
2880
				len = 0;
2881
			for ( i = column + 1; i < c.columns; i++ ) {
2882
				len += c.$headerIndexed[i].is( ':visible' ) ? 1 : 0;
2883
			}
2884
			return len === 0;
2885
		},
2886
 
2887
		// prevent text selection while dragging resize bar
2888
		toggleTextSelection : function( c, wo, toggle ) {
2889
			var namespace = c.namespace + 'tsresize';
2890
			wo.resizable_vars.disabled = toggle;
2891
			$( 'body' ).toggleClass( ts.css.resizableNoSelect, toggle );
2892
			if ( toggle ) {
2893
				$( 'body' )
2894
					.attr( 'unselectable', 'on' )
2895
					.bind( 'selectstart' + namespace, false );
2896
			} else {
2897
				$( 'body' )
2898
					.removeAttr( 'unselectable' )
2899
					.unbind( 'selectstart' + namespace );
2900
			}
2901
		},
2902
 
2903
		bindings : function( c, wo ) {
2904
			var namespace = c.namespace + 'tsresize';
2905
			wo.$resizable_container.children().bind( 'mousedown', function( event ) {
2906
				// save header cell and mouse position
2907
				var column,
2908
					vars = wo.resizable_vars,
2909
					$extras = $( c.namespace + '_extra_headers' ),
2910
					$header = $( event.target ).data( 'header' );
2911
 
2912
				column = parseInt( $header.attr( 'data-column' ), 10 );
2913
				vars.$target = $header = $header.add( $extras.filter('[data-column="' + column + '"]') );
2914
				vars.target = column;
2915
 
2916
				// if table is not as wide as it's parent, then resize the table
2917
				vars.$next = event.shiftKey || wo.resizable_targetLast ?
2918
					$header.parent().children().not( '.resizable-false' ).filter( ':last' ) :
2919
					$header.nextAll( ':not(.resizable-false)' ).eq( 0 );
2920
 
2921
				column = parseInt( vars.$next.attr( 'data-column' ), 10 );
2922
				vars.$next = vars.$next.add( $extras.filter('[data-column="' + column + '"]') );
2923
				vars.next = column;
2924
 
2925
				vars.mouseXPosition = event.pageX;
2926
				ts.resizable.updateStoredSizes( c, wo );
2927
				ts.resizable.toggleTextSelection(c, wo, true );
2928
			});
2929
 
2930
			$( document )
2931
				.bind( 'mousemove' + namespace, function( event ) {
2932
					var vars = wo.resizable_vars;
2933
					// ignore mousemove if no mousedown
2934
					if ( !vars.disabled || vars.mouseXPosition === 0 || !vars.$target ) { return; }
2935
					if ( wo.resizable_throttle ) {
2936
						clearTimeout( vars.timer );
2937
						vars.timer = setTimeout( function() {
2938
							ts.resizable.mouseMove( c, wo, event );
2939
						}, isNaN( wo.resizable_throttle ) ? 5 : wo.resizable_throttle );
2940
					} else {
2941
						ts.resizable.mouseMove( c, wo, event );
2942
					}
2943
				})
2944
				.bind( 'mouseup' + namespace, function() {
2945
					if (!wo.resizable_vars.disabled) { return; }
2946
					ts.resizable.toggleTextSelection( c, wo, false );
2947
					ts.resizable.stopResize( c, wo );
2948
					ts.resizable.setHandlePosition( c, wo );
2949
				});
2950
 
2951
			// resizeEnd event triggered by scroller widget
2952
			$( window ).bind( 'resize' + namespace + ' resizeEnd' + namespace, function() {
2953
				ts.resizable.setHandlePosition( c, wo );
2954
			});
2955
 
2956
			// right click to reset columns to default widths
2957
			c.$table
2958
				.bind( 'columnUpdate pagerComplete resizableUpdate '.split( ' ' ).join( namespace + ' ' ), function() {
2959
					ts.resizable.setHandlePosition( c, wo );
2960
				})
2961
				.bind( 'resizableReset' + namespace, function() {
2962
					ts.resizableReset( c.table );
2963
				})
2964
				.find( 'thead:first' )
2965
				.add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
2966
				.bind( 'contextmenu' + namespace, function() {
2967
					// $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
2968
					var allowClick = wo.resizable_vars.storedSizes.length === 0;
2969
					ts.resizableReset( c.table );
2970
					ts.resizable.setHandlePosition( c, wo );
2971
					wo.resizable_vars.storedSizes = [];
2972
					return allowClick;
2973
				});
2974
 
2975
		},
2976
 
2977
		mouseMove : function( c, wo, event ) {
2978
			if ( wo.resizable_vars.mouseXPosition === 0 || !wo.resizable_vars.$target ) { return; }
2979
			// resize columns
2980
			var column,
2981
				total = 0,
2982
				vars = wo.resizable_vars,
2983
				$next = vars.$next,
2984
				tar = vars.storedSizes[ vars.target ],
2985
				leftEdge = event.pageX - vars.mouseXPosition;
2986
			if ( vars.overflow ) {
2987
				if ( tar + leftEdge > 0 ) {
2988
					vars.storedSizes[ vars.target ] += leftEdge;
2989
					ts.resizable.setWidth( vars.$target, vars.storedSizes[ vars.target ], true );
2990
					// update the entire table width
2991
					for ( column = 0; column < c.columns; column++ ) {
2992
						total += vars.storedSizes[ column ];
2993
					}
2994
					ts.resizable.setWidth( c.$table.add( $( c.namespace + '_extra_table' ) ), total );
2995
				}
2996
				if ( !$next.length ) {
2997
					// if expanding right-most column, scroll the wrapper
2998
					vars.$wrap[0].scrollLeft = c.$table.width();
2999
				}
3000
			} else if ( vars.fullWidth ) {
3001
				vars.storedSizes[ vars.target ] += leftEdge;
3002
				vars.storedSizes[ vars.next ] -= leftEdge;
3003
				ts.resizable.setWidths( c, wo );
3004
			} else {
3005
				vars.storedSizes[ vars.target ] += leftEdge;
3006
				ts.resizable.setWidths( c, wo );
3007
			}
3008
			vars.mouseXPosition = event.pageX;
3009
			// dynamically update sticky header widths
3010
			c.$table.triggerHandler('stickyHeadersUpdate');
3011
		},
3012
 
3013
		stopResize : function( c, wo ) {
3014
			var vars = wo.resizable_vars;
3015
			ts.resizable.updateStoredSizes( c, wo );
3016
			if ( vars.useStorage ) {
3017
				// save all column widths
3018
				ts.storage( c.table, ts.css.resizableStorage, vars.storedSizes );
3019
				ts.storage( c.table, 'tablesorter-table-resized-width', c.$table.width() );
3020
			}
3021
			vars.mouseXPosition = 0;
3022
			vars.$target = vars.$next = null;
3023
			// will update stickyHeaders, just in case, see #912
3024
			c.$table.triggerHandler('stickyHeadersUpdate');
3025
			c.$table.triggerHandler('resizableComplete');
3026
		}
3027
	};
3028
 
3029
	// this widget saves the column widths if
3030
	// $.tablesorter.storage function is included
3031
	// **************************
3032
	ts.addWidget({
3033
		id: 'resizable',
3034
		priority: 40,
3035
		options: {
3036
			resizable : true, // save column widths to storage
3037
			resizable_addLastColumn : false,
3038
			resizable_includeFooter: true,
3039
			resizable_widths : [],
3040
			resizable_throttle : false, // set to true (5ms) or any number 0-10 range
3041
			resizable_targetLast : false
3042
		},
3043
		init: function(table, thisWidget, c, wo) {
3044
			ts.resizable.init( c, wo );
3045
		},
3046
		format: function( table, c, wo ) {
3047
			ts.resizable.setHandlePosition( c, wo );
3048
		},
3049
		remove: function( table, c, wo, refreshing ) {
3050
			if (wo.$resizable_container) {
3051
				var namespace = c.namespace + 'tsresize';
3052
				c.$table.add( $( c.namespace + '_extra_table' ) )
3053
					.removeClass('hasResizable')
3054
					.children( 'thead' )
3055
					.unbind( 'contextmenu' + namespace );
3056
 
3057
				wo.$resizable_container.remove();
3058
				ts.resizable.toggleTextSelection( c, wo, false );
3059
				ts.resizableReset( table, refreshing );
3060
				$( document ).unbind( 'mousemove' + namespace + ' mouseup' + namespace );
3061
			}
3062
		}
3063
	});
3064
 
3065
	ts.resizableReset = function( table, refreshing ) {
3066
		$( table ).each(function() {
3067
			var index, $t,
3068
				c = this.config,
3069
				wo = c && c.widgetOptions,
3070
				vars = wo.resizable_vars;
3071
			if ( table && c && c.$headerIndexed.length ) {
3072
				// restore the initial table width
3073
				if ( vars.overflow && vars.tableWidth ) {
3074
					ts.resizable.setWidth( c.$table, vars.tableWidth, true );
3075
					if ( vars.useStorage ) {
3076
						ts.storage( table, 'tablesorter-table-resized-width', vars.tableWidth );
3077
					}
3078
				}
3079
				for ( index = 0; index < c.columns; index++ ) {
3080
					$t = c.$headerIndexed[ index ];
3081
					if ( wo.resizable_widths && wo.resizable_widths[ index ] ) {
3082
						ts.resizable.setWidth( $t, wo.resizable_widths[ index ], vars.overflow );
3083
					} else if ( !$t.hasClass( 'resizable-false' ) ) {
3084
						// don't clear the width of any column that is not resizable
3085
						ts.resizable.setWidth( $t, '', vars.overflow );
3086
					}
3087
				}
3088
 
3089
				// reset stickyHeader widths
3090
				c.$table.triggerHandler( 'stickyHeadersUpdate' );
3091
				if ( ts.storage && !refreshing ) {
3092
					ts.storage( this, ts.css.resizableStorage, [] );
3093
				}
3094
			}
3095
		});
3096
	};
3097
 
3098
})( jQuery, window );
3099
 
3100
/*! Widget: saveSort - updated 2018-03-19 (v2.30.1) *//*
3101
* Requires tablesorter v2.16+
3102
* by Rob Garrison
3103
*/
3104
;(function ($) {
3105
	'use strict';
3106
	var ts = $.tablesorter || {};
3107
 
3108
	function getStoredSortList(c) {
3109
		var stored = ts.storage( c.table, 'tablesorter-savesort' );
3110
		return (stored && stored.hasOwnProperty('sortList') && $.isArray(stored.sortList)) ? stored.sortList : [];
3111
	}
3112
 
3113
	function sortListChanged(c, sortList) {
3114
		return (sortList || getStoredSortList(c)).join(',') !== c.sortList.join(',');
3115
	}
3116
 
3117
	// this widget saves the last sort only if the
3118
	// saveSort widget option is true AND the
3119
	// $.tablesorter.storage function is included
3120
	// **************************
3121
	ts.addWidget({
3122
		id: 'saveSort',
3123
		priority: 20,
3124
		options: {
3125
			saveSort : true
3126
		},
3127
		init: function(table, thisWidget, c, wo) {
3128
			// run widget format before all other widgets are applied to the table
3129
			thisWidget.format(table, c, wo, true);
3130
		},
3131
		format: function(table, c, wo, init) {
3132
			var time,
3133
				$table = c.$table,
3134
				saveSort = wo.saveSort !== false, // make saveSort active/inactive; default to true
3135
				sortList = { 'sortList' : c.sortList },
3136
				debug = ts.debug(c, 'saveSort');
3137
			if (debug) {
3138
				time = new Date();
3139
			}
3140
			if ($table.hasClass('hasSaveSort')) {
3141
				if (saveSort && table.hasInitialized && ts.storage && sortListChanged(c)) {
3142
					ts.storage( table, 'tablesorter-savesort', sortList );
3143
					if (debug) {
3144
						console.log('saveSort >> Saving last sort: ' + c.sortList + ts.benchmark(time));
3145
					}
3146
				}
3147
			} else {
3148
				// set table sort on initial run of the widget
3149
				$table.addClass('hasSaveSort');
3150
				sortList = '';
3151
				// get data
3152
				if (ts.storage) {
3153
					sortList = getStoredSortList(c);
3154
					if (debug) {
3155
						console.log('saveSort >> Last sort loaded: "' + sortList + '"' + ts.benchmark(time));
3156
					}
3157
					$table.bind('saveSortReset', function(event) {
3158
						event.stopPropagation();
3159
						ts.storage( table, 'tablesorter-savesort', '' );
3160
					});
3161
				}
3162
				// init is true when widget init is run, this will run this widget before all other widgets have initialized
3163
				// this method allows using this widget in the original tablesorter plugin; but then it will run all widgets twice.
3164
				if (init && sortList && sortList.length > 0) {
3165
					c.sortList = sortList;
3166
				} else if (table.hasInitialized && sortList && sortList.length > 0) {
3167
					// update sort change
3168
					if (sortListChanged(c, sortList)) {
3169
						ts.sortOn(c, sortList);
3170
					}
3171
				}
3172
			}
3173
		},
3174
		remove: function(table, c) {
3175
			c.$table.removeClass('hasSaveSort');
3176
			// clear storage
3177
			if (ts.storage) { ts.storage( table, 'tablesorter-savesort', '' ); }
3178
		}
3179
	});
3180
 
3181
})(jQuery);
3182
return jQuery.tablesorter;}));