/* * * StaticRow widget for jQuery TableSorter 2.0 * Version 1.0 * * Copyright (c) 2011 Nils Luxton * Licensed under the MIT license: * http://www.opensource.org/licenses/mit-license.php * */ $.tablesorter.addWidget({ // Give the new Widget an ID to be used in the tablesorter() call, as follows: // $('#myElement').tablesorter({ widgets: ['zebra','staticRow'] }); id: 'staticRow', // "Format" is run on all widgets once when the tablesorter has finished initialising, // and then again every time a sort has finished. format: function(table) { // Use a property of the function to determine // whether this is the first run of "Format" // (i.e. is this the table's default starting position, // or has it been sorted?) if (typeof $(table).data('hasSorted') == 'undefined') { $(table).data('hasSorted', true); // This will force us into the "else" block the next time "Format" is run // "Index" the static rows, saving their current (starting) // position in the table inside a data() param on the //