diff --git a/README.markdown b/README.markdown index 172040e5..ec57f29a 100644 --- a/README.markdown +++ b/README.markdown @@ -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. diff --git a/changelog.txt b/changelog.txt index 19f0534a..29d183e7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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) ============================ diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index 5f4afcdd..abae44ee 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -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)); } diff --git a/js/jquery.tablesorter.min.js b/js/jquery.tablesorter.min.js index 61a61f33..f87d0cbc 100644 --- a/js/jquery.tablesorter.min.js +++ b/js/jquery.tablesorter.min.js @@ -1,7 +1,7 @@ /* * TableSorter 2.0 - Client-side table sorting with ease! -* Version 2.0.24 Minified using http://dean.edwards.name/packer/ +* Version 2.0.25 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").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;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(){c.append($('').css('width',$(this).width()))});$(a).prepend(c)}}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){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;i0){c.trigger("sorton",[config.sortList])}applyWidget(this)})};this.addParser=function(b){var i,l=g.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));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;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(){c.append($('').css('width',$(this).width()))});$(a).prepend(c)}}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){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;i0){c.trigger("sorton",[config.sortList])}applyWidget(this)})};this.addParser=function(b){var i,l=g.length,a=true;for(i=0;i') .hover(function(){ $(this).addClass('ui-state-hover'); }, function(){ $(this).removeClass('ui-state-hover'); - }) - .append(''); + }); }); } $.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(), diff --git a/js/jquery.tablesorter.widgets.min.js b/js/jquery.tablesorter.widgets.min.js index 9c67c623..62945219 100644 --- a/js/jquery.tablesorter.widgets.min.js +++ b/js/jquery.tablesorter.widgets.min.js @@ -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('')}));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',l;h.debug&&(l=new Date);for(c=0;c';k.find("thead").append(d+="").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;cb.top&&d').wrapInner('
').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('').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',l;f.debug&&(l=new Date);for(b=0;b';k.find("thead").append(e+="").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;bc.top&&d').wrapInner('
').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); \ No newline at end of file diff --git a/package.json b/package.json index 1dbd618b..717ca97f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tablesorter", - "version": "2.0.24", + "version": "2.0.25", "title": "tablesorter", "author": { "name": "Christian Bach",