Skip to content

Commit d59b7f4

Browse files
committed
Update tablesorter to latest version (2.28.10)
1 parent f020142 commit d59b7f4

File tree

8 files changed

+123
-50
lines changed

8 files changed

+123
-50
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
===
33

4+
#### v1.23.10 (2017-05-17)
5+
6+
* Upgrade tablesorter to v2.28.10
7+
48
#### v1.23.9 (2017-05-05)
59

610
* Upgrade tablesorter to v2.28.9

README.md

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

55
Simple integration of jQuery tablesorter ([Mottie's fork]) into the asset pipeline.
66

7-
Current tablesorter version: 2.28.9 (5/3/2017), [documentation]
7+
Current tablesorter version: 2.28.10 (5/16/2017), [documentation]
88

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

lib/jquery-tablesorter/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module JqueryTablesorter
22
MAJOR = 1
33
MINOR = 23
4-
TINY = 9
4+
TINY = 10
55

66
VERSION = [MAJOR, MINOR, TINY].compact.join('.')
77
end

tablesorter

Submodule tablesorter updated 76 files

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

+18-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀██
55
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
66
*/
7-
/*! tablesorter (FORK) - updated 05-03-2017 (v2.28.9)*/
7+
/*! tablesorter (FORK) - updated 05-16-2017 (v2.28.10)*/
88
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
99
(function(factory) {
1010
if (typeof define === 'function' && define.amd) {
@@ -16,7 +16,7 @@
1616
}
1717
}(function(jQuery) {
1818

19-
/*! TableSorter (FORK) v2.28.9 *//*
19+
/*! TableSorter (FORK) v2.28.10 *//*
2020
* Client-side table sorting with ease!
2121
* @requires jQuery v1.2.6+
2222
*
@@ -40,7 +40,7 @@
4040
'use strict';
4141
var ts = $.tablesorter = {
4242

43-
version : '2.28.9',
43+
version : '2.28.10',
4444

4545
parsers : [],
4646
widgets : [],
@@ -272,11 +272,6 @@
272272
if ( !/tablesorter\-/.test( $table.attr( 'class' ) ) ) {
273273
tmp = ( c.theme !== '' ? ' tablesorter-' + c.theme : '' );
274274
}
275-
c.table = table;
276-
c.$table = $table
277-
.addClass( ts.css.table + ' ' + c.tableClass + tmp )
278-
.attr( 'role', 'grid' );
279-
c.$headers = $table.find( c.selectorHeaders );
280275

281276
// give the table a unique id, which will be used in namespace binding
282277
if ( !c.namespace ) {
@@ -286,6 +281,14 @@
286281
c.namespace = '.' + c.namespace.replace( ts.regex.nonWord, '' );
287282
}
288283

284+
c.table = table;
285+
c.$table = $table
286+
// add namespace to table to allow bindings on extra elements to target
287+
// the parent table (e.g. parser-input-select)
288+
.addClass( ts.css.table + ' ' + c.tableClass + tmp + ' ' + c.namespace.slice(1) )
289+
.attr( 'role', 'grid' );
290+
c.$headers = $table.find( c.selectorHeaders );
291+
289292
c.$table.children().children( 'tr' ).attr( 'role', 'row' );
290293
c.$tbodies = $table.children( 'tbody:not(.' + c.cssInfoBlock + ')' ).attr({
291294
'aria-live' : 'polite',
@@ -1304,6 +1307,12 @@
13041307
},
13051308

13061309
updateCell : function( c, cell, resort, callback ) {
1310+
// updateCell for child rows is a mess - we'll ignore them for now
1311+
// eventually I'll break out the "update" row cache code to make everything consistent
1312+
if ( $( cell ).closest( 'tr' ).hasClass( c.cssChildRow ) ) {
1313+
console.warn('Tablesorter Warning! "updateCell" for child row content has been disabled, use "update" instead');
1314+
return;
1315+
}
13071316
if ( ts.isEmptyObject( c.cache ) ) {
13081317
// empty table, do an update instead - fixes #1099
13091318
ts.updateHeader( c );
@@ -2522,6 +2531,7 @@
25222531
.unbind( ( 'mousedown mouseup keypress '.split( ' ' ).join( c.namespace + ' ' ) ).replace( ts.regex.spaces, ' ' ) );
25232532
ts.restoreHeaders( table );
25242533
$t.toggleClass( ts.css.table + ' ' + c.tableClass + ' tablesorter-' + c.theme, removeClasses === false );
2534+
$t.removeClass(c.namespace.slice(1));
25252535
// clear flag in case the plugin is initialized again
25262536
table.hasInitialized = false;
25272537
delete table.config.cache;

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

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! TableSorter (FORK) v2.28.9 *//*
1+
/*! TableSorter (FORK) v2.28.10 *//*
22
* Client-side table sorting with ease!
33
* @requires jQuery v1.2.6+
44
*
@@ -22,7 +22,7 @@
2222
'use strict';
2323
var ts = $.tablesorter = {
2424

25-
version : '2.28.9',
25+
version : '2.28.10',
2626

2727
parsers : [],
2828
widgets : [],
@@ -254,11 +254,6 @@
254254
if ( !/tablesorter\-/.test( $table.attr( 'class' ) ) ) {
255255
tmp = ( c.theme !== '' ? ' tablesorter-' + c.theme : '' );
256256
}
257-
c.table = table;
258-
c.$table = $table
259-
.addClass( ts.css.table + ' ' + c.tableClass + tmp )
260-
.attr( 'role', 'grid' );
261-
c.$headers = $table.find( c.selectorHeaders );
262257

263258
// give the table a unique id, which will be used in namespace binding
264259
if ( !c.namespace ) {
@@ -268,6 +263,14 @@
268263
c.namespace = '.' + c.namespace.replace( ts.regex.nonWord, '' );
269264
}
270265

266+
c.table = table;
267+
c.$table = $table
268+
// add namespace to table to allow bindings on extra elements to target
269+
// the parent table (e.g. parser-input-select)
270+
.addClass( ts.css.table + ' ' + c.tableClass + tmp + ' ' + c.namespace.slice(1) )
271+
.attr( 'role', 'grid' );
272+
c.$headers = $table.find( c.selectorHeaders );
273+
271274
c.$table.children().children( 'tr' ).attr( 'role', 'row' );
272275
c.$tbodies = $table.children( 'tbody:not(.' + c.cssInfoBlock + ')' ).attr({
273276
'aria-live' : 'polite',
@@ -1286,6 +1289,12 @@
12861289
},
12871290

12881291
updateCell : function( c, cell, resort, callback ) {
1292+
// updateCell for child rows is a mess - we'll ignore them for now
1293+
// eventually I'll break out the "update" row cache code to make everything consistent
1294+
if ( $( cell ).closest( 'tr' ).hasClass( c.cssChildRow ) ) {
1295+
console.warn('Tablesorter Warning! "updateCell" for child row content has been disabled, use "update" instead');
1296+
return;
1297+
}
12891298
if ( ts.isEmptyObject( c.cache ) ) {
12901299
// empty table, do an update instead - fixes #1099
12911300
ts.updateHeader( c );
@@ -2504,6 +2513,7 @@
25042513
.unbind( ( 'mousedown mouseup keypress '.split( ' ' ).join( c.namespace + ' ' ) ).replace( ts.regex.spaces, ' ' ) );
25052514
ts.restoreHeaders( table );
25062515
$t.toggleClass( ts.css.table + ' ' + c.tableClass + ' tablesorter-' + c.theme, removeClasses === false );
2516+
$t.removeClass(c.namespace.slice(1));
25072517
// clear flag in case the plugin is initialized again
25082518
table.hasInitialized = false;
25092519
delete table.config.cache;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀██
55
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
66
*/
7-
/*! tablesorter (FORK) - updated 05-03-2017 (v2.28.9)*/
7+
/*! tablesorter (FORK) - updated 05-16-2017 (v2.28.10)*/
88
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
99
(function(factory) {
1010
if (typeof define === 'function' && define.amd) {

vendor/assets/javascripts/jquery-tablesorter/parsers/parser-input-select.js

+80-31
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Parser: input & select - updated 11/26/2016 (v2.28.0) *//*
1+
/*! Parser: input & select - updated 5/16/2017 (v2.28.10) *//*
22
* for jQuery 1.7+ & tablesorter 2.7.11+
33
* Demo: http://mottie.github.com/tablesorter/docs/example-widget-grouping.html
44
*/
@@ -131,31 +131,54 @@
131131
$row.removeClass( checkboxClass );
132132
}
133133
},
134+
updateCheckbox = function($el, state) {
135+
if ($el[0].nodeName !== 'INPUT') {
136+
$el = $el.find( 'input[type="checkbox"]' );
137+
}
138+
if ($el.length) {
139+
var ua = window.navigator.userAgent;
140+
if (state === 'indeterminate') {
141+
// needed for IE
142+
$el.prop('checked', !(ua.indexOf('Trident/') > -1 || ua.indexOf('Edge/') > -1));
143+
$el.prop('indeterminate', true);
144+
} else {
145+
$el.prop('checked', state);
146+
$el.prop('indeterminate', false);
147+
}
148+
}
149+
},
134150
updateHeaderCheckbox = function( $table, checkboxClass ) {
135-
var ua = window.navigator.userAgent,
136-
$rows = $table.children( 'tbody' ).children( ':visible' ), // (include child rows?)
137-
len = $rows.length;
151+
var $rows = $table.children( 'tbody' ).children( ':visible' ), // (include child rows?)
152+
len = $rows.length,
153+
hasSticky = $table[0].config.widgetOptions.$sticky;
138154
// set indeterminate state on header checkbox
139155
$table.children( 'thead' ).find( 'input[type="checkbox"]' ).each( function() {
140156
var column = $( this ).closest( 'td, th' ).attr( 'data-column' ),
157+
$sticky = hasSticky.find( '[data-column="' + column + '"]' ),
141158
vis = $rows.filter( '.' + checkboxClass + '-' + column ).length,
142159
allChecked = vis === len && len > 0;
143160
if ( vis === 0 || allChecked ) {
144-
this.checked = allChecked;
145-
this.indeterminate = false;
161+
updateCheckbox($(this), allChecked);
162+
if ($sticky) {
163+
updateCheckbox($sticky, allChecked);
164+
}
146165
} else {
147-
// needed for IE
148-
this.checked = !(ua.indexOf('Trident/') > -1 || ua.indexOf('Edge/') > -1);
149-
this.indeterminate = true;
166+
updateCheckbox($(this), 'indeterminate');
167+
if ($sticky) {
168+
updateCheckbox($sticky, 'indeterminate');
169+
}
150170
}
151171
});
172+
152173
};
153174

154175
$( 'table' ).on( 'tablesorter-initialized updateComplete', function() {
155176
this.tablesorterBusy = false;
156177
var namespace = '.parser-forms';
157-
// bind to .tablesorter (default class name)
158-
$( this ).children( 'tbody' )
178+
$( this )
179+
// add namespace to table in case of version mismatch (v2.28.10)
180+
.addClass( this.config.namespace.slice(1) )
181+
.children( 'tbody' )
159182
.off( namespace )
160183
.on( 'mouseleave' + namespace, function( event ) {
161184
// make sure we restore original values (trigger blur)
@@ -165,15 +188,30 @@
165188
$( ':focus' ).blur();
166189
}
167190
})
168-
.on( 'focus' + namespace, 'select, input:not([type=checkbox]), textarea', function() {
191+
.on( 'focus' + namespace, 'select, input:not([type=checkbox]), textarea', function( event ) {
192+
var $row = $( event.target ).closest( 'tr' ),
193+
c = $row.closest( 'table' )[0].config;
194+
if ( !c || c && c.ignoreChildRow && $row.hasClass( c.cssChildRow ) ) {
195+
return;
196+
}
169197
$( this ).data( 'ts-original-value', this.value );
170198
})
171-
.on( 'blur' + namespace, 'input:not([type=checkbox]), textarea', function() {
199+
.on( 'blur' + namespace, 'input:not([type=checkbox]), textarea', function( event ) {
200+
var $row = $( event.target ).closest( 'tr' ),
201+
c = $row.closest( 'table' )[0].config;
202+
if ( !c || c && c.ignoreChildRow && $row.hasClass( c.cssChildRow ) ) {
203+
return;
204+
}
172205
// restore input value;
173206
// 'change' is triggered before 'blur' so this doesn't replace the new update with the original
174207
this.value = $( this ).data( 'ts-original-value' );
175208
})
176209
.on( 'change keyup '.split( ' ' ).join( namespace + ' ' ), 'select, input, textarea', function( event ) {
210+
var $row = $( this ).closest( 'tr' ),
211+
c = $row.closest( 'table' )[0].config;
212+
if ( !c || c && c.ignoreChildRow && $row.hasClass( c.cssChildRow ) ) {
213+
return;
214+
}
177215
if ( event.which === 27 && !( this.nodeName === 'INPUT' && this.type === 'checkbox' ) ) {
178216
// escape: restore original value
179217
this.value = $( this ).data( 'ts-original-value' );
@@ -187,11 +225,9 @@
187225
$target = $( event.target ),
188226
isCheckbox = event.target.type === 'checkbox',
189227
$cell = $target.closest( 'td' ),
190-
$table = $cell.closest( 'table' ),
191228
indx = $cell[ 0 ].cellIndex,
192-
c = $table[ 0 ].config || false,
193-
busy = $table.length && $table[ 0 ].tablesorterBusy,
194-
$hdr = c && c.$headerIndexed && c.$headerIndexed[ indx ] || [],
229+
busy = c.table.tablesorterBusy,
230+
$hdr = c.$headerIndexed && c.$headerIndexed[ indx ] || [],
195231
val = isCheckbox ? event.target.checked : $target.val();
196232
// abort if not a tablesorter table, or busy
197233
if ( $.isEmptyObject( c ) || busy !== false ) {
@@ -200,7 +236,7 @@
200236
if ( isCheckbox ) {
201237
checkboxClass = c.checkboxClass || 'checked';
202238
toggleRowClass( $cell.closest( 'tr' ), checkboxClass, indx, val );
203-
updateHeaderCheckbox( $table, checkboxClass );
239+
updateHeaderCheckbox( c.$table, checkboxClass );
204240
}
205241
// don't use updateCell if column is set to 'sorter-false' and 'filter-false',
206242
// or column is set to 'parser-false'
@@ -213,11 +249,11 @@
213249
// ignore change event if nothing changed
214250
if ( c && val !== $target.data( 'ts-original-value' ) || isCheckbox ) {
215251
$target.data( 'ts-original-value', val );
216-
$table[ 0 ].tablesorterBusy = true;
252+
c.table.tablesorterBusy = true;
217253
// pass undefined resort value so it falls back to config.resort setting
218254
$.tablesorter.updateCell( c, $cell, undef, function() {
219-
updateServer( event, $table, $target );
220-
$table[ 0 ].tablesorterBusy = false;
255+
updateServer( event, c.$table, $target );
256+
c.table.tablesorterBusy = false;
221257
});
222258
}
223259
}
@@ -240,32 +276,45 @@
240276
}
241277
})
242278
.children( 'thead' )
279+
.add( this.config.widgetOptions.$sticky )
243280
.off( namespace )
244281
// modified from http://jsfiddle.net/abkNM/6163/
245282
// click needed for IE; a change isn't fired when going from an indeterminate checkbox to
246283
// either checked or unchecked
247284
.on( 'click' + namespace + ' change' + namespace, 'input[type="checkbox"]', function( event ) {
248-
var undef, onlyVisible, column, $target, isParsed, checkboxClass,
285+
var c, undef, onlyVisible, column, $target, isParsed, checkboxClass,
249286
$checkbox = $( this ),
287+
isChecked = this.checked,
250288
$table = $checkbox.closest( 'table' ),
251-
c = $table.length && $table[ 0 ].config,
252-
isChecked = this.checked;
289+
isSticky = $table.length && $table[0].className.match(/(tablesorter\w+)_extra_table/);
290+
if (isSticky) {
291+
isSticky = isSticky[1];
292+
$table = $('.' + isSticky + ':not(.' + isSticky + '_extra_table)');
293+
}
294+
c = $table.length && $table[ 0 ].config;
253295
if ( $table.length && c && !$table[ 0 ].tablesorterBusy ) {
254296
column = parseInt( $checkbox.closest( 'td, th' ).attr( 'data-column' ), 10 );
255297
isParsed = c.parsers[ column ].id === 'checkbox';
256-
onlyVisible = $table.length && c.checkboxVisible;
298+
onlyVisible = c.checkboxVisible;
257299
$table[ 0 ].tablesorterBusy = true; // prevent "change" event from calling updateCell numerous times (see #971)
258-
$target = $table
259-
.children( 'tbody' )
260-
.children( 'tr' + ( typeof onlyVisible === 'undefined' || onlyVisible === true ? ':visible' : '' ) )
261-
.children( ':nth-child(' + ( column + 1 ) + ')' )
262-
.find( 'input[type="checkbox"]' )
263-
.prop( 'checked', isChecked );
300+
updateCheckbox(
301+
$target = $table
302+
.children( 'tbody' )
303+
.children( 'tr' + ( typeof onlyVisible === 'undefined' || onlyVisible === true ? ':visible' : '' ) )
304+
.children( ':nth-child(' + ( column + 1 ) + ')' ),
305+
isChecked
306+
);
264307
// add checkbox class names to row
265308
checkboxClass = c.checkboxClass || 'checked';
266309
$target.each( function() {
267310
toggleRowClass( $( this ).closest( 'tr' ), checkboxClass, column, isChecked );
268311
});
312+
if (isSticky) {
313+
// make main table checkbox match sticky header checkbox
314+
updateCheckbox($table.children( 'thead' ).find( '[data-column="' + column + '"]' ), isChecked);
315+
} else if (c.widgetOptions.$sticky) {
316+
updateCheckbox(c.widgetOptions.$sticky.find( 'thead' ).find( '[data-column="' + column + '"]' ), isChecked);
317+
}
269318
updateHeaderCheckbox( $table, checkboxClass );
270319
if ( isParsed ) {
271320
// only update cache if checkboxes are being sorted

0 commit comments

Comments
 (0)