diff --git a/README.markdown b/README.markdown index d3704fbc..19e82b47 100644 Binary files a/README.markdown and b/README.markdown differ diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index 32c4925d..76721748 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -1,6 +1,6 @@ /*! * tablesorter pager plugin - * updated 4/28/2012 + * updated 5/3/2012 */ ;(function($) { $.extend({tablesorterPager: new function() { diff --git a/addons/pager/jquery.tablesorter.pager.min.js b/addons/pager/jquery.tablesorter.pager.min.js index 32e77a6d..ed876dcb 100644 --- a/addons/pager/jquery.tablesorter.pager.min.js +++ b/addons/pager/jquery.tablesorter.pager.min.js @@ -1,2 +1,2 @@ -/*! tablesorter pager plugin minified - updated 4/28/2012 */ -;(function(d){d.extend({tablesorterPager:new function(){this.defaults={container:null,ajaxUrl:null,ajaxProcessing:function(){return[0,[],null]},output:"{startRow} to {endRow} of {totalRows} rows",updateArrows:!0,page:0,size:10,fixedHeight:!1,removeRows:!0,cssNext:".next",cssPrev:".prev",cssFirst:".first",cssLast:".last",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",cssDisabled:"disabled",totalRows:0,totalPages:0};var o=this,p=function(c,b){var a=c.cssDisabled,e=!!b;c.updateArrows&&(c.container[c.totalRows< c.size?"addClass":"removeClass"](a),d(c.cssFirst+","+c.cssPrev,c.container)[e||0===c.page?"addClass":"removeClass"](a),d(c.cssNext+","+c.cssLast,c.container)[e||c.page===c.totalPages-1?"addClass":"removeClass"](a))},t=function(c,b){if(0')},l=function(c,b){var a, e=d("tr:not(."+c.config.cssChildRow+")",c.tBodies[0]),g=e.length,f=b.page*b.size,i=f+b.size;i>g&&(i=g);for(a=0;a=f&&a'+(e?e.message+" ("+e.name+")":"No rows found")+"",l=a.ajaxProcessing(c)||[0,[]],n=l[1]||[],q=n.length,r=l[2];if(0";for(g=0;g"+n[c][g]+"";m+=""}r&&r.length===o&&(f=h.hasClass("hasStickyHeaders"),j=h.find("."+(a.widgetOptions&&a.widgetOptions.stickyHeaders||"tablesorter-stickyheader")),i=h.find("tfoot tr:first").children(),h.find("thead tr.tablesorter-header th").each(function(a){var b=d(this),b=b.find("span").length?b.find("span:first"): b;b.html(r[a]);i.eq(a).html(r[a]);f&&j.length&&(b=j.find("th").eq(a),b=b.find("span").length?b.find("span:first"):b,b.html(r[a]))}));e?h.find("thead").append(p):k.html(m);a.temp.remove();h.trigger("update");a.totalRows=l[0]||0;a.totalPages=Math.ceil(a.totalRows/a.size);t(b,a);s(b,a);h.trigger("pagerChange",a)}},v=function(c,b){var a=d(c),e=b.ajaxUrl.replace(/\{page\}/g,b.page).replace(/\{size\}/g,b.size);""!==e&&(b.temp=d("
",{id:"tablesorterPagerLoading",width:a.outerWidth(!0),height:a.outerHeight(!0)}), a.before(b.temp),d(document).ajaxError(function(a,d,e,j){u(null,c,b,j)}),d.getJSON(e,function(a){u(a,c,b)}))},n=function(c,b,a){var e,g,f,i=document.createDocumentFragment(),j=b.length;e=a.page*a.size;var h=e+a.size;if(!(1>j)){d(c).trigger("pagerChange",a);if(a.removeRows){h>b.length&&(h=b.length);for(d(c.tBodies[0]).empty();e=a.totalPages&&(a.page=a.totalPages-1,k(c,a));t(c,a);a.isDisabled|| s(c,a)}},w=function(c,b){b.ajax?p(b,!0):(b.isDisabled=!0,d.data(c,"pagerLastPage",b.page),d.data(c,"pagerLastSize",b.size),b.page=0,b.size=b.totalRows,b.totalPages=1,d("tr.pagerSavedHeightSpacer",c.tBodies[0]).remove(),n(c,c.config.rowsCopy,b));d(b.cssPageSize,b.container).addClass(b.cssDisabled)[0].disabled=!0},k=function(c,b){if(!b.isDisabled){if(0>b.page||b.page>b.totalPages-1)b.page=0;d.data(c,"pagerLastPage",b.page);b.ajax?v(c,b):n(c,c.config.rowsCopy,b)}},x=function(c,b,a){a.size=b;d.data(c, "pagerLastPage",a.page);d.data(c,"pagerLastSize",a.size);a.totalPages=Math.ceil(a.totalRows/a.size);k(c,a)},y=function(c,b,a){var e=d(b.cssPageSize,b.container).removeClass(b.cssDisabled).removeAttr("disabled");b.isDisabled=!1;b.page=d.data(c,"pagerLastPage")||b.page||0;b.size=d.data(c,"pagerLastSize")||parseInt(e.val(),10)||b.size;b.totalPages=Math.ceil(b.totalRows/b.size);a&&(d(c).trigger("update"),x(c,b.size,b),q(c,b),s(c,b))};o.appender=function(c,b){var a=c.config.pager;a.ajax||(c.config.rowsCopy= b,a.totalRows=b.length,a.size=d.data(c,"pagerLastSize")||a.size,a.totalPages=Math.ceil(a.totalRows/a.size),n(c,b,a))};o.construct=function(c){return this.each(function(){var b=this.config,a=b.pager=d.extend({},d.tablesorterPager.defaults,c),e=this,g=d(e),f=d(a.container).show();b.appender=o.appender;y(e,a,!1);"string"===typeof a.ajaxUrl?(a.ajax=!0,v(e,a)):(a.ajax=!1,d(this).trigger("appendCache"),q(e,a));d(a.cssFirst,f).unbind("click.pager").bind("click.pager",function(){if(!d(this).hasClass(a.cssDisabled)){a.page= 0;k(e,a)}return false});d(a.cssNext,f).unbind("click.pager").bind("click.pager",function(){if(!d(this).hasClass(a.cssDisabled)){a.page++;if(a.page>=a.totalPages-1)a.page=a.totalPages-1;k(e,a)}return false});d(a.cssPrev,f).unbind("click.pager").bind("click.pager",function(){if(!d(this).hasClass(a.cssDisabled)){a.page--;if(a.page<=0)a.page=0;k(e,a)}return false});d(a.cssLast,f).unbind("click.pager").bind("click.pager",function(){if(!d(this).hasClass(a.cssDisabled)){a.page=a.totalPages-1;k(e,a)}return false}); d(a.cssPageSize,f).unbind("change.pager").bind("change.pager",function(){d(a.cssPageSize,f).val(d(this).val());if(!d(this).hasClass(a.cssDisabled)){x(e,parseInt(d(this).val(),10),a);var b=d(e.tBodies[0]);b.find("tr.pagerSavedHeightSpacer").remove();d.data(e,"pagerSavedHeight",b.height());s(e,a);d.data(e,"pagerLastSize",a.size)}return false});g.unbind("disable.pager enable.pager destroy.pager").bind("disable.pager",function(){w(e,a)}).bind("enable.pager",function(){y(e,a,true)}).bind("destroy.pager", function(){w(e,a);a.container.hide();e.config.appender=null;d(e).unbind("destroy.pager sortEnd.pager enable.pager disable.pager")})})}}});d.fn.extend({tablesorterPager:d.tablesorterPager.construct})})(jQuery); +/*! tablesorter pager plugin minified - updated 5/3/2012 */ +;(function(d){d.extend({tablesorterPager:new function(){this.defaults={container:null,ajaxUrl:null,ajaxProcessing:function(){return[0,[],null]},output:"{startRow} to {endRow} of {totalRows} rows",updateArrows:!0,page:0,size:10,fixedHeight:!1,removeRows:!0,cssNext:".next",cssPrev:".prev",cssFirst:".first",cssLast:".last",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",cssDisabled:"disabled",totalRows:0,totalPages:0};var o=this,p=function(c,b){var a=c.cssDisabled,e=!!b;c.updateArrows&&(c.container[c.totalRows< c.size?"addClass":"removeClass"](a),d(c.cssFirst+","+c.cssPrev,c.container)[e||0===c.page?"addClass":"removeClass"](a),d(c.cssNext+","+c.cssLast,c.container)[e||c.page===c.totalPages-1?"addClass":"removeClass"](a))},t=function(c,b){if(0')},l=function(c,b){var a, e=d("tr:not(."+c.config.cssChildRow+")",c.tBodies[0]),g=e.length,f=b.page*b.size,i=f+b.size;i>g&&(i=g);for(a=0;a=f&&a'+(e?e.message+" ("+e.name+")":"No rows found")+"",l=a.ajaxProcessing(c)||[0,[]],n=l[1]||[],q=n.length,r=l[2];if(0";for(g=0;g"+n[c][g]+"";m+=""}r&&r.length===o&&(f=h.hasClass("hasStickyHeaders"),j=h.find("."+(a.widgetOptions&&a.widgetOptions.stickyHeaders||"tablesorter-stickyheader")),i=h.find("tfoot tr:first").children(),h.find("thead tr.tablesorter-header th").each(function(a){var b=d(this),b=b.find("span").length?b.find("span:first"): b;b.html(r[a]);i.eq(a).html(r[a]);f&&j.length&&(b=j.find("th").eq(a),b=b.find("span").length?b.find("span:first"):b,b.html(r[a]))}));e?h.find("thead").append(p):k.html(m);a.temp.remove();h.trigger("update");a.totalRows=l[0]||0;a.totalPages=Math.ceil(a.totalRows/a.size);t(b,a);s(b,a);h.trigger("pagerChange",a)}},v=function(c,b){var a=d(c),e=b.ajaxUrl.replace(/\{page\}/g,b.page).replace(/\{size\}/g,b.size);""!==e&&(b.temp=d("
",{id:"tablesorterPagerLoading",width:a.outerWidth(!0),height:a.outerHeight(!0)}), a.before(b.temp),d(document).ajaxError(function(a,d,e,j){u(null,c,b,j)}),d.getJSON(e,function(a){u(a,c,b)}))},n=function(c,b,a){var e,g,f,i=document.createDocumentFragment(),j=b.length;e=a.page*a.size;var h=e+a.size;if(!(1>j)){d(c).trigger("pagerChange",a);if(a.removeRows){h>b.length&&(h=b.length);for(d.tablesorter.clearTableBody(c);e=a.totalPages&&(a.page=a.totalPages-1,k(c,a));t(c,a);a.isDisabled|| s(c,a)}},w=function(c,b){b.ajax?p(b,!0):(b.isDisabled=!0,d.data(c,"pagerLastPage",b.page),d.data(c,"pagerLastSize",b.size),b.page=0,b.size=b.totalRows,b.totalPages=1,d("tr.pagerSavedHeightSpacer",c.tBodies[0]).remove(),n(c,c.config.rowsCopy,b));d(b.cssPageSize,b.container).addClass(b.cssDisabled)[0].disabled=!0},k=function(c,b){if(!b.isDisabled){if(0>b.page||b.page>b.totalPages-1)b.page=0;d.data(c,"pagerLastPage",b.page);b.ajax?v(c,b):n(c,c.config.rowsCopy,b)}},x=function(c,b,a){a.size=b;d.data(c, "pagerLastPage",a.page);d.data(c,"pagerLastSize",a.size);a.totalPages=Math.ceil(a.totalRows/a.size);k(c,a)},y=function(c,b,a){var e=d(b.cssPageSize,b.container).removeClass(b.cssDisabled).removeAttr("disabled");b.isDisabled=!1;b.page=d.data(c,"pagerLastPage")||b.page||0;b.size=d.data(c,"pagerLastSize")||parseInt(e.val(),10)||b.size;b.totalPages=Math.ceil(b.totalRows/b.size);a&&(d(c).trigger("update"),x(c,b.size,b),q(c,b),s(c,b))};o.appender=function(c,b){var a=c.config.pager;a.ajax||(c.config.rowsCopy= b,a.totalRows=b.length,a.size=d.data(c,"pagerLastSize")||a.size,a.totalPages=Math.ceil(a.totalRows/a.size),n(c,b,a))};o.construct=function(c){return this.each(function(){var b=this.config,a=b.pager=d.extend({},d.tablesorterPager.defaults,c),e=this,g=d(e),f=d(a.container).show();b.appender=o.appender;y(e,a,!1);"string"===typeof a.ajaxUrl?(a.ajax=!0,v(e,a)):(a.ajax=!1,d(this).trigger("appendCache"),q(e,a));d(a.cssFirst,f).unbind("click.pager").bind("click.pager",function(){if(!d(this).hasClass(a.cssDisabled)){a.page= 0;k(e,a)}return false});d(a.cssNext,f).unbind("click.pager").bind("click.pager",function(){if(!d(this).hasClass(a.cssDisabled)){a.page++;if(a.page>=a.totalPages-1)a.page=a.totalPages-1;k(e,a)}return false});d(a.cssPrev,f).unbind("click.pager").bind("click.pager",function(){if(!d(this).hasClass(a.cssDisabled)){a.page--;if(a.page<=0)a.page=0;k(e,a)}return false});d(a.cssLast,f).unbind("click.pager").bind("click.pager",function(){if(!d(this).hasClass(a.cssDisabled)){a.page=a.totalPages-1;k(e,a)}return false}); d(a.cssPageSize,f).unbind("change.pager").bind("change.pager",function(){d(a.cssPageSize,f).val(d(this).val());if(!d(this).hasClass(a.cssDisabled)){x(e,parseInt(d(this).val(),10),a);var b=d(e.tBodies[0]);b.find("tr.pagerSavedHeightSpacer").remove();d.data(e,"pagerSavedHeight",b.height());s(e,a);d.data(e,"pagerLastSize",a.size)}return false});g.unbind("disable.pager enable.pager destroy.pager").bind("disable.pager",function(){w(e,a)}).bind("enable.pager",function(){y(e,a,true)}).bind("destroy.pager", function(){w(e,a);a.container.hide();e.config.appender=null;d(e).unbind("destroy.pager sortEnd.pager enable.pager disable.pager")})})}}});d.fn.extend({tablesorterPager:d.tablesorterPager.construct})})(jQuery); diff --git a/docs/example-locale-sort.html b/docs/example-locale-sort.html new file mode 100644 index 00000000..d4dcdc89 --- /dev/null +++ b/docs/example-locale-sort.html @@ -0,0 +1,158 @@ + + + + + jQuery plugin: Tablesorter 2.0 - Sorting Accented Characters + + + + + + + + + + + + + + + + + + +
+

Demo

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Account #First NameLast NameAgeLocation
a1a10AnderEParker28Béchar
a1a2ÄndereHood33Bebington
A1a1AndéreKent18Berlin
A2b2CotÉAlmighty45Beckum
A1d2CÔteEvans56Curaçao
a2b11CÔtÉClark44Béjaïa
A2b1ÇotePresley24Bekkevoort
A1b0AndéréCarter40Bègles
+ +

Javascript

+
+

+	
+

HTML

+
+

+	
+ + + +
+ + + + diff --git a/docs/example-option-custom-sort.html b/docs/example-option-custom-sort.html new file mode 100644 index 00000000..b82cf4f2 --- /dev/null +++ b/docs/example-option-custom-sort.html @@ -0,0 +1,157 @@ + + + + + jQuery plugin: Tablesorter 2.0 - Using a Custom Sort Script + + + + + + + + + + + + + + + + + + + + + +
+

Demo

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Account #First NameLast NameAgeTotalDiscountDiff
a1a10PeterParker289.9920.3%+3
a1a2JohnHood3319.9925.1%-7
A1a1ClarkKent182.8944.2%-15
A2b2BruceAlmighty45153.1944%+19
A1d2BruceEvans56$153.1923%+9
a2b11JohnClark44($19.89)25.1%(5)
A2b1ElvisPresley24($9.99)50%(22)
A1b0FrankCarter40-12.9920%(6)
+ + +

Page Head

+
+
<!-- jQuery -->
+<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
+
+<!-- custom sorting script -->
+<script src="js/naturalSort.js"></script>
+
+<!-- Tablesorter: required -->
+<link rel="stylesheet" href="../css/blue/style.css">
+<script src="../js/jquery.tablesorter.js"></script>
+
+

Javascript

+
+

+	
+

HTML

+
+

+	
+ + + +
+ + + + diff --git a/docs/example-option-sort-key.html b/docs/example-option-sort-key.html index 4d7f7ee9..3814ec51 100644 --- a/docs/example-option-sort-key.html +++ b/docs/example-option-sort-key.html @@ -107,7 +107,7 @@
diff --git a/docs/index.html b/docs/index.html index 0e29215e..b4a25006 100644 --- a/docs/index.html +++ b/docs/index.html @@ -15,11 +15,12 @@ - + + @@ -94,6 +95,7 @@
  • Multi-column sorting
  • +
  • Multi-tbody sorting - see the options table below
  • Parsers for sorting text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats), time. Add your own easily
  • + + Deprecated Options + + + widgetColumns Object with Array @@ -1340,7 +1436,7 @@ $("table").trigger("sorton", [sorting]);

Note: This is the only method the pager widget uses - the entire table is stored in the cache, but only the visible portion is actually exists in the table.
// Table data was just dynamically changed (more than one cell)
-$(table)
+$("table")
   .trigger("update")
   .trigger("appendCache");
@@ -1543,15 +1639,15 @@ $(table) Required: Optional / Add-Ons: Themes: diff --git a/docs/js/chili/recipes.js b/docs/js/chili/recipes.js index ce6296c9..83b2dc64 100644 --- a/docs/js/chili/recipes.js +++ b/docs/js/chili/recipes.js @@ -164,7 +164,7 @@ ChiliBook.recipes[ "html.js" ] = } , comment: { _match: // - , _style: "color: #4040c2;" + , _style: "color: gray;" } , script: { _match: /(]*>)([\w\W]*?)(<\/script\s*>)/ @@ -191,7 +191,7 @@ ChiliBook.recipes[ "html.js" ] = + this.x( content, '/tag_attrs' ) + "" + this.x( close ) + ""; } - , _style: "color: navy; font-weight: bold;" + , _style: "color: navy;" } // matches an ending tag // like "" @@ -210,7 +210,7 @@ ChiliBook.recipes[ "html.js" ] = // before in $1, name in $2, between in $3, value in $4 _match: /(\W*?)([\w-]+)(\s*=\s*)((?:\'[^\']*(?:\\.[^\']*)*\')|(?:\"[^\"]*(?:\\.[^\"]*)*\"))/ , _replace: "$1$2$3$4" - , _style: { attr_name: "color: green;", attr_value: "color: maroon;" } + , _style: { attr_name: "color: royalBlue;", attr_value: "color: maroon;" } } } }; @@ -228,7 +228,7 @@ ChiliBook.recipes[ "js.js" ] = } , sl_comment: { _match: /\/\/.*/ - , _style: 'color: green;' + , _style: 'color: gray;' } , string: { _match: /(?:\'[^\'\\\n]*(?:\\.[^\'\\\n]*)*\')|(?:\"[^\"\\\n]*(?:\\.[^\"\\\n]*)*\")/ @@ -236,7 +236,7 @@ ChiliBook.recipes[ "js.js" ] = } , num: { _match: /\b[+-]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?\b/ - , _style: 'color: red;' + , _style: 'color: #a00;' } , reg_not: { //this prevents "a / b / c" to be interpreted as a reg_exp _match: /(?:\w+\s*)\/[^\/\\\n]*(?:\\.[^\/\\\n]*)*\/[gim]*(?:\s*\w+)/ @@ -250,7 +250,7 @@ ChiliBook.recipes[ "js.js" ] = } , brace: { _match: /[\{\}]/ - , _style: 'color: red; font-weight: bold;' + , _style: 'color: #c00; font-weight: bold;' } , statement: { _match: /\b(with|while|var|try|throw|switch|return|if|for|finally|else|do|default|continue|const|catch|case|break)\b/ @@ -292,7 +292,7 @@ ChiliBook.recipes[ "css.js" ] = , _main: { comment: { _match: /\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\// - , _style: "color: olive;" + , _style: "color: gray;" } , directive: { _match: /@\w+/ @@ -352,7 +352,7 @@ ChiliBook.recipes[ "css.js" ] = } , number: { _match: /(?:\b[+-]?(?:\d*\.?\d+|\d+\.?\d*))(?:%|(?:(?:px|pt|em|)\b))/ - , _style: "color: red;" + , _style: "color: maroon;" } , color : { _match: /(?:\#[a-fA-F0-9]{3,6})|\b(?:yellow|white|teal|silver|red|purple|olive|navy|maroon|lime|green|gray|fuchsia|blue|black|aqua|YellowGreen|Yellow|WhiteSmoke|White|Wheat|Violet|Turquoise|Tomato|Thistle|Teal|Tan|SteelBlue|SpringGreen|Snow|SlateGrey|SlateGray|SlateBlue|SkyBlue|Silver|Sienna|SeaShell|SeaGreen|SandyBrown|Salmon|SaddleBrown|RoyalBlue|RosyBrown|Red|Purple|PowderBlue|Plum|Pink|Peru|PeachPuff|PapayaWhip|PaleVioletRed|PaleTurquoise|PaleGreen|PaleGoldenRod|Orchid|OrangeRed|Orange|OliveDrab|Olive|OldLace|Navy|NavajoWhite|Moccasin|MistyRose|MintCream|MidnightBlue|MediumVioletRed|MediumTurquoise|MediumSpringGreen|MediumSlateBlue|MediumSeaGreen|MediumPurple|MediumOrchid|MediumBlue|MediumAquaMarine|Maroon|Magenta|Linen|LimeGreen|Lime|LightYellow|LightSteelBlue|LightSlateGrey|LightSlateGray|LightSkyBlue|LightSeaGreen|LightSalmon|LightPink|LightGrey|LightGreen|LightGray|LightGoldenRodYellow|LightCyan|LightCoral|LightBlue|LemonChiffon|LawnGreen|LavenderBlush|Lavender|Khaki|Ivory|Indigo|IndianRed|HotPink|HoneyDew|Grey|GreenYellow|Green|Gray|GoldenRod|Gold|GhostWhite|Gainsboro|Fuchsia|ForestGreen|FloralWhite|FireBrick|DodgerBlue|DimGrey|DimGray|DeepSkyBlue|DeepPink|Darkorange|DarkViolet|DarkTurquoise|DarkSlateGrey|DarkSlateGray|DarkSlateBlue|DarkSeaGreen|DarkSalmon|DarkRed|DarkOrchid|DarkOliveGreen|DarkMagenta|DarkKhaki|DarkGrey|DarkGreen|DarkGray|DarkGoldenRod|DarkCyan|DarkBlue|Cyan|Crimson|Cornsilk|CornflowerBlue|Coral|Chocolate|Chartreuse|CadetBlue|BurlyWood|Brown|BlueViolet|Blue|BlanchedAlmond|Black|Bisque|Beige|Azure|Aquamarine|Aqua|AntiqueWhite|AliceBlue)\b/ diff --git a/docs/js/naturalSort.js b/docs/js/naturalSort.js new file mode 100644 index 00000000..f028a2b2 --- /dev/null +++ b/docs/js/naturalSort.js @@ -0,0 +1,42 @@ +/* + * Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license + * Author: Jim Palmer (based on chunking idea from Dave Koelle) + */ + function naturalSort (a, b) { + var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi, + sre = /(^[ ]*|[ ]*$)/g, + dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/, + hre = /^0x[0-9a-f]+$/i, + ore = /^0/, + i = function(s) { return naturalSort.insensitive && (''+s).toLowerCase() || ''+s }, + // convert all to strings strip whitespace + x = i(a).replace(sre, '') || '', + y = i(b).replace(sre, '') || '', + // chunk/tokenize + xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'), + yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'), + // numeric, hex or date detection + xD = parseInt(x.match(hre)) || (xN.length != 1 && x.match(dre) && Date.parse(x)), + yD = parseInt(y.match(hre)) || xD && y.match(dre) && Date.parse(y) || null, + oFxNcL, oFyNcL; + // first try and sort Hex codes or Dates + if (yD) + if ( xD < yD ) return -1; + else if ( xD > yD ) return 1; + // natural sorting through split numeric strings and default strings + for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) { + // find floats not starting with '0', string or 0 if not defined (Clint Priest) + oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0; + oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0; + // handle numeric vs string comparison - number < string - (Kyle Adams) + if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { return (isNaN(oFxNcL)) ? 1 : -1; } + // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2' + else if (typeof oFxNcL !== typeof oFyNcL) { + oFxNcL += ''; + oFyNcL += ''; + } + if (oFxNcL < oFyNcL) return -1; + if (oFxNcL > oFyNcL) return 1; + } + return 0; +} diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index 41817cfe..f1476c6e 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -1,5 +1,5 @@ /*! -* TableSorter 2.1.20 - Client-side table sorting with ease! +* TableSorter 2.2 - Client-side table sorting with ease! * @requires jQuery v1.2.6+ * * Copyright (c) 2007 Christian Bach @@ -18,9 +18,9 @@ $.extend({ tablesorter: new function() { - this.version = "2.1.20"; + this.version = "2.2"; - var parsers = [], widgets = [], tbl; + var parsers = [], widgets = [], tbl, $tbl; this.defaults = { cssHeader: "tablesorter-header", cssAsc: "tablesorter-headerSortUp", @@ -34,9 +34,11 @@ sortLocaleCompare: false, sortReset: false, sortRestart: false, - emptyTo : "bottom", // sort empty cell to bottom - stringTo : "max", // sort strings in numerical column as max value + emptyTo: "bottom", // sort empty cell to bottom + stringTo: "max", // sort strings in numerical column as max value textExtraction: "simple", + textSorter: null, // use custom text sorter + ignoreCase: true, parsers: {}, widgets: [], headers: {}, @@ -196,13 +198,26 @@ } /* utils */ + function buildRegex(){ + var a, acc = '[', t = $.tablesorter, + reg = t.characterEquivalents; + t.characterRegexArray = {}; + for (a in reg) { + if (typeof a === 'string') { + acc += reg[a]; + t.characterRegexArray[a] = new RegExp('[' + reg[a] + ']', 'g'); + } + } + t.characterRegex = new RegExp(acc + ']'); + } + function buildCache(table) { var b = table.tBodies, tc = table.config, totalRows, totalCells, parsers = tc.parsers, - t, i, j, c, cols, cacheTime; + t, i, j, k, c, cols, cacheTime; tc.cache = {}; if (tc.debug) { cacheTime = new Date(); @@ -267,7 +282,7 @@ b = table.tBodies, rows = [], r, n, totalRows, checkCell, - f, i, j, l, pos, appendTime; + f, i, j, k, l, pos, appendTime; if (c.debug) { appendTime = new Date(); } @@ -277,7 +292,6 @@ n = c.cache[k].normalized; totalRows = n.length; checkCell = totalRows ? (n[0].length - 1) : 0; - for (i = 0; i < totalRows; i++) { pos = n[i][checkCell]; rows.push(r[pos]); @@ -378,7 +392,7 @@ } $tableHeaders = $(c.selectorHeaders, table) .wrapInner("
") - .each(function (index) { + .each(function(index) { this.column = header_index[this.parentNode.rowIndex + "-" + this.cellIndex]; this.order = formatSortingOrder( checkHeaderOrder(table, index) ) ? [1,0,2] : [0,1,2]; this.count = -1; // set to -1 because clicking on the header automatically adds one @@ -450,7 +464,7 @@ function fixColumnWidth(table) { if (table.config.widthFixed) { var colgroup = $(''); - $("tr:first td", table.tBodies[0]).each(function () { + $("tr:first td", table.tBodies[0]).each(function() { colgroup.append($('').css('width', $(this).width())); }); $(table).prepend(colgroup); @@ -475,7 +489,7 @@ function multisort(table, sortList) { var dynamicExp, col, mx = 0, dir = 0, tc = table.config, l = sortList.length, bl = table.tBodies.length, - sortTime, i, j, c, cache, lc, s, e, order, orgOrderCol; + sortTime, i, j, k, c, cache, lc, s, e, order, orgOrderCol; if (tc.debug) { sortTime = new Date(); } for (k = 0; k < bl; k++) { dynamicExp = "var sortWrapper = function(a,b) {"; @@ -521,10 +535,11 @@ // Natural sort modified from: http://www.webdeveloper.com/forum/showthread.php?t=107909 function sortText(a, b, col) { if (a === b) { return 0; } - var c = tbl[0].config, cnt = 0, L, t, x, e = c.string[ (c.empties[col] || c.emptyTo ) ]; + var c = tbl.config, cnt = 0, L, t, x, e = c.string[ (c.empties[col] || c.emptyTo ) ]; if (a === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? -1 : 1) : -e || -1; } if (b === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? 1 : -1) : e || 1; } - if (c.sortLocaleCompare) { return a.localeCompare(b); } + if (typeof c.textSorter === 'function') { return c.textSorter(a, b); } + // if (c.sortLocaleCompare) { return a.localeCompare(b); } try { x = /^(\.)?\d/; L = Math.min(a.length, b.length) + 1; @@ -552,11 +567,12 @@ function sortTextDesc(a, b, col) { if (a === b) { return 0; } - var c = tbl[0].config, e = c.string[ (c.empties[col] || c.emptyTo ) ]; + var c = tbl.config, e = c.string[ (c.empties[col] || c.emptyTo ) ]; if (a === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? -1 : 1) : e || 1; } if (b === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? 1 : -1) : -e || -1; } - if (c.sortLocaleCompare) { return b.localeCompare(a); } - return -sortText(a, b); + if (typeof c.textSorter === 'function') { return c.textSorter(b, a); } + // if (c.sortLocaleCompare) { return b.localeCompare(a); } + return sortText(b, a); } // return text string value by adding up ascii value @@ -576,7 +592,7 @@ function sortNumeric(a, b, col, mx, d) { if (a === b) { return 0; } - var c = tbl[0].config, e = c.string[ (c.empties[col] || c.emptyTo ) ]; + var c = tbl.config, e = c.string[ (c.empties[col] || c.emptyTo ) ]; if (a === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? -1 : 1) : -e || -1; } if (b === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? 1 : -1) : e || 1; } if (isNaN(a)) { a = getTextValue(a, mx, d); } @@ -586,7 +602,7 @@ function sortNumericDesc(a, b, col, mx, d) { if (a === b) { return 0; } - var c = tbl[0].config, e = c.string[ (c.empties[col] || c.emptyTo ) ]; + var c = tbl.config, e = c.string[ (c.empties[col] || c.emptyTo ) ]; if (a === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? -1 : 1) : e || 1; } if (b === '' && e !== 0) { return (typeof(e) === 'boolean') ? (e ? 1 : -1) : -e || -1; } if (isNaN(a)) { a = getTextValue(a, mx, d); } @@ -600,34 +616,37 @@ // if no thead or tbody quit. if (!this.tHead || this.tBodies.length === 0) { return; } // declare - var $this, $headers, config, - totalRows, $cell, c, i, j, k, a, s, o; + var $headers, $cell, totalRows, + config, c, i, j, k, a, s, o; + tbl = this; // new blank config object - this.config = {}; + tbl.config = {}; // merge and extend. - c = config = $.extend(true, this.config, $.tablesorter.defaults, settings); + c = config = $.extend(true, tbl.config, $.tablesorter.defaults, settings); // store common expression for speed - tbl = $this = $(this).addClass(this.config.tableClass); + $tbl = $(tbl).addClass(c.tableClass); // save the settings where they read - $.data(this, "tablesorter", c); + $.data(tbl, "tablesorter", c); + // build up character equivalent cross-reference + buildRegex(); // digit sort text location; keeping max+/- for backwards compatibility c.string = { 'max': 1, 'min': -1, 'max+': 1, 'max-': -1, 'zero': 0, 'none': 0, 'null': 0, 'top': true, 'bottom': false }; // build headers - $headers = buildHeaders(this); + $headers = buildHeaders(tbl); // try to auto detect column type, and store in tables config - c.parsers = buildParserCache(this, $headers); + c.parsers = buildParserCache(tbl, $headers); // build the cache for the tbody cells - buildCache(this); + buildCache(tbl); // fixate columns if the users supplies the fixedWidth option - fixColumnWidth(this); + fixColumnWidth(tbl); // apply event handling to headers // this is to big, perhaps break it out? $headers .click(function(e) { - // totalRows = ($this[0].tBodies[0] && $this[0].tBodies[0].rows.length) || 0; + // totalRows = (tbl.tBodies[0] && tbl.tBodies[0].rows.length) || 0; if (!this.sortDisabled) { // Only call sortStart if sorting is enabled. - $this.trigger("sortStart", tbl[0]); + $tbl.trigger("sortStart", tbl); // store exp, for speed $cell = $(this); k = !e[c.sortMultiSortKey]; @@ -689,10 +708,10 @@ } } // sortBegin event triggered immediately before the sort - $this.trigger("sortBegin", tbl[0]); + $tbl.trigger("sortBegin", tbl); // set css for headers - setHeadersCss($this[0], $headers, c.sortList); - appendToTable($this[0], multisort($this[0], c.sortList)); + setHeadersCss(tbl, $headers, c.sortList); + appendToTable(tbl, multisort(tbl, c.sortList)); // stop normal event by returning false return false; } @@ -707,7 +726,7 @@ } }); // apply easy methods that trigger binded events - $this + $tbl .bind("update", function(e, resort) { // remove rows/elements before update $(c.selectorRemove, this).remove(); @@ -715,25 +734,25 @@ c.parsers = buildParserCache(this, $headers); // rebuild the cache map buildCache(this); - if (resort !== false) { $this.trigger("sorton", [c.sortList]); } + if (resort !== false) { $tbl.trigger("sorton", [c.sortList]); } }) .bind("updateCell", function(e, cell, resort) { // get position from the dom. var pos = [(cell.parentNode.rowIndex - 1), cell.cellIndex], // update cache - format: function(s, table, cell, cellIndex) - tbodyindex = $(cell).closest('tbody').index(); - table.cache[tbodyindex].normalized[pos[0]][pos[1]] = c.parsers[pos[1]].format(getElementText(c, cell, pos[1]), $this, cell, pos[1]); - if (resort !== false) { $this.trigger("sorton", [c.sortList]); } + tbodyindex = $tbl.find('tbody').index( $(cell).closest('tbody') ); + tbl.config.cache[tbodyindex].normalized[pos[0]][pos[1]] = c.parsers[pos[1]].format(getElementText(c, cell, pos[1]), tbl, cell, pos[1]); + if (resort !== false) { $tbl.trigger("sorton", [c.sortList]); } }) .bind("addRows", function(e, $row, resort) { var i, rows = $row.filter('tr').length, dat = [], l = $row[0].cells.length, - tbodyindex = $row.closest('tbody').index(); + tbodyindex = $tbl.find('tbody').index( $row.closest('tbody') ); // add each row for (i = 0; i < rows; i++) { // add each cell for (j = 0; j < l; j++) { - dat[j] = c.parsers[j].format(getElementText(c, $row[i].cells[j], j), $this, $row[i].cells[j], j ); + dat[j] = c.parsers[j].format( getElementText(c, $row[i].cells[j], j), tbl, $row[i].cells[j], j ); } // add the row index to the end dat.push(c.cache[tbodyindex].row.length); @@ -743,10 +762,10 @@ dat = []; } // resort using current settings - if (resort !== false) { $this.trigger("sorton", [c.sortList]); } + if (resort !== false) { $tbl.trigger("sorton", [c.sortList]); } }) .bind("sorton", function(e, list) { - $this.trigger("sortStart", tbl[0]); + $tbl.trigger("sortStart", tbl); c.sortList = list; // update and store the sortlist var sortList = c.sortList; @@ -757,13 +776,13 @@ // sort the table and append it to the dom appendToTable(this, multisort(this, sortList)); }) - .bind("appendCache", function () { + .bind("appendCache", function() { appendToTable(this); }) - .bind("applyWidgetId", function (e, id) { + .bind("applyWidgetId", function(e, id) { getWidgetById(id).format(this); }) - .bind("applyWidgets", function () { + .bind("applyWidgets", function() { // apply widgets applyWidget(this); }); @@ -774,13 +793,13 @@ applyWidget(this, true); // if user has supplied a sort list to constructor. if (c.sortList.length > 0) { - $this.trigger("sorton", [c.sortList]); + $tbl.trigger("sorton", [c.sortList]); } else { // apply widget format applyWidget(this); } this.hasInitialized = true; - $this.trigger('tablesorter-initialized', this); + $tbl.trigger('tablesorter-initialized', this); if (typeof c.initialized === 'function') { c.initialized(this); } }); }; @@ -795,12 +814,12 @@ parsers.push(parser); } }; - this.addWidget = function (widget) { + this.addWidget = function(widget) { widgets.push(widget); }; this.formatFloat = function(s) { if (typeof(s) !== 'string') { return s; } - if (tbl[0].config.usNumberFormat) { + if (tbl.config.usNumberFormat) { // US Format - 1,234,567.89 -> 1234567.89 s = s.replace(/,/g,''); } else { @@ -819,9 +838,37 @@ // replace all unwanted chars and match. return (/^[\-+(]?\d*[)]?$/).test($.trim(s.replace(/[,.'\s]/g, ''))); }; - this.clearTableBody = function (table) { + // used when replacing accented characters during sorting + this.characterEquivalents = { + "a" : "\u00e1\u00e0\u00e2\u00e3\u00e4", // áàâãä + "A" : "\u00c1\u00c0\u00c2\u00c3\u00c4", // ÁÀÂÃÄ + "c" : "\u00e7", // ç + "C" : "\u00c7", // Ç + "e" : "\u00e9\u00e8\u00ea\u00eb", // éèêë + "E" : "\u00c9\u00c8\u00ca\u00cb", // ÉÈÊË + "i" : "\u00ed\u00ec\u0130\u00ee\u00ef", // íìİîï + "I" : "\u00cd\u00cc\u0130\u00ce\u00cf", // ÍÌİÎÏ + "o" : "\u00f3\u00f2\u00f4\u00f5\u00f6", // óòôõö + "O" : "\u00d3\u00d2\u00d4\u00d5\u00d6", // ÓÒÔÕÖ + "S" : "\u00df", // ß + "u" : "\u00fa\u00f9\u00fb\u00fc", // úùûü + "U" : "\u00da\u00d9\u00db\u00dc" // ÚÙÛÜ + }; + this.replaceAccents = function(s) { + if (this.characterRegex.test(s)) { + var a, eq = this.characterEquivalents; + for (a in eq) { + if (typeof a === 'string') { + s = s.replace( this.characterRegexArray[a], a ); + } + } + } + return s; + }; + this.clearTableBody = function(table) { $(table.tBodies).filter(':not(.' + table.config.cssInfoBlock + ')').empty(); }; + } })(); @@ -839,8 +886,10 @@ is: function(s) { return true; }, - format: function(s) { - return $.trim(s.toLocaleLowerCase()); + format: function(s, table) { + var c = table.config; + s = $.trim( c.ignoreCase ? s.toLocaleLowerCase() : s ); + return c.sortLocaleCompare ? $.tablesorter.replaceAccents(s) : s; }, type: "text" }); @@ -859,7 +908,7 @@ ts.addParser({ id: "currency", is: function(s) { - return (/^\(?[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]/).test(s); // $?. + return (/^\(?[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]/).test(s); // #$ $%"?. }, format: function(s) { return $.tablesorter.formatFloat(s.replace(/[^0-9,. \-()]/g, "")); diff --git a/js/jquery.tablesorter.min.js b/js/jquery.tablesorter.min.js index d6fbe3ce..41ed6b47 100644 --- a/js/jquery.tablesorter.min.js +++ b/js/jquery.tablesorter.min.js @@ -1,6 +1,6 @@ /*! -* TableSorter 2.1.20 - Client-side table sorting with ease! +* TableSorter 2.2 - Client-side table sorting with ease! * Minified using http://dean.edwards.name/packer/ * Copyright (c) 2007 Christian Bach */ -!(function($){$.extend({tablesorter:new function(){this.version="2.1.20";var q=[],widgets=[],tbl;this.defaults={cssHeader:"tablesorter-header",cssAsc:"tablesorter-headerSortUp",cssDesc:"tablesorter-headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:false,sortReset:false,sortRestart:false,emptyTo:"bottom",stringTo:"max",textExtraction:"simple",parsers:{},widgets:[],headers:{},empties:{},strings:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"mmddyyyy",usNumberFormat:true,onRenderHeader:null,selectorHeaders:'thead th',selectorRemove:"tr.remove-me",tableClass:'tablesorter',debug:false,widgetOptions:{zebra:["even","odd"]}};function log(s){if(typeof console!=="undefined"&&typeof console.log!=="undefined"){console.log(s)}else{alert(s)}}function benchmark(s,d){log(s+" ("+(new Date().getTime()-d.getTime())+"ms)")}this.benchmark=benchmark;this.hasInitialized=false;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,tbl,c)}else if(typeof(te)==="object"&&te.hasOwnProperty(c)){d=te[c](b,tbl,c)}else{d=$(b).text()}}return d}function getParserById(a){var i,l=q.length;for(i=0;i").each(function(a){this.column=header_index[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(checkHeaderOrder(b,a))?[1,0,2]:[0,1,2];this.count=-1;if(checkHeaderMetadata(this)||checkHeaderOptions(b,a)||$(this).hasClass('sorter-false')){this.sortDisabled=true}this.lockedOrder=false;lock=checkHeaderLocked(b,a);if(typeof(lock)!=='undefined'&&lock!==false){this.order=this.lockedOrder=formatSortingOrder(lock)?[1,1,1]:[0,0,0]}if(!this.sortDisabled){$th=$(this).addClass(c.cssHeader);if(c.onRenderHeader){c.onRenderHeader.apply($th,[a])}}c.headerList[a]=this;$(this).parent().addClass(c.cssHeader)});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;i1){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');$("tr:first td",a.tBodies[0]).each(function(){b.append($('').css('width',$(this).width()))});$(a).prepend(b)}}function updateHeaderSortCount(a,b){var i,s,o,c=a.config,l=b.length;for(i=0;ib)?1:-1}catch(er){return 0}}function sortTextDesc(a,b,d){if(a===b){return 0}var c=tbl[0].config,e=c.string[(c.empties[d]||c.emptyTo)];if(a===''&&e!==0){return(typeof(e)==='boolean')?(e?-1:1):e||1}if(b===''&&e!==0){return(typeof(e)==='boolean')?(e?1:-1):-e||-1}if(c.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;i0){f.trigger("sorton",[c.sortList])}else{applyWidget(this)}this.hasInitialized=true})};this.addParser=function(b){var i,l=q.length,a=true;for(i=0;i").each(function(a){this.column=header_index[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(checkHeaderOrder(b,a))?[1,0,2]:[0,1,2];this.count=-1;if(checkHeaderMetadata(this)||checkHeaderOptions(b,a)||$(this).hasClass('sorter-false')){this.sortDisabled=true}this.lockedOrder=false;lock=checkHeaderLocked(b,a);if(typeof(lock)!=='undefined'&&lock!==false){this.order=this.lockedOrder=formatSortingOrder(lock)?[1,1,1]:[0,0,0]}if(!this.sortDisabled){$th=$(this).addClass(c.cssHeader);if(c.onRenderHeader){c.onRenderHeader.apply($th,[a])}}c.headerList[a]=this;$(this).parent().addClass(c.cssHeader)});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;i1){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');$("tr:first td",a.tBodies[0]).each(function(){b.append($('').css('width',$(this).width()))});$(a).prepend(b)}}function updateHeaderSortCount(a,b){var i,s,o,c=a.config,l=b.length;for(i=0;ib)?1:-1}catch(er){return 0}}function sortTextDesc(a,b,d){if(a===b){return 0}var c=tbl.config,e=c.string[(c.empties[d]||c.emptyTo)];if(a===''&&e!==0){return(typeof(e)==='boolean')?(e?-1:1):e||1}if(b===''&&e!==0){return(typeof(e)==='boolean')?(e?1:-1):-e||-1}if(typeof c.textSorter==='function'){return c.textSorter(b,a)}return sortText(b,a)}function getTextValue(a,b,d){if(b){var i,l=a.length,n=b+d;for(i=0;i0){$tbl.trigger("sorton",[c.sortList])}else{applyWidget(this)}this.hasInitialized=true;$tbl.trigger('tablesorter-initialized',this);if(typeof c.initialized==='function'){c.initialized(this)}})};this.addParser=function(b){var i,l=q.length,a=true;for(i=0;i1){d.each(function(){d=$(this);if(!d.hasClass(child)){row++}even=(row%2===0);d.removeClass(css[even?1:0]).addClass(css[even?0:1])})}}if(a.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time)}}})})(jQuery); diff --git a/js/jquery.tablesorter.widgets.js b/js/jquery.tablesorter.widgets.js index 8dadead9..0167d71a 100644 --- a/js/jquery.tablesorter.widgets.js +++ b/js/jquery.tablesorter.widgets.js @@ -1,4 +1,4 @@ -/*! tableSorter 2.1 widgets - updated 4/23/2012 +/*! tableSorter 2.2 widgets - updated 5/3/2012 * * jQuery UI Theme * Column Styles @@ -8,7 +8,7 @@ * Save Sort * */ -(function($){ +;(function($){ // *** Store data in local storage, with a cookie fallback *** /* IE7 needs JSON library for JSON.stringify - (http://caniuse.com/#search=json) @@ -125,7 +125,7 @@ $.tablesorter.addWidget({ $.tablesorter.addWidget({ id: "columns", format: function(table) { - var $tr, $td, time, i, last, rmv, k, + var $tr, $td, time, last, rmv, k, c = table.config, b = table.tBodies, list = c.sortList, @@ -144,7 +144,7 @@ $.tablesorter.addWidget({ for (k = 0; k < b.length; k++ ) { // loop through the visible rows $tr = $(b[k]).filter(':not(' + c.cssInfoBlock + ')').find('tr:visible:not(.' + c.cssInfoBlock + ')'); - $tr.each(function (i) { + $tr.each(function(i) { $td = $(this).children().removeClass(rmv); // primary sort column class $td.eq(list[0][0]).addClass(css[0]); diff --git a/js/jquery.tablesorter.widgets.min.js b/js/jquery.tablesorter.widgets.min.js index 9afdee50..f14d192e 100644 --- a/js/jquery.tablesorter.widgets.min.js +++ b/js/jquery.tablesorter.widgets.min.js @@ -1,10 +1,10 @@ -/*! tableSorter 2.1 widgets - updated 4/23/2012 */ -(function(b){ -b.tablesorter.storage=function(a,e,d){var c,g=!1;c={};var i=a.id||b(".tablesorter").index(b(a)),f=window.location.pathname;try{g=!!localStorage.getItem}catch(j){}b.parseJSON&&(g?c=b.parseJSON(localStorage[e])||{}:(c=document.cookie.split(/[;\s|=]/),a=b.inArray(e,c)+1,c=0!==a?b.parseJSON(c[a])||{}:{}));if(d&&JSON&&JSON.hasOwnProperty("stringify")){if(!c[f]||!c[f][i])c[f]||(c[f]={});c[f][i]=d;g?localStorage[e]=JSON.stringify(c):(a=new Date,a.setTime(a.getTime()+31536E6),document.cookie= e+"="+JSON.stringify(c).replace(/\"/g,'"')+"; expires="+a.toGMTString()+"; path=/")}else return c&&c.hasOwnProperty(f)&&c[f].hasOwnProperty(i)?c[f][i]:{}}; -b.tablesorter.addWidget({id:"uitheme",format:function(a){var e,d,c,g,i,f=b(a),j=a.config,h=j.widgetOptions,k=["ui-icon-arrowthick-2-n-s","ui-icon-arrowthick-1-s","ui-icon-arrowthick-1-n"],k=j.widgetUitheme&&j.widgetUitheme.hasOwnProperty("css")?j.widgetUitheme.css||k:h&&h.hasOwnProperty("uitheme")?h.uitheme:k;c=k.join(" ");j.debug&&(e=new Date); f.hasClass("ui-theme")||(f.addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),b.each(j.headerList,function(){b(this).addClass("ui-widget-header ui-corner-all ui-state-default").append('').wrapInner('
').hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")})}));b.each(j.headerList,function(a){g=b(this);if(this.sortDisabled)g.find("span.ui-icon").removeClass(c+" ui-icon");else{d=g.hasClass(j.cssAsc)? k[1]:g.hasClass(j.cssDesc)?k[2]:g.hasClass(j.cssHeader)?k[0]:"";i=f.hasClass("hasStickyHeaders")?f.find("tr."+(h.stickyHeaders||"tablesorter-stickyHeader")).find("th").eq(a).add(g):g;i[d===k[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(c).addClass(d)}});j.debug&&b.tablesorter.benchmark("Applying uitheme widget",e)}}); -b.tablesorter.addWidget({id:"columns",format:function(a){var e,d,c,g,i=a.config,f=i.sortList,j=f.length,h=["primary","secondary","tertiary"],h=i.widgetColumns&& i.widgetColumns.hasOwnProperty("css")?i.widgetColumns.css||h:i.widgetOptions&&i.widgetOptions.hasOwnProperty("columns")?i.widgetOptions.columns||h:h;c=h.length-1;g=h.join(" ");i.debug&&(d=new Date);f&&f[0]?b("tr:visible",a.tBodies[0]).each(function(a){e=b(this).children().removeClass(g);e.eq(f[0][0]).addClass(h[0]);if(1',o;h.debug&&(o=new Date);for(e=0;eb.top&&a
').wrapInner('
')}).bind("mousemove",function(a){if(0!==i&&f){var b=a.pageX-i;f.width()<-b||j&&j.width()<=b||(j.width(j.width()+ b),i=a.pageX)}}).bind("mouseup",function(){d&&b.tablesorter.storage&&f&&(d[j.index()]=j.width(),b.tablesorter.storage(a,"tablesorter-resizable",d));h();return!1}).find(".tablesorter-resizer").bind("mousedown",function(a){f=b(a.target).closest("th");j=f.prev();i=a.pageX});b(a).find("thead").bind("mouseup mouseleave",function(){h()})}}}); -b.tablesorter.addWidget({id:"saveSort",init:function(a,b,d){d.format(a,!0)},format:function(a,e){var d,c,g=a.config;d={sortList:g.sortList};g.debug&&(c=new Date);b(a).hasClass("hasSaveSort")? a.hasInitialized&&b.tablesorter.storage&&(b.tablesorter.storage(a,"tablesorter-savesort",d),g.debug&&b.tablesorter.benchmark("saveSort widget: Saving last sort: "+g.sortList,c)):(b(a).addClass("hasSaveSort"),d="",b.tablesorter.storage&&(d=(d=b.tablesorter.storage(a,"tablesorter-savesort"))&&d.hasOwnProperty("sortList")&&b.isArray(d.sortList)?d.sortList:"",g.debug&&b.tablesorter.benchmark("saveSort: Last sort loaded: "+d,c)),e&&d&&0').wrapInner('
').hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")})}));b.each(h.headerList,function(a){g=b(this);if(this.sortDisabled)g.find("span.ui-icon").removeClass(c+" ui-icon");else{d=g.hasClass(h.cssAsc)? k[1]:g.hasClass(h.cssDesc)?k[2]:g.hasClass(h.cssHeader)?k[0]:"";i=e.hasClass("hasStickyHeaders")?e.find("tr."+(j.stickyHeaders||"tablesorter-stickyHeader")).find("th").eq(a).add(g):g;i[d===k[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(c).addClass(d)}});h.debug&&b.tablesorter.benchmark("Applying uitheme widget",f)}}); +b.tablesorter.addWidget({id:"columns",format:function(a){var f,d,c,g,i,e=a.config,h=a.tBodies,j=e.sortList,k=j.length,l=["primary","secondary","tertiary"], l=e.widgetColumns&&e.widgetColumns.hasOwnProperty("css")?e.widgetColumns.css||l:e.widgetOptions&&e.widgetOptions.hasOwnProperty("columns")?e.widgetOptions.columns||l:l;c=l.length-1;g=l.join(" ");e.debug&&(d=new Date);if(j&&j[0])for(i=0;i',o;j.debug&&(o=new Date);for(f=0;fa.top&&b
').wrapInner('
')}).bind("mousemove", function(a){if(0!==i&&e){var b=a.pageX-i;e.width()<-b||h&&h.width()<=b||(h.width(h.width()+b),i=a.pageX)}}).bind("mouseup",function(){d&&(b.tablesorter.storage&&e)&&(d[h.index()]=h.width(),b.tablesorter.storage(a,"tablesorter-resizable",d));j();return!1}).find(".tablesorter-resizer").bind("mousedown",function(a){e=b(a.target).closest("th");h=e.prev();i=a.pageX});b(a).find("thead").bind("mouseup mouseleave",function(){j()})}}}); +b.tablesorter.addWidget({id:"saveSort",init:function(a,b,d){d.format(a, !0)},format:function(a,f){var d,c,g=a.config;d={sortList:g.sortList};g.debug&&(c=new Date);b(a).hasClass("hasSaveSort")?a.hasInitialized&&b.tablesorter.storage&&(b.tablesorter.storage(a,"tablesorter-savesort",d),g.debug&&b.tablesorter.benchmark("saveSort widget: Saving last sort: "+g.sortList,c)):(b(a).addClass("hasSaveSort"),d="",b.tablesorter.storage&&(d=(d=b.tablesorter.storage(a,"tablesorter-savesort"))&&d.hasOwnProperty("sortList")&&b.isArray(d.sortList)?d.sortList:"",g.debug&&b.tablesorter.benchmark("saveSort: Last sort loaded: "+ d,c)),f&&d&&0