Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

sortReset, saveSort widget & pager fix

  • Loading branch information...
commit 3a848676ddd606ddd819c11e2a7e30010d2ed9e7 1 parent 6d3b5b3
@Mottie authored
View
10 README.markdown
@@ -34,6 +34,16 @@ Included all original [document pages](http://mottie.github.com/tablesorter/docs
View the [complete listing here](http://mottie.github.com/tablesorter/changelog.txt).
+####Version 2.0.27 (2012-1-31)
+
+* Added `sortReset` option
+ * Setting this option to `true`, allows you to click on the header a third time to clear the sort
+ * Clearing the sort DOES NOT return the table to it's initial unsorted state.
+* Added `saveSort` widget
+ * This widget will save the last sort to local storage, and will fallback to cookies.
+ * The widget does use the `JSON.stringify` function which is [not fully supported](http://caniuse.com/#search=json) (IE7), so if you plan to support it and use this widget, please include this [JSON library](https://github.com/douglascrockford/JSON-js).
+* Fixed pager page size not sticking. Fix for [issue #24](https://github.com/Mottie/tablesorter/issues/24).
+
####Version 2.0.26 (2012-1-30)
* Widgets should no longer be applied twice when an initial sort direction is added. Fix for [issue #21](https://github.com/Mottie/tablesorter/issues/21).
View
4 addons/pager/jquery.tablesorter.pager.js
@@ -1,6 +1,6 @@
/*
* tablesorter pager plugin
- * updated 10/28/2011
+ * updated 1/31/2012
*/
(function($) {
@@ -125,7 +125,7 @@
},
setPageSize = function(table, size, c) {
- c.size = size;
+ c.size = c.lastSize = size;
c.totalPages = Math.ceil(c.totalRows / c.size);
c.pagerPositionSet = false;
moveToPage(table, c);
View
4 addons/pager/jquery.tablesorter.pager.min.js
@@ -1,2 +1,2 @@
-/* tablesorter pager plugin - updated 10/28/2011 */
-(function(d){d.extend({tablesorterPager:new function(){var m=function(c){var a=c.cssDisabled;c.updateArrows&&(c.container[c.totalRows<c.size?"addClass":"removeClass"](a),d(c.cssFirst+","+c.cssPrev,c.container)[c.page===0?"addClass":"removeClass"](a),d(c.cssNext+","+c.cssLast,c.container)[c.page===c.totalPages-1?"addClass":"removeClass"](a))},q=function(c,a){a.startRow=a.size*a.page+1;a.endRow=Math.min(a.totalRows,a.size*(a.page+1));var b=d(a.cssPageDisplay,a.container),e=a.output.replace(/\{(page|totalPages|startRow|endRow|totalRows)\}/gi, function(b){return{"{page}":a.page+1,"{totalPages}":a.totalPages,"{startRow}":a.startRow,"{endRow}":a.endRow,"{totalRows}":a.totalRows}[b]});b[0].tagName==="INPUT"?b.val(e):b.html(e);m(a);a.container.show();d(c).trigger("pagerComplete",a)},n=function(c,a){var b=d(c);if(!a.pagerPositionSet&&a.positionFixed)b.offset&&a.container.css({top:b.offset().top+b.height()+a.offset+"px",position:"absolute"}),a.pagerPositionSet=true},j=function(c,a){var b,e=d("tr",c.tBodies[0]),g=e.length,f=a.page*a.size,i=f+ a.size;i>g&&(i=g);for(b=0;b<g;b++)e[b].style.display=b>=f&&b<i?"":"none"},o=function(c,a){a.size=a.lastSize=parseInt(d(a.cssPageSize,a.container).val(),10);m(a);a.removeRows||(j(c,a),d(c).bind("sortEnd.pager",function(){j(c,a);d(c).trigger("applyWidgets")}))},h=function(c,a,b){var e,g,h,i=d(c.tBodies[0]),k=a.length;e=b.page*b.size;var l=e+b.size;if(!(k<1)){d(c).trigger("pagerChange",b);if(b.removeRows){if(l>a.length)l=a.length;for(d.tablesorter.clearTableBody(c);e<l;e++){h=a[e];k=h.length;for(g=0;g< k;g++)i[0].appendChild(h[g])}}else j(c,b);n(c,i,b);d(c).trigger("applyWidgets");if(b.page>=b.totalPages)b.page=b.totalPages-1,f(c,b);q(c,b)}},p=function(c,a){a.lastPage=a.page;a.lastSize=a.size;a.size=a.totalRows;a.totalPages=1;h(c,a.rowsCopy,a)},f=function(c,a){if(!a.isDisabled){if(a.page<0||a.page>a.totalPages-1)a.page=0;h(c,a.rowsCopy,a)}};this.appender=function(c,a){var b=c.config;b.rowsCopy=a;b.totalRows=a.length;b.size=b.lastSize||b.size;b.totalPages=Math.ceil(b.totalRows/b.size);h(c,a,b)}; this.defaults={container:null,output:"{startRow} to {endRow} of {totalRows} rows",updateArrows:true,page:0,size:10,positionFixed:true,offset:0,removeRows:true,cssNext:".next",cssPrev:".prev",cssFirst:".first",cssLast:".last",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",cssDisabled:"disabled",totalRows:0,totalPages:0,appender:this.appender};this.construct=function(c){return this.each(function(){var a=d.extend(this.config,d.tablesorterPager.defaults,c),b=this,e=a.container;d(this).trigger("appendCache"); o(b,a);d(a.cssFirst,e).unbind("click.pager").bind("click.pager",function(){a.page=0;f(b,a);return false});d(a.cssNext,e).unbind("click.pager").bind("click.pager",function(){a.page++;if(a.page>=a.totalPages-1)a.page=a.totalPages-1;f(b,a);return false});d(a.cssPrev,e).unbind("click.pager").bind("click.pager",function(){a.page--;if(a.page<=0)a.page=0;f(b,a);return false});d(a.cssLast,e).unbind("click.pager").bind("click.pager",function(){a.page=a.totalPages-1;f(b,a);return false});d(a.cssPageSize,e).unbind("change.pager").bind("change.pager", function(){var c=parseInt(d(this).val(),10);a.size=c;a.totalPages=Math.ceil(a.totalRows/a.size);a.pagerPositionSet=false;f(b,a);n(b,a);return false});d(this).unbind("disable.pager enable.pager destroy.pager").bind("disable.pager",function(){a.isDisabled=true;p(b,a)}).bind("enable.pager",function(){a.isDisabled=false;d("table").trigger("update");a.page=a.lastPage||0;a.totalPages=Math.ceil(a.totalRows/a.size);o(b,a)}).bind("destroy.pager",function(){p(b,a);a.container.hide();a.appender=null;d(b).unbind("destroy.pager sortEnd.pager enable.pager disable.pager")})})}}}); d.fn.extend({tablesorterPager:d.tablesorterPager.construct})})(jQuery);
+/* tablesorter pager plugin - updated 1/31/2012 */
+(function(d){d.extend({tablesorterPager:new function(){var m=function(c){var a=c.cssDisabled;c.updateArrows&&(c.container[c.totalRows<c.size?"addClass":"removeClass"](a),d(c.cssFirst+","+c.cssPrev,c.container)[0===c.page?"addClass":"removeClass"](a),d(c.cssNext+","+c.cssLast,c.container)[c.page===c.totalPages-1?"addClass":"removeClass"](a))},q=function(c,a){a.startRow=a.size*a.page+1;a.endRow=Math.min(a.totalRows,a.size*(a.page+1));var b=d(a.cssPageDisplay,a.container),e=a.output.replace(/\{(page|totalPages|startRow|endRow|totalRows)\}/gi, function(b){return{"{page}":a.page+1,"{totalPages}":a.totalPages,"{startRow}":a.startRow,"{endRow}":a.endRow,"{totalRows}":a.totalRows}[b]});"INPUT"===b[0].tagName?b.val(e):b.html(e);m(a);a.container.show();d(c).trigger("pagerComplete",a)},n=function(c,a){var b=d(c);!a.pagerPositionSet&&a.positionFixed&&(b.offset&&a.container.css({top:b.offset().top+b.height()+a.offset+"px",position:"absolute"}),a.pagerPositionSet=!0)},j=function(c,a){var b,e=d("tr",c.tBodies[0]),g=e.length,f=a.page*a.size,i=f+a.size; i>g&&(i=g);for(b=0;b<g;b++)e[b].style.display=b>=f&&b<i?"":"none"},o=function(c,a){a.size=a.lastSize=parseInt(d(a.cssPageSize,a.container).val(),10);m(a);a.removeRows||(j(c,a),d(c).bind("sortEnd.pager",function(){j(c,a);d(c).trigger("applyWidgets")}))},h=function(c,a,b){var e,g,h,i=d(c.tBodies[0]),k=a.length;e=b.page*b.size;var l=e+b.size;if(!(1>k)){d(c).trigger("pagerChange",b);if(b.removeRows){l>a.length&&(l=a.length);for(d.tablesorter.clearTableBody(c);e<l;e++){h=a[e];k=h.length;for(g=0;g<k;g++)i[0].appendChild(h[g])}}else j(c, b);n(c,i,b);d(c).trigger("applyWidgets");b.page>=b.totalPages&&(b.page=b.totalPages-1,f(c,b));q(c,b)}},p=function(c,a){a.lastPage=a.page;a.lastSize=a.size;a.size=a.totalRows;a.totalPages=1;h(c,a.rowsCopy,a)},f=function(c,a){if(!a.isDisabled){if(0>a.page||a.page>a.totalPages-1)a.page=0;h(c,a.rowsCopy,a)}};this.appender=function(c,a){var b=c.config;b.rowsCopy=a;b.totalRows=a.length;b.size=b.lastSize||b.size;b.totalPages=Math.ceil(b.totalRows/b.size);h(c,a,b)};this.defaults={container:null,output:"{startRow} to {endRow} of {totalRows} rows", updateArrows:!0,page:0,size:10,positionFixed:!0,offset:0,removeRows:!0,cssNext:".next",cssPrev:".prev",cssFirst:".first",cssLast:".last",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",cssDisabled:"disabled",totalRows:0,totalPages:0,appender:this.appender};this.construct=function(c){return this.each(function(){var a=d.extend(this.config,d.tablesorterPager.defaults,c),b=this,e=a.container;d(this).trigger("appendCache");o(b,a);d(a.cssFirst,e).unbind("click.pager").bind("click.pager",function(){a.page= 0;f(b,a);return!1});d(a.cssNext,e).unbind("click.pager").bind("click.pager",function(){a.page++;a.page>=a.totalPages-1&&(a.page=a.totalPages-1);f(b,a);return!1});d(a.cssPrev,e).unbind("click.pager").bind("click.pager",function(){a.page--;0>=a.page&&(a.page=0);f(b,a);return!1});d(a.cssLast,e).unbind("click.pager").bind("click.pager",function(){a.page=a.totalPages-1;f(b,a);return!1});d(a.cssPageSize,e).unbind("change.pager").bind("change.pager",function(){var c=parseInt(d(this).val(),10);a.size=a.lastSize= c;a.totalPages=Math.ceil(a.totalRows/a.size);a.pagerPositionSet=!1;f(b,a);n(b,a);return!1});d(this).unbind("disable.pager enable.pager destroy.pager").bind("disable.pager",function(){a.isDisabled=!0;p(b,a)}).bind("enable.pager",function(){a.isDisabled=!1;d("table").trigger("update");a.page=a.lastPage||0;a.totalPages=Math.ceil(a.totalRows/a.size);o(b,a)}).bind("destroy.pager",function(){p(b,a);a.container.hide();a.appender=null;d(b).unbind("destroy.pager sortEnd.pager enable.pager disable.pager")})})}}}); d.fn.extend({tablesorterPager:d.tablesorterPager.construct})})(jQuery);
View
11 changelog.txt
@@ -1,5 +1,16 @@
TableSorter Change Log
+Version 2.0.27 (2012-1-31)
+============================
+
+* Added `sortReset` option
+ * Setting this option to `true`, allows you to click on the header a third time to clear the sort
+ * Clearing the sort DOES NOT return the table to it's initial unsorted state.
+* Added `saveSort` widget
+ * This widget will save the last sort to local storage, and will fallback to cookies.
+ * The widget does use the `JSON.stringify` function which is [not fully supported](http://caniuse.com/#search=json) (IE7), so if you plan to support it and use this widget, please include this [JSON library](https://github.com/douglascrockford/JSON-js).
+* Fixed pager page size not sticking. Fix for [issue #24](https://github.com/Mottie/tablesorter/issues/24).
+
Version 2.0.26 (2012-1-30)
============================
View
2  docs/example-widget-resizable.html
@@ -125,7 +125,7 @@
<div class="next-up">
<hr />
- Next up: <a href="example-widget-sticky-header.html">Applying the sticky header widget &rsaquo;&rsaquo;</a>
+ Next up: <a href="example-widget-savesort.html">Applying the save sort widget &rsaquo;&rsaquo;</a>
</div>
</div>
View
130 docs/example-widget-savesort.html
@@ -0,0 +1,130 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>jQuery plugin: Tablesorter 2.0 - Save Sort Widget</title>
+
+ <!-- jQuery -->
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
+
+ <!-- Demo stuff -->
+ <link rel="stylesheet" href="css/jq.css">
+ <script src="js/chili/jquery.chili-2.2.js"></script>
+ <script src="js/chili/recipes.js"></script>
+ <script src="js/docs.js"></script>
+
+ <!-- Tablesorter: required -->
+ <link rel="stylesheet" href="../css/blue/style.css">
+ <script src="../js/jquery.tablesorter.js"></script>
+ <script src="../js/jquery.tablesorter.widgets.js"></script>
+
+ <script id="js">$(function() {
+
+ // call the tablesorter plugin
+ $("table").tablesorter({
+
+ // use save sort widget
+ widgets: ["saveSort"]
+
+ });
+
+});</script>
+</head>
+<body>
+<div id="banner">
+ <h1>table<em>sorter</em></h1>
+ <h2>Save Sort Widget</h2>
+ <h3>Flexible client-side table sorting</h3>
+ <a href="index.html">Back to documentation</a>
+</div>
+<div id="main">
+
+ <p class="tip">
+ <em>NOTE!</em>
+ <ul>
+ <li>This widget can be applied to the original plugin. The code is in the "jquery.tablesorter.widgets.js" file.</li>
+ <li>Sort one or more columns, then reload the page to see that this widget remembers the last table sort.</li>
+ </ul>
+ </p>
+
+ <h1>Demo</h1>
+ <div id="demo"><table class="tablesorter">
+ <thead>
+ <tr>
+ <th>Account #</th>
+ <th>First Name</th>
+ <th>Last Name</th>
+ <th>Age</th>
+ <th>Total</th>
+ <th>Discount</th>
+ <th>Diff</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>A43</td>
+ <td>Peter</td>
+ <td>Parker</td>
+ <td>28</td>
+ <td>9.99</td>
+ <td>20.3%</td>
+ <td>+3</td>
+ </tr>
+ <tr>
+ <td>A255</td>
+ <td>John</td>
+ <td>Hood</td>
+ <td>33</td>
+ <td>19.99</td>
+ <td>25.1%</td>
+ <td>-7</td>
+ </tr>
+ <tr>
+ <td>A33</td>
+ <td>Clark</td>
+ <td>Kent</td>
+ <td>18</td>
+ <td>15.89</td>
+ <td>44.2%</td>
+ <td>-15</td>
+ </tr>
+ <tr>
+ <td>A1</td>
+ <td>Bruce</td>
+ <td>Almighty</td>
+ <td>45</td>
+ <td>153.19</td>
+ <td>44%</td>
+ <td>+19</td>
+ </tr>
+ <tr>
+ <td>A102</td>
+ <td>Bruce</td>
+ <td>Evans</td>
+ <td>56</td>
+ <td>153.19</td>
+ <td>23%</td>
+ <td>+9</td>
+ </tr>
+ </tbody>
+</table></div>
+
+ <h1>Javascript</h1>
+ <div id="javascript">
+ <pre class="js"></pre>
+ </div>
+ <h1>HTML</h1>
+ <div id="html">
+ <pre class="html"></pre>
+ </div>
+
+<div class="next-up">
+ <hr />
+ Next up: <a href="example-widget-sticky-header.html">Applying the sticky header widget &rsaquo;&rsaquo;</a>
+</div>
+
+</div>
+
+</body>
+</html>
+
View
31 docs/index.html
@@ -89,8 +89,8 @@
<li><a href="#Getting-Started">Getting started</a></li>
<li><a href="#Examples">Examples</a></li>
<li><a href="#Configuration">Configuration</a></li>
- <li><a href="#Methods">Methods</a> <span class="tip"><em>New!</em></span></li>
- <li><a href="#Events">Events</a> <span class="tip"><em>New!</em></span></li>
+ <li><a href="#Methods">Methods</a></li>
+ <li><a href="#Events">Events</a></li>
<li><a href="#Download">Download</a></li>
<li><a href="#Compatibility">Compatibility</a></li>
<li><a href="#Support">Support</a></li>
@@ -307,8 +307,8 @@
<h4>Parsers / Extracting Content</h4>
<ul>
<li><a href="example-option-digits.html">Dealing with digits!</a></li>
- <li><a href="example-options-headers-digits-strings.html">Dealing with text strings in numerical sorts</a> <span class="tip"><em>New! v2.0.10</em></span></li>
- <li><a href="example-parsers-class-name.html">Disable or set the column parser using class names</a> <span class="tip"><em>New! v2.0.11</em></span></li>
+ <li><a href="example-options-headers-digits-strings.html">Dealing with text strings in numerical sorts</a> (v2.0.10)</li>
+ <li><a href="example-parsers-class-name.html">Disable or set the column parser using class names</a> (v2.0.11)</li>
<li><a href="example-option-date-format.html">Changing the date format</a> <span class="tip"><em>New! v2.0.23</em></span></li>
<li><a href="example-parsers.html">Parser, writing your own</a></li>
<li><a href="example-option-text-extraction.html">Dealing with markup inside cells (textExtraction function)</a></li>
@@ -317,11 +317,12 @@
<h4>Widgets / Plugins</h4>
<ul>
<li><a href="example-apply-widget.html">Applying widgets</a></li>
- <li><a href="example-widget-columns.html">Columns widget</a> <span class="tip"><em>New! v2.0.17</em></span></li>
- <li><a href="example-widget-filter.html">Filter widget</a> <span class="tip"><em>New! v2.0.18</em></span></li>
- <li><a href="example-widget-ui-theme.html">jQuery UI theme widget</a> <span class="tip"><em>New! v2.0.9</em></span></li>
+ <li><a href="example-widget-columns.html">Columns widget</a> (v2.0.17)</li>
+ <li><a href="example-widget-filter.html">Filter widget</a> (v2.0.18)</li>
+ <li><a href="example-widget-ui-theme.html">jQuery UI theme widget</a> (v2.0.9)</li>
<li><a href="example-widget-resizable.html">Resizable Columns widget</a> <span class="tip"><em>New! v2.0.23.1</em></span></li>
- <li><a href="example-widget-sticky-header.html">Sticky header widget</a> <span class="tip"><em>New! v2.0.21.1</em></span></li>
+ <li><a href="example-widget-savesort.html">Save sort widget</a> <span class="tip"><em>New! v2.0.27</em></span></li>
+ <li><a href="example-widget-sticky-header.html">Sticky header widget</a> (v2.0.21.1)</li>
<li><a href="example-widget-zebra.html">Zebra stripe widget</a></li>
<li><a href="example-widgets.html">Widgets, writing your own</a></li>
<li><a href="example-pager.html">Pager plugin</a></li>
@@ -334,14 +335,14 @@
<ul>
<li><a href="example-empty-table.html">Initializing tablesorter on a empty table</a></li>
<li><a href="example-ajax.html">Appending table data with ajax</a></li>
- <li><a href="example-add-rows.html">Adding a table row</a> <span class="tip"><em>New! v2.0.16</em></span></li>
+ <li><a href="example-add-rows.html">Adding a table row</a> (v2.0.16)</li>
<li><a href="example-update-cell.html">Update the table after cell content has changed</a></li>
<li><a href="example-pager.html">Pager plugin</a> - examples of how to add and remove rows</li>
</ul>
<h4>Change Header Style</h4>
<ul>
- <li><a href="example-widget-ui-theme.html">jQuery UI theme widget</a> <span class="tip"><em>New! v2.0.9</em></span></li>
+ <li><a href="example-widget-ui-theme.html">jQuery UI theme widget</a> (v2.0.9)</li>
<li><a href="example-option-render-header.html">Modify how the header is rendered to allow for custom styling</a></li>
</ul>
@@ -740,6 +741,16 @@
<td></td>
</tr>
+ <tr id="sortreset">
+ <td>sortReset</td>
+ <td>Boolean</td>
+ <td>false</td>
+ <td>
+ Setting this option to <code class="hilight">true</code> will allow you to click on the table header a third time to reset the sort direction. However, it does not restore the original sort order, it merely clear the sort from the header. <span class="tip"><em>New!</em></span> in v2.0.27.
+ </td>
+ <td></td>
+ </tr>
+
<tr id="sortmultisortkey">
<td>sortMultiSortKey</td>
<td>String</td>
View
15 js/jquery.tablesorter.js
@@ -1,6 +1,6 @@
/*
* TableSorter 2.0 - Client-side table sorting with ease!
-* Version 2.0.26
+* Version 2.0.27
* @requires jQuery v1.2.3
*
* Copyright (c) 2007 Christian Bach
@@ -462,6 +462,7 @@
});
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]]);
}
}
@@ -639,7 +640,7 @@
// get current column index
i = this.column;
// get current column sort order
- this.order = this.count++ % 2;
+ this.order = this.count++ % (config.sortReset ? 3 : 2);
// always sort on the locked order.
if(typeof(this.lockedOrder) !== "undefined" && this.lockedOrder !== false) { this.order = this.lockedOrder; }
// user only wants to sort on one column
@@ -655,7 +656,7 @@
}
}
// add column to sort list
- config.sortList.push([i, this.order]);
+ if (this.order < 2) { config.sortList.push([i, this.order]); }
// multi column sorting
} else {
// the user has clicked on an already sorted column.
@@ -667,12 +668,16 @@
if (s[0] === i) {
o.count = s[1];
o.count++;
- s[1] = o.count % 2;
+ s[1] = o.count % (config.sortReset ? 3 : 2);
+ if (s[1] >= 2) {
+ config.sortList.splice(j,1);
+ o.count = 0;
+ }
}
}
} else {
// add column to sort list array
- config.sortList.push([i, this.order]);
+ if (this.order < 2) { config.sortList.push([i, this.order]); }
}
}
if (config.sortAppend !== null) {
View
4 js/jquery.tablesorter.min.js
@@ -1,7 +1,7 @@
/*
* TableSorter 2.0 - Client-side table sorting with ease!
-* Version 2.0.26 Minified using http://dean.edwards.name/packer/
+* Version 2.0.27 Minified using http://dean.edwards.name/packer/
* Copyright (c) 2007 Christian Bach
*/
-(function($){$.extend({tablesorter:new function(){var g=[],widgets=[],tbl;this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:false,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"mmddyyyy",onRenderHeader:null,selectorHeaders:'thead th',tableClass:'tablesorter',debug:false};function log(s){if(typeof console!=="undefined"&&typeof console.debug!=="undefined"){console.log(s)}else{alert(s)}}function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms")}this.benchmark=benchmark;function getElementText(a,b,c){var d="",te=a.textExtraction;if(!b){return""}if(!a.supportsTextContent){a.supportsTextContent=b.textContent||false}if(te==="simple"){if(a.supportsTextContent){d=b.textContent}else{if(b.childNodes[0]&&b.childNodes[0].hasChildNodes()){d=b.childNodes[0].innerHTML}else{d=b.innerHTML}}}else{if(typeof(te)==="function"){d=te(b)}else if(typeof(te)==="object"&&te.hasOwnProperty(c)){d=te[c](b)}else{d=$(b).text()}}return d}function getParserById(a){var i,l=g.length;for(i=0;i<l;i++){if(g[i].id.toLowerCase()===a.toLowerCase()){return g[i]}}return false}function getNodeFromRowAndCellIndex(a,b,c){return a[b].cells[c]}function trimAndGetNodeText(a,b,c){return $.trim(getElementText(a,b,c))}function detectParserForColumn(a,b,c,d){var i,l=g.length,node=false,nodeValue='',keepLooking=true;while(nodeValue===''&&keepLooking){c++;if(b[c]){node=getNodeFromRowAndCellIndex(b,c,d);nodeValue=trimAndGetNodeText(a.config,node,d);if(a.config.debug){log('Checking if value was empty on row:'+c)}}else{keepLooking=false}}for(i=1;i<l;i++){if(g[i].is(nodeValue,a,node)){return g[i]}}return g[0]}function buildParserCache(a,b){if(a.tBodies.length===0){return}var c=a.tBodies[0].rows,list,cells,l,h,i,p,parsersDebug="";if(c[0]){list=[];cells=c[0].cells;l=cells.length;for(i=0;i<l;i++){p=false;h=$(b[i]);if($.metadata&&(h.metadata()&&h.metadata().sorter)){p=getParserById(h.metadata().sorter)}else if((a.config.headers[i]&&a.config.headers[i].sorter)){p=getParserById(a.config.headers[i].sorter)}else if(h.attr('class')&&h.attr('class').match('sorter-')){p=getParserById(h.attr('class').match(/sorter-(\w+)/)[1]||'')}if(!p){p=detectParserForColumn(a,c,-1,i)}if(a.config.debug){parsersDebug+="column:"+i+" parser:"+p.id+"\n"}list.push(p)}}if(a.config.debug){log(parsersDebug)}return list}function buildCache(a){var b=a.tBodies[0],totalRows=(b&&b.rows.length)||0,totalCells=(b.rows[0]&&b.rows[0].cells.length)||0,g=a.config.parsers,cache={row:[],normalized:[]},t,i,j,c,cols,cacheTime;if(a.config.debug){cacheTime=new Date()}for(i=0;i<totalRows;++i){c=$(b.rows[i]);cols=[];if(c.hasClass(a.config.cssChildRow)){cache.row[cache.row.length-1]=cache.row[cache.row.length-1].add(c);continue}cache.row.push(c);for(j=0;j<totalCells;++j){t=trimAndGetNodeText(a.config,c[0].cells[j],j);cols.push(t===''?'':g[j].format(t,a,c[0].cells[j],j))}cols.push(cache.normalized.length);cache.normalized.push(cols)}if(a.config.debug){benchmark("Building cache for "+totalRows+" rows:",cacheTime)}a.config.cache=cache;return cache}function getWidgetById(a){var i,w,l=widgets.length;for(i=0;i<l;i++){w=widgets[i];if(w&&w.hasOwnProperty('id')&&w.id.toLowerCase()===a.toLowerCase()){return w}}}function applyWidget(a){var c=a.config.widgets,i,w,l=c.length;for(i=0;i<l;i++){w=getWidgetById(c[i]);if(w&&w.hasOwnProperty('format')){w.format(a)}}}function appendToTable(a,b){var c=a.config,r=b.row,n=b.normalized,totalRows=n.length,checkCell=totalRows?(n[0].length-1):0,rows=[],i,j,l,pos,appendTime;if(c.debug){appendTime=new Date()}for(i=0;i<totalRows;i++){pos=n[i][checkCell];rows.push(r[pos]);if(!c.appender||!c.removeRows){l=r[pos].length;for(j=0;j<l;j++){a.tBodies[0].appendChild(r[pos][j])}}}if(c.appender){c.appender(a,rows)}if(c.debug){benchmark("Rebuilt table:",appendTime)}applyWidget(a);setTimeout(function(){$(a).trigger("sortEnd",a)},0)}function computeTableHeaderCellIndexes(t){var a=[],lookup={},thead=t.getElementsByTagName('THEAD')[0],trs=thead.getElementsByTagName('TR'),i,j,k,l,c,cells,rowIndex,cellId,rowSpan,colSpan,firstAvailCol,matrixrow;for(i=0;i<trs.length;i++){cells=trs[i].cells;for(j=0;j<cells.length;j++){c=cells[j];rowIndex=c.parentNode.rowIndex;cellId=rowIndex+"-"+c.cellIndex;rowSpan=c.rowSpan||1;colSpan=c.colSpan||1;if(typeof(a[rowIndex])==="undefined"){a[rowIndex]=[]}for(k=0;k<a[rowIndex].length+1;k++){if(typeof(a[rowIndex][k])==="undefined"){firstAvailCol=k;break}}lookup[cellId]=firstAvailCol;for(k=rowIndex;k<rowIndex+rowSpan;k++){if(typeof(a[k])==="undefined"){a[k]=[]}matrixrow=a[k];for(l=firstAvailCol;l<firstAvailCol+colSpan;l++){matrixrow[l]="x"}}}}return lookup}function formatSortingOrder(v){if(typeof(v)!=="number"){return(v.toLowerCase().charAt(0)==="d")?1:0}else{return(v===1)?1:0}}function checkHeaderMetadata(a){return(($.metadata)&&($(a).metadata().sorter===false))}function checkHeaderOptions(a,i){return((a.config.headers[i])&&(a.config.headers[i].sorter===false))}function checkHeaderLocked(a,i){if((a.config.headers[i])&&(a.config.headers[i].lockedOrder!==null)){return a.config.headers[i].lockedOrder}return false}function checkHeaderOrder(a,i){if((a.config.headers[i])&&(a.config.headers[i].sortInitialOrder)){return a.config.headers[i].sortInitialOrder}return a.config.sortInitialOrder}function buildHeaders(b){var d=($.metadata)?true:false,header_index=computeTableHeaderCellIndexes(b),$th,lock,time,$tableHeaders,c=b.config;c.headerList=[];if(c.debug){time=new Date()}$tableHeaders=$(c.selectorHeaders,b).wrapInner("<span/>").each(function(a){this.column=header_index[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(checkHeaderOrder(b,a));this.count=this.order;if(checkHeaderMetadata(this)||checkHeaderOptions(b,a)||$(this).is('.sorter-false')){this.sortDisabled=true}this.lockedOrder=false;lock=checkHeaderLocked(b,a);if(typeof(lock)!=='undefined'&&lock!==false){this.order=this.lockedOrder=formatSortingOrder(lock)}if(!this.sortDisabled){$th=$(this).addClass(c.cssHeader);if(c.onRenderHeader){c.onRenderHeader.apply($th,[a])}}c.headerList[a]=this});if(c.debug){benchmark("Built headers:",time);log($tableHeaders)}return $tableHeaders}function checkCellColSpan(a,b,d){var i,cell,arr=[],r=a.tHead.rows,c=r[d].cells;for(i=0;i<c.length;i++){cell=c[i];if(cell.colSpan>1){arr=arr.concat(checkCellColSpan(a,b,d++))}else{if(a.tHead.length===1||(cell.rowSpan>1||!r[d+1])){arr.push(cell)}}}return arr}function isValueInArray(v,a){var i,l=a.length;for(i=0;i<l;i++){if(a[i][0]===v){return true}}return false}function setHeadersCss(b,c,d,e){c.removeClass(e[0]).removeClass(e[1]);var h=[],i,l;c.each(function(a){if(!this.sortDisabled){h[this.column]=$(this)}});l=d.length;for(i=0;i<l;i++){h[d[i][0]].addClass(e[d[i][1]])}}function fixColumnWidth(a,b){if(a.config.widthFixed){var c=$('<colgroup>');$("tr:first td",a.tBodies[0]).each(function(){c.append($('<col>').css('width',$(this).width()))});$(a).prepend(c)}}function updateHeaderSortCount(a,b){var i,s,o,c=a.config,l=b.length;for(i=0;i<l;i++){s=b[i];o=c.headerList[s[0]];o.count=s[1];o.count++}}function getCachedSortType(a,i){return(a)?a[i].type:''}function multisort(a,b,d){var f="var sortWrapper = function(a,b) {",col,mx=0,dir=0,tc=a.config,lc=d.normalized.length,l=b.length,sortTime,i,j,c,s,e,order,orgOrderCol;if(tc.debug){sortTime=new Date()}for(i=0;i<l;i++){c=b[i][0];order=b[i][1];s=(getCachedSortType(tc.parsers,c)==="text")?((order===0)?"sortText":"sortTextDesc"):((order===0)?"sortNumeric":"sortNumericDesc");e="e"+i;if(/Numeric/.test(s)&&tc.headers[c]&&tc.headers[c].string){for(j=0;j<lc;j++){col=Math.abs(parseFloat(d.normalized[j][c]));mx=Math.max(mx,isNaN(col)?0:col)}dir=(tc.headers[c])?tc.string[tc.headers[c].string]||0:0}f+="var "+e+" = "+s+"(a["+c+"],b["+c+"],"+mx+","+dir+"); ";f+="if ("+e+") { return "+e+"; } ";f+="else { "}orgOrderCol=(d.normalized&&d.normalized[0])?d.normalized[0].length-1:0;f+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(i=0;i<l;i++){f+="}; "}f+="return 0; ";f+="}; ";eval(f);d.normalized.sort(sortWrapper);if(tc.debug){benchmark("Sorting on "+b.toString()+" and dir "+order+" time:",sortTime)}return d}function sortText(a,b){if(a===''){return 1}if(b===''){return-1}if(a===b){return 0}if($.data(tbl[0],"tablesorter").sortLocaleCompare){return a.localeCompare(b)}try{var c=0,ax,t,x=/^(\.)?\d/,L=Math.min(a.length,b.length)+1;while(c<L&&a.charAt(c)===b.charAt(c)&&x.test(b.substring(c))===false&&x.test(a.substring(c))===false){c++}a=a.substring(c);b=b.substring(c);if(x.test(a)||x.test(b)){if(x.test(a)===false){return(a)?1:-1}else if(x.test(b)===false){return(b)?-1:1}else{t=parseFloat(a)-parseFloat(b);if(t!==0){return t}else{t=a.search(/[^\.\d]/)}if(t===-1){t=b.search(/[^\.\d]/)}a=a.substring(t);b=b.substring(t)}}return(a>b)?1:-1}catch(er){return 0}}function sortTextDesc(a,b){if(a===''){return 1}if(b===''){return-1}if(a===b){return 0}if($.data(tbl[0],"tablesorter").sortLocaleCompare){return b.localeCompare(a)}return-sortText(a,b)}function getTextValue(a,b,d){if(b){var i,l=a.length,n=b+d;for(i=0;i<l;i++){n+=a.charCodeAt(i)}return d*n}return 0}function sortNumeric(a,b,c,d){if(a===''){return 1}if(b===''){return-1}if(isNaN(a)){a=getTextValue(a,c,d)}if(isNaN(b)){b=getTextValue(b,c,d)}return a-b}function sortNumericDesc(a,b,c,d){if(a===''){return 1}if(b===''){return-1}if(isNaN(a)){a=getTextValue(a,c,d)}if(isNaN(b)){b=getTextValue(b,c,d)}return b-a}this.construct=function(d){return this.each(function(){if(!this.tHead||!this.tBodies){return}var c,$document,$headers,cache,config,shiftDown=0,sortOrder,sortCSS,totalRows,$cell,i,j,a,s,o;this.config={};config=$.extend(this.config,$.tablesorter.defaults,d);tbl=c=$(this).addClass(this.config.tableClass);$.data(this,"tablesorter",config);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);this.config.string={max:1,'max+':1,'max-':-1,none:0};cache=buildCache(this);sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){totalRows=(c[0].tBodies[0]&&c[0].tBodies[0].rows.length)||0;if(!this.sortDisabled){c.trigger("sortStart",tbl[0]);$cell=$(this);i=this.column;this.order=this.count++%2;if(typeof(this.lockedOrder)!=="undefined"&&this.lockedOrder!==false){this.order=this.lockedOrder}if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!==null){a=config.sortForce;for(j=0;j<a.length;j++){if(a[j][0]!==i){config.sortList.push(a[j])}}}config.sortList.push([i,this.order])}else{if(isValueInArray(i,config.sortList)){for(j=0;j<config.sortList.length;j++){s=config.sortList[j];o=config.headerList[s[0]];if(s[0]===i){o.count=s[1];o.count++;s[1]=o.count%2}}}else{config.sortList.push([i,this.order])}}if(config.sortAppend!==null){a=config.sortAppend;for(j=0;j<a.length;j++){if(a[j][0]!==i){config.sortList.push(a[j])}}}c.trigger("sortBegin",tbl[0]);setTimeout(function(){setHeadersCss(c[0],$headers,config.sortList,sortCSS);appendToTable(c[0],multisort(c[0],config.sortList,cache))},1);return false}}).mousedown(function(){if(config.cancelSelection){this.onselectstart=function(){return false};return false}});c.bind("update",function(){var a=this;setTimeout(function(){a.config.parsers=buildParserCache(a,$headers);cache=buildCache(a);c.trigger("sorton",[a.config.sortList])},1)}).bind("updateCell",function(e,a){var b=this.config,pos=[(a.parentNode.rowIndex-1),a.cellIndex];cache.normalized[pos[0]][pos[1]]=b.parsers[pos[1]].format(getElementText(b,a,pos[1]),a);this.config.cache=cache;c.trigger("sorton",[b.sortList])}).bind("addRows",function(e,a){var i,config=this.config,rows=a.filter('tr').length,dat=[],l=a[0].cells.length;for(i=0;i<rows;i++){for(j=0;j<l;j++){dat[j]=config.parsers[j].format(getElementText(config,a[i].cells[j],j),a[i].cells[j])}dat.push(cache.row.length);cache.row.push([a[i]]);cache.normalized.push(dat);dat=[]}config.cache=cache;c.trigger("sorton",[config.sortList])}).bind("sorton",function(e,a){$(this).trigger("sortStart",tbl[0]);config.sortList=a;var b=config.sortList;updateHeaderSortCount(this,b);setHeadersCss(this,$headers,b,sortCSS);appendToTable(this,multisort(this,b,cache))}).bind("appendCache",function(){appendToTable(this,cache)}).bind("applyWidgetId",function(e,a){getWidgetById(a).format(this)}).bind("applyWidgets",function(){applyWidget(this)});if($.metadata&&($(this).metadata()&&$(this).metadata().sortlist)){config.sortList=$(this).metadata().sortlist}if(config.sortList.length>0){c.trigger("sorton",[config.sortList])}else{applyWidget(this)}})};this.addParser=function(b){var i,l=g.length,a=true;for(i=0;i<l;i++){if(g[i].id.toLowerCase()===b.id.toLowerCase()){a=false}}if(a){g.push(b)}};this.addWidget=function(a){widgets.push(a)};this.formatFloat=function(s){var i=parseFloat(s);return isNaN(i)?$.trim(s):i};this.isDigit=function(s){return(/^[\-+]?\d*$/).test($.trim(s.replace(/[,.']/g,'')))};this.clearTableBody=function(a){if($.browser.msie){var b=function(){while(this.firstChild){this.removeChild(this.firstChild)}};b.apply(a.tBodies[0])}else{a.tBodies[0].innerHTML=""}}}})();$.fn.extend({tablesorter:$.tablesorter.construct});var m=$.tablesorter;m.addParser({id:"text",is:function(s){return true},format:function(s){return $.trim(s.toLocaleLowerCase())},type:"text"});m.addParser({id:"digit",is:function(s){return $.tablesorter.isDigit(s.replace(/,/g,""))},format:function(s){return $.tablesorter.formatFloat(s.replace(/,/g,""))},type:"numeric"});m.addParser({id:"currency",is:function(s){return(/^[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]/).test(s)},format:function(s){return $.tablesorter.formatFloat(s.replace(/\,/g,'.').replace(new RegExp(/[^0-9. \-]/g),""))},type:"numeric"});m.addParser({id:"ipAddress",is:function(s){return(/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/).test(s)},format:function(s){var i,item,a=s.split("."),r="",l=a.length;for(i=0;i<l;i++){item=a[i];if(item.length===2){r+="0"+item}else{r+=item}}return $.tablesorter.formatFloat(r)},type:"numeric"});m.addParser({id:"url",is:function(s){return(/^(https?|ftp|file):\/\/$/).test(s)},format:function(s){return $.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),''))},type:"text"});m.addParser({id:"isoDate",is:function(s){return(/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/).test(s)},format:function(s){return $.tablesorter.formatFloat((s!=="")?new Date(s.replace(new RegExp(/-/g),"/")).getTime():"0")},type:"numeric"});m.addParser({id:"percent",is:function(s){return(/\%$/).test($.trim(s))},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""))},type:"numeric"});m.addParser({id:"usLongDate",is:function(s){return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/))},format:function(s){return $.tablesorter.formatFloat(new Date(s).getTime())},type:"numeric"});m.addParser({id:"shortDate",is:function(s){return(/\d{1,4}[\/\-\,\.\s+]\d{1,4}[\/\-\.\,\s+]\d{1,4}/).test(s)},format:function(s,a,b,d){var c=a.config,format=(c.headers&&c.headers[d])?c.headers[d].dateFormat||c.dateFormat:c.dateFormat;s=s.replace(/\s+/g," ").replace(/[\-|\.|\,|\s]/g,"/");if(format==="mmddyyyy"){s=s.replace(/(\d{1,2})\/(\d{1,2})\/(\d{4})/,"$3/$1/$2")}else if(format==="ddmmyyyy"){s=s.replace(/(\d{1,2})\/(\d{1,2})\/(\d{4})/,"$3/$2/$1")}else if(format==="yyyymmdd"){s=s.replace(/(\d{4})\/(\d{1,2})\/(\d{1,2})/,"$1/$2/$3")}return $.tablesorter.formatFloat(new Date(s).getTime())},type:"numeric"});m.addParser({id:"time",is:function(s){return(/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/).test(s)},format:function(s){return $.tablesorter.formatFloat(new Date("2000/01/01 "+s).getTime())},type:"numeric"});m.addParser({id:"metadata",is:function(s){return false},format:function(s,a,b){var c=a.config,p=(!c.parserMetadataName)?'sortValue':c.parserMetadataName;return $(b).metadata()[p]},type:"numeric"});m.addWidget({id:"zebra",format:function(a){var b,row=0,even,time,child=a.config.cssChildRow,css=a.config.widgetZebra.css;if(a.config.debug){time=new Date()}$("tr:visible",a.tBodies[0]).each(function(i){b=$(this);if(!b.hasClass(child)){row++}even=(row%2===0);b.removeClass(css[even?1:0]).addClass(css[even?0:1])});if(a.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time)}}})})(jQuery);
+(function($){$.extend({tablesorter:new function(){var g=[],widgets=[],tbl;this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:false,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"mmddyyyy",onRenderHeader:null,selectorHeaders:'thead th',tableClass:'tablesorter',debug:false};function log(s){if(typeof console!=="undefined"&&typeof console.debug!=="undefined"){console.log(s)}else{alert(s)}}function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms")}this.benchmark=benchmark;function getElementText(a,b,c){var d="",te=a.textExtraction;if(!b){return""}if(!a.supportsTextContent){a.supportsTextContent=b.textContent||false}if(te==="simple"){if(a.supportsTextContent){d=b.textContent}else{if(b.childNodes[0]&&b.childNodes[0].hasChildNodes()){d=b.childNodes[0].innerHTML}else{d=b.innerHTML}}}else{if(typeof(te)==="function"){d=te(b)}else if(typeof(te)==="object"&&te.hasOwnProperty(c)){d=te[c](b)}else{d=$(b).text()}}return d}function getParserById(a){var i,l=g.length;for(i=0;i<l;i++){if(g[i].id.toLowerCase()===a.toLowerCase()){return g[i]}}return false}function getNodeFromRowAndCellIndex(a,b,c){return a[b].cells[c]}function trimAndGetNodeText(a,b,c){return $.trim(getElementText(a,b,c))}function detectParserForColumn(a,b,c,d){var i,l=g.length,node=false,nodeValue='',keepLooking=true;while(nodeValue===''&&keepLooking){c++;if(b[c]){node=getNodeFromRowAndCellIndex(b,c,d);nodeValue=trimAndGetNodeText(a.config,node,d);if(a.config.debug){log('Checking if value was empty on row:'+c)}}else{keepLooking=false}}for(i=1;i<l;i++){if(g[i].is(nodeValue,a,node)){return g[i]}}return g[0]}function buildParserCache(a,b){if(a.tBodies.length===0){return}var c=a.tBodies[0].rows,list,cells,l,h,i,p,parsersDebug="";if(c[0]){list=[];cells=c[0].cells;l=cells.length;for(i=0;i<l;i++){p=false;h=$(b[i]);if($.metadata&&(h.metadata()&&h.metadata().sorter)){p=getParserById(h.metadata().sorter)}else if((a.config.headers[i]&&a.config.headers[i].sorter)){p=getParserById(a.config.headers[i].sorter)}else if(h.attr('class')&&h.attr('class').match('sorter-')){p=getParserById(h.attr('class').match(/sorter-(\w+)/)[1]||'')}if(!p){p=detectParserForColumn(a,c,-1,i)}if(a.config.debug){parsersDebug+="column:"+i+" parser:"+p.id+"\n"}list.push(p)}}if(a.config.debug){log(parsersDebug)}return list}function buildCache(a){var b=a.tBodies[0],totalRows=(b&&b.rows.length)||0,totalCells=(b.rows[0]&&b.rows[0].cells.length)||0,g=a.config.parsers,cache={row:[],normalized:[]},t,i,j,c,cols,cacheTime;if(a.config.debug){cacheTime=new Date()}for(i=0;i<totalRows;++i){c=$(b.rows[i]);cols=[];if(c.hasClass(a.config.cssChildRow)){cache.row[cache.row.length-1]=cache.row[cache.row.length-1].add(c);continue}cache.row.push(c);for(j=0;j<totalCells;++j){t=trimAndGetNodeText(a.config,c[0].cells[j],j);cols.push(t===''?'':g[j].format(t,a,c[0].cells[j],j))}cols.push(cache.normalized.length);cache.normalized.push(cols)}if(a.config.debug){benchmark("Building cache for "+totalRows+" rows:",cacheTime)}a.config.cache=cache;return cache}function getWidgetById(a){var i,w,l=widgets.length;for(i=0;i<l;i++){w=widgets[i];if(w&&w.hasOwnProperty('id')&&w.id.toLowerCase()===a.toLowerCase()){return w}}}function applyWidget(a){var c=a.config.widgets,i,w,l=c.length;for(i=0;i<l;i++){w=getWidgetById(c[i]);if(w&&w.hasOwnProperty('format')){w.format(a)}}}function appendToTable(a,b){var c=a.config,r=b.row,n=b.normalized,totalRows=n.length,checkCell=totalRows?(n[0].length-1):0,rows=[],i,j,l,pos,appendTime;if(c.debug){appendTime=new Date()}for(i=0;i<totalRows;i++){pos=n[i][checkCell];rows.push(r[pos]);if(!c.appender||!c.removeRows){l=r[pos].length;for(j=0;j<l;j++){a.tBodies[0].appendChild(r[pos][j])}}}if(c.appender){c.appender(a,rows)}if(c.debug){benchmark("Rebuilt table:",appendTime)}applyWidget(a);setTimeout(function(){$(a).trigger("sortEnd",a)},0)}function computeTableHeaderCellIndexes(t){var a=[],lookup={},thead=t.getElementsByTagName('THEAD')[0],trs=thead.getElementsByTagName('TR'),i,j,k,l,c,cells,rowIndex,cellId,rowSpan,colSpan,firstAvailCol,matrixrow;for(i=0;i<trs.length;i++){cells=trs[i].cells;for(j=0;j<cells.length;j++){c=cells[j];rowIndex=c.parentNode.rowIndex;cellId=rowIndex+"-"+c.cellIndex;rowSpan=c.rowSpan||1;colSpan=c.colSpan||1;if(typeof(a[rowIndex])==="undefined"){a[rowIndex]=[]}for(k=0;k<a[rowIndex].length+1;k++){if(typeof(a[rowIndex][k])==="undefined"){firstAvailCol=k;break}}lookup[cellId]=firstAvailCol;for(k=rowIndex;k<rowIndex+rowSpan;k++){if(typeof(a[k])==="undefined"){a[k]=[]}matrixrow=a[k];for(l=firstAvailCol;l<firstAvailCol+colSpan;l++){matrixrow[l]="x"}}}}return lookup}function formatSortingOrder(v){if(typeof(v)!=="number"){return(v.toLowerCase().charAt(0)==="d")?1:0}else{return(v===1)?1:0}}function checkHeaderMetadata(a){return(($.metadata)&&($(a).metadata().sorter===false))}function checkHeaderOptions(a,i){return((a.config.headers[i])&&(a.config.headers[i].sorter===false))}function checkHeaderLocked(a,i){if((a.config.headers[i])&&(a.config.headers[i].lockedOrder!==null)){return a.config.headers[i].lockedOrder}return false}function checkHeaderOrder(a,i){if((a.config.headers[i])&&(a.config.headers[i].sortInitialOrder)){return a.config.headers[i].sortInitialOrder}return a.config.sortInitialOrder}function buildHeaders(b){var d=($.metadata)?true:false,header_index=computeTableHeaderCellIndexes(b),$th,lock,time,$tableHeaders,c=b.config;c.headerList=[];if(c.debug){time=new Date()}$tableHeaders=$(c.selectorHeaders,b).wrapInner("<span/>").each(function(a){this.column=header_index[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(checkHeaderOrder(b,a));this.count=this.order;if(checkHeaderMetadata(this)||checkHeaderOptions(b,a)||$(this).is('.sorter-false')){this.sortDisabled=true}this.lockedOrder=false;lock=checkHeaderLocked(b,a);if(typeof(lock)!=='undefined'&&lock!==false){this.order=this.lockedOrder=formatSortingOrder(lock)}if(!this.sortDisabled){$th=$(this).addClass(c.cssHeader);if(c.onRenderHeader){c.onRenderHeader.apply($th,[a])}}c.headerList[a]=this});if(c.debug){benchmark("Built headers:",time);log($tableHeaders)}return $tableHeaders}function checkCellColSpan(a,b,d){var i,cell,arr=[],r=a.tHead.rows,c=r[d].cells;for(i=0;i<c.length;i++){cell=c[i];if(cell.colSpan>1){arr=arr.concat(checkCellColSpan(a,b,d++))}else{if(a.tHead.length===1||(cell.rowSpan>1||!r[d+1])){arr.push(cell)}}}return arr}function isValueInArray(v,a){var i,l=a.length;for(i=0;i<l;i++){if(a[i][0]===v){return true}}return false}function setHeadersCss(b,c,d,e){c.removeClass(e[0]).removeClass(e[1]);var h=[],i,l;c.each(function(a){if(!this.sortDisabled){h[this.column]=$(this)}});l=d.length;for(i=0;i<l;i++){if(d[i][1]===2){continue}h[d[i][0]].addClass(e[d[i][1]])}}function fixColumnWidth(a,b){if(a.config.widthFixed){var c=$('<colgroup>');$("tr:first td",a.tBodies[0]).each(function(){c.append($('<col>').css('width',$(this).width()))});$(a).prepend(c)}}function updateHeaderSortCount(a,b){var i,s,o,c=a.config,l=b.length;for(i=0;i<l;i++){s=b[i];o=c.headerList[s[0]];o.count=s[1];o.count++}}function getCachedSortType(a,i){return(a)?a[i].type:''}function multisort(a,b,d){var f="var sortWrapper = function(a,b) {",col,mx=0,dir=0,tc=a.config,lc=d.normalized.length,l=b.length,sortTime,i,j,c,s,e,order,orgOrderCol;if(tc.debug){sortTime=new Date()}for(i=0;i<l;i++){c=b[i][0];order=b[i][1];s=(getCachedSortType(tc.parsers,c)==="text")?((order===0)?"sortText":"sortTextDesc"):((order===0)?"sortNumeric":"sortNumericDesc");e="e"+i;if(/Numeric/.test(s)&&tc.headers[c]&&tc.headers[c].string){for(j=0;j<lc;j++){col=Math.abs(parseFloat(d.normalized[j][c]));mx=Math.max(mx,isNaN(col)?0:col)}dir=(tc.headers[c])?tc.string[tc.headers[c].string]||0:0}f+="var "+e+" = "+s+"(a["+c+"],b["+c+"],"+mx+","+dir+"); ";f+="if ("+e+") { return "+e+"; } ";f+="else { "}orgOrderCol=(d.normalized&&d.normalized[0])?d.normalized[0].length-1:0;f+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(i=0;i<l;i++){f+="}; "}f+="return 0; ";f+="}; ";eval(f);d.normalized.sort(sortWrapper);if(tc.debug){benchmark("Sorting on "+b.toString()+" and dir "+order+" time:",sortTime)}return d}function sortText(a,b){if(a===''){return 1}if(b===''){return-1}if(a===b){return 0}if($.data(tbl[0],"tablesorter").sortLocaleCompare){return a.localeCompare(b)}try{var c=0,ax,t,x=/^(\.)?\d/,L=Math.min(a.length,b.length)+1;while(c<L&&a.charAt(c)===b.charAt(c)&&x.test(b.substring(c))===false&&x.test(a.substring(c))===false){c++}a=a.substring(c);b=b.substring(c);if(x.test(a)||x.test(b)){if(x.test(a)===false){return(a)?1:-1}else if(x.test(b)===false){return(b)?-1:1}else{t=parseFloat(a)-parseFloat(b);if(t!==0){return t}else{t=a.search(/[^\.\d]/)}if(t===-1){t=b.search(/[^\.\d]/)}a=a.substring(t);b=b.substring(t)}}return(a>b)?1:-1}catch(er){return 0}}function sortTextDesc(a,b){if(a===''){return 1}if(b===''){return-1}if(a===b){return 0}if($.data(tbl[0],"tablesorter").sortLocaleCompare){return b.localeCompare(a)}return-sortText(a,b)}function getTextValue(a,b,d){if(b){var i,l=a.length,n=b+d;for(i=0;i<l;i++){n+=a.charCodeAt(i)}return d*n}return 0}function sortNumeric(a,b,c,d){if(a===''){return 1}if(b===''){return-1}if(isNaN(a)){a=getTextValue(a,c,d)}if(isNaN(b)){b=getTextValue(b,c,d)}return a-b}function sortNumericDesc(a,b,c,d){if(a===''){return 1}if(b===''){return-1}if(isNaN(a)){a=getTextValue(a,c,d)}if(isNaN(b)){b=getTextValue(b,c,d)}return b-a}this.construct=function(d){return this.each(function(){if(!this.tHead||!this.tBodies){return}var c,$document,$headers,cache,config,shiftDown=0,sortOrder,sortCSS,totalRows,$cell,i,j,a,s,o;this.config={};config=$.extend(this.config,$.tablesorter.defaults,d);tbl=c=$(this).addClass(this.config.tableClass);$.data(this,"tablesorter",config);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);this.config.string={max:1,'max+':1,'max-':-1,none:0};cache=buildCache(this);sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){totalRows=(c[0].tBodies[0]&&c[0].tBodies[0].rows.length)||0;if(!this.sortDisabled){c.trigger("sortStart",tbl[0]);$cell=$(this);i=this.column;this.order=this.count++%(config.sortReset?3:2);if(typeof(this.lockedOrder)!=="undefined"&&this.lockedOrder!==false){this.order=this.lockedOrder}if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!==null){a=config.sortForce;for(j=0;j<a.length;j++){if(a[j][0]!==i){config.sortList.push(a[j])}}}if(this.order<2){config.sortList.push([i,this.order])}}else{if(isValueInArray(i,config.sortList)){for(j=0;j<config.sortList.length;j++){s=config.sortList[j];o=config.headerList[s[0]];if(s[0]===i){o.count=s[1];o.count++;s[1]=o.count%(config.sortReset?3:2);if(s[1]>=2){config.sortList.splice(j,1);o.count=0}}}}else{if(this.order<2){config.sortList.push([i,this.order])}}}if(config.sortAppend!==null){a=config.sortAppend;for(j=0;j<a.length;j++){if(a[j][0]!==i){config.sortList.push(a[j])}}}c.trigger("sortBegin",tbl[0]);setTimeout(function(){setHeadersCss(c[0],$headers,config.sortList,sortCSS);appendToTable(c[0],multisort(c[0],config.sortList,cache))},1);return false}}).mousedown(function(){if(config.cancelSelection){this.onselectstart=function(){return false};return false}});c.bind("update",function(){var a=this;setTimeout(function(){a.config.parsers=buildParserCache(a,$headers);cache=buildCache(a);c.trigger("sorton",[a.config.sortList])},1)}).bind("updateCell",function(e,a){var b=this.config,pos=[(a.parentNode.rowIndex-1),a.cellIndex];cache.normalized[pos[0]][pos[1]]=b.parsers[pos[1]].format(getElementText(b,a,pos[1]),a);this.config.cache=cache;c.trigger("sorton",[b.sortList])}).bind("addRows",function(e,a){var i,config=this.config,rows=a.filter('tr').length,dat=[],l=a[0].cells.length;for(i=0;i<rows;i++){for(j=0;j<l;j++){dat[j]=config.parsers[j].format(getElementText(config,a[i].cells[j],j),a[i].cells[j])}dat.push(cache.row.length);cache.row.push([a[i]]);cache.normalized.push(dat);dat=[]}config.cache=cache;c.trigger("sorton",[config.sortList])}).bind("sorton",function(e,a){$(this).trigger("sortStart",tbl[0]);config.sortList=a;var b=config.sortList;updateHeaderSortCount(this,b);setHeadersCss(this,$headers,b,sortCSS);appendToTable(this,multisort(this,b,cache))}).bind("appendCache",function(){appendToTable(this,cache)}).bind("applyWidgetId",function(e,a){getWidgetById(a).format(this)}).bind("applyWidgets",function(){applyWidget(this)});if($.metadata&&($(this).metadata()&&$(this).metadata().sortlist)){config.sortList=$(this).metadata().sortlist}if(config.sortList.length>0){c.trigger("sorton",[config.sortList])}else{applyWidget(this)}})};this.addParser=function(b){var i,l=g.length,a=true;for(i=0;i<l;i++){if(g[i].id.toLowerCase()===b.id.toLowerCase()){a=false}}if(a){g.push(b)}};this.addWidget=function(a){widgets.push(a)};this.formatFloat=function(s){var i=parseFloat(s);return isNaN(i)?$.trim(s):i};this.isDigit=function(s){return(/^[\-+]?\d*$/).test($.trim(s.replace(/[,.']/g,'')))};this.clearTableBody=function(a){if($.browser.msie){var b=function(){while(this.firstChild){this.removeChild(this.firstChild)}};b.apply(a.tBodies[0])}else{a.tBodies[0].innerHTML=""}}}})();$.fn.extend({tablesorter:$.tablesorter.construct});var m=$.tablesorter;m.addParser({id:"text",is:function(s){return true},format:function(s){return $.trim(s.toLocaleLowerCase())},type:"text"});m.addParser({id:"digit",is:function(s){return $.tablesorter.isDigit(s.replace(/,/g,""))},format:function(s){return $.tablesorter.formatFloat(s.replace(/,/g,""))},type:"numeric"});m.addParser({id:"currency",is:function(s){return(/^[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]/).test(s)},format:function(s){return $.tablesorter.formatFloat(s.replace(/\,/g,'.').replace(new RegExp(/[^0-9. \-]/g),""))},type:"numeric"});m.addParser({id:"ipAddress",is:function(s){return(/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/).test(s)},format:function(s){var i,item,a=s.split("."),r="",l=a.length;for(i=0;i<l;i++){item=a[i];if(item.length===2){r+="0"+item}else{r+=item}}return $.tablesorter.formatFloat(r)},type:"numeric"});m.addParser({id:"url",is:function(s){return(/^(https?|ftp|file):\/\/$/).test(s)},format:function(s){return $.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),''))},type:"text"});m.addParser({id:"isoDate",is:function(s){return(/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/).test(s)},format:function(s){return $.tablesorter.formatFloat((s!=="")?new Date(s.replace(new RegExp(/-/g),"/")).getTime():"0")},type:"numeric"});m.addParser({id:"percent",is:function(s){return(/\%$/).test($.trim(s))},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""))},type:"numeric"});m.addParser({id:"usLongDate",is:function(s){return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/))},format:function(s){return $.tablesorter.formatFloat(new Date(s).getTime())},type:"numeric"});m.addParser({id:"shortDate",is:function(s){return(/\d{1,4}[\/\-\,\.\s+]\d{1,4}[\/\-\.\,\s+]\d{1,4}/).test(s)},format:function(s,a,b,d){var c=a.config,format=(c.headers&&c.headers[d])?c.headers[d].dateFormat||c.dateFormat:c.dateFormat;s=s.replace(/\s+/g," ").replace(/[\-|\.|\,|\s]/g,"/");if(format==="mmddyyyy"){s=s.replace(/(\d{1,2})\/(\d{1,2})\/(\d{4})/,"$3/$1/$2")}else if(format==="ddmmyyyy"){s=s.replace(/(\d{1,2})\/(\d{1,2})\/(\d{4})/,"$3/$2/$1")}else if(format==="yyyymmdd"){s=s.replace(/(\d{4})\/(\d{1,2})\/(\d{1,2})/,"$1/$2/$3")}return $.tablesorter.formatFloat(new Date(s).getTime())},type:"numeric"});m.addParser({id:"time",is:function(s){return(/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/).test(s)},format:function(s){return $.tablesorter.formatFloat(new Date("2000/01/01 "+s).getTime())},type:"numeric"});m.addParser({id:"metadata",is:function(s){return false},format:function(s,a,b){var c=a.config,p=(!c.parserMetadataName)?'sortValue':c.parserMetadataName;return $(b).metadata()[p]},type:"numeric"});m.addWidget({id:"zebra",format:function(a){var b,row=0,even,time,child=a.config.cssChildRow,css=a.config.widgetZebra.css;if(a.config.debug){time=new Date()}$("tr:visible",a.tBodies[0]).each(function(i){b=$(this);if(!b.hasClass(child)){row++}even=(row%2===0);b.removeClass(css[even?1:0]).addClass(css[even?0:1])});if(a.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time)}}})})(jQuery);
View
62 js/jquery.tablesorter.widgets.js
@@ -1,10 +1,11 @@
-/* TableSorter 2.0 Widgets - updated 1/30/2012
+/* TableSorter 2.0 Widgets - updated 1/31/2012
*
* jQuery UI Theme
* Column Styles
* Column Filters
* Sticky Header
* Column Resizing
+ * Save Sort
*
*/
(function($){
@@ -281,4 +282,63 @@ $.tablesorter.addWidget({
}
});
+// Save table sort widget
+// store last sort in local storage, with a cookie fallback
+// IE7 needs JSON library for JSON.stringify - see link below
+// **************************
+$.tablesorter.addWidget({
+ id: 'saveSort',
+ format: function(table) {
+ var n, d, k, ls, time, c = table.config,
+ // older browsers don't support JSON.stringify (http://caniuse.com/#search=json)
+ // if you need it, then include https://github.com/douglascrockford/JSON-js
+ sortList = '{"sortList":' + JSON.stringify(c.sortList) + '}';
+ if (c.debug) {
+ time = new Date();
+ }
+ if (c.widgetsavesort){
+ n = 'tablesorter' + (c.tableIndex || 0) + table.id;
+ // save table sort
+ if (c.hasLocalStorage) {
+ localStorage[n] = sortList; // local storage
+ } else {
+ d = new Date();
+ d.setTime(d.getTime()+(31536e+6)); // 365 days
+ document.cookie = n + '=' + sortList + '; expires=' + d.toGMTString() + '; path=/';
+ }
+ if (c.debug) {
+ $.tablesorter.benchmark('saveSort: Saving sort to "' + n + '" in ' + (c.hasLocalStorage ? 'local storage' : 'a cookie'), time);
+ }
+ } else {
+ // set table sort on initial run of the widget
+ c.widgetsavesort = true;
+ c.hasLocalStorage = false;
+ // check for local storage - from Modernzr
+ try { if (localStorage.getItem) { c.hasLocalStorage = true; } } catch(e) {}
+ // save table index; in case there is more than one table on the page
+ c.tableIndex = $('.tablesorter').index($(table));
+ // make sure we use a unique table key; use index in case table.id = ""
+ n = 'tablesorter' + (c.tableIndex || 0) + table.id;
+ // get data
+ if (c.hasLocalStorage) {
+ ls = localStorage[n]; // local storage
+ } else {
+ k = document.cookie.split(/[;\s|=]/); // cookie
+ d = $.inArray(n, k) + 1; // add one to get from the key to the value
+ ls = (d !== 0) ? k[d] : '';
+ }
+ // parse data
+ try { ls = $.parseJSON(ls); } catch(e) { ls = ''; }
+ sortList = (ls && ls.hasOwnProperty('sortList') && $.isArray(ls.sortList)) ? [ls.sortList] : '';
+ if (c.debug) {
+ $.tablesorter.benchmark('saveSort: Last sort for "' + n + '" obtained from ' + (c.hasLocalStorage ? 'local storage' : 'a cookie'), time);
+ }
+ // update sort change
+ if (sortList && sortList.length > 0) {
+ $(table).trigger('sorton', sortList);
+ }
+ }
+ }
+});
+
})(jQuery);
View
13 js/jquery.tablesorter.widgets.min.js
@@ -1,9 +1,10 @@
-/* TableSorter 2.0 Widgets - updated 1/30/2012 */
+/* TableSorter 2.0 Widgets - updated 1/31/2012 */
(function(b){
-b.tablesorter.addWidget({id:"uitheme",format:function(e){var c,a,g,j,h,d=e.config,f=b(e),i=["ui-icon-arrowthick-2-n-s","ui-icon-arrowthick-1-s","ui-icon-arrowthick-1-n"];d.widgetUitheme&&d.widgetUitheme.hasOwnProperty("css")&&(i=d.widgetUitheme.css||i);g=i.join(" ");d.debug&&(c=new Date);f.is(".ui-theme")||(f.addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),b.each(d.headerList,function(){b(this).addClass("ui-widget-header ui-corner-all").append('<span class="ui-icon"/>').wrapInner('<div class="inner"/>').hover(function(){b(this).addClass("ui-state-hover")}, function(){b(this).removeClass("ui-state-hover")})}));b.each(d.headerList,function(c){j=b(this);this.sortDisabled?j.find("span.ui-icon").removeClass(g+" ui-icon"):(a=j.hasClass(d.cssAsc)?i[1]:j.hasClass(d.cssDesc)?i[2]:j.hasClass(d.cssHeader)?i[0]:"",h=f.hasClass("hasStickyHeaders")?f.find("tr.stickyHeader").find("th").eq(c).add(j):j,h[a===i[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(g).addClass(a))});d.debug&&b.tablesorter.benchmark("Applying uitheme widget", c)}});
-b.tablesorter.addWidget({id:"columns",format:function(e){var c,a,g,j,h=e.config,d=h.sortList,f=d.length,i=["primary","secondary","tertiary"];h.widgetColumns&&h.widgetColumns.hasOwnProperty("css")&&(i=h.widgetColumns.css||i);g=i.length-1;j=i.join(" ");h.debug&&(a=new Date);d&&d[0]&&b("tr:visible",e.tBodies[0]).each(function(a){c=b(this).children().removeClass(j);c.eq(d[0][0]).addClass(i[0]);if(1<f)for(a=1;a<f;a++)c.eq(d[a][0]).addClass(i[a]||i[g])});h.debug&&b.tablesorter.benchmark("Applying Columns widget", a)}});
-b.tablesorter.addWidget({id:"filter",format:function(e){if(!e.config.filtering){var c,a,g,j,h,d,f=e.config,i=f.headerList.length,k=b(e),e='<tr class="filters">',l;f.debug&&(l=new Date);for(c=0;c<i;c++)e+='<td><input type="text" class="filter" data-col="'+c+'" style="',e+=f.headers[c]&&"filter"in f.headers[c]&&!1===f.headers[c].filter||b(f.headerList[c]).is(".filter-false")?"display:none":"",e+='"></td>';k.find("thead").append(e+="</tr>").find(".filter").bind("keyup",function(){a=k.find(".filter").map(function(){return(b(this).val()|| "").toLowerCase()}).get();""===a.join("")?k.find("tr").show():k.find("tbody").find("tr:not(.expand-child)").each(function(){g=!0;h=b(this).nextUntil("tr:not(.expand-child)");j=h.length&&("undefined"!==typeof f.widgetFilterChildRows?f.widgetFilterChildRows:1)?h.text():"";d=b(this).find("td");for(c=0;c<i;c++)""!==a[c]&&0<=(d.eq(c).text()+j).toLowerCase().indexOf(a[c])?g=g?!0:!1:""!==a[c]&&(g=!1);b(this)[g?"show":"hide"]();if(h.length)h[g?"show":"hide"]()});k.trigger("applyWidgets")});f.filtering=!0; f.debug&&b.tablesorter.benchmark("Applying Filter widget",l)}}});
-b.tablesorter.addWidget({id:"stickyHeaders",format:function(e){if(!b(e).hasClass("hasStickyHeaders")){var c=b(e).addClass("hasStickyHeaders"),a=b(window),g=b(e).find("thead"),j=g.find("tr").children(),h=j.eq(0),d=parseInt(j.eq(0).css("border-left-width"),10),f=g.find("tr:not(.filters)").clone().addClass("stickyHeader").css({width:g.outerWidth()+2*d,position:"fixed",left:h.offset().left,marginLeft:-d,top:0,visibility:"hidden",zIndex:10}), i=f.children(),k;c.bind("sortEnd",function(a,c){var d=b(c).find("thead tr"),f=d.filter(".stickyHeader").children();d.filter(":not(.stickyHeader)").children().each(function(a){f.eq(a).attr("class",b(this).attr("class"))})}).bind("pagerComplete",function(){a.resize()});j.each(function(a){var c=b(this);i.eq(a).width(c.width()).bind("click",function(a){c.trigger(a)}).bind("mousedown",function(){this.onselectstart=function(){return!1};return!1})});g.prepend(f);a.scroll(function(){var b=h.offset(),d=a.scrollTop(), d=d>b.top&&d<b.top+c.find("tbody").height()?"visible":"hidden";f.css({left:b.left-a.scrollLeft(),visibility:d});d!==k&&(a.resize(),k=d)}).resize(function(){f.css({left:h.offset().left-a.scrollLeft(),width:g.outerWidth()+2*d});i.each(function(a){b(this).width(j.eq(a).width())})})}}});
-b.tablesorter.addWidget({id:"resizable",format:function(e){if(!e.config.resizable){var c,a=e.config,g=a.headerList,j=g.length,h=function(){a.resizable_position=0;a.resizable_target=null;b(window).trigger("resize")};a.resizable_target= null;a.resizable_position=0;for(c=1;c<j;c++)b(g[c]).append('<div class="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>').find(".resizer").bind("mousedown",function(d){a.resizable_target=b(d.target).closest("th");a.resizable_position=d.pageX}).end().bind("mousemove",function(b){if(!(0===a.resizable_position||null===typeof a.resizable_target)){var c=b.pageX-a.resizable_position, e=a.resizable_target.closest("th").prev();if(!(a.resizable_target.width()<-c||e&&e.width()<=c))e.width(e.width()+c),a.resizable_position=b.pageX}}).bind("mouseup",function(){h();return!1});b(e).find("thead").bind("mouseup mouseleave",function(){h()});a.resizable=!0}}})
+b.tablesorter.addWidget({id:"uitheme",format:function(f){var c,a,d,g,e,h=f.config,i=b(f),j=["ui-icon-arrowthick-2-n-s","ui-icon-arrowthick-1-s","ui-icon-arrowthick-1-n"];h.widgetUitheme&&h.widgetUitheme.hasOwnProperty("css")&&(j=h.widgetUitheme.css||j);d=j.join(" ");h.debug&&(c=new Date);i.is(".ui-theme")||(i.addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),b.each(h.headerList,function(){b(this).addClass("ui-widget-header ui-corner-all").append('<span class="ui-icon"/>').wrapInner('<div class="inner"/>').hover(function(){b(this).addClass("ui-state-hover")}, function(){b(this).removeClass("ui-state-hover")})}));b.each(h.headerList,function(c){g=b(this);this.sortDisabled?g.find("span.ui-icon").removeClass(d+" ui-icon"):(a=g.hasClass(h.cssAsc)?j[1]:g.hasClass(h.cssDesc)?j[2]:g.hasClass(h.cssHeader)?j[0]:"",e=i.hasClass("hasStickyHeaders")?i.find("tr.stickyHeader").find("th").eq(c).add(g):g,e[a===j[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(d).addClass(a))});h.debug&&b.tablesorter.benchmark("Applying uitheme widget", c)}});
+b.tablesorter.addWidget({id:"columns",format:function(f){var c,a,d,g,e=f.config,h=e.sortList,i=h.length,j=["primary","secondary","tertiary"];e.widgetColumns&&e.widgetColumns.hasOwnProperty("css")&&(j=e.widgetColumns.css||j);d=j.length-1;g=j.join(" ");e.debug&&(a=new Date);h&&h[0]&&b("tr:visible",f.tBodies[0]).each(function(a){c=b(this).children().removeClass(g);c.eq(h[0][0]).addClass(j[0]);if(1<i)for(a=1;a<i;a++)c.eq(h[a][0]).addClass(j[a]||j[d])});e.debug&&b.tablesorter.benchmark("Applying Columns widget", a)}});
+b.tablesorter.addWidget({id:"filter",format:function(f){if(!f.config.filtering){var c,a,d,g,e,h,i=f.config,j=i.headerList.length,k=b(f),f='<tr class="filters">',l;i.debug&&(l=new Date);for(c=0;c<j;c++)f+='<td><input type="text" class="filter" data-col="'+c+'" style="',f+=i.headers[c]&&"filter"in i.headers[c]&&!1===i.headers[c].filter||b(i.headerList[c]).is(".filter-false")?"display:none":"",f+='"></td>';k.find("thead").append(f+="</tr>").find(".filter").bind("keyup",function(){a=k.find(".filter").map(function(){return(b(this).val()|| "").toLowerCase()}).get();""===a.join("")?k.find("tr").show():k.find("tbody").find("tr:not(.expand-child)").each(function(){d=!0;e=b(this).nextUntil("tr:not(.expand-child)");g=e.length&&("undefined"!==typeof i.widgetFilterChildRows?i.widgetFilterChildRows:1)?e.text():"";h=b(this).find("td");for(c=0;c<j;c++)""!==a[c]&&0<=(h.eq(c).text()+g).toLowerCase().indexOf(a[c])?d=d?!0:!1:""!==a[c]&&(d=!1);b(this)[d?"show":"hide"]();if(e.length)e[d?"show":"hide"]()});k.trigger("applyWidgets")});i.filtering=!0; i.debug&&b.tablesorter.benchmark("Applying Filter widget",l)}}});
+b.tablesorter.addWidget({id:"stickyHeaders",format:function(f){if(!b(f).hasClass("hasStickyHeaders")){var c=b(f).addClass("hasStickyHeaders"),a=b(window),d=b(f).find("thead"),g=d.find("tr").children(),e=g.eq(0),h=parseInt(g.eq(0).css("border-left-width"),10),i=d.find("tr:not(.filters)").clone().addClass("stickyHeader").css({width:d.outerWidth()+2*h,position:"fixed",left:e.offset().left,marginLeft:-h,top:0,visibility:"hidden",zIndex:10}), j=i.children(),k;c.bind("sortEnd",function(a,c){var e=b(c).find("thead tr"),d=e.filter(".stickyHeader").children();e.filter(":not(.stickyHeader)").children().each(function(a){d.eq(a).attr("class",b(this).attr("class"))})}).bind("pagerComplete",function(){a.resize()});g.each(function(a){var c=b(this);j.eq(a).width(c.width()).bind("click",function(a){c.trigger(a)}).bind("mousedown",function(){this.onselectstart=function(){return!1};return!1})});d.prepend(i);a.scroll(function(){var b=e.offset(),d=a.scrollTop(), d=d>b.top&&d<b.top+c.find("tbody").height()?"visible":"hidden";i.css({left:b.left-a.scrollLeft(),visibility:d});d!==k&&(a.resize(),k=d)}).resize(function(){i.css({left:e.offset().left-a.scrollLeft(),width:d.outerWidth()+2*h});j.each(function(a){b(this).width(g.eq(a).width())})})}}});
+b.tablesorter.addWidget({id:"resizable",format:function(f){if(!f.config.resizable){var c,a=f.config,d=a.headerList,g=d.length,e=function(){a.resizable_position=0;a.resizable_target=null;b(window).trigger("resize")};a.resizable_target= null;a.resizable_position=0;for(c=1;c<g;c++)b(d[c]).append('<div class="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>').find(".resizer").bind("mousedown",function(c){a.resizable_target=b(c.target).closest("th");a.resizable_position=c.pageX}).end().bind("mousemove",function(c){if(!(0===a.resizable_position||null===typeof a.resizable_target)){var b=c.pageX-a.resizable_position, d=a.resizable_target.closest("th").prev();a.resizable_target.width()<-b||d&&d.width()<=b||(d.width(d.width()+b),a.resizable_position=c.pageX)}}).bind("mouseup",function(){e();return!1});b(f).find("thead").bind("mouseup mouseleave",function(){e()});a.resizable=!0}}});
+b.tablesorter.addWidget({id:"saveSort",format:function(f){var c,a,d,g,e=f.config;d='{"sortList":'+JSON.stringify(e.sortList)+"}";e.debug&&(g=new Date);if(e.widgetsavesort)c="tablesorter"+(e.tableIndex||0)+f.id,e.hasLocalStorage?localStorage[c]= d:(a=new Date,a.setTime(a.getTime()+31536E6),document.cookie=c+"="+d+"; expires="+a.toGMTString()+"; path=/"),e.debug&&b.tablesorter.benchmark('saveSort: Saving sort to "'+c+'" in '+(e.hasLocalStorage?"local storage":"a cookie"),g);else{e.widgetsavesort=!0;e.hasLocalStorage=!1;try{localStorage.getItem&&(e.hasLocalStorage=!0)}catch(h){}e.tableIndex=b(".tablesorter").index(b(f));c="tablesorter"+(e.tableIndex||0)+f.id;e.hasLocalStorage?a=localStorage[c]:(d=document.cookie.split(/[;\s|=]/),a=b.inArray(c, d)+1,a=0!==a?d[a]:"");try{a=b.parseJSON(a)}catch(i){a=""}d=a&&a.hasOwnProperty("sortList")&&b.isArray(a.sortList)?[a.sortList]:"";e.debug&&b.tablesorter.benchmark('saveSort: Last sort for "'+c+'" obtained from '+(e.hasLocalStorage?"local storage":"a cookie"),g);d&&0<d.length&&b(f).trigger("sorton",d)}}})
})(jQuery);
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "tablesorter",
- "version": "2.0.26",
+ "version": "2.0.27",
"title": "tablesorter",
"author": {
"name": "Christian Bach",
Please sign in to comment.
Something went wrong with that request. Please try again.