Skip to content

Commit 0eae812

Browse files
committed
Merge pull request #7 from dkarpenko/upgrade_to_2_7_5
Upgrade to 2.7.5
2 parents c6abf4d + 8715a18 commit 0eae812

10 files changed

+97
-73
lines changed

CHANGELOG.markdown

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Changelog
22
===
3+
#### v1.4.1
4+
5+
* Upgrade tablesorter to v2.7.5
6+
37
#### v1.4.0
48

59
* Upgrade tablesorter to v2.7.3

README.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Simple integration of jquery-tablesorter into the asset pipeline.
66

7-
Current tablesorter version: 2.7.3 (1/10/2013), [documentation]
7+
Current tablesorter version: 2.7.5 (2/5/2013), [documentation]
88

99
Any issue associate with the js/css files, please report to [Mottie's fork].
1010

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace :jquery_tablesorter do
1010
#
1111
javascript_dir = 'vendor/assets/javascripts/jquery-tablesorter'
1212
FileUtils.mkdir_p(javascript_dir)
13-
Dir.glob('tablesorter/js/*.js').each do |file|
13+
Dir.glob('tablesorter/js/*.js').reject{ |file| file =~ /.min.js\Z/}.each do |file|
1414
FileUtils.cp file, javascript_dir, :verbose => true
1515
end
1616

lib/jquery-tablesorter/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module JqueryTablesorter
2-
VERSION = "1.4.0"
2+
VERSION = "1.4.1"
33
end

tablesorter

Submodule tablesorter updated 75 files

vendor/assets/javascripts/jquery-tablesorter/addons/pager/jquery.tablesorter.pager.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* tablesorter pager plugin
3-
* updated 1/4/2013
3+
* updated 1/29/2013
44
*/
55
/*jshint browser:true, jquery:true, unused:false */
66
;(function($) {
@@ -138,7 +138,7 @@
138138
if (h) {
139139
d = h - $b.height();
140140
if ( d > 5 && $.data(table, 'pagerLastSize') === c.size && $b.children('tr:visible').length < c.size ) {
141-
$b.append('<tr class="pagerSavedHeightSpacer ' + table.config.selectorRemove.replace('.','') + '" style="height:' + d + 'px;"></tr>');
141+
$b.append('<tr class="pagerSavedHeightSpacer ' + table.config.selectorRemove.replace(/(tr)?\./g,'') + '" style="height:' + d + 'px;"></tr>');
142142
}
143143
}
144144
}
@@ -188,9 +188,8 @@
188188
var i, j, hsh, $f, $sh,
189189
$t = $(table),
190190
tc = table.config,
191-
$b = c.$tbodies,
192191
hl = $t.find('thead th').length, tds = '',
193-
err = '<tr class="' + c.cssErrorRow + ' ' + tc.selectorRemove.replace('.','') + '"><td style="text-align: center;" colspan="' + hl + '">' +
192+
err = '<tr class="' + c.cssErrorRow + ' ' + tc.selectorRemove.replace(/(tr)?\./g,'') + '"><td style="text-align: center;" colspan="' + hl + '">' +
194193
(exception ? exception.message + ' (' + exception.name + ')' : 'No rows found') + '</td></tr>',
195194
result = c.ajaxProcessing(data) || [ 0, [] ],
196195
d = result[1] || [],
@@ -234,7 +233,7 @@
234233
// add error row to thead instead of tbody, or clicking on the header will result in a parser error
235234
$t.find('thead').append(err);
236235
} else {
237-
$b.html( tds ); // add tbody
236+
$(table.tBodies[0]).html( tds ); // add rows to first tbody
238237
}
239238
if (tc.showProcessing) {
240239
$.tablesorter.isProcessing(table); // remove loading icon
@@ -453,7 +452,7 @@
453452
config.appender = $this.appender;
454453

455454
$t
456-
.unbind('filterStart.pager filterEnd.pager sortEnd.pager disable.pager enable.pager destroy.pager update.pager')
455+
.unbind('filterStart.pager filterEnd.pager sortEnd.pager disable.pager enable.pager destroy.pager update.pager pageSize.pager')
457456
.bind('filterStart.pager', function(e, filters) {
458457
$.data(table, 'pagerUpdateTriggered', false);
459458
c.currentFilters = filters;
@@ -481,6 +480,11 @@
481480
})
482481
.bind('update.pager', function(){
483482
hideRows(table, c);
483+
})
484+
.bind('pageSize.pager', function(e,v){
485+
c.size = parseInt(v, 10) || 10;
486+
hideRows(table, c);
487+
updatePageDisplay(table, c);
484488
});
485489

486490
// clicked controls

vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.js

+33-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* TableSorter 2.7.3 - Client-side table sorting with ease!
2+
* TableSorter 2.7.5 - Client-side table sorting with ease!
33
* @requires jQuery v1.2.6+
44
*
55
* Copyright (c) 2007 Christian Bach
@@ -24,7 +24,7 @@
2424

2525
var ts = this;
2626

27-
ts.version = "2.7.3";
27+
ts.version = "2.7.5";
2828

2929
ts.parsers = [];
3030
ts.widgets = [];
@@ -160,7 +160,7 @@
160160
}
161161
}
162162
for (i = 1; i < l; i++) {
163-
if (ts.parsers[i].is(nodeValue, table, node)) {
163+
if (ts.parsers[i].is && ts.parsers[i].is(nodeValue, table, node)) {
164164
return ts.parsers[i];
165165
}
166166
}
@@ -170,7 +170,8 @@
170170

171171
function buildParserCache(table) {
172172
var c = table.config,
173-
tb = c.$tbodies,
173+
// update table bodies in case we start with an empty table
174+
tb = c.$tbodies = c.$table.children('tbody:not(.' + c.cssInfoBlock + ')'),
174175
rows, list, l, i, h, ch, p, parsersDebug = "";
175176
if ( tb.length === 0) {
176177
return c.debug ? log('*Empty table!* Not building a parser cache') : '';
@@ -322,6 +323,7 @@
322323
function computeThIndexes(t) {
323324
var matrix = [],
324325
lookup = {},
326+
cols = 0, // determine the number of columns
325327
trs = $(t).find('thead:eq(0), tfoot').children('tr'), // children tr in tfoot - see issue #196
326328
i, j, k, l, c, cells, rowIndex, cellId, rowSpan, colSpan, firstAvailCol, matrixrow;
327329
for (i = 0; i < trs.length; i++) {
@@ -343,6 +345,7 @@
343345
}
344346
}
345347
lookup[cellId] = firstAvailCol;
348+
cols = Math.max(firstAvailCol, cols);
346349
// add data-column
347350
$(c).attr({ 'data-column' : firstAvailCol }); // 'data-row' : rowIndex
348351
for (k = rowIndex; k < rowIndex + rowSpan; k++) {
@@ -356,6 +359,7 @@
356359
}
357360
}
358361
}
362+
t.config.columns = cols; // may not be accurate if # header columns !== # tbody columns
359363
return lookup;
360364
}
361365

@@ -443,14 +447,25 @@
443447
}
444448
}
445449

450+
// automatically add col group, and column sizes if set
446451
function fixColumnWidth(table) {
447-
if (table.config.widthFixed && $(table).find('colgroup').length === 0) {
448-
var colgroup = $('<colgroup>'),
449-
overallWidth = $(table).width();
450-
$("tr:first td", table.tBodies[0]).each(function() {
451-
colgroup.append($('<col>').css('width', parseInt(($(this).width()/overallWidth)*1000, 10)/10 + '%'));
452-
});
453-
$(table).prepend(colgroup);
452+
var $c, c = table.config,
453+
$cg = $('<colgroup>'),
454+
$cgo = c.$table.find('colgroup'),
455+
n = c.columns.length,
456+
overallWidth = c.$table.width();
457+
$("tr:first td", table.tBodies[0]).each(function(i) {
458+
$c = $('<col>');
459+
if (c.widthFixed) {
460+
$c.css('width', parseInt(($(this).width()/overallWidth)*1000, 10)/10 + '%');
461+
}
462+
$cg.append($c);
463+
});
464+
// replace colgroup contents
465+
if ($cgo.length) {
466+
$cgo.html( $cg.html() );
467+
} else {
468+
c.$table.prepend( $cg );
454469
}
455470
}
456471

@@ -564,6 +579,9 @@
564579
c.$tbodies = $this.children('tbody:not(.' + c.cssInfoBlock + ')');
565580
// build headers
566581
c.$headers = buildHeaders($t0);
582+
// fixate columns if the users supplies the fixedWidth option
583+
// do this after theme has been applied
584+
fixColumnWidth($t0);
567585
// try to auto detect column type, and store in tables config
568586
c.parsers = buildParserCache($t0);
569587
// build the cache for the tbody cells
@@ -703,7 +721,7 @@
703721
multisort($t0);
704722
appendToTable($t0);
705723
})
706-
.bind("update", function(e, resort, callback) {
724+
.bind("update updateRows", function(e, resort, callback) {
707725
// remove rows/elements before update
708726
$(c.selectorRemove, $t0).remove();
709727
// rebuild parsers
@@ -805,10 +823,6 @@
805823
ts.applyWidget($t0);
806824
}
807825

808-
// fixate columns if the users supplies the fixedWidth option
809-
// do this after theme has been applied
810-
fixColumnWidth($t0);
811-
812826
// show processesing icon
813827
if (c.showProcessing) {
814828
$this
@@ -1238,7 +1252,7 @@
12381252
ts.addParser({
12391253
id: "isoDate",
12401254
is: function(s) {
1241-
return (/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/).test(s);
1255+
return (/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/).test(s);
12421256
},
12431257
format: function(s, table) {
12441258
return ts.formatFloat((s !== "") ? (new Date(s.replace(/-/g, "/")).getTime() || "") : "", table);
@@ -1261,7 +1275,8 @@
12611275
id: "usLongDate",
12621276
is: function(s) {
12631277
// two digit years are not allowed cross-browser
1264-
return (/^[A-Z]{3,10}\.?\s+\d{1,2},?\s+(\d{4})(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?$/i).test(s);
1278+
// Jan 01, 2013 12:34:56 PM or 01 Jan 2013
1279+
return (/^[A-Z]{3,10}\.?\s+\d{1,2},?\s+(\d{4})(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?$/i).test(s) || (/^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i).test(s);
12651280
},
12661281
format: function(s, table) {
12671282
return ts.formatFloat( (new Date(s.replace(/(\S)([AP]M)$/i, "$1 $2")).getTime() || ''), table);

vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.min.js

-5
This file was deleted.

vendor/assets/javascripts/jquery-tablesorter/jquery.tablesorter.widgets.js

+46-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! tableSorter 2.4+ widgets - updated 1/10/2013
1+
/*! tableSorter 2.4+ widgets - updated 1/29/2013
22
*
33
* Column Styles
44
* Column Filters
@@ -810,14 +810,24 @@ $.tablesorter.addWidget({
810810
format: function(table){
811811
if ($(table).hasClass('hasResizable')) { return; }
812812
$(table).addClass('hasResizable');
813-
var t, j, s, $c, $cols,
813+
var $t, t, i, j, s, $c, $cols, w, tw,
814814
$tbl = $(table),
815815
c = table.config,
816816
wo = c.widgetOptions,
817817
position = 0,
818818
$target = null,
819819
$next = null,
820+
fullWidth = Math.abs($tbl.parent().width() - $tbl.width()) < 20,
820821
stopResize = function(){
822+
if ($.tablesorter.storage && $target){
823+
s[$target.index()] = $target.width();
824+
s[$next.index()] = $next.width();
825+
$target.width( s[$target.index()] );
826+
$next.width( s[$next.index()] );
827+
if (wo.resizable !== false){
828+
$.tablesorter.storage(table, 'tablesorter-resizable', s);
829+
}
830+
}
821831
position = 0;
822832
$target = $next = null;
823833
$(window).trigger('resize'); // will update stickyHeaders, just in case
@@ -831,8 +841,17 @@ $.tablesorter.addWidget({
831841
}
832842
}
833843
}
834-
$tbl.children('thead:first').find('tr').each(function(){
835-
$c = $(this).children();
844+
$t = $tbl.children('thead:first').children('tr');
845+
// add resizable-false class name to headers (across rows as needed)
846+
$t.children().each(function(){
847+
t = $(this);
848+
i = t.attr('data-column');
849+
j = $.tablesorter.getData( t, c.headers[i], 'resizable') === "false";
850+
$t.children().filter('[data-column="' + i + '"]').toggleClass('resizable-false', j);
851+
});
852+
// add wrapper inside each cell to allow for positioning of the resizable target block
853+
$t.each(function(){
854+
$c = $(this).children(':not(.resizable-false)');
836855
if (!$(this).find('.tablesorter-wrapper').length) {
837856
// Firefox needs this inner div to position the resizer correctly
838857
$c.wrapInner('<div class="tablesorter-wrapper" style="position:relative;height:100%;width:100%"></div>');
@@ -842,36 +861,37 @@ $.tablesorter.addWidget({
842861
});
843862
$cols
844863
.each(function(){
845-
t = $(this);
846-
j = parseInt(t.css('padding-right'), 10) + 8; // 8 is 1/2 of the 16px wide resizer
847-
t
864+
$t = $(this);
865+
j = parseInt($t.css('padding-right'), 10) + 10; // 8 is 1/2 of the 16px wide resizer grip
866+
t = '<div class="tablesorter-resizer" style="cursor:w-resize;position:absolute;z-index:1;right:-' + j +
867+
'px;top:0;height:100%;width:20px;"></div>';
868+
$t
848869
.find('.tablesorter-wrapper')
849-
.append('<div class="tablesorter-resizer" style="cursor:w-resize;position:absolute;height:100%;width:16px;right:-' + j + 'px;top:0;z-index:1;"></div>');
870+
.append(t);
850871
})
851872
.bind('mousemove.tsresize', function(e){
852873
// ignore mousemove if no mousedown
853874
if (position === 0 || !$target) { return; }
854875
// resize columns
855-
var w = e.pageX - position;
856-
$target.width( $target.width() + w );
857-
$next.width( $next.width() - w );
876+
w = e.pageX - position;
877+
tw = $target.width();
878+
$target.width( tw + w );
879+
if ($target.width() !== tw && fullWidth){
880+
$next.width( $next.width() - w );
881+
}
858882
position = e.pageX;
859883
})
860884
.bind('mouseup.tsresize', function(){
861-
if ($.tablesorter.storage && $target){
862-
s[$target.index()] = $target.width();
863-
s[$next.index()] = $next.width();
864-
if (wo.resizable !== false){
865-
$.tablesorter.storage(table, 'tablesorter-resizable', s);
866-
}
867-
}
868885
stopResize();
869886
})
870-
.find('.tablesorter-resizer')
887+
.find('.tablesorter-resizer,.tablesorter-resizer-grip')
871888
.bind('mousedown', function(e){
872889
// save header cell and mouse position; closest() not supported by jQuery v1.2.6
873-
$target = $(e.target).parents('th:last');
874-
$next = $target.next();
890+
$target = $(e.target).closest('th');
891+
t = c.$headers.filter('[data-column="' + $target.attr('data-column') + '"]');
892+
if (t.length > 1) { $target = $target.add(t); }
893+
// if table is not as wide as it's parent, then resize the table
894+
$next = e.shiftKey ? $target.parent().find('th:not(.resizable-false)').filter(':last') : $target.nextAll(':not(.resizable-false)').eq(0);
875895
position = e.pageX;
876896
});
877897
$tbl.find('thead:first')
@@ -894,16 +914,14 @@ $.tablesorter.addWidget({
894914
.unbind('mouseup.tsresize mouseleave.tsresize contextmenu.tsresize')
895915
.find('tr').children()
896916
.unbind('mousemove.tsresize mouseup.tsresize')
897-
.find('.tablesorter-wrapper').each(function(){
898-
$(this).find('.tablesorter-resizer').remove();
899-
$(this).replaceWith( $(this).contents() );
900-
});
917+
// don't remove "tablesorter-wrapper" as uitheme uses it too
918+
.find('.tablesorter-resizer,.tablesorter-resizer-grip').remove();
901919
$.tablesorter.resizableReset(table);
902920
}
903921
});
904922
$.tablesorter.resizableReset = function(table){
905-
$(table.config.headerList).width('auto');
906-
$.tablesorter.storage(table, 'tablesorter-resizable', {});
923+
$(table.config.headerList).filter(':not(.resizable-false)').css('width','');
924+
if ($.tablesorter.storage) { $.tablesorter.storage(table, 'tablesorter-resizable', {}); }
907925
};
908926

909927
// Save table sort widget
@@ -956,7 +974,7 @@ $.tablesorter.addWidget({
956974
},
957975
remove: function(table, c, wo){
958976
// clear storage
959-
$.tablesorter.storage( table, 'tablesorter-savesort', '' );
977+
if ($.tablesorter.storage) { $.tablesorter.storage( table, 'tablesorter-savesort', '' ); }
960978
}
961979
});
962980

0 commit comments

Comments
 (0)