Sha256: a49284dadbfd41ef231a1ea27509669159d5ddbc3d1630e99cb8c2c2b02cec08

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

/*! tablesorter repeatHeaders widget - updated 10/26/2014 (v2.18.0)
* Requires tablesorter v2.8+ and jQuery 1.7+
* Original by Christian Bach from the example-widgets.html demo
*/
/*global jQuery: false */
;(function($){
	"use strict";

	$.tablesorter.addWidget({
		id: "repeatHeaders",
		priority: 10,
		options: {
			rowsToSkip : 4
		},
		// format is called on init and when a sorting has finished
		format: function(table, c, wo) {
			var h = '', i, $tr, l, skip;
			// cache and collect all TH headers
			if (!wo.repeatHeaders) {
				h = '<tr class="repeated-header remove-me">';
				$.each(c.headerContent, function(i,t) {
					h += '<th>' + t + '</th>';
				});
				// "remove-me" class was added in case the table needs to be updated, the "remove-me" rows will be
				// removed prior to the update to prevent including the rows in the update - see "selectorRemove" option
				wo.repeatHeaders = h + '</tr>';
			}

			// number of rows to skip
			skip = wo && wo.rowsToSkip || 4;

			// remove appended headers by classname
			c.$table.find("tr.repeated-header").remove();
			$tr = c.$tbodies.find('tr');
			l = $tr.length;
			// loop all tr elements and insert a copy of the "headers"
			for (i = skip; i < l; i += skip) {
				// insert a copy of the table head every X rows
				$tr.eq(i).before(wo.repeatHeaders);
			}
		},
		// this remove function is called when using the refreshWidgets method or when destroying the tablesorter plugin
		// this function only applies to tablesorter v2.4+
		remove: function(table, c){
			c.$table.find("tr.repeated-header").remove();
		}

	});

})(jQuery);

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jquery-tablesorter-1.13.4 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-repeatheaders.js
jquery-tablesorter-1.13.3 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-repeatheaders.js
jquery-tablesorter-1.13.2 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-repeatheaders.js
jquery-tablesorter-1.13.1 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-repeatheaders.js
jquery-tablesorter-1.13.0 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-repeatheaders.js