mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
ie speed optimization
This commit is contained in:
parent
b5735fd0db
commit
516152e256
BIN
README.markdown
BIN
README.markdown
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
/*!
|
||||
* tablesorter pager plugin
|
||||
* updated 5/23/2012
|
||||
* updated 5/28/2012
|
||||
*/
|
||||
;(function($) {
|
||||
$.extend({tablesorterPager: new function() {
|
||||
@ -235,6 +235,7 @@
|
||||
if (e > rows.length ) {
|
||||
e = rows.length;
|
||||
}
|
||||
$(table.tBodies[0]).addClass('tablesorter-hidden');
|
||||
$.tablesorter.clearTableBody(table);
|
||||
for (i = s; i < e; i++) {
|
||||
o = rows[i];
|
||||
@ -244,6 +245,7 @@
|
||||
}
|
||||
}
|
||||
table.tBodies[0].appendChild(f);
|
||||
$(table.tBodies[0]).removeClass('tablesorter-hidden');
|
||||
}
|
||||
if ( c.page >= c.totalPages ) {
|
||||
moveToLastPage(table, c);
|
||||
|
4
addons/pager/jquery.tablesorter.pager.min.js
vendored
4
addons/pager/jquery.tablesorter.pager.min.js
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -59,6 +59,10 @@ table.tablesorter th.tablesorter-headerSortDown {
|
||||
/* image */
|
||||
/* background-image: url(black-desc.gif); */
|
||||
}
|
||||
/* used to hide a tbody while rebuilding to speed it up */
|
||||
table.tablesorter .tablesorter-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Zebra Widget - row alternating colors */
|
||||
table.tablesorter tr.odd td {
|
||||
|
Binary file not shown.
@ -48,6 +48,10 @@ table.tablesorter th.headerSortDown span:first-child,
|
||||
table.tablesorter th.tablesorter-headerSortDown .tablesorter-header-inner {
|
||||
background: url(desc.png) no-repeat;
|
||||
}
|
||||
/* used to hide a tbody while rebuilding to speed it up */
|
||||
table.tablesorter .tablesorter-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Zebra Widget - row alternating colors */
|
||||
table.tablesorter tr.odd td {
|
||||
|
@ -40,6 +40,10 @@ table.tablesorter tbody td {
|
||||
table.tablesorter tr.ui-state-default {
|
||||
background-image: url();
|
||||
}
|
||||
/* used to hide a tbody while rebuilding to speed it up */
|
||||
table.tablesorter .tablesorter-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* filter widget */
|
||||
table.tablesorter thead tr.tablesorter-filter input.tablesorter-filter {
|
||||
|
@ -48,6 +48,7 @@
|
||||
<li>This widget can be applied to the original plugin. The code is in the "jquery.tablesorter.widgets.js" file.</li>
|
||||
<li>This widget now saves all changed column widths to local storage, or it falls back to a cookie! <span class="tip"><em>New! v2.1</em></span></li>
|
||||
<li>Column width saving requires the new "$.tablesorter.storage()" function included with the "jquery.tablesorter.widgets.js" file. <span class="tip"><em>New! v2.1</em></span></li>
|
||||
<li>Fixed the issue where resizing a column would cause a sort of the column to the right in v2.3.5.</li>
|
||||
<li>Because this widget uses jQuery's <code class="hilight">closest()</code> function, it requires jQuery 1.3+ in order to work.</li>
|
||||
<li>Because this widget uses jQuery's <code class="hilight">parseJson()</code> function, it requires jQuery version 1.4.1+ in order to save the widths.</li>
|
||||
</ul>
|
||||
|
@ -31,9 +31,10 @@
|
||||
|
||||
// format is called when the on init and when a sorting has finished
|
||||
format: function(table) {
|
||||
var h, i, skip;
|
||||
// cache and collect all TH headers
|
||||
if (!this.headers) {
|
||||
var h = this.headers = [];
|
||||
h = this.headers = [];
|
||||
$("thead th",table).each(function() {
|
||||
h.push(
|
||||
"<th>" + $(this).text() + "</th>"
|
||||
@ -44,18 +45,17 @@
|
||||
// remove appended headers by classname
|
||||
$("tr.repeated-header",table).remove();
|
||||
|
||||
// number of rows to skip
|
||||
skip = 4;
|
||||
|
||||
// loop all tr elements and insert a copy of the "headers"
|
||||
for (var i = 0; i < table.tBodies[0].rows.length; i++) {
|
||||
for (i = skip; i < table.tBodies[0].rows.length; i += (skip + 1)) {
|
||||
// insert a copy of the table head every X rows
|
||||
// i mod 5 = 4, is true every 4th row, starting from the 4th.
|
||||
// i mod 6 = 5, is true every 5th row, starting from the 5th, etc.
|
||||
if ((i%5) === 4) {
|
||||
$("tbody tr:eq(" + i + ")",table).before(
|
||||
// "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
|
||||
$("<tr></tr>").addClass("repeated-header remove-me").html(this.headers.join(""))
|
||||
);
|
||||
}
|
||||
$("tbody tr:eq(" + i + ")",table).before(
|
||||
// "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
|
||||
$("<tr></tr>").addClass("repeated-header remove-me").html(this.headers.join(""))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,6 +312,15 @@
|
||||
<td>80</td>
|
||||
<td>80</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student24</td>
|
||||
<td>Languages</td>
|
||||
<td>female</td>
|
||||
<td>100</td>
|
||||
<td>91</td>
|
||||
<td>13</td>
|
||||
<td>82</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
@ -690,7 +690,7 @@
|
||||
<pre class="js">$(function(){
|
||||
$("table").tablesorter({
|
||||
onRenderHeader: function (){
|
||||
$(this).find('span').addClass('roundedCorners');
|
||||
$(this).find('div').addClass('roundedCorners');
|
||||
}
|
||||
});
|
||||
});</pre>and you'll end up with this HTML (only the thead is shown)<pre class="html"><thead>
|
||||
@ -1282,7 +1282,7 @@ $(function(){
|
||||
<td>Boolean</td>
|
||||
<td>false</td>
|
||||
<td>
|
||||
Filter widget: Set this option to <code class="hilight">true</code> to use the filter to find text from the start of the column, so typing in "a" will find "albert" but not "frank", both have a's. (New v2.1).
|
||||
Set this option to <code class="hilight">true</code> to use the filter to find text from the start of the column, so typing in "a" will find "albert" but not "frank", both have a's. (New v2.1).
|
||||
<div class="collapsible">
|
||||
<br>
|
||||
Use the <a href="#widget-filter-startswith"><code class="hilight">filter_startsWith</code></a> option as follows:
|
||||
@ -1298,6 +1298,58 @@ $(function(){
|
||||
<td><a href="example-widget-filter.html">Example</a></td>
|
||||
</tr>
|
||||
|
||||
<tr id="widget-filter-ignorecase">
|
||||
<td><a href="#" class="toggle2">filter_ignoreCase</a></td>
|
||||
<td>Boolean</td>
|
||||
<td>true</td>
|
||||
<td>
|
||||
Set this option to <code class="hilight">false</code> to make the column content search case-insensitive, so typing in "a" will not find "Albert". <span class="tip"><em>New! v2.3.4</em></span>
|
||||
<div class="collapsible">
|
||||
<br>
|
||||
Use the <a href="#widget-filter-ignorecase"><code class="hilight">filter_ignorecase</code></a> option as follows:
|
||||
<pre class="js">$(function(){
|
||||
$("table").tablesorter({
|
||||
widgets: ["filter"],
|
||||
widgetOptions : {
|
||||
filter_ignoreCase : false
|
||||
}
|
||||
});
|
||||
});</pre></div>
|
||||
</td>
|
||||
<td><a href="example-widget-filter.html">Example</a></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr id="widget-filter-searchdelay">
|
||||
<td><a href="#" class="toggle2">filter_searchDelay</a></td>
|
||||
<td>Numeric</td>
|
||||
<td>300</td>
|
||||
<td>
|
||||
Set this option to the number of milliseconds to delay the search. <span class="tip"><em>New! v2.3.4</em></span>
|
||||
<div class="collapsible">
|
||||
<br>
|
||||
Use the <a href="#widget-filter-searchdelay"><code class="hilight">filter_searchDelay</code></a> option as follows:
|
||||
<pre class="js">$(function(){
|
||||
$("table").tablesorter({
|
||||
widgets: ["filter"],
|
||||
widgetOptions : {
|
||||
filter_searchDelay : 500
|
||||
}
|
||||
});
|
||||
});</pre>
|
||||
|
||||
If you want to want to initialize the filter without user input, target any one of the filters and trigger a "search".
|
||||
|
||||
<pre class="js">// target the first filter input
|
||||
// this method will begin the search after the searchDelay time
|
||||
$('input.tablesorter-filter:eq(0)').trigger('search');
|
||||
|
||||
// this method will begin the search immediately
|
||||
$('input.tablesorter-filter:eq(0)').trigger('search', false);</pre></div>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr id="widget-sticky-headers">
|
||||
<td><a href="#" class="toggle2">stickyHeaders</a></td>
|
||||
<td>String</td>
|
||||
|
@ -24,7 +24,7 @@
|
||||
this.defaults = {
|
||||
|
||||
// appearance
|
||||
widthFixed : false,
|
||||
widthFixed : false, // adds colgroup to fix widths of columns
|
||||
|
||||
// functionality
|
||||
cancelSelection : true, // prevent text selection in the header
|
||||
@ -51,6 +51,7 @@
|
||||
textSorter : null, // use custom text sorter - function(a,b){ return a.sort(b); } // basic sort
|
||||
|
||||
// widget options
|
||||
widgets: [], // method to add widgets, e.g. widgets: ['zebra']
|
||||
widgetOptions : {
|
||||
zebra : [ "even", "odd" ] // zebra widget alternating row class names
|
||||
},
|
||||
@ -79,8 +80,7 @@
|
||||
headerList: [],
|
||||
empties: {},
|
||||
strings: {},
|
||||
parsers: [],
|
||||
widgets: []
|
||||
parsers: []
|
||||
|
||||
// deprecated; but retained for backwards compatibility
|
||||
// widgetZebra: { css: ["even", "odd"] }
|
||||
@ -104,17 +104,26 @@
|
||||
this.hasInitialized = false;
|
||||
|
||||
function getElementText(table, node, cellIndex) {
|
||||
var text = "", t = table.config.textExtraction;
|
||||
if (!node) { return ""; }
|
||||
var c = table.config,
|
||||
t = c.textExtraction, text = "";
|
||||
if (t === "simple") {
|
||||
text = $(node).text();
|
||||
if (c.supportsTextContent) {
|
||||
text = node.textContent; // newer browsers support this
|
||||
} else {
|
||||
if (node.childNodes[0] && node.childNodes[0].hasChildNodes()) {
|
||||
text = node.childNodes[0].innerHTML;
|
||||
} else {
|
||||
text = node.innerHTML;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (typeof(t) === "function") {
|
||||
text = t(node, table, cellIndex);
|
||||
} else if (typeof(t) === "object" && t.hasOwnProperty(cellIndex)) {
|
||||
text = t[cellIndex](node, table, cellIndex);
|
||||
} else {
|
||||
text = $(node).text();
|
||||
text = c.supportsTextContent ? node.textContent : $(node).text();
|
||||
}
|
||||
}
|
||||
return $.trim(text);
|
||||
@ -159,11 +168,10 @@
|
||||
|
||||
function buildParserCache(table, $headers) {
|
||||
var c = table.config,
|
||||
$tb = $(table.tBodies).filter(':not(.' + c.cssInfoBlock + ')'),
|
||||
$f = $(document.createDocumentFragment()),
|
||||
ts = $.tablesorter, rows, list, l, i, h, ch, p, parsersDebug = "";
|
||||
if ( $tb.length === 0) { return; } // In the case of empty tables
|
||||
rows = $tb.children('tr').clone().appendTo($f);
|
||||
tb = $(table.tBodies).filter(':not(.' + c.cssInfoBlock + ')'),
|
||||
ts = $.tablesorter, rows, list, l, i, h, m, ch, cl, p, parsersDebug = "";
|
||||
if ( tb.length === 0) { return; } // In the case of empty tables
|
||||
rows = tb[0].rows;
|
||||
if (rows[0]) {
|
||||
list = [];
|
||||
l = rows[0].cells.length;
|
||||
@ -221,6 +229,7 @@
|
||||
tc.cache[k] = { row: [], normalized: [] };
|
||||
// ignore tbodies with class name from css.cssInfoBlock
|
||||
if (!$(b[k]).hasClass(tc.cssInfoBlock)) {
|
||||
$(b[k]).addClass('tablesorter-hidden');
|
||||
totalRows = (b[k] && b[k].rows.length) || 0;
|
||||
totalCells = (b[k].rows[0] && b[k].rows[0].cells.length) || 0;
|
||||
for (i = 0; i < totalRows; ++i) {
|
||||
@ -243,6 +252,7 @@
|
||||
cols.push(tc.cache[k].normalized.length); // add position for rowCache
|
||||
tc.cache[k].normalized.push(cols);
|
||||
}
|
||||
$(b[k]).removeClass('tablesorter-hidden');
|
||||
}
|
||||
}
|
||||
if (tc.debug) {
|
||||
@ -261,8 +271,11 @@
|
||||
}
|
||||
|
||||
function applyWidget(table, init) {
|
||||
var c = table.config.widgets,
|
||||
i, w, l = c.length;
|
||||
var tc = table.config, c = tc.widgets,
|
||||
time, i, w, l = c.length;
|
||||
if (tc.debug) {
|
||||
time = new Date();
|
||||
}
|
||||
for (i = 0; i < l; i++) {
|
||||
w = getWidgetById(c[i]);
|
||||
if ( w ) {
|
||||
@ -273,6 +286,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tc.debug) {
|
||||
benchmark("Completed " + (init === true ? "initializing" : "applying") + " widgets", time);
|
||||
}
|
||||
}
|
||||
|
||||
// init flag (true) used by pager plugin to prevent widget application
|
||||
@ -287,6 +303,7 @@
|
||||
}
|
||||
for (k = 0; k < b.length; k++) {
|
||||
if (!$(b[k]).hasClass(c.cssInfoBlock)){
|
||||
$(b[k]).addClass('tablesorter-hidden');
|
||||
f = document.createDocumentFragment();
|
||||
r = c2[k].row;
|
||||
n = c2[k].normalized;
|
||||
@ -304,6 +321,7 @@
|
||||
}
|
||||
}
|
||||
table.tBodies[k].appendChild(f);
|
||||
$(b[k]).removeClass('tablesorter-hidden');
|
||||
}
|
||||
}
|
||||
if (c.appender) {
|
||||
@ -366,6 +384,7 @@
|
||||
return (/^d/i.test(v) || v === 1);
|
||||
}
|
||||
|
||||
|
||||
function buildHeaders(table) {
|
||||
var header_index = computeThIndexes(table), ch, $t,
|
||||
$th, lock, time, $tableHeaders, c = table.config, ts = $.tablesorter;
|
||||
@ -373,11 +392,12 @@
|
||||
if (c.debug) {
|
||||
time = new Date();
|
||||
}
|
||||
$tableHeaders = $(c.selectorHeaders, table)
|
||||
.wrapInner("<div class='tablesorter-header-inner' />")
|
||||
$tableHeaders = $(table).find(c.selectorHeaders)
|
||||
.each(function(index) {
|
||||
$t = $(this);
|
||||
ch = c.headers[index];
|
||||
this.innerHTML = '<div class="tablesorter-header-inner">' + this.innerHTML + '</div>'; // faster than wrapInner
|
||||
if (c.onRenderHeader) { c.onRenderHeader.apply($th, [index]); }
|
||||
this.column = header_index[this.parentNode.rowIndex + "-" + this.cellIndex];
|
||||
this.order = formatSortingOrder( ts.getData($t, ch, 'sortInitialOrder') || c.sortInitialOrder ) ? [1,0,2] : [0,1,2];
|
||||
this.count = -1; // set to -1 because clicking on the header automatically adds one
|
||||
@ -389,15 +409,14 @@
|
||||
}
|
||||
if (!this.sortDisabled) {
|
||||
$th = $t.addClass(c.cssHeader);
|
||||
if (c.onRenderHeader) { c.onRenderHeader.apply($th, [index]); }
|
||||
}
|
||||
// add cell to headerList
|
||||
c.headerList[index] = this;
|
||||
// add to parent in case there are multiple rows
|
||||
$t.parent().addClass(c.cssHeader);
|
||||
});
|
||||
if (c.debug) {
|
||||
benchmark("Built headers", time);
|
||||
if (table.config.debug) {
|
||||
benchmark("Built headers:", time);
|
||||
log($tableHeaders);
|
||||
}
|
||||
return $tableHeaders;
|
||||
@ -426,7 +445,10 @@
|
||||
l = list.length;
|
||||
for (i = 0; i < l; i++) {
|
||||
if (list[i][1] === 2) { continue; } // direction = 2 means reset!
|
||||
h[list[i][0]].addClass(css[list[i][1]]);
|
||||
if (h[list[i][0]]) {
|
||||
// add class if cell exists - fix for issue #78
|
||||
h[list[i][0]].addClass(css[list[i][1]]);
|
||||
}
|
||||
// multicolumn sorting updating
|
||||
f = $headers.filter('[data-column="' + list[i][0] + '"]');
|
||||
if (l > 1 && f.length) {
|
||||
@ -735,7 +757,6 @@
|
||||
this.onselectstart = function() {
|
||||
return false;
|
||||
};
|
||||
return false;
|
||||
});
|
||||
}
|
||||
// apply easy methods that trigger binded events
|
||||
@ -1111,7 +1132,7 @@
|
||||
ts.addWidget({
|
||||
id: "zebra",
|
||||
format: function(table) {
|
||||
var $tb, $tr, $f, row, even, time, k, j, l,
|
||||
var $tb, $tv, $tr, $f, row, even, time, k, j, l,
|
||||
c = table.config,
|
||||
child = new RegExp(c.cssChildRow, 'i'),
|
||||
b = $(table).children('tbody:not(.' + c.cssInfoBlock + ')'),
|
||||
@ -1123,23 +1144,23 @@
|
||||
time = new Date();
|
||||
}
|
||||
for (k = 0; k < b.length; k++ ) {
|
||||
row = 0;
|
||||
// loop through the visible rows
|
||||
$tb = $(b[k]);
|
||||
l = $tb.children('tr').length;
|
||||
if (l > 1) {
|
||||
$f = $(document.createDocumentFragment());
|
||||
$tr = $tb.children('tr').appendTo($f);
|
||||
for (j = 0; j < l; j++) {
|
||||
if ($tr[j].style.display !== 'none') {
|
||||
// style children rows the same way the parent row was styled
|
||||
if (!child.test($tr[j].className)) { row++; }
|
||||
even = (row % 2 === 0);
|
||||
$tr.eq(j).removeClass(css[even ? 1 : 0]).addClass(css[even ? 0 : 1]);
|
||||
}
|
||||
}
|
||||
row = 0;
|
||||
$tv = $tb.find('tr:visible');
|
||||
$tb.addClass('tablesorter-hidden');
|
||||
// revered back to using jQuery each - strangely it's the fastest method
|
||||
$tv.each(function(){
|
||||
$tr = $(this);
|
||||
// style children rows the same way the parent row was styled
|
||||
if (!child.test(this.className)) { row++; }
|
||||
even = (row % 2 === 0);
|
||||
$tr.removeClass(css[even ? 1 : 0]).addClass(css[even ? 0 : 1]);
|
||||
});
|
||||
$tb.removeClass('tablesorter-hidden');
|
||||
}
|
||||
$tb.append($tr);
|
||||
}
|
||||
if (c.debug) {
|
||||
ts.benchmark("Applying Zebra widget", time);
|
||||
|
4
js/jquery.tablesorter.min.js
vendored
4
js/jquery.tablesorter.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
/*! tableSorter 2.3 widgets - updated 5/23/2012
|
||||
/*! tableSorter 2.3 widgets - updated 5/28/2012
|
||||
*
|
||||
* jQuery UI Theme
|
||||
* Column Styles
|
||||
@ -125,7 +125,7 @@ $.tablesorter.addWidget({
|
||||
$.tablesorter.addWidget({
|
||||
id: "columns",
|
||||
format: function(table) {
|
||||
var $tb, $tr, $td, $f, time, last, rmv, i, j, k, l,
|
||||
var $tb, $tr, $td, $t, time, last, rmv, i, k, l,
|
||||
c = table.config,
|
||||
b = $(table).children('tbody:not(.' + c.cssInfoBlock + ')'),
|
||||
list = c.sortList,
|
||||
@ -142,14 +142,14 @@ $.tablesorter.addWidget({
|
||||
// check if there is a sort (on initialization there may not be one)
|
||||
for (k = 0; k < b.length; k++ ) {
|
||||
$tb = $(b[k]);
|
||||
$f = $(document.createDocumentFragment());
|
||||
$tr = $tb.children('tr').appendTo($f);
|
||||
$tr = $tb.addClass('tablesorter-hidden').children('tr');
|
||||
l = $tr.length;
|
||||
// loop through the visible rows
|
||||
for (j = 0; j < l; j++) {
|
||||
if ($tr[j].style.display !== 'none') {
|
||||
$tr.each(function(){
|
||||
$t = $(this);
|
||||
if (this.style.display !== 'none') {
|
||||
// remove all columns class names
|
||||
$td = $tr.eq(j).children().removeClass(rmv);
|
||||
$td = $t.children().removeClass(rmv);
|
||||
// add appropriate column class names
|
||||
if (list && list[0]) {
|
||||
// primary sort column class
|
||||
@ -162,8 +162,8 @@ $.tablesorter.addWidget({
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$tb.append($tr);
|
||||
});
|
||||
$tb.removeClass('tablesorter-hidden');
|
||||
}
|
||||
if (c.debug) {
|
||||
$.tablesorter.benchmark("Applying Columns widget", time);
|
||||
@ -178,7 +178,7 @@ $.tablesorter.addWidget({
|
||||
id: "filter",
|
||||
format: function(table) {
|
||||
if (!$(table).hasClass('hasFilters')) {
|
||||
var i, j, k, l, cv, v, r, t, x, cr, $tb, $tr, $td, $f,
|
||||
var i, j, k, l, cv, v, r, t, x, cr, $tb, $tr, $td,
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
css = wo.filter_cssFilter || 'tablesorter-filter',
|
||||
@ -197,8 +197,7 @@ $.tablesorter.addWidget({
|
||||
cv = v.join('');
|
||||
for (k = 0; k < b.length; k++ ) {
|
||||
$tb = $(b[k]);
|
||||
$f = $(document.createDocumentFragment());
|
||||
$tr = $tb.children('tr').appendTo($f);
|
||||
$tr = $tb.addClass('tablesorter-hidden').children('tr');
|
||||
l = $tr.length;
|
||||
// loop through the rows
|
||||
for (j = 0; j < l; j++) {
|
||||
@ -231,7 +230,7 @@ $.tablesorter.addWidget({
|
||||
}
|
||||
}
|
||||
}
|
||||
$tb.append($tr);
|
||||
$tb.removeClass('tablesorter-hidden');
|
||||
}
|
||||
if (c.debug) {
|
||||
$.tablesorter.benchmark("Completed filter widget search", time);
|
||||
@ -256,6 +255,8 @@ $.tablesorter.addWidget({
|
||||
$t
|
||||
.find('thead').eq(0).append(fr += '</tr>')
|
||||
.find('input.' + css).bind('keyup search', function(e, delay){
|
||||
// ignore arrow and meta keys; allow backspace
|
||||
if ((e.which < 32 && e.which !== 8) || (e.which >= 37 && e.which <=40)) { return; }
|
||||
// skip delay
|
||||
if (delay === false) {
|
||||
findRows();
|
||||
@ -317,11 +318,11 @@ $.tablesorter.addWidget({
|
||||
});
|
||||
// set sticky header cell width and link clicks to real header
|
||||
hdrCells.each(function(i){
|
||||
var t = $(this),
|
||||
s = stkyCells.eq(i)
|
||||
var t = $(this);
|
||||
stkyCells.eq(i)
|
||||
// clicking on sticky will trigger sort
|
||||
.bind('click', function(e){
|
||||
t.trigger(e);
|
||||
.bind('mouseup', function(e){
|
||||
t.trigger(e, true); // external mouseup flag (click timer is ignored)
|
||||
})
|
||||
// prevent sticky header text selection
|
||||
.bind('mousedown', function(){
|
||||
@ -374,12 +375,11 @@ $.tablesorter.addWidget({
|
||||
format: function(table) {
|
||||
if ($(table).hasClass('hasResizable')) { return; }
|
||||
$(table).addClass('hasResizable');
|
||||
var i, j, w, s, c = table.config,
|
||||
var j, s, c = table.config,
|
||||
$cols = $(c.headerList).filter(':gt(0)'),
|
||||
position = 0,
|
||||
$target = null,
|
||||
$prev = null,
|
||||
len = $cols.length,
|
||||
stopResize = function(){
|
||||
position = 0;
|
||||
$target = $prev = null;
|
||||
@ -403,8 +403,7 @@ $.tablesorter.addWidget({
|
||||
.bind('mousemove', function(e){
|
||||
// ignore mousemove if no mousedown
|
||||
if (position === 0 || !$target) { return; }
|
||||
var w = e.pageX - position,
|
||||
n = $prev;
|
||||
var w = e.pageX - position;
|
||||
// make sure
|
||||
if ( $target.width() < -w || ( $prev && $prev.width() <= w )) { return; }
|
||||
// resize current column
|
||||
@ -425,6 +424,7 @@ $.tablesorter.addWidget({
|
||||
$target = $(e.target).closest('th');
|
||||
$prev = $target.prev();
|
||||
position = e.pageX;
|
||||
return false;
|
||||
});
|
||||
$(table).find('thead').bind('mouseup mouseleave', function(){
|
||||
stopResize();
|
||||
@ -443,7 +443,7 @@ $.tablesorter.addWidget({
|
||||
thisWidget.format(table, true);
|
||||
},
|
||||
format: function(table, init) {
|
||||
var n, d, k, sl, time, c = table.config, sortList = { "sortList" : c.sortList };
|
||||
var sl, time, c = table.config, sortList = { "sortList" : c.sortList };
|
||||
if (c.debug) {
|
||||
time = new Date();
|
||||
}
|
||||
|
16
js/jquery.tablesorter.widgets.min.js
vendored
16
js/jquery.tablesorter.widgets.min.js
vendored
@ -1,10 +1,10 @@
|
||||
/*! tableSorter 2.3 widgets - updated 5/19/2012 */
|
||||
/*! tableSorter 2.3 widgets - updated 5/28/2012 */
|
||||
;(function(b){
|
||||
b.tablesorter.storage=function(a,e,c){var d,h=!1;d={};var j=a.id||b(".tablesorter").index(b(a)),f=window.location.pathname;try{h=!!localStorage.getItem}catch(g){}b.parseJSON&&(h?d=b.parseJSON(localStorage[e])||{}:(d=document.cookie.split(/[;\s|=]/),a=b.inArray(e,d)+1,d=0!==a?b.parseJSON(d[a])||{}:{}));if(c&&JSON&&JSON.hasOwnProperty("stringify")){if(!d[f]||!d[f][j])d[f]||(d[f]={});d[f][j]=c;h?localStorage[e]=JSON.stringify(d):(a=new Date,a.setTime(a.getTime()+31536E6),document.cookie= e+"="+JSON.stringify(d).replace(/\"/g,'"')+"; expires="+a.toGMTString()+"; path=/")}else return d&&d.hasOwnProperty(f)&&d[f].hasOwnProperty(j)?d[f][j]:{}};
|
||||
b.tablesorter.addWidget({id:"uitheme",format:function(a){var e,c,d,h,j,f=b(a),g=a.config,i=g.widgetOptions,k=["ui-icon-arrowthick-2-n-s","ui-icon-arrowthick-1-s","ui-icon-arrowthick-1-n"],k=g.widgetUitheme&&g.widgetUitheme.hasOwnProperty("css")?g.widgetUitheme.css||k:i&&i.hasOwnProperty("uitheme")?i.uitheme:k;d=k.join(" ");g.debug&&(e=new Date); f.hasClass("ui-theme")||(f.addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),b.each(g.headerList,function(){b(this).addClass("ui-widget-header ui-corner-all ui-state-default").append('<span class="ui-icon"/>').wrapInner('<div class="tablesorter-inner"/>').hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")})}));b.each(g.headerList,function(a){h=b(this);if(this.sortDisabled)h.find("span.ui-icon").removeClass(d+" ui-icon");else{c=h.hasClass(g.cssAsc)? k[1]:h.hasClass(g.cssDesc)?k[2]:h.hasClass(g.cssHeader)?k[0]:"";j=f.hasClass("hasStickyHeaders")?f.find("tr."+(i.stickyHeaders||"tablesorter-stickyHeader")).find("th").eq(a).add(h):h;j[c===k[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(d).addClass(c)}});g.debug&&b.tablesorter.benchmark("Applying uitheme widget",e)}});
|
||||
b.tablesorter.addWidget({id:"columns",format:function(a){var e,c,d,h,j,f,g,i,k,l=a.config,m=b(a).children("tbody:not(."+l.cssInfoBlock+")"),o=l.sortList, p=o.length,n=["primary","secondary","tertiary"],n=l.widgetColumns&&l.widgetColumns.hasOwnProperty("css")?l.widgetColumns.css||n:l.widgetOptions&&l.widgetOptions.hasOwnProperty("columns")?l.widgetOptions.columns||n:n;h=n.length-1;j=n.join(" ");l.debug&&(d=new Date);if(o&&o[0])for(i=0;i<m.length;i++){a=b(m[i]);e=b(document.createDocumentFragment());e=a.children("tr").appendTo(e);k=e.length;for(g=0;g<k;g++)if(c=e.eq(g).children().removeClass(j),c.eq(o[0][0]).addClass(n[0]),1<p)for(f=1;f<p;f++)c.eq(o[f][0]).addClass(n[f]|| n[h]);a.append(e)}else{c=b(a).find("td");p=c.length;j=RegExp("("+n.join("|")+")");for(f=0;f<p;f++)c[f].className=c[f].className.replace(j,"")}l.debug&&b.tablesorter.benchmark("Applying Columns widget",d)}});
|
||||
b.tablesorter.addWidget({id:"filter",format:function(a){if(!b(a).hasClass("hasFilters")){var e,c,d,h,j,f,g,i=a.config,k=i.widgetOptions,l=k.filter_cssFilter||"tablesorter-filter",m=b(a).addClass("hasFilters"),o=i.parsers.length,a='<tr class="'+l+'">',p;i.debug&&(p=new Date);for(e=0;e<o;e++)a+= '<td><input type="search" data-col="'+e+'" class="'+l,a=b.tablesorter.getData?a+("false"===b.tablesorter.getData(i.headerList[e],i.headers[e],"filter")?' disabled" disabled':'"'):a+(i.headers[e]&&i.headers[e].hasOwnProperty("filter")&&!1===i.headers[e].filter||b(i.headerList[e]).is(".filter-false")?' disabled" disabled':'"'),a+="></td>";m.find("thead").eq(0).append(a+="</tr>").find("input."+l).bind("keyup search",function(){c=m.find("thead").eq(0).children("tr").find("input."+l).map(function(){return(b(this).val()|| "").toLowerCase()}).get();""===c.join("")?m.find("tr").show():m.children("tbody:not(."+i.cssInfoBlock+")").children("tr:not(."+i.cssChildRow+")").each(function(){d=!0;f=b(this).nextUntil("tr:not(."+i.cssChildRow+")");h=f.length&&(k&&k.hasOwnProperty("filter_childRows")&&"undefined"!==typeof k.filter_childRows?k.filter_childRows:1)?f.text():"";g=b(this).children("td");for(e=0;e<o;e++)j=b.trim(g.eq(e).text()+h).toLowerCase().indexOf(c[e]),""!==c[e]&&(!k.filter_startsWith&&0<=j||k.filter_startsWith&& 0===j)?d=d?!0:!1:""!==c[e]&&(d=!1);b(this)[d?"show":"hide"]();if(f.length)f[d?"show":"hide"]()});m.trigger("applyWidgets")});i.debug&&b.tablesorter.benchmark("Applying Filter widget",p)}}});
|
||||
b.tablesorter.addWidget({id:"stickyHeaders",format:function(a){if(!b(a).hasClass("hasStickyHeaders")){var e=b(a).addClass("hasStickyHeaders"),c=a.config.widgetOptions,d=b(window),h=b(a).children("thead"),j=h.children("tr:not(.sticky-false)").children(),f=c.stickyHeaders||"tablesorter-stickyHeader",g=j.eq(0),i= e.find("tfoot"),k=h.find("tr.tablesorter-header:not(.sticky-false)").clone().removeClass("tablesorter-header").addClass(f).css({width:h.outerWidth(!0),position:"fixed",left:g.offset().left,margin:0,top:0,visibility:"hidden",zIndex:10}),l=k.children(),m="";e.bind("sortEnd",function(a,c){var d=b(c).find("thead tr"),e=d.filter("."+f).children();d.filter(":not(."+f+")").children().each(function(a){e.eq(a).attr("class",b(this).attr("class"))})}).bind("pagerComplete",function(){d.resize()});j.each(function(a){var c= b(this);l.eq(a).bind("click",function(b){c.trigger(b)}).bind("mousedown",function(){this.onselectstart=function(){return!1};return!1}).find(".tablesorter-header-inner").width(c.find(".tablesorter-header-inner").width())});h.prepend(k);d.scroll(function(){var b=g.offset(),a=d.scrollTop(),c=e.height()-(g.height()+(i.height()||0)),a=a>b.top&&a<b.top+c?"visible":"hidden";k.css({left:b.left-d.scrollLeft(),visibility:a});a!==m&&(d.resize(),m=a)}).resize(function(){var a=0;k.css({left:g.offset().left-d.scrollLeft(), width:h.outerWidth()}).each(function(c){b(this).css("top",a);a+=h.find("tr").eq(c).outerHeight()});l.find(".tablesorter-header-inner").each(function(a){b(this).width(j.eq(a).find(".tablesorter-header-inner").width())})})}}});
|
||||
b.tablesorter.addWidget({id:"resizable",format:function(a){if(!b(a).hasClass("hasResizable")){b(a).addClass("hasResizable");var e,c,d=a.config,h=b(d.headerList).filter(":gt(0)"),j=0,f=null,g=null,i=function(){j=0;f=g=null;b(window).trigger("resize")};if(c=b.tablesorter.storage? b.tablesorter.storage(a,"tablesorter-resizable"):"")for(e in c)!isNaN(e)&&e<d.headerList.length&&b(d.headerList[e]).width(c[e]);h.each(function(){b(this).append('<div class="tablesorter-resizer" style="cursor:w-resize;position:absolute;height:100%;width:20px;left:-20px;top:0;z-index:1;"></div>').wrapInner('<div style="position:relative;height:100%;width:100%"></div>')}).bind("mousemove",function(a){if(0!==j&&f){var b=a.pageX-j;f.width()<-b||g&&g.width()<=b||(g.width(g.width()+b),j=a.pageX)}}).bind("mouseup", function(){c&&(b.tablesorter.storage&&f)&&(c[g.index()]=g.width(),b.tablesorter.storage(a,"tablesorter-resizable",c));i();return!1}).find(".tablesorter-resizer").bind("mousedown",function(a){f=b(a.target).closest("th");g=f.prev();j=a.pageX});b(a).find("thead").bind("mouseup mouseleave",function(){i()})}}});
|
||||
b.tablesorter.addWidget({id:"saveSort",init:function(a,b,c){c.format(a,!0)},format:function(a,e){var c,d,h=a.config;c={sortList:h.sortList};h.debug&&(d=new Date);b(a).hasClass("hasSaveSort")?a.hasInitialized&& b.tablesorter.storage&&(b.tablesorter.storage(a,"tablesorter-savesort",c),h.debug&&b.tablesorter.benchmark("saveSort widget: Saving last sort: "+h.sortList,d)):(b(a).addClass("hasSaveSort"),c="",b.tablesorter.storage&&(c=(c=b.tablesorter.storage(a,"tablesorter-savesort"))&&c.hasOwnProperty("sortList")&&b.isArray(c.sortList)?c.sortList:"",h.debug&&b.tablesorter.benchmark("saveSort: Last sort loaded: "+c,d)),e&&c&&0<c.length?h.sortList=c:a.hasInitialized&&(c&&0<c.length)&&b(a).trigger("sorton",[c]))}})
|
||||
b.tablesorter.storage=function(a,e,c){var d,g=!1;d={};var j=a.id||b(".tablesorter").index(b(a)),h=window.location.pathname;try{g=!!localStorage.getItem}catch(f){}b.parseJSON&&(g?d=b.parseJSON(localStorage[e])||{}:(d=document.cookie.split(/[;\s|=]/),a=b.inArray(e,d)+1,d=0!==a?b.parseJSON(d[a])||{}:{}));if(c&&JSON&&JSON.hasOwnProperty("stringify")){if(!d[h]||!d[h][j])d[h]||(d[h]={});d[h][j]=c;g?localStorage[e]=JSON.stringify(d):(a=new Date,a.setTime(a.getTime()+31536E6),document.cookie= e+"="+JSON.stringify(d).replace(/\"/g,'"')+"; expires="+a.toGMTString()+"; path=/")}else return d&&d.hasOwnProperty(h)&&d[h].hasOwnProperty(j)?d[h][j]:{}};
|
||||
b.tablesorter.addWidget({id:"uitheme",format:function(a){var e,c,d,g,j,h=b(a),f=a.config,k=f.widgetOptions,i=["ui-icon-arrowthick-2-n-s","ui-icon-arrowthick-1-s","ui-icon-arrowthick-1-n"],i=f.widgetUitheme&&f.widgetUitheme.hasOwnProperty("css")?f.widgetUitheme.css||i:k&&k.hasOwnProperty("uitheme")?k.uitheme:i;d=i.join(" ");f.debug&&(e=new Date); h.hasClass("ui-theme")||(h.addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),b.each(f.headerList,function(){b(this).addClass("ui-widget-header ui-corner-all ui-state-default").append('<span class="ui-icon"/>').wrapInner('<div class="tablesorter-inner"/>').hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")})}));b.each(f.headerList,function(a){g=b(this);if(this.sortDisabled)g.find("span.ui-icon").removeClass(d+" ui-icon");else{c=g.hasClass(f.cssAsc)? i[1]:g.hasClass(f.cssDesc)?i[2]:g.hasClass(f.cssHeader)?i[0]:"";j=h.hasClass("hasStickyHeaders")?h.find("tr."+(k.stickyHeaders||"tablesorter-stickyHeader")).find("th").eq(a).add(g):g;j[c===i[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(d).addClass(c)}});f.debug&&b.tablesorter.benchmark("Applying uitheme widget",e)}});
|
||||
b.tablesorter.addWidget({id:"columns",format:function(a){var e,c,d,g,j,h,f,k,i=a.config,o=b(a).children("tbody:not(."+i.cssInfoBlock+")"),m=i.sortList, p=m.length,n=["primary","secondary","tertiary"],n=i.widgetColumns&&i.widgetColumns.hasOwnProperty("css")?i.widgetColumns.css||n:i.widgetOptions&&i.widgetOptions.hasOwnProperty("columns")?i.widgetOptions.columns||n:n;j=n.length-1;h=n.join(" ");i.debug&&(g=new Date);for(k=0;k<o.length;k++)a=b(o[k]),e=a.addClass("tablesorter-hidden").children("tr"),e.each(function(){d=b(this);if("none"!==this.style.display&&(c=d.children().removeClass(h),m&&m[0]&&(c.eq(m[0][0]).addClass(n[0]),1<p)))for(f=1;f<p;f++)c.eq(m[f][0]).addClass(n[f]|| n[j])}),a.removeClass("tablesorter-hidden");i.debug&&b.tablesorter.benchmark("Applying Columns widget",g)}});
|
||||
b.tablesorter.addWidget({id:"filter",format:function(a){if(!b(a).hasClass("hasFilters")){var e,c,d,g,j,h,f,k,i,o,m,p,n,l=a.config,q=l.widgetOptions,r=q.filter_cssFilter||"tablesorter-filter",s=b(a).addClass("hasFilters"),u=s.children("tbody:not(."+l.cssInfoBlock+")"),v=l.parsers.length,a='<tr class="'+r+'">',y=RegExp(l.cssChildRow),t,w,x=function(){l.debug&&(t=new Date);h=s.find("thead").eq(0).children("tr").find("input."+ r).map(function(){e=b(this).val()||"";return q.filter_ignoreCase?e.toLocaleLowerCase():e}).get();j=h.join("");for(d=0;d<u.length;d++){m=b(u[d]);p=m.addClass("tablesorter-hidden").children("tr");g=p.length;for(c=0;c<g;c++)if(""===j)p[c].style.display="";else if(!y.test(p[c].className)){f=!0;o=p.eq(c).nextUntil("tr:not(."+l.cssChildRow+")");k=o.length&&(q&&q.hasOwnProperty("filter_childRows")&&"undefined"!==typeof q.filter_childRows?q.filter_childRows:1)?o.text():"";n=p.eq(c).children("td");for(e=0;e< v;e++)""!==h[e]&&(i=b.trim(n.eq(e).text()+k),i=(q.filter_ignoreCase?i.toLocaleLowerCase():i).indexOf(h[e]),f=!q.filter_startsWith&&0<=i||q.filter_startsWith&&0===i?f?!0:!1:!1);p[c].style.display=f?"":"none";if(o.length)o[f?"show":"hide"]()}m.removeClass("tablesorter-hidden")}l.debug&&b.tablesorter.benchmark("Completed filter widget search",t);s.trigger("applyWidgets")};l.debug&&(t=new Date);for(e=0;e<v;e++)a+='<td><input type="search" data-col="'+e+'" class="'+r,a=b.tablesorter.getData?a+("false"=== b.tablesorter.getData(l.headerList[e],l.headers[e],"filter")?' disabled" disabled':'"'):a+(l.headers[e]&&l.headers[e].hasOwnProperty("filter")&&!1===l.headers[e].filter||b(l.headerList[e]).is(".filter-false")?' disabled" disabled':'"'),a+="></td>";s.find("thead").eq(0).append(a+="</tr>").find("input."+r).bind("keyup search",function(b,a){32>b.which&&8!==b.which||37<=b.which&&40>=b.which||(!1===a?x():(clearTimeout(w),w=setTimeout(function(){x()},q.filter_searchDelay||300)))});l.debug&&b.tablesorter.benchmark("Applying Filter widget", t)}}});
|
||||
b.tablesorter.addWidget({id:"stickyHeaders",format:function(a){if(!b(a).hasClass("hasStickyHeaders")){var e=b(a).addClass("hasStickyHeaders"),c=a.config.widgetOptions,d=b(window),g=b(a).children("thead"),j=g.children("tr:not(.sticky-false)").children(),h=c.stickyHeaders||"tablesorter-stickyHeader",f=j.eq(0),k=e.find("tfoot"),i=g.find("tr.tablesorter-header:not(.sticky-false)").clone().removeClass("tablesorter-header").addClass(h).css({width:g.outerWidth(!0),position:"fixed",left:f.offset().left, margin:0,top:0,visibility:"hidden",zIndex:10}),o=i.children(),m="";e.bind("sortEnd",function(a,c){var d=b(c).find("thead tr"),e=d.filter("."+h).children();d.filter(":not(."+h+")").children().each(function(a){e.eq(a).attr("class",b(this).attr("class"))})}).bind("pagerComplete",function(){d.resize()});j.each(function(a){var c=b(this);o.eq(a).bind("mouseup",function(b){c.trigger(b,!0)}).bind("mousedown",function(){this.onselectstart=function(){return!1};return!1}).find(".tablesorter-header-inner").width(c.find(".tablesorter-header-inner").width())}); g.prepend(i);d.scroll(function(){var b=f.offset(),a=d.scrollTop(),c=e.height()-(f.height()+(k.height()||0)),a=a>b.top&&a<b.top+c?"visible":"hidden";i.css({left:b.left-d.scrollLeft(),visibility:a});a!==m&&(d.resize(),m=a)}).resize(function(){var a=0;i.css({left:f.offset().left-d.scrollLeft(),width:g.outerWidth()}).each(function(c){b(this).css("top",a);a+=g.find("tr").eq(c).outerHeight()});o.find(".tablesorter-header-inner").each(function(a){b(this).width(j.eq(a).find(".tablesorter-header-inner").width())})})}}});
|
||||
b.tablesorter.addWidget({id:"resizable",format:function(a){if(!b(a).hasClass("hasResizable")){b(a).addClass("hasResizable");var e,c,d=a.config,g=b(d.headerList).filter(":gt(0)"),j=0,h=null,f=null,k=function(){j=0;h=f=null;b(window).trigger("resize")};if(c=b.tablesorter.storage?b.tablesorter.storage(a,"tablesorter-resizable"):"")for(e in c)!isNaN(e)&&e<d.headerList.length&&b(d.headerList[e]).width(c[e]);g.each(function(){b(this).append('<div class="tablesorter-resizer" style="cursor:w-resize;position:absolute;height:100%;width:20px;left:-20px;top:0;z-index:1;"></div>').wrapInner('<div style="position:relative;height:100%;width:100%"></div>')}).bind("mousemove", function(b){if(0!==j&&h){var a=b.pageX-j;h.width()<-a||f&&f.width()<=a||(f.width(f.width()+a),j=b.pageX)}}).bind("mouseup",function(){c&&(b.tablesorter.storage&&h)&&(c[f.index()]=f.width(),b.tablesorter.storage(a,"tablesorter-resizable",c));k();return!1}).find(".tablesorter-resizer").bind("mousedown",function(a){h=b(a.target).closest("th");f=h.prev();j=a.pageX;return!1});b(a).find("thead").bind("mouseup mouseleave",function(){k()})}}});
|
||||
b.tablesorter.addWidget({id:"saveSort",init:function(a,b,c){c.format(a, !0)},format:function(a,e){var c,d,g=a.config;c={sortList:g.sortList};g.debug&&(d=new Date);b(a).hasClass("hasSaveSort")?a.hasInitialized&&b.tablesorter.storage&&(b.tablesorter.storage(a,"tablesorter-savesort",c),g.debug&&b.tablesorter.benchmark("saveSort widget: Saving last sort: "+g.sortList,d)):(b(a).addClass("hasSaveSort"),c="",b.tablesorter.storage&&(c=(c=b.tablesorter.storage(a,"tablesorter-savesort"))&&c.hasOwnProperty("sortList")&&b.isArray(c.sortList)?c.sortList:"",g.debug&&b.tablesorter.benchmark("saveSort: Last sort loaded: "+ c,d)),e&&c&&0<c.length?g.sortList=c:a.hasInitialized&&(c&&0<c.length)&&b(a).trigger("sorton",[c]))}})
|
||||
})(jQuery);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tablesorter",
|
||||
"version": "2.3.4",
|
||||
"version": "2.3.5",
|
||||
"title": "tablesorter",
|
||||
"author": {
|
||||
"name": "Christian Bach",
|
||||
|
Loading…
Reference in New Issue
Block a user