empty cell sort & ui theme fixes

This commit is contained in:
Rob Garrison 2011-12-14 11:37:55 -06:00
parent 95311a78ee
commit 8c04cd4400
7 changed files with 36 additions and 98 deletions

View File

@ -34,6 +34,11 @@ 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.25 (2011-12-14)
* The ui theme and sticky header widgets now work together and update the arrow direction. Fix for [issue #15](https://github.com/Mottie/tablesorter/issues/15).
* Empty cells with only a tab or space will now sort at the bottom. Thanks to [pursual](https://github.com/pursual) for the fix for [issue #16](https://github.com/Mottie/tablesorter/issues/16).
####Version 2.0.24 (2011-12-12)
* Modified empty cell sorting to always sort at the bottom. Fix for [issue #14](https://github.com/Mottie/tablesorter/issues/14).
@ -144,78 +149,3 @@ View the [complete listing here](http://mottie.github.com/tablesorter/changelog.
* Added "filter-false" class, that when applied will disable the filter widget for that column.
* Updated the headers docs and the filter widget demo.
* Updated the currency parser to use unicode characters to better work in different document formats.
#### Version 2.0.19 (2011-09-16)
* Added code in attempt to clear the table headers between multiple tables - fix for [issue #2](https://github.com/Mottie/tablesorter/issues/2).
* Cleaned up some code and wrapped the widget code to prevent conflicts with other javascript libraries.
* Updated the columns widget:
* Added css examples to the [demo](http://mottie.github.com/tablesorter/docs/example-widget-columns.html).
* Removed the `widgetColumns` option from the core, but it is still used by the widget - the way it is used hasn't changed.
* Updated the uitheme widget:
* Added `widgetUitheme` option - used by the widget, but not included in the core. See the demo for a better example.
* Example added to the [uitheme widget demo](http://mottie.github.com/tablesorter/docs/example-widget-columns.html).
#### Version 2.0.18.1 (2011-09-14)
* Updated the "uitheme" widget with method to add zebra striping and hovered header classes.
#### Version 2.0.18 (2011-09-13)
* Fixed a bug in the column widget, it would cause an error if no initial sort was set.
* Fixed a bug where an error would occur if a widget doesn't exist.
* Updated pager widget to allow restoring the pager plugin & updated demo.
* Added column filter widget. It is designed so that each column has an filter.
#### Version 2.0.17 (2011-09-11)
* Added a jquery.tablesorter.widget.js file:
* It contains the "uitheme" widget, to add any jQuery UI theme, and the new "columns" widget, to style columns.
* The blue and green themes have been updated with the added styles from the columns widget.
* Added a Columns Widget demo and instructions.
* Added a `widgetColumns` option which defines the css classes added by the columns widget.
* Added notes to the pager plugin demo page to better specify when a change was added.
* The green theme header images have been modified to better work with variable width tables.
#### Version 2.0.16 (2011-09-08)
* Added notes to demo pages to indicate if the original (version 2.0.5, at [tablesorter.com](http://tablesorter.com/docs/)) does have that option or method.
* Added "addRows" method that allows adding table rows.
* This method differs from the "update" method in that it only adds rows to the cache.
* Use this new method to add rows to a table with the pager plugin applied. Using the "update" method on a table with the pager plugin will remove all hidden rows from the cache.
* Added a "destroy.pager" method to remove the pager from the table - pager demo updated.
#### Version 2.0.15 (2011-08-23)
* Fixed a problem that caused a javascript error when a table header cell doesn't have a class name.
#### Version 2.0.14 (2011-08-22)
* Reverted the changes made in 2.0.13 and added checks to prevent errors.
* Allowed sorting an empty table which would then automatically sort its contents when the table is updated.
* Modified "Update" and "UpdateCell" methods to automatically resort the table using the existing sort.
* Updated the [Initializing tablesorter on an empty table](http://mottie.github.com/tablesorter/docs/example-empty-table.html) demo and [Updating a table cell](http://mottie.github.com/tablesorter/docs/example-update-cell.html).
#### Version 2.0.13 (2011-08-19)
* Fixed a problem where a javascript error would occur when initializing a multi sort on an empty table. Thanks again to Eugene Ivakhiv!
#### Version 2.0.12 (2011-08-19)
* Updated the `textExtraction` functionality
* The original textExtraction function was only able to be applied to all cells.
* Apparently the ability to define textExtraction on a per column basis was misinterpreted by me, so now I've added it.
* Use the option as follows:
```javascript
$("table").tablesorter({
textExtraction: {
0: function(node) { return $(node).find(selector1).text(); },
1: function(node) { return $(node).find(selector2).text(); },
// etc
}
});
```
* Updated the [Dealing with markup inside cells](http://mottie.github.com/tablesorter/docs/example-option-text-extraction.html) demo.
* Thanks to Eugene Ivakhiv for bringing this issue to my attention in my blog.

View File

@ -1,5 +1,11 @@
TableSorter Change Log
Version 2.0.25 (2011-12-14)
============================
* The ui theme and sticky header widgets now work together and update the arrow direction. Fix for [issue #15](https://github.com/Mottie/tablesorter/issues/15).
* Empty cells with only a tab or space will now sort at the bottom. Thanks to [pursual](https://github.com/pursual) for the fix for [issue #16](https://github.com/Mottie/tablesorter/issues/16).
Version 2.0.24 (2011-12-12)
============================

View File

@ -1,6 +1,6 @@
/*
* TableSorter 2.0 - Client-side table sorting with ease!
* Version 2.0.24
* Version 2.0.25
* @requires jQuery v1.2.3
*
* Copyright (c) 2007 Christian Bach
@ -252,7 +252,7 @@
}
cache.row.push(c);
for (j = 0; j < totalCells; ++j) {
t = getElementText(table.config, c[0].cells[j], j);
t = trimAndGetNodeText(table.config, c[0].cells[j], j);
// don't bother parsing if the string is empty - previously parsing would change it to zero
cols.push( t === '' ? '' : parsers[j].format(t, table, c[0].cells[j], j));
}

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/* TableSorter 2.0 Widgets - updated 12/12/2011
/* TableSorter 2.0 Widgets - updated 12/14/2011
*
* jQuery UI Theme
* Column Styles
@ -14,7 +14,7 @@
$.tablesorter.addWidget({
id: "uitheme",
format: function(table) {
var time, klass, rmv, c = table.config,
var time, klass, rmv, $t, t, c = table.config, $table = $(table),
// ["up/down arrow (cssHeaders, unsorted)", "down arrow (cssDesc, descending)", "up arrow (cssAsc, ascending)" ]
icons = ["ui-icon-arrowthick-2-n-s", "ui-icon-arrowthick-1-s", "ui-icon-arrowthick-1-n"];
if (c.widgetUitheme && c.widgetUitheme.hasOwnProperty('css')) { icons = c.widgetUitheme.css || icons; }
@ -22,27 +22,29 @@ $.tablesorter.addWidget({
if (c.debug) {
time = new Date();
}
if (!$(table).is('.ui-theme')) {
$(table).addClass('ui-widget ui-widget-content ui-corner-all ui-theme');
if (!$table.is('.ui-theme')) {
$table.addClass('ui-widget ui-widget-content ui-corner-all ui-theme');
$.each(c.headerList, function(){
$(this)
// using "ui-theme" class in case the user adds their own ui-icon using onRenderHeader
.addClass('ui-widget-header ui-corner-all')
.append('<span class="ui-icon"/>')
.hover(function(){
$(this).addClass('ui-state-hover');
}, function(){
$(this).removeClass('ui-state-hover');
})
.append('<span class="ui-icon"/>');
});
});
}
$.each(c.headerList, function(i){
$t = $(this);
if (c.headers[i] && c.headers[i].sorter === false) {
// no sort arrows for disabled columns!
$(this).find('span.ui-icon').removeClass(rmv + ' ui-icon');
$t.find('span.ui-icon').removeClass(rmv + ' ui-icon');
} else {
klass = ($(this).is('.' + c.cssAsc)) ? icons[1] : ($(this).is('.' + c.cssDesc)) ? icons[2] : $(this).is('.' + c.cssHeader) ? icons[0] : '';
$(this)[klass === icons[0] ? 'removeClass' : 'addClass']('ui-state-active')
klass = ($t.hasClass(c.cssAsc)) ? icons[1] : ($t.hasClass(c.cssDesc)) ? icons[2] : $t.hasClass(c.cssHeader) ? icons[0] : '';
t = ($table.hasClass('hasStickyHeaders')) ? $table.find('tr.stickyHeader').find('th').eq(i).add($t) : $t;
t[klass === icons[0] ? 'removeClass' : 'addClass']('ui-state-active')
.find('span.ui-icon').removeClass(rmv).addClass(klass);
}
});
@ -153,8 +155,8 @@ $.tablesorter.addWidget({
$.tablesorter.addWidget({
id: "stickyHeaders",
format: function(table) {
if ($(table).find('.stickyHeader').length) { return; }
var $table = $(table),
if ($(table).hasClass('hasStickyHeaders')) { return; }
var $table = $(table).addClass('hasStickyHeaders'),
win = $(window),
header = $(table).find('thead'),
hdrCells = header.find('tr').children(),

View File

@ -1,9 +1,9 @@
/* TableSorter 2.0 Widgets - updated 12/12/2011 */
/* TableSorter 2.0 Widgets - updated 12/14/2011 */
(function(b){
b.tablesorter.addWidget({id:"uitheme",format:function(d){var c,a,g,f=d.config,e=["ui-icon-arrowthick-2-n-s","ui-icon-arrowthick-1-s","ui-icon-arrowthick-1-n"];f.widgetUitheme&&f.widgetUitheme.hasOwnProperty("css")&&(e=f.widgetUitheme.css||e);g=e.join(" ");f.debug&&(c=new Date);b(d).is(".ui-theme")||(b(d).addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),b.each(f.headerList,function(){b(this).addClass("ui-widget-header ui-corner-all").hover(function(){b(this).addClass("ui-state-hover")}, function(){b(this).removeClass("ui-state-hover")}).append('<span class="ui-icon"/>')}));b.each(f.headerList,function(c){f.headers[c]&&!1===f.headers[c].sorter?b(this).find("span.ui-icon").removeClass(g+" ui-icon"):(a=b(this).is("."+f.cssAsc)?e[1]:b(this).is("."+f.cssDesc)?e[2]:b(this).is("."+f.cssHeader)?e[0]:"",b(this)[a===e[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(g).addClass(a))});f.debug&&b.tablesorter.benchmark("Applying uitheme widget",c)}});
b.tablesorter.addWidget({id:"columns", format:function(d){var c,a,g,f,e=d.config,j=e.sortList,h=j.length,i=["primary","secondary","tertiary"];e.widgetColumns&&e.widgetColumns.hasOwnProperty("css")&&(i=e.widgetColumns.css||i);g=i.length-1;f=i.join(" ");e.debug&&(a=new Date);j&&j[0]&&b("tr:visible",d.tBodies[0]).each(function(a){c=b(this).children().removeClass(f);c.eq(j[0][0]).addClass(i[0]);if(1<h)for(a=1;a<h;a++)c.eq(j[a][0]).addClass(i[a]||i[g])});e.debug&&b.tablesorter.benchmark("Applying Columns widget",a)}});
b.tablesorter.addWidget({id:"filter", format:function(d){if(!d.config.filtering){var c,a,g,f,e,j,h=d.config,i=h.headerList.length,k=b(d),d='<tr class="filters">',l;h.debug&&(l=new Date);for(c=0;c<i;c++)d+='<td><input type="text" class="filter" data-col="'+c+'" style="',d+=h.headers[c]&&"filter"in h.headers[c]&&!1===h.headers[c].filter||b(h.headerList[c]).is(".filter-false")?"display:none":"",d+='"></td>';k.find("thead").append(d+="</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;e=b(this).nextUntil("tr:not(.expand-child)");f=e.length&&("undefined"!==typeof h.widgetFilterChildRows?h.widgetFilterChildRows:1)?e.text():"";j=b(this).find("td");for(c=0;c<i;c++)""!==a[c]&&0<=(j.eq(c).text()+f).toLowerCase().indexOf(a[c])?g=g?!0:!1:""!==a[c]&&(g=!1);b(this)[g?"show":"hide"]();if(e.length)e[g?"show":"hide"]()});k.trigger("applyWidgets")});h.filtering=!0; h.debug&&b.tablesorter.benchmark("Applying Filter widget",l)}}});
b.tablesorter.addWidget({id:"stickyHeaders",format:function(d){if(!b(d).find(".stickyHeader").length){var c=b(d),a=b(window),g=b(d).find("thead"),f=g.find("tr").children(),e=f.eq(0),j=parseInt(f.eq(0).css("border-left-width"),10),h=g.find("tr:not(.filters)").clone().addClass("stickyHeader").css({width:g.outerWidth()+2*j,position:"fixed",left:e.offset().left,marginLeft:-j,top:0,visibility:"hidden",zIndex:10}),i=h.children(),k;c.bind("sortEnd", function(a,c){var d=b(c).find("thead tr"),e=d.filter(".stickyHeader").children();d.filter(":not(.stickyHeader)").children().each(function(a){e.eq(a).attr("class",b(this).attr("class"))})});f.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(h);a.scroll(function(){var b=e.offset(),d=a.scrollTop(),d=d>b.top&&d<b.top+c.find("tbody").height()?"visible":"hidden";h.css({left:b.left- a.scrollLeft(),visibility:d});d!==k&&(a.resize(),k=d)}).resize(function(){h.css({left:e.offset().left-a.scrollLeft(),width:g.outerWidth()+2*j});i.each(function(a){b(this).width(f.eq(a).width())})})}}});
b.tablesorter.addWidget({id:"resizable",format:function(d){if(!d.config.resizable){var c,a=d.config,g=a.headerList,f=g.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<f;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(c){a.resizable_target=b(c.target).closest("th");a.resizable_position=c.pageX}).end().bind("mousemove",function(b){if(!(0===a.resizable_position||null===typeof a.resizable_target)){var c=b.pageX-a.resizable_position,d=a.resizable_target.closest("th").prev();if(!(a.resizable_target.width()<-c||d&&d.width()<=c))d.width(d.width()+c),a.resizable_position=b.pageX}}).bind("mouseup",function(){e();return!1});b(d).find("thead").bind("mouseup mouseleave",function(){e()});a.resizable=!0}}})
(function(c){
c.tablesorter.addWidget({id:"uitheme",format:function(e){var b,a,g,j,h,d=e.config,f=c(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&&(b=new Date);f.is(".ui-theme")||(f.addClass("ui-widget ui-widget-content ui-corner-all ui-theme"),c.each(d.headerList,function(){c(this).addClass("ui-widget-header ui-corner-all").append('<span class="ui-icon"/>').hover(function(){c(this).addClass("ui-state-hover")}, function(){c(this).removeClass("ui-state-hover")})}));c.each(d.headerList,function(b){j=c(this);d.headers[b]&&!1===d.headers[b].sorter?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(b).add(j):j,h[a===i[0]?"removeClass":"addClass"]("ui-state-active").find("span.ui-icon").removeClass(g).addClass(a))});d.debug&&c.tablesorter.benchmark("Applying uitheme widget", b)}});
c.tablesorter.addWidget({id:"columns",format:function(e){var b,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]&&c("tr:visible",e.tBodies[0]).each(function(a){b=c(this).children().removeClass(j);b.eq(d[0][0]).addClass(i[0]);if(1<f)for(a=1;a<f;a++)b.eq(d[a][0]).addClass(i[a]||i[g])});h.debug&&c.tablesorter.benchmark("Applying Columns widget", a)}});
c.tablesorter.addWidget({id:"filter",format:function(e){if(!e.config.filtering){var b,a,g,j,h,d,f=e.config,i=f.headerList.length,k=c(e),e='<tr class="filters">',l;f.debug&&(l=new Date);for(b=0;b<i;b++)e+='<td><input type="text" class="filter" data-col="'+b+'" style="',e+=f.headers[b]&&"filter"in f.headers[b]&&!1===f.headers[b].filter||c(f.headerList[b]).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(c(this).val()|| "").toLowerCase()}).get();""===a.join("")?k.find("tr").show():k.find("tbody").find("tr:not(.expand-child)").each(function(){g=!0;h=c(this).nextUntil("tr:not(.expand-child)");j=h.length&&("undefined"!==typeof f.widgetFilterChildRows?f.widgetFilterChildRows:1)?h.text():"";d=c(this).find("td");for(b=0;b<i;b++)""!==a[b]&&0<=(d.eq(b).text()+j).toLowerCase().indexOf(a[b])?g=g?!0:!1:""!==a[b]&&(g=!1);c(this)[g?"show":"hide"]();if(h.length)h[g?"show":"hide"]()});k.trigger("applyWidgets")});f.filtering=!0; f.debug&&c.tablesorter.benchmark("Applying Filter widget",l)}}});
c.tablesorter.addWidget({id:"stickyHeaders",format:function(e){if(!c(e).hasClass("hasStickyHeaders")){var b=c(e).addClass("hasStickyHeaders"),a=c(window),g=c(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;b.bind("sortEnd",function(a,b){var d=c(b).find("thead tr"),f=d.filter(".stickyHeader").children();d.filter(":not(.stickyHeader)").children().each(function(a){f.eq(a).attr("class",c(this).attr("class"))})});j.each(function(a){var b=c(this);i.eq(a).width(b.width()).bind("click",function(a){b.trigger(a)}).bind("mousedown",function(){this.onselectstart=function(){return!1};return!1})});g.prepend(f);a.scroll(function(){var c=h.offset(),d=a.scrollTop(),d=d>c.top&&d<c.top+b.find("tbody").height()? "visible":"hidden";f.css({left:c.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){c(this).width(j.eq(a).width())})})}}});
c.tablesorter.addWidget({id:"resizable",format:function(e){if(!e.config.resizable){var b,a=e.config,g=a.headerList,j=g.length,h=function(){a.resizable_position=0;a.resizable_target=null;c(window).trigger("resize")};a.resizable_target=null;a.resizable_position=0; for(b=1;b<j;b++)c(g[b]).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=c(d.target).closest("th");a.resizable_position=d.pageX}).end().bind("mousemove",function(d){if(!(0===a.resizable_position||null===typeof a.resizable_target)){var c=d.pageX-a.resizable_position,b=a.resizable_target.closest("th").prev(); if(!(a.resizable_target.width()<-c||b&&b.width()<=c))b.width(b.width()+c),a.resizable_position=d.pageX}}).bind("mouseup",function(){h();return!1});c(e).find("thead").bind("mouseup mouseleave",function(){h()});a.resizable=!0}}})
})(jQuery);

View File

@ -1,6 +1,6 @@
{
"name": "tablesorter",
"version": "2.0.24",
"version": "2.0.25",
"title": "tablesorter",
"author": {
"name": "Christian Bach",