Permalink
Browse files

empty cell sorting & aligned sticky headers

  • Loading branch information...
1 parent 9b6f38a commit 95311a78eef1d49bdded082d9bfcdcb302318d7a @Mottie committed Dec 13, 2011
View
@@ -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.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).
+* Updated the sticky header widget to line up properly with the UI theme. Fix for [issue #13](https://github.com/Mottie/tablesorter/issues/13).
+
####Version 2.0.23.5 (2011-12-6)
* Updated the sticky header widget again to not interfere with the filter widget. Fix for [issue #10](https://github.com/Mottie/tablesorter/issues/10).
View
@@ -1,5 +1,11 @@
TableSorter Change Log
+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).
+* Updated the sticky header widget to line up properly with the UI theme. Fix for [issue #13](https://github.com/Mottie/tablesorter/issues/13).
+
Version 2.0.23.5 (2011-12-6)
============================
View
@@ -14,7 +14,7 @@ table.tablesorter thead tr th, tr.stickyHeader th, table.tablesorter tfoot tr th
background-color: #e6eeee;
border-collapse: collapse;
font-size: 8pt;
- padding: 4px;
+ padding: 4px 20px 4px 4px;
}
table.tablesorter thead tr .header, tr.stickyHeader .header {
background-image: url(black-bg.gif);
View
@@ -16,6 +16,7 @@ table.tablesorter thead tr .header {
background-repeat: no-repeat;
background-position: center right;
cursor: pointer;
+ white-space: normal;
}
table.tablesorter tbody td {
padding: 4px;
View
@@ -5,7 +5,7 @@
<title>jQuery plugin: Tablesorter 2.0</title>
<!-- jQuery -->
-<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
+<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<!-- Demo stuff -->
<link rel="stylesheet" href="css/jq.css">
@@ -20,7 +20,7 @@
$(function() {
$("#tablesorter-demo").tablesorter({sortList:[[0,0],[2,1]],widgets:['zebra']});
$("#options").tablesorter({sortList:[[0,0]],headers:{3:{sorter:false},4:{sorter:false}}});
- $("#methods,#events").tablesorter({sortList: [[0,0]],headers:{1:{sorter:false},2:{sorter:false}}});
+ $("#methods,#events").tablesorter({sortList:[[0,0]],headers:{1:{sorter:false},2:{sorter:false}}});
});
</script>
</head>
@@ -36,7 +36,7 @@
</div>
<p>
<strong>Author:</strong> <a class="external" href="http://lovepeacenukes.com">Christian Bach</a><br>
- <strong>Version:</strong> <a href="http://github.com/Mottie/tablesorter/downloads">2.0.23.1</a> (forked from <a href="http://tablesorter.com/docs/">version 2.0.5</a>, <a href="../changelog.txt">changelog</a>)<br>
+ <strong>Version:</strong> <a class="current-version" href="http://github.com/Mottie/tablesorter/downloads">2.0+</a> (forked from <a href="http://tablesorter.com/docs/">version 2.0.5</a>, <a href="../changelog.txt">changelog</a>)<br>
<strong>Licence:</strong>
Dual licensed under <a class="external" href="http://www.opensource.org/licenses/mit-license.php">MIT</a>
or <a class="external" href="http://www.opensource.org/licenses/gpl-license.php">GPL</a> licenses.
View
@@ -47,6 +47,14 @@ $(function(){
return false;
});
+ // update version number
+ var t = $('.current-version');
+ if (t.length) {
+ $.getJSON('../package.json', function(data) {
+ t.html(data.version || '2.0+');
+ });
+ }
+
});
$(window).load(function(){
View
@@ -8,7 +8,7 @@
<link href="docs/css/jq.css" rel="stylesheet">
<!-- jQuery: required (tablesorter works with jQuery 1.2.3+) -->
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<!-- Pick a theme, load the plugin & initialize plugin -->
<link href="css/blue/style.css" rel="stylesheet">
@@ -1,6 +1,6 @@
/*
* TableSorter 2.0 - Client-side table sorting with ease!
-* Version 2.0.23
+* Version 2.0.24
* @requires jQuery v1.2.3
*
* Copyright (c) 2007 Christian Bach
@@ -74,6 +74,7 @@
* @name tablesorter
* @cat Plugins/Tablesorter
* @author Christian Bach/christian.bach@polyester.se
+* @contributor Rob Garrison/https://github.com/Mottie/tablesorter
*/
(function($){
$.extend({
@@ -235,7 +236,7 @@
row: [],
normalized: []
},
- i, j, c, cols, cacheTime;
+ t, i, j, c, cols, cacheTime;
if (table.config.debug) {
cacheTime = new Date();
}
@@ -251,11 +252,12 @@
}
cache.row.push(c);
for (j = 0; j < totalCells; ++j) {
- cols.push(parsers[j].format(getElementText(table.config, c[0].cells[j], j), table, c[0].cells[j], j));
+ t = getElementText(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));
}
cols.push(cache.normalized.length); // add position for rowCache
cache.normalized.push(cols);
- cols = null;
}
if (table.config.debug) {
benchmark("Building cache for " + totalRows + " rows:", cacheTime);
@@ -310,7 +312,6 @@
if (c.appender) {
c.appender(table, rows);
}
- rows = null;
if (c.debug) {
benchmark("Rebuilt table:", appendTime);
}
@@ -529,8 +530,10 @@
// Natural sort modified from: http://www.webdeveloper.com/forum/showthread.php?t=107909
function sortText(a, b) {
- if ($.data(tbl[0], "tablesorter").sortLocaleCompare) { return a.localeCompare(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 cnt = 0, ax, t, x = /^(\.)?\d/,
L = Math.min(a.length, b.length) + 1;
@@ -557,6 +560,9 @@
}
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);
}
@@ -565,7 +571,6 @@
// so the text is somewhat sorted when using a digital sort
// this is NOT an alphanumeric sort
function getTextValue(a, mx, d){
- if (a === '') { return (d || 0) * Number.MAX_VALUE; }
if (mx) {
// make sure the text value is greater than the max numerical value (mx)
var i, l = a.length, n = mx + d;
@@ -578,14 +583,18 @@
}
function sortNumeric(a, b, mx, d) {
- if (a === '' || isNaN(a)) { a = getTextValue(a, mx, d); }
- if (b === '' || isNaN(b)) { b = getTextValue(b, mx, d); }
+ if (a === '') { return 1; }
+ if (b === '') { return -1; }
+ if (isNaN(a)) { a = getTextValue(a, mx, d); }
+ if (isNaN(b)) { b = getTextValue(b, mx, d); }
return a - b;
}
function sortNumericDesc(a, b, mx, d) {
- if (a === '' || isNaN(a)) { a = getTextValue(a, mx, d); }
- if (b === '' || isNaN(b)) { b = getTextValue(b, mx, d); }
+ if (a === '') { return 1; }
+ if (b === '') { return -1; }
+ if (isNaN(a)) { a = getTextValue(a, mx, d); }
+ if (isNaN(b)) { b = getTextValue(b, mx, d); }
return b - a;
}
Oops, something went wrong.
@@ -1,4 +1,4 @@
-/* TableSorter 2.0 Widgets - updated 12/6/2011
+/* TableSorter 2.0 Widgets - updated 12/12/2011
*
* jQuery UI Theme
* Column Styles
@@ -28,12 +28,12 @@ $.tablesorter.addWidget({
$(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){
@@ -158,14 +158,16 @@ $.tablesorter.addWidget({
win = $(window),
header = $(table).find('thead'),
hdrCells = header.find('tr').children(),
+ firstCell = hdrCells.eq(0),
brdr = parseInt(hdrCells.eq(0).css('border-left-width'),10),
sticky = header.find('tr:not(.filters)').clone()
.addClass('stickyHeader')
.css({
width : header.outerWidth() + brdr * 2,
position : 'fixed',
- top : 0,
+ left : firstCell.offset().left,
marginLeft : -brdr,
+ top : 0,
visibility : 'hidden',
zIndex : 10
}),
@@ -199,7 +201,7 @@ $.tablesorter.addWidget({
// make it sticky!
win
.scroll(function(){
- var offset = $table.offset(),
+ var offset = firstCell.offset(),
sTop = win.scrollTop(),
vis = ((sTop > offset.top) && (sTop < offset.top + $table.find('tbody').height())) ? 'visible' : 'hidden';
sticky.css({
@@ -214,7 +216,7 @@ $.tablesorter.addWidget({
})
.resize(function(){
sticky.css({
- left : $(table).offset().left - win.scrollLeft(),
+ left : firstCell.offset().left - win.scrollLeft(),
width: header.outerWidth() + brdr * 2
});
stkyCells.each(function(i){
Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 95311a7

Please sign in to comment.